Bug 63588 - Packets from foreign clients are duplicated
Summary: Packets from foreign clients are duplicated
Status: RESOLVED FIXED
Alias: None
Product: kopete
Classification: Applications
Component: Jabber Plugin (show other bugs)
Version: 0.7.1
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Till Gerken
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-09-01 19:59 UTC by Till Gerken
Modified: 2004-03-10 15:04 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Till Gerken 2003-09-01 19:59:20 UTC
Version:           0.7.1 (using KDE 3.1.9)
Compiler:          gcc version 3.3.2 20030812 (Debian prerelease)
OS:          Linux (i686) release 2.4.21-ck3

When being logged in with another client to the same Jabber account, renaming an account in the foreign client causes Kopete to send out the renaming request again.
Comment 1 Till Gerken 2003-09-01 20:02:20 UTC
Reassigning to self and adding Matthias Wimmer (amessage admin). 
 
Matthias: I discovered this when experimenting with renaming the AIM transport in Psi 
and Kopete while being logged in with both at the same time. Could it be that your 
users causing AIM to fail are logged in with two Kopete instances at the same time? 
 
This is very unlikely to happen on the same machine because Kopete only opens up 
once per session per default. However, it could be that they have a Kopete instance 
running remotely which "catches" a rename command and replies with the same 
command again - causing both clients to play ping-pong. 
Comment 2 Matt Rogers 2003-09-01 20:07:02 UTC
Trying to read Till's mind and set things up correctly. 
Comment 3 Martijn Klingens 2004-01-18 11:50:55 UTC
Till, I'm tempted to close this bug due to non-response for months. Any objections?

Martijn
Comment 4 Till Gerken 2004-01-18 12:15:35 UTC
Please keep it open, it's still valid (I submitted it myself). I am in Sweden right now and only have Internet access today for a few minutes, will get cut off again. I hope to be back and active by the second half of February.
Comment 5 Till Gerken 2004-03-10 15:04:12 UTC
CVS commit by gerken: 

Fix Kopete echoing packets on pushed roster changes from other clients. On
revisiting this issue, it could possibly have led to a packet storm if two
Kopete instances were logged in at the same time - seemingly similar to bug
#63508, except for that the flood could never be reproduced. (packets were
only sent out twice per Kopete instance, then everything settled)
CCMAIL: 63588-done@bugs.kde.org


  M +35 -12    jabbercontact.cpp   1.166
  M +3 -1      jabbercontact.h   1.92
  M +1 -1      ui/dlgjabbervcard.cpp   1.25


--- kdenetwork/kopete/protocols/jabber/jabbercontact.cpp  #1.165:1.166
@@ -80,7 +80,10 @@ JabberContact::JabberContact (QString us
         slotUpdatePresence (static_cast<JabberProtocol *>(protocol())->JabberKOSOffline, QString::null);
 
-        connect(this, SIGNAL(displayNameChanged(const QString &, const QString &)), this, SLOT(slotRenameContact(const QString &, const QString &)));
+        connect(this, SIGNAL(displayNameChanged(const QString &, const QString &)), this, SLOT(slotDisplayNameChanged(const QString &, const QString &)));
 
         actionSendAuth = 0L;
+
+        mIsNetworkPush = false;
+
 }
 
@@ -265,13 +268,23 @@ void JabberContact::slotUpdateContact (c
         // only update the nickname if its not empty
         if (!item.name ().isEmpty () && !item.name ().isNull ())
+        {
+                /*
+                 * The setDisplayName() call unfortunately emits displayNameChanged()
+                 * which is also used for local renames. This means that we have to
+                 * differentiate in slotDisplayNameChanged() if the rename was actually
+                 * due to a network push or a local action. mIsNetworkPush keeps
+                 * this information.
+                 */
+                mIsNetworkPush = true;
                 setDisplayName (item.name ());
+        }
 
 }
 
-void JabberContact::slotRenameContact (const QString &oldName, const QString &newName)
+void JabberContact::slotDisplayNameChanged (const QString &oldName, const QString &newName)
 {
-        QString name = newName;
+        kdDebug (JABBER_DEBUG_GLOBAL) << k_funcinfo << "Display name changed from " << oldName << " to " << newName << ", network push: " << mIsNetworkPush << endl;
 
-        kdDebug (JABBER_DEBUG_GLOBAL) << k_funcinfo << "Renaming contact " << oldName << " to " << newName << endl;
+        QString name = newName;
 
         // if the name has been deleted, revert
@@ -282,5 +295,11 @@ void JabberContact::slotRenameContact (c
         rosterItem.setName (name);
 
-        // send rename request to protocol backend
+        /*
+         * Only send a rename request if this is a local change
+         * See slotUpdateContact() for details.
+         */
+        if(!mIsNetworkPush)
+        {
+                // our display name has been changed, forward the change to the roster
         if (!account()->isConnected())
         {
@@ -293,4 +312,8 @@ void JabberContact::slotRenameContact (c
         rosterTask->set (rosterItem.jid (), rosterItem.name (), rosterItem.groups ());
         rosterTask->go (true);
+        }
+
+        // make sure the flag is being reset
+        mIsNetworkPush = false;
 
 }

--- kdenetwork/kopete/protocols/jabber/jabbercontact.h  #1.91:1.92
@@ -147,5 +147,5 @@ public slots:
          * Catch the rename dialog's results
          */
-        void slotRenameContact (const QString &oldName, const QString &newName);
+        void slotDisplayNameChanged (const QString &oldName, const QString &newName);
 
 protected slots:
@@ -249,4 +249,6 @@ private:
         bool resourceOverride, mEditingVCard;
 
+        bool mIsNetworkPush;
+
         /**
          * Message manager in use to display a message

--- kdenetwork/kopete/protocols/jabber/ui/dlgjabbervcard.cpp  #1.24:1.25
@@ -230,5 +230,5 @@ void dlgJabberVCard::slotSaveNickname ()
         else
         {
-                jc->slotRenameContact(m_mainWidget->leNick->text(), m_mainWidget->leNick->text());
+                jc->slotDisplayNameChanged(m_mainWidget->leNick->text(), m_mainWidget->leNick->text());
         }