changeset 22352:03b2b21b4c42

* Don't flag outgoing oscar messages as "offline deliverable" if the message is an auto-reply. Fixes #4941. * Don't flag outgoing oscar messages as "offline deliverable" if the destination user is a cell phone or if we know that the destination user is currently online
author Mark Doliner <mark@kingant.net>
date Thu, 28 Feb 2008 08:15:27 +0000
parents 53873732f90a
children 50931b2113bf 51e740d3af3b
files libpurple/protocols/oscar/family_icbm.c libpurple/protocols/oscar/oscar.c
diffstat 2 files changed, 24 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/oscar/family_icbm.c	Thu Feb 28 01:42:51 2008 +0000
+++ b/libpurple/protocols/oscar/family_icbm.c	Thu Feb 28 08:15:27 2008 +0000
@@ -372,15 +372,18 @@
 	if (args->flags & AIM_IMFLAGS_AWAY) {
 		byte_stream_put16(&data, 0x0004);
 		byte_stream_put16(&data, 0x0000);
-	} else if (args->flags & AIM_IMFLAGS_ACK) {
-		/* Set the Request Acknowledge flag */
-		byte_stream_put16(&data, 0x0003);
-		byte_stream_put16(&data, 0x0000);
-	}
-
-	if (args->flags & AIM_IMFLAGS_OFFLINE) {
-		byte_stream_put16(&data, 0x0006);
-		byte_stream_put16(&data, 0x0000);
+	} else {
+		if (args->flags & AIM_IMFLAGS_ACK) {
+			/* Set the Request Acknowledge flag */
+			byte_stream_put16(&data, 0x0003);
+			byte_stream_put16(&data, 0x0000);
+		}
+
+		if (args->flags & AIM_IMFLAGS_OFFLINE) {
+			/* Allow this message to be queued as an offline message */
+			byte_stream_put16(&data, 0x0006);
+			byte_stream_put16(&data, 0x0000);
+		}
 	}
 
 	/*
--- a/libpurple/protocols/oscar/oscar.c	Thu Feb 28 01:42:51 2008 +0000
+++ b/libpurple/protocols/oscar/oscar.c	Thu Feb 28 08:15:27 2008 +0000
@@ -4225,13 +4225,15 @@
 	PeerConnection *conn;
 	int ret;
 	char *tmp1, *tmp2;
-	gboolean is_html;
+	gboolean is_sms, is_html;
 
 	od = (OscarData *)gc->proto_data;
 	account = purple_connection_get_account(gc);
 	ret = 0;
 
-	if (od->icq && aim_snvalid_sms(name)) {
+	is_sms = aim_snvalid_sms(name);
+
+	if (od->icq && is_sms) {
 		/*
 		 * We're sending to a phone number and this is ICQ,
 		 * so send the message as an SMS using aim_icq_sendsms()
@@ -4257,6 +4259,7 @@
 		struct aim_sendimext_args args;
 		PurpleConversation *conv;
 		PurpleStoredImage *img;
+		PurpleBuddy *buddy;
 
 		conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, name, account);
 
@@ -4266,13 +4269,19 @@
 			                        "You must be Direct Connected to send IM Images."),
 			                        PURPLE_MESSAGE_ERROR, time(NULL));
 
+		buddy = purple_find_buddy(gc->account, name);
+
 		bi = g_hash_table_lookup(od->buddyinfo, purple_normalize(account, name));
 		if (!bi) {
 			bi = g_new0(struct buddyinfo, 1);
 			g_hash_table_insert(od->buddyinfo, g_strdup(purple_normalize(account, name)), bi);
 		}
 
-		args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES | AIM_IMFLAGS_OFFLINE;
+		args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES;
+
+		if (!is_sms && (!buddy || !PURPLE_BUDDY_IS_ONLINE(buddy)))
+			args.flags |= AIM_IMFLAGS_OFFLINE;
+
 		if (od->icq) {
 			/* We have to present different "features" (whose meaning
 			   is unclear and are merely a result of protocol inspection)
@@ -4281,7 +4290,6 @@
 			   encoded" (and instead, assumes them to be UTF-8).
 			   For more details, see SF issue 1179452.
 			*/
-			PurpleBuddy *buddy = purple_find_buddy(gc->account, name);
 			if (buddy && PURPLE_BUDDY_IS_ONLINE(buddy)) {
 				args.features = features_icq;
 				args.featureslen = sizeof(features_icq);