[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdenetwork/kopete/protocols/oscar/liboscar
From:       Roman Jarosz <kedgedev () centrum ! cz>
Date:       2007-03-22 12:57:06
Message-ID: 1174568226.287954.29367.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 645365 by rjarosz:

Forwardport: Update our local Server Side Info correctly.
Fix authorization status in ICQ.

Fix bug 133950: adding users to visible/invisible list does not work
Please test it because I can't reproduce it.

CCBUG: 133950



 M  +23 -1     client.cpp  
 M  +62 -28    contactmanager.cpp  
 M  +3 -2      contactmanager.h  
 M  +0 -9      tasks/ssiauthtask.cpp  
 M  +113 -10   tasks/ssimodifytask.cpp  
 M  +14 -3     tasks/ssimodifytask.h  


--- trunk/KDE/kdenetwork/kopete/protocols/oscar/liboscar/client.cpp #645364:645365
@@ -117,6 +117,7 @@
 	ICQUserInfoRequestTask* icqInfoTask;
 	UserInfoTask* userInfoTask;
 	TypingNotifyTask * typingNotifyTask;
+	SSIModifyTask* ssiModifyTask;
 	//Managers
 	ContactManager* ssiManager;
 	ConnectionHandler connections;
@@ -174,6 +175,7 @@
 	d->userInfoTask = 0L;
 	d->stage = ClientPrivate::StageOne;
 	d->typingNotifyTask = 0L;
+	d->ssiModifyTask = 0L;
 	d->awayMsgRequestTimer = new QTimer();
 	d->codecProvider = &defaultCodecProvider;
 
@@ -711,6 +713,7 @@
 	d->icqInfoTask = new ICQUserInfoRequestTask( c->rootTask() );
 	d->userInfoTask = new UserInfoTask( c->rootTask() );
 	d->typingNotifyTask = new TypingNotifyTask( c->rootTask() );
+	d->ssiModifyTask = new SSIModifyTask( c->rootTask(), true );
 
 	connect( d->onlineNotifier, SIGNAL( userIsOnline( const QString&, const \
                UserDetails& ) ),
 	         this, SIGNAL( receivedUserInfo( const QString&, const UserDetails& ) ) );
@@ -754,6 +757,8 @@
 	SSIModifyTask* ssimt = new SSIModifyTask( c->rootTask() );
 	if ( ssimt->removeGroup( groupName ) )
 		ssimt->go( true );
+	else
+		delete ssimt;
 }
 
 void Client::addGroup( const QString& groupName )
@@ -766,6 +771,8 @@
 	SSIModifyTask* ssimt = new SSIModifyTask( c->rootTask() );
 	if ( ssimt->addGroup( groupName ) )
 		ssimt->go( true );
+	else
+		delete ssimt;
 }
 
 void Client::addContact( const QString& contactName, const QString& groupName )
@@ -778,7 +785,8 @@
 	SSIModifyTask* ssimt = new SSIModifyTask( c->rootTask() );
 	if ( ssimt->addContact( contactName, groupName )  )
 		ssimt->go( true );
-
+	else
+		delete ssimt;
 }
 
 void Client::removeContact( const QString& contactName )
@@ -791,6 +799,8 @@
 	SSIModifyTask* ssimt = new SSIModifyTask( c->rootTask() );
 	if ( ssimt->removeContact( contactName ) )
 		ssimt->go( true );
+	else
+		delete ssimt;
 }
 
 void Client::renameGroup( const QString & oldGroupName, const QString & newGroupName \
) @@ -803,6 +813,8 @@
 	SSIModifyTask* ssimt = new SSIModifyTask( c->rootTask() );
 	if ( ssimt->renameGroup( oldGroupName, newGroupName ) )
 		ssimt->go( true );
+	else
+		delete ssimt;
 }
 
 void Client::modifyContactItem( const OContact& oldItem, const OContact& newItem )
@@ -824,14 +836,20 @@
 	case 0:
 		if ( ssimt->modifyItem( oldItem, newItem ) )
 			ssimt->go( true );
+		else
+			delete ssimt;
 		break;
 	case 1:
 		if ( ssimt->addItem( newItem ) )
 			ssimt->go( true );
+		else
+			delete ssimt;
 		break;
 	case 2:
 		if ( ssimt->removeItem( oldItem ) )
 			ssimt->go( true );
+		else
+			delete ssimt;
 		break;
 	}
 }
