Bug 63425

Summary: resource identifiers truncated from Jabber "to" addresses
Product: [Unmaintained] kopete Reporter: Peter Saint-Andre <stpeter>
Component: Jabber PluginAssignee: Kopete Developers <kopete-bugs-null>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Peter Saint-Andre 2003-08-29 18:15:44 UTC
Version:           0.71 (using KDE KDE 3.1.1)
Installed from:    SuSE RPMs
Compiler:          gcc 3 
OS:          Linux

Kopete removes the Jabber "resource identifier" from to addresses (or at least some to addresses). So for example, if a user attempts to send <message to="jabber.org/echo"><body>test</body></message>, what Kopete actually sends over the wire is <message to="jabber.org"><body>test</body></message>. I've just tested this with a Kopete user and he provided me with ethereal output. I've experienced this bug first-hand because I'm one of the jabber.org server admins, and I receive all messages send to="jabber.org"! :-) GAIM had a similar bug (#703765 -- see <http://sourceforge.net/tracker/index.php?func=detail&aid=703765&group_id=235&atid=100235>)
Comment 1 Till Gerken 2003-08-30 12:04:07 UTC
Hm, this is odd. Actually, when "best resource" is selected (see context menu 
of the Jabber contact -> select resource), Kopete will not touch the resource 
part of the address. I will look into it.
Comment 2 Stefan Vogel 2003-09-08 10:39:10 UTC
I am the kopete user, who triggered this behavior. I did create a new contact 
"jabber.org/echo". I can see this string also in the display. Then I tried to send a message to 
this contact. For this contact, the resource context menu is not available, probably because 
this contact is marked as offline. 
Comment 3 robertgogolok 2003-09-08 12:54:29 UTC
The server removes your subscription, so it won't show you a context menu, 
right. 
Sending a raw packet to the server works of course: 
kopete: [dlgJabberSendRaw] Sending RAW message 
kopete: [void JabberAccount::slotPsiDebug(const QString&)] Psi: Client: 
outgoing: [ 
<message to='amessage.de/echo' from='gogo@amessage.de/Kopete - desktop - 
FreeBSD'> 
<body>Body text</body> 
</message>] 
kopete: 
kopete: [void JabberAccount::slotPsiDebug(const QString&)] Psi: Client: 
incoming: [ 
<message from="amessage.de/echo" to="gogo@amessage.de/Kopete - desktop - 
FreeBSD" > 
<body>Body text</body> 
</message> 
] 
Comment 4 jstuart 2004-02-17 04:41:03 UTC
Does this bug still occur in 0.8.0?
Comment 5 Till Gerken 2004-03-10 14:18:26 UTC
CVS commit by gerken: 

Make a contact instance honour a default resource being supplied to it upon
creation.

For those listed in the bug report: Peter, I don't know if it makes sense to
only subscribe to a certain resource of a contact? Is that actually allowed?
The Jabber protocol does not forbid it, nor does it allow it. Right now, the
code will allow you to "subscribe" to a resource by adding this specific
resource to the contact list, but it will always stay offline.

At least Psi also adds a normal contact of the form <user@domain> to the
list, which all reply messages will then originate from. Any input is
greatly appreciated.
CCMAIL: 63425@bugs.kde.org


  M +9 -7      jabbercontact.cpp   1.165
  M +6 -1      jabbercontact.h   1.91


