5477
|
1 /**
|
|
2 * @file request.h 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 #ifndef _GAIM_REQUEST_H_
|
|
24 #define _GAIM_REQUEST_H_
|
|
25
|
|
26 #include <stdlib.h>
|
|
27 #include <glib-object.h>
|
|
28 #include <glib.h>
|
|
29
|
|
30 /**
|
|
31 * Request types.
|
|
32 */
|
|
33 typedef enum
|
|
34 {
|
|
35 GAIM_REQUEST_INPUT = 0, /**< Text input request. */
|
|
36 GAIM_REQUEST_CHOICE, /**< Multiple-choice request. */
|
|
37 GAIM_REQUEST_ACTION /**< Action request. */
|
|
38
|
|
39 } GaimRequestType;
|
|
40
|
|
41 /**
|
|
42 * Request UI operations.
|
|
43 */
|
|
44 typedef struct
|
|
45 {
|
|
46 void *(*request_input)(const char *title, const char *primary,
|
|
47 const char *secondary, const char *default_value,
|
|
48 const char *ok_text, GCallback ok_cb,
|
|
49 const char *cancel_text, GCallback cancel_cb,
|
|
50 void *user_data);
|
|
51 void *(*request_choice)(const char *title, const char *primary,
|
|
52 const char *secondary, unsigned int default_value,
|
|
53 const char *ok_text, GCallback ok_cb,
|
|
54 const char *cancel_text, GCallback cancel_cb,
|
|
55 void *user_data, va_list args);
|
|
56 void *(*request_action)(const char *title, const char *primary,
|
|
57 const char *secondary, unsigned int default_action,
|
|
58 void *user_data, va_list actions);
|
|
59
|
|
60 void (*close_request)(GaimRequestType type, void *uihandle);
|
|
61
|
|
62 } GaimRequestUiOps;
|
|
63
|
|
64 /**************************************************************************/
|
|
65 /** @name Request API */
|
|
66 /**************************************************************************/
|
|
67 /*@{*/
|
|
68
|
|
69 /**
|
|
70 * Prompts the user for text input.
|
|
71 *
|
|
72 * @param handle The plugin or connection handle.
|
|
73 * @param title The title of the message.
|
|
74 * @param primary The main point of the message.
|
|
75 * @param secondary The secondary information.
|
|
76 * @param default_value The default value.
|
|
77 * @param ok_text The text for the OK button.
|
|
78 * @param ok_cb The callback for the OK button.
|
|
79 * @param cancel_text The text for the cancel button.
|
|
80 * @param cancel_cb The callback for the cancel button.
|
|
81 * @param user_data The data to pass to the callback.
|
|
82 *
|
|
83 * @return A UI-specific handle.
|
|
84 */
|
|
85 void *gaim_request_input(void *handle, const char *title,
|
|
86 const char *primary, const char *secondary,
|
|
87 const char *default_value,
|
|
88 const char *ok_text, GCallback ok_cb,
|
|
89 const char *cancel_text, GCallback cancel_cb,
|
|
90 void *user_data);
|
|
91
|
|
92 /**
|
|
93 * Prompts the user for multiple-choice input.
|
|
94 *
|
|
95 * @param handle The plugin or connection handle.
|
|
96 * @param title The title of the message.
|
|
97 * @param primary The main point of the message.
|
|
98 * @param secondary The secondary information.
|
|
99 * @param default_value The default value.
|
|
100 * @param ok_text The text for the OK button.
|
|
101 * @param ok_cb The callback for the OK button.
|
|
102 * @param cancel_text The text for the cancel button.
|
|
103 * @param cancel_cb The callback for the cancel button.
|
|
104 * @param user_data The data to pass to the callback.
|
|
105 * @param choice The choices.
|
|
106 *
|
|
107 * @return A UI-specific handle.
|
|
108 */
|
|
109 void *gaim_request_choice(void *handle, const char *title,
|
|
110 const char *primary, const char *secondary,
|
|
111 unsigned int default_value,
|
|
112 const char *ok_text, GCallback ok_cb,
|
|
113 const char *cancel_text, GCallback cancel_cb,
|
|
114 void *user_data,
|
|
115 const char *choice, ...);
|
|
116
|
|
117 /**
|
|
118 * Prompts the user for multiple-choice input.
|
|
119 *
|
|
120 * @param handle The plugin or connection handle.
|
|
121 * @param title The title of the message.
|
|
122 * @param primary The main point of the message.
|
|
123 * @param secondary The secondary information.
|
|
124 * @param default_value The default value.
|
|
125 * @param ok_text The text for the OK button.
|
|
126 * @param ok_cb The callback for the OK button.
|
|
127 * @param cancel_text The text for the cancel button.
|
|
128 * @param cancel_cb The callback for the cancel button.
|
|
129 * @param user_data The data to pass to the callback.
|
|
130 * @param choices The choices.
|
|
131 *
|
|
132 * @return A UI-specific handle.
|
|
133 */
|
|
134 void *gaim_request_choice_varg(void *handle, const char *title,
|
|
135 const char *primary, const char *secondary,
|
|
136 unsigned int default_value,
|
|
137 const char *ok_text, GCallback ok_cb,
|
|
138 const char *cancel_text, GCallback cancel_cb,
|
|
139 void *user_data, va_list choices);
|
|
140
|
|
141 /**
|
|
142 * Prompts the user for an action.
|
|
143 *
|
|
144 * This is often represented as a dialog with a button for each action.
|
|
145 *
|
|
146 * @param handle The plugin or connection handle.
|
|
147 * @param title The title of the message.
|
|
148 * @param primary The main point of the message.
|
|
149 * @param secondary The secondary information.
|
|
150 * @param default_action The default value.
|
|
151 * @param user_data The data to pass to the callback.
|
|
152 * @param action The first action.
|
|
153 *
|
|
154 * @return A UI-specific handle.
|
|
155 */
|
|
156 void *gaim_request_action(void *handle, const char *title,
|
|
157 const char *primary, const char *secondary,
|
|
158 unsigned int default_action,
|
|
159 void *user_data, const char *action, ...);
|
|
160
|
|
161 /**
|
|
162 * Prompts the user for an action.
|
|
163 *
|
|
164 * This is often represented as a dialog with a button for each action.
|
|
165 *
|
|
166 * @param handle The plugin or connection handle.
|
|
167 * @param title The title of the message.
|
|
168 * @param primary The main point of the message.
|
|
169 * @param secondary The secondary information.
|
|
170 * @param default_action The default value.
|
|
171 * @param user_data The data to pass to the callback.
|
|
172 * @param actions A list of actions and callbacks.
|
|
173 *
|
|
174 * @return A UI-specific handle.
|
|
175 */
|
|
176 void *gaim_request_action_varg(void *handle, const char *title,
|
|
177 const char *primary, const char *secondary,
|
|
178 unsigned int default_action,
|
|
179 void *user_data, va_list actions);
|
|
180
|
|
181 /**
|
|
182 * Closes a request.
|
|
183 *
|
|
184 * This should be used only by the UI operation functions and part of the
|
|
185 * core.
|
|
186 *
|
|
187 * @param type The request type.
|
|
188 * @param uihandle The request UI handle.
|
|
189 */
|
|
190 void gaim_request_close(GaimRequestType type, void *uihandle);
|
|
191
|
|
192 /**
|
|
193 * Closes all requests registered with the specified handle.
|
|
194 *
|
|
195 * @param handle The handle.
|
|
196 */
|
|
197 void gaim_request_close_with_handle(void *handle);
|
|
198
|
|
199 /**
|
|
200 * A wrapper for gaim_request_action() that uses Yes and No buttons.
|
|
201 */
|
|
202 #define gaim_request_yes_no(handle, title, primary, secondary, \
|
|
203 default_action, user_data, yes_cb, no_cb) \
|
|
204 gaim_request_action((handle), (title), (primary), (secondary) \
|
|
205 (default_action), (user_data), \
|
|
206 _("Yes"), (yes_cb), _("No"), (no_cb), NULL)
|
|
207
|
|
208 /**
|
|
209 * A wrapper for gaim_request_action() that uses OK and Cancel buttons.
|
|
210 */
|
|
211 #define gaim_request_ok_cancel(handle, title, primary, secondary, \
|
|
212 default_action, user_data, ok_cb, cancel_cb) \
|
|
213 gaim_request_action((handle), (title), (primary), (secondary) \
|
|
214 (default_action), (user_data), \
|
|
215 _("OK"), (ok_cb), _("Cancel"), (cancel_cb), NULL)
|
|
216
|
|
217 /*@}*/
|
|
218
|
|
219 /**************************************************************************/
|
|
220 /** @name UI Operations API */
|
|
221 /**************************************************************************/
|
|
222 /*@{*/
|
|
223
|
|
224 /**
|
|
225 * Sets the UI operations structure to be used when displaying a
|
|
226 * request.
|
|
227 *
|
|
228 * @param ops The UI operations structure.
|
|
229 */
|
|
230 void gaim_set_request_ui_ops(GaimRequestUiOps *ops);
|
|
231
|
|
232 /**
|
|
233 * Returns the UI operations structure to be used when displaying a
|
|
234 * request.
|
|
235 *
|
|
236 * @param ops The UI operations structure.
|
|
237 */
|
|
238 GaimRequestUiOps *gaim_get_request_ui_ops(void);
|
|
239
|
|
240 /*@}*/
|
|
241
|
|
242 #endif /* _GAIM_REQUEST_H_ */
|