~ubuntu-branches/ubuntu/edgy/kopete/edgy-proposed

« back to all changes in this revision

Viewing changes to kopete/protocols/jabber/jabbercontactpool.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Sarah Hobbs
  • Date: 2006-07-14 23:45:58 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060714234558-gq6jzmy117r2pj4r
Tags: 4:3.5.4+kopete0.12.1-0ubuntu1
* New upstream version
* Reverted patch 01_kopete_kdesktop_freeze.diff (fixed upstream)
* Reverted patch 02_icq_version_too_old.diff (fixed upstream)
* Bumped Version so that this gets installed, instead of the kopete in kdenetwork

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#include <kdebug.h>
23
23
#include <kmessagebox.h>
24
24
#include <kopeteaccountmanager.h>
 
25
#include <kopetecontactlist.h>
25
26
#include "kopeteuiglobal.h"
26
27
#include "jabberprotocol.h"
27
28
#include "jabberbasecontact.h"
118
119
        JabberContactPoolItem *mContactItem = findPoolItem ( mContact );
119
120
        if ( mContactItem)
120
121
        {
121
 
                kdDebug(JABBER_DEBUG_GLOBAL) << k_funcinfo << "Updating existing contact " << mContact.jid().full() << endl;
122
 
 
123
 
                // It exists, update it.
124
 
                mContactItem->contact()->updateContact ( mContact );
125
 
                mContactItem->setDirty ( dirty );
126
 
 
127
 
                //we must tell to the originating function that no new contact has been added
128
 
                return 0L;//mContactItem->contact ();
 
122
                if(mContactItem->contact()->inherits(roomContact ?
 
123
                                 (const char*)("JabberGroupContact") : (const char*)("JabberGroupMemberContact") ) )
 
124
                {
 
125
                        
 
126
                        kdDebug(JABBER_DEBUG_GLOBAL) << k_funcinfo << "Updating existing contact " << mContact.jid().full() << endl;
 
127
                        
 
128
                        // It exists, update it.
 
129
                        mContactItem->contact()->updateContact ( mContact );
 
130
                        mContactItem->setDirty ( dirty );
 
131
        
 
132
                        //we must tell to the originating function that no new contact has been added
 
133
                        return 0L;//mContactItem->contact ();
 
134
                }
 
135
                else
 
136
                {
 
137
                        //this happen if we receive a MUC invitaiton:  when the invitaiton is received, it's from the muc itself
 
138
                        //and then kopete will create a temporary contact for it. but it will not be a good contact.
 
139
                        kdDebug(JABBER_DEBUG_GLOBAL) << k_funcinfo << "Bad contact will be removed and re-added " << mContact.jid().full() << endl;
 
140
                        Kopete::MetaContact *old_mc=mContactItem->contact()->metaContact();
 
141
                        delete mContactItem->contact();
 
142
                        mContactItem = 0L;
 
143
                        if(old_mc->contacts().isEmpty() && old_mc!=metaContact)
 
144
                        {
 
145
                                Kopete::ContactList::self()->removeMetaContact( old_mc );
 
146
                        }
 
147
                        
 
148
                }
 
149
 
129
150
        }
130
151
 
131
152
        kdDebug(JABBER_DEBUG_GLOBAL) << k_funcinfo << "Adding new contact " << mContact.jid().full() << endl;
161
182
                         * The following deletion will cause slotContactDestroyed()
162
183
                         * to be called, which will clean the up the list.
163
184
                         */
164
 
                        delete mContactItem->contact ();
 
185
                        if(mContactItem->contact())
 
186
                        {
 
187
                                Kopete::MetaContact *mc=mContactItem->contact()->metaContact();
 
188
                                delete mContactItem->contact ();
 
189
                                if(mc && mc->contacts().isEmpty())
 
190
                                {
 
191
                                        Kopete::ContactList::self()->removeMetaContact(mc) ;
 
192
                                }
 
193
                        }
165
194
                        return;
166
195
                }
167
196
        }