comparison libpurple/prpl.h @ 32672:3828a61c44da

A boring and large patch so I can merge heads.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Fri, 23 Dec 2011 08:21:58 +0000
parents 96e66fbe2881
children
comparison
equal deleted inserted replaced
32671:0e69949b3e61 32672:3828a61c44da
29 29
30 #ifndef _PURPLE_PRPL_H_ 30 #ifndef _PURPLE_PRPL_H_
31 #define _PURPLE_PRPL_H_ 31 #define _PURPLE_PRPL_H_
32 32
33 typedef struct _PurplePluginProtocolInfo PurplePluginProtocolInfo; 33 typedef struct _PurplePluginProtocolInfo PurplePluginProtocolInfo;
34 /** @copydoc _PurpleAttentionType */ 34
35 /** Represents "nudges" and "buzzes" that you may send to a buddy to attract
36 * their attention (or vice-versa).
37 */
35 typedef struct _PurpleAttentionType PurpleAttentionType; 38 typedef struct _PurpleAttentionType PurpleAttentionType;
36 39
37 /**************************************************************************/ 40 /**************************************************************************/
38 /** @name Basic Protocol Information */ 41 /** @name Basic Protocol Information */
39 /**************************************************************************/ 42 /**************************************************************************/
109 int min; /**< Minimum value in case of integer */ 112 int min; /**< Minimum value in case of integer */
110 int max; /**< Maximum value in case of integer */ 113 int max; /**< Maximum value in case of integer */
111 gboolean secret; /**< True if the entry is secret (password) */ 114 gboolean secret; /**< True if the entry is secret (password) */
112 }; 115 };
113 116
114 /** Represents "nudges" and "buzzes" that you may send to a buddy to attract
115 * their attention (or vice-versa).
116 */
117 struct _PurpleAttentionType
118 {
119 const char *name; /**< Shown in GUI elements */
120 const char *incoming_description; /**< Shown when sent */
121 const char *outgoing_description; /**< Shown when receied */
122 const char *icon_name; /**< Icon to display (optional) */
123 const char *unlocalized_name; /**< Unlocalized name for UIs needing it */
124
125 /* Reserved fields for future purposes */
126 gpointer _reserved2;
127 gpointer _reserved3;
128 gpointer _reserved4;
129 };
130
131 /** 117 /**
132 * Protocol options 118 * Protocol options
133 * 119 *
134 * These should all be stuff that some plugins can do and others can't. 120 * These should all be stuff that some plugins can do and others can't.
135 */ 121 */
198 OPT_PROTO_REGISTER_NOSCREENNAME = 0x00000200, 184 OPT_PROTO_REGISTER_NOSCREENNAME = 0x00000200,
199 185
200 /** 186 /**
201 * Indicates that slash commands are native to this protocol. 187 * Indicates that slash commands are native to this protocol.
202 * Used as a hint that unknown commands should not be sent as messages. 188 * Used as a hint that unknown commands should not be sent as messages.
203 * @since 2.1.0
204 */ 189 */
205 OPT_PROTO_SLASH_COMMANDS_NATIVE = 0x00000400, 190 OPT_PROTO_SLASH_COMMANDS_NATIVE = 0x00000400,
206 191
207 /** 192 /**
208 * Indicates that this protocol supports sending a user-supplied message 193 * Indicates that this protocol supports sending a user-supplied message
209 * along with an invitation. 194 * along with an invitation.
210 * @since 2.8.0
211 */ 195 */
212 OPT_PROTO_INVITE_MESSAGE = 0x00000800 196 OPT_PROTO_INVITE_MESSAGE = 0x00000800
213 197
214 } PurpleProtocolOptions; 198 } PurpleProtocolOptions;
215 199
220 * between purple and the protocol plugin. Many of these callbacks can be 204 * between purple and the protocol plugin. Many of these callbacks can be
221 * NULL. If a callback must be implemented, it has a comment indicating so. 205 * NULL. If a callback must be implemented, it has a comment indicating so.
222 */ 206 */
223 struct _PurplePluginProtocolInfo 207 struct _PurplePluginProtocolInfo
224 { 208 {
209 /**
210 * The size of the PurplePluginProtocolInfo. This should always be sizeof(PurplePluginProtocolInfo).
211 * This allows adding more functions to this struct without requiring a major version bump.
212 */
213 unsigned long struct_size;
214
215 /* NOTE:
216 * If more functions are added, they should accessed using the following syntax:
217 *
218 * if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, new_function))
219 * prpl->new_function(...);
220 *
221 * instead of
222 *
223 * if (prpl->new_function != NULL)
224 * prpl->new_function(...);
225 *
226 * The PURPLE_PROTOCOL_PLUGIN_HAS_FUNC macro can be used for the older member
227 * functions (e.g. login, send_im etc.) too.
228 */
229
225 PurpleProtocolOptions options; /**< Protocol options. */ 230 PurpleProtocolOptions options; /**< Protocol options. */
226 231
227 GList *user_splits; /**< A GList of PurpleAccountUserSplit */ 232 GList *user_splits; /**< A GList of PurpleAccountUserSplit */
228 GList *protocol_options; /**< A GList of PurpleAccountOption */ 233 GList *protocol_options; /**< A GList of PurpleAccountOption */
229 234
331 void (*set_status)(PurpleAccount *account, PurpleStatus *status); 336 void (*set_status)(PurpleAccount *account, PurpleStatus *status);
332 337
333 void (*set_idle)(PurpleConnection *, int idletime); 338 void (*set_idle)(PurpleConnection *, int idletime);
334 void (*change_passwd)(PurpleConnection *, const char *old_pass, 339 void (*change_passwd)(PurpleConnection *, const char *old_pass,
335 const char *new_pass); 340 const char *new_pass);
341
336 /** 342 /**
337 * Add a buddy to a group on the server. 343 * Add a buddy to a group on the server.
338 * 344 *
339 * This PRPL function may be called in situations in which the buddy is 345 * This PRPL function may be called in situations in which the buddy is
340 * already in the specified group. If the protocol supports 346 * already in the specified group. If the protocol supports
341 * authorization and the user is not already authorized to see the 347 * authorization and the user is not already authorized to see the
342 * status of \a buddy, \a add_buddy should request authorization. 348 * status of \a buddy, \a add_buddy should request authorization.
343 * 349 *
344 * @deprecated Since 2.8.0, add_buddy_with_invite is preferred. 350 * If authorization is required, then use the supplied invite message.
345 * @see add_buddy_with_invite 351 */
346 */ 352 void (*add_buddy)(PurpleConnection *pc, PurpleBuddy *buddy, PurpleGroup *group, const char *message);
347 void (*add_buddy)(PurpleConnection *, PurpleBuddy *buddy, PurpleGroup *group); 353 void (*add_buddies)(PurpleConnection *pc, GList *buddies, GList *groups, const char *message);
348 void (*add_buddies)(PurpleConnection *, GList *buddies, GList *groups);
349 void (*remove_buddy)(PurpleConnection *, PurpleBuddy *buddy, PurpleGroup *group); 354 void (*remove_buddy)(PurpleConnection *, PurpleBuddy *buddy, PurpleGroup *group);
350 void (*remove_buddies)(PurpleConnection *, GList *buddies, GList *groups); 355 void (*remove_buddies)(PurpleConnection *, GList *buddies, GList *groups);
351 void (*add_permit)(PurpleConnection *, const char *name); 356 void (*add_permit)(PurpleConnection *, const char *name);
352 void (*add_deny)(PurpleConnection *, const char *name); 357 void (*add_deny)(PurpleConnection *, const char *name);
353 void (*rem_permit)(PurpleConnection *, const char *name); 358 void (*rem_permit)(PurpleConnection *, const char *name);
442 447
443 /** 448 /**
444 * @deprecated Use #PurplePluginProtocolInfo.get_info instead. 449 * @deprecated Use #PurplePluginProtocolInfo.get_info instead.
445 */ 450 */
446 void (*get_cb_info)(PurpleConnection *, int, const char *who); 451 void (*get_cb_info)(PurpleConnection *, int, const char *who);
447 /**
448 * @deprecated Use #PurplePluginProtocolInfo.get_cb_real_name and
449 * #PurplePluginProtocolInfo.status_text instead.
450 */
451 void (*get_cb_away)(PurpleConnection *, int, const char *who);
452 452
453 /** save/store buddy's alias on server list/roster */ 453 /** save/store buddy's alias on server list/roster */
454 void (*alias_buddy)(PurpleConnection *, const char *who, 454 void (*alias_buddy)(PurpleConnection *, const char *who,
455 const char *alias); 455 const char *alias);
456 456
532 532
533 /* Attention API for sending & receiving zaps/nudges/buzzes etc. */ 533 /* Attention API for sending & receiving zaps/nudges/buzzes etc. */
534 gboolean (*send_attention)(PurpleConnection *gc, const char *username, guint type); 534 gboolean (*send_attention)(PurpleConnection *gc, const char *username, guint type);
535 GList *(*get_attention_types)(PurpleAccount *acct); 535 GList *(*get_attention_types)(PurpleAccount *acct);
536 536
537 /**
538 * The size of the PurplePluginProtocolInfo. This should always be sizeof(PurplePluginProtocolInfo).
539 * This allows adding more functions to this struct without requiring a major version bump.
540 */
541 unsigned long struct_size;
542
543 /* NOTE:
544 * If more functions are added, they should accessed using the following syntax:
545 *
546 * if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, new_function))
547 * prpl->new_function(...);
548 *
549 * instead of
550 *
551 * if (prpl->new_function != NULL)
552 * prpl->new_function(...);
553 *
554 * The PURPLE_PROTOCOL_PLUGIN_HAS_FUNC macro can be used for the older member
555 * functions (e.g. login, send_im etc.) too.
556 */
557
558 /** This allows protocols to specify additional strings to be used for 537 /** This allows protocols to specify additional strings to be used for
559 * various purposes. The idea is to stuff a bunch of strings in this hash 538 * various purposes. The idea is to stuff a bunch of strings in this hash
560 * table instead of expanding the struct for every addition. This hash 539 * table instead of expanding the struct for every addition. This hash
561 * table is allocated every call and MUST be unrefed by the caller. 540 * table is allocated every call and MUST be unrefed by the caller.
562 * 541 *
588 const char *who); 567 const char *who);
589 568
590 /** 569 /**
591 * Returns an array of "PurpleMood"s, with the last one having 570 * Returns an array of "PurpleMood"s, with the last one having
592 * "mood" set to @c NULL. 571 * "mood" set to @c NULL.
593 * @since 2.7.0
594 */ 572 */
595 PurpleMood *(*get_moods)(PurpleAccount *account); 573 PurpleMood *(*get_moods)(PurpleAccount *account);
596 574
597 /** 575 /**
598 * Set the user's "friendly name" (or alias or nickname or 576 * Set the user's "friendly name" (or alias or nickname or
608 * a protocol-specific "default"). 586 * a protocol-specific "default").
609 * @param success_cb Callback to be called if the public alias is set 587 * @param success_cb Callback to be called if the public alias is set
610 * @param failure_cb Callback to be called if setting the public alias 588 * @param failure_cb Callback to be called if setting the public alias
611 * fails 589 * fails
612 * @see purple_account_set_public_alias 590 * @see purple_account_set_public_alias
613 * @since 2.7.0
614 */ 591 */
615 void (*set_public_alias)(PurpleConnection *gc, const char *alias, 592 void (*set_public_alias)(PurpleConnection *gc, const char *alias,
616 PurpleSetPublicAliasSuccessCallback success_cb, 593 PurpleSetPublicAliasSuccessCallback success_cb,
617 PurpleSetPublicAliasFailureCallback failure_cb); 594 PurpleSetPublicAliasFailureCallback failure_cb);
618 /** 595 /**
625 * @param gc The connection for which to retireve the alias 602 * @param gc The connection for which to retireve the alias
626 * @param success_cb Callback to be called with the retrieved alias 603 * @param success_cb Callback to be called with the retrieved alias
627 * @param failure_cb Callback to be called if the prpl is unable to 604 * @param failure_cb Callback to be called if the prpl is unable to
628 * retrieve the alias 605 * retrieve the alias
629 * @see purple_account_get_public_alias 606 * @see purple_account_get_public_alias
630 * @since 2.7.0
631 */ 607 */
632 void (*get_public_alias)(PurpleConnection *gc, 608 void (*get_public_alias)(PurpleConnection *gc,
633 PurpleGetPublicAliasSuccessCallback success_cb, 609 PurpleGetPublicAliasSuccessCallback success_cb,
634 PurpleGetPublicAliasFailureCallback failure_cb); 610 PurpleGetPublicAliasFailureCallback failure_cb);
635
636 /**
637 * Add a buddy to a group on the server.
638 *
639 * This PRPL function may be called in situations in which the buddy is
640 * already in the specified group. If the protocol supports
641 * authorization and the user is not already authorized to see the
642 * status of \a buddy, \a add_buddy should request authorization.
643 *
644 * If authorization is required, then use the supplied invite message.
645 *
646 * @since 2.8.0
647 */
648 void (*add_buddy_with_invite)(PurpleConnection *pc, PurpleBuddy *buddy, PurpleGroup *group, const char *message);
649 void (*add_buddies_with_invite)(PurpleConnection *pc, GList *buddies, GList *groups, const char *message);
650 }; 611 };
651 612
652 #define PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, member) \ 613 #define PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, member) \
653 (((G_STRUCT_OFFSET(PurplePluginProtocolInfo, member) < G_STRUCT_OFFSET(PurplePluginProtocolInfo, struct_size)) \ 614 (G_STRUCT_OFFSET(PurplePluginProtocolInfo, member) < prpl->struct_size && \
654 || (G_STRUCT_OFFSET(PurplePluginProtocolInfo, member) < prpl->struct_size)) && \
655 prpl->member != NULL) 615 prpl->member != NULL)
656 616
657 617
658 #define PURPLE_IS_PROTOCOL_PLUGIN(plugin) \ 618 #define PURPLE_IS_PROTOCOL_PLUGIN(plugin) \
659 ((plugin)->info->type == PURPLE_PLUGIN_PROTOCOL) 619 ((plugin)->info->type == PURPLE_PLUGIN_PROTOCOL)
678 * without localization. 638 * without localization.
679 * @param name A localized string that the UI may display for the event. This 639 * @param name A localized string that the UI may display for the event. This
680 * should be the same string as @a ulname, with localization. 640 * should be the same string as @a ulname, with localization.
681 * @param inc_desc A localized description shown when the event is received. 641 * @param inc_desc A localized description shown when the event is received.
682 * @param out_desc A localized description shown when the event is sent. 642 * @param out_desc A localized description shown when the event is sent.
643 *
683 * @return A pointer to the new object. 644 * @return A pointer to the new object.
684 * @since 2.4.0
685 */ 645 */
686 PurpleAttentionType *purple_attention_type_new(const char *ulname, const char *name, 646 PurpleAttentionType *purple_attention_type_new(const char *ulname, const char *name,
687 const char *inc_desc, const char *out_desc); 647 const char *inc_desc, const char *out_desc);
688 648
689 /** 649 /**
691 * 651 *
692 * @param type The attention type. 652 * @param type The attention type.
693 * @param name The localized name that will be displayed by UIs. This should be 653 * @param name The localized name that will be displayed by UIs. This should be
694 * the same string given as the unlocalized name, but with 654 * the same string given as the unlocalized name, but with
695 * localization. 655 * localization.
696 * @since 2.4.0
697 */ 656 */
698 void purple_attention_type_set_name(PurpleAttentionType *type, const char *name); 657 void purple_attention_type_set_name(PurpleAttentionType *type, const char *name);
699 658
700 /** 659 /**
701 * Sets the description of the attention-demanding event shown in conversations 660 * Sets the description of the attention-demanding event shown in conversations
702 * when the event is received. 661 * when the event is received.
703 * 662 *
704 * @param type The attention type. 663 * @param type The attention type.
705 * @param desc The localized description for incoming events. 664 * @param desc The localized description for incoming events.
706 * @since 2.4.0
707 */ 665 */
708 void purple_attention_type_set_incoming_desc(PurpleAttentionType *type, const char *desc); 666 void purple_attention_type_set_incoming_desc(PurpleAttentionType *type, const char *desc);
709 667
710 /** 668 /**
711 * Sets the description of the attention-demanding event shown in conversations 669 * Sets the description of the attention-demanding event shown in conversations
712 * when the event is sent. 670 * when the event is sent.
713 * 671 *
714 * @param type The attention type. 672 * @param type The attention type.
715 * @param desc The localized description for outgoing events. 673 * @param desc The localized description for outgoing events.
716 * @since 2.4.0
717 */ 674 */
718 void purple_attention_type_set_outgoing_desc(PurpleAttentionType *type, const char *desc); 675 void purple_attention_type_set_outgoing_desc(PurpleAttentionType *type, const char *desc);
719 676
720 /** 677 /**
721 * Sets the name of the icon to display for the attention event; this is optional. 678 * Sets the name of the icon to display for the attention event; this is optional.
722 * 679 *
723 * @param type The attention type. 680 * @param type The attention type.
724 * @param name The icon's name. 681 * @param name The icon's name.
725 * @note Icons are optional for attention events. 682 * @note Icons are optional for attention events.
726 * @since 2.4.0
727 */ 683 */
728 void purple_attention_type_set_icon_name(PurpleAttentionType *type, const char *name); 684 void purple_attention_type_set_icon_name(PurpleAttentionType *type, const char *name);
729 685
730 /** 686 /**
731 * Sets the unlocalized name of the attention event; some UIs may need this, 687 * Sets the unlocalized name of the attention event; some UIs may need this,
732 * thus it is required. 688 * thus it is required.
733 * 689 *
734 * @param type The attention type. 690 * @param type The attention type.
735 * @param ulname The unlocalized name. This should be the same string given as 691 * @param ulname The unlocalized name. This should be the same string given as
736 * the localized name, but without localization. 692 * the localized name, but without localization.
737 * @since 2.4.0
738 */ 693 */
739 void purple_attention_type_set_unlocalized_name(PurpleAttentionType *type, const char *ulname); 694 void purple_attention_type_set_unlocalized_name(PurpleAttentionType *type, const char *ulname);
740 695
741 /** 696 /**
742 * Get the attention type's name as displayed by the UI. 697 * Get the attention type's name as displayed by the UI.
743 * 698 *
744 * @param type The attention type. 699 * @param type The attention type.
700 *
745 * @return The name. 701 * @return The name.
746 * @since 2.4.0
747 */ 702 */
748 const char *purple_attention_type_get_name(const PurpleAttentionType *type); 703 const char *purple_attention_type_get_name(const PurpleAttentionType *type);
749 704
750 /** 705 /**
751 * Get the attention type's description shown when the event is received. 706 * Get the attention type's description shown when the event is received.
752 * 707 *
753 * @param type The attention type. 708 * @param type The attention type.
754 * @return The description. 709 * @return The description.
755 * @since 2.4.0
756 */ 710 */
757 const char *purple_attention_type_get_incoming_desc(const PurpleAttentionType *type); 711 const char *purple_attention_type_get_incoming_desc(const PurpleAttentionType *type);
758 712
759 /** 713 /**
760 * Get the attention type's description shown when the event is sent. 714 * Get the attention type's description shown when the event is sent.
761 * 715 *
762 * @param type The attention type. 716 * @param type The attention type.
763 * @return The description. 717 * @return The description.
764 * @since 2.4.0
765 */ 718 */
766 const char *purple_attention_type_get_outgoing_desc(const PurpleAttentionType *type); 719 const char *purple_attention_type_get_outgoing_desc(const PurpleAttentionType *type);
767 720
768 /** 721 /**
769 * Get the attention type's icon name. 722 * Get the attention type's icon name.
770 * 723 *
771 * @param type The attention type. 724 * @param type The attention type.
772 * @return The icon name or @c NULL if unset/empty. 725 * @return The icon name or @c NULL if unset/empty.
773 * @note Icons are optional for attention events. 726 * @note Icons are optional for attention events.
774 * @since 2.4.0
775 */ 727 */
776 const char *purple_attention_type_get_icon_name(const PurpleAttentionType *type); 728 const char *purple_attention_type_get_icon_name(const PurpleAttentionType *type);
777 729
778 /** 730 /**
779 * Get the attention type's unlocalized name; this is useful for some UIs. 731 * Get the attention type's unlocalized name; this is useful for some UIs.
780 * 732 *
781 * @param type The attention type 733 * @param type The attention type
782 * @return The unlocalized name. 734 * @return The unlocalized name.
783 * @since 2.4.0
784 */ 735 */
785 const char *purple_attention_type_get_unlocalized_name(const PurpleAttentionType *type); 736 const char *purple_attention_type_get_unlocalized_name(const PurpleAttentionType *type);
786 737
787 /*@}*/ 738 /*@}*/
788 739
834 * This is meant to be called from protocol plugins. 785 * This is meant to be called from protocol plugins.
835 * 786 *
836 * @param account The account. 787 * @param account The account.
837 * 788 *
838 * @see account-actions-changed 789 * @see account-actions-changed
839 * @since 2.6.0
840 */ 790 */
841 void purple_prpl_got_account_actions(PurpleAccount *account); 791 void purple_prpl_got_account_actions(PurpleAccount *account);
842 792
843 /** 793 /**
844 * Notifies Purple that a buddy's idle state and time have changed. 794 * Notifies Purple that a buddy's idle state and time have changed.
925 * of the attention request command to send. 0 if prpl only defines one 875 * of the attention request command to send. 0 if prpl only defines one
926 * (for example, Yahoo and MSN), but some protocols define more (MySpaceIM). 876 * (for example, Yahoo and MSN), but some protocols define more (MySpaceIM).
927 * 877 *
928 * Note that you can't send arbitrary PurpleAttentionType's, because there is 878 * Note that you can't send arbitrary PurpleAttentionType's, because there is
929 * only a fixed set of attention commands. 879 * only a fixed set of attention commands.
930 *
931 * @since 2.5.0
932 */ 880 */
933 void purple_prpl_send_attention(PurpleConnection *gc, const char *who, guint type_code); 881 void purple_prpl_send_attention(PurpleConnection *gc, const char *who, guint type_code);
934 882
935 /** 883 /**
936 * Process an incoming attention message. 884 * Process an incoming attention message.
937 * 885 *
938 * @param gc The connection that received the attention message. 886 * @param gc The connection that received the attention message.
939 * @param who Who requested your attention. 887 * @param who Who requested your attention.
940 * @param type_code An index into the prpl's attention_types list determining the type 888 * @param type_code An index into the prpl's attention_types list determining the type
941 * of the attention request command to send. 889 * of the attention request command to send.
942 *
943 * @since 2.5.0
944 */ 890 */
945 void purple_prpl_got_attention(PurpleConnection *gc, const char *who, guint type_code); 891 void purple_prpl_got_attention(PurpleConnection *gc, const char *who, guint type_code);
946 892
947 /** 893 /**
948 * Process an incoming attention message in a chat. 894 * Process an incoming attention message in a chat.
950 * @param gc The connection that received the attention message. 896 * @param gc The connection that received the attention message.
951 * @param id The chat id. 897 * @param id The chat id.
952 * @param who Who requested your attention. 898 * @param who Who requested your attention.
953 * @param type_code An index into the prpl's attention_types list determining the type 899 * @param type_code An index into the prpl's attention_types list determining the type
954 * of the attention request command to send. 900 * of the attention request command to send.
955 *
956 * @since 2.5.0
957 */ 901 */
958 void purple_prpl_got_attention_in_chat(PurpleConnection *gc, int id, const char *who, guint type_code); 902 void purple_prpl_got_attention_in_chat(PurpleConnection *gc, int id, const char *who, guint type_code);
959 903
960 /** 904 /**
961 * Determines if the contact supports the given media session type. 905 * Determines if the contact supports the given media session type.
986 * 930 *
987 * This function is intended to be used only by prpls. 931 * This function is intended to be used only by prpls.
988 * 932 *
989 * @param account The account the user is on. 933 * @param account The account the user is on.
990 * @param who The name of the contact for which capabilities have been received. 934 * @param who The name of the contact for which capabilities have been received.
991 * @since 2.7.0
992 */ 935 */
993 void purple_prpl_got_media_caps(PurpleAccount *account, const char *who); 936 void purple_prpl_got_media_caps(PurpleAccount *account, const char *who);
994 937
995 /*@}*/ 938 /*@}*/
996 939