Mercurial > pidgin.yaz
changeset 31150:b3b7b537284f
msn: Merge dialog and error to get an unified msn_error api.
author | masca@cpw.pidgin.im |
---|---|
date | Fri, 12 Mar 2010 02:26:57 +0000 |
parents | 54c8aeecab4c |
children | f6b2412e4351 |
files | libpurple/protocols/msn/Makefile.am libpurple/protocols/msn/dialog.c libpurple/protocols/msn/dialog.h libpurple/protocols/msn/error.c libpurple/protocols/msn/error.h libpurple/protocols/msn/session.c |
diffstat | 6 files changed, 133 insertions(+), 183 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/msn/Makefile.am Thu Mar 11 17:59:53 2010 +0000 +++ b/libpurple/protocols/msn/Makefile.am Fri Mar 12 02:26:57 2010 +0000 @@ -12,8 +12,6 @@ command.h \ contact.c\ contact.h\ - dialog.c \ - dialog.h \ error.c \ error.h \ group.c \
--- a/libpurple/protocols/msn/dialog.c Thu Mar 11 17:59:53 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,148 +0,0 @@ -/** - * @file dialog.c Dialog functions - * - * purple - * - * Purple is the legal property of its developers, whose names are too numerous - * to list here. Please refer to the COPYRIGHT file distributed with this - * source distribution. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA - */ - -#include "msn.h" -#include "dialog.h" - -typedef struct -{ - PurpleConnection *gc; - char *who; - char *group; - gboolean add; - -} MsnAddRemData; - -/* Remove the buddy referenced by the MsnAddRemData before the serverside list - * is changed. If the buddy will be added, he'll be added back; if he will be - * removed, he won't be. */ -/* Actually with our MSNP14 code that isn't true yet, he won't be added back :( - * */ -static void -msn_complete_sync_issue(MsnAddRemData *data) -{ - PurpleBuddy *buddy; - PurpleGroup *group = NULL; - - if (data->group != NULL) - group = purple_find_group(data->group); - - if (group != NULL) - buddy = purple_find_buddy_in_group(purple_connection_get_account(data->gc), data->who, group); - else - buddy = purple_find_buddy(purple_connection_get_account(data->gc), data->who); - - if (buddy != NULL) - purple_blist_remove_buddy(buddy); -} - - -static void -msn_add_cb(MsnAddRemData *data) -{ -#if 0 - /* this *should* be necessary !! */ - msn_complete_sync_issue(data); -#endif - - if (g_list_find(purple_connections_get_all(), data->gc) != NULL) - { - MsnSession *session = data->gc->proto_data; - MsnUserList *userlist = session->userlist; - - msn_userlist_add_buddy(userlist, data->who, data->group); - } - - g_free(data->group); - g_free(data->who); - g_free(data); -} - -static void -msn_rem_cb(MsnAddRemData *data) -{ - msn_complete_sync_issue(data); - - if (g_list_find(purple_connections_get_all(), data->gc) != NULL) - { - MsnSession *session = data->gc->proto_data; - MsnUserList *userlist = session->userlist; - - if (data->group == NULL) { - msn_userlist_rem_buddy_from_list(userlist, data->who, MSN_LIST_FL); - } else { - g_free(data->group); - } - } - - g_free(data->who); - g_free(data); -} - -void -msn_show_sync_issue(MsnSession *session, const char *passport, - const char *group_name) -{ - PurpleConnection *gc; - PurpleAccount *account; - MsnAddRemData *data; - char *msg, *reason; - - account = session->account; - gc = purple_account_get_connection(account); - - data = g_new0(MsnAddRemData, 1); - data->who = g_strdup(passport); - data->group = g_strdup(group_name); - data->gc = gc; - - msg = g_strdup_printf(_("Buddy list synchronization issue in %s (%s)"), - purple_account_get_username(account), - purple_account_get_protocol_name(account)); - - if (group_name != NULL) - { - reason = g_strdup_printf(_("%s on the local list is " - "inside the group \"%s\" but not on " - "the server list. " - "Do you want this buddy to be added?"), - passport, group_name); - } - else - { - reason = g_strdup_printf(_("%s is on the local list but " - "not on the server list. " - "Do you want this buddy to be added?"), - passport); - } - - purple_request_action(gc, NULL, msg, reason, PURPLE_DEFAULT_ACTION_NONE, - purple_connection_get_account(gc), data->who, NULL, - data, 2, - _("Yes"), G_CALLBACK(msn_add_cb), - _("No"), G_CALLBACK(msn_rem_cb)); - - g_free(reason); - g_free(msg); -}
--- a/libpurple/protocols/msn/dialog.h Thu Mar 11 17:59:53 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -/** - * @file dialog.h Dialog functions - * - * purple - * - * Purple is the legal property of its developers, whose names are too numerous - * to list here. Please refer to the COPYRIGHT file distributed with this - * source distribution. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA - */ -#ifndef MSN_DIALOG_H -#define MSN_DIALOG_H - -void msn_show_sync_issue(MsnSession *session, const char *passport, - const char *group_name); - -#endif /* MSN_DIALOG_H */
--- a/libpurple/protocols/msn/error.c Thu Mar 11 17:59:53 2010 +0000 +++ b/libpurple/protocols/msn/error.c Fri Mar 12 02:26:57 2010 +0000 @@ -24,6 +24,15 @@ #include "msn.h" #include "error.h" +typedef struct +{ + PurpleConnection *gc; + char *who; + char *group; + gboolean add; + +} MsnAddRemData; + const char * msn_error_get_text(unsigned int type, gboolean *debug) { @@ -264,3 +273,115 @@ g_free(buf); } +/* Remove the buddy referenced by the MsnAddRemData before the serverside list + * is changed. If the buddy will be added, he'll be added back; if he will be + * removed, he won't be. */ +/* Actually with our MSNP14 code that isn't true yet, he won't be added back :( + * */ +static void +msn_complete_sync_issue(MsnAddRemData *data) +{ + PurpleBuddy *buddy; + PurpleGroup *group = NULL; + + if (data->group != NULL) + group = purple_find_group(data->group); + + if (group != NULL) + buddy = purple_find_buddy_in_group(purple_connection_get_account(data->gc), data->who, group); + else + buddy = purple_find_buddy(purple_connection_get_account(data->gc), data->who); + + if (buddy != NULL) + purple_blist_remove_buddy(buddy); +} + + +static void +msn_add_cb(MsnAddRemData *data) +{ +#if 0 + /* this *should* be necessary !! */ + msn_complete_sync_issue(data); +#endif + + if (g_list_find(purple_connections_get_all(), data->gc) != NULL) + { + MsnSession *session = data->gc->proto_data; + MsnUserList *userlist = session->userlist; + + msn_userlist_add_buddy(userlist, data->who, data->group); + } + + g_free(data->group); + g_free(data->who); + g_free(data); +} + +static void +msn_rem_cb(MsnAddRemData *data) +{ + msn_complete_sync_issue(data); + + if (g_list_find(purple_connections_get_all(), data->gc) != NULL) + { + MsnSession *session = data->gc->proto_data; + MsnUserList *userlist = session->userlist; + + if (data->group == NULL) { + msn_userlist_rem_buddy_from_list(userlist, data->who, MSN_LIST_FL); + } else { + g_free(data->group); + } + } + + g_free(data->who); + g_free(data); +} + +void +msn_error_sync_issue(MsnSession *session, const char *passport, + const char *group_name) +{ + PurpleConnection *gc; + PurpleAccount *account; + MsnAddRemData *data; + char *msg, *reason; + + account = session->account; + gc = purple_account_get_connection(account); + + data = g_new0(MsnAddRemData, 1); + data->who = g_strdup(passport); + data->group = g_strdup(group_name); + data->gc = gc; + + msg = g_strdup_printf(_("Buddy list synchronization issue in %s (%s)"), + purple_account_get_username(account), + purple_account_get_protocol_name(account)); + + if (group_name != NULL) + { + reason = g_strdup_printf(_("%s on the local list is " + "inside the group \"%s\" but not on " + "the server list. " + "Do you want this buddy to be added?"), + passport, group_name); + } + else + { + reason = g_strdup_printf(_("%s is on the local list but " + "not on the server list. " + "Do you want this buddy to be added?"), + passport); + } + + purple_request_action(gc, NULL, msg, reason, PURPLE_DEFAULT_ACTION_NONE, + purple_connection_get_account(gc), data->who, NULL, + data, 2, + _("Yes"), G_CALLBACK(msn_add_cb), + _("No"), G_CALLBACK(msn_rem_cb)); + + g_free(reason); + g_free(msg); +}
--- a/libpurple/protocols/msn/error.h Thu Mar 11 17:59:53 2010 +0000 +++ b/libpurple/protocols/msn/error.h Fri Mar 12 02:26:57 2010 +0000 @@ -44,4 +44,14 @@ */ void msn_error_handle(MsnSession *session, unsigned int type); +/** + * Show the sync issue in a dialog using request api + * + * @param sesion MsnSession associated to this error. + * @param passport The passport associated with the error. + * @param group_name The group in the buddy is suppoused to be + */ +void msn_error_sync_issue(MsnSession *session, const char *passport, + const char *group_name); + #endif /* MSN_ERROR_H */
--- a/libpurple/protocols/msn/session.c Thu Mar 11 17:59:53 2010 +0000 +++ b/libpurple/protocols/msn/session.c Fri Mar 12 02:26:57 2010 +0000 @@ -21,14 +21,13 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ +#include "error.h" #include "msn.h" #include "msnutils.h" #include "session.h" #include "notification.h" #include "oim.h" -#include "dialog.h" - MsnSession * msn_session_new(PurpleAccount *account) { @@ -301,7 +300,7 @@ if (!found) { if ((remote_user == NULL) || !(remote_user->list_op & MSN_LIST_FL_OP)) { /* The user is not on the server list */ - msn_show_sync_issue(session, buddy_name, group_name); + msn_error_sync_issue(session, buddy_name, group_name); } else { /* The user is not in that group on the server list */ to_remove = g_list_prepend(to_remove, buddy);