--- kdenetwork/kopete/protocols/jabber/jabbercontact.cpp  #1.164:1.165
@@ -53,4 +53,5 @@ JabberContact::JabberContact (QString us
                                 : KopeteContact (p, userId.lower(), mc)
 {
+        XMPP::Jid jid(userId);
 
         parentMetaContact = mc;
@@ -60,10 +61,11 @@ JabberContact::JabberContact (QString us
         messageManager = 0L;
 
-        rosterItem.setJid (XMPP::Jid (userId));
+        rosterItem.setJid (jid);
         rosterItem.setName (nickname);
         rosterItem.setGroups (groups);
 
         // create a default (empty) resource for the contact
-        JabberResource *defaultResource = new JabberResource (QString::null, -1, QDateTime::currentDateTime (),
+        defaultResource = new JabberResource (jid.resource(), -1,
+                                              QDateTime::currentDateTime (),
                                                                                                                   static_cast<JabberProtocol *>(protocol())->JabberKOSOffline, "");
 
@@ -195,7 +197,7 @@ QPtrList<KAction> *JabberContact::custom
 
                 // put best resource first
-                items.append (i18n ("Automatic (best resource)"));
+                items.append (i18n ("Automatic (best/default resource)"));
 
-                if (!tmpBestResource->resource ().isNull ())
+                if (tmpBestResource != defaultResource)
                         items.append (tmpBestResource->resource ());
 
@@ -205,6 +207,6 @@ QPtrList<KAction> *JabberContact::custom
                 for (JabberResource * tmpResource = resources.first (); tmpResource; tmpResource = resources.next (), i++)
                 {
-                        // skip the default (empty) resource
-                        if (tmpResource->resource ().isNull ())
+                        // skip the default resource
+                        if (tmpResource == defaultResource)
                         {
                                 i--;

--- kdenetwork/kopete/protocols/jabber/jabbercontact.h  #1.90:1.91
@@ -221,4 +221,9 @@ private:
 
         /**
+         * Default resource for this contact (usually empty)
+         */
+        JabberResource *defaultResource;
+
+        /**
          * This will simply cache all
          * relevant data for this contact.


Comment 6 Peter Saint-Andre 2004-03-10 17:08:11 UTC
The protocol allows you to subscribe to the presence of a
<user@host/resource> rather than <user@host>, although this
is not encouraged because most of the time the user wants to 
subscribe to the presence of another user no matter which client
or device (resource) the other person uses. So it is allowed but 
you may want to hide that functionality from the user.

Peter

Comment 7 Till Gerken 2004-03-16 02:21:36 UTC
CVS commit by gerken: 

Major rewrite of the Jabber plugin's core. The original cause was that the
Jabber plugin did not correctly deal with resources and did not follow
Jabber's protocol recommendations. This changes fixes that and more.

- Instead of a simple dictionary based lookup per contact, a global resource
  pool is now being used, featuring query facilities etc.
- The contact handling has been moved to a pool-like concept similar to the
  resource handling, again with query facilities and so on.
- The protocol has been ported to use KopeteAwayActions
- JabberAwayDialog is gone
- The infamous JabberMessageManager is back. It now sends the first message
  to no resource (unless a preselected default exists due to contact list
  subscription or user's demand). When the first message is received, it
  will lock itself to that message's originating resource. Messages from
  other resources will cause a new window to be opened.
- The protocol has been overhauled so that there is now a clear distinction
  between user defined actions (causing packets to be sent out) and Kopete
  reacting to other clients (actions pushed from the server). This was a
  total mess before.
- Countless other fixes.
- Groupchat has been disabled for the time being because it doesn't work and
  is too alpha. A rewrite is on my todo list.
CCMAIL: kopete-devel@kde.org, 63425-done@bugs.kde.org, 64366-done@bugs.kde.org, 69683-done@bugs.kde.org


  M +11 -1     Makefile.am   1.39
  M +5 -23     TODO   1.84
  M +371 -512  jabberaccount.cpp   1.91
  M +67 -68    jabberaccount.h   1.37
  M +3 -2      jabberawaydialog.cpp   1.3
  M +312 -478  jabbercontact.cpp   1.167
  M +42 -111   jabbercontact.h   1.93
  M +236 -0    jabbercontactpool.cpp   1.2
  M +117 -0    jabbercontactpool.h   1.2
  M +161 -0    jabbermessagemanager.cpp   1.2
  M +86 -0     jabbermessagemanager.h   1.2
  M +8 -8      jabberprotocol.cpp   1.207
  M +1 -1      jabberprotocol.h   1.97
  M +17 -31    jabberresource.cpp   1.12
  M +15 -20    jabberresource.h   1.9
  M +312 -0    jabberresourcepool.cpp   1.2
  M +115 -0    jabberresourcepool.h   1.2
  M +1 -1      ui/dlgjabberbrowse.cpp   1.15
  M +220 -167  ui/dlgjabbereditaccountwidget.ui   1.26
  M +1 -2      ui/dlgjabberregister.cpp   1.18
  M +2 -2      ui/dlgjabbervcard.cpp   1.26
  M +46 -7     ui/jabberaddcontactpage.cpp   1.20
  M +1 -4      ui/jabberaddcontactpage.h   1.11
  M +3 -1      ui/jabbereditaccountwidget.cpp   1.36