[PythonCE] Smartphone 2003
Brad Clements
bkc at murkworks.com
Thu Dec 9 15:41:47 CET 2004
SipGetInfo() is a Python specific function in the CE glue module.
it's defined in win32gui.i, and here's the code fragment.
It looks to me like SipGetInfo is a real win32 function as well, defined in sipapi.h in the
windows ce toolkit.
--
/// FUNCTIONS FROM SIPAPI.H
DWORD SipStatus();
#define SIP_STATUS_UNAVAILABLE SIP_STATUS_UNAVAILABLE
#define SIP_STATUS_AVAILABLE SIP_STATUS_AVAILABLE
// BOOL SipSetDefaultRect(RECT *rect); // couldn't convert this
BOOLAPI SipRegisterNotification(HWND hwnd);
BOOLAPI SipShowIM(DWORD tf);
#define SIPF_OFF SIPF_OFF
#define SIPF_ON SIPF_ON
#define SIPF_DOCKED SIPF_DOCKED
#define SIPF_LOCKED SIPF_LOCKED
#define SPI_SETCOMPLETIONINFO SPI_SETCOMPLETIONINFO
#define SPI_SETSIPINFO SPI_SETSIPINFO
#define SPI_GETSIPINFO SPI_GETSIPINFO
#define SPI_SETCURRENTIM SPI_SETCURRENTIM
#define SPI_GETCURRENTIM SPI_GETCURRENTIM
%{
// SIPINFO object
class PySIPINFO : public PyObject {
public:
PySIPINFO(void);
~PySIPINFO();
SIPINFO m_sipInfo;
/* Python support */
static PyObject *meth_SetDialogProc(PyObject *self, PyObject *args);
static void deallocFunc(PyObject *ob);
static PyObject *getattr(PyObject *self, char *name);
static int setattr(PyObject *self, char *name, PyObject *v);
#pragma warning( disable : 4251 )
static struct memberlist memberlist[];
#pragma warning( default : 4251 )
};
#define PySIPINFO_Check(ob) ((ob)->ob_type == &PySIPINFOType)
// @object PySIPINFO|A Python object representing a SIPINFO structure
PyTypeObject PySIPINFOType =
{
PyObject_HEAD_INIT(&PyType_Type)
0,
"PySIPINFO",
sizeof(PySIPINFO),
0,
PySIPINFO::deallocFunc, /* tp_dealloc */
0, /* tp_print */
PySIPINFO::getattr, /* tp_getattr */
PySIPINFO::setattr, /* tp_setattr */
0, /* tp_compare */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0,
0, /* tp_call */
0, /* tp_str */
};
#undef OFF
#define OFF(e) offsetof(PySIPINFO, e)
/*static*/ struct memberlist PySIPINFO::memberlist[] = {
{"fdwFlags", T_INT, OFF(m_sipInfo.fdwFlags)}, // @prop integer|fdwFlags|
{"rcVisibleDesktop", T_OBJECT, OFF(m_sipInfo.rcVisibleDesktop)}, // @prop PyRECT|rcVisibleDesktop
{"rcSipRect", T_OBJECT, OFF(m_sipInfo.rcSipRect)}, // @prop PyRECT|rcSipRect
{NULL}
};
PySIPINFO::PySIPINFO(void)
{
ob_type = &PySIPINFOType;
_Py_NewReference(this);
memset(&m_sipInfo, 0, sizeof(m_sipInfo));
m_sipInfo.cbSize = sizeof(m_sipInfo);
}
PySIPINFO::~PySIPINFO(void)
{
}
PyObject *PySIPINFO::getattr(PyObject *self, char *name)
{
// PyObject *ret = Py_FindMethod(PyWNDCLASS_methods, self, name);
// if (ret != NULL)
// return ret;
// PyErr_Clear();
PySIPINFO *pW = (PySIPINFO *)self;
if (strcmp("rcVisibleDesktop", name)==0) {
PyObject *o;
o = Py_BuildValue("llll", pW->m_sipInfo.rcVisibleDesktop.left, pW->m_sipInfo.rcVisibleDesktop.top,
pW->m_sipInfo.rcVisibleDesktop.right, pW->m_sipInfo.rcVisibleDesktop.bottom);
return o;
}
return PyMember_Get((char *)self, memberlist, name);
}
int PySIPINFO::setattr(PyObject *self, char *name, PyObject *v)
{
if (v == NULL) {
PyErr_SetString(PyExc_AttributeError, "can't delete SIPINFO attributes");
return -1;
}
PySIPINFO *pW = (PySIPINFO *)self;
if (strcmp("rcVisibleDesktop", name)==0) {
RECT r;
if (PyTuple_Check(v) && PyArg_ParseTuple(v, "llll", &r.left, &r.top, &r.right, &r.bottom)) {
pW->m_sipInfo.rcVisibleDesktop = r;
return 0;
}
PyErr_SetString(PyExc_TypeError, "rcVisibleDesktop: This param must be a tuple of four integers");
return -1;
}
return PyMember_Set((char *)self, memberlist, name, v);
}
/*static*/ void PySIPINFO::deallocFunc(PyObject *ob)
{
delete (PySIPINFO *)ob;
}
static PyObject *MakeSIPINFO(PyObject *self, PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
return new PySIPINFO();
}
%}
%native (SIPINFO) MakeSIPINFO;
%{
// @pyswig int|SipGetInfo|Get SIP Info
static PyObject *PySipGetInfo(PyObject *self, PyObject *args)
{
PyObject *obwc;
// @pyparm <o PySIPINFO>|SipInfo||The SIPInfo object
if (!PyArg_ParseTuple(args, "O", &obwc))
return NULL;
if (!PySIPINFO_Check(obwc)) {
PyErr_SetString(PyExc_TypeError, "The object must be a SIPINFO object");
return NULL;
}
int bres = SipGetInfo(&((PySIPINFO *)obwc)->m_sipInfo);
PyObject *res = PyInt_FromLong(bres);
return res;
}
// @pyswig int|SipSetInfo|Set SIP Info
static PyObject *PySipSetInfo(PyObject *self, PyObject *args)
{
PyObject *obwc;
// @pyparm <o PySIPINFO>|SipInfo||The SIPInfo object
if (!PyArg_ParseTuple(args, "O", &obwc))
return NULL;
if (!PySIPINFO_Check(obwc)) {
PyErr_SetString(PyExc_TypeError, "The object must be a SIPINFO object");
return NULL;
}
int bres = SipSetInfo(&((PySIPINFO *)obwc)->m_sipInfo);
PyObject *res = PyInt_FromLong(bres);
return res;
}
%}
%native (SipGetInfo) PySipGetInfo;
%native (SipSetInfo) PySipSetInfo;
--
Brad Clements, bkc at murkworks.com (315)268-1000
http://www.murkworks.com (315)268-9812 Fax
http://www.wecanstopspam.org/ AOL-IM: BKClements
More information about the PythonCE
mailing list