@@ -847,6 +865,8 @@
 	SSIModifyTask* ssimt = new SSIModifyTask( c->rootTask() );
 	if ( ssimt->changeGroup( contact, newGroupName ) )
 		ssimt->go( true );
+	else
+		delete ssimt;
 }
 
 void Client::requestFullInfo( const QString& contactId )
@@ -1453,6 +1473,7 @@
 	delete d->icqInfoTask;
 	delete d->userInfoTask;
 	delete d->typingNotifyTask;
+	delete d->ssiModifyTask;
 
 	d->errorTask = 0;
 	d->onlineNotifier = 0;
@@ -1462,6 +1483,7 @@
 	d->icqInfoTask = 0;
 	d->userInfoTask = 0;
 	d->typingNotifyTask = 0;
+	d->ssiModifyTask = 0;
 }
 
 bool Client::hasIconConnection( ) const
--- trunk/KDE/kdenetwork/kopete/protocols/oscar/liboscar/contactmanager.cpp \
#645364:645365 @@ -448,26 +448,26 @@
 	return false;
 }
 
-bool ContactManager::updateGroup( const OContact& oldGroup, const OContact& newGroup \
) +bool ContactManager::updateGroup( const OContact& group )
 {
-	removeID( oldGroup );
-	if ( d->contactList.removeAll( oldGroup ) == 0 )
+	OContact oldGroup = findGroup( group.name() );
+
+	if ( oldGroup.isValid() )
 	{
-		kDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "No group were removed." << endl;
-		return false;
+		removeID( oldGroup );
+		d->contactList.removeAll( oldGroup );
 	}
-	
-	if ( d->contactList.contains( newGroup ) )
+
+	if ( d->contactList.contains( group ) )
 	{
 		kDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "New group is already in list." << endl;
 		return false;
 	}
-	
-	kDebug( OSCAR_RAW_DEBUG ) << k_funcinfo << "Updating group '" << newGroup.name() << \
                "' in SSI list" << endl;
-	addID( newGroup );
-	d->contactList.append( newGroup );
-	emit groupUpdated( newGroup );
-	
+
+	kDebug( OSCAR_RAW_DEBUG ) << k_funcinfo << "Updating group '" << group.name() << "' \
in SSI list" << endl; +	addID( group );
+	d->contactList.append( group );
+	emit groupUpdated( group );
 	return true;
 }
 
@@ -516,26 +516,26 @@
 	return true;
 }
 
-bool ContactManager::updateContact( const OContact& oldContact, const OContact& \
newContact ) +bool ContactManager::updateContact( const OContact& contact )
 {
-	removeID( oldContact );
-	if ( d->contactList.removeAll( oldContact ) == 0 )
+	OContact oldContact = findContact( contact.name() );
+
+	if ( oldContact.isValid() )
 	{
-		kDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "No contacts were removed." << endl;
-		return false;
+		removeID( oldContact );
+		d->contactList.removeAll( oldContact );
 	}
-	
-	if ( d->contactList.contains( newContact ) )
+
+	if ( d->contactList.contains( contact ) )
 	{
 		kDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "New contact is already in list." << \
endl;  return false;
 	}
-	
-	kDebug( OSCAR_RAW_DEBUG ) << k_funcinfo << "Updating contact '" << \
                newContact.name() << "' in SSI list" << endl;
-	addID( newContact );
-	d->contactList.append( newContact );
-	emit contactUpdated( newContact );
-	
+
+	kDebug( OSCAR_RAW_DEBUG ) << k_funcinfo << "Updating contact '" << contact.name() \
<< "' in SSI list" << endl; +	addID( contact );
+	d->contactList.append( contact );
+	emit contactUpdated( contact );
 	return true;
 }
 
@@ -569,17 +569,51 @@
 
 bool ContactManager::newItem( const OContact& item )
 {
-	//no error checking for now
+	if ( d->contactList.contains( item ) )
+	{
+		kDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "Item is already in list." << endl;
+		return false;
+	}
+
 	kDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "Adding item " << item.toString() << endl;
 	addID( item );
 	d->contactList.append( item );
 	return true;
 }
 
