From: Etan R. <de...@us...> - 2005-03-17 17:16:02
|
Update of /cvsroot/gaim/gaim/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1121/src Modified Files: Tag: oldstatus account.c account.h gtkaccount.c Log Message: Ok, so after messing this up a couple different ways I found a way to fix this that doesn't break us going to 1.2.0. This is suboptimal, but it's a start. I'll clean up the rest for 2.0.0. Index: account.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/account.c,v retrieving revision 1.96.2.8 retrieving revision 1.96.2.9 diff -u -d -p -r1.96.2.8 -r1.96.2.9 --- account.c 17 Mar 2005 05:17:03 -0000 1.96.2.8 +++ account.c 17 Mar 2005 17:15:37 -0000 1.96.2.9 @@ -262,6 +262,22 @@ gaim_account_notify_added(GaimAccount *a ui_ops->notify_added(account, remote_user, id, alias, message); } +void +gaim_account_request_add(GaimAccount *account, const char *id, + const char *remote_user, const char *alias, + const char *message) +{ + GaimAccountUiOps *ui_ops; + + g_return_if_fail(account != NULL); + g_return_if_fail(remote_user != NULL); + + ui_ops = gaim_accounts_get_ui_ops(); + + if (ui_ops != NULL && ui_ops->notify_added != NULL) + ui_ops->request_add(account, remote_user, id, alias, message); +} + static void change_password_cb(GaimAccount *account, GaimRequestFields *fields) { Index: account.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/account.h,v retrieving revision 1.50.2.2 retrieving revision 1.50.2.3 diff -u -d -p -r1.50.2.2 -r1.50.2.3 --- account.h 17 Mar 2005 05:17:03 -0000 1.50.2.2 +++ account.h 17 Mar 2005 17:15:39 -0000 1.50.2.3 @@ -44,6 +44,9 @@ struct _GaimAccountUiOps void (*notify_added)(GaimAccount *account, const char *remote_user, const char *id, const char *alias, const char *message); + void (*request_add)(GaimAccount *account, const char *remote_user, + const char *id, const char *alias, + const char *message); }; struct _GaimAccount @@ -145,6 +148,25 @@ void gaim_account_notify_added(GaimAccou const char *message); /** + * Notifies the user that the account was added to a remote user's + * buddy list and asks the user if they want to add the remote user to their + * buddy list. + * + * This will present a dialog informing the local user that the remote user + * added them to the remote users buddy list and will ask if they want to add + * the remote user to the local buddy list. + * + * @param account The account that was added. + * @param remote_user The name of the user that added this account. + * @param id The optional ID of the local account. Rarely used. + * @param alias The optional alias of the user. + * @param message The optional message sent from the user adding you. + */ +void gaim_account_request_add(GaimAccount *account, const char *remote_user, + const char *id, const char *alias, + const char *message); + +/** * Requests information from the user to change the account's password. * * @param account The account to change the password on. Index: gtkaccount.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/gtkaccount.c,v retrieving revision 1.147.2.8 retrieving revision 1.147.2.9 diff -u -d -p -r1.147.2.8 -r1.147.2.9 --- gtkaccount.c 17 Mar 2005 05:17:03 -0000 1.147.2.8 +++ gtkaccount.c 17 Mar 2005 17:15:39 -0000 1.147.2.9 @@ -2509,6 +2509,28 @@ add_user_cb(GaimGtkAccountAddUserData *d free_add_user_data(data); } +static char * +make_info(GaimAccount *account, GaimConnection *gc, GaimBuddy *buddy, + const char *remote_user, const char *id, const char *alias, + const char *msg) +{ + return g_strdup_printf(_("%s%s%s%s has made %s his or her buddy%s%s%s"), + remote_user, + (alias != NULL ? " (" : ""), + (alias != NULL ? alias : ""), + (alias != NULL ? ")" : ""), + (id != NULL + ? id + : (gaim_connection_get_display_name(gc) != NULL + ? gaim_connection_get_display_name(gc) + : gaim_account_get_username(account))), + (msg != NULL ? ": " : "."), + (msg != NULL ? msg : ""), + (buddy != NULL + ? "" + : _("\n\nDo you wish to add him or her to your buddy list?"))); +} + static void gaim_gtk_accounts_notify_added(GaimAccount *account, const char *remote_user, const char *id, const char *alias, @@ -2528,21 +2550,7 @@ gaim_gtk_accounts_notify_added(GaimAccou data->username = g_strdup(remote_user); data->alias = (alias != NULL ? g_strdup(alias) : NULL); - buffer = g_strdup_printf(_("%s%s%s%s has made %s his or her buddy%s%s%s"), - remote_user, - (alias != NULL ? " (" : ""), - (alias != NULL ? alias : ""), - (alias != NULL ? ")" : ""), - (id != NULL - ? id - : (gaim_connection_get_display_name(gc) != NULL - ? gaim_connection_get_display_name(gc) - : gaim_account_get_username(account))), - (msg != NULL ? ": " : "."), - (msg != NULL ? msg : ""), - (buddy != NULL - ? "" - : _("\n\nDo you wish to add him or her to your buddy list?"))); + buffer = make_info(account, gc, buddy, remote_user, id, alias, msg); if (buddy != NULL) { @@ -2559,9 +2567,40 @@ gaim_gtk_accounts_notify_added(GaimAccou g_free(buffer); } +static void +gaim_gtk_accounts_request_add(GaimAccount *account, const char *remote_user, + const char *id, const char *alias, + const char *msg) +{ + char *buffer; + GaimConnection *gc; + GaimGtkAccountAddUserData *data; + GaimBuddy *buddy; + + gc = gaim_account_get_connection(account); + + buddy = gaim_find_buddy(account, remote_user); + + data = g_new0(GaimGtkAccountAddUserData, 1); + data->account = account; + data->username = g_strdup(remote_user); + data->alias = (alias != NULL ? g_strdup(alias) : NULL); + + buffer = make_info(account, gc, buddy, remote_user, id, alias, msg); + + gaim_request_action(NULL, NULL, _("Add buddy to your list?"), + buffer, GAIM_DEFAULT_ACTION_NONE, data, 2, + _("Add"), G_CALLBACK(add_user_cb), + _("Cancel"), G_CALLBACK(free_add_user_data)); + + g_free(buffer); +} + + static GaimAccountUiOps ui_ops = { - gaim_gtk_accounts_notify_added + gaim_gtk_accounts_notify_added, + gaim_gtk_accounts_request_add }; GaimAccountUiOps * |