Another source code. PY_MsgQuery is a simple modal popup with some extras features.
#include "Python.h"
#include <aknglobalnote.h>
#include <eiknotapi.h>
#include <aknglobalconfirmationquery.h>
#include <aknglobalmsgquery.h>
#include <akngloballistquery.h>
#include <e32std.h>
#include <e32base.h>
#include <badesca.h>
#include "globaluimodule.h"
#define TO_MILLISEC(s) (s)*1000*1000
#define OKOnly R_AVKON_SOFTKEYS_OK_EMPTY
#define OKCancel R_AVKON_SOFTKEYS_OK_CANCEL
#define OKBack R_AVKON_SOFTKEYS_OK_BACK
#define CancelOnly R_AVKON_SOFTKEYS_CANCEL
#define BackOnly R_AVKON_SOFTKEYS_BACK
#define CloseOnly R_AVKON_SOFTKEYS_CLOSE
#define YesNo R_AVKON_SOFTKEYS_YES_NO
/* TYPE METHODS */
extern "C" PyObject*
infopopup(PyObject* /*self*/, PyObject* args)
{
//TInt queryAnswer = 1;
char* querystr = NULL;
int querystr_l = 0;
char* headerstr = NULL;
int headerstr_l = 0;
TRequestStatus msgQueryStatus = KRequestPending;
TRequestStatus timerStatus = KRequestPending;
int delayInSeconds = 0;
int butType = 0;
TInt timeout = 0;
if(!PyArg_ParseTuple(args, "u#u#|i|i:infopopup", &querystr, &querystr_l, &headerstr, &headerstr_l, &butType, &delayInSeconds)){
return NULL;
}
/*
* Per v2 ho risolto splittando gli if
* altrimenti dava errore di compilazione
* SOLO durante il build per ARMI e THUMB
*/
#ifdef EKA2
if((butType != R_AVKON_SOFTKEYS_OK_EMPTY) and (butType != R_AVKON_SOFTKEYS_OK_CANCEL) and (butType != R_AVKON_SOFTKEYS_OK_BACK) and (butType != R_AVKON_SOFTKEYS_CANCEL) and (butType != R_AVKON_SOFTKEYS_BACK) and (butType != R_AVKON_SOFTKEYS_CLOSE) and (butType != R_AVKON_SOFTKEYS_YES_NO)){
butType=R_AVKON_SOFTKEYS_OK_CANCEL;
}
#else
if(butType == R_AVKON_SOFTKEYS_OK_EMPTY){
/* DO NOTHING */
} else {
if(butType == R_AVKON_SOFTKEYS_OK_CANCEL){
/* DO NOTHING */
} else {
if(butType == R_AVKON_SOFTKEYS_OK_BACK){
/* DO NOTHING */
} else {
if(butType == R_AVKON_SOFTKEYS_CANCEL){
/* DO NOTHING */
} else{
if(butType == R_AVKON_SOFTKEYS_BACK){
/* DO NOTHING */
} else {
if(butType == R_AVKON_SOFTKEYS_CLOSE){
/* DO NOTHING */
} else {
if(butType == R_AVKON_SOFTKEYS_YES_NO){
/* DO NOTHING */
} else {
butType=R_AVKON_SOFTKEYS_OK_CANCEL;
} } } } } } }
#endif
TPtrC query_str((TUint16*)querystr, querystr_l);
TPtrC header_str((TUint16*)headerstr, headerstr_l);
timeout = TO_MILLISEC(delayInSeconds);
TTimeIntervalMicroSeconds32 timeoutValue = TTimeIntervalMicroSeconds32(timeout);
CAknGlobalMsgQuery *msgQueryDialog = NULL;
TRAPD(err,
{
msgQueryDialog = CAknGlobalMsgQuery::NewL();
});
if(err != KErrNone){
RETURN_ERROR_OR_PYNONE(err);
}
CleanupStack::PushL(msgQueryDialog);
Py_BEGIN_ALLOW_THREADS
TRAPD(err,
{
msgQueryDialog->ShowMsgQueryL(msgQueryStatus,query_str,butType,header_str, KNullDesC);
});
Py_END_ALLOW_THREADS
if(err != KErrNone){
CleanupStack::PopAndDestroy(msgQueryDialog);
RETURN_ERROR_OR_PYNONE(err);
}
bool dialogTimedOut = false;
if (delayInSeconds > 0){
RTimer timer;
CleanupClosePushL(timer);
timer.CreateLocal();
timer.After(timerStatus,timeoutValue);
Py_BEGIN_ALLOW_THREADS
User::WaitForRequest(timerStatus,msgQueryStatus);
Py_END_ALLOW_THREADS
if (timerStatus != KRequestPending)
dialogTimedOut = true;
timer.Cancel();
msgQueryDialog->CancelMsgQuery();
CleanupStack::PopAndDestroy(); // calls timer.Close()
}
Py_BEGIN_ALLOW_THREADS
User::WaitForRequest(msgQueryStatus);
Py_END_ALLOW_THREADS
CleanupStack::PopAndDestroy(msgQueryDialog);
if (dialogTimedOut) {
Py_INCREF(Py_None);
return Py_None;
} else
return Py_BuildValue("i",
msgQueryStatus.Int() == EAknSoftkeyOk ? 1 : 0);
}
/* INIT */
extern "C" {
static const PyMethodDef globalui_methods[] = {
//{"global_note", (PyCFunction)global_note, METH_VARARGS, NULL},
//{"global_query", (PyCFunction)global_query, METH_VARARGS, NULL},
{"infopopup", (PyCFunction)infopopup, METH_VARARGS, NULL},
//{"global_popup_menu", (PyCFunction)global_popup_menu, METH_VARARGS, NULL},
{NULL, NULL}/* sentinel*/
};
DL_EXPORT(void) initglobalui(void)
{
PyObject *m, *d;
m = Py_InitModule("msgquery", (PyMethodDef*)globalui_methods);
d = PyModule_GetDict(m);
PyDict_SetItemString(d, "OKREmpty", PyInt_FromLong(OKOnly));
PyDict_SetItemString(d, "OKRCancel", PyInt_FromLong(OKCancel));
PyDict_SetItemString(d, "OKRBack", PyInt_FromLong(OKBack));
PyDict_SetItemString(d, "RCancel", PyInt_FromLong(CancelOnly));
PyDict_SetItemString(d, "RBack", PyInt_FromLong(BackOnly));
PyDict_SetItemString(d, "RClose", PyInt_FromLong(CloseOnly));
PyDict_SetItemString(d, "LYesRNo", PyInt_FromLong(YesNo));
}
} /* extern "C" */
#ifndef EKA2
GLDEF_C TInt E32Dll(TDllReason)
{
return KErrNone;
}
#endif
Example python usage:
from msgquery import infopopup,OKREmpty
infopopup('text body','title',OKREmpty)
As usually, if anyone want entire project, contact me. Thank you