+bool ContactManager::updateItem( const OContact& item )
+{
+	OContact oldItem = findItem( item.name(), item.type() );
+
+	if ( oldItem.isValid() )
+	{
+		removeID( oldItem );
+		d->contactList.removeAll( oldItem );
+	}
+
+	if ( d->contactList.contains( item ) )
+	{
+		kDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "New item is already in list." << endl;
+		return false;
+	}
+
+	kDebug( OSCAR_RAW_DEBUG ) << k_funcinfo << "Updating item in SSI list" << endl;
+	addID( item );
+	d->contactList.append( item );
+	return true;
+}
+
 bool ContactManager::removeItem( const OContact& item )
 {
 	removeID( item );
-	d->contactList.removeAll( item );
+	int remcount = d->contactList.removeAll( item );
+
+	if ( remcount == 0 )
+	{
+		kDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "No items were removed." << endl;
+		return false;
+	}
+
 	return true;
 }
 
--- trunk/KDE/kdenetwork/kopete/protocols/oscar/liboscar/contactmanager.h \
#645364:645365 @@ -105,16 +105,17 @@
 
 public slots:
 	bool newGroup( const OContact& group );
-	bool updateGroup( const OContact& oldGroup, const OContact& newGroup );
+	bool updateGroup( const OContact& group );
 	bool removeGroup( const OContact& group );
 	bool removeGroup( const QString& group );
 
 	bool newContact( const OContact& contact );
-	bool updateContact( const OContact& oldContact, const OContact& newContact );
+	bool updateContact( const OContact& contact );
 	bool removeContact( const OContact& contact );
 	bool removeContact( const QString& contact );
 	
 	bool newItem( const OContact& item );
+	bool updateItem( const OContact& item );
 	bool removeItem( const OContact& item );
 
 	void addID( const OContact& item );
--- trunk/KDE/kdenetwork/kopete/protocols/oscar/liboscar/tasks/ssiauthtask.cpp \
#645364:645365 @@ -112,10 +112,6 @@
 	
 	Transfer* t = createTransfer( f, s, buf );
 	send( t );
-	
-	OContact contact = m_manager->findContact( uin );
-	if ( contact )
-		contact.setWaitingAuth( true );
 }
 
 void SSIAuthTask::sendAuthReply( const QString& uin, const QString& reason, bool \
auth ) @@ -175,11 +171,6 @@
 		kDebug( OSCAR_RAW_DEBUG ) << k_funcinfo << "Authorization request declined by " << \
uin << endl;  
 	kDebug( OSCAR_RAW_DEBUG ) << k_funcinfo << "Reason: " << reason << endl;
-	
-	OContact sender = m_manager->findContact( uin );
-	if ( sender )
-		sender.setWaitingAuth( false );
-		
 	emit authReplied( uin, reason, accepted );
 }
 
--- trunk/KDE/kdenetwork/kopete/protocols/oscar/liboscar/tasks/ssimodifytask.cpp \
#645364:645365 @@ -28,9 +28,10 @@
 #include "transfer.h"
 
 
