comparison mcabber/src/jabglue.c @ 693:e98abd3ce28c

Add /request command Usage: /request version|time [jid]
author Mikael Berthe <mikael@lilotux.net>
date Sat, 11 Feb 2006 15:18:45 +0100
parents 3c0a0a993de8
children c299035ccb9f
comparison
equal deleted inserted replaced
692:d3511f846d47 693:e98abd3ce28c
569 iqs_del(iqn->id); // XXX 569 iqs_del(iqn->id); // XXX
570 g_free(name_utf8); 570 g_free(name_utf8);
571 g_free(cleanjid); 571 g_free(cleanjid);
572 } 572 }
573 573
574 void jb_request_time(const char *fulljid) 574 void jb_request(const char *jid, enum iqreq_type reqtype)
575 { 575 {
576 request_time(fulljid); 576 GSList *resources;
577 GSList *roster_elt;
578
579 if (reqtype == iqreq_none) return;
580
581 if (strchr(jid, '/')) {
582 // This is a full JID
583 if (reqtype == iqreq_version) {
584 request_version(jid);
585 scr_LogPrint(LPRINT_NORMAL, "Sent version request to <%s>", jid);
586 } else if (reqtype == iqreq_time) {
587 request_time(jid);
588 scr_LogPrint(LPRINT_NORMAL, "Sent time request to <%s>", jid);
589 }
590 return;
591 }
592
593 // The resource has not been specified
594 roster_elt = roster_find(jid, jidsearch, ROSTER_TYPE_USER|ROSTER_TYPE_ROOM);
595 if (!roster_elt) {
596 scr_LogPrint(LPRINT_NORMAL, "User <%s> isn't in the roster.");
597 return;
598 }
599
600 // Send a request to each resource
601 resources = buddy_getresources(roster_elt->data);
602 for ( ; resources ; resources = g_slist_next(resources) ) {
603 gchar *fulljid;
604 fulljid = g_strdup_printf("%s/%s", jid, (char*)resources->data);
605 if (reqtype == iqreq_version) {
606 request_version(fulljid);
607 scr_LogPrint(LPRINT_NORMAL, "Sent version request to <%s>", fulljid);
608 } else if (reqtype == iqreq_time) {
609 request_time(fulljid);
610 scr_LogPrint(LPRINT_NORMAL, "Sent time request to <%s>", fulljid);
611 }
612 g_free(fulljid);
613 }
577 } 614 }
578 615
579 // Join a MUC room 616 // Join a MUC room
580 void jb_room_join(const char *room, const char *nickname) 617 void jb_room_join(const char *room, const char *nickname)
581 { 618 {