comparison src/protocols/zephyr/zephyr.c @ 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 3196d9044a45
children a4498ce61bf6
comparison
equal deleted inserted replaced
4587:5040b5ea12e9 4588:2778ebd04b63
385 serv_got_joined_chat(zgc, zt2->id, zt2->name); 385 serv_got_joined_chat(zgc, zt2->id, zt2->name);
386 } 386 }
387 /* If the person is in the default Realm, then strip the 387 /* If the person is in the default Realm, then strip the
388 Realm from the sender field */ 388 Realm from the sender field */
389 sendertmp = g_strdup_printf("%s",notice.z_sender); 389 sendertmp = g_strdup_printf("%s",notice.z_sender);
390 realmptr = strchr(sendertmp,'@'); 390 if (realmptr = strchr(sendertmp,'@')) {
391 realmptr++; 391 realmptr++;
392 if (!g_strcasecmp(realmptr,ZGetRealm())) { 392 if (!g_strcasecmp(realmptr,ZGetRealm())) {
393 realmptr--; 393 realmptr--;
394 sprintf(realmptr,"%c",'\0'); 394 sprintf(realmptr,"%c",'\0');
395 send_inst = g_strdup_printf("%s %s",sendertmp, 395 send_inst = g_strdup_printf("%s %s",sendertmp,
396 notice.z_class_inst); 396 notice.z_class_inst);
397 397 } else {
398 send_inst = g_strdup_printf("%s %s",notice.z_sender,
399 notice.z_class_inst);
400 }
398 } else { 401 } else {
399 send_inst = g_strdup_printf("%s %s",notice.z_sender, 402 send_inst = g_strdup_printf("%s %s",sendertmp,notice.z_class_inst);
400 notice.z_class_inst);
401 } 403 }
402 serv_got_chat_in(zgc, zt2->id, send_inst, FALSE, 404 serv_got_chat_in(zgc, zt2->id, send_inst, FALSE,
403 buf2, time(NULL)); 405 buf2, time(NULL));
404 g_free(sendertmp); 406 g_free(sendertmp);
405 g_free(send_inst); 407 g_free(send_inst);
510 while (fgets(buff, BUFSIZ, f)) { 512 while (fgets(buff, BUFSIZ, f)) {
511 strip_comments(buff); 513 strip_comments(buff);
512 if (buff[0]) { 514 if (buff[0]) {
513 triple = g_strsplit(buff, ",", 3); 515 triple = g_strsplit(buff, ",", 3);
514 if (triple[0] && triple[1] ) { 516 if (triple[0] && triple[1] ) {
515 char *tmp = g_strdup_printf("%s@%s", g_getenv("USER"), 517 /* char *tmp = g_strdup_printf("%s@%s", g_getenv("USER"),
516 ZGetRealm()); 518 ZGetRealm());*/
519 char *tmp = g_strdup_printf("%s",ZGetSender());
517 char *atptr; 520 char *atptr;
518 sub.zsub_class = triple[0]; 521 sub.zsub_class = triple[0];
519 sub.zsub_classinst = triple[1]; 522 sub.zsub_classinst = triple[1];
520 if(triple[2] == NULL) { 523 if(triple[2] == NULL) {
521 recip = g_malloc0(1); 524 recip = g_malloc0(1);
522 } else if (!g_strcasecmp(triple[2], "%me%")) { 525 } else if (!g_strcasecmp(triple[2], "%me%")) {
523 recip = g_strdup_printf("%s@%s", g_getenv("USER"), 526 recip = g_strdup_printf("%s",ZGetSender());
524 ZGetRealm());
525 } else if (!g_strcasecmp(triple[2], "*")) { 527 } else if (!g_strcasecmp(triple[2], "*")) {
526 /* wildcard 528 /* wildcard
527 * form of class,instance,* */ 529 * form of class,instance,* */
528 recip = g_malloc0(1); 530 recip = g_malloc0(1);
529 } else if (!g_strcasecmp(triple[2], tmp)) { 531 } else if (!g_strcasecmp(triple[2], tmp)) {
584 { 586 {
585 ZSubscription_t sub; 587 ZSubscription_t sub;
586 588
587 if (zgc) { 589 if (zgc) {
588 do_error_dialog("Already logged in with Zephyr", "Because Zephyr uses your system username, you are unable to " 590 do_error_dialog("Already logged in with Zephyr", "Because Zephyr uses your system username, you are unable to "
589 "have multiple accounts on it when logged in as the same user.", GAIM_ERROR); 591 "have multiple accounts on it when logged in as the same user.", GAIM_ERROR);
590 return; 592 return;
591 } 593 }
592 594
593 zgc = new_gaim_conn(account); 595 zgc = new_gaim_conn(account);
594 596
902 904
903 classname = data->data; 905 classname = data->data;
904 instname = data->next->data; 906 instname = data->next->data;
905 recip = data->next->next->data; 907 recip = data->next->next->data;
906 if (!g_strcasecmp(recip, "%me%")) 908 if (!g_strcasecmp(recip, "%me%"))
907 recip = g_getenv("USER"); 909 recip = ZGetSender();
908 910
909 zt1 = new_triple(classname, instname, recip); 911 zt1 = new_triple(classname, instname, recip);
910 zt2 = find_sub_by_triple(zt1); 912 zt2 = find_sub_by_triple(zt1);
911 if (zt2) { 913 if (zt2) {
912 free_triple(zt1); 914 free_triple(zt1);