Remove unused Meson option for enchant.
[pidgin-git.git] / libpurple / request.h
blob49c32f6b74ce629bb3b28bc0df5d0fdd46ee2e48
1 /* purple
3 * Purple is the legal property of its developers, whose names are too numerous
4 * to list here. Please refer to the COPYRIGHT file distributed with this
5 * source distribution.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
22 #ifndef PURPLE_REQUEST_H
23 #define PURPLE_REQUEST_H
24 /**
25 * SECTION:request
26 * @section_id: libpurple-request
27 * @short_description: <filename>request.h</filename>
28 * @title: Request API
31 #include <stdlib.h>
32 #include <glib-object.h>
33 #include <glib.h>
35 #include "conversation.h"
36 #include "request-datasheet.h"
38 #define PURPLE_TYPE_REQUEST_UI_OPS (purple_request_ui_ops_get_type())
40 /**
41 * PurpleRequestField:
43 * A request field.
45 typedef struct _PurpleRequestField PurpleRequestField;
47 /**
48 * PurpleRequestFields:
50 * Multiple fields request data.
52 typedef struct _PurpleRequestFields PurpleRequestFields;
54 /**
55 * PurpleRequestFieldGroup:
57 * A group of fields with a title.
59 typedef struct _PurpleRequestFieldGroup PurpleRequestFieldGroup;
61 /**
62 * PurpleRequestCommonParameters:
64 * Common parameters for UI operations.
66 typedef struct _PurpleRequestCommonParameters PurpleRequestCommonParameters;
68 typedef struct _PurpleRequestUiOps PurpleRequestUiOps;
70 #include "account.h"
72 #define PURPLE_DEFAULT_ACTION_NONE -1
74 /**
75 * PurpleRequestType:
76 * @PURPLE_REQUEST_INPUT: Text input request.
77 * @PURPLE_REQUEST_CHOICE: Multiple-choice request.
78 * @PURPLE_REQUEST_ACTION: Action request.
79 * @PURPLE_REQUEST_WAIT: Please wait dialog.
80 * @PURPLE_REQUEST_FIELDS: Multiple fields request.
81 * @PURPLE_REQUEST_FILE: File open or save request.
82 * @PURPLE_REQUEST_FOLDER: Folder selection request.
84 * Request types.
86 typedef enum
88 PURPLE_REQUEST_INPUT = 0,
89 PURPLE_REQUEST_CHOICE,
90 PURPLE_REQUEST_ACTION,
91 PURPLE_REQUEST_WAIT,
92 PURPLE_REQUEST_FIELDS,
93 PURPLE_REQUEST_FILE,
94 PURPLE_REQUEST_FOLDER
96 } PurpleRequestType;
98 /**
99 * PurpleRequestFieldType:
100 * @PURPLE_REQUEST_FIELD_NONE: No field.
101 * @PURPLE_REQUEST_FIELD_STRING: String field.
102 * @PURPLE_REQUEST_FIELD_INTEGER: Integer field.
103 * @PURPLE_REQUEST_FIELD_BOOLEAN: Boolean field.
104 * @PURPLE_REQUEST_FIELD_CHOICE: Choice field (dropdown?).
105 * @PURPLE_REQUEST_FIELD_LIST: List field.
106 * @PURPLE_REQUEST_FIELD_LABEL: Label field.
107 * @PURPLE_REQUEST_FIELD_IMAGE: Image field.
108 * @PURPLE_REQUEST_FIELD_ACCOUNT: #PurpleAccount field.
109 * @PURPLE_REQUEST_FIELD_DATASHEET: Datasheet field.
111 * A type of field.
113 typedef enum
115 PURPLE_REQUEST_FIELD_NONE,
116 PURPLE_REQUEST_FIELD_STRING,
117 PURPLE_REQUEST_FIELD_INTEGER,
118 PURPLE_REQUEST_FIELD_BOOLEAN,
119 PURPLE_REQUEST_FIELD_CHOICE,
120 PURPLE_REQUEST_FIELD_LIST,
121 PURPLE_REQUEST_FIELD_LABEL,
122 PURPLE_REQUEST_FIELD_IMAGE,
123 PURPLE_REQUEST_FIELD_ACCOUNT,
124 PURPLE_REQUEST_FIELD_DATASHEET
126 } PurpleRequestFieldType;
129 * PurpleRequestFeature:
130 * @PURPLE_REQUEST_FEATURE_HTML: Specifies that HTML should be supported.
132 * Feature flags for the request api.
134 typedef enum
136 PURPLE_REQUEST_FEATURE_HTML = 0x00000001
137 } PurpleRequestFeature;
140 * PurpleRequestIconType:
141 * @PURPLE_REQUEST_ICON_DEFAULT: The default icon.
142 * @PURPLE_REQUEST_ICON_REQUEST: Use a question icon.
143 * @PURPLE_REQUEST_ICON_DIALOG: Use a dialog icon.
144 * @PURPLE_REQUEST_ICON_WAIT: Use a wait icon.
145 * @PURPLE_REQUEST_ICON_INFO: Use an info icon.
146 * @PURPLE_REQUEST_ICON_WARNING: Use a warning icon.
147 * @PURPLE_REQUEST_ICON_ERROR: Use an error icon.
149 * Constants to define which kind of icon should be displayed.
151 typedef enum
153 PURPLE_REQUEST_ICON_DEFAULT = 0,
154 PURPLE_REQUEST_ICON_REQUEST,
155 PURPLE_REQUEST_ICON_DIALOG,
156 PURPLE_REQUEST_ICON_WAIT,
157 PURPLE_REQUEST_ICON_INFO,
158 PURPLE_REQUEST_ICON_WARNING,
159 PURPLE_REQUEST_ICON_ERROR
160 } PurpleRequestIconType;
163 * PurpleRequestCancelCb:
164 * @data: user-data.
166 * A callback that's used to handle cancel actions.
168 typedef void (*PurpleRequestCancelCb)(gpointer data);
171 * PurpleRequestUiOps:
172 * @features: A bitwise or of #PurpleRequestFeature's.
173 * @request_input: See purple_request_input().
174 * @request_choice: See purple_request_choice_varg().
175 * @request_action: See purple_request_action_varg().
176 * @request_wait: See purple_request_wait().
177 * @request_wait_update: See purple_request_wait_pulse(),
178 * purple_request_wait_progress().
179 * @request_fields: See purple_request_fields().
180 * @request_file: See purple_request_file().
181 * @request_folder: See purple_request_folder().
182 * @close_request: See purple_request_close().
184 * Request UI operations.
186 struct _PurpleRequestUiOps
188 PurpleRequestFeature features;
190 void *(*request_input)(const char *title, const char *primary,
191 const char *secondary, const char *default_value,
192 gboolean multiline, gboolean masked, gchar *hint,
193 const char *ok_text, GCallback ok_cb,
194 const char *cancel_text, GCallback cancel_cb,
195 PurpleRequestCommonParameters *cpar, void *user_data);
197 void *(*request_choice)(const char *title, const char *primary,
198 const char *secondary, gpointer default_value,
199 const char *ok_text, GCallback ok_cb, const char *cancel_text,
200 GCallback cancel_cb, PurpleRequestCommonParameters *cpar,
201 void *user_data, va_list choices);
203 void *(*request_action)(const char *title, const char *primary,
204 const char *secondary, int default_action,
205 PurpleRequestCommonParameters *cpar, void *user_data,
206 size_t action_count, va_list actions);
208 void *(*request_wait)(const char *title, const char *primary,
209 const char *secondary, gboolean with_progress,
210 PurpleRequestCancelCb cancel_cb,
211 PurpleRequestCommonParameters *cpar, void *user_data);
213 void (*request_wait_update)(void *ui_handle, gboolean pulse,
214 gfloat fraction);
216 void *(*request_fields)(const char *title, const char *primary,
217 const char *secondary, PurpleRequestFields *fields,
218 const char *ok_text, GCallback ok_cb,
219 const char *cancel_text, GCallback cancel_cb,
220 PurpleRequestCommonParameters *cpar, void *user_data);
222 void *(*request_file)(const char *title, const char *filename,
223 gboolean savedialog, GCallback ok_cb, GCallback cancel_cb,
224 PurpleRequestCommonParameters *cpar, void *user_data);
226 void *(*request_folder)(const char *title, const char *dirname,
227 GCallback ok_cb, GCallback cancel_cb,
228 PurpleRequestCommonParameters *cpar, void *user_data);
230 void (*close_request)(PurpleRequestType type, void *ui_handle);
232 /*< private >*/
233 void (*_purple_reserved1)(void);
234 void (*_purple_reserved2)(void);
235 void (*_purple_reserved3)(void);
236 void (*_purple_reserved4)(void);
239 typedef void (*PurpleRequestInputCb)(void *data, const char *value);
241 typedef gboolean (*PurpleRequestFieldValidator)(PurpleRequestField *field,
242 gchar **errmsg, gpointer user_data);
244 typedef gboolean (*PurpleRequestFieldSensitivityCb)(PurpleRequestField *field);
247 * PurpleRequestActionCb:
248 * @data: user-data
249 * @action: The action that was chosen.
251 * The type of callbacks passed to purple_request_action(). The first
252 * argument is the <literal>user_data</literal> parameter; the second is the
253 * index in the list of actions of the one chosen.
255 typedef void (*PurpleRequestActionCb)(void *data, int action);
258 * PurpleRequestChoiceCb:
259 * @data: user-data
260 * @value: The choice that was made.
262 * The type of callbacks passed to purple_request_choice(). The first
263 * argument is the <literal>user_data</literal> parameter; the second is the
264 * values of those choice.
266 typedef void (*PurpleRequestChoiceCb)(void *data, gpointer value);
267 typedef void (*PurpleRequestFieldsCb)(void *data, PurpleRequestFields *fields);
268 typedef void (*PurpleRequestFileCb)(void *data, const char *filename);
269 typedef void (*PurpleRequestHelpCb)(gpointer data);
271 G_BEGIN_DECLS
273 /**************************************************************************/
274 /* Common parameters API */
275 /**************************************************************************/
278 * purple_request_cpar_new:
280 * Creates new parameters set for the request, which may or may not be used by
281 * the UI to display the request.
283 * Returns: The new parameters set.
285 PurpleRequestCommonParameters *
286 purple_request_cpar_new(void);
289 * purple_request_cpar_from_connection:
290 * @gc: The #PurpleConnection.
292 * Creates new parameters set initially bound with the #PurpleConnection.
294 * Returns: The new parameters set.
296 PurpleRequestCommonParameters *
297 purple_request_cpar_from_connection(PurpleConnection *gc);
300 * purple_request_cpar_from_account:
301 * @account: The #PurpleAccount.
303 * Creates new parameters set initially bound with the #PurpleAccount.
305 * Returns: The new parameters set.
307 PurpleRequestCommonParameters *
308 purple_request_cpar_from_account(PurpleAccount *account);
311 * purple_request_cpar_from_conversation:
312 * @conv: The #PurpleConversation.
314 * Creates new parameters set initially bound with the #PurpleConversation.
316 * Returns: The new parameters set.
318 PurpleRequestCommonParameters *
319 purple_request_cpar_from_conversation(PurpleConversation *conv);
322 * purple_request_cpar_ref:
323 * @cpar: The object to ref.
325 * Increases the reference count on the parameters set.
327 void
328 purple_request_cpar_ref(PurpleRequestCommonParameters *cpar);
331 * purple_request_cpar_unref:
332 * @cpar: The parameters set object to unref and possibly destroy.
334 * Decreases the reference count on the parameters set.
336 * The object will be destroyed when this reaches 0.
338 * Returns: The NULL, if object was destroyed, cpar otherwise.
340 PurpleRequestCommonParameters *
341 purple_request_cpar_unref(PurpleRequestCommonParameters *cpar);
344 * purple_request_cpar_set_account:
345 * @cpar: The parameters set.
346 * @account: The #PurpleAccount to associate.
348 * Sets the #PurpleAccount associated with the request, or %NULL, if none is.
350 void
351 purple_request_cpar_set_account(PurpleRequestCommonParameters *cpar,
352 PurpleAccount *account);
355 * purple_request_cpar_get_account:
356 * @cpar: The parameters set (may be %NULL).
358 * Gets the #PurpleAccount associated with the request.
360 * Returns: (transfer none): The associated #PurpleAccount, or %NULL if none is
361 * set.
363 PurpleAccount *
364 purple_request_cpar_get_account(PurpleRequestCommonParameters *cpar);
367 * purple_request_cpar_set_conversation:
368 * @cpar: The parameters set.
369 * @conv: The #PurpleConversation to associate.
371 * Sets the #PurpleConversation associated with the request, or %NULL, if
372 * none is.
374 void
375 purple_request_cpar_set_conversation(PurpleRequestCommonParameters *cpar,
376 PurpleConversation *conv);
379 * purple_request_cpar_get_conversation:
380 * @cpar: The parameters set (may be %NULL).
382 * Gets the #PurpleConversation associated with the request.
384 * Returns: (transfer none): The associated #PurpleConversation, or %NULL if
385 * none is set.
387 PurpleConversation *
388 purple_request_cpar_get_conversation(PurpleRequestCommonParameters *cpar);
391 * purple_request_cpar_set_icon:
392 * @cpar: The parameters set.
393 * @icon_type: The icon type.
395 * Sets the icon associated with the request.
397 void
398 purple_request_cpar_set_icon(PurpleRequestCommonParameters *cpar,
399 PurpleRequestIconType icon_type);
402 * purple_request_cpar_get_icon:
403 * @cpar: The parameters set.
405 * Gets the icon associated with the request.
407 * Returns: icon_type The icon type.
409 PurpleRequestIconType
410 purple_request_cpar_get_icon(PurpleRequestCommonParameters *cpar);
413 * purple_request_cpar_set_custom_icon:
414 * @cpar: The parameters set.
415 * @icon_data: The icon image contents (%NULL to reset).
416 * @icon_size: The icon image size.
418 * Sets the custom icon associated with the request.
420 void
421 purple_request_cpar_set_custom_icon(PurpleRequestCommonParameters *cpar,
422 gconstpointer icon_data, gsize icon_size);
425 * purple_request_cpar_get_custom_icon:
426 * @cpar: The parameters set (may be %NULL).
427 * @icon_size: The pointer to variable, where icon size should be stored
428 * (may be %NULL).
430 * Gets the custom icon associated with the request.
432 * Returns: The icon image contents.
434 gconstpointer
435 purple_request_cpar_get_custom_icon(PurpleRequestCommonParameters *cpar,
436 gsize *icon_size);
439 * purple_request_cpar_set_html:
440 * @cpar: The parameters set.
441 * @enabled: 1, if the text passed with the request contains HTML,
442 * 0 otherwise. Don't use any other values, as they may be
443 * redefined in the future.
445 * Switches the request text to be HTML or not.
447 void
448 purple_request_cpar_set_html(PurpleRequestCommonParameters *cpar,
449 gboolean enabled);
452 * purple_request_cpar_is_html:
453 * @cpar: The parameters set (may be %NULL).
455 * Checks, if the text passed to the request is HTML.
457 * Returns: %TRUE, if the text is HTML, %FALSE otherwise.
459 gboolean
460 purple_request_cpar_is_html(PurpleRequestCommonParameters *cpar);
463 * purple_request_cpar_set_compact:
464 * @cpar: The parameters set.
465 * @compact: TRUE for compact, FALSE otherwise.
467 * Sets dialog display mode to compact or default.
469 void
470 purple_request_cpar_set_compact(PurpleRequestCommonParameters *cpar,
471 gboolean compact);
474 * purple_request_cpar_is_compact:
475 * @cpar: The parameters set (may be %NULL).
477 * Gets dialog display mode.
479 * Returns: TRUE for compact, FALSE for default.
481 gboolean
482 purple_request_cpar_is_compact(PurpleRequestCommonParameters *cpar);
485 * purple_request_cpar_set_help_cb:
486 * @cpar: The parameters set.
487 * @cb: The callback.
488 * @user_data: The data to be passed to the callback.
490 * Sets the callback for the Help button.
492 void
493 purple_request_cpar_set_help_cb(PurpleRequestCommonParameters *cpar,
494 PurpleRequestHelpCb cb, gpointer user_data);
497 * purple_request_cpar_get_help_cb:
498 * @cpar: The parameters set (may be %NULL).
499 * @user_data: The pointer to the variable, where user data (to be passed to
500 * callback function) should be stored.
502 * Gets the callback for the Help button.
504 * Returns: The callback.
506 PurpleRequestHelpCb
507 purple_request_cpar_get_help_cb(PurpleRequestCommonParameters *cpar,
508 gpointer *user_data);
511 * purple_request_cpar_set_extra_actions:
512 * @cpar: The parameters set.
513 * @...: A list of actions. These are pairs of arguments. The first of each
514 * pair is the <type>char *</type> label that appears on the button. It
515 * should have an underscore before the letter you want to use as the
516 * accelerator key for the button. The second of each pair is the
517 * #PurpleRequestFieldsCb function to use when the button is clicked.
518 * Should be terminated with the NULL label.
520 * Sets extra actions for the PurpleRequestFields dialog.
522 void
523 purple_request_cpar_set_extra_actions(PurpleRequestCommonParameters *cpar, ...);
526 * purple_request_cpar_get_extra_actions:
527 * @cpar: The parameters set (may be %NULL).
529 * Gets extra actions for the PurpleRequestFields dialog.
531 * Returns: (transfer none): A list of actions (pairs of arguments, as in
532 * setter).
534 GSList *
535 purple_request_cpar_get_extra_actions(PurpleRequestCommonParameters *cpar);
538 * purple_request_cpar_set_parent_from:
539 * @cpar: The parameters set.
540 * @ui_handle: The UI handle.
542 * Sets the same parent window for this dialog, as the parent of specified
543 * Notify API or Request API dialog UI handle.
545 void
546 purple_request_cpar_set_parent_from(PurpleRequestCommonParameters *cpar,
547 gpointer ui_handle);
550 * purple_request_cpar_get_parent_from:
551 * @cpar: The parameters set (may be %NULL).
553 * Gets the parent "donor" for this dialog.
555 * Returns: The donors UI handle.
557 gpointer
558 purple_request_cpar_get_parent_from(PurpleRequestCommonParameters *cpar);
560 /**************************************************************************/
561 /* Field List API */
562 /**************************************************************************/
565 * purple_request_fields_new:
567 * Creates a list of fields to pass to purple_request_fields().
569 * Returns: A PurpleRequestFields structure.
571 PurpleRequestFields *purple_request_fields_new(void);
574 * purple_request_fields_destroy:
575 * @fields: The list of fields to destroy.
577 * Destroys a list of fields.
579 void purple_request_fields_destroy(PurpleRequestFields *fields);
582 * purple_request_fields_add_group:
583 * @fields: The fields list.
584 * @group: The group to add.
586 * Adds a group of fields to the list.
588 void purple_request_fields_add_group(PurpleRequestFields *fields,
589 PurpleRequestFieldGroup *group);
592 * purple_request_fields_get_groups:
593 * @fields: The fields list.
595 * Returns a list of all groups in a field list.
597 * Returns: (element-type PurpleRequestFieldGroup) (transfer none): A list of groups.
599 GList *purple_request_fields_get_groups(const PurpleRequestFields *fields);
602 * purple_request_fields_set_tab_names:
603 * @fields: The fields list.
604 * @tab_names: NULL-terminated array of localized tab labels,
605 * may be %NULL.
607 * Set tab names for a field list.
609 void purple_request_fields_set_tab_names(PurpleRequestFields *fields,
610 const gchar **tab_names);
613 * purple_request_fields_get_tab_names:
614 * @fields: The fields list.
616 * Returns tab names of a field list.
618 * Returns: (array zero-terminated=1) (transfer none): Localized tab labels, or
619 * %NULL if tabs are disabled.
621 const gchar **
622 purple_request_fields_get_tab_names(const PurpleRequestFields *fields);
625 * purple_request_fields_exists:
626 * @fields: The fields list.
627 * @id: The ID of the field.
629 * Returns whether or not the field with the specified ID exists.
631 * Returns: TRUE if the field exists, or FALSE.
633 gboolean purple_request_fields_exists(const PurpleRequestFields *fields,
634 const char *id);
637 * purple_request_fields_get_required:
638 * @fields: The fields list.
640 * Returns a list of all required fields.
642 * Returns: (element-type PurpleRequestField) (transfer none): The list of required fields.
644 const GList *purple_request_fields_get_required(
645 const PurpleRequestFields *fields);
648 * purple_request_fields_get_validatable:
649 * @fields: The fields list.
651 * Returns a list of all validated fields.
653 * Returns: (element-type PurpleRequestField) (transfer none): The list of validated fields.
655 const GList *purple_request_fields_get_validatable(
656 const PurpleRequestFields *fields);
659 * purple_request_fields_get_autosensitive:
660 * @fields: The fields list.
662 * Returns a list of all fields with sensitivity callback added.
664 * Returns: (element-type PurpleRequestField) (transfer none): The list of
665 * fields with automatic sensitivity callback.
667 const GList *
668 purple_request_fields_get_autosensitive(const PurpleRequestFields *fields);
671 * purple_request_fields_is_field_required:
672 * @fields: The fields list.
673 * @id: The field ID.
675 * Returns whether or not a field with the specified ID is required.
677 * Returns: TRUE if the specified field is required, or FALSE.
679 gboolean purple_request_fields_is_field_required(const PurpleRequestFields *fields,
680 const char *id);
683 * purple_request_fields_all_required_filled:
684 * @fields: The fields list.
686 * Returns whether or not all required fields have values.
688 * Returns: TRUE if all required fields have values, or FALSE.
690 gboolean purple_request_fields_all_required_filled(
691 const PurpleRequestFields *fields);
694 * purple_request_fields_all_valid:
695 * @fields: The fields list.
697 * Returns whether or not all fields are valid.
699 * Returns: TRUE if all fields are valid, or FALSE.
701 gboolean purple_request_fields_all_valid(const PurpleRequestFields *fields);
704 * purple_request_fields_get_field:
705 * @fields: The fields list.
706 * @id: The ID of the field.
708 * Return the field with the specified ID.
710 * Returns: The field, if found.
712 PurpleRequestField *purple_request_fields_get_field(
713 const PurpleRequestFields *fields, const char *id);
716 * purple_request_fields_get_string:
717 * @fields: The fields list.
718 * @id: The ID of the field.
720 * Returns the string value of a field with the specified ID.
722 * Returns: The string value, if found, or %NULL otherwise.
724 const char *purple_request_fields_get_string(const PurpleRequestFields *fields,
725 const char *id);
728 * purple_request_fields_get_integer:
729 * @fields: The fields list.
730 * @id: The ID of the field.
732 * Returns the integer value of a field with the specified ID.
734 * Returns: The integer value, if found, or 0 otherwise.
736 int purple_request_fields_get_integer(const PurpleRequestFields *fields,
737 const char *id);
740 * purple_request_fields_get_bool:
741 * @fields: The fields list.
742 * @id: The ID of the field.
744 * Returns the boolean value of a field with the specified ID.
746 * Returns: The boolean value, if found, or %FALSE otherwise.
748 gboolean purple_request_fields_get_bool(const PurpleRequestFields *fields,
749 const char *id);
752 * purple_request_fields_get_choice:
753 * @fields: The fields list.
754 * @id: The ID of the field.
756 * Returns the choice index of a field with the specified ID.
758 * Returns: The choice value, if found, or NULL otherwise.
760 gpointer
761 purple_request_fields_get_choice(const PurpleRequestFields *fields,
762 const char *id);
765 * purple_request_fields_get_account:
766 * @fields: The fields list.
767 * @id: The ID of the field.
769 * Returns the account of a field with the specified ID.
771 * Returns: (transfer none): The account value, if found, or %NULL otherwise.
773 PurpleAccount *purple_request_fields_get_account(const PurpleRequestFields *fields,
774 const char *id);
777 * purple_request_fields_get_ui_data:
778 * @fields: The fields list.
780 * Returns the UI data associated with this object.
782 * Returns: The UI data associated with this object. This is a
783 * convenience field provided to the UIs--it is not
784 * used by the libpurple core.
786 gpointer purple_request_fields_get_ui_data(const PurpleRequestFields *fields);
789 * purple_request_fields_set_ui_data:
790 * @fields: The fields list.
791 * @ui_data: A pointer to associate with this object.
793 * Set the UI data associated with this object.
795 void purple_request_fields_set_ui_data(PurpleRequestFields *fields, gpointer ui_data);
797 /**************************************************************************/
798 /* Fields Group API */
799 /**************************************************************************/
802 * purple_request_field_group_new:
803 * @title: The optional title to give the group.
805 * Creates a fields group with an optional title.
807 * Returns: A new fields group
809 PurpleRequestFieldGroup *purple_request_field_group_new(const char *title);
812 * purple_request_field_group_set_tab:
813 * @group: The group.
814 * @tab_no: The tab number.
816 * Sets tab number for a group.
818 * See purple_request_fields_set_tab_names().
820 void purple_request_field_group_set_tab(PurpleRequestFieldGroup *group,
821 guint tab_no);
824 * purple_request_field_group_get_tab:
825 * @group: The group.
827 * Returns tab number of a group.
829 * See purple_request_fields_get_tab_names().
831 * Returns: Tab number.
833 guint purple_request_field_group_get_tab(const PurpleRequestFieldGroup *group);
836 * purple_request_field_group_destroy:
837 * @group: The group to destroy.
839 * Destroys a fields group.
841 void purple_request_field_group_destroy(PurpleRequestFieldGroup *group);
844 * purple_request_field_group_add_field:
845 * @group: The group to add the field to.
846 * @field: The field to add to the group.
848 * Adds a field to the group.
850 void purple_request_field_group_add_field(PurpleRequestFieldGroup *group,
851 PurpleRequestField *field);
854 * purple_request_field_group_get_title:
855 * @group: The group.
857 * Returns the title of a fields group.
859 * Returns: The title, if set.
861 const char *purple_request_field_group_get_title(
862 const PurpleRequestFieldGroup *group);
865 * purple_request_field_group_get_fields:
866 * @group: The group.
868 * Returns a list of all fields in a group.
870 * Returns: (element-type PurpleRequestField) (transfer none): The list of fields in the group.
872 GList *purple_request_field_group_get_fields(
873 const PurpleRequestFieldGroup *group);
876 * purple_request_field_group_get_fields_list:
877 * @group: The group.
879 * Returns a list of all fields in a group.
881 * Returns: (transfer none): The list of fields in the group.
883 PurpleRequestFields *purple_request_field_group_get_fields_list(
884 const PurpleRequestFieldGroup *group);
886 /**************************************************************************/
887 /* Field API */
888 /**************************************************************************/
891 * purple_request_field_new:
892 * @id: The field ID.
893 * @text: The text label of the field.
894 * @type: The type of field.
896 * Creates a field of the specified type.
898 * Returns: The new field.
900 PurpleRequestField *purple_request_field_new(const char *id, const char *text,
901 PurpleRequestFieldType type);
904 * purple_request_field_destroy:
905 * @field: The field to destroy.
907 * Destroys a field.
909 void purple_request_field_destroy(PurpleRequestField *field);
912 * purple_request_field_set_label:
913 * @field: The field.
914 * @label: The text label.
916 * Sets the label text of a field.
918 void purple_request_field_set_label(PurpleRequestField *field, const char *label);
921 * purple_request_field_set_visible:
922 * @field: The field.
923 * @visible: TRUE if visible, or FALSE if not.
925 * Sets whether or not a field is visible.
927 void purple_request_field_set_visible(PurpleRequestField *field, gboolean visible);
930 * purple_request_field_set_type_hint:
931 * @field: The field.
932 * @type_hint: The type hint.
934 * Sets the type hint for the field.
936 * This is optionally used by the UIs to provide such features as
937 * auto-completion for type hints like "account" and "screenname".
939 void purple_request_field_set_type_hint(PurpleRequestField *field,
940 const char *type_hint);
943 * purple_request_field_set_tooltip:
944 * @field: The field.
945 * @tooltip: The tooltip text.
947 * Sets the tooltip for the field.
949 * This is optionally used by the UIs to provide a tooltip for
950 * the field.
952 void purple_request_field_set_tooltip(PurpleRequestField *field,
953 const char *tooltip);
956 * purple_request_field_set_required:
957 * @field: The field.
958 * @required: TRUE if required, or FALSE.
960 * Sets whether or not a field is required.
962 void purple_request_field_set_required(PurpleRequestField *field,
963 gboolean required);
966 * purple_request_field_get_field_type:
967 * @field: The field.
969 * Returns the type of a field.
971 * Returns: The field's type.
973 PurpleRequestFieldType purple_request_field_get_field_type(const PurpleRequestField *field);
976 * purple_request_field_get_group:
977 * @field: The field.
979 * Returns the group for the field.
981 * Returns: The UI data.
983 PurpleRequestFieldGroup *purple_request_field_get_group(const PurpleRequestField *field);
986 * purple_request_field_get_id:
987 * @field: The field.
989 * Returns the ID of a field.
991 * Returns: The ID
993 const char *purple_request_field_get_id(const PurpleRequestField *field);
996 * purple_request_field_get_label:
997 * @field: The field.
999 * Returns the label text of a field.
1001 * Returns: The label text.
1003 const char *purple_request_field_get_label(const PurpleRequestField *field);
1006 * purple_request_field_is_visible:
1007 * @field: The field.
1009 * Returns whether or not a field is visible.
1011 * Returns: TRUE if the field is visible. FALSE otherwise.
1013 gboolean purple_request_field_is_visible(const PurpleRequestField *field);
1016 * purple_request_field_get_type_hint:
1017 * @field: The field.
1019 * Returns the field's type hint.
1021 * Returns: The field's type hint.
1023 const char *purple_request_field_get_field_type_hint(const PurpleRequestField *field);
1026 * purple_request_field_get_tooltip:
1027 * @field: The field.
1029 * Returns the field's tooltip.
1031 * Returns: The field's tooltip.
1033 const char *purple_request_field_get_tooltip(const PurpleRequestField *field);
1036 * purple_request_field_is_required:
1037 * @field: The field.
1039 * Returns whether or not a field is required.
1041 * Returns: TRUE if the field is required, or FALSE.
1043 gboolean purple_request_field_is_required(const PurpleRequestField *field);
1046 * purple_request_field_is_filled:
1047 * @field: The field.
1049 * Checks, if specified field has value.
1051 * Returns: TRUE if the field has value, or FALSE.
1053 gboolean purple_request_field_is_filled(const PurpleRequestField *field);
1056 * purple_request_field_set_validator:
1057 * @field: The field.
1058 * @validator: The validator callback, NULL to disable validation.
1059 * @user_data: The data to pass to the callback.
1061 * Sets validator for a single field.
1063 void purple_request_field_set_validator(PurpleRequestField *field,
1064 PurpleRequestFieldValidator validator, void *user_data);
1067 * purple_request_field_is_validatable:
1068 * @field: The field.
1070 * Returns whether or not field has validator set.
1072 * Returns: TRUE if the field has validator, or FALSE.
1074 gboolean purple_request_field_is_validatable(PurpleRequestField *field);
1077 * purple_request_field_is_valid:
1078 * @field: The field.
1079 * @errmsg: If non-NULL, the memory area, where the pointer to validation
1080 * failure message will be set.
1082 * Checks, if specified field is valid.
1084 * If detailed message about failure reason is needed, there is an option to
1085 * return (via errmsg argument) pointer to newly allocated error message.
1086 * It must be freed with g_free after use.
1088 * Note: empty, not required fields are valid.
1090 * Returns: TRUE, if the field is valid, FALSE otherwise.
1092 gboolean purple_request_field_is_valid(PurpleRequestField *field, gchar **errmsg);
1095 * purple_request_field_set_sensitive:
1096 * @field: The field.
1097 * @sensitive: TRUE if the field should be sensitive for user input.
1099 * Sets field editable.
1101 void purple_request_field_set_sensitive(PurpleRequestField *field,
1102 gboolean sensitive);
1105 * purple_request_field_is_sensitive:
1106 * @field: The field.
1108 * Checks, if field is editable.
1110 * Returns: TRUE, if the field is sensitive for user input.
1112 gboolean purple_request_field_is_sensitive(PurpleRequestField *field);
1115 * purple_request_field_set_sensitivity_cb:
1116 * @field: The field.
1117 * @cb: The callback.
1119 * Sets the callback, used to determine if the field should be editable.
1121 void purple_request_field_set_sensitivity_cb(PurpleRequestField *field,
1122 PurpleRequestFieldSensitivityCb cb);
1125 * purple_request_field_get_ui_data:
1126 * @field: The field.
1128 * Returns the ui_data for a field.
1130 * Returns: The UI data.
1132 gpointer purple_request_field_get_ui_data(const PurpleRequestField *field);
1135 * purple_request_field_set_ui_data:
1136 * @field: The field.
1137 * @ui_data: The UI data.
1139 * Sets the ui_data for a field.
1141 void purple_request_field_set_ui_data(PurpleRequestField *field,
1142 gpointer ui_data);
1144 /**************************************************************************/
1145 /* String Field API */
1146 /**************************************************************************/
1149 * purple_request_field_string_new:
1150 * @id: The field ID.
1151 * @text: The text label of the field.
1152 * @default_value: The optional default value.
1153 * @multiline: Whether or not this should be a multiline string.
1155 * Creates a string request field.
1157 * Returns: The new field.
1159 PurpleRequestField *purple_request_field_string_new(const char *id,
1160 const char *text,
1161 const char *default_value,
1162 gboolean multiline);
1165 * purple_request_field_string_set_default_value:
1166 * @field: The field.
1167 * @default_value: The default value.
1169 * Sets the default value in a string field.
1171 void purple_request_field_string_set_default_value(PurpleRequestField *field,
1172 const char *default_value);
1175 * purple_request_field_string_set_value:
1176 * @field: The field.
1177 * @value: The value.
1179 * Sets the value in a string field.
1181 void purple_request_field_string_set_value(PurpleRequestField *field,
1182 const char *value);
1185 * purple_request_field_string_set_masked:
1186 * @field: The field.
1187 * @masked: The masked value.
1189 * Sets whether or not a string field is masked
1190 * (commonly used for password fields).
1192 void purple_request_field_string_set_masked(PurpleRequestField *field,
1193 gboolean masked);
1196 * purple_request_field_string_get_default_value:
1197 * @field: The field.
1199 * Returns the default value in a string field.
1201 * Returns: The default value.
1203 const char *purple_request_field_string_get_default_value(
1204 const PurpleRequestField *field);
1207 * purple_request_field_string_get_value:
1208 * @field: The field.
1210 * Returns the user-entered value in a string field.
1212 * Returns: The value.
1214 const char *purple_request_field_string_get_value(const PurpleRequestField *field);
1217 * purple_request_field_string_is_multiline:
1218 * @field: The field.
1220 * Returns whether or not a string field is multi-line.
1222 * Returns: %TRUE if the field is mulit-line, or %FALSE otherwise.
1224 gboolean purple_request_field_string_is_multiline(const PurpleRequestField *field);
1227 * purple_request_field_string_is_masked:
1228 * @field: The field.
1230 * Returns whether or not a string field is masked.
1232 * Returns: %TRUE if the field is masked, or %FALSE otherwise.
1234 gboolean purple_request_field_string_is_masked(const PurpleRequestField *field);
1236 /**************************************************************************/
1237 /* Integer Field API */
1238 /**************************************************************************/
1241 * purple_request_field_int_new:
1242 * @id: The field ID.
1243 * @text: The text label of the field.
1244 * @default_value: The default value.
1245 * @lower_bound: The lower bound.
1246 * @upper_bound: The upper bound.
1248 * Creates an integer field.
1250 * Returns: The new field.
1252 PurpleRequestField *purple_request_field_int_new(const char *id,
1253 const char *text, int default_value, int lower_bound, int upper_bound);
1256 * purple_request_field_int_set_default_value:
1257 * @field: The field.
1258 * @default_value: The default value.
1260 * Sets the default value in an integer field.
1262 void purple_request_field_int_set_default_value(PurpleRequestField *field,
1263 int default_value);
1266 * purple_request_field_int_set_lower_bound:
1267 * @field: The field.
1268 * @lower_bound: The lower bound.
1270 * Sets the lower bound in an integer field.
1272 void purple_request_field_int_set_lower_bound(PurpleRequestField *field, int lower_bound);
1275 * purple_request_field_int_set_upper_bound:
1276 * @field: The field.
1277 * @upper_bound: The upper bound.
1279 * Sets the upper bound in an integer field.
1281 void purple_request_field_int_set_upper_bound(PurpleRequestField *field, int upper_bound);
1284 * purple_request_field_int_set_value:
1285 * @field: The field.
1286 * @value: The value.
1288 * Sets the value in an integer field.
1290 void purple_request_field_int_set_value(PurpleRequestField *field, int value);
1293 * purple_request_field_int_get_default_value:
1294 * @field: The field.
1296 * Returns the default value in an integer field.
1298 * Returns: The default value.
1300 int purple_request_field_int_get_default_value(const PurpleRequestField *field);
1303 * purple_request_field_int_get_lower_bound:
1304 * @field: The field.
1306 * Returns the lower bound in an integer field.
1308 * Returns: The lower bound.
1310 int purple_request_field_int_get_lower_bound(const PurpleRequestField *field);
1313 * purple_request_field_int_get_upper_bound:
1314 * @field: The field.
1316 * Returns the upper bound in an integer field.
1318 * Returns: The upper bound.
1320 int purple_request_field_int_get_upper_bound(const PurpleRequestField *field);
1323 * purple_request_field_int_get_value:
1324 * @field: The field.
1326 * Returns the user-entered value in an integer field.
1328 * Returns: The value.
1330 int purple_request_field_int_get_value(const PurpleRequestField *field);
1332 /**************************************************************************/
1333 /* Boolean Field API */
1334 /**************************************************************************/
1337 * purple_request_field_bool_new:
1338 * @id: The field ID.
1339 * @text: The text label of the field.
1340 * @default_value: The default value.
1342 * Creates a boolean field.
1344 * This is often represented as a checkbox.
1346 * Returns: The new field.
1348 PurpleRequestField *purple_request_field_bool_new(const char *id,
1349 const char *text,
1350 gboolean default_value);
1353 * purple_request_field_bool_set_default_value:
1354 * @field: The field.
1355 * @default_value: The default value.
1357 * Sets the default value in an boolean field.
1359 void purple_request_field_bool_set_default_value(PurpleRequestField *field,
1360 gboolean default_value);
1363 * purple_request_field_bool_set_value:
1364 * @field: The field.
1365 * @value: The value.
1367 * Sets the value in an boolean field.
1369 void purple_request_field_bool_set_value(PurpleRequestField *field,
1370 gboolean value);
1373 * purple_request_field_bool_get_default_value:
1374 * @field: The field.
1376 * Returns the default value in an boolean field.
1378 * Returns: The default value.
1380 gboolean purple_request_field_bool_get_default_value(
1381 const PurpleRequestField *field);
1384 * purple_request_field_bool_get_value:
1385 * @field: The field.
1387 * Returns the user-entered value in an boolean field.
1389 * Returns: The value.
1391 gboolean purple_request_field_bool_get_value(const PurpleRequestField *field);
1393 /**************************************************************************/
1394 /* Choice Field API */
1395 /**************************************************************************/
1398 * purple_request_field_choice_new:
1399 * @id: The field ID.
1400 * @text: The optional label of the field.
1401 * @default_value: The default choice.
1403 * Creates a multiple choice field.
1405 * This is often represented as a group of radio buttons.
1407 * Returns: The new field.
1409 PurpleRequestField *
1410 purple_request_field_choice_new(const char *id, const char *text,
1411 gpointer default_value);
1414 * purple_request_field_choice_add:
1415 * @field: The choice field.
1416 * @label: The choice label.
1417 * @data: The choice value.
1419 * Adds a choice to a multiple choice field.
1421 void
1422 purple_request_field_choice_add(PurpleRequestField *field, const char *label,
1423 gpointer data);
1426 * purple_request_field_choice_set_default_value:
1427 * @field: The field.
1428 * @default_value: The default value.
1430 * Sets the default value in an choice field.
1432 void
1433 purple_request_field_choice_set_default_value(PurpleRequestField *field,
1434 gpointer default_value);
1437 * purple_request_field_choice_set_value:
1438 * @field: The field.
1439 * @value: The value.
1441 * Sets the value in an choice field.
1443 void
1444 purple_request_field_choice_set_value(PurpleRequestField *field,
1445 gpointer value);
1448 * purple_request_field_choice_get_default_value:
1449 * @field: The field.
1451 * Returns the default value in an choice field.
1453 * Returns: The default value.
1455 gpointer
1456 purple_request_field_choice_get_default_value(const PurpleRequestField *field);
1459 * purple_request_field_choice_get_value:
1460 * @field: The field.
1462 * Returns the user-entered value in an choice field.
1464 * Returns: The value.
1466 gpointer
1467 purple_request_field_choice_get_value(const PurpleRequestField *field);
1470 * purple_request_field_choice_get_elements:
1471 * @field: The field.
1473 * Returns a list of elements in a choice field.
1475 * Returns: (transfer none): The list of pairs of {label, value}.
1477 GList *
1478 purple_request_field_choice_get_elements(const PurpleRequestField *field);
1481 * purple_request_field_choice_set_data_destructor:
1482 * @field: The field.
1483 * @destroy: The destroy function.
1485 * Sets the destructor for field values.
1487 void
1488 purple_request_field_choice_set_data_destructor(PurpleRequestField *field,
1489 GDestroyNotify destroy);
1491 /**************************************************************************/
1492 /* List Field API */
1493 /**************************************************************************/
1496 * purple_request_field_list_new:
1497 * @id: The field ID.
1498 * @text: The optional label of the field.
1500 * Creates a multiple list item field.
1502 * Returns: The new field.
1504 PurpleRequestField *purple_request_field_list_new(const char *id, const char *text);
1507 * purple_request_field_list_set_multi_select:
1508 * @field: The list field.
1509 * @multi_select: TRUE if multiple selection is enabled,
1510 * or FALSE otherwise.
1512 * Sets whether or not a list field allows multiple selection.
1514 void purple_request_field_list_set_multi_select(PurpleRequestField *field,
1515 gboolean multi_select);
1518 * purple_request_field_list_get_multi_select:
1519 * @field: The list field.
1521 * Returns whether or not a list field allows multiple selection.
1523 * Returns: TRUE if multiple selection is enabled, or FALSE otherwise.
1525 gboolean purple_request_field_list_get_multi_select(
1526 const PurpleRequestField *field);
1529 * purple_request_field_list_get_data:
1530 * @field: The list field.
1531 * @text: The item text.
1533 * Returns the data for a particular item.
1535 * Returns: The data associated with the item.
1537 void *purple_request_field_list_get_data(const PurpleRequestField *field,
1538 const char *text);
1541 * purple_request_field_list_add_icon:
1542 * @field: The list field.
1543 * @item: The list item.
1544 * @icon_path: The path to icon file, or %NULL for no icon.
1545 * @data: The associated data.
1547 * Adds an item to a list field.
1549 void purple_request_field_list_add_icon(PurpleRequestField *field,
1550 const char *item, const char* icon_path, void* data);
1553 * purple_request_field_list_add_selected:
1554 * @field: The field.
1555 * @item: The item to add.
1557 * Adds a selected item to the list field.
1559 void purple_request_field_list_add_selected(PurpleRequestField *field,
1560 const char *item);
1563 * purple_request_field_list_clear_selected:
1564 * @field: The field.
1566 * Clears the list of selected items in a list field.
1568 void purple_request_field_list_clear_selected(PurpleRequestField *field);
1571 * purple_request_field_list_set_selected:
1572 * @field: The field.
1573 * @items: (element-type utf8) (transfer none): The list of selected items.
1575 * Sets a list of selected items in a list field.
1577 void purple_request_field_list_set_selected(PurpleRequestField *field,
1578 GList *items);
1581 * purple_request_field_list_is_selected:
1582 * @field: The field.
1583 * @item: The item.
1585 * Returns whether or not a particular item is selected in a list field.
1587 * Returns: TRUE if the item is selected. FALSE otherwise.
1589 gboolean purple_request_field_list_is_selected(const PurpleRequestField *field,
1590 const char *item);
1593 * purple_request_field_list_get_selected:
1594 * @field: The field.
1596 * Returns a list of selected items in a list field.
1598 * To retrieve the data for each item, use
1599 * purple_request_field_list_get_data().
1601 * Returns: (element-type utf8) (transfer none): The list of selected items.
1603 GList *purple_request_field_list_get_selected(
1604 const PurpleRequestField *field);
1607 * purple_request_field_list_get_items:
1608 * @field: The field.
1610 * Returns a list of items in a list field.
1612 * Returns: (element-type utf8) (transfer none): The list of items.
1614 GList *purple_request_field_list_get_items(const PurpleRequestField *field);
1617 * purple_request_field_list_get_icons:
1618 * @field: The field.
1620 * Returns a list of icons in a list field.
1622 * The icons will correspond with the items, in order.
1624 * Returns: (element-type utf8) (transfer none): The list of icons or %NULL (i.e. the empty #GList)
1625 * if no items have icons.
1627 GList *purple_request_field_list_get_icons(const PurpleRequestField *field);
1629 /**************************************************************************/
1630 /* Label Field API */
1631 /**************************************************************************/
1634 * purple_request_field_label_new:
1635 * @id: The field ID.
1636 * @text: The label of the field.
1638 * Creates a label field.
1640 * Returns: The new field.
1642 PurpleRequestField *purple_request_field_label_new(const char *id,
1643 const char *text);
1645 /**************************************************************************/
1646 /* Image Field API */
1647 /**************************************************************************/
1650 * purple_request_field_image_new:
1651 * @id: The field ID.
1652 * @text: The label of the field.
1653 * @buf: The image data.
1654 * @size: The size of the data in @buf.
1656 * Creates an image field.
1658 * Returns: The new field.
1660 PurpleRequestField *purple_request_field_image_new(const char *id, const char *text,
1661 const char *buf, gsize size);
1664 * purple_request_field_image_set_scale:
1665 * @field: The image field.
1666 * @x: The x scale factor.
1667 * @y: The y scale factor.
1669 * Sets the scale factors of an image field.
1671 void purple_request_field_image_set_scale(PurpleRequestField *field, unsigned int x, unsigned int y);
1674 * purple_request_field_image_get_buffer:
1675 * @field: The image field.
1677 * Returns pointer to the image.
1679 * Returns: Pointer to the image.
1681 const char *purple_request_field_image_get_buffer(PurpleRequestField *field);
1684 * purple_request_field_image_get_size:
1685 * @field: The image field.
1687 * Returns size (in bytes) of the image.
1689 * Returns: Size of the image.
1691 gsize purple_request_field_image_get_size(PurpleRequestField *field);
1694 * purple_request_field_image_get_scale_x:
1695 * @field: The image field.
1697 * Returns X scale coefficient of the image.
1699 * Returns: X scale coefficient of the image.
1701 unsigned int purple_request_field_image_get_scale_x(PurpleRequestField *field);
1704 * purple_request_field_image_get_scale_y:
1705 * @field: The image field.
1707 * Returns Y scale coefficient of the image.
1709 * Returns: Y scale coefficient of the image.
1711 unsigned int purple_request_field_image_get_scale_y(PurpleRequestField *field);
1713 /**************************************************************************/
1714 /* Account Field API */
1715 /**************************************************************************/
1718 * purple_request_field_account_new:
1719 * @id: The field ID.
1720 * @text: The text label of the field.
1721 * @account: The optional default account.
1723 * Creates an account field.
1725 * By default, this field will not show offline accounts.
1727 * Returns: The new field.
1729 PurpleRequestField *purple_request_field_account_new(const char *id,
1730 const char *text,
1731 PurpleAccount *account);
1734 * purple_request_field_account_set_default_value:
1735 * @field: The account field.
1736 * @default_value: The default account.
1738 * Sets the default account on an account field.
1740 void purple_request_field_account_set_default_value(PurpleRequestField *field,
1741 PurpleAccount *default_value);
1744 * purple_request_field_account_set_value:
1745 * @field: The account field.
1746 * @value: The account.
1748 * Sets the account in an account field.
1750 void purple_request_field_account_set_value(PurpleRequestField *field,
1751 PurpleAccount *value);
1754 * purple_request_field_account_set_show_all:
1755 * @field: The account field.
1756 * @show_all: Whether or not to show all accounts.
1758 * Sets whether or not to show all accounts in an account field.
1760 * If TRUE, all accounts, online or offline, will be shown. If FALSE,
1761 * only online accounts will be shown.
1763 void purple_request_field_account_set_show_all(PurpleRequestField *field,
1764 gboolean show_all);
1767 * purple_request_field_account_set_filter:
1768 * @field: The account field.
1769 * @filter_func: The account filter function.
1771 * Sets the account filter function in an account field.
1773 * This function will determine which accounts get displayed and which
1774 * don't.
1776 void purple_request_field_account_set_filter(PurpleRequestField *field,
1777 PurpleFilterAccountFunc filter_func);
1780 * purple_request_field_account_get_default_value:
1781 * @field: The field.
1783 * Returns the default account in an account field.
1785 * Returns: (transfer none): The default account.
1787 PurpleAccount *purple_request_field_account_get_default_value(
1788 const PurpleRequestField *field);
1791 * purple_request_field_account_get_value:
1792 * @field: The field.
1794 * Returns the user-entered account in an account field.
1796 * Returns: (transfer none): The user-entered account.
1798 PurpleAccount *purple_request_field_account_get_value(
1799 const PurpleRequestField *field);
1802 * purple_request_field_account_get_show_all:
1803 * @field: The account field.
1805 * Returns whether or not to show all accounts in an account field.
1807 * If TRUE, all accounts, online or offline, will be shown. If FALSE,
1808 * only online accounts will be shown.
1810 * Returns: Whether or not to show all accounts.
1812 gboolean purple_request_field_account_get_show_all(
1813 const PurpleRequestField *field);
1816 * purple_request_field_account_get_filter:
1817 * @field: The account field.
1819 * Returns the account filter function in an account field.
1821 * This function will determine which accounts get displayed and which
1822 * don't.
1824 * Returns: The account filter function.
1826 PurpleFilterAccountFunc purple_request_field_account_get_filter(
1827 const PurpleRequestField *field);
1829 /**************************************************************************/
1830 /* Datasheet Field API */
1831 /**************************************************************************/
1834 * purple_request_field_datasheet_new:
1835 * @id: The field ID.
1836 * @text: The label of the field, may be %NULL.
1837 * @sheet: The datasheet.
1839 * Creates a datasheet item field.
1841 * Returns: The new field.
1843 PurpleRequestField *purple_request_field_datasheet_new(const char *id,
1844 const gchar *text, PurpleRequestDatasheet *sheet);
1847 * purple_request_field_datasheet_get_sheet:
1848 * @field: The field.
1850 * Returns a datasheet for a field.
1852 * Returns: (transfer none): The datasheet object.
1854 PurpleRequestDatasheet *purple_request_field_datasheet_get_sheet(
1855 PurpleRequestField *field);
1857 /**************************************************************************/
1858 /* Validators for request fields. */
1859 /**************************************************************************/
1862 * purple_request_field_email_validator:
1863 * @field: The field.
1864 * @errmsg: (out) (optional): destination for error message.
1865 * @user_data: Ignored.
1867 * Validates a field which should contain an email address.
1869 * See purple_request_field_set_validator().
1871 * Returns: TRUE, if field contains valid email address.
1873 gboolean purple_request_field_email_validator(PurpleRequestField *field,
1874 gchar **errmsg, void *user_data);
1877 * purple_request_field_alphanumeric_validator:
1878 * @field: The field.
1879 * @errmsg: (allow-none): destination for error message.
1880 * @allowed_characters: (allow-none): allowed character list
1881 * (NULL-terminated string).
1883 * Validates a field which should contain alphanumeric content.
1885 * See purple_request_field_set_validator().
1887 * Returns: TRUE, if field contains only alphanumeric characters.
1889 gboolean purple_request_field_alphanumeric_validator(PurpleRequestField *field,
1890 gchar **errmsg, void *allowed_characters);
1892 /**************************************************************************/
1893 /* Request API */
1894 /**************************************************************************/
1897 * purple_request_input:
1898 * @handle: The plugin or connection handle. For some
1899 * things this is <emphasis>extremely</emphasis> important. The
1900 * handle is used to programmatically close the request
1901 * dialog when it is no longer needed. For protocols this
1902 * is often a pointer to the #PurpleConnection
1903 * instance. For plugins this should be a similar,
1904 * unique memory location. This value is important
1905 * because it allows a request to be closed with
1906 * purple_request_close_with_handle() when, for
1907 * example, you sign offline. If the request is
1908 * <emphasis>not</emphasis> closed it is
1909 * <emphasis>very</emphasis> likely to cause a crash whenever
1910 * the callback handler functions are triggered.
1911 * @title: The title of the message, or %NULL if it should have
1912 * no title.
1913 * @primary: The main point of the message, or %NULL if you're
1914 * feeling enigmatic.
1915 * @secondary: Secondary information, or %NULL if there is none.
1916 * @default_value: The default value.
1917 * @multiline: %TRUE if the inputted text can span multiple lines.
1918 * @masked: %TRUE if the inputted text should be masked in some
1919 * way (such as by displaying characters as stars). This
1920 * might be because the input is some kind of password.
1921 * @hint: Optionally suggest how the input box should appear.
1922 * Use "html", for example, to allow the user to enter HTML.
1923 * @ok_text: The text for the <literal>OK</literal> button, which may not
1924 * be %NULL.
1925 * @ok_cb: The callback for the <literal>OK</literal> button, which may
1926 * not be %NULL.
1927 * @cancel_text: The text for the <literal>Cancel</literal> button, which may
1928 * not be %NULL.
1929 * @cancel_cb: The callback for the <literal>Cancel</literal> button, which
1930 * may be %NULL.
1931 * @cpar: The #PurpleRequestCommonParameters object, which gets
1932 * unref'ed after this call.
1933 * @user_data: The data to pass to the callback.
1935 * Prompts the user for text input.
1937 * Returns: A UI-specific handle.
1939 void *purple_request_input(void *handle, const char *title, const char *primary,
1940 const char *secondary, const char *default_value, gboolean multiline,
1941 gboolean masked, gchar *hint,
1942 const char *ok_text, GCallback ok_cb,
1943 const char *cancel_text, GCallback cancel_cb,
1944 PurpleRequestCommonParameters *cpar,
1945 void *user_data);
1948 * purple_request_choice:
1949 * @handle: The plugin or connection handle. For some things this
1950 * is <emphasis>extremely</emphasis> important. See the comments on
1951 * purple_request_input().
1952 * @title: The title of the message, or %NULL if it should have
1953 * no title.
1954 * @primary: The main point of the message, or %NULL if you're
1955 * feeling enigmatic.
1956 * @secondary: Secondary information, or %NULL if there is none.
1957 * @default_value: The default choice; this should be one of the values
1958 * listed in the varargs.
1959 * @ok_text: The text for the <literal>OK</literal> button, which may not
1960 * be %NULL.
1961 * @ok_cb: The callback for the <literal>OK</literal> button, which may
1962 * not be %NULL.
1963 * @cancel_text: The text for the <literal>Cancel</literal> button, which may
1964 * not be %NULL.
1965 * @cancel_cb: The callback for the <literal>Cancel</literal> button, or
1966 * %NULL to do nothing.
1967 * @cpar: The #PurpleRequestCommonParameters object, which gets
1968 * unref'ed after this call.
1969 * @user_data: The data to pass to the callback.
1970 * @...: The choices, which should be pairs of <type>char *</type>
1971 * descriptions and <type>int</type> values, terminated with a
1972 * %NULL parameter.
1974 * Prompts the user for multiple-choice input.
1976 * Returns: A UI-specific handle.
1978 void *purple_request_choice(void *handle, const char *title, const char *primary,
1979 const char *secondary, gpointer default_value,
1980 const char *ok_text, GCallback ok_cb,
1981 const char *cancel_text, GCallback cancel_cb,
1982 PurpleRequestCommonParameters *cpar,
1983 void *user_data, ...) G_GNUC_NULL_TERMINATED;
1986 * purple_request_choice_varg:
1987 * @handle: The plugin or connection handle. For some things this
1988 * is <emphasis>extremely</emphasis> important. See the comments on
1989 * purple_request_input().
1990 * @title: The title of the message, or %NULL if it should have
1991 * no title.
1992 * @primary: The main point of the message, or %NULL if you're
1993 * feeling enigmatic.
1994 * @secondary: Secondary information, or %NULL if there is none.
1995 * @default_value: The default choice; this should be one of the values
1996 * listed in the varargs.
1997 * @ok_text: The text for the <literal>OK</literal> button, which may not
1998 * be %NULL.
1999 * @ok_cb: The callback for the <literal>OK</literal> button, which may
2000 * not be %NULL.
2001 * @cancel_text: The text for the <literal>Cancel</literal> button, which may
2002 * not be %NULL.
2003 * @cancel_cb: The callback for the <literal>Cancel</literal> button, or
2004 * %NULL to do nothing.
2005 * @cpar: The #PurpleRequestCommonParameters object, which gets
2006 * unref'ed after this call.
2007 * @user_data: The data to pass to the callback.
2008 * @choices: The choices, which should be pairs of <type>char *</type>
2009 * descriptions and <type>int</type> values, terminated with a
2010 * %NULL parameter.
2012 * <literal>va_list</literal> version of purple_request_choice(); see its
2013 * documentation.
2015 void *purple_request_choice_varg(void *handle, const char *title,
2016 const char *primary, const char *secondary, gpointer default_value,
2017 const char *ok_text, GCallback ok_cb,
2018 const char *cancel_text, GCallback cancel_cb,
2019 PurpleRequestCommonParameters *cpar,
2020 void *user_data, va_list choices);
2023 * purple_request_action:
2024 * @handle: The plugin or connection handle. For some things this
2025 * is <emphasis>extremely</emphasis> important. See the comments on
2026 * purple_request_input().
2027 * @title: The title of the message, or %NULL if it should have
2028 * no title.
2029 * @primary: The main point of the message, or %NULL if you're
2030 * feeling enigmatic.
2031 * @secondary: Secondary information, or %NULL if there is none.
2032 * @default_action: The default action, zero-indexed; if the third action
2033 * supplied should be the default, supply
2034 * <literal>2</literal>. This should be the action that
2035 * users are most likely to select.
2036 * @cpar: The #PurpleRequestCommonParameters object, which gets
2037 * unref'ed after this call.
2038 * @user_data: The data to pass to the callback.
2039 * @action_count: The number of actions.
2040 * @...: A list of actions. These are pairs of
2041 * arguments. The first of each pair is the
2042 * <type>char *</type> label that appears on the button.
2043 * It should have an underscore before the letter you want
2044 * to use as the accelerator key for the button. The
2045 * second of each pair is the #PurpleRequestActionCb
2046 * function to use when the button is clicked.
2048 * Prompts the user for an action.
2050 * This is often represented as a dialog with a button for each action.
2052 * Returns: A UI-specific handle.
2054 void *
2055 purple_request_action(void *handle, const char *title, const char *primary,
2056 const char *secondary, int default_action,
2057 PurpleRequestCommonParameters *cpar, void *user_data,
2058 size_t action_count, ...);
2061 * purple_request_action_varg:
2062 * @handle: The plugin or connection handle. For some things this
2063 * is <emphasis>extremely</emphasis> important. See the comments on
2064 * purple_request_input().
2065 * @title: The title of the message, or %NULL if it should have
2066 * no title.
2067 * @primary: The main point of the message, or %NULL if you're
2068 * feeling enigmatic.
2069 * @secondary: Secondary information, or %NULL if there is none.
2070 * @default_action: The default action, zero-indexed; if the third action
2071 * supplied should be the default, supply
2072 * <literal>2</literal>. This should be the action that
2073 * users are most likely to select.
2074 * @cpar: The #PurpleRequestCommonParameters object, which gets
2075 * unref'ed after this call.
2076 * @user_data: The data to pass to the callback.
2077 * @action_count: The number of actions.
2078 * @actions: A list of actions. These are pairs of
2079 * arguments. The first of each pair is the
2080 * <type>char *</type> label that appears on the button.
2081 * It should have an underscore before the letter you want
2082 * to use as the accelerator key for the button. The
2083 * second of each pair is the #PurpleRequestActionCb
2084 * function to use when the button is clicked.
2086 * <literal>va_list</literal> version of purple_request_action(); see its
2087 * documentation.
2089 void *
2090 purple_request_action_varg(void *handle, const char *title, const char *primary,
2091 const char *secondary, int default_action,
2092 PurpleRequestCommonParameters *cpar, void *user_data,
2093 size_t action_count, va_list actions);
2096 * purple_request_wait:
2097 * @handle: The plugin or connection handle. For some things this
2098 * is <emphasis>extremely</emphasis> important. See the comments on
2099 * purple_request_input().
2100 * @title: The title of the message, or %NULL if it should have
2101 * default title.
2102 * @primary: The main point of the message, or %NULL if you're
2103 * feeling enigmatic.
2104 * @secondary: Secondary information, or %NULL if there is none.
2105 * @with_progress: %TRUE, if we want to display progress bar, %FALSE
2106 * otherwise
2107 * @cancel_cb: The callback for the <literal>Cancel</literal> button, which
2108 * may be %NULL.
2109 * @cpar: The #PurpleRequestCommonParameters object, which gets
2110 * unref'ed after this call.
2111 * @user_data: The data to pass to the callback.
2113 * Displays a "please wait" dialog.
2115 * Returns: A UI-specific handle.
2117 void *
2118 purple_request_wait(void *handle, const char *title, const char *primary,
2119 const char *secondary, gboolean with_progress,
2120 PurpleRequestCancelCb cancel_cb, PurpleRequestCommonParameters *cpar,
2121 void *user_data);
2124 * purple_request_wait_pulse:
2125 * @ui_handle: The request UI handle.
2127 * Notifies the "please wait" dialog that some progress has been made, but you
2128 * don't know how much.
2130 void
2131 purple_request_wait_pulse(void *ui_handle);
2134 * purple_request_wait_progress:
2135 * @ui_handle: The request UI handle.
2136 * @fraction: The part of task that is done (between 0.0 and 1.0,
2137 * inclusive).
2139 * Notifies the "please wait" dialog about progress has been made.
2141 void
2142 purple_request_wait_progress(void *ui_handle, gfloat fraction);
2145 * purple_request_fields:
2146 * @handle: The plugin or connection handle. For some things this
2147 * is <emphasis>extremely</emphasis> important. See the comments on
2148 * purple_request_input().
2149 * @title: The title of the message, or %NULL if it should have
2150 * no title.
2151 * @primary: The main point of the message, or %NULL if you're
2152 * feeling enigmatic.
2153 * @secondary: Secondary information, or %NULL if there is none.
2154 * @fields: The list of fields.
2155 * @ok_text: The text for the <literal>OK</literal> button, which may not be
2156 * %NULL.
2157 * @ok_cb: The callback for the <literal>OK</literal> button, which may
2158 * not be
2159 * %NULL.
2160 * @cancel_text: The text for the <literal>Cancel</literal> button, which may
2161 * not be %NULL.
2162 * @cancel_cb: The callback for the <literal>Cancel</literal> button, which
2163 * may be %NULL.
2164 * @cpar: The #PurpleRequestCommonParameters object, which gets
2165 * unref'ed after this call.
2166 * @user_data: The data to pass to the callback.
2168 * Displays groups of fields for the user to fill in.
2170 * Returns: A UI-specific handle.
2172 void *
2173 purple_request_fields(void *handle, const char *title, const char *primary,
2174 const char *secondary, PurpleRequestFields *fields,
2175 const char *ok_text, GCallback ok_cb,
2176 const char *cancel_text, GCallback cancel_cb,
2177 PurpleRequestCommonParameters *cpar,
2178 void *user_data);
2181 * purple_request_is_valid_ui_handle:
2182 * @ui_handle: The UI handle.
2183 * @type: The pointer to variable, where request type may be stored
2184 * (may be %NULL).
2186 * Checks, if passed UI handle is valid.
2188 * Returns: TRUE, if handle is valid, FALSE otherwise.
2190 gboolean
2191 purple_request_is_valid_ui_handle(void *ui_handle, PurpleRequestType *type);
2194 * purple_request_add_close_notify:
2195 * @ui_handle: The UI handle.
2196 * @notify: The function to be called.
2197 * @notify_data: The data to be passed to the callback function.
2199 * Adds a function called when notification dialog is closed.
2201 void
2202 purple_request_add_close_notify(void *ui_handle, GDestroyNotify notify,
2203 gpointer notify_data);
2206 * purple_request_close:
2207 * @type: The request type.
2208 * @uihandle: The request UI handle.
2210 * Closes a request.
2212 void purple_request_close(PurpleRequestType type, void *uihandle);
2215 * purple_request_close_with_handle:
2216 * @handle: The handle, as supplied as the @handle parameter to one of the
2217 * <literal>purple_request_*</literal> functions.
2219 * Closes all requests registered with the specified handle.
2221 * See purple_request_input().
2223 void purple_request_close_with_handle(void *handle);
2226 * purple_request_yes_no:
2227 * @handle: The handle, as supplied as the @handle parameter to one of the
2228 * <literal>purple_request_*</literal> functions.
2229 * @title: The title of the message, or %NULL if it should have
2230 * no title.
2231 * @primary: The main point of the message, or %NULL if you're
2232 * feeling enigmatic.
2233 * @secondary: Secondary information, or %NULL if there is none.
2234 * @default_action: The default action, zero-indexed; if the third action
2235 * supplied should be the default, supply
2236 * <literal>2</literal>. This should be the action that
2237 * users are most likely to select.
2238 * @cpar: The #PurpleRequestCommonParameters object, which gets
2239 * unref'ed after this call.
2240 * @user_data: The data to pass to the callback.
2241 * @yes_cb: A #PurpleRequestActionCb to call when yes is selected.
2242 * @no_cb: A #PurpleRequestActionCb to call when no is selected.
2244 * A wrapper for purple_request_action() that uses <literal>Yes</literal> and
2245 * <literal>No</literal> buttons.
2247 #define purple_request_yes_no(handle, title, primary, secondary, default_action, cpar, user_data, yes_cb, no_cb) \
2248 purple_request_action((handle), (title), (primary), (secondary), \
2249 (default_action), (cpar), (user_data), 2, _("_Yes"), (yes_cb), \
2250 _("_No"), (no_cb))
2253 * purple_request_ok_cancel:
2254 * @handle: The handle, as supplied as the @handle parameter to one of
2255 * the <literal>purple_request_*</literal> functions.
2256 * @title: The title of the message, or %NULL if it should have
2257 * no title.
2258 * @primary: The main point of the message, or %NULL if you're
2259 * feeling enigmatic.
2260 * @secondary: Secondary information, or %NULL if there is none.
2261 * @default_action: The default action, zero-indexed; if the third action
2262 * supplied should be the default, supply
2263 * <literal>2</literal>. This should be the action that
2264 * users are most likely to select.
2265 * @cpar: The #PurpleRequestCommonParameters object, which gets
2266 * unref'ed after this call.
2267 * @user_data: The data to pass to the callback.
2268 * @ok_cb: A #PurpleRequestActionCb to call when ok is selected.
2269 * @cancel_cb: A #PurpleRequestActionCb to call when cancel is selected.
2271 * A wrapper for purple_request_action() that uses <literal>OK</literal> and
2272 * <literal>Cancel</literal> buttons.
2274 #define purple_request_ok_cancel(handle, title, primary, secondary, default_action, cpar, user_data, ok_cb, cancel_cb) \
2275 purple_request_action((handle), (title), (primary), (secondary), \
2276 (default_action), (cpar), (user_data), 2, _("_OK"), (ok_cb), \
2277 _("_Cancel"), (cancel_cb))
2280 * purple_request_accept_cancel:
2281 * @handle: The handle, as supplied as the @handle parameter to one of
2282 * the <literal>purple_request_*</literal> functions.
2283 * @title: The title of the message, or %NULL if it should have
2284 * no title.
2285 * @primary: The main point of the message, or %NULL if you're
2286 * feeling enigmatic.
2287 * @secondary: Secondary information, or %NULL if there is none.
2288 * @default_action: The default action, zero-indexed; if the third action
2289 * supplied should be the default, supply
2290 * <literal>2</literal>. This should be the action that
2291 * users are most likely to select.
2292 * @cpar: The #PurpleRequestCommonParameters object, which gets
2293 * unref'ed after this call.
2294 * @user_data: The data to pass to the callback.
2295 * @accept_cb: A #PurpleRequestActionCb to call when accepted is selected.
2296 * @cancel_cb: A #PurpleRequestActionCb to call when cancel is selected.
2298 * A wrapper for purple_request_action() that uses Accept and Cancel buttons.
2300 #define purple_request_accept_cancel(handle, title, primary, secondary, default_action, cpar, user_data, accept_cb, cancel_cb) \
2301 purple_request_action((handle), (title), (primary), (secondary), \
2302 (default_action), (cpar), (user_data), 2, _("_Accept"), \
2303 (accept_cb), _("_Cancel"), (cancel_cb))
2306 * purple_request_file:
2307 * @handle: The plugin or connection handle. For some things this
2308 * is <emphasis>extremely</emphasis> important. See the comments
2309 * on purple_request_input().
2310 * @title: The title of the message, or %NULL if it should have no title.
2311 * @filename: The default filename (may be %NULL)
2312 * @savedialog: True if this dialog is being used to save a file. False if
2313 * it is being used to open a file.
2314 * @ok_cb: The callback for the <literal>OK</literal> button.
2315 * @cancel_cb: The callback for the <literal>Cancel</literal> button, which
2316 * may be %NULL.
2317 * @cpar: The #PurpleRequestCommonParameters object, which gets unref'ed
2318 * after this call.
2319 * @user_data: The data to pass to the callback.
2321 * Displays a file selector request dialog. Returns the selected filename to
2322 * the callback. Can be used for either opening a file or saving a file.
2324 * Returns: A UI-specific handle.
2326 void *
2327 purple_request_file(void *handle, const char *title, const char *filename,
2328 gboolean savedialog, GCallback ok_cb, GCallback cancel_cb,
2329 PurpleRequestCommonParameters *cpar, void *user_data);
2332 * purple_request_folder:
2333 * @handle: The plugin or connection handle. For some things this is
2334 * <emphasis>extremely</emphasis> important. See the comments on
2335 * purple_request_input().
2336 * @title: The title of the message, or %NULL if it should have no title.
2337 * @dirname: The default directory name (may be %NULL)
2338 * @ok_cb: The callback for the <literal>OK</literal> button.
2339 * @cancel_cb: The callback for the <literal>Cancel</literal> button, which
2340 * may be %NULL.
2341 * @cpar: The #PurpleRequestCommonParameters object, which gets unref'ed
2342 * after this call.
2343 * @user_data: The data to pass to the callback.
2345 * Displays a folder select dialog. Returns the selected filename to
2346 * the callback.
2348 * Returns: A UI-specific handle.
2350 void *
2351 purple_request_folder(void *handle, const char *title, const char *dirname,
2352 GCallback ok_cb, GCallback cancel_cb,
2353 PurpleRequestCommonParameters *cpar, void *user_data);
2355 /**************************************************************************/
2356 /* UI Registration Functions */
2357 /**************************************************************************/
2360 * purple_request_ui_ops_get_type:
2362 * Returns: The #GType for the #PurpleRequestUiOps boxed structure.
2364 GType purple_request_ui_ops_get_type(void);
2367 * purple_request_set_ui_ops:
2368 * @ops: The UI operations structure.
2370 * Sets the UI operations structure to be used when displaying a
2371 * request.
2373 void purple_request_set_ui_ops(PurpleRequestUiOps *ops);
2376 * purple_request_get_ui_ops:
2378 * Returns the UI operations structure to be used when displaying a
2379 * request.
2381 * Returns: The UI operations structure.
2383 PurpleRequestUiOps *purple_request_get_ui_ops(void);
2385 G_END_DECLS
2387 #endif /* PURPLE_REQUEST_H */