Mercurial > pidgin
comparison libpurple/request.h @ 32819:2c6510167895 default tip
propagate from branch 'im.pidgin.pidgin.2.x.y' (head 3315c5dfbd0ad16511bdcf865e5b07c02d07df24)
to branch 'im.pidgin.pidgin' (head cbd1eda6bcbf0565ae7766396bb8f6f419cb6a9a)
| author | Elliott Sales de Andrade <qulogic@pidgin.im> |
|---|---|
| date | Sat, 02 Jun 2012 02:30:49 +0000 |
| parents | ca8b2ec198d9 |
| children |
comparison
equal
deleted
inserted
replaced
| 32818:01ff09d4a463 | 32819:2c6510167895 |
|---|---|
| 28 | 28 |
| 29 #include <stdlib.h> | 29 #include <stdlib.h> |
| 30 #include <glib-object.h> | 30 #include <glib-object.h> |
| 31 #include <glib.h> | 31 #include <glib.h> |
| 32 | 32 |
| 33 /** @copydoc _PurpleRequestField */ | 33 /** |
| 34 * A request field. | |
| 35 */ | |
| 34 typedef struct _PurpleRequestField PurpleRequestField; | 36 typedef struct _PurpleRequestField PurpleRequestField; |
| 37 | |
| 38 /** | |
| 39 * Multiple fields request data. | |
| 40 */ | |
| 41 typedef struct _PurpleRequestFields PurpleRequestFields; | |
| 42 | |
| 43 /** | |
| 44 * A group of fields with a title. | |
| 45 */ | |
| 46 typedef struct _PurpleRequestFieldGroup PurpleRequestFieldGroup; | |
| 35 | 47 |
| 36 #include "account.h" | 48 #include "account.h" |
| 37 | 49 |
| 38 #define PURPLE_DEFAULT_ACTION_NONE -1 | 50 #define PURPLE_DEFAULT_ACTION_NONE -1 |
| 39 | 51 |
| 62 PURPLE_REQUEST_FIELD_BOOLEAN, | 74 PURPLE_REQUEST_FIELD_BOOLEAN, |
| 63 PURPLE_REQUEST_FIELD_CHOICE, | 75 PURPLE_REQUEST_FIELD_CHOICE, |
| 64 PURPLE_REQUEST_FIELD_LIST, | 76 PURPLE_REQUEST_FIELD_LIST, |
| 65 PURPLE_REQUEST_FIELD_LABEL, | 77 PURPLE_REQUEST_FIELD_LABEL, |
| 66 PURPLE_REQUEST_FIELD_IMAGE, | 78 PURPLE_REQUEST_FIELD_IMAGE, |
| 67 PURPLE_REQUEST_FIELD_ACCOUNT | 79 PURPLE_REQUEST_FIELD_ACCOUNT, |
| 80 PURPLE_REQUEST_FIELD_CERTIFICATE | |
| 68 | 81 |
| 69 } PurpleRequestFieldType; | 82 } PurpleRequestFieldType; |
| 70 | |
| 71 /** | |
| 72 * Multiple fields request data. | |
| 73 */ | |
| 74 typedef struct | |
| 75 { | |
| 76 GList *groups; | |
| 77 | |
| 78 GHashTable *fields; | |
| 79 | |
| 80 GList *required_fields; | |
| 81 | |
| 82 void *ui_data; | |
| 83 | |
| 84 } PurpleRequestFields; | |
| 85 | |
| 86 /** | |
| 87 * A group of fields with a title. | |
| 88 */ | |
| 89 typedef struct | |
| 90 { | |
| 91 PurpleRequestFields *fields_list; | |
| 92 | |
| 93 char *title; | |
| 94 | |
| 95 GList *fields; | |
| 96 | |
| 97 } PurpleRequestFieldGroup; | |
| 98 | |
| 99 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_REQUEST_C_) | |
| 100 /** | |
| 101 * A request field. | |
| 102 */ | |
| 103 struct _PurpleRequestField | |
| 104 { | |
| 105 PurpleRequestFieldType type; | |
| 106 PurpleRequestFieldGroup *group; | |
| 107 | |
| 108 char *id; | |
| 109 char *label; | |
| 110 char *type_hint; | |
| 111 | |
| 112 gboolean visible; | |
| 113 gboolean required; | |
| 114 | |
| 115 union | |
| 116 { | |
| 117 struct | |
| 118 { | |
| 119 gboolean multiline; | |
| 120 gboolean masked; | |
| 121 gboolean editable; | |
| 122 char *default_value; | |
| 123 char *value; | |
| 124 | |
| 125 } string; | |
| 126 | |
| 127 struct | |
| 128 { | |
| 129 int default_value; | |
| 130 int value; | |
| 131 | |
| 132 } integer; | |
| 133 | |
| 134 struct | |
| 135 { | |
| 136 gboolean default_value; | |
| 137 gboolean value; | |
| 138 | |
| 139 } boolean; | |
| 140 | |
| 141 struct | |
| 142 { | |
| 143 int default_value; | |
| 144 int value; | |
| 145 | |
| 146 GList *labels; | |
| 147 | |
| 148 } choice; | |
| 149 | |
| 150 struct | |
| 151 { | |
| 152 GList *items; | |
| 153 GList *icons; | |
| 154 GHashTable *item_data; | |
| 155 GList *selected; | |
| 156 GHashTable *selected_table; | |
| 157 | |
| 158 gboolean multiple_selection; | |
| 159 | |
| 160 } list; | |
| 161 | |
| 162 struct | |
| 163 { | |
| 164 PurpleAccount *default_account; | |
| 165 PurpleAccount *account; | |
| 166 gboolean show_all; | |
| 167 | |
| 168 PurpleFilterAccountFunc filter_func; | |
| 169 | |
| 170 } account; | |
| 171 | |
| 172 struct | |
| 173 { | |
| 174 unsigned int scale_x; | |
| 175 unsigned int scale_y; | |
| 176 const char *buffer; | |
| 177 gsize size; | |
| 178 } image; | |
| 179 | |
| 180 } u; | |
| 181 | |
| 182 void *ui_data; | |
| 183 | |
| 184 }; | |
| 185 #endif | |
| 186 | 83 |
| 187 /** | 84 /** |
| 188 * Request UI operations. | 85 * Request UI operations. |
| 189 */ | 86 */ |
| 190 typedef struct | 87 typedef struct |
| 260 typedef void (*PurpleRequestActionCb)(void *, int); | 157 typedef void (*PurpleRequestActionCb)(void *, int); |
| 261 typedef void (*PurpleRequestChoiceCb)(void *, int); | 158 typedef void (*PurpleRequestChoiceCb)(void *, int); |
| 262 typedef void (*PurpleRequestFieldsCb)(void *, PurpleRequestFields *fields); | 159 typedef void (*PurpleRequestFieldsCb)(void *, PurpleRequestFields *fields); |
| 263 typedef void (*PurpleRequestFileCb)(void *, const char *filename); | 160 typedef void (*PurpleRequestFileCb)(void *, const char *filename); |
| 264 | 161 |
| 265 #ifdef __cplusplus | 162 G_BEGIN_DECLS |
| 266 extern "C" { | |
| 267 #endif | |
| 268 | 163 |
| 269 /**************************************************************************/ | 164 /**************************************************************************/ |
| 270 /** @name Field List API */ | 165 /** @name Field List API */ |
| 271 /**************************************************************************/ | 166 /**************************************************************************/ |
| 272 /*@{*/ | 167 /*@{*/ |
| 408 * @return The account value, if found, or NULL otherwise. | 303 * @return The account value, if found, or NULL otherwise. |
| 409 */ | 304 */ |
| 410 PurpleAccount *purple_request_fields_get_account(const PurpleRequestFields *fields, | 305 PurpleAccount *purple_request_fields_get_account(const PurpleRequestFields *fields, |
| 411 const char *id); | 306 const char *id); |
| 412 | 307 |
| 308 /** | |
| 309 * Returns the UI data associated with this object. | |
| 310 * | |
| 311 * @param fields The fields list. | |
| 312 * | |
| 313 * @return The UI data associated with this object. This is a | |
| 314 * convenience field provided to the UIs--it is not | |
| 315 * used by the libuprple core. | |
| 316 */ | |
| 317 gpointer purple_request_fields_get_ui_data(const PurpleRequestFields *fields); | |
| 318 | |
| 319 /** | |
| 320 * Set the UI data associated with this object. | |
| 321 * | |
| 322 * @param fields The fields list. | |
| 323 * @param ui_data A pointer to associate with this object. | |
| 324 */ | |
| 325 void purple_request_fields_set_ui_data(PurpleRequestFields *fields, gpointer ui_data); | |
| 326 | |
| 413 /*@}*/ | 327 /*@}*/ |
| 414 | 328 |
| 415 /**************************************************************************/ | 329 /**************************************************************************/ |
| 416 /** @name Fields Group API */ | 330 /** @name Fields Group API */ |
| 417 /**************************************************************************/ | 331 /**************************************************************************/ |
| 458 * @param group The group. | 372 * @param group The group. |
| 459 * | 373 * |
| 460 * @constreturn The list of fields in the group. | 374 * @constreturn The list of fields in the group. |
| 461 */ | 375 */ |
| 462 GList *purple_request_field_group_get_fields( | 376 GList *purple_request_field_group_get_fields( |
| 377 const PurpleRequestFieldGroup *group); | |
| 378 | |
| 379 /** | |
| 380 * Returns a list of all fields in a group. | |
| 381 * | |
| 382 * @param group The group. | |
| 383 * | |
| 384 * @constreturn The list of fields in the group. | |
| 385 */ | |
| 386 PurpleRequestFields *purple_request_field_group_get_fields_list( | |
| 463 const PurpleRequestFieldGroup *group); | 387 const PurpleRequestFieldGroup *group); |
| 464 | 388 |
| 465 /*@}*/ | 389 /*@}*/ |
| 466 | 390 |
| 467 /**************************************************************************/ | 391 /**************************************************************************/ |
| 515 */ | 439 */ |
| 516 void purple_request_field_set_type_hint(PurpleRequestField *field, | 440 void purple_request_field_set_type_hint(PurpleRequestField *field, |
| 517 const char *type_hint); | 441 const char *type_hint); |
| 518 | 442 |
| 519 /** | 443 /** |
| 444 * Sets the tooltip for the field. | |
| 445 * | |
| 446 * This is optionally used by the UIs to provide a tooltip for | |
| 447 * the field. | |
| 448 * | |
| 449 * @param field The field. | |
| 450 * @param tooltip The tooltip text. | |
| 451 */ | |
| 452 void purple_request_field_set_tooltip(PurpleRequestField *field, | |
| 453 const char *tooltip); | |
| 454 | |
| 455 /** | |
| 520 * Sets whether or not a field is required. | 456 * Sets whether or not a field is required. |
| 521 * | 457 * |
| 522 * @param field The field. | 458 * @param field The field. |
| 523 * @param required TRUE if required, or FALSE. | 459 * @param required TRUE if required, or FALSE. |
| 524 */ | 460 */ |
| 538 * Returns the group for the field. | 474 * Returns the group for the field. |
| 539 * | 475 * |
| 540 * @param field The field. | 476 * @param field The field. |
| 541 * | 477 * |
| 542 * @return The UI data. | 478 * @return The UI data. |
| 543 * | |
| 544 * @since 2.6.0 | |
| 545 */ | 479 */ |
| 546 PurpleRequestFieldGroup *purple_request_field_get_group(const PurpleRequestField *field); | 480 PurpleRequestFieldGroup *purple_request_field_get_group(const PurpleRequestField *field); |
| 547 | 481 |
| 548 /** | 482 /** |
| 549 * Returns the ID of a field. | 483 * Returns the ID of a field. |
| 580 * @return The field's type hint. | 514 * @return The field's type hint. |
| 581 */ | 515 */ |
| 582 const char *purple_request_field_get_type_hint(const PurpleRequestField *field); | 516 const char *purple_request_field_get_type_hint(const PurpleRequestField *field); |
| 583 | 517 |
| 584 /** | 518 /** |
| 519 * Returns the field's tooltip. | |
| 520 * | |
| 521 * @param field The field. | |
| 522 * | |
| 523 * @return The field's tooltip. | |
| 524 */ | |
| 525 const char *purple_request_field_get_tooltip(const PurpleRequestField *field); | |
| 526 | |
| 527 /** | |
| 585 * Returns whether or not a field is required. | 528 * Returns whether or not a field is required. |
| 586 * | 529 * |
| 587 * @param field The field. | 530 * @param field The field. |
| 588 * | 531 * |
| 589 * @return TRUE if the field is required, or FALSE. | 532 * @return TRUE if the field is required, or FALSE. |
| 594 * Returns the ui_data for a field. | 537 * Returns the ui_data for a field. |
| 595 * | 538 * |
| 596 * @param field The field. | 539 * @param field The field. |
| 597 * | 540 * |
| 598 * @return The UI data. | 541 * @return The UI data. |
| 599 * | |
| 600 * @since 2.6.0 | |
| 601 */ | 542 */ |
| 602 gpointer purple_request_field_get_ui_data(const PurpleRequestField *field); | 543 gpointer purple_request_field_get_ui_data(const PurpleRequestField *field); |
| 603 | 544 |
| 604 /** | 545 /** |
| 605 * Sets the ui_data for a field. | 546 * Sets the ui_data for a field. |
| 606 * | 547 * |
| 607 * @param field The field. | 548 * @param field The field. |
| 608 * @param ui_data The UI data. | 549 * @param ui_data The UI data. |
| 609 * | 550 * |
| 610 * @return The UI data. | 551 * @return The UI data. |
| 611 * | |
| 612 * @since 2.6.0 | |
| 613 */ | 552 */ |
| 614 void purple_request_field_set_ui_data(PurpleRequestField *field, | 553 void purple_request_field_set_ui_data(PurpleRequestField *field, |
| 615 gpointer ui_data); | 554 gpointer ui_data); |
| 616 | 555 |
| 617 /*@}*/ | 556 /*@}*/ |
| 959 /** | 898 /** |
| 960 * Adds an item to a list field. | 899 * Adds an item to a list field. |
| 961 * | 900 * |
| 962 * @param field The list field. | 901 * @param field The list field. |
| 963 * @param item The list item. | 902 * @param item The list item. |
| 964 * @param data The associated data. | |
| 965 * | |
| 966 * @deprecated Use purple_request_field_list_add_icon() instead. | |
| 967 */ | |
| 968 void purple_request_field_list_add(PurpleRequestField *field, | |
| 969 const char *item, void *data); | |
| 970 | |
| 971 /** | |
| 972 * Adds an item to a list field. | |
| 973 * | |
| 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. | 903 * @param icon_path The path to icon file, or @c NULL for no icon. |
| 977 * @param data The associated data. | 904 * @param data The associated data. |
| 978 */ | 905 */ |
| 979 void purple_request_field_list_add_icon(PurpleRequestField *field, | 906 void purple_request_field_list_add_icon(PurpleRequestField *field, |
| 980 const char *item, const char* icon_path, void* data); | 907 const char *item, const char* icon_path, void* data); |
| 1237 * @param field The account field. | 1164 * @param field The account field. |
| 1238 * | 1165 * |
| 1239 * @return The account filter function. | 1166 * @return The account filter function. |
| 1240 */ | 1167 */ |
| 1241 PurpleFilterAccountFunc purple_request_field_account_get_filter( | 1168 PurpleFilterAccountFunc purple_request_field_account_get_filter( |
| 1169 const PurpleRequestField *field); | |
| 1170 | |
| 1171 /*@}*/ | |
| 1172 | |
| 1173 /**************************************************************************/ | |
| 1174 /** @name Certificate Field API */ | |
| 1175 /**************************************************************************/ | |
| 1176 /*@{*/ | |
| 1177 | |
| 1178 /** | |
| 1179 * Creates a certificate field. | |
| 1180 * | |
| 1181 * @param id The field ID. | |
| 1182 * @param text The label of the field. | |
| 1183 * @param cert The certificate of the field. | |
| 1184 * | |
| 1185 * @return The new field. | |
| 1186 */ | |
| 1187 PurpleRequestField *purple_request_field_certificate_new(const char *id, | |
| 1188 const char *text, | |
| 1189 PurpleCertificate *cert); | |
| 1190 | |
| 1191 /** | |
| 1192 * Returns the certificate in a certificate field. | |
| 1193 * | |
| 1194 * @param field The field. | |
| 1195 * | |
| 1196 * @return The certificate. | |
| 1197 */ | |
| 1198 PurpleCertificate *purple_request_field_certificate_get_value( | |
| 1242 const PurpleRequestField *field); | 1199 const PurpleRequestField *field); |
| 1243 | 1200 |
| 1244 /*@}*/ | 1201 /*@}*/ |
| 1245 | 1202 |
| 1246 /**************************************************************************/ | 1203 /**************************************************************************/ |
| 1400 PurpleAccount *account, const char *who, PurpleConversation *conv, | 1357 PurpleAccount *account, const char *who, PurpleConversation *conv, |
| 1401 void *user_data, size_t action_count, va_list actions); | 1358 void *user_data, size_t action_count, va_list actions); |
| 1402 | 1359 |
| 1403 /** | 1360 /** |
| 1404 * Version of purple_request_action() supplying an image for the UI to | 1361 * Version of purple_request_action() supplying an image for the UI to |
| 1405 * optionally display as an icon in the dialog; see its documentation | 1362 * optionally display as an icon in the dialog; see its documentation. |
| 1406 * @since 2.7.0 | |
| 1407 */ | 1363 */ |
| 1408 void *purple_request_action_with_icon(void *handle, const char *title, | 1364 void *purple_request_action_with_icon(void *handle, const char *title, |
| 1409 const char *primary, const char *secondary, int default_action, | 1365 const char *primary, const char *secondary, int default_action, |
| 1410 PurpleAccount *account, const char *who, PurpleConversation *conv, | 1366 PurpleAccount *account, const char *who, PurpleConversation *conv, |
| 1411 gconstpointer icon_data, gsize icon_size, void *user_data, | 1367 gconstpointer icon_data, gsize icon_size, void *user_data, |
| 1412 size_t action_count, ...); | 1368 size_t action_count, ...); |
| 1413 | 1369 |
| 1414 /** | 1370 /** |
| 1415 * <tt>va_list</tt> version of purple_request_action_with_icon(); | 1371 * <tt>va_list</tt> version of purple_request_action_with_icon(); |
| 1416 * see its documentation. | 1372 * see its documentation. |
| 1417 * @since 2.7.0 | |
| 1418 */ | 1373 */ |
| 1419 void *purple_request_action_with_icon_varg(void *handle, const char *title, | 1374 void *purple_request_action_with_icon_varg(void *handle, const char *title, |
| 1420 const char *primary, const char *secondary, int default_action, | 1375 const char *primary, const char *secondary, int default_action, |
| 1421 PurpleAccount *account, const char *who, PurpleConversation *conv, | 1376 PurpleAccount *account, const char *who, PurpleConversation *conv, |
| 1422 gconstpointer icon_data, gsize icon_size, | 1377 gconstpointer icon_data, gsize icon_size, |
| 1574 void *purple_request_folder(void *handle, const char *title, const char *dirname, | 1529 void *purple_request_folder(void *handle, const char *title, const char *dirname, |
| 1575 GCallback ok_cb, GCallback cancel_cb, | 1530 GCallback ok_cb, GCallback cancel_cb, |
| 1576 PurpleAccount *account, const char *who, PurpleConversation *conv, | 1531 PurpleAccount *account, const char *who, PurpleConversation *conv, |
| 1577 void *user_data); | 1532 void *user_data); |
| 1578 | 1533 |
| 1534 /** | |
| 1535 * Prompts the user for action over a certificate. | |
| 1536 * | |
| 1537 * This is often represented as a dialog with a button for each action. | |
| 1538 * | |
| 1539 * @param handle The plugin or connection handle. For some things this | |
| 1540 * is <em>extremely</em> important. See the comments on | |
| 1541 * purple_request_input(). | |
| 1542 * @param title The title of the message, or @c NULL if it should have | |
| 1543 * no title. | |
| 1544 * @param primary The main point of the message, or @c NULL if you're | |
| 1545 * feeling enigmatic. | |
| 1546 * @param secondary Secondary information, or @c NULL if there is none. | |
| 1547 * @param cert The #PurpleCertificate associated with this request. | |
| 1548 * @param ok_text The text for the @c OK button, which may not be @c NULL. | |
| 1549 * @param ok_cb The callback for the @c OK button, which may not be | |
| 1550 * @c NULL. | |
| 1551 * @param cancel_text The text for the @c Cancel button, which may not be | |
| 1552 * @c NULL. | |
| 1553 * @param cancel_cb The callback for the @c Cancel button, which may be | |
| 1554 * @c NULL. | |
| 1555 * @param user_data The data to pass to the callback. | |
| 1556 * | |
| 1557 * @return A UI-specific handle. | |
| 1558 */ | |
| 1559 void *purple_request_certificate(void *handle, const char *title, | |
| 1560 const char *primary, const char *secondary, PurpleCertificate *cert, | |
| 1561 const char *ok_text, GCallback ok_cb, | |
| 1562 const char *cancel_text, GCallback cancel_cb, | |
| 1563 void *user_data); | |
| 1564 | |
| 1579 /*@}*/ | 1565 /*@}*/ |
| 1580 | 1566 |
| 1581 /**************************************************************************/ | 1567 /**************************************************************************/ |
| 1582 /** @name UI Registration Functions */ | 1568 /** @name UI Registration Functions */ |
| 1583 /**************************************************************************/ | 1569 /**************************************************************************/ |
| 1599 */ | 1585 */ |
| 1600 PurpleRequestUiOps *purple_request_get_ui_ops(void); | 1586 PurpleRequestUiOps *purple_request_get_ui_ops(void); |
| 1601 | 1587 |
| 1602 /*@}*/ | 1588 /*@}*/ |
| 1603 | 1589 |
| 1604 #ifdef __cplusplus | 1590 G_END_DECLS |
| 1605 } | |
| 1606 #endif | |
| 1607 | 1591 |
| 1608 #endif /* _PURPLE_REQUEST_H_ */ | 1592 #endif /* _PURPLE_REQUEST_H_ */ |
