summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/yahoo/libkyahoo/picturenotifiertask.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-05 08:45:53 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-05 08:45:53 +0000
commit5527e01e0675fbb06b632ccdae423756fbff622b (patch)
treec2dd1a478a7789d3b01e77fdf31f9011a96a81c5 /kopete/protocols/yahoo/libkyahoo/picturenotifiertask.cpp
parent1fc8db48741fae272e2d29078b266a3d0f2e2dd1 (diff)
downloadtdenetwork-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/picturenotifiertask.cpp')
-rw-r--r--kopete/protocols/yahoo/libkyahoo/picturenotifiertask.cpp51
1 files changed, 27 insertions, 24 deletions
diff --git a/kopete/protocols/yahoo/libkyahoo/picturenotifiertask.cpp b/kopete/protocols/yahoo/libkyahoo/picturenotifiertask.cpp
index 6259f7e8..b88b99c6 100644
--- a/kopete/protocols/yahoo/libkyahoo/picturenotifiertask.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/picturenotifiertask.cpp
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Notifies about buddy icons
- Copyright (c) 2005 AndrĂ© Duffeck <[email protected]>
+ Copyright (c) 2005 AndrĂ© Duffeck <[email protected]>
*************************************************************************
* *
@@ -19,15 +19,15 @@
#include "ymsgtransfer.h"
#include "yahootypes.h"
#include "client.h"
-#include <qstring.h>
+
#include <qstringlist.h>
-#include <kurl.h>
#include <kdebug.h>
#include <klocale.h>
+
PictureNotifierTask::PictureNotifierTask(Task* parent) : Task(parent)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
}
PictureNotifierTask::~PictureNotifierTask()
@@ -37,23 +37,23 @@ PictureNotifierTask::~PictureNotifierTask()
bool PictureNotifierTask::take( Transfer* transfer )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
-
if ( !forMe( transfer ) )
return false;
-
+
YMSGTransfer *t = 0L;
t = dynamic_cast<YMSGTransfer*>(transfer);
if (!t)
return false;
switch( t->service() )
- {
+ {
case Yahoo::ServicePictureStatus:
parsePictureStatus( t );
+ parsePicture( t );
break;
case Yahoo::ServicePictureChecksum:
parsePictureChecksum( t );
+ parsePicture( t );
break;
case Yahoo::ServicePicture:
parsePicture( t );
@@ -63,16 +63,15 @@ bool PictureNotifierTask::take( Transfer* transfer )
break;
default:
break;
- }
+ }
return true;
}
-bool PictureNotifierTask::forMe( Transfer* transfer ) const
+bool PictureNotifierTask::forMe( const Transfer* transfer ) const
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
- YMSGTransfer *t = 0L;
- t = dynamic_cast<YMSGTransfer*>(transfer);
+ const YMSGTransfer *t = 0L;
+ t = dynamic_cast<const YMSGTransfer*>(transfer);
if (!t)
return false;
@@ -89,37 +88,37 @@ bool PictureNotifierTask::forMe( Transfer* transfer ) const
void PictureNotifierTask::parsePictureStatus( YMSGTransfer *t )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
QString nick; /* key = 4 */
int state; /* key = 213 */
nick = t->firstParam( 4 );
state = t->firstParam( 213 ).toInt();
-
+
emit pictureStatusNotify( nick, state );
}
void PictureNotifierTask::parsePictureChecksum( YMSGTransfer *t )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
QString nick; /* key = 4 */
int checksum; /* key = 192 */
nick = t->firstParam( 4 );
checksum = t->firstParam( 192 ).toInt();
-
+
if( nick != client()->userId() )
emit pictureChecksumNotify( nick, checksum );
}
void PictureNotifierTask::parsePicture( YMSGTransfer *t )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
QString nick; /* key = 4 */
- int type; /* key = 13: 1 = request, 2 = notification */
+ int type; /* key = 13: 1 = request, 2 = notification, 0 = Just changed */
QString url; /* key = 20 */
int checksum; /* key = 192 */
@@ -127,30 +126,34 @@ void PictureNotifierTask::parsePicture( YMSGTransfer *t )
url = t->firstParam( 20 );
checksum = t->firstParam( 192 ).toInt();
type = t->firstParam( 13 ).toInt();
-
+
if( type == 1 )
emit pictureRequest( nick );
+ else if( type == 0 )
+ emit pictureInfoNotify( nick, KURL( url ), checksum );
else if( type == 2 )
emit pictureInfoNotify( nick, KURL( url ), checksum );
}
void PictureNotifierTask::parsePictureUploadResponse( YMSGTransfer *t )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
QString url;
QString error;
+ int expires;
url = t->firstParam( 20 );
error = t->firstParam( 16 );
-
+ expires = t->firstParam( 38 ).toInt();
+
if( !error.isEmpty() )
client()->notifyError(i18n("The picture was not successfully uploaded"), error, Client::Error );
if( !url.isEmpty() )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Emitting url: " << url << endl;
- emit pictureUploaded( url );
+ kdDebug(YAHOO_RAW_DEBUG) << "Emitting url: " << url << " Picture expires: " << expires << endl;
+ emit pictureUploaded( url, expires );
}
}