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

List:       kde-commits
Subject:    KDE/kdenetwork/kopete/protocols/oscar/liboscar
From:       Matt Rogers <mattr () kde ! org>
Date:       2005-07-28 1:48:15
Message-ID: 1122515295.217910.14180.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 439392 by mattr:

forward port from branch:

reenable rename group. 
add methods that manipulate arbitrary items so i can do
things like add a buddy icon item or change the privacy
options, etc.



 M  +14 -0     ssimanager.cpp  
 M  +2 -0      ssimanager.h  
 M  +38 -5     ssimodifytask.cpp  
 M  +11 -1     ssimodifytask.h  


--- trunk/KDE/kdenetwork/kopete/protocols/oscar/liboscar/ssimanager.cpp \
#439391:439392 @@ -129,6 +129,20 @@
 	//FIXME: NOT Implemented!
 }
 
+bool SSIManager::hasItem( const Oscar::SSI& item ) const
+{
+	QValueList<Oscar::SSI>::const_iterator it, listEnd = d->SSIList.end();
+	
+	for ( it = d->SSIList.begin(); it != listEnd; ++it )
+	{
+		Oscar::SSI s = ( *it );
+		if ( s == item )
+			return true;
+	}
+	
+	return false;
+}
+
 Oscar::SSI SSIManager::findGroup( const QString &group ) const
 {
 	QValueList<Oscar::SSI>::const_iterator it, listEnd = d->SSIList.end();
--- trunk/KDE/kdenetwork/kopete/protocols/oscar/liboscar/ssimanager.h #439391:439392
@@ -74,6 +74,8 @@
 	 * replaced with the data from the new list
 	 */
 	void loadFromExisting( const QValueList<Oscar::SSI*>& newList );
+	
+	bool hasItem( const Oscar::SSI& item ) const;
 
 	Oscar::SSI findGroup( const QString& group ) const;
 	Oscar::SSI findGroup( int groupId ) const;
--- trunk/KDE/kdenetwork/kopete/protocols/oscar/liboscar/ssimodifytask.cpp \
#439391:439392 @@ -152,8 +152,6 @@
 
 bool SSIModifyTask::renameGroup( const QString& oldName, const QString & newName )
 {
-	return false; //rename group is unimplemented
-	
 	m_opType = Rename;
 	m_opSubject = Group;
 	if ( oldName == newName )
@@ -165,6 +163,38 @@
 	return true;
 }
 
+bool SSIModifyTask::addItem( const SSI& item )
+{
+	m_opType = Add;
+	m_opSubject = NoSubject;
+	m_newItem = item;
+	return true;
+}
+
+bool SSIModifyTask::removeItem( const SSI& item )
+{
+	m_opType = Remove;
+	m_opSubject = NoSubject;
+	m_oldItem = item;
+	return false;
+}
+
+bool SSIModifyTask::modifyItem( const SSI& oldItem, const SSI& newItem )
+{
+	if ( !m_ssiManager->hasItem( oldItem ) )
+		return false;
+	
+	//make sure there are some common things between the two items
+	if ( oldItem.type() != newItem.type() )
+		return false;
+	
+	m_oldItem = oldItem;
+	m_newItem = newItem;
+	m_opType = Change;
+	m_opSubject = NoSubject;
+	return true;
+}
+
 bool SSIModifyTask::forMe( const Transfer * transfer ) const
 {
 	const SnacTransfer* st = dynamic_cast<const SnacTransfer*>( transfer );
@@ -272,10 +302,12 @@
 		sendEditEnd();
 	}
 
-	//change the group name
-	if ( m_opType == Rename )
+	//modify an item
+	//we use rename for group and change for other items
+	if ( m_opType == Rename || ( m_opType == Change && m_opSubject != Group ) )
 	{
-		kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "Renaming the group" << m_oldItem.name() \
<< " to " << m_newItem.name() << endl; +		kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << \
"Modifying the item: " << m_oldItem.toString() << endl; +		kdDebug(OSCAR_RAW_DEBUG) \
<< k_funcinfo << "changing it to: " << m_newItem.toString() << endl;  \
sendEditStart();  
 		//change the group name
@@ -283,6 +315,7 @@
 		m_id = client()->snacSequence();
 		SNAC s1 = { 0x0013, 0x0009, 0x0000, m_id };
 		Buffer* ssiBuffer = new Buffer;
+		ssiBuffer->addString( m_oldItem );
 		Transfer* t2 = createTransfer( f1, s1, ssiBuffer );
 		send( t2 );
 		
--- trunk/KDE/kdenetwork/kopete/protocols/oscar/liboscar/ssimodifytask.h \
#439391:439392 @@ -87,10 +87,20 @@
 	//! @return true if we can send the packet
 	bool renameGroup( const QString& oldName, const QString& newName );
 	
+	//! Add an item to the SSI list
+	//! Should be used for other items we don't have explicit functions for
+	//! like icon hashs, privacy settings, non-icq contacts, etc.
+	bool addItem( const SSI& item );
+	
+	//! Remove an item from the SSI list
+	//! Should be used for other items we don't have explicit functions for
+	//! like icon hashs, privacy settings, non-icq contacts, etc.
+	bool removeItem( const SSI& item );
+	
 	//! Modify an item on the SSI list
 	//! Should be used for other items we don't have explicit functions for
 	//! like icon hashs, privacy settings, non-icq contacts, etc.
-	bool modifyItem( const SSI& item );
+	bool modifyItem( const SSI& oldItem, const SSI& newItem );
 	
 protected:
 	virtual bool forMe( const Transfer* transfer ) const;


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

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