I think this was accidentally changed in revision
[pidgin-git.git] / libpurple / request.h
blob8035ef806bb3f7c7c4b622299cb4c6a5ec72871f
1 /**
2 * @file request.h Request API
3 * @ingroup core
4 */
6 /* purple
8 * Purple is the legal property of its developers, whose names are too numerous
9 * to list here. Please refer to the COPYRIGHT file distributed with this
10 * source distribution.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
26 #ifndef _PURPLE_REQUEST_H_
27 #define _PURPLE_REQUEST_H_
29 #include <stdlib.h>
30 #include <glib-object.h>
31 #include <glib.h>
33 /** @copydoc _PurpleRequestField */
34 typedef struct _PurpleRequestField PurpleRequestField;
36 #include "account.h"
38 #define PURPLE_DEFAULT_ACTION_NONE -1
40 /**
41 * Request types.
43 typedef enum
45 PURPLE_REQUEST_INPUT = 0, /**< Text input request. */
46 PURPLE_REQUEST_CHOICE, /**< Multiple-choice request. */
47 PURPLE_REQUEST_ACTION, /**< Action request. */
48 PURPLE_REQUEST_FIELDS, /**< Multiple fields request. */
49 PURPLE_REQUEST_FILE, /**< File open or save request. */
50 PURPLE_REQUEST_FOLDER /**< Folder selection request. */
52 } PurpleRequestType;
54 /**
55 * A type of field.
57 typedef enum
59 PURPLE_REQUEST_FIELD_NONE,
60 PURPLE_REQUEST_FIELD_STRING,
61 PURPLE_REQUEST_FIELD_INTEGER,
62 PURPLE_REQUEST_FIELD_BOOLEAN,
63 PURPLE_REQUEST_FIELD_CHOICE,
64 PURPLE_REQUEST_FIELD_LIST,
65 PURPLE_REQUEST_FIELD_LABEL,
66 PURPLE_REQUEST_FIELD_IMAGE,
67 PURPLE_REQUEST_FIELD_ACCOUNT
69 } PurpleRequestFieldType;
71 /**
72 * Multiple fields request data.
74 typedef struct
76 GList *groups;
78 GHashTable *fields;
80 GList *required_fields;
82 void *ui_data;
84 } PurpleRequestFields;
86 /**
87 * A group of fields with a title.
89 typedef struct
91 PurpleRequestFields *fields_list;
93 char *title;
95 GList *fields;
97 } PurpleRequestFieldGroup;
99 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_REQUEST_C_)
101 * A request field.
103 struct _PurpleRequestField
105 PurpleRequestFieldType type;
106 PurpleRequestFieldGroup *group;
108 char *id;
109 char *label;
110 char *type_hint;
112 gboolean visible;
113 gboolean required;
115 union
117 struct
119 gboolean multiline;
120 gboolean masked;
121 gboolean editable;
122 char *default_value;
123 char *value;
125 } string;
127 struct
129 int default_value;
130 int value;
132 } integer;
134 struct
136 gboolean default_value;
137 gboolean value;
139 } boolean;
141 struct
143 int default_value;
144 int value;
146 GList *labels;
148 } choice;
150 struct
152 GList *items;
153 GList *icons;
154 GHashTable *item_data;
155 GList *selected;
156 GHashTable *selected_table;
158 gboolean multiple_selection;
160 } list;
162 struct
164 PurpleAccount *default_account;
165 PurpleAccount *account;
166 gboolean show_all;
168 PurpleFilterAccountFunc filter_func;
170 } account;
172 struct
174 unsigned int scale_x;
175 unsigned int scale_y;
176 const char *buffer;
177 gsize size;
178 } image;
180 } u;
182 void *ui_data;
185 #endif
188 * Request UI operations.
190 typedef struct
192 /** @see purple_request_input(). */
193 void *(*request_input)(const char *title, const char *primary,
194 const char *secondary, const char *default_value,
195 gboolean multiline, gboolean masked, gchar *hint,
196 const char *ok_text, GCallback ok_cb,
197 const char *cancel_text, GCallback cancel_cb,
198 PurpleAccount *account, const char *who,
199 PurpleConversation *conv, void *user_data);
201 /** @see purple_request_choice_varg(). */
202 void *(*request_choice)(const char *title, const char *primary,
203 const char *secondary, int default_value,
204 const char *ok_text, GCallback ok_cb,
205 const char *cancel_text, GCallback cancel_cb,
206 PurpleAccount *account, const char *who,
207 PurpleConversation *conv, void *user_data,
208 va_list choices);
210 /** @see purple_request_action_varg(). */
211 void *(*request_action)(const char *title, const char *primary,
212 const char *secondary, int default_action,
213 PurpleAccount *account, const char *who,
214 PurpleConversation *conv, void *user_data,
215 size_t action_count, va_list actions);
217 /** @see purple_request_fields(). */
218 void *(*request_fields)(const char *title, const char *primary,
219 const char *secondary, PurpleRequestFields *fields,
220 const char *ok_text, GCallback ok_cb,
221 const char *cancel_text, GCallback cancel_cb,
222 PurpleAccount *account, const char *who,
223 PurpleConversation *conv, void *user_data);
225 /** @see purple_request_file(). */
226 void *(*request_file)(const char *title, const char *filename,
227 gboolean savedialog, GCallback ok_cb,
228 GCallback cancel_cb, PurpleAccount *account,
229 const char *who, PurpleConversation *conv,
230 void *user_data);
232 void (*close_request)(PurpleRequestType type, void *ui_handle);
234 /** @see purple_request_folder(). */
235 void *(*request_folder)(const char *title, const char *dirname,
236 GCallback ok_cb, GCallback cancel_cb,
237 PurpleAccount *account, const char *who,
238 PurpleConversation *conv, void *user_data);
240 /** @see purple_request_action_with_icon_varg(). */
241 void *(*request_action_with_icon)(const char *title, const char *primary,
242 const char *secondary, int default_action,
243 PurpleAccount *account, const char *who,
244 PurpleConversation *conv,
245 gconstpointer icon_data, gsize icon_size,
246 void *user_data,
247 size_t action_count, va_list actions);
249 void (*_purple_reserved1)(void);
250 void (*_purple_reserved2)(void);
251 void (*_purple_reserved3)(void);
252 } PurpleRequestUiOps;
254 typedef void (*PurpleRequestInputCb)(void *, const char *);
256 /** The type of callbacks passed to purple_request_action(). The first
257 * argument is the @a user_data parameter; the second is the index in the list
258 * of actions of the one chosen.
260 typedef void (*PurpleRequestActionCb)(void *, int);
261 typedef void (*PurpleRequestChoiceCb)(void *, int);
262 typedef void (*PurpleRequestFieldsCb)(void *, PurpleRequestFields *fields);
263 typedef void (*PurpleRequestFileCb)(void *, const char *filename);
265 #ifdef __cplusplus
266 extern "C" {
267 #endif
269 /**************************************************************************/
270 /** @name Field List API */
271 /**************************************************************************/
272 /*@{*/
275 * Creates a list of fields to pass to purple_request_fields().
277 * @return A PurpleRequestFields structure.
279 PurpleRequestFields *purple_request_fields_new(void);
282 * Destroys a list of fields.
284 * @param fields The list of fields to destroy.
286 void purple_request_fields_destroy(PurpleRequestFields *fields);
289 * Adds a group of fields to the list.
291 * @param fields The fields list.
292 * @param group The group to add.
294 void purple_request_fields_add_group(PurpleRequestFields *fields,
295 PurpleRequestFieldGroup *group);
298 * Returns a list of all groups in a field list.
300 * @param fields The fields list.
302 * @constreturn A list of groups.
304 GList *purple_request_fields_get_groups(const PurpleRequestFields *fields);
307 * Returns whether or not the field with the specified ID exists.
309 * @param fields The fields list.
310 * @param id The ID of the field.
312 * @return TRUE if the field exists, or FALSE.
314 gboolean purple_request_fields_exists(const PurpleRequestFields *fields,
315 const char *id);
318 * Returns a list of all required fields.
320 * @param fields The fields list.
322 * @constreturn The list of required fields.
324 GList *purple_request_fields_get_required(const PurpleRequestFields *fields);
327 * Returns whether or not a field with the specified ID is required.
329 * @param fields The fields list.
330 * @param id The field ID.
332 * @return TRUE if the specified field is required, or FALSE.
334 gboolean purple_request_fields_is_field_required(const PurpleRequestFields *fields,
335 const char *id);
338 * Returns whether or not all required fields have values.
340 * @param fields The fields list.
342 * @return TRUE if all required fields have values, or FALSE.
344 gboolean purple_request_fields_all_required_filled(
345 const PurpleRequestFields *fields);
348 * Return the field with the specified ID.
350 * @param fields The fields list.
351 * @param id The ID of the field.
353 * @return The field, if found.
355 PurpleRequestField *purple_request_fields_get_field(
356 const PurpleRequestFields *fields, const char *id);
359 * Returns the string value of a field with the specified ID.
361 * @param fields The fields list.
362 * @param id The ID of the field.
364 * @return The string value, if found, or @c NULL otherwise.
366 const char *purple_request_fields_get_string(const PurpleRequestFields *fields,
367 const char *id);
370 * Returns the integer value of a field with the specified ID.
372 * @param fields The fields list.
373 * @param id The ID of the field.
375 * @return The integer value, if found, or 0 otherwise.
377 int purple_request_fields_get_integer(const PurpleRequestFields *fields,
378 const char *id);
381 * Returns the boolean value of a field with the specified ID.
383 * @param fields The fields list.
384 * @param id The ID of the field.
386 * @return The boolean value, if found, or @c FALSE otherwise.
388 gboolean purple_request_fields_get_bool(const PurpleRequestFields *fields,
389 const char *id);
392 * Returns the choice index of a field with the specified ID.
394 * @param fields The fields list.
395 * @param id The ID of the field.
397 * @return The choice index, if found, or -1 otherwise.
399 int purple_request_fields_get_choice(const PurpleRequestFields *fields,
400 const char *id);
403 * Returns the account of a field with the specified ID.
405 * @param fields The fields list.
406 * @param id The ID of the field.
408 * @return The account value, if found, or NULL otherwise.
410 PurpleAccount *purple_request_fields_get_account(const PurpleRequestFields *fields,
411 const char *id);
413 /*@}*/
415 /**************************************************************************/
416 /** @name Fields Group API */
417 /**************************************************************************/
418 /*@{*/
421 * Creates a fields group with an optional title.
423 * @param title The optional title to give the group.
425 * @return A new fields group
427 PurpleRequestFieldGroup *purple_request_field_group_new(const char *title);
430 * Destroys a fields group.
432 * @param group The group to destroy.
434 void purple_request_field_group_destroy(PurpleRequestFieldGroup *group);
437 * Adds a field to the group.
439 * @param group The group to add the field to.
440 * @param field The field to add to the group.
442 void purple_request_field_group_add_field(PurpleRequestFieldGroup *group,
443 PurpleRequestField *field);
446 * Returns the title of a fields group.
448 * @param group The group.
450 * @return The title, if set.
452 const char *purple_request_field_group_get_title(
453 const PurpleRequestFieldGroup *group);
456 * Returns a list of all fields in a group.
458 * @param group The group.
460 * @constreturn The list of fields in the group.
462 GList *purple_request_field_group_get_fields(
463 const PurpleRequestFieldGroup *group);
465 /*@}*/
467 /**************************************************************************/
468 /** @name Field API */
469 /**************************************************************************/
470 /*@{*/
473 * Creates a field of the specified type.
475 * @param id The field ID.
476 * @param text The text label of the field.
477 * @param type The type of field.
479 * @return The new field.
481 PurpleRequestField *purple_request_field_new(const char *id, const char *text,
482 PurpleRequestFieldType type);
485 * Destroys a field.
487 * @param field The field to destroy.
489 void purple_request_field_destroy(PurpleRequestField *field);
492 * Sets the label text of a field.
494 * @param field The field.
495 * @param label The text label.
497 void purple_request_field_set_label(PurpleRequestField *field, const char *label);
500 * Sets whether or not a field is visible.
502 * @param field The field.
503 * @param visible TRUE if visible, or FALSE if not.
505 void purple_request_field_set_visible(PurpleRequestField *field, gboolean visible);
508 * Sets the type hint for the field.
510 * This is optionally used by the UIs to provide such features as
511 * auto-completion for type hints like "account" and "screenname".
513 * @param field The field.
514 * @param type_hint The type hint.
516 void purple_request_field_set_type_hint(PurpleRequestField *field,
517 const char *type_hint);
520 * Sets whether or not a field is required.
522 * @param field The field.
523 * @param required TRUE if required, or FALSE.
525 void purple_request_field_set_required(PurpleRequestField *field,
526 gboolean required);
529 * Returns the type of a field.
531 * @param field The field.
533 * @return The field's type.
535 PurpleRequestFieldType purple_request_field_get_type(const PurpleRequestField *field);
538 * Returns the group for the field.
540 * @param field The field.
542 * @return The UI data.
544 * @since 2.6.0
546 PurpleRequestFieldGroup *purple_request_field_get_group(const PurpleRequestField *field);
549 * Returns the ID of a field.
551 * @param field The field.
553 * @return The ID
555 const char *purple_request_field_get_id(const PurpleRequestField *field);
558 * Returns the label text of a field.
560 * @param field The field.
562 * @return The label text.
564 const char *purple_request_field_get_label(const PurpleRequestField *field);
567 * Returns whether or not a field is visible.
569 * @param field The field.
571 * @return TRUE if the field is visible. FALSE otherwise.
573 gboolean purple_request_field_is_visible(const PurpleRequestField *field);
576 * Returns the field's type hint.
578 * @param field The field.
580 * @return The field's type hint.
582 const char *purple_request_field_get_type_hint(const PurpleRequestField *field);
585 * Returns whether or not a field is required.
587 * @param field The field.
589 * @return TRUE if the field is required, or FALSE.
591 gboolean purple_request_field_is_required(const PurpleRequestField *field);
594 * Returns the ui_data for a field.
596 * @param field The field.
598 * @return The UI data.
600 * @since 2.6.0
602 gpointer purple_request_field_get_ui_data(const PurpleRequestField *field);
605 * Sets the ui_data for a field.
607 * @param field The field.
608 * @param ui_data The UI data.
610 * @return The UI data.
612 * @since 2.6.0
614 void purple_request_field_set_ui_data(PurpleRequestField *field,
615 gpointer ui_data);
617 /*@}*/
619 /**************************************************************************/
620 /** @name String Field API */
621 /**************************************************************************/
622 /*@{*/
625 * Creates a string request field.
627 * @param id The field ID.
628 * @param text The text label of the field.
629 * @param default_value The optional default value.
630 * @param multiline Whether or not this should be a multiline string.
632 * @return The new field.
634 PurpleRequestField *purple_request_field_string_new(const char *id,
635 const char *text,
636 const char *default_value,
637 gboolean multiline);
640 * Sets the default value in a string field.
642 * @param field The field.
643 * @param default_value The default value.
645 void purple_request_field_string_set_default_value(PurpleRequestField *field,
646 const char *default_value);
649 * Sets the value in a string field.
651 * @param field The field.
652 * @param value The value.
654 void purple_request_field_string_set_value(PurpleRequestField *field,
655 const char *value);
658 * Sets whether or not a string field is masked
659 * (commonly used for password fields).
661 * @param field The field.
662 * @param masked The masked value.
664 void purple_request_field_string_set_masked(PurpleRequestField *field,
665 gboolean masked);
668 * Sets whether or not a string field is editable.
670 * @param field The field.
671 * @param editable The editable value.
673 void purple_request_field_string_set_editable(PurpleRequestField *field,
674 gboolean editable);
677 * Returns the default value in a string field.
679 * @param field The field.
681 * @return The default value.
683 const char *purple_request_field_string_get_default_value(
684 const PurpleRequestField *field);
687 * Returns the user-entered value in a string field.
689 * @param field The field.
691 * @return The value.
693 const char *purple_request_field_string_get_value(const PurpleRequestField *field);
696 * Returns whether or not a string field is multi-line.
698 * @param field The field.
700 * @return @c TRUE if the field is mulit-line, or @c FALSE otherwise.
702 gboolean purple_request_field_string_is_multiline(const PurpleRequestField *field);
705 * Returns whether or not a string field is masked.
707 * @param field The field.
709 * @return @c TRUE if the field is masked, or @c FALSE otherwise.
711 gboolean purple_request_field_string_is_masked(const PurpleRequestField *field);
714 * Returns whether or not a string field is editable.
716 * @param field The field.
718 * @return @c TRUE if the field is editable, or @c FALSE otherwise.
720 gboolean purple_request_field_string_is_editable(const PurpleRequestField *field);
722 /*@}*/
724 /**************************************************************************/
725 /** @name Integer Field API */
726 /**************************************************************************/
727 /*@{*/
730 * Creates an integer field.
732 * @param id The field ID.
733 * @param text The text label of the field.
734 * @param default_value The default value.
736 * @return The new field.
738 PurpleRequestField *purple_request_field_int_new(const char *id,
739 const char *text,
740 int default_value);
743 * Sets the default value in an integer field.
745 * @param field The field.
746 * @param default_value The default value.
748 void purple_request_field_int_set_default_value(PurpleRequestField *field,
749 int default_value);
752 * Sets the value in an integer field.
754 * @param field The field.
755 * @param value The value.
757 void purple_request_field_int_set_value(PurpleRequestField *field, int value);
760 * Returns the default value in an integer field.
762 * @param field The field.
764 * @return The default value.
766 int purple_request_field_int_get_default_value(const PurpleRequestField *field);
769 * Returns the user-entered value in an integer field.
771 * @param field The field.
773 * @return The value.
775 int purple_request_field_int_get_value(const PurpleRequestField *field);
777 /*@}*/
779 /**************************************************************************/
780 /** @name Boolean Field API */
781 /**************************************************************************/
782 /*@{*/
785 * Creates a boolean field.
787 * This is often represented as a checkbox.
789 * @param id The field ID.
790 * @param text The text label of the field.
791 * @param default_value The default value.
793 * @return The new field.
795 PurpleRequestField *purple_request_field_bool_new(const char *id,
796 const char *text,
797 gboolean default_value);
800 * Sets the default value in an boolean field.
802 * @param field The field.
803 * @param default_value The default value.
805 void purple_request_field_bool_set_default_value(PurpleRequestField *field,
806 gboolean default_value);
809 * Sets the value in an boolean field.
811 * @param field The field.
812 * @param value The value.
814 void purple_request_field_bool_set_value(PurpleRequestField *field,
815 gboolean value);
818 * Returns the default value in an boolean field.
820 * @param field The field.
822 * @return The default value.
824 gboolean purple_request_field_bool_get_default_value(
825 const PurpleRequestField *field);
828 * Returns the user-entered value in an boolean field.
830 * @param field The field.
832 * @return The value.
834 gboolean purple_request_field_bool_get_value(const PurpleRequestField *field);
836 /*@}*/
838 /**************************************************************************/
839 /** @name Choice Field API */
840 /**************************************************************************/
841 /*@{*/
844 * Creates a multiple choice field.
846 * This is often represented as a group of radio buttons.
848 * @param id The field ID.
849 * @param text The optional label of the field.
850 * @param default_value The default choice.
852 * @return The new field.
854 PurpleRequestField *purple_request_field_choice_new(const char *id,
855 const char *text,
856 int default_value);
859 * Adds a choice to a multiple choice field.
861 * @param field The choice field.
862 * @param label The choice label.
864 void purple_request_field_choice_add(PurpleRequestField *field,
865 const char *label);
868 * Sets the default value in an choice field.
870 * @param field The field.
871 * @param default_value The default value.
873 void purple_request_field_choice_set_default_value(PurpleRequestField *field,
874 int default_value);
877 * Sets the value in an choice field.
879 * @param field The field.
880 * @param value The value.
882 void purple_request_field_choice_set_value(PurpleRequestField *field, int value);
885 * Returns the default value in an choice field.
887 * @param field The field.
889 * @return The default value.
891 int purple_request_field_choice_get_default_value(const PurpleRequestField *field);
894 * Returns the user-entered value in an choice field.
896 * @param field The field.
898 * @return The value.
900 int purple_request_field_choice_get_value(const PurpleRequestField *field);
903 * Returns a list of labels in a choice field.
905 * @param field The field.
907 * @constreturn The list of labels.
909 GList *purple_request_field_choice_get_labels(const PurpleRequestField *field);
911 /*@}*/
913 /**************************************************************************/
914 /** @name List Field API */
915 /**************************************************************************/
916 /*@{*/
919 * Creates a multiple list item field.
921 * @param id The field ID.
922 * @param text The optional label of the field.
924 * @return The new field.
926 PurpleRequestField *purple_request_field_list_new(const char *id, const char *text);
929 * Sets whether or not a list field allows multiple selection.
931 * @param field The list field.
932 * @param multi_select TRUE if multiple selection is enabled,
933 * or FALSE otherwise.
935 void purple_request_field_list_set_multi_select(PurpleRequestField *field,
936 gboolean multi_select);
939 * Returns whether or not a list field allows multiple selection.
941 * @param field The list field.
943 * @return TRUE if multiple selection is enabled, or FALSE otherwise.
945 gboolean purple_request_field_list_get_multi_select(
946 const PurpleRequestField *field);
949 * Returns the data for a particular item.
951 * @param field The list field.
952 * @param text The item text.
954 * @return The data associated with the item.
956 void *purple_request_field_list_get_data(const PurpleRequestField *field,
957 const char *text);
960 * Adds an item to a list field.
962 * @param field The list field.
963 * @param item The list item.
964 * @param data The associated data.
966 * @deprecated Use purple_request_field_list_add_icon() instead.
968 void purple_request_field_list_add(PurpleRequestField *field,
969 const char *item, void *data);
972 * Adds an item to a list field.
974 * @param field The list field.
975 * @param item The list item.
976 * @param icon_path The path to icon file, or @c NULL for no icon.
977 * @param data The associated data.
979 void purple_request_field_list_add_icon(PurpleRequestField *field,
980 const char *item, const char* icon_path, void* data);
983 * Adds a selected item to the list field.
985 * @param field The field.
986 * @param item The item to add.
988 void purple_request_field_list_add_selected(PurpleRequestField *field,
989 const char *item);
992 * Clears the list of selected items in a list field.
994 * @param field The field.
996 void purple_request_field_list_clear_selected(PurpleRequestField *field);
999 * Sets a list of selected items in a list field.
1001 * @param field The field.
1002 * @param items The list of selected items, which is not modified or freed.
1004 void purple_request_field_list_set_selected(PurpleRequestField *field,
1005 GList *items);
1008 * Returns whether or not a particular item is selected in a list field.
1010 * @param field The field.
1011 * @param item The item.
1013 * @return TRUE if the item is selected. FALSE otherwise.
1015 gboolean purple_request_field_list_is_selected(const PurpleRequestField *field,
1016 const char *item);
1019 * Returns a list of selected items in a list field.
1021 * To retrieve the data for each item, use
1022 * purple_request_field_list_get_data().
1024 * @param field The field.
1026 * @constreturn The list of selected items.
1028 GList *purple_request_field_list_get_selected(
1029 const PurpleRequestField *field);
1032 * Returns a list of items in a list field.
1034 * @param field The field.
1036 * @constreturn The list of items.
1038 GList *purple_request_field_list_get_items(const PurpleRequestField *field);
1041 * Returns a list of icons in a list field.
1043 * The icons will correspond with the items, in order.
1045 * @param field The field.
1047 * @constreturn The list of icons or @c NULL (i.e. the empty GList) if no
1048 * items have icons.
1050 GList *purple_request_field_list_get_icons(const PurpleRequestField *field);
1052 /*@}*/
1054 /**************************************************************************/
1055 /** @name Label Field API */
1056 /**************************************************************************/
1057 /*@{*/
1060 * Creates a label field.
1062 * @param id The field ID.
1063 * @param text The label of the field.
1065 * @return The new field.
1067 PurpleRequestField *purple_request_field_label_new(const char *id,
1068 const char *text);
1070 /*@}*/
1072 /**************************************************************************/
1073 /** @name Image Field API */
1074 /**************************************************************************/
1075 /*@{*/
1078 * Creates an image field.
1080 * @param id The field ID.
1081 * @param text The label of the field.
1082 * @param buf The image data.
1083 * @param size The size of the data in @a buffer.
1085 * @return The new field.
1087 PurpleRequestField *purple_request_field_image_new(const char *id, const char *text,
1088 const char *buf, gsize size);
1091 * Sets the scale factors of an image field.
1093 * @param field The image field.
1094 * @param x The x scale factor.
1095 * @param y The y scale factor.
1097 void purple_request_field_image_set_scale(PurpleRequestField *field, unsigned int x, unsigned int y);
1100 * Returns pointer to the image.
1102 * @param field The image field.
1104 * @return Pointer to the image.
1106 const char *purple_request_field_image_get_buffer(PurpleRequestField *field);
1109 * Returns size (in bytes) of the image.
1111 * @param field The image field.
1113 * @return Size of the image.
1115 gsize purple_request_field_image_get_size(PurpleRequestField *field);
1118 * Returns X scale coefficient of the image.
1120 * @param field The image field.
1122 * @return X scale coefficient of the image.
1124 unsigned int purple_request_field_image_get_scale_x(PurpleRequestField *field);
1127 * Returns Y scale coefficient of the image.
1129 * @param field The image field.
1131 * @return Y scale coefficient of the image.
1133 unsigned int purple_request_field_image_get_scale_y(PurpleRequestField *field);
1135 /*@}*/
1137 /**************************************************************************/
1138 /** @name Account Field API */
1139 /**************************************************************************/
1140 /*@{*/
1143 * Creates an account field.
1145 * By default, this field will not show offline accounts.
1147 * @param id The field ID.
1148 * @param text The text label of the field.
1149 * @param account The optional default account.
1151 * @return The new field.
1153 PurpleRequestField *purple_request_field_account_new(const char *id,
1154 const char *text,
1155 PurpleAccount *account);
1158 * Sets the default account on an account field.
1160 * @param field The account field.
1161 * @param default_value The default account.
1163 void purple_request_field_account_set_default_value(PurpleRequestField *field,
1164 PurpleAccount *default_value);
1167 * Sets the account in an account field.
1169 * @param field The account field.
1170 * @param value The account.
1172 void purple_request_field_account_set_value(PurpleRequestField *field,
1173 PurpleAccount *value);
1176 * Sets whether or not to show all accounts in an account field.
1178 * If TRUE, all accounts, online or offline, will be shown. If FALSE,
1179 * only online accounts will be shown.
1181 * @param field The account field.
1182 * @param show_all Whether or not to show all accounts.
1184 void purple_request_field_account_set_show_all(PurpleRequestField *field,
1185 gboolean show_all);
1188 * Sets the account filter function in an account field.
1190 * This function will determine which accounts get displayed and which
1191 * don't.
1193 * @param field The account field.
1194 * @param filter_func The account filter function.
1196 void purple_request_field_account_set_filter(PurpleRequestField *field,
1197 PurpleFilterAccountFunc filter_func);
1200 * Returns the default account in an account field.
1202 * @param field The field.
1204 * @return The default account.
1206 PurpleAccount *purple_request_field_account_get_default_value(
1207 const PurpleRequestField *field);
1210 * Returns the user-entered account in an account field.
1212 * @param field The field.
1214 * @return The user-entered account.
1216 PurpleAccount *purple_request_field_account_get_value(
1217 const PurpleRequestField *field);
1220 * Returns whether or not to show all accounts in an account field.
1222 * If TRUE, all accounts, online or offline, will be shown. If FALSE,
1223 * only online accounts will be shown.
1225 * @param field The account field.
1226 * @return Whether or not to show all accounts.
1228 gboolean purple_request_field_account_get_show_all(
1229 const PurpleRequestField *field);
1232 * Returns the account filter function in an account field.
1234 * This function will determine which accounts get displayed and which
1235 * don't.
1237 * @param field The account field.
1239 * @return The account filter function.
1241 PurpleFilterAccountFunc purple_request_field_account_get_filter(
1242 const PurpleRequestField *field);
1244 /*@}*/
1246 /**************************************************************************/
1247 /** @name Request API */
1248 /**************************************************************************/
1249 /*@{*/
1252 * Prompts the user for text input.
1254 * @param handle The plugin or connection handle. For some
1255 * things this is <em>extremely</em> important. The
1256 * handle is used to programmatically close the request
1257 * dialog when it is no longer needed. For PRPLs this
1258 * is often a pointer to the #PurpleConnection
1259 * instance. For plugins this should be a similar,
1260 * unique memory location. This value is important
1261 * because it allows a request to be closed with
1262 * purple_request_close_with_handle() when, for
1263 * example, you sign offline. If the request is
1264 * <em>not</em> closed it is <strong>very</strong>
1265 * likely to cause a crash whenever the callback
1266 * handler functions are triggered.
1267 * @param title The title of the message, or @c NULL if it should have
1268 * no title.
1269 * @param primary The main point of the message, or @c NULL if you're
1270 * feeling enigmatic.
1271 * @param secondary Secondary information, or @c NULL if there is none.
1272 * @param default_value The default value.
1273 * @param multiline @c TRUE if the inputted text can span multiple lines.
1274 * @param masked @c TRUE if the inputted text should be masked in some
1275 * way (such as by displaying characters as stars). This
1276 * might be because the input is some kind of password.
1277 * @param hint Optionally suggest how the input box should appear.
1278 * Use "html", for example, to allow the user to enter
1279 * HTML.
1280 * @param ok_text The text for the @c OK button, which may not be @c NULL.
1281 * @param ok_cb The callback for the @c OK button, which may not be @c
1282 * NULL.
1283 * @param cancel_text The text for the @c Cancel button, which may not be @c
1284 * NULL.
1285 * @param cancel_cb The callback for the @c Cancel button, which may be
1286 * @c NULL.
1287 * @param account The #PurpleAccount associated with this request, or @c
1288 * NULL if none is.
1289 * @param who The username of the buddy associated with this request,
1290 * or @c NULL if none is.
1291 * @param conv The #PurpleConversation associated with this request, or
1292 * @c NULL if none is.
1293 * @param user_data The data to pass to the callback.
1295 * @return A UI-specific handle.
1297 void *purple_request_input(void *handle, const char *title, const char *primary,
1298 const char *secondary, const char *default_value, gboolean multiline,
1299 gboolean masked, gchar *hint,
1300 const char *ok_text, GCallback ok_cb,
1301 const char *cancel_text, GCallback cancel_cb,
1302 PurpleAccount *account, const char *who, PurpleConversation *conv,
1303 void *user_data);
1306 * Prompts the user for multiple-choice input.
1308 * @param handle The plugin or connection handle. For some things this
1309 * is <em>extremely</em> important. See the comments on
1310 * purple_request_input().
1311 * @param title The title of the message, or @c NULL if it should have
1312 * no title.
1313 * @param primary The main point of the message, or @c NULL if you're
1314 * feeling enigmatic.
1315 * @param secondary Secondary information, or @c NULL if there is none.
1316 * @param default_value The default choice; this should be one of the values
1317 * listed in the varargs.
1318 * @param ok_text The text for the @c OK button, which may not be @c NULL.
1319 * @param ok_cb The callback for the @c OK button, which may not be @c
1320 * NULL.
1321 * @param cancel_text The text for the @c Cancel button, which may not be @c
1322 * NULL.
1323 * @param cancel_cb The callback for the @c Cancel button, or @c NULL to
1324 * do nothing.
1325 * @param account The #PurpleAccount associated with this request, or @c
1326 * NULL if none is.
1327 * @param who The username of the buddy associated with this request,
1328 * or @c NULL if none is.
1329 * @param conv The #PurpleConversation associated with this request, or
1330 * @c NULL if none is.
1331 * @param user_data The data to pass to the callback.
1332 * @param ... The choices, which should be pairs of <tt>char *</tt>
1333 * descriptions and <tt>int</tt> values, terminated with a
1334 * @c NULL parameter.
1336 * @return A UI-specific handle.
1338 void *purple_request_choice(void *handle, const char *title, const char *primary,
1339 const char *secondary, int default_value,
1340 const char *ok_text, GCallback ok_cb,
1341 const char *cancel_text, GCallback cancel_cb,
1342 PurpleAccount *account, const char *who, PurpleConversation *conv,
1343 void *user_data, ...) G_GNUC_NULL_TERMINATED;
1346 * <tt>va_list</tt> version of purple_request_choice(); see its documentation.
1348 void *purple_request_choice_varg(void *handle, const char *title,
1349 const char *primary, const char *secondary, int default_value,
1350 const char *ok_text, GCallback ok_cb,
1351 const char *cancel_text, GCallback cancel_cb,
1352 PurpleAccount *account, const char *who, PurpleConversation *conv,
1353 void *user_data, va_list choices);
1356 * Prompts the user for an action.
1358 * This is often represented as a dialog with a button for each action.
1360 * @param handle The plugin or connection handle. For some things this
1361 * is <em>extremely</em> important. See the comments on
1362 * purple_request_input().
1363 * @param title The title of the message, or @c NULL if it should have
1364 * no title.
1365 * @param primary The main point of the message, or @c NULL if you're
1366 * feeling enigmatic.
1367 * @param secondary Secondary information, or @c NULL if there is none.
1368 * @param default_action The default action, zero-indexed; if the third action
1369 * supplied should be the default, supply <tt>2</tt>.
1370 * The should be the action that users are most likely
1371 * to select.
1372 * @param account The #PurpleAccount associated with this request, or @c
1373 * NULL if none is.
1374 * @param who The username of the buddy associated with this request,
1375 * or @c NULL if none is.
1376 * @param conv The #PurpleConversation associated with this request, or
1377 * @c NULL if none is.
1378 * @param user_data The data to pass to the callback.
1379 * @param action_count The number of actions.
1380 * @param ... A list of actions. These are pairs of
1381 * arguments. The first of each pair is the
1382 * <tt>char *</tt> label that appears on the button. It
1383 * should have an underscore before the letter you want
1384 * to use as the accelerator key for the button. The
1385 * second of each pair is the #PurpleRequestActionCb
1386 * function to use when the button is clicked.
1388 * @return A UI-specific handle.
1390 void *purple_request_action(void *handle, const char *title, const char *primary,
1391 const char *secondary, int default_action, PurpleAccount *account,
1392 const char *who, PurpleConversation *conv, void *user_data,
1393 size_t action_count, ...);
1396 * <tt>va_list</tt> version of purple_request_action(); see its documentation.
1398 void *purple_request_action_varg(void *handle, const char *title,
1399 const char *primary, const char *secondary, int default_action,
1400 PurpleAccount *account, const char *who, PurpleConversation *conv,
1401 void *user_data, size_t action_count, va_list actions);
1404 * Version of purple_request_action() supplying an image for the UI to
1405 * optionally display as an icon in the dialog; see its documentation
1406 * @since 2.7.0
1408 void *purple_request_action_with_icon(void *handle, const char *title,
1409 const char *primary, const char *secondary, int default_action,
1410 PurpleAccount *account, const char *who, PurpleConversation *conv,
1411 gconstpointer icon_data, gsize icon_size, void *user_data,
1412 size_t action_count, ...);
1415 * <tt>va_list</tt> version of purple_request_action_with_icon();
1416 * see its documentation.
1417 * @since 2.7.0
1419 void *purple_request_action_with_icon_varg(void *handle, const char *title,
1420 const char *primary, const char *secondary, int default_action,
1421 PurpleAccount *account, const char *who, PurpleConversation *conv,
1422 gconstpointer icon_data, gsize icon_size,
1423 void *user_data, size_t action_count, va_list actions);
1427 * Displays groups of fields for the user to fill in.
1429 * @param handle The plugin or connection handle. For some things this
1430 * is <em>extremely</em> important. See the comments on
1431 * purple_request_input().
1432 * @param title The title of the message, or @c NULL if it should have
1433 * no title.
1434 * @param primary The main point of the message, or @c NULL if you're
1435 * feeling enigmatic.
1436 * @param secondary Secondary information, or @c NULL if there is none.
1437 * @param fields The list of fields.
1438 * @param ok_text The text for the @c OK button, which may not be @c NULL.
1439 * @param ok_cb The callback for the @c OK button, which may not be @c
1440 * NULL.
1441 * @param cancel_text The text for the @c Cancel button, which may not be @c
1442 * NULL.
1443 * @param cancel_cb The callback for the @c Cancel button, which may be
1444 * @c NULL.
1445 * @param account The #PurpleAccount associated with this request, or @c
1446 * NULL if none is
1447 * @param who The username of the buddy associated with this request,
1448 * or @c NULL if none is
1449 * @param conv The #PurpleConversation associated with this request, or
1450 * @c NULL if none is
1451 * @param user_data The data to pass to the callback.
1453 * @return A UI-specific handle.
1455 void *purple_request_fields(void *handle, const char *title, const char *primary,
1456 const char *secondary, PurpleRequestFields *fields,
1457 const char *ok_text, GCallback ok_cb,
1458 const char *cancel_text, GCallback cancel_cb,
1459 PurpleAccount *account, const char *who, PurpleConversation *conv,
1460 void *user_data);
1463 * Closes a request.
1465 * @param type The request type.
1466 * @param uihandle The request UI handle.
1468 void purple_request_close(PurpleRequestType type, void *uihandle);
1471 * Closes all requests registered with the specified handle.
1473 * @param handle The handle, as supplied as the @a handle parameter to one of the
1474 * <tt>purple_request_*</tt> functions.
1476 * @see purple_request_input().
1478 void purple_request_close_with_handle(void *handle);
1481 * A wrapper for purple_request_action() that uses @c Yes and @c No buttons.
1483 #define purple_request_yes_no(handle, title, primary, secondary, \
1484 default_action, account, who, conv, \
1485 user_data, yes_cb, no_cb) \
1486 purple_request_action((handle), (title), (primary), (secondary), \
1487 (default_action), account, who, conv, (user_data), 2, \
1488 _("_Yes"), (yes_cb), _("_No"), (no_cb))
1491 * A wrapper for purple_request_action() that uses @c OK and @c Cancel buttons.
1493 #define purple_request_ok_cancel(handle, title, primary, secondary, \
1494 default_action, account, who, conv, \
1495 user_data, ok_cb, cancel_cb) \
1496 purple_request_action((handle), (title), (primary), (secondary), \
1497 (default_action), account, who, conv, (user_data), 2, \
1498 _("_OK"), (ok_cb), _("_Cancel"), (cancel_cb))
1501 * A wrapper for purple_request_action() that uses Accept and Cancel buttons.
1503 #define purple_request_accept_cancel(handle, title, primary, secondary, \
1504 default_action, account, who, conv, \
1505 user_data, accept_cb, cancel_cb) \
1506 purple_request_action((handle), (title), (primary), (secondary), \
1507 (default_action), account, who, conv, (user_data), 2, \
1508 _("_Accept"), (accept_cb), _("_Cancel"), (cancel_cb))
1511 * A wrapper for purple_request_action_with_icon() that uses Accept and Cancel
1512 * buttons.
1514 #define purple_request_accept_cancel_with_icon(handle, title, primary, secondary, \
1515 default_action, account, who, conv, \
1516 icon_data, icon_size, \
1517 user_data, accept_cb, cancel_cb) \
1518 purple_request_action_with_icon((handle), (title), (primary), (secondary), \
1519 (default_action), account, who, conv, icon_data, icon_size, \
1520 (user_data), 2, \
1521 _("_Accept"), (accept_cb), _("_Cancel"), (cancel_cb))
1524 * Displays a file selector request dialog. Returns the selected filename to
1525 * the callback. Can be used for either opening a file or saving a file.
1527 * @param handle The plugin or connection handle. For some things this
1528 * is <em>extremely</em> important. See the comments on
1529 * purple_request_input().
1530 * @param title The title of the message, or @c NULL if it should have
1531 * no title.
1532 * @param filename The default filename (may be @c NULL)
1533 * @param savedialog True if this dialog is being used to save a file.
1534 * False if it is being used to open a file.
1535 * @param ok_cb The callback for the @c OK button.
1536 * @param cancel_cb The callback for the @c Cancel button, which may be @c NULL.
1537 * @param account The #PurpleAccount associated with this request, or @c
1538 * NULL if none is
1539 * @param who The username of the buddy associated with this request,
1540 * or @c NULL if none is
1541 * @param conv The #PurpleConversation associated with this request, or
1542 * @c NULL if none is
1543 * @param user_data The data to pass to the callback.
1545 * @return A UI-specific handle.
1547 void *purple_request_file(void *handle, const char *title, const char *filename,
1548 gboolean savedialog, GCallback ok_cb, GCallback cancel_cb,
1549 PurpleAccount *account, const char *who, PurpleConversation *conv,
1550 void *user_data);
1553 * Displays a folder select dialog. Returns the selected filename to
1554 * the callback.
1556 * @param handle The plugin or connection handle. For some things this
1557 * is <em>extremely</em> important. See the comments on
1558 * purple_request_input().
1559 * @param title The title of the message, or @c NULL if it should have
1560 * no title.
1561 * @param dirname The default directory name (may be @c NULL)
1562 * @param ok_cb The callback for the @c OK button.
1563 * @param cancel_cb The callback for the @c Cancel button, which may be @c NULL.
1564 * @param account The #PurpleAccount associated with this request, or @c
1565 * NULL if none is
1566 * @param who The username of the buddy associated with this request,
1567 * or @c NULL if none is
1568 * @param conv The #PurpleConversation associated with this request, or
1569 * @c NULL if none is
1570 * @param user_data The data to pass to the callback.
1572 * @return A UI-specific handle.
1574 void *purple_request_folder(void *handle, const char *title, const char *dirname,
1575 GCallback ok_cb, GCallback cancel_cb,
1576 PurpleAccount *account, const char *who, PurpleConversation *conv,
1577 void *user_data);
1579 /*@}*/
1581 /**************************************************************************/
1582 /** @name UI Registration Functions */
1583 /**************************************************************************/
1584 /*@{*/
1587 * Sets the UI operations structure to be used when displaying a
1588 * request.
1590 * @param ops The UI operations structure.
1592 void purple_request_set_ui_ops(PurpleRequestUiOps *ops);
1595 * Returns the UI operations structure to be used when displaying a
1596 * request.
1598 * @return The UI operations structure.
1600 PurpleRequestUiOps *purple_request_get_ui_ops(void);
1602 /*@}*/
1604 #ifdef __cplusplus
1606 #endif
1608 #endif /* _PURPLE_REQUEST_H_ */