gaim/gaim

Parents a2c275079ba4
Children 01c97bed6258
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.
--- a/plugins/ChangeLog.API Thu Mar 17 11:02:51 2005 -0500
+++ b/plugins/ChangeLog.API Thu Mar 17 12:15:50 2005 -0500
@@ -14,6 +14,10 @@
(Christopher O'Brien)
* Added: GAIM_CBFLAGS_TYPING to GaimConvChatBuddyFlags
(Christopher O'Brien)
+ * Added: gaim_account_request_add which takes the same arguments as
+ * gaim_account_notify_added but always asks the user if they want to add
+ * the buddy to the buddy list
+ * Added: An accompanying request_add GaimAccountUiOp
version 1.1.4 (2/24/2005):
* No changes
--- a/src/account.c Thu Mar 17 11:02:51 2005 -0500
+++ b/src/account.c Thu Mar 17 12:15:50 2005 -0500
@@ -262,6 +262,22 @@
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)
{
--- a/src/account.h Thu Mar 17 11:02:51 2005 -0500
+++ b/src/account.h Thu Mar 17 12:15:50 2005 -0500
@@ -44,6 +44,9 @@
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 @@
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.
--- a/src/gtkaccount.c Thu Mar 17 11:02:51 2005 -0500
+++ b/src/gtkaccount.c Thu Mar 17 12:15:50 2005 -0500
@@ -2509,6 +2509,28 @@
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 @@
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 @@
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 *
--- a/src/protocols/jabber/presence.c Thu Mar 17 11:02:51 2005 -0500
+++ b/src/protocols/jabber/presence.c Thu Mar 17 12:15:50 2005 -0500
@@ -156,6 +156,7 @@
}
struct _jabber_add_permit {
+ JabberStream *js;
GaimConnection *gc;
char *who;
};
@@ -163,11 +164,22 @@
static void authorize_add_cb(struct _jabber_add_permit *jap)
{
if(g_list_find(gaim_connections_get_all(), jap->gc)) {
+ GaimBuddy *buddy = NULL;
jabber_presence_subscription_set(jap->gc->proto_data, jap->who,
"subscribed");
- if(!gaim_find_buddy(jap->gc->account, jap->who))
- gaim_account_notify_added(jap->gc->account, NULL, jap->who, NULL, NULL);
+ buddy = gaim_find_buddy(jap->gc->account, jap->who);
+
+ if (buddy) {
+ JabberBuddy *jb = NULL;
+
+ jb = jabber_buddy_find(jap->js, jap->who, TRUE);
+
+ if ((jb->subscription & JABBER_SUB_TO) == 0)
+ gaim_account_request_add(jap->gc->account, NULL, jap->who, NULL, NULL);
+ else
+ gaim_account_notify_added(jap->gc->account, NULL, jap->who, NULL, NULL);
+ }
}
g_free(jap->who);
@@ -242,6 +254,7 @@
char *msg = g_strdup_printf(_("The user %s wants to add you to their buddy list."), from);
jap->gc = js->gc;
jap->who = g_strdup(from);
+ jap->js = js;
gaim_request_action(js->gc, NULL, msg, NULL, GAIM_DEFAULT_ACTION_NONE,
jap, 2,