Added SIGCHLD handling to avoid zombie processes.
[python-purple] / request_cbs.pxd
1 #
2 #  Copyright (c) 2008 INdT - Instituto Nokia de Tecnologia
3 #
4 #  This file is part of python-purple.
5 #
6 #  python-purple is free software: you can redistribute it and/or modify
7 #  it under the terms of the GNU General Public License as published by
8 #  the Free Software Foundation, either version 3 of the License, or
9 #  (at your option) any later version.
10 #
11 #  python-purple is distributed in the hope that it will be useful,
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 #  GNU General Public License for more details.
15 #
16 #  You should have received a copy of the GNU General Public License
17 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 #
19
20 cimport purple
21
22 cdef extern from *:
23     ctypedef char const_char "const char"
24     ctypedef int size_t
25     ctypedef void* va_list
26     char* charptr "char *"
27     glib.GCallback glibcb "GCallback"
28     void* va_arg(void *action, void *type)
29
30 request_cbs = {}
31
32 cdef request.PurpleRequestActionCb req_actions_cb[10]
33 cdef object req_actions_list = []
34 cdef void *req_action_user_data = NULL
35
36 cdef void *request_input(const_char *title, const_char *primary, \
37         const_char *secondary, const_char *default_value, \
38         glib.gboolean multiline, glib.gboolean masked, glib.gchar *hint, \
39         const_char *ok_text, glib.GCallback ok_cb, const_char *cancel_text, \
40         glib.GCallback cancel_cb, \
41         account.PurpleAccount *account, const_char *who, \
42         conversation.PurpleConversation *conv, void *user_data):
43     """
44     @see purple_request_input().
45     """
46     debug.purple_debug_info("request", "%s", "request-input\n")
47     if request_cbs.has_key("request-input"):
48         (<object> request_cbs["request-input"])("request-input: TODO")
49
50 cdef void *request_choice(const_char *title, const_char *primary, \
51         const_char *secondary, int default_value, const_char *ok_text, \
52         glib.GCallback ok_cb, const_char *cancel_text, \
53         glib.GCallback cancel_cb, account.PurpleAccount *account, \
54         const_char *who, conversation.PurpleConversation *conv, \
55         void *user_data, va_list choices):
56     """
57     @see purple_request_choice_varg().
58     """
59     debug.purple_debug_info("request", "%s", "request-choice\n")
60     if request_cbs.has_key("request-choice"):
61         (<object> request_cbs["request-choice"])("request-choice: TODO")
62
63 cdef void __call_action(int i):
64     global req_actions_cb
65     global req_actions_list
66     global req_action_user_data
67
68     cdef request.PurpleRequestActionCb cb 
69
70     if req_actions_list and len(req_actions_list) > i:
71         cb = req_actions_cb[i]
72         cb(req_action_user_data, i)
73
74 cdef void *request_action(const_char *title, const_char *primary, \
75         const_char *secondary, int default_action, \
76         account.PurpleAccount *account, const_char *who, \
77         conversation.PurpleConversation *conv, void *user_data, \
78         size_t action_count, va_list actions):
79     """
80     @see purple_request_action_varg().
81     """
82     global req_actions_cb
83     global req_actions_list
84     global req_action_user_data
85     cdef int i
86     cdef char *btn_txt
87     cdef void *cb
88
89     i = 0
90
91     req_action_user_data = user_data
92     req_actions_list = []
93
94     #FIXME: i < 10 max size to req_actions_cb
95     while i < action_count and i < 10:
96         btn_txt = <char *> va_arg(actions, charptr)
97         req_actions_cb[i] = <request.PurpleRequestActionCb> va_arg(actions, glibcb)
98         req_actions_list.append(btn_txt)
99         i = i + 1
100
101     debug.purple_debug_info("request", "%s", "request-action\n")
102     if request_cbs.has_key("request-action"):
103         (<object> request_cbs["request-action"])(<char *> title,
104                         <char *> primary, <char *> secondary,
105                         default_action, req_actions_list)
106
107 cdef void *request_fields(const_char *title, const_char *primary, \
108         const_char *secondary, request.PurpleRequestFields *fields, \
109         const_char *ok_text, glib.GCallback ok_cb, const_char *cancel_text, \
110         glib.GCallback cancel_cb, account.PurpleAccount *account, \
111         const_char *who, conversation.PurpleConversation *conv, \
112         void *user_data):
113     """
114     @see purple_request_fields().
115     """
116     debug.purple_debug_info("request", "%s", "request-fields\n")
117     if request_cbs.has_key("request-fields"):
118         (<object> request_cbs["request-fields"])("request-fields: TODO")
119
120 cdef void *request_file(const_char *title, const_char *filename, \
121         glib.gboolean savedialog, glib.GCallback ok_cb, \
122         glib.GCallback cancel_cb, account.PurpleAccount *account, \
123         const_char *who, conversation.PurpleConversation *conv, \
124         void *user_data):
125     """
126     @see purple_request_file().
127     """
128     debug.purple_debug_info("request", "%s", "request-file\n")
129     if request_cbs.has_key("request-file"):
130         (<object> request_cbs["request-file"])("request-file: TODO")
131
132 cdef void close_request(request.PurpleRequestType type, void *ui_handle):
133     """
134     TODO
135     """
136     debug.purple_debug_info("request", "%s", "close-request\n")
137     if request_cbs.has_key("close-request"):
138         (<object> request_cbs["close-request"])("close-request: TODO")
139
140 cdef void *request_folder(const_char *title, const_char *dirname, \
141         glib.GCallback ok_cb, glib.GCallback cancel_cb, \
142         account.PurpleAccount *account, const_char *who, \
143         conversation.PurpleConversation *conv, void *user_data):
144     """
145     @see purple_request_folder().
146     """
147     debug.purple_debug_info("request", "%s", "request-folder\n")
148     if request_cbs.has_key("request-folder"):
149         (<object> request_cbs["request-folder"])("request-folder: TODO")