Removed unused/duplicated/deprecated includes.
[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 cdef extern from *:
21     ctypedef char const_char "const char"
22     ctypedef int size_t
23     ctypedef void* va_list
24     char* charptr "char *"
25     glib.GCallback glibcb "GCallback"
26     void* va_arg(void *action, void *type)
27
28 request_cbs = {}
29
30 cdef request.PurpleRequestActionCb req_actions_cb[10]
31 cdef object req_actions_list = []
32 cdef void *req_action_user_data = NULL
33
34 cdef void *request_input(const_char *title, const_char *primary, \
35         const_char *secondary, const_char *default_value, \
36         glib.gboolean multiline, glib.gboolean masked, glib.gchar *hint, \
37         const_char *ok_text, glib.GCallback ok_cb, const_char *cancel_text, \
38         glib.GCallback cancel_cb, \
39         account.PurpleAccount *account, const_char *who, \
40         conversation.PurpleConversation *conv, void *user_data):
41     """
42     @see purple_request_input().
43     """
44     debug.purple_debug_info("request", "%s", "request-input\n")
45     if "request-input" in request_cbs:
46         (<object> request_cbs["request-input"])("request-input: TODO")
47
48 cdef void *request_choice(const_char *title, const_char *primary, \
49         const_char *secondary, int default_value, const_char *ok_text, \
50         glib.GCallback ok_cb, const_char *cancel_text, \
51         glib.GCallback cancel_cb, account.PurpleAccount *account, \
52         const_char *who, conversation.PurpleConversation *conv, \
53         void *user_data, va_list choices):
54     """
55     @see purple_request_choice_varg().
56     """
57     debug.purple_debug_info("request", "%s", "request-choice\n")
58     if "request-choice" in request_cbs:
59         (<object> request_cbs["request-choice"])("request-choice: TODO")
60
61 cdef void __call_action(int i):
62     global req_actions_cb
63     global req_actions_list
64     global req_action_user_data
65
66     cdef request.PurpleRequestActionCb cb 
67
68     if req_actions_list and len(req_actions_list) > i:
69         cb = req_actions_cb[i]
70         cb(req_action_user_data, i)
71
72 cdef void *request_action(const_char *title, const_char *primary, \
73         const_char *secondary, int default_action, \
74         account.PurpleAccount *account, const_char *who, \
75         conversation.PurpleConversation *conv, void *user_data, \
76         size_t action_count, va_list actions):
77     """
78     @see purple_request_action_varg().
79     """
80     global req_actions_cb
81     global req_actions_list
82     global req_action_user_data
83     cdef int i
84     cdef char *btn_txt
85     cdef void *cb
86
87     i = 0
88
89     req_action_user_data = user_data
90     req_actions_list = []
91
92     #FIXME: i < 10 max size to req_actions_cb
93     while i < action_count and i < 10:
94         btn_txt = <char *> va_arg(actions, charptr)
95         req_actions_cb[i] = <request.PurpleRequestActionCb> va_arg(actions, glibcb)
96         req_actions_list.append(btn_txt)
97         i = i + 1
98
99     debug.purple_debug_info("request", "%s", "request-action\n")
100     if "request-action" in request_cbs:
101         (<object> request_cbs["request-action"]) \
102             (<char *> title, <char *> primary, <char *> secondary, \
103             default_action, req_actions_list)
104
105 cdef void *request_fields(const_char *title, const_char *primary, \
106         const_char *secondary, request.PurpleRequestFields *fields, \
107         const_char *ok_text, glib.GCallback ok_cb, const_char *cancel_text, \
108         glib.GCallback cancel_cb, account.PurpleAccount *account, \
109         const_char *who, conversation.PurpleConversation *conv, \
110         void *user_data):
111     """
112     @see purple_request_fields().
113     """
114     debug.purple_debug_info("request", "%s", "request-fields\n")
115     if "request-fields" in request_cbs:
116         (<object> request_cbs["request-fields"])("request-fields: TODO")
117
118 cdef void *request_file(const_char *title, const_char *filename, \
119         glib.gboolean savedialog, glib.GCallback ok_cb, \
120         glib.GCallback cancel_cb, account.PurpleAccount *account, \
121         const_char *who, conversation.PurpleConversation *conv, \
122         void *user_data):
123     """
124     @see purple_request_file().
125     """
126     debug.purple_debug_info("request", "%s", "request-file\n")
127     if "request-file" in request_cbs:
128         (<object> request_cbs["request-file"])("request-file: TODO")
129
130 cdef void close_request(request.PurpleRequestType type, void *ui_handle):
131     """
132     TODO
133     """
134     debug.purple_debug_info("request", "%s", "close-request\n")
135     if "close-request" in request_cbs:
136         (<object> request_cbs["close-request"])("close-request: TODO")
137
138 cdef void *request_folder(const_char *title, const_char *dirname, \
139         glib.GCallback ok_cb, glib.GCallback cancel_cb, \
140         account.PurpleAccount *account, const_char *who, \
141         conversation.PurpleConversation *conv, void *user_data):
142     """
143     @see purple_request_folder().
144     """
145     debug.purple_debug_info("request", "%s", "request-folder\n")
146     if "request-folder" in request_cbs:
147         (<object> request_cbs["request-folder"])("request-folder: TODO")