Mercurial > pidgin.yaz
annotate src/request.c @ 5598:8b24e4d1e082
[gaim-migrate @ 6002]
(10:36:12) Robot101: fixes three things:
(10:36:33) Robot101: linkifies text that's inserted by the history plugin, if you have that option enabled
for conversations in general
(10:37:02) Robot101: validates the UTF-8 in incoming server-side aliases, so trillian can't screw us over
(10:37:38) Robot101: changes the wording in the iconaway plugin so it no longer claims to minimise the
away window, which for the moment is a dialog and isn't meant to be minimised
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Sat, 31 May 2003 14:38:03 +0000 |
parents | b7c0be69c749 |
children | 11001789cb22 |
rev | line source |
---|---|
5477 | 1 /** |
2 * @file request.c Request API | |
3 * @ingroup core | |
4 * | |
5 * gaim | |
6 * | |
7 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> | |
8 * | |
9 * This program is free software; you can redistribute it and/or modify | |
10 * it under the terms of the GNU General Public License as published by | |
11 * the Free Software Foundation; either version 2 of the License, or | |
12 * (at your option) any later version. | |
13 * | |
14 * This program is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
20 * along with this program; if not, write to the Free Software | |
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
22 */ | |
23 #include "request.h" | |
24 | |
25 static GaimRequestUiOps *request_ui_ops = NULL; | |
26 static GList *handles = NULL; | |
27 | |
28 typedef struct | |
29 { | |
30 GaimRequestType type; | |
31 void *handle; | |
32 void *ui_handle; | |
33 | |
34 } GaimRequestInfo; | |
35 | |
36 | |
37 void * | |
38 gaim_request_input(void *handle, const char *title, const char *primary, | |
39 const char *secondary, const char *default_value, | |
5482
a41149ee8a29
[gaim-migrate @ 5878]
Christian Hammond <chipx86@chipx86.com>
parents:
5477
diff
changeset
|
40 gboolean multiline, |
5477 | 41 const char *ok_text, GCallback ok_cb, |
42 const char *cancel_text, GCallback cancel_cb, | |
43 void *user_data) | |
44 { | |
45 GaimRequestUiOps *ops; | |
46 | |
47 g_return_val_if_fail(primary != NULL, NULL); | |
48 g_return_val_if_fail(ok_text != NULL, NULL); | |
49 g_return_val_if_fail(ok_cb != NULL, NULL); | |
50 | |
51 ops = gaim_get_request_ui_ops(); | |
52 | |
53 if (ops != NULL && ops->request_input != NULL) { | |
54 GaimRequestInfo *info; | |
55 | |
56 info = g_new0(GaimRequestInfo, 1); | |
57 info->type = GAIM_REQUEST_INPUT; | |
58 info->handle = handle; | |
59 info->ui_handle = ops->request_input(title, primary, secondary, | |
5482
a41149ee8a29
[gaim-migrate @ 5878]
Christian Hammond <chipx86@chipx86.com>
parents:
5477
diff
changeset
|
60 default_value, multiline, |
a41149ee8a29
[gaim-migrate @ 5878]
Christian Hammond <chipx86@chipx86.com>
parents:
5477
diff
changeset
|
61 ok_text, ok_cb, |
5477 | 62 cancel_text, cancel_cb, |
63 user_data); | |
64 | |
65 handles = g_list_append(handles, info); | |
66 | |
67 return info->ui_handle; | |
68 } | |
69 | |
70 return NULL; | |
71 } | |
72 | |
73 void * | |
74 gaim_request_choice(void *handle, const char *title, const char *primary, | |
75 const char *secondary, unsigned int default_value, | |
76 const char *ok_text, GCallback ok_cb, | |
77 const char *cancel_text, GCallback cancel_cb, | |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
78 void *user_data, size_t choice_count, ...) |
5477 | 79 { |
80 void *ui_handle; | |
81 va_list args; | |
82 | |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
83 g_return_val_if_fail(primary != NULL, NULL); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
84 g_return_val_if_fail(ok_text != NULL, NULL); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
85 g_return_val_if_fail(ok_cb != NULL, NULL); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
86 g_return_val_if_fail(choice_count > 0, NULL); |
5477 | 87 |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
88 va_start(args, choice_count); |
5477 | 89 ui_handle = gaim_request_choice_varg(handle, title, primary, secondary, |
90 default_value, ok_text, ok_cb, | |
91 cancel_text, cancel_cb, user_data, | |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
92 choice_count, args); |
5477 | 93 va_end(args); |
94 | |
95 return ui_handle; | |
96 } | |
97 | |
98 void * | |
99 gaim_request_choice_varg(void *handle, const char *title, | |
100 const char *primary, const char *secondary, | |
101 unsigned int default_value, | |
102 const char *ok_text, GCallback ok_cb, | |
103 const char *cancel_text, GCallback cancel_cb, | |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
104 void *user_data, size_t choice_count, |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
105 va_list choices) |
5477 | 106 { |
107 GaimRequestUiOps *ops; | |
108 | |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
109 g_return_val_if_fail(primary != NULL, NULL); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
110 g_return_val_if_fail(ok_text != NULL, NULL); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
111 g_return_val_if_fail(ok_cb != NULL, NULL); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
112 g_return_val_if_fail(choice_count > 0, NULL); |
5477 | 113 |
114 ops = gaim_get_request_ui_ops(); | |
115 | |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
116 if (ops != NULL && ops->request_choice != NULL) { |
5477 | 117 GaimRequestInfo *info; |
118 | |
119 info = g_new0(GaimRequestInfo, 1); | |
120 info->type = GAIM_REQUEST_CHOICE; | |
121 info->handle = handle; | |
122 info->ui_handle = ops->request_choice(title, primary, secondary, | |
5482
a41149ee8a29
[gaim-migrate @ 5878]
Christian Hammond <chipx86@chipx86.com>
parents:
5477
diff
changeset
|
123 default_value, |
a41149ee8a29
[gaim-migrate @ 5878]
Christian Hammond <chipx86@chipx86.com>
parents:
5477
diff
changeset
|
124 ok_text, ok_cb, |
5477 | 125 cancel_text, cancel_cb, |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
126 user_data, choice_count, |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
127 choices); |
5477 | 128 |
129 handles = g_list_append(handles, info); | |
130 | |
131 return info->ui_handle; | |
132 } | |
133 | |
134 return NULL; | |
135 } | |
136 | |
137 void * | |
138 gaim_request_action(void *handle, const char *title, const char *primary, | |
139 const char *secondary, unsigned int default_action, | |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
140 void *user_data, size_t action_count, ...) |
5477 | 141 { |
142 void *ui_handle; | |
143 va_list args; | |
144 | |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
145 g_return_val_if_fail(primary != NULL, NULL); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
146 g_return_val_if_fail(action_count > 0, NULL); |
5477 | 147 |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
148 va_start(args, action_count); |
5477 | 149 ui_handle = gaim_request_action_varg(handle, title, primary, secondary, |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
150 default_action, user_data, |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
151 action_count, args); |
5477 | 152 va_end(args); |
153 | |
154 return ui_handle; | |
155 } | |
156 | |
157 void * | |
158 gaim_request_action_varg(void *handle, const char *title, | |
159 const char *primary, const char *secondary, | |
160 unsigned int default_action, void *user_data, | |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
161 size_t action_count, va_list actions) |
5477 | 162 { |
163 GaimRequestUiOps *ops; | |
164 | |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
165 g_return_val_if_fail(primary != NULL, NULL); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
166 g_return_val_if_fail(action_count > 0, NULL); |
5477 | 167 |
168 ops = gaim_get_request_ui_ops(); | |
169 | |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
170 if (ops != NULL && ops->request_action != NULL) { |
5477 | 171 GaimRequestInfo *info; |
172 | |
173 info = g_new0(GaimRequestInfo, 1); | |
174 info->type = GAIM_REQUEST_ACTION; | |
175 info->handle = handle; | |
176 info->ui_handle = ops->request_action(title, primary, secondary, | |
177 default_action, user_data, | |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
178 action_count, actions); |
5477 | 179 |
180 handles = g_list_append(handles, info); | |
181 | |
182 return info->ui_handle; | |
183 } | |
184 | |
185 return NULL; | |
186 } | |
187 | |
188 void | |
189 gaim_request_close(GaimRequestType type, void *ui_handle) | |
190 { | |
191 GList *l; | |
192 GaimRequestUiOps *ops; | |
193 | |
194 g_return_if_fail(ui_handle != NULL); | |
195 | |
196 ops = gaim_get_request_ui_ops(); | |
197 | |
198 for (l = handles; l != NULL; l = l->next) { | |
199 GaimRequestInfo *info = l->data; | |
200 | |
201 if (info->ui_handle == ui_handle) { | |
202 handles = g_list_remove(handles, info); | |
203 | |
204 if (ops != NULL && ops->close_request != NULL) | |
205 ops->close_request(info->type, ui_handle); | |
206 | |
207 g_free(info); | |
208 | |
209 break; | |
210 } | |
211 } | |
212 } | |
213 | |
214 void | |
215 gaim_request_close_with_handle(void *handle) | |
216 { | |
217 GList *l, *l_next; | |
218 GaimRequestUiOps *ops; | |
219 | |
220 g_return_if_fail(handle != NULL); | |
221 | |
222 ops = gaim_get_request_ui_ops(); | |
223 | |
224 for (l = handles; l != NULL; l = l_next) { | |
225 GaimRequestInfo *info = l->data; | |
226 | |
227 l_next = l->next; | |
228 | |
229 if (info->handle == handle) { | |
230 handles = g_list_remove(handles, info); | |
231 | |
232 if (ops != NULL && ops->close_request != NULL) | |
233 ops->close_request(info->type, info->ui_handle); | |
234 | |
235 g_free(info); | |
236 } | |
237 } | |
238 } | |
239 | |
240 void | |
241 gaim_set_request_ui_ops(GaimRequestUiOps *ops) | |
242 { | |
243 request_ui_ops = ops; | |
244 } | |
245 | |
246 GaimRequestUiOps * | |
247 gaim_get_request_ui_ops(void) | |
248 { | |
249 return request_ui_ops; | |
250 } | |
251 | |
252 |