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

List:       kde-commits
Subject:    branches/KDE/4.2/kdenetwork/kopete/protocols/yahoo
From:       Matt Rogers <mattr () kde ! org>
Date:       2009-02-06 2:57:22
Message-ID: 1233889042.604330.13574.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 921978 by mattr:

Backport patch for 150482 to the KDE 4.2 branch.

It'll be in KDE 4.2.1

BUG: 150482



 M  +12 -0     libkyahoo/client.cpp  
 M  +12 -0     libkyahoo/client.h  
 M  +59 -10    libkyahoo/modifybuddytask.cpp  
 M  +12 -0     libkyahoo/modifybuddytask.h  
 M  +2 -2      libkyahoo/yahootypes.h  
 M  +11 -3     libkyahoo/ymsgprotocol.cpp  
 M  +53 -0     yahooaccount.cpp  
 M  +3 -0      yahooaccount.h  


--- branches/KDE/4.2/kdenetwork/kopete/protocols/yahoo/libkyahoo/client.cpp \
#921977:921978 @@ -450,6 +450,10 @@
 void Client::addBuddy( const QString &userId, const QString &group, const QString \
&message )  {
 	ModifyBuddyTask *mbt = new ModifyBuddyTask( d->root );
+	
+	QObject::connect(mbt, SIGNAL(buddyAddResult( const QString &, const QString &, bool \
)), +			 SIGNAL(buddyAddResult( const QString &, const QString &, bool)));
+
 	mbt->setType( ModifyBuddyTask::AddBuddy );
 	mbt->setTarget( userId );
 	mbt->setGroup( group );
@@ -460,6 +464,10 @@
 void Client::removeBuddy( const QString &userId, const QString &group )
 {
 	ModifyBuddyTask *mbt = new ModifyBuddyTask( d->root );
+
+	QObject::connect(mbt, SIGNAL(buddyRemoveResult( const QString &, const QString &, \
bool )), +			 SIGNAL(buddyRemoveResult( const QString &, const QString &, bool)));
+
 	mbt->setType( ModifyBuddyTask::RemoveBuddy );
 	mbt->setTarget( userId );
 	mbt->setGroup( group );
@@ -469,6 +477,10 @@
 void Client::moveBuddy( const QString &userId, const QString &oldGroup, const \
QString &newGroup )  {
 	ModifyBuddyTask *mbt = new ModifyBuddyTask( d->root );
+
+	QObject::connect(mbt, SIGNAL(buddyChangeGroupResult( const QString &, const QString \
&, bool )), +			 SIGNAL(buddyChangeGroupResult( const QString &, const QString &, \
bool))); +
 	mbt->setType( ModifyBuddyTask::MoveBuddy );
 	mbt->setTarget( userId );
 	mbt->setOldGroup( oldGroup );
--- branches/KDE/4.2/kdenetwork/kopete/protocols/yahoo/libkyahoo/client.h \
#921977:921978 @@ -486,6 +486,18 @@
 		 */
 		void gotBuddy( const QString &, const QString &, const QString & );
 		/**
+		 * Notifies about adding buddies
+		 */
+		void buddyAddResult( const QString &, const QString &, bool );
+		/**
+		 * Notifies about removing buddies
+		 */
+		void buddyRemoveResult( const QString &, const QString &, bool );
+		/**
+		 * Notifies about buddies changing groups
+		 */
+		void buddyChangeGroupResult( const QString &, const QString &, bool );
+		/**
 		 * Notifies about the status of online buddies
 		 */
 		void statusChanged( const QString&, int, const QString&, int, int, int );
--- branches/KDE/4.2/kdenetwork/kopete/protocols/yahoo/libkyahoo/modifybuddytask.cpp \
#921977:921978 @@ -31,6 +31,55 @@
 {
 }
 
+bool ModifyBuddyTask::take( Transfer* transfer )
+{
+     if( !forMe( transfer ) )
+	  return false;
+
+     YMSGTransfer *t = static_cast<YMSGTransfer *>(transfer);
+
+     bool success = t->firstParam(66) == "0";
+
+     switch(t->service())
+     {
+     case Yahoo::ServiceBuddyAdd:
+	  emit buddyAddResult(m_target, m_group, success);
+	  break;
+     case Yahoo::ServiceBuddyRemove:
+	  emit buddyRemoveResult(m_target, m_group, success);
+	  break;
+     case Yahoo::ServiceBuddyChangeGroup:
+	  emit buddyChangeGroupResult(m_target, m_group, success);
+     default:
+	  return false;
+     }
+
+     if(success)
+	  setSuccess();
+     else
+	  setError();
+
+     return true;
+}
+
+bool ModifyBuddyTask::forMe( const Transfer* transfer ) const
+{
+     const YMSGTransfer *t = 0L;
+     t = dynamic_cast<const YMSGTransfer*>(transfer);
+     
+     if(!t)
+	  return false;
+
+     if( (t->service() == Yahoo::ServiceBuddyAdd ||
+	  t->service() == Yahoo::ServiceBuddyRemove) &&
+	 t->firstParam(7) == m_target)
+     {
+	  return true;
+     }
+     
+     return false;
+}
+
 void ModifyBuddyTask::onGo()
 {
 	kDebug(YAHOO_RAW_DEBUG) ;
@@ -47,27 +96,27 @@
 			moveBuddy();
 		break;
 	}
-
-
-	
-	setSuccess();
 }
 
 void ModifyBuddyTask::addBuddy()
 {
-	YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceAddBuddy);
+	YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceBuddyAdd);
 	t->setId( client()->sessionID() );
+	t->setParam( 65, m_group.toLocal8Bit() );
+	t->setParam( 97, 1 );
 	t->setParam( 1, client()->userId().toLocal8Bit() );
-	t->setParam( 7, m_target.toLocal8Bit() );
-	t->setParam( 14, m_message.toUtf8() );
-	t->setParam( 65, m_group.toLocal8Bit() );	
-	t->setParam( 97, 1 );	// UTF-8
+	t->setParam( 302,  319 );
+	t->setParam( 300,  319 );
+	t->setParam( 7,  m_target.toLocal8Bit() );
+	t->setParam( 334,  0 );
+	t->setParam( 301, 319 );
+	t->setParam( 303, 319 );	// UTF-8
 	send( t );
 }
 
 void ModifyBuddyTask::removeBuddy()
 {
-	YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceRemBuddy);
+	YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceBuddyRemove);
 	t->setId( client()->sessionID() );
 	t->setParam( 1, client()->userId().toLocal8Bit() );
 	t->setParam( 7, m_target.toLocal8Bit() );