-SSIModifyTask::SSIModifyTask( Task* parent ) : Task( parent )
+SSIModifyTask::SSIModifyTask( Task* parent, bool staticTask ) : Task( parent )
 {
 	m_ssiManager = parent->client()->ssiManager();
+	m_static = staticTask;
 	m_opType = NoType;
 	m_opSubject = NoSubject;
 	m_id = 0;
@@ -50,9 +51,22 @@
 {
 	if ( forMe( transfer ) )
 	{
-		setTransfer( transfer );
-		handleContactAck();
-		setTransfer( 0 );
+		SnacTransfer* st = dynamic_cast<SnacTransfer*>( transfer );
+		if ( st )
+		{
+			setTransfer( transfer );
+
+			if ( st->snacSubtype() == 0x0008 )
+				handleContactAdd();
+			else if ( st->snacSubtype() == 0x0009 )
+				handleContactUpdate();
+			else if ( st->snacSubtype() == 0x000A )
+				handleContactRemove();
+			else if ( st->snacSubtype() == 0x000E )
+				handleContactAck();
+
+			setTransfer( 0 );
+		}
 		return true;
 	}
 	else
@@ -202,10 +216,22 @@
 	if ( !st )
 		return false;
 
-	if ( st->snacService() == 0x0013 && st->snacSubtype() == 0x000E && m_id == \
                st->snac().id )
-		return true;
-	else
-		return false;
+	if ( st->snacService() == 0x0013 )
+	{
+		WORD subtype = st->snacSubtype();
+		if ( m_static )
+		{
+			if ( subtype == 0x0008 || subtype == 0x0009 || subtype == 0x000A )
+				return true;
+		}
+		else
+		{
+			if ( subtype == 0x000E && m_id == st->snac().id )
+				return true;
+		}
+	}
+
+	return false;
 }
 
 void SSIModifyTask::handleContactAck()
@@ -429,9 +455,9 @@
 		else if ( m_opSubject == Group )
 		{
 			if ( m_opType == Rename )
-				m_ssiManager->updateGroup( m_oldItem, m_newItem );
+				m_ssiManager->updateGroup( m_newItem );
 			else if ( m_opType == Change )
-				m_ssiManager->updateContact( m_oldItem, m_newItem );
+				m_ssiManager->updateContact( m_newItem );
 		}
 		else if ( m_opSubject == NoSubject )
 		{
@@ -530,4 +556,81 @@
 		buffer->addTLV( ( *it ) );
 }
 
+OContact SSIModifyTask::getItemFromBuffer( Buffer* buffer ) const
+{
+	QList<TLV> tlvList;
+
+	QString itemName = QString::fromUtf8( buffer->getBSTR() );
+	Oscar::WORD groupId = buffer->getWord();
+	Oscar::WORD itemId = buffer->getWord();
+	Oscar::WORD itemType = buffer->getWord();
+	Oscar::WORD tlvLength = buffer->getWord();
+	for ( int i = 0; i < tlvLength; )
+	{
+		TLV t = buffer->getTLV();
+		i += 4;
+		i += t.length;
+		tlvList.append( t );
+	}
+
+	if ( itemType == ROSTER_CONTACT )
+		itemName = Oscar::normalize( itemName );
+
+	return OContact( itemName, groupId, itemId, itemType, tlvList );
+}
+
+void SSIModifyTask::handleContactAdd()
+{
+	Buffer* b = transfer()->buffer();
+
+	while ( b->bytesAvailable() > 0 )
+	{
+		OContact item = getItemFromBuffer( b );
+		kDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "Adding " << item.name() << " to SSI \
manager" << endl; +
+		if ( item.type() == ROSTER_GROUP )
+			m_ssiManager->newGroup( item );
+		else if ( item.type() == ROSTER_CONTACT )
+			m_ssiManager->newContact( item );
+		else
+			m_ssiManager->newItem( item );
+	}
+}
+
+void SSIModifyTask::handleContactUpdate()
+{
+	Buffer* b = transfer()->buffer();
+
+	while ( b->bytesAvailable() > 0 )
+	{
+		OContact item = getItemFromBuffer( b );
+		kDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "Updating " << item.name() << " in SSI \
manager" << endl; +
+		if ( item.type() == ROSTER_GROUP )
+			m_ssiManager->updateGroup( item );
+		else if ( item.type() == ROSTER_CONTACT )
+			m_ssiManager->updateContact( item );
+		else
+			m_ssiManager->updateItem( item );
+	}
+}
+
+void SSIModifyTask::handleContactRemove()
+{
+	Buffer* b = transfer()->buffer();
+
+	while ( b->bytesAvailable() > 0 )
+	{
+		OContact item = getItemFromBuffer( b );
+		kDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "Removing " << item.name() << " from SSI \
manager" << endl; +
+		if ( item.type() == ROSTER_GROUP )
+			m_ssiManager->removeGroup( item );
+		else if ( item.type() == ROSTER_CONTACT )
+			m_ssiManager->removeContact( item );
+		else
+			m_ssiManager->removeItem( item );
+	}
+}
+
 //kate: tab-width 4; indent-mode csands;
--- trunk/KDE/kdenetwork/kopete/protocols/oscar/liboscar/tasks/ssimodifytask.h \
#645364:645365 @@ -52,7 +52,7 @@
 class SSIModifyTask : public Task
 {
 public:
-    SSIModifyTask(Task* parent);
+    SSIModifyTask( Task* parent, bool staticTask = false );
     ~SSIModifyTask();
 
 	virtual void onGo();
@@ -129,7 +129,17 @@
 	void sendEditEnd();
 	
 	void addItemToBuffer( OContact item, Buffer* buffer );
-	
+	OContact getItemFromBuffer( Buffer* buffer ) const;
+
+	//! Handle server request to add data
+	void handleContactAdd();
+
+	//! Handle server request to update data
+	void handleContactUpdate();
+
+	//! Handle server request to remove data
+	void handleContactRemove();
+
 private:
 	OContact m_oldItem;
 	OContact m_newItem;
@@ -138,7 +148,8 @@
 	OperationSubject m_opSubject;
 	Oscar::WORD m_id;
 	ContactManager* m_ssiManager;
-	
+	bool m_static;
+
 };
 
 #endif


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic