Mercurial > pidgin
changeset 31396:1bd617f2c46a
Add new functions for adding buddies with an invite message. If the
prpl implements this function, then it's preferred over the no-message
version.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Sun, 20 Mar 2011 00:02:55 +0000 |
parents | 3c0343e88c71 |
children | 7c33eaed54e5 |
files | ChangeLog.API libpurple/account.c libpurple/account.h libpurple/prpl.h |
diffstat | 4 files changed, 146 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog.API Sat Mar 19 23:47:36 2011 +0000 +++ b/ChangeLog.API Sun Mar 20 00:02:55 2011 +0000 @@ -5,11 +5,21 @@ Added: * account-authorization-requested-with-message signal (Stefan Ott) (#8690) + * purple_account_add_buddy_with_invite + * purple_account_add_buddies_with_invite * purple_notify_user_info_add_pair_plaintext * purple_media_get_active_local_candidates * purple_media_get_active_remote_candidates * purple_media_manager_get_video_caps (Jakub Adam) (#13095) * purple_media_manager_set_video_caps (Jakub Adam) (#13095) + * Added add_buddy_with_invite to PurplePluginProtocolInfo + * Added add_buddies_with_invite to PurplePluginProtocolInfo + + Deprecated: + * purple_account_add_buddy + * purple_account_add_buddies_with_invite + * add_buddy from PurplePluginProtocolInfo struct + * add_buddies from PurplePluginProtocolInfo struct Pidgin: Added:
--- a/libpurple/account.c Sat Mar 19 23:47:36 2011 +0000 +++ b/libpurple/account.c Sun Mar 20 00:02:55 2011 +0000 @@ -2540,8 +2540,37 @@ if (prpl != NULL) prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); - if (prpl_info != NULL && prpl_info->add_buddy != NULL) - prpl_info->add_buddy(gc, buddy, purple_buddy_get_group(buddy)); + if (prpl_info != NULL) { + if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, add_buddy_with_invite)) + prpl_info->add_buddy_with_invite(gc, buddy, purple_buddy_get_group(buddy), NULL); + else if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, add_buddy)) + prpl_info->add_buddy(gc, buddy, purple_buddy_get_group(buddy)); + } +} + +void +purple_account_add_buddy_with_invite(PurpleAccount *account, PurpleBuddy *buddy, const char *message) +{ + PurplePluginProtocolInfo *prpl_info = NULL; + PurpleConnection *gc; + PurplePlugin *prpl = NULL; + + g_return_if_fail(account != NULL); + g_return_if_fail(buddy != NULL); + + gc = purple_account_get_connection(account); + if (gc != NULL) + prpl = purple_connection_get_prpl(gc); + + if (prpl != NULL) + prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); + + if (prpl_info != NULL) { + if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, add_buddy_with_invite)) + prpl_info->add_buddy_with_invite(gc, buddy, purple_buddy_get_group(buddy), message); + else if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, add_buddy)) + prpl_info->add_buddy(gc, buddy, purple_buddy_get_group(buddy)); + } } void @@ -2566,9 +2595,69 @@ groups = g_list_append(groups, purple_buddy_get_group(buddy)); } - if (prpl_info->add_buddies != NULL) + if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, add_buddies_with_invite)) + prpl_info->add_buddies_with_invite(gc, buddies, groups, NULL); + else if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, add_buddies)) prpl_info->add_buddies(gc, buddies, groups); - else if (prpl_info->add_buddy != NULL) { + else if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, add_buddy_with_invite)) { + GList *curb = buddies, *curg = groups; + + while ((curb != NULL) && (curg != NULL)) { + prpl_info->add_buddy_with_invite(gc, curb->data, curg->data, NULL); + curb = curb->next; + curg = curg->next; + } + } + else if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, add_buddy)) { + GList *curb = buddies, *curg = groups; + + while ((curb != NULL) && (curg != NULL)) { + prpl_info->add_buddy(gc, curb->data, curg->data); + curb = curb->next; + curg = curg->next; + } + } + + g_list_free(groups); + } +} + +void +purple_account_add_buddies_with_invite(PurpleAccount *account, GList *buddies, const char *message) +{ + PurplePluginProtocolInfo *prpl_info = NULL; + PurpleConnection *gc = purple_account_get_connection(account); + PurplePlugin *prpl = NULL; + + if (gc != NULL) + prpl = purple_connection_get_prpl(gc); + + if (prpl != NULL) + prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); + + if (prpl_info) { + GList *cur, *groups = NULL; + + /* Make a list of what group each buddy is in */ + for (cur = buddies; cur != NULL; cur = cur->next) { + PurpleBuddy *buddy = cur->data; + groups = g_list_append(groups, purple_buddy_get_group(buddy)); + } + + if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, add_buddies_with_invite)) + prpl_info->add_buddies_with_invite(gc, buddies, groups, message); + else if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, add_buddy_with_invite)) { + GList *curb = buddies, *curg = groups; + + while ((curb != NULL) && (curg != NULL)) { + prpl_info->add_buddy_with_invite(gc, curb->data, curg->data, message); + curb = curb->next; + curg = curg->next; + } + } + else if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, add_buddies)) + prpl_info->add_buddies(gc, buddies, groups); + else if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, add_buddy)) { GList *curb = buddies, *curg = groups; while ((curb != NULL) && (curg != NULL)) {
--- a/libpurple/account.h Sat Mar 19 23:47:36 2011 +0000 +++ b/libpurple/account.h Sun Mar 20 00:02:55 2011 +0000 @@ -958,15 +958,40 @@ * * @param account The account. * @param buddy The buddy to add. + * + * @deprecated Use purple_account_add_buddy_with_invite and \c NULL message. */ void purple_account_add_buddy(PurpleAccount *account, PurpleBuddy *buddy); /** + * Adds a buddy to the server-side buddy list for the specified account. + * + * @param account The account. + * @param buddy The buddy to add. + * @param message The invite message. This may be ignored by a prpl. + * + * @since 2.8.0 + */ +void purple_account_add_buddy_with_invite(PurpleAccount *account, PurpleBuddy *buddy, const char *message); + +/** * Adds a list of buddies to the server-side buddy list. * * @param account The account. * @param buddies The list of PurpleBlistNodes representing the buddies to add. + * + * @deprecated Use purple_account_add_buddies_with_invite and \c NULL message. */ void purple_account_add_buddies(PurpleAccount *account, GList *buddies); +/** + * Adds a list of buddies to the server-side buddy list. + * + * @param account The account. + * @param buddies The list of PurpleBlistNodes representing the buddies to add. + * @param message The invite message. This may be ignored by a prpl. + * + * @since 2.8.0 + */ +void purple_account_add_buddies_with_invite(PurpleAccount *account, GList *buddies, const char *message); /** * Removes a buddy from the server-side buddy list.
--- a/libpurple/prpl.h Sat Mar 19 23:47:36 2011 +0000 +++ b/libpurple/prpl.h Sun Mar 20 00:02:55 2011 +0000 @@ -333,6 +333,9 @@ * already in the specified group. If the protocol supports * authorization and the user is not already authorized to see the * status of \a buddy, \a add_buddy should request authorization. + * + * @deprecated Since 2.8.0, add_buddy_with_invite is preferred. + * @see add_buddy_with_invite */ void (*add_buddy)(PurpleConnection *, PurpleBuddy *buddy, PurpleGroup *group); void (*add_buddies)(PurpleConnection *, GList *buddies, GList *groups); @@ -622,6 +625,21 @@ void (*get_public_alias)(PurpleConnection *gc, PurpleGetPublicAliasSuccessCallback success_cb, PurpleGetPublicAliasFailureCallback failure_cb); + + /** + * Add a buddy to a group on the server. + * + * This PRPL function may be called in situations in which the buddy is + * already in the specified group. If the protocol supports + * authorization and the user is not already authorized to see the + * status of \a buddy, \a add_buddy should request authorization. + * + * If authorization is required, then use the supplied invite message. + * + * @since 2.8.0 + */ + void (*add_buddy_with_invite)(PurpleConnection *pc, PurpleBuddy *buddy, PurpleGroup *group, const char *message); + void (*add_buddies_with_invite)(PurpleConnection *pc, GList *buddies, GList *groups, const char *message); }; #define PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, member) \