Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/jabglue.c @ 43:b8bd163be431
[/trunk] Changeset 59 by mikael
* Change display of message when there is a subject
* Some work on (un)subscription messages
author | mikael |
---|---|
date | Tue, 05 Apr 2005 20:11:04 +0000 |
parents | a7c699bd09e0 |
children | f22e1d120606 |
comparison
equal
deleted
inserted
replaced
42:82247685b14b | 43:b8bd163be431 |
---|---|
339 // Maybe we should remember the resource? | 339 // Maybe we should remember the resource? |
340 if (r) | 340 if (r) |
341 scr_LogPrint("There is an extra part in message (resource?): %s", r); | 341 scr_LogPrint("There is an extra part in message (resource?): %s", r); |
342 */ | 342 */ |
343 | 343 |
344 scr_LogPrint("Msg from <%s>, type=%s", jidtodisp(from), type); | 344 //scr_LogPrint("Msg from <%s>, type=%s", jidtodisp(from), type); |
345 scr_WriteIncomingMessage(jidtodisp(from), body); | 345 scr_WriteIncomingMessage(jidtodisp(from), body); |
346 } | 346 } |
347 | 347 |
348 void statehandler(jconn conn, int state) | 348 void statehandler(jconn conn, int state) |
349 { | 349 { |
411 p = xmlnode_get_data(x); if (p) body = p; | 411 p = xmlnode_get_data(x); if (p) body = p; |
412 | 412 |
413 if ((x = xmlnode_get_tag(packet->x, "subject")) != NULL) | 413 if ((x = xmlnode_get_tag(packet->x, "subject")) != NULL) |
414 if ((p = xmlnode_get_data(x)) != NULL) { | 414 if ((p = xmlnode_get_data(x)) != NULL) { |
415 char *tmp = malloc(strlen(body)+strlen(p)+3); | 415 char *tmp = malloc(strlen(body)+strlen(p)+3); |
416 strcpy(tmp, p); | 416 *tmp = '['; |
417 strcat(tmp, ": "); | 417 strcpy(tmp+1, p); |
418 strcat(tmp, "]\n"); | |
418 strcat(tmp, body); | 419 strcat(tmp, body); |
419 body = tmp; // XXX we should free it later... | 420 body = tmp; // XXX we should free it later... |
420 } | 421 } |
421 | 422 |
422 /* there can be multiple <x> tags. we're looking for one with | 423 /* there can be multiple <x> tags. we're looking for one with |
624 */ | 625 */ |
625 break; | 626 break; |
626 | 627 |
627 case JPACKET_S10N: | 628 case JPACKET_S10N: |
628 scr_LogPrint("Received subscription packet"); | 629 scr_LogPrint("Received subscription packet"); |
629 /* | 630 if (type) scr_LogPrint("Type=%s", type); |
630 isagent = find(jhook.agents.begin(), jhook.agents.end(), from) != jhook.agents.end(); | 631 |
631 | 632 if (!strcmp(type, "subscribe")) { |
632 if (type == "subscribe") { | 633 // if (!isagent) { |
633 if (!isagent) { | 634 scr_LogPrint("<%s> wants to subscribe " |
634 em.store(imauthorization(ic, imevent::incoming, | 635 "to your network presence updates", from); |
635 imauthorization::Request, _("The user wants to subscribe to your network presence updates"))); | 636 /*} else { |
636 | |
637 } else { | |
638 auto_ptr<char> cfrom(strdup(from.c_str())); | 637 auto_ptr<char> cfrom(strdup(from.c_str())); |
639 x = jutil_presnew(JPACKET__SUBSCRIBED, cfrom.get(), 0); | 638 x = jutil_presnew(JPACKET__SUBSCRIBED, cfrom.get(), 0); |
640 jab_send(jc, x); | 639 jab_send(jc, x); |
641 xmlnode_free(x); | 640 xmlnode_free(x); |
642 } | 641 }*/ |
643 | 642 } else if (!strcmp(type, "unsubscribe")) { |
644 } else if (type == "unsubscribe") { | 643 x = jutil_presnew(JPACKET__UNSUBSCRIBED, from, 0); |
645 auto_ptr<char> cfrom(strdup(from.c_str())); | |
646 x = jutil_presnew(JPACKET__UNSUBSCRIBED, cfrom.get(), 0); | |
647 jab_send(jc, x); | 644 jab_send(jc, x); |
648 xmlnode_free(x); | 645 xmlnode_free(x); |
649 em.store(imnotification(ic, _("The user has removed you from his contact list (unsubscribed you, using the Jabber language)"))); | 646 scr_LogPrint("<%s> has unsubscribed to your presence updates", from); |
650 | |
651 } | 647 } |
652 */ | |
653 | |
654 break; | 648 break; |
655 | 649 |
656 default: | 650 default: |
657 break; | 651 break; |
658 } | 652 } |