diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-05 08:45:53 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-05 08:45:53 +0000 |
commit | 5527e01e0675fbb06b632ccdae423756fbff622b (patch) | |
tree | c2dd1a478a7789d3b01e77fdf31f9011a96a81c5 /kopete/protocols/yahoo/libkyahoo/modifybuddytask.cpp | |
parent | 1fc8db48741fae272e2d29078b266a3d0f2e2dd1 (diff) | |
download | tdenetwork-5527e01e0675fbb06b632ccdae423756fbff622b.tar.gz tdenetwork-5527e01e0675fbb06b632ccdae423756fbff622b.zip |
Many fixes to the Yahoo protocol, courtesy of Serghei Amelian
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1146108 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kopete/protocols/yahoo/libkyahoo/modifybuddytask.cpp')
-rw-r--r-- | kopete/protocols/yahoo/libkyahoo/modifybuddytask.cpp | 81 |
1 files changed, 66 insertions, 15 deletions
diff --git a/kopete/protocols/yahoo/libkyahoo/modifybuddytask.cpp b/kopete/protocols/yahoo/libkyahoo/modifybuddytask.cpp index afae97cf..018d0e84 100644 --- a/kopete/protocols/yahoo/libkyahoo/modifybuddytask.cpp +++ b/kopete/protocols/yahoo/libkyahoo/modifybuddytask.cpp @@ -2,7 +2,7 @@ Kopete Yahoo Protocol Add a buddy to the Contactlist - Copyright (c) 2005 André Duffeck <[email protected]> + Copyright (c) 2005-2006 André Duffeck <[email protected]> ************************************************************************* * * @@ -19,21 +19,70 @@ #include "ymsgtransfer.h" #include "yahootypes.h" #include "client.h" -#include <qstring.h> + #include <kdebug.h> ModifyBuddyTask::ModifyBuddyTask(Task* parent) : Task(parent) { - kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; + kdDebug(YAHOO_RAW_DEBUG) ; } ModifyBuddyTask::~ModifyBuddyTask() { } +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) && + m_target == t->firstParam(7).data() ) + { + return true; + } + + return false; +} + void ModifyBuddyTask::onGo() { - kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; + kdDebug(YAHOO_RAW_DEBUG) ; switch( m_type ) { @@ -47,31 +96,31 @@ void ModifyBuddyTask::onGo() moveBuddy(); break; } - - - - setSuccess( true ); } void ModifyBuddyTask::addBuddy() { - YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceAddBuddy); + YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceBuddyAdd); t->setId( client()->sessionID() ); + t->setParam( 65, m_group.local8Bit() ); + t->setParam( 97, 1 ); // UTF-8 t->setParam( 1, client()->userId().local8Bit() ); - t->setParam( 7, m_target.local8Bit() ); - t->setParam( 14, m_message.utf8() ); - t->setParam( 65, m_group.local8Bit() ); - t->setParam( 97, 1 ); // UTF-8 + t->setParam( 302, 319 ); + t->setParam( 300, 319 ); + t->setParam( 7, m_target.local8Bit() ); + t->setParam( 334, 0 ); + t->setParam( 301, 319 ); + t->setParam( 303, 319 ); 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().local8Bit() ); t->setParam( 7, m_target.local8Bit() ); - t->setParam( 65, m_group.local8Bit() ); + t->setParam( 65, m_group.local8Bit() ); send( t ); } @@ -114,3 +163,5 @@ void ModifyBuddyTask::setType( Type type ) { m_type = type; } + +#include "modifybuddytask.moc" |