--- branches/KDE/4.2/kdenetwork/kopete/protocols/yahoo/libkyahoo/modifybuddytask.h \
#921977:921978 @@ -26,6 +26,7 @@
 */
 class ModifyBuddyTask : public Task
 {
+Q_OBJECT
 public:
 	enum Type { AddBuddy, RemoveBuddy, MoveBuddy };
 	ModifyBuddyTask(Task *parent);
@@ -33,11 +34,22 @@
 	
 	virtual void onGo();
 	
+	bool take(Transfer *transfer);
+
 	void setType( Type type );
 	void setMessage( const QString &text );
 	void setTarget( const QString &target );
 	void setGroup( const QString &group );
 	void setOldGroup( const QString &group );
+
+signals:
+	void buddyAddResult( const QString &, const QString &, bool );
+	void buddyRemoveResult( const QString &, const QString &, bool );
+	void buddyChangeGroupResult( const QString &, const QString &, bool );
+
+protected:
+	virtual bool forMe( const Transfer *transfer ) const;
+
 private:
 	void addBuddy();
 	void removeBuddy();
--- branches/KDE/4.2/kdenetwork/kopete/protocols/yahoo/libkyahoo/yahootypes.h \
#921977:921978 @@ -72,8 +72,8 @@
 		ServiceAuthResp = 0x54,
 		ServiceList = 85,
 		ServiceAuth = 0x57,
-		ServiceAddBuddy = 0x83,
-		ServiceRemBuddy,
+		ServiceBuddyAdd = 0x83,
+		ServiceBuddyRemove = 0x84,
 		ServiceIgnoreContact,	/* > 1, 7, 13 < 1, 66, 13, 0*/
 		ServiceRejectContact,
 		ServiceGroupRename = 0x89, /* > 1, 65(new), 66(0), 67(old) */
--- branches/KDE/4.2/kdenetwork/kopete/protocols/yahoo/libkyahoo/ymsgprotocol.cpp \
#921977:921978 @@ -154,10 +154,18 @@
 			kDebug(YAHOO_RAW_DEBUG) << " Parsed packet service -  This means ServiceNotify " \
<< servicenum;  service = Yahoo::ServiceNotify;
 		break;
-		case (Yahoo::ServiceAddBuddy) :
-			kDebug(YAHOO_RAW_DEBUG) << " Parsed packet service -  This means ServiceAddBuddy \
                " << servicenum;
-			service = Yahoo::ServiceAddBuddy;
+		case (Yahoo::ServiceBuddyAdd) :
+			kDebug(YAHOO_RAW_DEBUG) << " Parsed packet service -  This means ServiceBuddyAdd \
" << servicenum; +			service = Yahoo::ServiceBuddyAdd;
 		break;
+        	case (Yahoo::ServiceBuddyRemove) :
+	                kDebug(YAHOO_RAW_DEBUG) << "Parsed packet service -  This means \
ServiceBuddyRemove " << servicenum; +	                service = \
Yahoo::ServiceBuddyRemove; +	        break;
+        	case (Yahoo::ServiceBuddyChangeGroup) :
+	                kDebug(YAHOO_RAW_DEBUG) << "Parsed packet service -  This means \
ServiceBuddyChangeGroup " << servicenum; +	                service = \
Yahoo::ServiceBuddyChangeGroup; +	        break;
 		case (Yahoo::ServicePictureChecksum) :
 			kDebug(YAHOO_RAW_DEBUG) << " Parsed packet service -  This means \
ServicePictureChecksum " << servicenum;  service = Yahoo::ServicePictureChecksum;
--- branches/KDE/4.2/kdenetwork/kopete/protocols/yahoo/yahooaccount.cpp \
#921977:921978 @@ -244,6 +244,15 @@
 		QObject::connect(m_session, SIGNAL(gotBuddy(const QString &, const QString &, \
                const QString &)),
 		                 this, SLOT(slotGotBuddy(const QString &, const QString &, const \
QString &)));  
+		QObject::connect(m_session, SIGNAL(buddyAddResult(const QString &, const QString \
&, bool)), +				 this, SLOT(slotBuddyAddResult(const QString &, const QString &, \
bool))); +
+		QObject::connect(m_session, SIGNAL(buddyRemoveResult(const QString &, const \
QString &, bool)), +				 this, SLOT(slotBuddyRemoveResult(const QString &, const \
QString &, bool))); +
+		QObject::connect(m_session, SIGNAL(buddyChangeGroupResult(const QString &, const \
QString &, bool)), +				 this, SLOT(slotBuddyChangeGroupResult(const QString &, const \
QString &, bool))); +
 		QObject::connect(m_session, SIGNAL(authorizationAccepted( const QString & )),
 		                 this, SLOT(slotAuthorizationAccepted( const QString & )) );
 
@@ -377,6 +386,15 @@
 		QObject::disconnect(m_session, SIGNAL(gotBuddy(const QString &, const QString &, \
                const QString &)),
 		                    this, SLOT(slotGotBuddy(const QString &, const QString &, \
const QString &)));  
+		QObject::disconnect(m_session, SIGNAL(buddyAddResult(const QString &, const \
QString &, bool)), +		                    this, SLOT(slotBuddyAddResult(const QString \
&, const QString &, bool))); +
+		QObject::disconnect(m_session, SIGNAL(buddyRemoveResult(const QString &, const \
QString &, bool)), +		                    this, SLOT(slotBuddyRemoveResult(const \
QString &, const QString &, bool))); +
+		QObject::disconnect(m_session, SIGNAL(buddyChangeGroupResult(const QString &, \
const QString &, bool)), +				 this, SLOT(slotBuddyChangeGroupResult(const QString &, \
const QString &, bool))); +
 		QObject::disconnect(m_session, SIGNAL(authorizationAccepted( const QString &)),
 		                 this, SLOT(slotAuthorizationAccepted( const QString &)) );
 
@@ -696,6 +714,7 @@
 
 		setBuddyIcon( myself()->property( Kopete::Global::Properties::self()->photo() \
).value().toString() );  m_session->getYABEntries( m_YABLastMerge, \
m_YABLastRemoteRevision ); +		IDs.clear();
 		m_lastDisconnectCode = 0;
 		theHaveContactList = true;
 		return;
@@ -804,8 +823,42 @@
 		Kopete::Group *g=Kopete::ContactList::self()->findGroup(group);
 		addContact(userid, alias.isEmpty() ? userid : alias, g, \
Kopete::Account::ChangeKABC);  }
+
+	kDebug(YAHOO_GEN_DEBUG) << IDs;
 }
 
