From: Ragner Magalhaes Date: Tue, 16 Dec 2008 13:14:24 +0000 (+0000) Subject: Fixing support to request_action callback X-Git-Url: http://git.maemo.org/git/?p=python-purple;a=commitdiff_plain;h=d398c7889a23b5055833c0438de8fac3a2424f80;hp=3453e9755aca10e51bb7ce6b7a665ee461aad1de Fixing support to request_action callback Fixing support to request_action callback Signed-off-by: Ragner Magalhaes Acked-by: Anderson Briglia git-svn-id: https://garage.maemo.org/svn/carman/branches/carman-0.7-beta2/python-purple@1721 596f6dd7-e928-0410-a184-9e12fd12cf7e --- diff --git a/libpurple/request.pxd b/libpurple/request.pxd index 9289520..ea7f576 100644 --- a/libpurple/request.pxd +++ b/libpurple/request.pxd @@ -61,6 +61,11 @@ cdef extern from "libpurple/request.h": ctypedef struct PurpleRequestField: pass + ctypedef void (*PurpleRequestActionCb)(void *, int) + ctypedef void (*PurpleRequestChoiceCb)(void *, int) + ctypedef void (*PurpleRequestFieldsCb)(void *, PurpleRequestFields *fields) + ctypedef void (*PurpleRequestFileCb)(void *, char *filename) + ctypedef struct PurpleRequestUiOps: void *(*request_input) (const_char *title, const_char *primary, const_char *secondary, diff --git a/purple.pyx b/purple.pyx index e32c963..5de7e43 100644 --- a/purple.pyx +++ b/purple.pyx @@ -429,6 +429,9 @@ cdef class Purple: iter = iter.next return protocol_list + def call_action(self, i): + __call_action(i) + include "protocol.pyx" #include "plugin.pyx" include "proxy.pyx" diff --git a/request_cbs.pxd b/request_cbs.pxd index 46af219..fd98e02 100644 --- a/request_cbs.pxd +++ b/request_cbs.pxd @@ -23,9 +23,16 @@ cdef extern from *: ctypedef char const_char "const char" ctypedef int size_t ctypedef void* va_list + char* charptr "char *" + glib.GCallback glibcb "GCallback" + void* va_arg(void *action, void *type) request_cbs = {} +cdef request.PurpleRequestActionCb req_actions_cb[10] +cdef object req_actions_list = [] +cdef void *req_action_user_data = NULL + cdef void *request_input(const_char *title, const_char *primary, \ const_char *secondary, const_char *default_value, \ glib.gboolean multiline, glib.gboolean masked, glib.gchar *hint, \ @@ -53,6 +60,17 @@ cdef void *request_choice(const_char *title, const_char *primary, \ if request_cbs.has_key("request-choice"): ( request_cbs["request-choice"])("request-choice: TODO") +cdef void __call_action(int i): + global req_actions_cb + global req_actions_list + global req_action_user_data + + cdef request.PurpleRequestActionCb cb + + if req_actions_list and len(req_actions_list) > i: + cb = req_actions_cb[i] + cb(req_action_user_data, i) + cdef void *request_action(const_char *title, const_char *primary, \ const_char *secondary, int default_action, \ account.PurpleAccount *account, const_char *who, \ @@ -61,9 +79,30 @@ cdef void *request_action(const_char *title, const_char *primary, \ """ @see purple_request_action_varg(). """ + global req_actions_cb + global req_actions_list + global req_action_user_data + cdef int i + cdef char *btn_txt + cdef void *cb + + i = 0 + + req_action_user_data = user_data + req_actions_list = [] + + #FIXME: i < 10 max size to req_actions_cb + while i < action_count and i < 10: + btn_txt = va_arg(actions, charptr) + req_actions_cb[i] = va_arg(actions, glibcb) + req_actions_list.append(btn_txt) + i = i + 1 + debug.purple_debug_info("request", "%s", "request-action\n") if request_cbs.has_key("request-action"): - ( request_cbs["request-action"])("request-action: TODo") + ( request_cbs["request-action"])( title, + primary, secondary, + default_action, req_actions_list) cdef void *request_fields(const_char *title, const_char *primary, \ const_char *secondary, request.PurpleRequestFields *fields, \