changeset 1722:b18142457ca9

Fix vCard requests in MUC rooms
author Mikael Berthe <mikael@lilotux.net>
date Sun, 28 Feb 2010 11:33:39 +0100
parents 8cfc2a386b1f
children 681fa0bbf388
files mcabber/mcabber/commands.c mcabber/mcabber/xmpp.c mcabber/mcabber/xmpp_muc.c
diffstat 3 files changed, 19 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/mcabber/commands.c	Sun Feb 28 10:20:13 2010 +0100
+++ b/mcabber/mcabber/commands.c	Sun Feb 28 11:33:39 2010 +0100
@@ -3227,7 +3227,7 @@
 static void do_request(char *arg)
 {
   char **paramlst;
-  char *fjid, *type, *tmp;
+  char *fjid, *type;
   enum iqreq_type numtype = iqreq_none;
   char *jid_utf8 = NULL;
 
@@ -3290,9 +3290,15 @@
   if (fjid) {
     switch (numtype) {
       case iqreq_vcard:
-          // vCards requests are done to bare jid
-          tmp = strchr(fjid, JID_RESOURCE_SEPARATOR);
-          if (tmp) *tmp = '\0';
+          { // vCards requests are sent to the bare jid, except in MUC rooms
+            gchar *tmp = strchr(fjid, JID_RESOURCE_SEPARATOR);
+            if (tmp) {
+              gchar *bjid = jidtodisp(fjid);
+              if (!roster_find(bjid, jidsearch, ROSTER_TYPE_ROOM))
+                *tmp = '\0';
+              g_free(bjid);
+            }
+          }
       case iqreq_version:
       case iqreq_time:
       case iqreq_last:
--- a/mcabber/mcabber/xmpp.c	Sun Feb 28 10:20:13 2010 +0100
+++ b/mcabber/mcabber/xmpp.c	Sun Feb 28 11:33:39 2010 +0100
@@ -235,6 +235,7 @@
   GSList *resources, *p_res;
   GSList *roster_elt;
   const char *strreqtype, *xmlns;
+  gboolean vcard2user;
 
   if (reqtype == iqreq_version) {
     xmlns = NS_VERSION;
@@ -254,9 +255,13 @@
   } else
     return;
 
-  if (strchr(fjid, JID_RESOURCE_SEPARATOR) || reqtype == iqreq_vcard) {
-    // This is a full JID
-    // Or a vCard request, resource should have been stripped before
+  // Is it a vCard request to a regular user?
+  // (vCard requests are sent to bare JIDs, except in MUC rooms...)
+  vcard2user = (reqtype == iqreq_vcard &&
+                !roster_find(fjid, jidsearch, ROSTER_TYPE_ROOM));
+
+  if (strchr(fjid, JID_RESOURCE_SEPARATOR) || vcard2user) {
+    // This is a full JID or a vCard request to a contact
     xmpp_iq_request(fjid, xmlns);
     scr_LogPrint(LPRINT_NORMAL, "Sent %s request to <%s>", strreqtype, fjid);
     return;
--- a/mcabber/mcabber/xmpp_muc.c	Sun Feb 28 10:20:13 2010 +0100
+++ b/mcabber/mcabber/xmpp_muc.c	Sun Feb 28 11:33:39 2010 +0100
@@ -672,7 +672,7 @@
     const char *id;
     char *desc = g_strdup_printf("<%s> invites you to %s", from, to);
     event_muc_invitation *invitation;
-    
+
     invitation = g_new(event_muc_invitation, 1);
     invitation->to = g_strdup(to);
     invitation->from = g_strdup(from);