Convert all uses of PURPLE_UNSAFE_DEBUG to the new API I added.
[pidgin-git.git] / libpurple / request.h
blob08a18faaca514623a2663dbb6aa4c1e0e5ded09c
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 GHashTable *item_data;
154 GList *selected;
155 GHashTable *selected_table;
157 gboolean multiple_selection;
159 } list;
161 struct
163 PurpleAccount *default_account;
164 PurpleAccount *account;
165 gboolean show_all;
167 PurpleFilterAccountFunc filter_func;
169 } account;
171 struct
173 unsigned int scale_x;
174 unsigned int scale_y;
175 const char *buffer;
176 gsize size;
177 } image;
179 } u;
181 void *ui_data;
184 #endif
187 * Request UI operations.
189 typedef struct
191 /** @see purple_request_input(). */
192 void *(*request_input)(const char *title, const char *primary,
193 const char *secondary, const char *default_value,
194 gboolean multiline, gboolean masked, gchar *hint,
195 const char *ok_text, GCallback ok_cb,
196 const char *cancel_text, GCallback cancel_cb,
197 PurpleAccount *account, const char *who,
198 PurpleConversation *conv, void *user_data);
200 /** @see purple_request_choice_varg(). */
201 void *(*request_choice)(const char *title, const char *primary,
202 const char *secondary, int default_value,
203 const char *ok_text, GCallback ok_cb,
204 const char *cancel_text, GCallback cancel_cb,
205 PurpleAccount *account, const char *who,
206 PurpleConversation *conv, void *user_data,
207 va_list choices);
209 /** @see purple_request_action_varg(). */
210 void *(*request_action)(const char *title, const char *primary,
211 const char *secondary, int default_action,
212 PurpleAccount *account, const char *who,
213 PurpleConversation *conv, void *user_data,
214 size_t action_count, va_list actions);
216 /** @see purple_request_fields(). */
217 void *(*request_fields)(const char *title, const char *primary,
218 const char *secondary, PurpleRequestFields *fields,
219 const char *ok_text, GCallback ok_cb,
220 const char *cancel_text, GCallback cancel_cb,
221 PurpleAccount *account, const char *who,
222 PurpleConversation *conv, void *user_data);
224 /** @see purple_request_file(). */
225 void *(*request_file)(const char *title, const char *filename,
226 gboolean savedialog, GCallback ok_cb,
227 GCallback cancel_cb, PurpleAccount *account,
228 const char *who, PurpleConversation *conv,
229 void *user_data);
231 void (*close_request)(PurpleRequestType type, void *ui_handle);
233 /** @see purple_request_folder(). */
234 void *(*request_folder)(const char *title, const char *dirname,
235 GCallback ok_cb, GCallback cancel_cb,
236 PurpleAccount *account, const char *who,
237 PurpleConversation *conv, void *user_data);
239 void (*_purple_reserved1)(void);
240 void (*_purple_reserved2)(void);
241 void (*_purple_reserved3)(void);
242 void (*_purple_reserved4)(void);
243 } PurpleRequestUiOps;
245 typedef void (*PurpleRequestInputCb)(void *, const char *);
247 /** The type of callbacks passed to purple_request_action(). The first
248 * argument is the @a user_data parameter; the second is the index in the list
249 * of actions of the one chosen.
251 typedef void (*PurpleRequestActionCb)(void *, int);
252 typedef void (*PurpleRequestChoiceCb)(void *, int);
253 typedef void (*PurpleRequestFieldsCb)(void *, PurpleRequestFields *fields);
254 typedef void (*PurpleRequestFileCb)(void *, const char *filename);
256 #ifdef __cplusplus
257 extern "C" {
258 #endif
260 /**************************************************************************/
261 /** @name Field List API */
262 /**************************************************************************/
263 /*@{*/
266 * Creates a list of fields to pass to purple_request_fields().
268 * @return A PurpleRequestFields structure.
270 PurpleRequestFields *purple_request_fields_new(void);
273 * Destroys a list of fields.
275 * @param fields The list of fields to destroy.
277 void purple_request_fields_destroy(PurpleRequestFields *fields);
280 * Adds a group of fields to the list.
282 * @param fields The fields list.
283 * @param group The group to add.
285 void purple_request_fields_add_group(PurpleRequestFields *fields,
286 PurpleRequestFieldGroup *group);
289 * Returns a list of all groups in a field list.
291 * @param fields The fields list.
293 * @constreturn A list of groups.
295 GList *purple_request_fields_get_groups(const PurpleRequestFields *fields);
298 * Returns whether or not the field with the specified ID exists.
300 * @param fields The fields list.
301 * @param id The ID of the field.
303 * @return TRUE if the field exists, or FALSE.
305 gboolean purple_request_fields_exists(const PurpleRequestFields *fields,
306 const char *id);
309 * Returns a list of all required fields.
311 * @param fields The fields list.
313 * @constreturn The list of required fields.
315 GList *purple_request_fields_get_required(const PurpleRequestFields *fields);
318 * Returns whether or not a field with the specified ID is required.
320 * @param fields The fields list.
321 * @param id The field ID.
323 * @return TRUE if the specified field is required, or FALSE.
325 gboolean purple_request_fields_is_field_required(const PurpleRequestFields *fields,
326 const char *id);
329 * Returns whether or not all required fields have values.
331 * @param fields The fields list.
333 * @return TRUE if all required fields have values, or FALSE.
335 gboolean purple_request_fields_all_required_filled(
336 const PurpleRequestFields *fields);
339 * Return the field with the specified ID.
341 * @param fields The fields list.
342 * @param id The ID of the field.
344 * @return The field, if found.
346 PurpleRequestField *purple_request_fields_get_field(
347 const PurpleRequestFields *fields, const char *id);
350 * Returns the string value of a field with the specified ID.
352 * @param fields The fields list.
353 * @param id The ID of the field.
355 * @return The string value, if found, or @c NULL otherwise.
357 const char *purple_request_fields_get_string(const PurpleRequestFields *fields,
358 const char *id);
361 * Returns the integer value of a field with the specified ID.
363 * @param fields The fields list.
364 * @param id The ID of the field.
366 * @return The integer value, if found, or 0 otherwise.
368 int purple_request_fields_get_integer(const PurpleRequestFields *fields,
369 const char *id);
372 * Returns the boolean value of a field with the specified ID.
374 * @param fields The fields list.
375 * @param id The ID of the field.
377 * @return The boolean value, if found, or @c FALSE otherwise.
379 gboolean purple_request_fields_get_bool(const PurpleRequestFields *fields,
380 const char *id);
383 * Returns the choice index of a field with the specified ID.
385 * @param fields The fields list.
386 * @param id The ID of the field.
388 * @return The choice index, if found, or -1 otherwise.
390 int purple_request_fields_get_choice(const PurpleRequestFields *fields,
391 const char *id);
394 * Returns the account of a field with the specified ID.
396 * @param fields The fields list.
397 * @param id The ID of the field.
399 * @return The account value, if found, or NULL otherwise.
401 PurpleAccount *purple_request_fields_get_account(const PurpleRequestFields *fields,
402 const char *id);
404 /*@}*/
406 /**************************************************************************/
407 /** @name Fields Group API */
408 /**************************************************************************/
409 /*@{*/
412 * Creates a fields group with an optional title.
414 * @param title The optional title to give the group.
416 * @return A new fields group
418 PurpleRequestFieldGroup *purple_request_field_group_new(const char *title);
421 * Destroys a fields group.
423 * @param group The group to destroy.
425 void purple_request_field_group_destroy(PurpleRequestFieldGroup *group);
428 * Adds a field to the group.
430 * @param group The group to add the field to.
431 * @param field The field to add to the group.
433 void purple_request_field_group_add_field(PurpleRequestFieldGroup *group,
434 PurpleRequestField *field);
437 * Returns the title of a fields group.
439 * @param group The group.
441 * @return The title, if set.
443 const char *purple_request_field_group_get_title(
444 const PurpleRequestFieldGroup *group);
447 * Returns a list of all fields in a group.
449 * @param group The group.
451 * @constreturn The list of fields in the group.
453 GList *purple_request_field_group_get_fields(
454 const PurpleRequestFieldGroup *group);
456 /*@}*/
458 /**************************************************************************/
459 /** @name Field API */
460 /**************************************************************************/
461 /*@{*/
464 * Creates a field of the specified type.
466 * @param id The field ID.
467 * @param text The text label of the field.
468 * @param type The type of field.
470 * @return The new field.
472 PurpleRequestField *purple_request_field_new(const char *id, const char *text,
473 PurpleRequestFieldType type);
476 * Destroys a field.
478 * @param field The field to destroy.
480 void purple_request_field_destroy(PurpleRequestField *field);
483 * Sets the label text of a field.
485 * @param field The field.
486 * @param label The text label.
488 void purple_request_field_set_label(PurpleRequestField *field, const char *label);
491 * Sets whether or not a field is visible.
493 * @param field The field.
494 * @param visible TRUE if visible, or FALSE if not.
496 void purple_request_field_set_visible(PurpleRequestField *field, gboolean visible);
499 * Sets the type hint for the field.
501 * This is optionally used by the UIs to provide such features as
502 * auto-completion for type hints like "account" and "screenname".
504 * @param field The field.
505 * @param type_hint The type hint.
507 void purple_request_field_set_type_hint(PurpleRequestField *field,
508 const char *type_hint);
511 * Sets whether or not a field is required.
513 * @param field The field.
514 * @param required TRUE if required, or FALSE.
516 void purple_request_field_set_required(PurpleRequestField *field,
517 gboolean required);
520 * Returns the type of a field.
522 * @param field The field.
524 * @return The field's type.
526 PurpleRequestFieldType purple_request_field_get_type(const PurpleRequestField *field);
529 * Returns the group for the field.
531 * @param field The field.
533 * @return The UI data.
535 * @since 2.6.0
537 PurpleRequestFieldGroup *purple_request_field_get_group(const PurpleRequestField *field);
540 * Returns the ID of a field.
542 * @param field The field.
544 * @return The ID
546 const char *purple_request_field_get_id(const PurpleRequestField *field);
549 * Returns the label text of a field.
551 * @param field The field.
553 * @return The label text.
555 const char *purple_request_field_get_label(const PurpleRequestField *field);
558 * Returns whether or not a field is visible.
560 * @param field The field.
562 * @return TRUE if the field is visible. FALSE otherwise.
564 gboolean purple_request_field_is_visible(const PurpleRequestField *field);
567 * Returns the field's type hint.
569 * @param field The field.
571 * @return The field's type hint.
573 const char *purple_request_field_get_type_hint(const PurpleRequestField *field);
576 * Returns whether or not a field is required.
578 * @param field The field.
580 * @return TRUE if the field is required, or FALSE.
582 gboolean purple_request_field_is_required(const PurpleRequestField *field);
585 * Returns the ui_data for a field.
587 * @param field The field.
589 * @return The UI data.
591 * @since 2.6.0
593 gpointer purple_request_field_get_ui_data(const PurpleRequestField *field);
596 * Sets the ui_data for a field.
598 * @param field The field.
599 * @param ui_data The UI data.
601 * @return The UI data.
603 * @since 2.6.0
605 void purple_request_field_set_ui_data(PurpleRequestField *field,
606 gpointer ui_data);
608 /*@}*/
610 /**************************************************************************/
611 /** @name String Field API */
612 /**************************************************************************/
613 /*@{*/
616 * Creates a string request field.
618 * @param id The field ID.
619 * @param text The text label of the field.
620 * @param default_value The optional default value.
621 * @param multiline Whether or not this should be a multiline string.
623 * @return The new field.
625 PurpleRequestField *purple_request_field_string_new(const char *id,
626 const char *text,
627 const char *default_value,
628 gboolean multiline);
631 * Sets the default value in a string field.
633 * @param field The field.
634 * @param default_value The default value.
636 void purple_request_field_string_set_default_value(PurpleRequestField *field,
637 const char *default_value);
640 * Sets the value in a string field.
642 * @param field The field.
643 * @param value The value.
645 void purple_request_field_string_set_value(PurpleRequestField *field,
646 const char *value);
649 * Sets whether or not a string field is masked
650 * (commonly used for password fields).
652 * @param field The field.
653 * @param masked The masked value.
655 void purple_request_field_string_set_masked(PurpleRequestField *field,
656 gboolean masked);
659 * Sets whether or not a string field is editable.
661 * @param field The field.
662 * @param editable The editable value.
664 void purple_request_field_string_set_editable(PurpleRequestField *field,
665 gboolean editable);
668 * Returns the default value in a string field.
670 * @param field The field.
672 * @return The default value.
674 const char *purple_request_field_string_get_default_value(
675 const PurpleRequestField *field);
678 * Returns the user-entered value in a string field.
680 * @param field The field.
682 * @return The value.
684 const char *purple_request_field_string_get_value(const PurpleRequestField *field);
687 * Returns whether or not a string field is multi-line.
689 * @param field The field.
691 * @return @c TRUE if the field is mulit-line, or @c FALSE otherwise.
693 gboolean purple_request_field_string_is_multiline(const PurpleRequestField *field);
696 * Returns whether or not a string field is masked.
698 * @param field The field.
700 * @return @c TRUE if the field is masked, or @c FALSE otherwise.
702 gboolean purple_request_field_string_is_masked(const PurpleRequestField *field);
705 * Returns whether or not a string field is editable.
707 * @param field The field.
709 * @return @c TRUE if the field is editable, or @c FALSE otherwise.
711 gboolean purple_request_field_string_is_editable(const PurpleRequestField *field);
713 /*@}*/
715 /**************************************************************************/
716 /** @name Integer Field API */
717 /**************************************************************************/
718 /*@{*/
721 * Creates an integer field.
723 * @param id The field ID.
724 * @param text The text label of the field.
725 * @param default_value The default value.
727 * @return The new field.
729 PurpleRequestField *purple_request_field_int_new(const char *id,
730 const char *text,
731 int default_value);
734 * Sets the default value in an integer field.
736 * @param field The field.
737 * @param default_value The default value.
739 void purple_request_field_int_set_default_value(PurpleRequestField *field,
740 int default_value);
743 * Sets the value in an integer field.
745 * @param field The field.
746 * @param value The value.
748 void purple_request_field_int_set_value(PurpleRequestField *field, int value);
751 * Returns the default value in an integer field.
753 * @param field The field.
755 * @return The default value.
757 int purple_request_field_int_get_default_value(const PurpleRequestField *field);
760 * Returns the user-entered value in an integer field.
762 * @param field The field.
764 * @return The value.
766 int purple_request_field_int_get_value(const PurpleRequestField *field);
768 /*@}*/
770 /**************************************************************************/
771 /** @name Boolean Field API */
772 /**************************************************************************/
773 /*@{*/
776 * Creates a boolean field.
778 * This is often represented as a checkbox.
780 * @param id The field ID.
781 * @param text The text label of the field.
782 * @param default_value The default value.
784 * @return The new field.
786 PurpleRequestField *purple_request_field_bool_new(const char *id,
787 const char *text,
788 gboolean default_value);
791 * Sets the default value in an boolean field.
793 * @param field The field.
794 * @param default_value The default value.
796 void purple_request_field_bool_set_default_value(PurpleRequestField *field,
797 gboolean default_value);
800 * Sets the value in an boolean field.
802 * @param field The field.
803 * @param value The value.
805 void purple_request_field_bool_set_value(PurpleRequestField *field,
806 gboolean value);
809 * Returns the default value in an boolean field.
811 * @param field The field.
813 * @return The default value.
815 gboolean purple_request_field_bool_get_default_value(
816 const PurpleRequestField *field);
819 * Returns the user-entered value in an boolean field.
821 * @param field The field.
823 * @return The value.
825 gboolean purple_request_field_bool_get_value(const PurpleRequestField *field);
827 /*@}*/
829 /**************************************************************************/
830 /** @name Choice Field API */
831 /**************************************************************************/
832 /*@{*/
835 * Creates a multiple choice field.
837 * This is often represented as a group of radio buttons.
839 * @param id The field ID.
840 * @param text The optional label of the field.
841 * @param default_value The default choice.
843 * @return The new field.
845 PurpleRequestField *purple_request_field_choice_new(const char *id,
846 const char *text,
847 int default_value);
850 * Adds a choice to a multiple choice field.
852 * @param field The choice field.
853 * @param label The choice label.
855 void purple_request_field_choice_add(PurpleRequestField *field,
856 const char *label);
859 * Sets the default value in an choice field.
861 * @param field The field.
862 * @param default_value The default value.
864 void purple_request_field_choice_set_default_value(PurpleRequestField *field,
865 int default_value);
868 * Sets the value in an choice field.
870 * @param field The field.
871 * @param value The value.
873 void purple_request_field_choice_set_value(PurpleRequestField *field, int value);
876 * Returns the default value in an choice field.
878 * @param field The field.
880 * @return The default value.
882 int purple_request_field_choice_get_default_value(const PurpleRequestField *field);
885 * Returns the user-entered value in an choice field.
887 * @param field The field.
889 * @return The value.
891 int purple_request_field_choice_get_value(const PurpleRequestField *field);
894 * Returns a list of labels in a choice field.
896 * @param field The field.
898 * @constreturn The list of labels.
900 GList *purple_request_field_choice_get_labels(const PurpleRequestField *field);
902 /*@}*/
904 /**************************************************************************/
905 /** @name List Field API */
906 /**************************************************************************/
907 /*@{*/
910 * Creates a multiple list item field.
912 * @param id The field ID.
913 * @param text The optional label of the field.
915 * @return The new field.
917 PurpleRequestField *purple_request_field_list_new(const char *id, const char *text);
920 * Sets whether or not a list field allows multiple selection.
922 * @param field The list field.
923 * @param multi_select TRUE if multiple selection is enabled,
924 * or FALSE otherwise.
926 void purple_request_field_list_set_multi_select(PurpleRequestField *field,
927 gboolean multi_select);
930 * Returns whether or not a list field allows multiple selection.
932 * @param field The list field.
934 * @return TRUE if multiple selection is enabled, or FALSE otherwise.
936 gboolean purple_request_field_list_get_multi_select(
937 const PurpleRequestField *field);
940 * Returns the data for a particular item.
942 * @param field The list field.
943 * @param text The item text.
945 * @return The data associated with the item.
947 void *purple_request_field_list_get_data(const PurpleRequestField *field,
948 const char *text);
951 * Adds an item to a list field.
953 * @param field The list field.
954 * @param item The list item.
955 * @param data The associated data.
957 void purple_request_field_list_add(PurpleRequestField *field,
958 const char *item, void *data);
961 * Adds a selected item to the list field.
963 * @param field The field.
964 * @param item The item to add.
966 void purple_request_field_list_add_selected(PurpleRequestField *field,
967 const char *item);
970 * Clears the list of selected items in a list field.
972 * @param field The field.
974 void purple_request_field_list_clear_selected(PurpleRequestField *field);
977 * Sets a list of selected items in a list field.
979 * @param field The field.
980 * @param items The list of selected items, which is not modified or freed.
982 void purple_request_field_list_set_selected(PurpleRequestField *field,
983 GList *items);
986 * Returns whether or not a particular item is selected in a list field.
988 * @param field The field.
989 * @param item The item.
991 * @return TRUE if the item is selected. FALSE otherwise.
993 gboolean purple_request_field_list_is_selected(const PurpleRequestField *field,
994 const char *item);
997 * Returns a list of selected items in a list field.
999 * To retrieve the data for each item, use
1000 * purple_request_field_list_get_data().
1002 * @param field The field.
1004 * @constreturn The list of selected items.
1006 GList *purple_request_field_list_get_selected(
1007 const PurpleRequestField *field);
1010 * Returns a list of items in a list field.
1012 * @param field The field.
1014 * @constreturn The list of items.
1016 GList *purple_request_field_list_get_items(const PurpleRequestField *field);
1018 /*@}*/
1020 /**************************************************************************/
1021 /** @name Label Field API */
1022 /**************************************************************************/
1023 /*@{*/
1026 * Creates a label field.
1028 * @param id The field ID.
1029 * @param text The label of the field.
1031 * @return The new field.
1033 PurpleRequestField *purple_request_field_label_new(const char *id,
1034 const char *text);
1036 /*@}*/
1038 /**************************************************************************/
1039 /** @name Image Field API */
1040 /**************************************************************************/
1041 /*@{*/
1044 * Creates an image field.
1046 * @param id The field ID.
1047 * @param text The label of the field.
1048 * @param buf The image data.
1049 * @param size The size of the data in @a buffer.
1051 * @return The new field.
1053 PurpleRequestField *purple_request_field_image_new(const char *id, const char *text,
1054 const char *buf, gsize size);
1057 * Sets the scale factors of an image field.
1059 * @param field The image field.
1060 * @param x The x scale factor.
1061 * @param y The y scale factor.
1063 void purple_request_field_image_set_scale(PurpleRequestField *field, unsigned int x, unsigned int y);
1066 * Returns pointer to the image.
1068 * @param field The image field.
1070 * @return Pointer to the image.
1072 const char *purple_request_field_image_get_buffer(PurpleRequestField *field);
1075 * Returns size (in bytes) of the image.
1077 * @param field The image field.
1079 * @return Size of the image.
1081 gsize purple_request_field_image_get_size(PurpleRequestField *field);
1084 * Returns X scale coefficient of the image.
1086 * @param field The image field.
1088 * @return X scale coefficient of the image.
1090 unsigned int purple_request_field_image_get_scale_x(PurpleRequestField *field);
1093 * Returns Y scale coefficient of the image.
1095 * @param field The image field.
1097 * @return Y scale coefficient of the image.
1099 unsigned int purple_request_field_image_get_scale_y(PurpleRequestField *field);
1101 /*@}*/
1103 /**************************************************************************/
1104 /** @name Account Field API */
1105 /**************************************************************************/
1106 /*@{*/
1109 * Creates an account field.
1111 * By default, this field will not show offline accounts.
1113 * @param id The field ID.
1114 * @param text The text label of the field.
1115 * @param account The optional default account.
1117 * @return The new field.
1119 PurpleRequestField *purple_request_field_account_new(const char *id,
1120 const char *text,
1121 PurpleAccount *account);
1124 * Sets the default account on an account field.
1126 * @param field The account field.
1127 * @param default_value The default account.
1129 void purple_request_field_account_set_default_value(PurpleRequestField *field,
1130 PurpleAccount *default_value);
1133 * Sets the account in an account field.
1135 * @param field The account field.
1136 * @param value The account.
1138 void purple_request_field_account_set_value(PurpleRequestField *field,
1139 PurpleAccount *value);
1142 * Sets whether or not to show all accounts in an account field.
1144 * If TRUE, all accounts, online or offline, will be shown. If FALSE,
1145 * only online accounts will be shown.
1147 * @param field The account field.
1148 * @param show_all Whether or not to show all accounts.
1150 void purple_request_field_account_set_show_all(PurpleRequestField *field,
1151 gboolean show_all);
1154 * Sets the account filter function in an account field.
1156 * This function will determine which accounts get displayed and which
1157 * don't.
1159 * @param field The account field.
1160 * @param filter_func The account filter function.
1162 void purple_request_field_account_set_filter(PurpleRequestField *field,
1163 PurpleFilterAccountFunc filter_func);
1166 * Returns the default account in an account field.
1168 * @param field The field.
1170 * @return The default account.
1172 PurpleAccount *purple_request_field_account_get_default_value(
1173 const PurpleRequestField *field);
1176 * Returns the user-entered account in an account field.
1178 * @param field The field.
1180 * @return The user-entered account.
1182 PurpleAccount *purple_request_field_account_get_value(
1183 const PurpleRequestField *field);
1186 * Returns whether or not to show all accounts in an account field.
1188 * If TRUE, all accounts, online or offline, will be shown. If FALSE,
1189 * only online accounts will be shown.
1191 * @param field The account field.
1192 * @return Whether or not to show all accounts.
1194 gboolean purple_request_field_account_get_show_all(
1195 const PurpleRequestField *field);
1198 * Returns the account filter function in an account field.
1200 * This function will determine which accounts get displayed and which
1201 * don't.
1203 * @param field The account field.
1205 * @return The account filter function.
1207 PurpleFilterAccountFunc purple_request_field_account_get_filter(
1208 const PurpleRequestField *field);
1210 /*@}*/
1212 /**************************************************************************/
1213 /** @name Request API */
1214 /**************************************************************************/
1215 /*@{*/
1218 * Prompts the user for text input.
1220 * @param handle The plugin or connection handle. For some
1221 * things this is <em>extremely</em> important. The
1222 * handle is used to programmatically close the request
1223 * dialog when it is no longer needed. For PRPLs this
1224 * is often a pointer to the #PurpleConnection
1225 * instance. For plugins this should be a similar,
1226 * unique memory location. This value is important
1227 * because it allows a request to be closed with
1228 * purple_request_close_with_handle() when, for
1229 * example, you sign offline. If the request is
1230 * <em>not</em> closed it is <strong>very</strong>
1231 * likely to cause a crash whenever the callback
1232 * handler functions are triggered.
1233 * @param title The title of the message, or @c NULL if it should have
1234 * no title.
1235 * @param primary The main point of the message, or @c NULL if you're
1236 * feeling enigmatic.
1237 * @param secondary Secondary information, or @c NULL if there is none.
1238 * @param default_value The default value.
1239 * @param multiline @c TRUE if the inputted text can span multiple lines.
1240 * @param masked @c TRUE if the inputted text should be masked in some
1241 * way (such as by displaying characters as stars). This
1242 * might be because the input is some kind of password.
1243 * @param hint Optionally suggest how the input box should appear.
1244 * Use "html", for example, to allow the user to enter
1245 * HTML.
1246 * @param ok_text The text for the @c OK button, which may not be @c NULL.
1247 * @param ok_cb The callback for the @c OK button, which may not be @c
1248 * NULL.
1249 * @param cancel_text The text for the @c Cancel button, which may not be @c
1250 * NULL.
1251 * @param cancel_cb The callback for the @c Cancel button, which may be
1252 * @c NULL.
1253 * @param account The #PurpleAccount associated with this request, or @c
1254 * NULL if none is.
1255 * @param who The username of the buddy associated with this request,
1256 * or @c NULL if none is.
1257 * @param conv The #PurpleConversation associated with this request, or
1258 * @c NULL if none is.
1259 * @param user_data The data to pass to the callback.
1261 * @return A UI-specific handle.
1263 void *purple_request_input(void *handle, const char *title, const char *primary,
1264 const char *secondary, const char *default_value, gboolean multiline,
1265 gboolean masked, gchar *hint,
1266 const char *ok_text, GCallback ok_cb,
1267 const char *cancel_text, GCallback cancel_cb,
1268 PurpleAccount *account, const char *who, PurpleConversation *conv,
1269 void *user_data);
1272 * Prompts the user for multiple-choice input.
1274 * @param handle The plugin or connection handle. For some things this
1275 * is <em>extremely</em> important. See the comments on
1276 * purple_request_input().
1277 * @param title The title of the message, or @c NULL if it should have
1278 * no title.
1279 * @param primary The main point of the message, or @c NULL if you're
1280 * feeling enigmatic.
1281 * @param secondary Secondary information, or @c NULL if there is none.
1282 * @param default_value The default choice; this should be one of the values
1283 * listed in the varargs.
1284 * @param ok_text The text for the @c OK button, which may not be @c NULL.
1285 * @param ok_cb The callback for the @c OK button, which may not be @c
1286 * NULL.
1287 * @param cancel_text The text for the @c Cancel button, which may not be @c
1288 * NULL.
1289 * @param cancel_cb The callback for the @c Cancel button, or @c NULL to
1290 * do nothing.
1291 * @param account The #PurpleAccount associated with this request, or @c
1292 * NULL if none is.
1293 * @param who The username of the buddy associated with this request,
1294 * or @c NULL if none is.
1295 * @param conv The #PurpleConversation associated with this request, or
1296 * @c NULL if none is.
1297 * @param user_data The data to pass to the callback.
1298 * @param ... The choices, which should be pairs of <tt>char *</tt>
1299 * descriptions and <tt>int</tt> values, terminated with a
1300 * @c NULL parameter.
1302 * @return A UI-specific handle.
1304 void *purple_request_choice(void *handle, const char *title, const char *primary,
1305 const char *secondary, int default_value,
1306 const char *ok_text, GCallback ok_cb,
1307 const char *cancel_text, GCallback cancel_cb,
1308 PurpleAccount *account, const char *who, PurpleConversation *conv,
1309 void *user_data, ...) G_GNUC_NULL_TERMINATED;
1312 * <tt>va_list</tt> version of purple_request_choice(); see its documentation.
1314 void *purple_request_choice_varg(void *handle, const char *title,
1315 const char *primary, const char *secondary, int default_value,
1316 const char *ok_text, GCallback ok_cb,
1317 const char *cancel_text, GCallback cancel_cb,
1318 PurpleAccount *account, const char *who, PurpleConversation *conv,
1319 void *user_data, va_list choices);
1322 * Prompts the user for an action.
1324 * This is often represented as a dialog with a button for each action.
1326 * @param handle The plugin or connection handle. For some things this
1327 * is <em>extremely</em> important. See the comments on
1328 * purple_request_input().
1329 * @param title The title of the message, or @c NULL if it should have
1330 * no title.
1331 * @param primary The main point of the message, or @c NULL if you're
1332 * feeling enigmatic.
1333 * @param secondary Secondary information, or @c NULL if there is none.
1334 * @param default_action The default action, zero-indexed; if the third action
1335 * supplied should be the default, supply <tt>2</tt>.
1336 * The should be the action that users are most likely
1337 * to select.
1338 * @param account The #PurpleAccount associated with this request, or @c
1339 * NULL if none is.
1340 * @param who The username of the buddy associated with this request,
1341 * or @c NULL if none is.
1342 * @param conv The #PurpleConversation associated with this request, or
1343 * @c NULL if none is.
1344 * @param user_data The data to pass to the callback.
1345 * @param action_count The number of actions.
1346 * @param ... A list of actions. These are pairs of
1347 * arguments. The first of each pair is the
1348 * <tt>char *</tt> label that appears on the button. It
1349 * should have an underscore before the letter you want
1350 * to use as the accelerator key for the button. The
1351 * second of each pair is the #PurpleRequestActionCb
1352 * function to use when the button is clicked.
1354 * @return A UI-specific handle.
1356 void *purple_request_action(void *handle, const char *title, const char *primary,
1357 const char *secondary, int default_action, PurpleAccount *account,
1358 const char *who, PurpleConversation *conv, void *user_data,
1359 size_t action_count, ...);
1362 * <tt>va_list</tt> version of purple_request_action(); see its documentation.
1364 void *purple_request_action_varg(void *handle, const char *title,
1365 const char *primary, const char *secondary, int default_action,
1366 PurpleAccount *account, const char *who, PurpleConversation *conv,
1367 void *user_data, size_t action_count, va_list actions);
1370 * Displays groups of fields for the user to fill in.
1372 * @param handle The plugin or connection handle. For some things this
1373 * is <em>extremely</em> important. See the comments on
1374 * purple_request_input().
1375 * @param title The title of the message, or @c NULL if it should have
1376 * no title.
1377 * @param primary The main point of the message, or @c NULL if you're
1378 * feeling enigmatic.
1379 * @param secondary Secondary information, or @c NULL if there is none.
1380 * @param fields The list of fields.
1381 * @param ok_text The text for the @c OK button, which may not be @c NULL.
1382 * @param ok_cb The callback for the @c OK button, which may not be @c
1383 * NULL.
1384 * @param cancel_text The text for the @c Cancel button, which may not be @c
1385 * NULL.
1386 * @param cancel_cb The callback for the @c Cancel button, which may be
1387 * @c NULL.
1388 * @param account The #PurpleAccount associated with this request, or @c
1389 * NULL if none is
1390 * @param who The username of the buddy associated with this request,
1391 * or @c NULL if none is
1392 * @param conv The #PurpleConversation associated with this request, or
1393 * @c NULL if none is
1394 * @param user_data The data to pass to the callback.
1396 * @return A UI-specific handle.
1398 void *purple_request_fields(void *handle, const char *title, const char *primary,
1399 const char *secondary, PurpleRequestFields *fields,
1400 const char *ok_text, GCallback ok_cb,
1401 const char *cancel_text, GCallback cancel_cb,
1402 PurpleAccount *account, const char *who, PurpleConversation *conv,
1403 void *user_data);
1406 * Closes a request.
1408 * @param type The request type.
1409 * @param uihandle The request UI handle.
1411 void purple_request_close(PurpleRequestType type, void *uihandle);
1414 * Closes all requests registered with the specified handle.
1416 * @param handle The handle, as supplied as the @a handle parameter to one of the
1417 * <tt>purple_request_*</tt> functions.
1419 * @see purple_request_input().
1421 void purple_request_close_with_handle(void *handle);
1424 * A wrapper for purple_request_action() that uses @c Yes and @c No buttons.
1426 #define purple_request_yes_no(handle, title, primary, secondary, \
1427 default_action, account, who, conv, \
1428 user_data, yes_cb, no_cb) \
1429 purple_request_action((handle), (title), (primary), (secondary), \
1430 (default_action), account, who, conv, (user_data), 2, \
1431 _("_Yes"), (yes_cb), _("_No"), (no_cb))
1434 * A wrapper for purple_request_action() that uses @c OK and @c Cancel buttons.
1436 #define purple_request_ok_cancel(handle, title, primary, secondary, \
1437 default_action, account, who, conv, \
1438 user_data, ok_cb, cancel_cb) \
1439 purple_request_action((handle), (title), (primary), (secondary), \
1440 (default_action), account, who, conv, (user_data), 2, \
1441 _("_OK"), (ok_cb), _("_Cancel"), (cancel_cb))
1444 * A wrapper for purple_request_action() that uses Accept and Cancel buttons.
1446 #define purple_request_accept_cancel(handle, title, primary, secondary, \
1447 default_action, account, who, conv, \
1448 user_data, accept_cb, cancel_cb) \
1449 purple_request_action((handle), (title), (primary), (secondary), \
1450 (default_action), account, who, conv, (user_data), 2, \
1451 _("_Accept"), (accept_cb), _("_Cancel"), (cancel_cb))
1454 * Displays a file selector request dialog. Returns the selected filename to
1455 * the callback. Can be used for either opening a file or saving a file.
1457 * @param handle The plugin or connection handle. For some things this
1458 * is <em>extremely</em> important. See the comments on
1459 * purple_request_input().
1460 * @param title The title of the message, or @c NULL if it should have
1461 * no title.
1462 * @param filename The default filename (may be @c NULL)
1463 * @param savedialog True if this dialog is being used to save a file.
1464 * False if it is being used to open a file.
1465 * @param ok_cb The callback for the @c OK button.
1466 * @param cancel_cb The callback for the @c Cancel button, which may be @c NULL.
1467 * @param account The #PurpleAccount associated with this request, or @c
1468 * NULL if none is
1469 * @param who The username of the buddy associated with this request,
1470 * or @c NULL if none is
1471 * @param conv The #PurpleConversation associated with this request, or
1472 * @c NULL if none is
1473 * @param user_data The data to pass to the callback.
1475 * @return A UI-specific handle.
1477 void *purple_request_file(void *handle, const char *title, const char *filename,
1478 gboolean savedialog, GCallback ok_cb, GCallback cancel_cb,
1479 PurpleAccount *account, const char *who, PurpleConversation *conv,
1480 void *user_data);
1483 * Displays a folder select dialog. Returns the selected filename to
1484 * the callback.
1486 * @param handle The plugin or connection handle. For some things this
1487 * is <em>extremely</em> important. See the comments on
1488 * purple_request_input().
1489 * @param title The title of the message, or @c NULL if it should have
1490 * no title.
1491 * @param dirname The default directory name (may be @c NULL)
1492 * @param ok_cb The callback for the @c OK button.
1493 * @param cancel_cb The callback for the @c Cancel button, which may be @c NULL.
1494 * @param account The #PurpleAccount associated with this request, or @c
1495 * NULL if none is
1496 * @param who The username of the buddy associated with this request,
1497 * or @c NULL if none is
1498 * @param conv The #PurpleConversation associated with this request, or
1499 * @c NULL if none is
1500 * @param user_data The data to pass to the callback.
1502 * @return A UI-specific handle.
1504 void *purple_request_folder(void *handle, const char *title, const char *dirname,
1505 GCallback ok_cb, GCallback cancel_cb,
1506 PurpleAccount *account, const char *who, PurpleConversation *conv,
1507 void *user_data);
1509 /*@}*/
1511 /**************************************************************************/
1512 /** @name UI Registration Functions */
1513 /**************************************************************************/
1514 /*@{*/
1517 * Sets the UI operations structure to be used when displaying a
1518 * request.
1520 * @param ops The UI operations structure.
1522 void purple_request_set_ui_ops(PurpleRequestUiOps *ops);
1525 * Returns the UI operations structure to be used when displaying a
1526 * request.
1528 * @return The UI operations structure.
1530 PurpleRequestUiOps *purple_request_get_ui_ops(void);
1532 /*@}*/
1534 #ifdef __cplusplus
1536 #endif
1538 #endif /* _PURPLE_REQUEST_H_ */