diff libpurple/protocols/oscar/oscar.c @ 27728:b8d98bc09656

propagate from branch 'im.pidgin.pidgin' (head 45b8a011cd84e0e69d7ac5a6fb84f55cdb0809cb) to branch 'im.pidgin.pidgin.yaz' (head 13a41ae84ed6f01e6f56d570c07fd04f3b02e781)
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Tue, 02 Oct 2007 17:49:49 +0000
parents 13ab08434a50 2bb82b05d30a
children 73ef026191e7
line wrap: on
line diff
--- a/libpurple/protocols/oscar/oscar.c	Fri Sep 28 04:03:27 2007 +0000
+++ b/libpurple/protocols/oscar/oscar.c	Tue Oct 02 17:49:49 2007 +0000
@@ -2210,12 +2210,14 @@
 {
 	PurpleConnection *gc;
 	OscarData *od;
+	PurpleAccount *account;
 	PurpleBuddy *buddy;
 	PurpleGroup *group;
 
 	gc = data->gc;
 	od = gc->proto_data;
-	buddy = purple_find_buddy(purple_connection_get_account(gc), data->name);
+	account = purple_connection_get_account(gc);
+	buddy = purple_find_buddy(account, data->name);
 	if (buddy != NULL)
 		group = purple_buddy_get_group(buddy);
 	else
@@ -2227,7 +2229,19 @@
 				   buddy->name, group->name);
 		aim_ssi_sendauthrequest(od, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list."));
 		if (!aim_ssi_itemlist_finditem(od->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))
+		{
 			aim_ssi_addbuddy(od, buddy->name, group->name, NULL, purple_buddy_get_alias_only(buddy), NULL, NULL, TRUE);
+
+			/* Mobile users should always be online */
+			if (buddy->name[0] == '+') {
+				purple_prpl_got_user_status(account,
+						purple_buddy_get_name(buddy),
+						OSCAR_STATUS_ID_AVAILABLE, NULL);
+				purple_prpl_got_user_status(account,
+						purple_buddy_get_name(buddy),
+						OSCAR_STATUS_ID_MOBILE, NULL);
+			}
+		}
 	}
 }
 
@@ -4648,12 +4662,16 @@
 
 void
 oscar_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) {
-	OscarData *od = (OscarData *)gc->proto_data;
+	OscarData *od;
+	PurpleAccount *account;
+
+	od = (OscarData *)gc->proto_data;
+	account = purple_connection_get_account(gc);
 
 	if (!aim_snvalid(buddy->name)) {
 		gchar *buf;
 		buf = g_strdup_printf(_("Could not add the buddy %s because the screen name is invalid.  Screen names must be a valid email address, or start with a letter and contain only letters, numbers and spaces, or contain only numbers."), buddy->name);
-		if (!purple_conv_present_error(buddy->name, purple_connection_get_account(gc), buf))
+		if (!purple_conv_present_error(buddy->name, account, buf))
 			purple_notify_error(gc, NULL, _("Unable To Add"), buf);
 		g_free(buf);
 
@@ -4667,6 +4685,16 @@
 		purple_debug_info("oscar",
 				   "ssi: adding buddy %s to group %s\n", buddy->name, group->name);
 		aim_ssi_addbuddy(od, buddy->name, group->name, NULL, purple_buddy_get_alias_only(buddy), NULL, NULL, 0);
+
+		/* Mobile users should always be online */
+		if (buddy->name[0] == '+') {
+			purple_prpl_got_user_status(account,
+					purple_buddy_get_name(buddy),
+					OSCAR_STATUS_ID_AVAILABLE, NULL);
+			purple_prpl_got_user_status(account,
+					purple_buddy_get_name(buddy),
+					OSCAR_STATUS_ID_MOBILE, NULL);
+		}
 	}
 
 	/* XXX - Should this be done from AIM accounts, as well? */
@@ -4982,6 +5010,17 @@
 							g_free(comment);
 						}
 					}
+
+					/* Mobile users should always be online */
+					if (b->name[0] == '+') {
+						purple_prpl_got_user_status(account,
+								purple_buddy_get_name(b),
+								OSCAR_STATUS_ID_AVAILABLE, NULL);
+						purple_prpl_got_user_status(account,
+								purple_buddy_get_name(b),
+								OSCAR_STATUS_ID_MOBILE, NULL);
+					}
+
 					g_free(gname_utf8);
 					g_free(alias_utf8);
 				}
@@ -5172,6 +5211,17 @@
 		purple_debug_info("oscar",
 				   "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans"));
 		purple_blist_add_buddy(b, NULL, g, NULL);
+
+		/* Mobile users should always be online */
+		if (b->name[0] == '+') {
+			purple_prpl_got_user_status(account,
+					purple_buddy_get_name(b),
+					OSCAR_STATUS_ID_AVAILABLE, NULL);
+			purple_prpl_got_user_status(account,
+					purple_buddy_get_name(b),
+					OSCAR_STATUS_ID_MOBILE, NULL);
+		}
+
 	}
 
 	g_free(gname_utf8);