changeset 4588:2778ebd04b63

[gaim-migrate @ 4872] Arun A Tharuvai (aat) writes: "I've fixed the following problems which I ran into recently. When subscribing getenv("USER") is used instead of ZGetSender() , causing subscriptions of the form class,instance,%me% to fail where a person's Zephyr username is different from their local username. Also, it segfaults whenever receiving zephyrs from senders that have no realm field. e.g. people with usernames of the form username instead of username@realmname . " committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Tue, 18 Feb 2003 23:59:28 +0000
parents 5040b5ea12e9
children eddb870a3c4d
files src/protocols/zephyr/zephyr.c
diffstat 1 files changed, 18 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/zephyr/zephyr.c	Tue Feb 18 15:15:51 2003 +0000
+++ b/src/protocols/zephyr/zephyr.c	Tue Feb 18 23:59:28 2003 +0000
@@ -387,17 +387,19 @@
 					/* If the person is in the default Realm, then strip the 
 					   Realm from the sender field */
 					sendertmp = g_strdup_printf("%s",notice.z_sender);
-					realmptr = strchr(sendertmp,'@');
-					realmptr++;
-					if (!g_strcasecmp(realmptr,ZGetRealm())) {
-						realmptr--;
-						sprintf(realmptr,"%c",'\0');
-						send_inst = g_strdup_printf("%s %s",sendertmp,
-									    notice.z_class_inst);
-								     
+					if (realmptr = strchr(sendertmp,'@')) {
+						realmptr++;
+						if (!g_strcasecmp(realmptr,ZGetRealm())) {
+							realmptr--;
+							sprintf(realmptr,"%c",'\0');
+							send_inst = g_strdup_printf("%s %s",sendertmp,
+										    notice.z_class_inst);
+						} else {
+							send_inst = g_strdup_printf("%s %s",notice.z_sender,
+										    notice.z_class_inst);
+						}
 					} else {
-						send_inst = g_strdup_printf("%s %s",notice.z_sender,
-									    notice.z_class_inst);
+						send_inst = g_strdup_printf("%s %s",sendertmp,notice.z_class_inst);
 					}
 					serv_got_chat_in(zgc, zt2->id, send_inst, FALSE,
 								buf2, time(NULL));
@@ -512,16 +514,16 @@
 			if (buff[0]) {
 				triple = g_strsplit(buff, ",", 3);
 				if (triple[0] && triple[1] ) {
-					char *tmp = g_strdup_printf("%s@%s", g_getenv("USER"),
-								    ZGetRealm());
+					/*					char *tmp = g_strdup_printf("%s@%s", g_getenv("USER"), 
+										ZGetRealm());*/
+					char *tmp = g_strdup_printf("%s",ZGetSender());
 					char *atptr;
 					sub.zsub_class = triple[0];
 					sub.zsub_classinst = triple[1];
 					if(triple[2] == NULL) {
 						recip = g_malloc0(1);
 					} else if (!g_strcasecmp(triple[2], "%me%")) {
-						recip = g_strdup_printf("%s@%s", g_getenv("USER"),
-										ZGetRealm());
+						recip = g_strdup_printf("%s",ZGetSender());
 					} else if (!g_strcasecmp(triple[2], "*")) {
 						/* wildcard
 						 * form of class,instance,* */
@@ -586,7 +588,7 @@
 
 	if (zgc) {
 		do_error_dialog("Already logged in with Zephyr", "Because Zephyr uses your system username, you are unable to "
-                                "have multiple accounts on it when logged in as the same user.", GAIM_ERROR);
+				"have multiple accounts on it when logged in as the same user.", GAIM_ERROR);
 		return;
 	}
 
@@ -904,7 +906,7 @@
 	instname = data->next->data;
 	recip = data->next->next->data;
 	if (!g_strcasecmp(recip, "%me%"))
-		recip = g_getenv("USER");
+		recip = ZGetSender();
 
 	zt1 = new_triple(classname, instname, recip);
 	zt2 = find_sub_by_triple(zt1);