+void YahooAccount::slotBuddyAddResult( const QString &userid, const QString &group, \
bool success ) +{
+     kDebug(YAHOO_GEN_DEBUG) << success;
+
+     if(success)
+	  IDs[userid] = QPair<QString, QString>(group, QString());
+
+     kDebug(YAHOO_GEN_DEBUG) << IDs;
+}
+
+void YahooAccount::slotBuddyRemoveResult( const QString &userid, const QString \
&group, bool success ) +{
+     kDebug(YAHOO_GEN_DEBUG);
+
+     // Ignore success here, the only reason this will fail is because the
+     // contact isn't on the server's list, so we shouldn't have them in our
+     // list either.
+     IDs.remove(userid);
+
+     kDebug(YAHOO_GEN_DEBUG) << IDs;
+}
+
+void YahooAccount::slotBuddyChangeGroupResult(const QString &userid, const QString \
&group, bool success) +{
+     kDebug(YAHOO_GEN_DEBUG);
+     
+     if(success)
+	  IDs[userid] = QPair<QString, QString>(group, QString());
+
+     kDebug(YAHOO_GEN_DEBUG) << IDs;
+}
+
 void YahooAccount::slotAuthorizationAccepted( const QString &who )
 {
 	kDebug(YAHOO_GEN_DEBUG) ;
--- branches/KDE/4.2/kdenetwork/kopete/protocols/yahoo/yahooaccount.h #921977:921978
@@ -181,6 +181,9 @@
 	void slotDisconnected();
 	void slotLoginFailed();
 	void slotGotBuddy(const QString &userid, const QString &alias, const QString \
&group); +	void slotBuddyAddResult(const QString &userid, const QString &group, bool \
success); +	void slotBuddyRemoveResult(const QString &userid, const QString &group, \
bool success); +	void slotBuddyChangeGroupResult(const QString &userid, const QString \
&group, bool success);  void slotAuthorizationAccepted( const QString &who );
 	void slotAuthorizationRejected( const QString &who, const QString &msg );
 	void slotgotAuthorizationRequest( const QString &, const QString &, const QString & \
);


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

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