summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/yahoo/libkyahoo
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
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')
-rw-r--r--kopete/protocols/yahoo/libkyahoo/Makefile.am4
-rw-r--r--kopete/protocols/yahoo/libkyahoo/changestatustask.cpp12
-rw-r--r--kopete/protocols/yahoo/libkyahoo/changestatustask.h4
-rw-r--r--kopete/protocols/yahoo/libkyahoo/chatsessiontask.cpp8
-rw-r--r--kopete/protocols/yahoo/libkyahoo/chatsessiontask.h2
-rw-r--r--kopete/protocols/yahoo/libkyahoo/client.cpp252
-rw-r--r--kopete/protocols/yahoo/libkyahoo/client.h304
-rw-r--r--kopete/protocols/yahoo/libkyahoo/conferencetask.cpp64
-rw-r--r--kopete/protocols/yahoo/libkyahoo/conferencetask.h6
-rw-r--r--kopete/protocols/yahoo/libkyahoo/connector.cpp2
-rw-r--r--kopete/protocols/yahoo/libkyahoo/connector.h2
-rw-r--r--kopete/protocols/yahoo/libkyahoo/coreprotocol.cpp109
-rw-r--r--kopete/protocols/yahoo/libkyahoo/coreprotocol.h42
-rw-r--r--kopete/protocols/yahoo/libkyahoo/filetransfernotifiertask.cpp63
-rw-r--r--kopete/protocols/yahoo/libkyahoo/filetransfernotifiertask.h7
-rw-r--r--kopete/protocols/yahoo/libkyahoo/inputprotocolbase.cpp6
-rw-r--r--kopete/protocols/yahoo/libkyahoo/inputprotocolbase.h4
-rw-r--r--kopete/protocols/yahoo/libkyahoo/listtask.cpp67
-rw-r--r--kopete/protocols/yahoo/libkyahoo/listtask.h10
-rw-r--r--kopete/protocols/yahoo/libkyahoo/logintask.cpp279
-rw-r--r--kopete/protocols/yahoo/libkyahoo/logintask.h25
-rw-r--r--kopete/protocols/yahoo/libkyahoo/logofftask.cpp10
-rw-r--r--kopete/protocols/yahoo/libkyahoo/logofftask.h3
-rw-r--r--kopete/protocols/yahoo/libkyahoo/mailnotifiertask.cpp18
-rw-r--r--kopete/protocols/yahoo/libkyahoo/mailnotifiertask.h4
-rw-r--r--kopete/protocols/yahoo/libkyahoo/md5.c4
-rw-r--r--kopete/protocols/yahoo/libkyahoo/messagereceivertask.cpp39
-rw-r--r--kopete/protocols/yahoo/libkyahoo/messagereceivertask.h4
-rw-r--r--kopete/protocols/yahoo/libkyahoo/modifybuddytask.cpp81
-rw-r--r--kopete/protocols/yahoo/libkyahoo/modifybuddytask.h14
-rw-r--r--kopete/protocols/yahoo/libkyahoo/modifyyabtask.cpp59
-rw-r--r--kopete/protocols/yahoo/libkyahoo/modifyyabtask.h4
-rw-r--r--kopete/protocols/yahoo/libkyahoo/oscartypes.h12
-rw-r--r--kopete/protocols/yahoo/libkyahoo/picturenotifiertask.cpp51
-rw-r--r--kopete/protocols/yahoo/libkyahoo/picturenotifiertask.h13
-rw-r--r--kopete/protocols/yahoo/libkyahoo/pingtask.cpp8
-rw-r--r--kopete/protocols/yahoo/libkyahoo/pingtask.h2
-rw-r--r--kopete/protocols/yahoo/libkyahoo/receivefiletask.cpp69
-rw-r--r--kopete/protocols/yahoo/libkyahoo/receivefiletask.h14
-rw-r--r--kopete/protocols/yahoo/libkyahoo/requestpicturetask.cpp12
-rw-r--r--kopete/protocols/yahoo/libkyahoo/requestpicturetask.h8
-rw-r--r--kopete/protocols/yahoo/libkyahoo/safedelete.cpp5
-rw-r--r--kopete/protocols/yahoo/libkyahoo/safedelete.h2
-rw-r--r--kopete/protocols/yahoo/libkyahoo/sendauthresptask.cpp6
-rw-r--r--kopete/protocols/yahoo/libkyahoo/sendauthresptask.h2
-rw-r--r--kopete/protocols/yahoo/libkyahoo/sendfiletask.cpp217
-rw-r--r--kopete/protocols/yahoo/libkyahoo/sendfiletask.h19
-rw-r--r--kopete/protocols/yahoo/libkyahoo/sendmessagetask.cpp14
-rw-r--r--kopete/protocols/yahoo/libkyahoo/sendmessagetask.h2
-rw-r--r--kopete/protocols/yahoo/libkyahoo/sendnotifytask.cpp26
-rw-r--r--kopete/protocols/yahoo/libkyahoo/sendnotifytask.h2
-rw-r--r--kopete/protocols/yahoo/libkyahoo/sendpicturetask.cpp116
-rw-r--r--kopete/protocols/yahoo/libkyahoo/sendpicturetask.h12
-rw-r--r--kopete/protocols/yahoo/libkyahoo/sha1.c8
-rw-r--r--kopete/protocols/yahoo/libkyahoo/sha1.h1
-rw-r--r--kopete/protocols/yahoo/libkyahoo/statusnotifiertask.cpp49
-rw-r--r--kopete/protocols/yahoo/libkyahoo/statusnotifiertask.h7
-rw-r--r--kopete/protocols/yahoo/libkyahoo/stealthtask.cpp17
-rw-r--r--kopete/protocols/yahoo/libkyahoo/stealthtask.h2
-rw-r--r--kopete/protocols/yahoo/libkyahoo/stream.cpp2
-rw-r--r--kopete/protocols/yahoo/libkyahoo/stream.h4
-rw-r--r--kopete/protocols/yahoo/libkyahoo/task.cpp29
-rw-r--r--kopete/protocols/yahoo/libkyahoo/task.h3
-rw-r--r--kopete/protocols/yahoo/libkyahoo/webcamtask.cpp217
-rw-r--r--kopete/protocols/yahoo/libkyahoo/webcamtask.h13
-rw-r--r--kopete/protocols/yahoo/libkyahoo/yabentry.cpp86
-rw-r--r--kopete/protocols/yahoo/libkyahoo/yabentry.h4
-rw-r--r--kopete/protocols/yahoo/libkyahoo/yabtask.cpp47
-rw-r--r--kopete/protocols/yahoo/libkyahoo/yabtask.h13
-rw-r--r--kopete/protocols/yahoo/libkyahoo/yahoo_fn.h5
-rw-r--r--kopete/protocols/yahoo/libkyahoo/yahoobuddyiconloader.cpp37
-rw-r--r--kopete/protocols/yahoo/libkyahoo/yahoobuddyiconloader.h10
-rw-r--r--kopete/protocols/yahoo/libkyahoo/yahoobytestream.cpp23
-rw-r--r--kopete/protocols/yahoo/libkyahoo/yahoobytestream.h11
-rw-r--r--kopete/protocols/yahoo/libkyahoo/yahooclientstream.cpp76
-rw-r--r--kopete/protocols/yahoo/libkyahoo/yahooclientstream.h37
-rw-r--r--kopete/protocols/yahoo/libkyahoo/yahooconnector.cpp18
-rw-r--r--kopete/protocols/yahoo/libkyahoo/yahooconnector.h3
-rw-r--r--kopete/protocols/yahoo/libkyahoo/yahootypes.h54
-rw-r--r--kopete/protocols/yahoo/libkyahoo/ymsgprotocol.cpp237
-rw-r--r--kopete/protocols/yahoo/libkyahoo/ymsgprotocol.h14
-rw-r--r--kopete/protocols/yahoo/libkyahoo/ymsgtransfer.cpp65
-rw-r--r--kopete/protocols/yahoo/libkyahoo/ymsgtransfer.h34
83 files changed, 1993 insertions, 1257 deletions
diff --git a/kopete/protocols/yahoo/libkyahoo/Makefile.am b/kopete/protocols/yahoo/libkyahoo/Makefile.am
index b5e8e034..8524b4b1 100644
--- a/kopete/protocols/yahoo/libkyahoo/Makefile.am
+++ b/kopete/protocols/yahoo/libkyahoo/Makefile.am
@@ -14,10 +14,10 @@ libkyahoo_la_SOURCES = client.cpp task.cpp connector.cpp inputprotocolbase.cpp \
requestpicturetask.cpp yahoobuddyiconloader.cpp stealthtask.cpp sendpicturetask.cpp \
webcamtask.cpp conferencetask.cpp sendauthresptask.cpp pingtask.cpp yabtask.cpp \
yabentry.cpp modifyyabtask.cpp chatsessiontask.cpp sendfiletask.cpp filetransfernotifiertask.cpp \
- receivefiletask.cpp
+ receivefiletask.cpp yahoochattask.cpp
libkyahoo_la_LDFLAGS = -no-undefined $(all_libraries)
libkyahoo_la_LIBADD = $(LIB_QT)
noinst_HEADERS = logintask.h yabentry.h yabtask.h modifyyabtask.h \
- chatsessiontask.h
+ chatsessiontask.h yahoochattask.h
KDE_OPTIONS = nofinal
diff --git a/kopete/protocols/yahoo/libkyahoo/changestatustask.cpp b/kopete/protocols/yahoo/libkyahoo/changestatustask.cpp
index a4da7b57..3d73920c 100644
--- a/kopete/protocols/yahoo/libkyahoo/changestatustask.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/changestatustask.cpp
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Change our Status
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005-2006 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -19,12 +19,12 @@
#include "ymsgtransfer.h"
#include "yahootypes.h"
#include "client.h"
-#include <qstring.h>
+
#include <kdebug.h>
ChangeStatusTask::ChangeStatusTask(Task* parent) : Task(parent)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
}
ChangeStatusTask::~ChangeStatusTask()
@@ -33,7 +33,7 @@ ChangeStatusTask::~ChangeStatusTask()
void ChangeStatusTask::onGo()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
if( m_status == Yahoo::StatusInvisible ) // status --> Invisible
{
@@ -52,13 +52,13 @@ void ChangeStatusTask::onGo()
t->setParam( 10, m_status );
t->setParam( 47, m_type );
t->setParam( 97, 1 ); // it's utf8
-
+
send( t );
if( client()->status() == Yahoo::StatusInvisible ) // Invisible --> Status
sendVisibility( Visible );
}
- setSuccess( true );
+ setSuccess();
}
void ChangeStatusTask::sendVisibility( Visibility visible )
diff --git a/kopete/protocols/yahoo/libkyahoo/changestatustask.h b/kopete/protocols/yahoo/libkyahoo/changestatustask.h
index 5455c665..22c48031 100644
--- a/kopete/protocols/yahoo/libkyahoo/changestatustask.h
+++ b/kopete/protocols/yahoo/libkyahoo/changestatustask.h
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Change our Status
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -32,7 +32,7 @@ public:
enum Type { Available, Away };
ChangeStatusTask(Task *parent);
~ChangeStatusTask();
-
+
virtual void onGo();
void setMessage( const QString &msg );
diff --git a/kopete/protocols/yahoo/libkyahoo/chatsessiontask.cpp b/kopete/protocols/yahoo/libkyahoo/chatsessiontask.cpp
index 553297e9..cacd7f80 100644
--- a/kopete/protocols/yahoo/libkyahoo/chatsessiontask.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/chatsessiontask.cpp
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
chatsessiontask.cpp - Register / Unregister a chatsession
- Copyright (c) 2006 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2006 André Duffeck <duffeck@kde.org>
Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
@@ -26,7 +26,7 @@
ChatSessionTask::ChatSessionTask(Task* parent) : Task(parent)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
}
ChatSessionTask::~ChatSessionTask()
@@ -35,7 +35,7 @@ ChatSessionTask::~ChatSessionTask()
void ChatSessionTask::onGo()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
YMSGTransfer *t = new YMSGTransfer( Yahoo::ServiceChatSession );
t->setId( client()->sessionID() );
@@ -52,7 +52,7 @@ void ChatSessionTask::onGo()
}
send( t );
- setSuccess( true );
+ setSuccess();
}
void ChatSessionTask::setTarget( const QString &to )
diff --git a/kopete/protocols/yahoo/libkyahoo/chatsessiontask.h b/kopete/protocols/yahoo/libkyahoo/chatsessiontask.h
index b5b5c76c..964ff411 100644
--- a/kopete/protocols/yahoo/libkyahoo/chatsessiontask.h
+++ b/kopete/protocols/yahoo/libkyahoo/chatsessiontask.h
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
chatsessiontask.h - Register / Unregister a chatsession
- Copyright (c) 2006 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2006 André Duffeck <duffeck@kde.org>
Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
diff --git a/kopete/protocols/yahoo/libkyahoo/client.cpp b/kopete/protocols/yahoo/libkyahoo/client.cpp
index 186f1e12..710da771 100644
--- a/kopete/protocols/yahoo/libkyahoo/client.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/client.cpp
@@ -1,14 +1,14 @@
/*
Kopete Yahoo Protocol
-
- Copyright (c) 2005-2006 André Duffeck <andre.duffeck@kdemail.net>
+
+ Copyright (c) 2005-2006 André Duffeck <duffeck@kde.org>
Copyright (c) 2004 Duncan Mac-Vicar P. <duncan@kde.org>
Copyright (c) 2004 Matt Rogers <matt.rogers@kdemail.net>
Copyright (c) 2004 SuSE Linux AG <http://www.suse.com>
- Copyright (C) 2003 Justin Karneges
-
+ Copyright (C) 2003 Justin Karneges <justin@affinix.com>
+
Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
-
+
*************************************************************************
* *
* This library is free software; you can redistribute it and/or *
@@ -20,9 +20,9 @@
*/
#include <qtimer.h>
+#include <qpixmap.h>
#include <kdebug.h>
-#include <kurl.h>
#include <ksocketbase.h>
#include "yahooclientstream.h"
@@ -52,6 +52,7 @@
#include "sendfiletask.h"
#include "filetransfernotifiertask.h"
#include "receivefiletask.h"
+#include "yahoochattask.h"
#include "client.h"
#include "yahootypes.h"
#include "yahoobuddyiconloader.h"
@@ -73,7 +74,7 @@ public:
int error;
QString errorString;
QString errorInformation;
-
+
// tasks
bool tasksInitialized;
LoginTask * loginTask;
@@ -86,6 +87,8 @@ public:
ConferenceTask *conferenceTask;
YABTask *yabTask;
FileTransferNotifierTask *fileTransferTask;
+ YahooChatTask *yahooChatTask;
+ ReceiveFileTask *receiveFileTask;
// Connection data
uint sessionID;
@@ -95,10 +98,13 @@ public:
Yahoo::Status status;
Yahoo::Status statusOnConnect;
QString statusMessageOnConnect;
- int pictureFlag;
+ Yahoo::PictureStatus pictureFlag;
+ int pictureChecksum;
+ bool buddyListReady;
+ QStringList pictureRequestQueue;
};
-Client::Client(QObject *par) :QObject(par, "yahooclient" )
+Client::Client(QObject *par) :QObject(par, "yahooclient")
{
d = new ClientPrivate;
/* d->tzoffset = 0;*/
@@ -112,19 +118,21 @@ Client::Client(QObject *par) :QObject(par, "yahooclient" )
d->iconLoader = 0L;
d->loginTask = new LoginTask( d->root );
d->listTask = new ListTask( d->root );
- d->pictureFlag = 0;
+ d->pictureFlag = Yahoo::NoPicture;
+ d->buddyListReady = false;
m_connector = 0L;
m_pingTimer = new QTimer( this );
QObject::connect( m_pingTimer, SIGNAL( timeout() ), this, SLOT( sendPing() ) );
QObject::connect( d->loginTask, SIGNAL( haveSessionID( uint ) ), SLOT( lt_gotSessionID( uint ) ) );
- QObject::connect( d->loginTask, SIGNAL( loginResponse( int, const QString& ) ),
+ QObject::connect( d->loginTask, SIGNAL( buddyListReady() ), SLOT( processPictureQueue() ) );
+ QObject::connect( d->loginTask, SIGNAL( loginResponse( int, const QString& ) ),
SLOT( slotLoginResponse( int, const QString& ) ) );
QObject::connect( d->loginTask, SIGNAL( haveCookies() ), SLOT( slotGotCookies() ) );
- QObject::connect( d->listTask, SIGNAL( gotBuddy(const QString &, const QString &, const QString &) ),
+ QObject::connect( d->listTask, SIGNAL( gotBuddy(const QString &, const QString &, const QString &) ),
SIGNAL( gotBuddy(const QString &, const QString &, const QString &) ) );
- QObject::connect( d->listTask, SIGNAL( stealthStatusChanged( const QString&, Yahoo::StealthStatus ) ),
+ QObject::connect( d->listTask, SIGNAL( stealthStatusChanged( const QString&, Yahoo::StealthStatus ) ),
SIGNAL( stealthStatusChanged( const QString&, Yahoo::StealthStatus ) ) );
}
@@ -138,7 +146,7 @@ Client::~Client()
void Client::connect( const QString &host, const uint port, const QString &userId, const QString &pass )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
d->host = host;
d->port = port;
d->user = userId;
@@ -151,7 +159,8 @@ void Client::connect( const QString &host, const uint port, const QString &userI
QObject::connect( d->stream, SIGNAL( connected() ), this, SLOT( cs_connected() ) );
QObject::connect( d->stream, SIGNAL( error(int) ), this, SLOT( streamError(int) ) );
QObject::connect( d->stream, SIGNAL( readyRead() ), this, SLOT( streamReadyRead() ) );
-
+ QObject::connect( d->stream, SIGNAL( connectionClosed() ), this, SLOT( streamDisconnected() ) );
+
d->stream->connectToServer( host, false );
}
@@ -162,9 +171,9 @@ void Client::cancelConnect()
void Client::cs_connected()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
emit connected();
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " starting login task ... "<< endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " starting login task ... " << endl;
d->loginTask->setStateOnConnect( (d->statusOnConnect == Yahoo::StatusInvisible) ? Yahoo::StatusInvisible : Yahoo::StatusAvailable );
d->loginTask->go();
@@ -173,7 +182,7 @@ void Client::cs_connected()
void Client::close()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
m_pingTimer->stop();
if( d->active )
{
@@ -181,7 +190,7 @@ void Client::close()
lt->go( true );
}
if( d->tasksInitialized)
- deleteTasks();
+ deleteTasks();
d->loginTask->reset();
if( d->stream ) {
QObject::disconnect( d->stream, SIGNAL( readyRead() ), this, SLOT( streamReadyRead() ) );
@@ -191,6 +200,8 @@ void Client::close()
if( m_connector )
m_connector->deleteLater();
m_connector = 0L;
+ d->active = false;
+ d->buddyListReady = false;
}
int Client::error()
@@ -211,18 +222,18 @@ QString Client::errorInformation()
// SLOTS //
void Client::streamError( int error )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "CLIENT ERROR (Error " << error << ")" << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "CLIENT ERROR (Error " << error << ")" << endl;
QString msg;
d->active = false;
// Examine error
- if( error == ClientStream::ErrConnection ) // Ask Connector in this case
+ if( error == ClientStream::ErrConnection && m_connector ) // Ask Connector in this case
{
d->error = m_connector->errorCode();
d->errorString = KSocketBase::errorString( (KSocketBase::SocketError)d->error );
}
- else
+ else if( d->stream )
{
d->error = error;
d->errorString = d->stream->errorText();
@@ -241,9 +252,15 @@ void Client::streamReadyRead()
distribute( transfer );
}
+void Client::streamDisconnected()
+{
+ d->active = false;
+ emit disconnected();
+}
+
void Client::lt_loginFinished()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
slotLoginResponse( d->loginTask->statusCode(), d->loginTask->statusString() );
}
@@ -258,26 +275,27 @@ void Client::slotLoginResponse( int response, const QString &msg )
changeStatus( d->statusOnConnect, d->statusMessageOnConnect, Yahoo::StatusTypeAway );
d->statusMessageOnConnect = QString::null;
setStatus( d->statusOnConnect );
- m_pingTimer->start( 60 * 1000 );
+ /* only send a ping every hour. we get disconnected otherwise */
+ m_pingTimer->start( 60 * 60 * 1000 );
initTasks();
} else {
d->active = false;
close();
}
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Emitting loggedIn" << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "Emitting loggedIn" << endl;
emit loggedIn( response, msg );
}
void Client::lt_gotSessionID( uint id )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Got SessionID: " << id << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "Got SessionID: " << id << endl;
d->sessionID = id;
}
void Client::slotGotCookies()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Y: " << d->loginTask->yCookie()
+ kdDebug(YAHOO_RAW_DEBUG) << "Y: " << d->loginTask->yCookie()
<< " T: " << d->loginTask->tCookie()
<< " C: " << d->loginTask->cCookie() << endl;
d->yCookie = d->loginTask->yCookie();
@@ -388,17 +406,17 @@ void Client::cancelFileTransfer( unsigned int transferId )
void Client::changeStatus( Yahoo::Status status, const QString &message, Yahoo::StatusType type )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "status: " << status
+ kdDebug(YAHOO_RAW_DEBUG) << "status: " << status
<< " message: " << message
- << " type: " << type << endl;
+ << " type: " << type << endl;
ChangeStatusTask *cst = new ChangeStatusTask( d->root );
cst->setStatus( status );
cst->setMessage( message );
cst->setType( type );
cst->go( true );
-
+
if( status == Yahoo::StatusInvisible )
- stealthContact( QString::null, Yahoo::StealthOnline, Yahoo::StealthClear );
+ stealthContact( QString(), Yahoo::StealthOnline, Yahoo::StealthClear );
setStatus( status );
}
@@ -416,10 +434,10 @@ void Client::sendPing()
{
if( !d->active )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Disconnected. NOT sending a PING." << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "Disconnected. NOT sending a PING." << endl;
return;
}
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Sending a PING." << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "Sending a PING." << endl;
PingTask *pt = new PingTask( d->root );
pt->go( true );
}
@@ -438,6 +456,10 @@ void Client::stealthContact(QString const &userId, Yahoo::StealthMode mode, Yaho
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 );
@@ -448,6 +470,10 @@ void Client::addBuddy( const QString &userId, const QString &group, const QStrin
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 );
@@ -457,6 +483,10 @@ void Client::removeBuddy( const QString &userId, const QString &group )
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 );
@@ -466,8 +496,33 @@ void Client::moveBuddy( const QString &userId, const QString &oldGroup, const QS
// ***** Buddyicon handling *****
+void Client::processPictureQueue()
+{
+ kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ d->buddyListReady = true;
+ if( d->pictureRequestQueue.isEmpty() )
+ {
+ return;
+ }
+
+ requestPicture( d->pictureRequestQueue.front() );
+ d->pictureRequestQueue.pop_front();
+
+
+ if( !d->pictureRequestQueue.isEmpty() )
+ {
+ QTimer::singleShot( 1000, this, SLOT(processPictureQueue()) );
+ }
+}
+
void Client::requestPicture( const QString &userId )
{
+ if( !d->buddyListReady )
+ {
+ d->pictureRequestQueue << userId;
+ return;
+ }
+
RequestPictureTask *rpt = new RequestPictureTask( d->root );
rpt->setTarget( userId );
rpt->go( true );
@@ -478,8 +533,8 @@ void Client::downloadPicture( const QString &userId, KURL url, int checksum )
if( !d->iconLoader )
{
d->iconLoader = new YahooBuddyIconLoader( this );
- QObject::connect( d->iconLoader, SIGNAL(fetchedBuddyIcon(const QString&, KTempFile*, int )),
- SIGNAL(pictureDownloaded(const QString&, KTempFile*, int ) ) );
+ QObject::connect( d->iconLoader, SIGNAL(fetchedBuddyIcon(const QString&, const QByteArray &, int )),
+ SIGNAL(pictureDownloaded(const QString&, const QByteArray &, int ) ) );
}
d->iconLoader->fetchBuddyIcon( QString(userId), KURL(url), checksum );
@@ -487,32 +542,31 @@ void Client::downloadPicture( const QString &userId, KURL url, int checksum )
void Client::uploadPicture( KURL url )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "URL: " << url.url() << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "URL: " << url.url() << endl;
SendPictureTask *spt = new SendPictureTask( d->root );
spt->setType( SendPictureTask::UploadPicture );
spt->setFilename( url.fileName() );
if ( url.isLocalFile() )
- spt->setPath( url.path() );
+ spt->setPath( url.path() ); // FIXME: to test if is what we want
else
spt->setPath( url.url() );
- d->pictureFlag = 2;
spt->go( true );
}
-void Client::sendPictureChecksum( int checksum, const QString &who )
+void Client::sendPictureChecksum( const QString &userId, int checksum )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "checksum: " << checksum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "checksum: " << checksum << endl;
SendPictureTask *spt = new SendPictureTask( d->root );
spt->setType( SendPictureTask::SendChecksum );
spt->setChecksum( checksum );
- if( !who.isEmpty() )
- spt->setTarget( who );
- spt->go( true );
+ if( !userId.isEmpty() )
+ spt->setTarget( userId );
+ spt->go( true );
}
void Client::sendPictureInformation( const QString &userId, const QString &url, int checksum )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "checksum: " << checksum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "checksum: " << checksum << endl;
SendPictureTask *spt = new SendPictureTask( d->root );
spt->setType( SendPictureTask::SendInformation );
spt->setChecksum( checksum );
@@ -521,13 +575,16 @@ void Client::sendPictureInformation( const QString &userId, const QString &url,
spt->go( true );
}
-void Client::sendPictureStatusUpdate( const QString &userId, int type )
+void Client::setPictureStatus( Yahoo::PictureStatus status )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Setting PictureStatus to: " << type << endl;
+ if( d->pictureFlag == status )
+ return;
+
+ kdDebug(YAHOO_RAW_DEBUG) << "Setting PictureStatus to: " << status << endl;
+ d->pictureFlag = status;
SendPictureTask *spt = new SendPictureTask( d->root );
spt->setType( SendPictureTask::SendStatus );
- spt->setStatus( type );
- spt->setTarget( userId );
+ spt->setStatus( status );
spt->go( true );
}
@@ -624,10 +681,36 @@ void Client::deleteYABEntry( YABEntry &entry )
myt->go(true);
}
+// ***** Yahoo Chat *****
+void Client::getYahooChatCategories()
+{
+ d->yahooChatTask->getYahooChatCategories();
+}
+
+void Client::getYahooChatRooms( const Yahoo::ChatCategory &category )
+{
+ d->yahooChatTask->getYahooChatRooms( category );
+}
+
+void Client::joinYahooChatRoom( const Yahoo::ChatRoom &room )
+{
+ d->yahooChatTask->joinRoom( room );
+}
+
+void Client::sendYahooChatMessage( const QString &msg, const QString &handle )
+{
+ d->yahooChatTask->sendYahooChatMessage( msg, handle );
+}
+
+void Client::leaveChat()
+{
+ d->yahooChatTask->logout();
+}
+
// ***** other *****
void Client::notifyError( const QString &info, const QString & errorString, LogLevel level )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << QString::fromLatin1("\nThe following error occured: %1\n Reason: %2\n LogLevel: %3")
+ kdDebug(YAHOO_RAW_DEBUG) << QString::fromLatin1("\nThe following error occurred: %1\n Reason: %2\n LogLevel: %3")
.arg(info).arg(errorString).arg(level) << endl;
d->errorString = errorString;
d->errorInformation = info;
@@ -675,12 +758,6 @@ QString Client::password()
return d->pass;
}
-QCString Client::ipAddress()
-{
- //TODO determine ip address
- return "127.0.0.1";
-}
-
QString Client::host()
{
return d->host;
@@ -701,9 +778,14 @@ int Client::pictureFlag()
return d->pictureFlag;
}
-void Client::setPictureFlag( int flag )
+int Client::pictureChecksum()
+{
+ return d->pictureChecksum;
+}
+
+void Client::setPictureChecksum( int cs )
{
- d->pictureFlag = flag;
+ d->pictureChecksum = cs;
}
QString Client::yCookie()
@@ -723,7 +805,7 @@ QString Client::cCookie()
void Client::distribute( Transfer * transfer )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
if( !rootTask()->take( transfer ) )
kdDebug(YAHOO_RAW_DEBUG) << "CLIENT: root task refused transfer" << endl;
delete transfer;
@@ -731,9 +813,9 @@ void Client::distribute( Transfer * transfer )
void Client::send( Transfer* request )
{
- kdDebug(YAHOO_RAW_DEBUG) << "CLIENT::send()"<< endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "CLIENT::send()" << endl;
if( !d->stream )
- {
+ {
kdDebug(YAHOO_RAW_DEBUG) << "CLIENT - NO STREAM TO SEND ON!" << endl;
return;
}
@@ -743,7 +825,7 @@ void Client::send( Transfer* request )
void Client::debug(const QString &str)
{
- qDebug( "CLIENT: %s", str.ascii() );
+ qDebug( "CLIENT: %s", str.ascii() );
}
Task * Client::rootTask()
@@ -757,23 +839,21 @@ void Client::initTasks()
return;
d->statusTask = new StatusNotifierTask( d->root );
- QObject::connect( d->statusTask, SIGNAL( statusChanged( const QString&, int, const QString&, int, int ) ),
- SIGNAL( statusChanged( const QString&, int, const QString&, int, int ) ) );
- QObject::connect( d->statusTask, SIGNAL( stealthStatusChanged( const QString&, Yahoo::StealthStatus ) ),
+ QObject::connect( d->statusTask, SIGNAL( statusChanged(const QString&,int,const QString&,int,int,int) ),
+ SIGNAL( statusChanged(const QString&,int,const QString&,int,int,int) ) );
+ QObject::connect( d->statusTask, SIGNAL( stealthStatusChanged( const QString&, Yahoo::StealthStatus ) ),
SIGNAL( stealthStatusChanged( const QString&, Yahoo::StealthStatus ) ) );
- QObject::connect( d->statusTask, SIGNAL( loginResponse( int, const QString& ) ),
+ QObject::connect( d->statusTask, SIGNAL( loginResponse( int, const QString& ) ),
SLOT( slotLoginResponse( int, const QString& ) ) );
- QObject::connect( d->statusTask, SIGNAL( authorizationRejected( const QString&, const QString& ) ),
+ QObject::connect( d->statusTask, SIGNAL( authorizationRejected( const QString&, const QString& ) ),
SIGNAL( authorizationRejected( const QString&, const QString& ) ) );
- QObject::connect( d->statusTask, SIGNAL( authorizationAccepted( const QString& ) ),
+ QObject::connect( d->statusTask, SIGNAL( authorizationAccepted( const QString& ) ),
SIGNAL( authorizationAccepted( const QString& ) ) );
- QObject::connect( d->statusTask, SIGNAL( gotAuthorizationRequest( const QString &, const QString &, const QString & ) ),
+ QObject::connect( d->statusTask, SIGNAL( gotAuthorizationRequest( const QString &, const QString &, const QString & ) ),
SIGNAL( gotAuthorizationRequest( const QString &, const QString &, const QString & ) ) );
- QObject::connect( d->statusTask, SIGNAL( gotPictureChecksum( const QString &, int ) ),
- SIGNAL( pictureChecksumNotify( const QString &, int ) ) );
d->mailTask = new MailNotifierTask( d->root );
- QObject::connect( d->mailTask, SIGNAL( mailNotify(const QString&, const QString&, int) ),
+ QObject::connect( d->mailTask, SIGNAL( mailNotify(const QString&, const QString&, int) ),
SIGNAL( mailNotify(const QString&, const QString&, int) ) );
d->messageReceiverTask = new MessageReceiverTask( d->root );
@@ -797,8 +877,8 @@ void Client::initTasks()
SIGNAL( pictureInfoNotify( const QString &, KURL, int ) ) );
QObject::connect( d->pictureNotifierTask, SIGNAL( pictureRequest( const QString & ) ),
SIGNAL( pictureRequest( const QString & ) ) );
- QObject::connect( d->pictureNotifierTask, SIGNAL( pictureUploaded( const QString & ) ),
- SIGNAL( pictureUploaded( const QString & ) ) );
+ QObject::connect( d->pictureNotifierTask, SIGNAL( pictureUploaded( const QString &, int ) ),
+ SIGNAL( pictureUploaded( const QString &, int ) ) );
d->webcamTask = new WebcamTask( d->root );
QObject::connect( d->webcamTask, SIGNAL( webcamImageReceived( const QString &, const QPixmap &) ),
@@ -839,10 +919,24 @@ void Client::initTasks()
SIGNAL( gotYABRevision( long, bool ) ) );
d->fileTransferTask = new FileTransferNotifierTask( d->root );
- QObject::connect( d->fileTransferTask, SIGNAL(incomingFileTransfer( const QString &, const QString &,
- long, const QString &, const QString &, unsigned long )),
- SIGNAL(incomingFileTransfer( const QString &, const QString &,
- long, const QString &, const QString &, unsigned long )) );
+ QObject::connect( d->fileTransferTask, SIGNAL(incomingFileTransfer( const QString &, const QString &,
+ long, const QString &, const QString &, unsigned long, const QPixmap & )),
+ SIGNAL(incomingFileTransfer( const QString &, const QString &,
+ long, const QString &, const QString &, unsigned long, const QPixmap & )) );
+
+ d->yahooChatTask = new YahooChatTask( d->root );
+ QObject::connect( d->yahooChatTask, SIGNAL(gotYahooChatCategories( const QDomDocument & )),
+ SIGNAL(gotYahooChatCategories( const QDomDocument & )) );
+ QObject::connect( d->yahooChatTask, SIGNAL(gotYahooChatRooms( const Yahoo::ChatCategory &, const QDomDocument & )),
+ SIGNAL(gotYahooChatRooms( const Yahoo::ChatCategory &, const QDomDocument & )) );
+ QObject::connect( d->yahooChatTask, SIGNAL(chatRoomJoined( int , int , const QString &, const QString & ) ),
+ SIGNAL(chatRoomJoined( int , int , const QString &, const QString & ) ) );
+ QObject::connect( d->yahooChatTask, SIGNAL(chatBuddyHasJoined( const QString &, const QString &, bool ) ),
+ SIGNAL(chatBuddyHasJoined( const QString &, const QString &, bool ) ) );
+ QObject::connect( d->yahooChatTask, SIGNAL(chatBuddyHasLeft(QString,QString) ),
+ SIGNAL(chatBuddyHasLeft(QString,QString) ) );
+ QObject::connect( d->yahooChatTask, SIGNAL(chatMessageReceived( const QString &, const QString &, const QString & ) ),
+ SIGNAL(chatMessageReceived( const QString &, const QString &, const QString & ) ) );
}
void Client::deleteTasks()
@@ -864,6 +958,10 @@ void Client::deleteTasks()
d->yabTask = 0L;
d->fileTransferTask->deleteLater();
d->fileTransferTask = 0;
+ d->yahooChatTask->deleteLater();
+ d->yahooChatTask = 0;
+ d->receiveFileTask->deleteLater();
+ d->receiveFileTask = 0;
}
#include "client.moc"
diff --git a/kopete/protocols/yahoo/libkyahoo/client.h b/kopete/protocols/yahoo/libkyahoo/client.h
index 711336f0..f4a3fef5 100644
--- a/kopete/protocols/yahoo/libkyahoo/client.h
+++ b/kopete/protocols/yahoo/libkyahoo/client.h
@@ -1,14 +1,14 @@
/*
Kopete Yahoo Protocol
-
- Copyright (c) 2005-2006 André Duffeck <andre.duffeck@kdemail.net>
+
+ Copyright (c) 2005-2006 André Duffeck <duffeck@kde.org>
Copyright (c) 2004 Duncan Mac-Vicar P. <duncan@kde.org>
Copyright (c) 2004 Matt Rogers <matt.rogers@kdemail.net>
Copyright (c) 2004 SuSE Linux AG <http://www.suse.com>
- Copyright (C) 2003 Justin Karneges
-
- Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
-
+ Copyright (C) 2003 Justin Karneges <justin@affinix.com>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
*************************************************************************
* *
* This library is free software; you can redistribute it and/or *
@@ -23,77 +23,80 @@
#define LIBYAHOO_CLIENT_H
#include <qobject.h>
+#include <kurl.h>
#include "transfer.h"
#include "yahootypes.h"
-#define YMSG_PROGRAM_VERSION_STRING "7,5,0,33"
+#define YMSG_PROGRAM_VERSION_STRING "8.1.0.209"
class QString;
class QTimer;
+class QPixmap;
+class QDomDocument;
class ClientStream;
class KNetworkConnector;
class Task;
-class KURL;
-class KTempFile;
-class YABEntry;
-class SendFileTask;
+class KTemporaryFile;
+struct YABEntry;
class Client : public QObject
{
Q_OBJECT
public:
-
+
/*************
- EXTERNAL API
+ EXTERNAL API
*************/
- enum LogLevel { Debug, Info, Notice, Warning, Error, Critical };
-
+ enum LogLevel { Debug, Info, Notice, Warning, Error, Critical };
+
Client(QObject *parent=0);
~Client();
+
+ /**
+ * Set the Yahoo Id of the account
+ * @param username The Yahoo Id
+ */
void setUserId( const QString& userName );
/**
+ * Set the picture checksum
+ * @param username The checksum
+ */
+ void setPictureChecksum( int cs );
+
+ /**
* Start a connection to the server using the supplied @ref ClientStream.
* This is only a transport layer connection.
* Needed for protocol action P1.
- * @param s initialised client stream to use for the connection.
- * @param server the server to connect to - but this is also set on the connector used to construct the clientstream??
- * @param auth indicate whether we're connecting to the authorizer or the bos server
+ * @param host The server to connect to.
+ * @param port The port to be used. The Yahoo server allows connection on arbitrary ports.
+ * @param userId The yahoo ID that will be connected.
+ * @param pass The password.
*/
void connect( const QString &host, const uint port, const QString &userId, const QString &pass );
- /**
- * Cancel active login attemps
- */
+ /** Cancel active login attemps */
void cancelConnect();
- /**
- * Logout and disconnect
- */
+ /** Logout and disconnect */
void close();
- /**
- * Returns the errorcode
- */
+ /** Returns the errorcode */
int error();
- /**
- * Returns a description of the error
- */
+ /** Returns a description of the error */
QString errorString();
- /**
- * Returns information about what went wrong
- */
+ /** Returns information about what went wrong */
QString errorInformation();
/**
- * Specifies the status we connect with.
+ * Specifies the status we connect with.
* The Yahoo protocol supports connecting into Online and Invisible state.
- * If status is any other status the Client connects into Online state and changes into the specified state after the login.
+ * If status is any other status the Client connects into Online state and changes into the specified state after the login.
* @param status the status to connect with
*/
void setStatusOnConnect( Yahoo::Status status );
@@ -106,22 +109,9 @@ Q_OBJECT
*/
void setStatusMessageOnConnect( const QString &msg );
- /**
- * Accessors needed for login
- */
+ /** Accessors needed for login */
QString host();
int port();
-
- /**
- * return the pictureFlag describing the status of our buddy icon
- * 0 = no icon, 2 = icon, 1 = avatar (?)
- */
- int pictureFlag();
-
- /**
- * set the pictureFlag describing the status of our buddy icon
- */
- void setPictureFlag( int flag );
/**
* Send a Typing notification
@@ -129,7 +119,7 @@ Q_OBJECT
* @param typing true if there is typing activity, false if not
*/
void sendTyping( const QString &to, bool typing );
-
+
/**
* Send a Message
* @param to the buddy that should receive the message
@@ -139,7 +129,7 @@ Q_OBJECT
/**
* Register / Unregister a chatsession
- * @param to the buddy, the chatsession belongs to
+ * @param to the buddy, the chatsession belongs to
* @param close if true, the chatsession will be closed, if false, it will be opened
*/
void setChatSessionState( const QString &to, bool close );
@@ -155,7 +145,7 @@ Q_OBJECT
* @param status the status that will be set
* @param message the status message that will be set
* @param type Yahoo::StatusTypeAvailable means that the user is available, Yahoo::StatusTypeAway means that the user is away from the keyboard
- */
+ */
void changeStatus(Yahoo::Status status, const QString &message, Yahoo::StatusType type);
/**
@@ -175,200 +165,281 @@ Q_OBJECT
/**
* Remove a buddy from the contact list
+ * @param userId the yahoo ID of the buddy that should be removed
+ * @param group the group where the buddy belongs to
*/
void removeBuddy( const QString &userId, const QString &group );
/**
* Move a buddy into another group
+ * @param userId the yahoo ID of the buddy that should be moved
+ * @param oldGroup the group where the buddy belongs to
+ * @param newGroup the group where the buddy will be placed
*/
void moveBuddy( const QString &userId, const QString &oldGroup, const QString &newGroup );
/**
* Change the stealth status of a buddy
+ * @param userId the yahoo ID of the buddy that should be moved
+ * @param mode defines the Stealth mode that is changed. That can be "Appear Offline", "Appear Online" or "Apper permanently offline"
+ * @param state the status of the specified Stealth mode. Active, Not Active or Clear
*/
void stealthContact( QString const &userId, Yahoo::StealthMode mode, Yahoo::StealthStatus state );
/**
* Request the buddy's picture
+ * @param userId the yahoo ID of the buddy
*/
void requestPicture( const QString &userId );
/**
* Download the buddy's picture
+ * @param userId the yahoo ID of the buddy
+ * @param url the url of the picture
+ * @param checksum the checksum of the picture
*/
void downloadPicture( const QString &userId, KURL url, int checksum );
/**
* Send our picture
+ * @param url the file that should be sent as our buddy picture
*/
void uploadPicture( KURL url );
/**
* Send checksum of our picture
+ * @param userId the yahoo ID of the buddy. Can be a null string if the picture has changed.
+ * @param checksum the checksum of the picture
*/
- void sendPictureChecksum( int checksum, const QString & );
+ void sendPictureChecksum( const QString &userId, int checksum );
/**
* Send information about our picture
+ * @param userId the yahoo ID of the buddy that should be informed
+ * @param url the url of our picture
+ * @param checksum the checksum of the picture
*/
void sendPictureInformation( const QString &userId, const QString &url, int checksum );
/**
* Notify the buddies about our new status
+ * @param flag the type of our picture (0=none, 1=avatar, 2=picture)
*/
- void sendPictureStatusUpdate( const QString &userId, int type );
+ void setPictureStatus( Yahoo::PictureStatus flag );
/**
* Send a response to the webcam invite ( Accept / Decline )
+ * @param userId the yahoo ID of the sender
*/
void requestWebcam( const QString &userId );
/**
* Stop receiving of webcam
+ * @param userId the yahoo ID of the sender
*/
void closeWebcam( const QString &userId );
/**
* Invite the user to view your Webcam
+ * @param userId the yahoo ID of the receiver
*/
void sendWebcamInvite( const QString &userId );
/**
* transmit a new image to the watchers
+ * @param image the image data
*/
void sendWebcamImage( const QByteArray &image );
- /**
- * Stop transmission
- */
+ /** Stop the webcam transmission */
void closeOutgoingWebcam();
/**
* Allow a buddy to watch the cam
+ * @param userId the yahoo ID of the receiver
*/
void grantWebcamAccess( const QString &userId );
/**
* Invite buddies to a conference
+ * @param room the name of the conference
+ * @param members a list of members that are invited to the conference
+ * @param msg the invite message
*/
void inviteConference( const QString &room, const QStringList &members, const QString &msg );
/**
* Invite buddies to a already existing conference
+ * @param room the name of the conference
+ * @param who a list of members that are additionally invited to the conference
+ * @param members a list of members that are already in the conference
+ * @param msg the invite message
*/
void addInviteConference( const QString &room, const QStringList &who, const QStringList &members, const QString &msg );
/**
* Join a conference
+ * @param room the name of the conference
+ * @param members a list of members that are already in the conference
*/
void joinConference( const QString &room, const QStringList &members );
/**
* Decline to join a conference
+ * @param room the name of the conference
+ * @param members a list of members that are in the conference
+ * @param msg the reason why we don't want to join
*/
void declineConference( const QString &room, const QStringList &members, const QString &msg );
/**
* Leave the conference
+ * @param room the name of the conference
+ * @param members a list of members that are in the conference
*/
void leaveConference( const QString &room, const QStringList &members );
/**
* Send a message to the conference
+ * @param room the name of the conference
+ * @param members a list of members that are in the conference
+ * @param msg the message
*/
void sendConferenceMessage( const QString &room, const QStringList &members, const QString &msg );
/**
* Send a authorization request response
+ * @param userId the yahoo ID of the requesting buddy
+ * @param accept true, if the user is allowed to see our status, false if not
+ * @param msg the reason for our decision
*/
void sendAuthReply( const QString &userId, bool accept, const QString &msg );
/**
* Fetches all entries of the YAB
+ * @param lastMerge the YAB-Revision that was last merged with the local YAB
+ * @param lastRemoteRevision the latest known YAB-Revision
*/
void getYABEntries( long lastMerge, long lastRemoteRevision );
/**
* Saves a modified YAB entry
+ * @param entry the YAB entry
*/
void saveYABEntry( YABEntry &entry );
/**
* Creates a new YAB entry
+ * @param entry the YAB entry
*/
void addYABEntry( YABEntry &entry );
/**
* Deletes a YAB entry
+ * @param entry the YAB entry
*/
void deleteYABEntry( YABEntry &entry );
/**
* Send a file to a buddy
+ * @param transferId the unique ID of the transfer
+ * @param userId yahoo ID of the receiver
+ * @param msg a description of the file to be sent
+ * @param url the location of the file to be sent
*/
void sendFile( unsigned int transferId, const QString &userId, const QString &msg, KURL url );
/**
* Receive a file from a buddy
+ * @param transferId the unique ID of the transfer
+ * @param userId yahoo ID of the sender
+ * @param remoteURL the url of the file
+ * @param localURL the location where the file should be stored
*/
void receiveFile( unsigned int transferId, const QString &userId, KURL remoteURL, KURL localURL );
/**
* Reject a file offered by a buddy
+ * @param userId yahoo ID of the sender
+ * @param remoteURL the url of the file
*/
void rejectFile( const QString &userId, KURL remoteURL );
/**
- * The user canceled the filetransfer
+ * Canceled a filetransfer
+ * @param transferId the unique ID of the transfer
+ */
+ void cancelFileTransfer( unsigned int transferId );
+
+ /**
+ * Get the list of yahoo chat categories
+ */
+ void getYahooChatCategories();
+
+ /**
+ * Get the list of chatrooms for the given category
+ */
+ void getYahooChatRooms( const Yahoo::ChatCategory &category );
+
+ /**
+ * Join a chat room
+ */
+ void joinYahooChatRoom( const Yahoo::ChatRoom &room );
+
+ /**
+ * Leave the chat room
+ */
+ void leaveChat();
+
+ /**
+ * Send a chat message
*/
- void cancelFileTransfer( unsigned int transferId );
+ void sendYahooChatMessage( const QString &msg, const QString &handle );
/*************
- INTERNAL (FOR USE BY TASKS) METHODS
+ INTERNAL (FOR USE BY TASKS) METHODS
*************/
/**
* Send an outgoing request to the server
+ * @param request the transfer to be sent
*/
void send( Transfer *request );
-
+
/**
* Print a debug statement
*/
void debug( const QString &str );
-
- /**
- * The current user's user ID
- */
+
+ /** The current user's user ID */
QString userId();
-
- /**
- * The current user's password
- */
+
+ /** The current user's password */
QString password();
-
- /**
- * Host's IP address
- */
- QCString ipAddress();
-
+
+ /** current Session ID */
+ uint sessionID();
+
/**
- * current Session ID
+ * return the pictureFlag describing the status of our buddy icon
+ * 0 = no icon, 2 = icon, 1 = avatar (?)
*/
- uint sessionID();
+ int pictureFlag();
/**
- * Get our status
+ * return the picture checksum
*/
+ int pictureChecksum();
+
+ /** Get our status */
Yahoo::Status status();
/**
* Set our status
+ * @param status the new status
*/
- void setStatus( Yahoo::Status );
+ void setStatus( Yahoo::Status status );
- /**
- * Access the root Task for this client, so tasks may be added to it.
- */
+ /** Access the root Task for this client, so tasks may be added to it. */
Task* rootTask();
/**
@@ -389,11 +460,11 @@ Q_OBJECT
*/
void loggedIn( int, const QString& );
- /**
- * Notifies that the login process has failed
+ /**
+ * Notifies that the login process has failed
*/
void loginFailed();
-
+
/**
* Notifies tasks and account so they can react properly
*/
@@ -413,9 +484,21 @@ Q_OBJECT
*/
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 );
+ void statusChanged( const QString&, int, const QString&, int, int, int );
/**
* Notifies about the stealth status of buddies
*/
@@ -459,7 +542,7 @@ Q_OBJECT
/**
* The iconLoader has successfully downloaded a picutre
*/
- void pictureDownloaded( const QString &, KTempFile *, int );
+ void pictureDownloaded( const QString &, const QByteArray &, int );
/**
* A Buddy asks for our picture
*/
@@ -467,7 +550,7 @@ Q_OBJECT
/**
* Information about the picture upload
*/
- void pictureUploaded( const QString & );
+ void pictureUploaded( const QString &, int );
/**
* We've received a webcam image from a buddy
*/
@@ -545,7 +628,7 @@ Q_OBJECT
*/
void gotYABEntry( YABEntry * );
/**
- * An error occured while saving a Yahoo Addressbook entry
+ * An error occurred while saving a Yahoo Addressbook entry
*/
void modifyYABEntryError( YABEntry *, const QString & );
/**
@@ -557,7 +640,7 @@ Q_OBJECT
*/
void fileTransferComplete( unsigned int );
/**
- * An error occured during the filetransfer
+ * An error occurred during the filetransfer
*/
void fileTransferError( unsigned int, int, const QString & );
/**
@@ -568,14 +651,39 @@ Q_OBJECT
* A buddy is trying to send us a file
*/
void incomingFileTransfer( const QString &, const QString &, long, const QString &,
- const QString &, unsigned long );
+ const QString &, unsigned long, const QPixmap & );
+ /**
+ * We have received the list of yahoo chat categories
+ */
+ void gotYahooChatCategories( const QDomDocument & );
+ /**
+ * We have received the list of chatrooms for the categories
+ */
+ void gotYahooChatRooms( const Yahoo::ChatCategory &, const QDomDocument & );
+ /**
+ * We have joined a chatroom
+ */
+ void chatRoomJoined( int, int, const QString &, const QString & );
+ /**
+ * A buddy has joined a chatroom
+ */
+ void chatBuddyHasJoined( const QString &, const QString &, bool );
+ /**
+ * A buddy has left a chatroom
+ */
+ void chatBuddyHasLeft( const QString &, const QString & );
+ /**
+ * We have received a message in a chatroom
+ */
+ void chatMessageReceived( const QString &, const QString &, const QString & );
protected slots:
// INTERNAL, FOR USE BY TASKS' finished() SIGNALS //
void lt_loginFinished();
void lt_gotSessionID( uint );
void cs_connected();
void slotGotCookies();
-
+ void streamDisconnected();
+
/**
* Used by tasks to identify a response to a login attempt
*/
@@ -585,7 +693,7 @@ Q_OBJECT
* Used by the client stream to notify errors to upper layers.
*/
void streamError( int error );
-
+
/**
* The client stream has data ready to read.
*/
@@ -595,16 +703,22 @@ Q_OBJECT
* Send a Yahoo Ping packet to the server
*/
void sendPing();
+
+ /**
+ * Send all queued buddy icon requests
+ */
+ void processPictureQueue();
+
private:
void distribute( Transfer *transfer );
-
+
/**
* create static tasks and connect their signals
*/
void initTasks();
/**
- * remove static tasks and their singal connections
+ * remove static tasks and their signal connections
*/
void deleteTasks();
diff --git a/kopete/protocols/yahoo/libkyahoo/conferencetask.cpp b/kopete/protocols/yahoo/libkyahoo/conferencetask.cpp
index 5f68eaa0..9ab0d4c1 100644
--- a/kopete/protocols/yahoo/libkyahoo/conferencetask.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/conferencetask.cpp
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Handles conferences
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -25,7 +25,7 @@
ConferenceTask::ConferenceTask(Task* parent) : Task(parent)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
}
ConferenceTask::~ConferenceTask()
@@ -34,14 +34,12 @@ ConferenceTask::~ConferenceTask()
bool ConferenceTask::take( Transfer* transfer )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
-
if ( !forMe( transfer ) )
return false;
YMSGTransfer *t = 0L;
t = static_cast<YMSGTransfer*>(transfer);
-
+
if( t->service() == Yahoo::ServiceConfInvite ||
t->service() == Yahoo::ServiceConfAddInvite)
parseInvitation( t );
@@ -57,12 +55,10 @@ bool ConferenceTask::take( Transfer* transfer )
return true;
}
-bool ConferenceTask::forMe( Transfer* transfer ) const
+bool ConferenceTask::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;
@@ -71,7 +67,7 @@ bool ConferenceTask::forMe( Transfer* transfer ) const
t->service() == Yahoo::ServiceConfDecline ||
t->service() == Yahoo::ServiceConfLogoff ||
t->service() == Yahoo::ServiceConfAddInvite ||
- t->service() == Yahoo::ServiceConfMsg )
+ t->service() == Yahoo::ServiceConfMsg )
return true;
else
return false;
@@ -79,8 +75,8 @@ bool ConferenceTask::forMe( Transfer* transfer ) const
void ConferenceTask::parseInvitation( YMSGTransfer *t )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
-
+ kdDebug(YAHOO_RAW_DEBUG) ;
+
int i = 0;
QString who = t->firstParam( 50 );
QString room = t->firstParam( 57 );
@@ -92,9 +88,9 @@ void ConferenceTask::parseInvitation( YMSGTransfer *t )
msg = t->firstParam( 58 );
QStringList members;
- for( i = 0; i < t->paramCount( 52 ); i++ )
+ for( i = 0; i < t->paramCount( 52 ); ++i )
members.append( t->nthParam( 52, i ) );
- for( i = 0; i < t->paramCount( 53 ); i++ )
+ for( i = 0; i < t->paramCount( 53 ); ++i )
members.append( t->nthParam( 53, i ) );
if( who == client()->userId() )
return;
@@ -105,7 +101,7 @@ void ConferenceTask::parseInvitation( YMSGTransfer *t )
void ConferenceTask::parseMessage( YMSGTransfer *t )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
QString room = t->firstParam( 57 );
QString from = t->firstParam( 3 );
@@ -117,12 +113,12 @@ void ConferenceTask::parseMessage( YMSGTransfer *t )
msg = t->firstParam( 14 );
if( !msg.isEmpty() )
- emit gotMessage( from, room, msg );
+ emit gotMessage( from, room, msg );
}
void ConferenceTask::parseUserJoined( YMSGTransfer *t )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
QString room = t->firstParam( 57 );
QString who = t->firstParam( 53 );
@@ -133,7 +129,7 @@ void ConferenceTask::parseUserJoined( YMSGTransfer *t )
void ConferenceTask::parseUserLeft( YMSGTransfer *t )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
QString room = t->firstParam( 57 );
QString who = t->firstParam( 56 );
@@ -144,7 +140,7 @@ void ConferenceTask::parseUserLeft( YMSGTransfer *t )
void ConferenceTask::parseUserDeclined( YMSGTransfer *t )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
QString room = t->firstParam( 57 );
QString who = t->firstParam( 54 );
@@ -156,7 +152,7 @@ void ConferenceTask::parseUserDeclined( YMSGTransfer *t )
void ConferenceTask::inviteConference( const QString &room, const QStringList &members, const QString &msg )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceConfInvite);
t->setId( client()->sessionID() );
@@ -165,7 +161,7 @@ void ConferenceTask::inviteConference( const QString &room, const QStringList &m
t->setParam( 57, room.local8Bit() );
t->setParam( 58, msg.local8Bit() );
t->setParam( 97, 1 );
- for( QStringList::const_iterator it = members.begin(); it != members.end(); it++ )
+ for( QStringList::const_iterator it = members.begin(); it != members.end(); ++it )
t->setParam( 52, (*it).local8Bit() );
t->setParam( 13, "0" );
@@ -174,21 +170,21 @@ void ConferenceTask::inviteConference( const QString &room, const QStringList &m
void ConferenceTask::addInvite( const QString &room, const QStringList &who, const QStringList &members, const QString &msg )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceConfAddInvite);
t->setId( client()->sessionID() );
t->setParam( 1, client()->userId().local8Bit() );
QString whoList = who.first();
- for( uint i = 1; i < who.size(); i++ )
+ for( int i = 1; i < who.size(); i++ )
whoList += QString(",%1").arg( who[i] );
t->setParam( 51, whoList.local8Bit() );
t->setParam( 57, room.local8Bit() );
t->setParam( 58, msg.local8Bit() );
t->setParam( 97, 1 );
- for( QStringList::const_iterator it = members.begin(); it != members.end(); it++ )
+ for( QStringList::const_iterator it = members.begin(); it != members.end(); ++it )
{
t->setParam( 52, (*it).local8Bit() );
t->setParam( 53, (*it).local8Bit() ); // Note: this field should only be set if the buddy has already joined the conference, but no harm is done this way
@@ -200,12 +196,12 @@ void ConferenceTask::addInvite( const QString &room, const QStringList &who, con
void ConferenceTask::joinConference( const QString &room, const QStringList &members )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceConfLogon);
t->setId( client()->sessionID() );
t->setParam( 1, client()->userId().local8Bit() );
- for( QStringList::const_iterator it = members.begin(); it != members.end(); it++ )
+ for( QStringList::const_iterator it = members.begin(); it != members.end(); ++it )
t->setParam( 3, (*it).local8Bit() );
t->setParam( 57, room.local8Bit() );
@@ -214,14 +210,14 @@ void ConferenceTask::joinConference( const QString &room, const QStringList &mem
void ConferenceTask::declineConference( const QString &room, const QStringList &members, const QString &msg )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceConfDecline);
t->setId( client()->sessionID() );
t->setParam( 1, client()->userId().local8Bit() );
- for( QStringList::const_iterator it = members.begin(); it != members.end(); it++ )
+ for( QStringList::const_iterator it = members.begin(); it != members.end(); ++it )
t->setParam( 3, (*it).local8Bit() );
- t->setParam( 57, room.local8Bit() );
+ t->setParam( 57, room.local8Bit() );
t->setParam( 14, msg.utf8() );
t->setParam( 97, 1 );
@@ -229,12 +225,12 @@ void ConferenceTask::declineConference( const QString &room, const QStringList &
}
void ConferenceTask::leaveConference( const QString &room, const QStringList &members )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceConfLogoff);
t->setId( client()->sessionID() );
t->setParam( 1, client()->userId().local8Bit() );
- for( QStringList::const_iterator it = members.begin(); it != members.end(); it++ )
+ for( QStringList::const_iterator it = members.begin(); it != members.end(); ++it )
t->setParam( 3, (*it).local8Bit() );
t->setParam( 57, room.local8Bit() );
@@ -243,12 +239,12 @@ void ConferenceTask::leaveConference( const QString &room, const QStringList &me
void ConferenceTask::sendMessage( const QString &room, const QStringList &members, const QString &msg )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceConfMsg);
t->setId( client()->sessionID() );
t->setParam( 1, client()->userId().local8Bit() );
- for( QStringList::const_iterator it = members.begin(); it != members.end(); it++ )
+ for( QStringList::const_iterator it = members.begin(); it != members.end(); ++it )
t->setParam( 53, (*it).local8Bit() );
t->setParam( 57, room.local8Bit() );
t->setParam( 14, msg.utf8() );
diff --git a/kopete/protocols/yahoo/libkyahoo/conferencetask.h b/kopete/protocols/yahoo/libkyahoo/conferencetask.h
index b6649a93..f8a101c5 100644
--- a/kopete/protocols/yahoo/libkyahoo/conferencetask.h
+++ b/kopete/protocols/yahoo/libkyahoo/conferencetask.h
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Handles conferences
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -30,9 +30,9 @@ class ConferenceTask : public Task
public:
ConferenceTask(Task *parent);
~ConferenceTask();
-
+
bool take(Transfer *transfer);
- bool forMe( Transfer* transfer ) const;
+ bool forMe( const Transfer* transfer ) const;
void joinConference( const QString &room, const QStringList &members );
void declineConference( const QString &room, const QStringList &members, const QString &msg );
diff --git a/kopete/protocols/yahoo/libkyahoo/connector.cpp b/kopete/protocols/yahoo/libkyahoo/connector.cpp
index 6ae174e8..773f8757 100644
--- a/kopete/protocols/yahoo/libkyahoo/connector.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/connector.cpp
@@ -4,7 +4,7 @@
Copyright (c) 2004 Matt Rogers <matt.rogers@kdemail.net>
- Based on Iris, Copyright (C) 2003 Justin Karneges
+ Based on Iris, Copyright (C) 2003 Justin Karneges <justin@affinix.com>
Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
diff --git a/kopete/protocols/yahoo/libkyahoo/connector.h b/kopete/protocols/yahoo/libkyahoo/connector.h
index 70e01f3d..dea818fb 100644
--- a/kopete/protocols/yahoo/libkyahoo/connector.h
+++ b/kopete/protocols/yahoo/libkyahoo/connector.h
@@ -4,7 +4,7 @@
Copyright (c) 2004 Matt Rogers <matt.rogers@kdemail.net>
Based on code Copyright (c) 2004 SuSE Linux AG <http://www.suse.com>
- Based on Iris, Copyright (C) 2003 Justin Karneges
+ Based on Iris, Copyright (C) 2003 Justin Karneges <justin@affinix.com>
Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
diff --git a/kopete/protocols/yahoo/libkyahoo/coreprotocol.cpp b/kopete/protocols/yahoo/libkyahoo/coreprotocol.cpp
index b05cb16d..2c73ef2b 100644
--- a/kopete/protocols/yahoo/libkyahoo/coreprotocol.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/coreprotocol.cpp
@@ -1,14 +1,14 @@
/*
Kopete Yahoo Protocol
-
+
Copyright (c) 2004 Duncan Mac-Vicar P. <duncan@kde.org>
-
- Based on code
+
+ Based on code
Copyright (c) 2004 SuSE Linux AG <http://www.suse.com>
- Copyright (C) 2003 Justin Karneges
-
+ Copyright (C) 2003 Justin Karneges <justin@affinix.com>
+
Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
-
+
*************************************************************************
* *
* This library is free software; you can redistribute it and/or *
@@ -26,7 +26,6 @@
#include <qdatetime.h>
#include <qtextstream.h>
-
#include <kdebug.h>
#include <kurl.h>
@@ -39,7 +38,7 @@ CoreProtocol::CoreProtocol() : QObject()
m_YMSGProtocol = new YMSGProtocol( this, "ymsgprotocol" );
}
-CoreProtocol::~CoreProtocol()
+CoreProtocol::~CoreProtocol()
{
}
@@ -52,60 +51,63 @@ void CoreProtocol::addIncomingData( const QByteArray & incomingBytes )
{
// store locally
int oldsize = m_in.size();
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << incomingBytes.size() << " bytes. already had " << oldsize << " bytes" << endl;
-
+ kdDebug(YAHOO_RAW_DEBUG) << incomingBytes.size() << " bytes. already had " << oldsize << " bytes" << endl;
+
m_in.resize( oldsize + incomingBytes.size() );
memcpy( m_in.data() + oldsize, incomingBytes.data(), incomingBytes.size() );
-
+
m_state = Available;
// convert every event in the chunk to a Transfer, signalling it back to the clientstream
-
+
int parsedBytes = 0;
int transferCount = 0;
// while there is data left in the input buffer, and we are able to parse something out of it
-
+
while ( m_in.size() && ( parsedBytes = wireToTransfer(m_in) ) )
{
transferCount++;
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " parsed transfer " << transferCount << " in chunk of "<< parsedBytes << " bytes" << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " parsed transfer " << transferCount << " in chunk of "<< parsedBytes << " bytes" << endl;
int size = m_in.size();
if ( parsedBytes < size )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " more data in chunk! ( I have parsed " << parsedBytes << " and total data of " << size << ")" << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " more data in chunk! ( I have parsed " << parsedBytes << " and total data of " << size << ")" << endl;
+ // remove parsed bytes from the buffer
+ //m_in.remove( 0, parsedBytes );
+
// copy the unparsed bytes into a new qbytearray and replace m_in with that
- QByteArray remainder( size - parsedBytes );
- memcpy( remainder.data(), m_in.data() + parsedBytes, remainder.size() );
- m_in = remainder;
+ QByteArray remainder( size - parsedBytes );
+ memcpy( remainder.data(), m_in.data() + parsedBytes, remainder.size() );
+ m_in = remainder;
}
else
m_in.truncate( 0 );
}
if ( m_state == NeedMore )
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " message was incomplete, waiting for more..." << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " message was incomplete, waiting for more..." << endl;
/*
if ( m_eventProtocol->state() == EventProtocol::OutOfSync )
- {
+ {
qDebug( " - protocol thinks it's out of sync, discarding the rest of the buffer and hoping the server regains sync soon..." );
m_in.truncate( 0 );
}
*/
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " done processing chunk" << endl;
-
+ kdDebug(YAHOO_RAW_DEBUG) << " done processing chunk" << endl;
+
}
Transfer* CoreProtocol::incomingTransfer()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
if ( m_state == Available )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " - got a transfer" << endl;
+// kdDebug(YAHOO_RAW_DEBUG) << " - got a transfer";
m_state = NoData;
return m_inTransfer;
m_inTransfer = 0;
}
else
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " no milk today" << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " no milk today" << endl;
return 0;
}
}
@@ -113,7 +115,7 @@ Transfer* CoreProtocol::incomingTransfer()
void cp_dump( const QByteArray &bytes )
{
#ifdef YAHOO_COREPROTOCOL_DEBUG
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " contains " << bytes.count() << " bytes" << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " contains " << bytes.count() << " bytes" << endl;
for ( uint i = 0; i < bytes.count(); ++i )
{
printf( "%02x ", bytes[ i ] );
@@ -126,20 +128,20 @@ void cp_dump( const QByteArray &bytes )
void CoreProtocol::outgoingTransfer( Transfer* outgoing )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
if ( outgoing->type() == Transfer::YMSGTransfer )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " got YMSGTransfer" << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " got YMSGTransfer" << endl;
YMSGTransfer *yt = (YMSGTransfer *) outgoing;
QByteArray bytesOut = yt->serialize();
-
- //QTextStream dout( bytesOut, IO_WriteOnly );
+
+ //QTextStream dout( bytesOut, QIODevice::WriteOnly );
//dout.setEncoding( QTextStream::Latin1 );
//dout.setByteOrder( QDataStream::LittleEndian );
//dout << bytesOut;
- //kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " " << bytesOut << endl;
+ //kdDebug(YAHOO_RAW_DEBUG) << " " << bytesOut;
emit outgoingData( bytesOut );
- // now convert
+ // now convert
//fieldsToWire( fields );
}
delete outgoing;
@@ -149,53 +151,60 @@ void CoreProtocol::outgoingTransfer( Transfer* outgoing )
int CoreProtocol::wireToTransfer( const QByteArray& wire )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
// processing incoming data and reassembling it into transfers
// may be an event or a response
-
+
uint bytesParsed = 0;
-
+
if ( wire.size() < 20 ) // minimal value of a YMSG header
{
m_state = NeedMore;
return bytesParsed;
}
-
- QDataStream din( wire, IO_ReadOnly );
-
+
+ QByteArray tempWire = wire;
+ QDataStream din( tempWire, IO_ReadOnly );
+
// look at first four bytes and decide what to do with the chunk
if ( okToProceed( din ) )
{
if ( (wire[0] == 'Y') && (wire[1] == 'M') && (wire[2] == 'S') && (wire[3] == 'G'))
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " - looks like a valid YMSG packet" << endl;
- Transfer *t = m_YMSGProtocol->parse( wire, bytesParsed );
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " - YMSG Protocol parsed " << bytesParsed << " bytes" << endl;
+// kdDebug(YAHOO_RAW_DEBUG) << " - looks like a valid YMSG packet";
+ YMSGTransfer *t = static_cast<YMSGTransfer *>(m_YMSGProtocol->parse( wire, bytesParsed ));
+// kdDebug(YAHOO_RAW_DEBUG) << " - YMSG Protocol parsed " << bytesParsed << " bytes";
if ( t )
{
+ if( wire.size() < t->packetLength() )
+ {
+ m_state = NeedMore;
+ delete t;
+ return 0;
+ }
m_inTransfer = t;
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " - got a valid packet " << endl;
-
+// kdDebug(YAHOO_RAW_DEBUG) << " - got a valid packet ";
+
m_state = Available;
emit incomingData();
}
else
bytesParsed = 0;
}
- else
- {
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " - not a valid YMSG packet. Trying to recover: " << wire << endl;
+ else
+ {
+ kdDebug(YAHOO_RAW_DEBUG) << " - not a valid YMSG packet. Trying to recover." << endl;
QTextStream s( wire, IO_ReadOnly );
QString remaining = s.read();
int pos = remaining.find( "YMSG", bytesParsed );
if( pos >= 0 )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Recover successful." << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "Recover successful." << endl;
bytesParsed += pos;
}
else
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Recover failed. Dump it!" << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "Recover failed. Dump it!" << endl;
bytesParsed = wire.size();
}
}
@@ -208,7 +217,7 @@ void CoreProtocol::reset()
m_in.resize( 0 );
}
-void CoreProtocol::slotOutgoingData( const QCString &out )
+void CoreProtocol::slotOutgoingData( const QByteArray &out )
{
qDebug( "%s", out.data() );
}
@@ -218,7 +227,7 @@ bool CoreProtocol::okToProceed( QDataStream &din)
if ( din.atEnd() )
{
m_state = NeedMore;
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " saved message prematurely" << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " saved message prematurely" << endl;
return false;
}
else
diff --git a/kopete/protocols/yahoo/libkyahoo/coreprotocol.h b/kopete/protocols/yahoo/libkyahoo/coreprotocol.h
index fb78aa39..6432093c 100644
--- a/kopete/protocols/yahoo/libkyahoo/coreprotocol.h
+++ b/kopete/protocols/yahoo/libkyahoo/coreprotocol.h
@@ -1,14 +1,14 @@
/*
Kopete Yahoo Protocol
-
+
Copyright (c) 2004 Duncan Mac-Vicar P. <duncan@kde.org>
-
- Based on code
+
+ Based on code
Copyright (c) 2004 SuSE Linux AG <http://www.suse.com>
- Copyright (C) 2003 Justin Karneges
-
+ Copyright (C) 2003 Justin Karneges <justin@affinix.com>
+
Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
-
+
*************************************************************************
* *
* This library is free software; you can redistribute it and/or *
@@ -22,9 +22,7 @@
#ifndef YAHOO_CORE_PROTOCOL_H
#define YAHOO_CORE_PROTOCOL_H
-#include <qcstring.h>
#include <qobject.h>
-#include <qptrlist.h>
class Transfer;
class YMSGProtocol;
@@ -36,43 +34,43 @@ public:
enum State { NeedMore, Available, NoData, OutOfSync };
CoreProtocol();
-
+
virtual ~CoreProtocol();
-
+
/**
* Reset the protocol, clear buffers
*/
void reset();
-
+
/**
* Accept data from the network, and buffer it into a useful message
* This requires parsing out each FLAP, etc. from the incoming data
* @param incomingBytes Raw data in wire format.
*/
void addIncomingData( const QByteArray& incomingBytes );
-
+
/**
* @return the incoming transfer or 0 if none is available.
*/
Transfer* incomingTransfer();
-
- /**
+
+ /**
* Convert a request into an outgoing transfer
* emits @ref outgoingData() with each part of the transfer
*/
void outgoingTransfer( Transfer* outgoing );
-
+
/**
- * Get the state of the protocol
+ * Get the state of the protocol
*/
int state();
-
+
signals:
- /**
+ /**
* Emitted as the core protocol converts fields to wire ready data
*/
void outgoingData( const QByteArray& );
-
+
/**
* Emitted when there is incoming data, parsed into a Transfer
*/
@@ -81,8 +79,8 @@ protected slots:
/**
* Just a debug method to test emitting to the socket, atm - should go to the ClientStream
*/
- void slotOutgoingData( const QCString & );
-
+ void slotOutgoingData( const QByteArray & );
+
protected:
/**
* Check that there is data to read, and set the protocol's state if there isn't any.
@@ -91,7 +89,7 @@ protected:
/**
* Convert incoming wire data into a Transfer object and queue it
* @return number of bytes from the input that were parsed into a Transfer
- */
+ */
int wireToTransfer( const QByteArray& wire );
private:
diff --git a/kopete/protocols/yahoo/libkyahoo/filetransfernotifiertask.cpp b/kopete/protocols/yahoo/libkyahoo/filetransfernotifiertask.cpp
index 7d2042e4..e011dfeb 100644
--- a/kopete/protocols/yahoo/libkyahoo/filetransfernotifiertask.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/filetransfernotifiertask.cpp
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Notifies about incoming filetransfers
- Copyright (c) 2006 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2006 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -19,12 +19,15 @@
#include "ymsgtransfer.h"
#include "yahootypes.h"
#include "client.h"
+
#include <qstring.h>
+#include <qpixmap.h>
#include <kdebug.h>
+//#include <kcodecs.h>
FileTransferNotifierTask::FileTransferNotifierTask(Task* parent) : Task(parent)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
}
FileTransferNotifierTask::~FileTransferNotifierTask()
@@ -34,11 +37,9 @@ FileTransferNotifierTask::~FileTransferNotifierTask()
bool FileTransferNotifierTask::take( Transfer* transfer )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
-
if ( !forMe( transfer ) )
return false;
-
+
YMSGTransfer *t = static_cast<YMSGTransfer*>(transfer);
if( t->service() == Yahoo::ServiceFileTransfer )
@@ -47,24 +48,24 @@ bool FileTransferNotifierTask::take( Transfer* transfer )
parseFileTransfer7( t );
else if( t->service() == Yahoo::ServicePeerToPeer )
acceptFileTransfer( t );
-
+
return true;
}
-bool FileTransferNotifierTask::forMe( Transfer *transfer ) const
+bool FileTransferNotifierTask::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;
if( t->service() == Yahoo::ServiceP2PFileXfer ||
- t->service() == Yahoo::ServicePeerToPeer ||
- t->service() == Yahoo::ServiceFileTransfer ||
- t->service() == Yahoo::ServiceFileTransfer7
+ t->service() == Yahoo::ServicePeerToPeer ||
+ t->service() == Yahoo::ServiceFileTransfer ||
+ (t->service() == Yahoo::ServiceFileTransfer7 &&
+ t->firstParam(222).toInt() == 1)
)
return true;
else
@@ -73,7 +74,7 @@ bool FileTransferNotifierTask::forMe( Transfer *transfer ) const
void FileTransferNotifierTask::parseFileTransfer( YMSGTransfer *t )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
QString from; /* key = 4 */
QString to; /* key = 5 */
@@ -97,22 +98,22 @@ void FileTransferNotifierTask::parseFileTransfer( YMSGTransfer *t )
{
client()->notifyError( "Fileupload result received.", msg, Client::Notice );
return;
- }
-
+ }
+
if( url.isEmpty() )
return;
-
+
unsigned int left = url.findRev( '/' ) + 1;
- unsigned int right = url.findRev( '?' );
+ unsigned int right = url.findRev( '?' );
filename = url.mid( left, right - left );
- emit incomingFileTransfer( from, url, expires, msg, filename, size );
+ emit incomingFileTransfer( from, url, expires, msg, filename, size, QPixmap() );
}
void FileTransferNotifierTask::parseFileTransfer7( YMSGTransfer *t )
-{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+{
+ kdDebug(YAHOO_RAW_DEBUG) ;
QString from; /* key = 4 */
QString to; /* key = 5 */
@@ -121,25 +122,35 @@ void FileTransferNotifierTask::parseFileTransfer7( YMSGTransfer *t )
QString msg; /* key = 14 */
QString filename; /* key = 27 */
unsigned long size; /* key = 28 */
-
+ QByteArray preview; /* key = 267 */
+ QPixmap previewPixmap;
+
if( t->firstParam( 222 ).toInt() == 2 )
return; // user cancelled the file transfer
from = t->firstParam( 4 );
to = t->firstParam( 5 );
url = t->firstParam( 265 );
- expires = t->firstParam( 38 ).toLong();
msg = t->firstParam( 14 );
+ expires = t->firstParam( 38 ).toLong();
filename = t->firstParam( 27 );
size = t->firstParam( 28 ).toULong();
- emit incomingFileTransfer( from, url, expires, msg, filename, size );
+ // FIXME (same)
+ //preview = QByteArray::fromBase64( t->firstParam( 267 ) );
+
+ if( preview.size() > 0 )
+ {
+ previewPixmap.loadFromData( preview );
+ }
+
+ emit incomingFileTransfer( from, url, expires, msg, filename, size, previewPixmap );
}
void FileTransferNotifierTask::acceptFileTransfer( YMSGTransfer *transfer )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
-
+ kdDebug(YAHOO_RAW_DEBUG) ;
+
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServicePeerToPeer);
t->setId( client()->sessionID() );
t->setParam( 4, client()->userId().local8Bit() );
diff --git a/kopete/protocols/yahoo/libkyahoo/filetransfernotifiertask.h b/kopete/protocols/yahoo/libkyahoo/filetransfernotifiertask.h
index 0fd01eec..24b684f4 100644
--- a/kopete/protocols/yahoo/libkyahoo/filetransfernotifiertask.h
+++ b/kopete/protocols/yahoo/libkyahoo/filetransfernotifiertask.h
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Notifies about incoming filetransfers
- Copyright (c) 2006 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2006 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -22,6 +22,7 @@
class QString;
class YMSGTransfer;
+class QPixmap;
/**
@author André Duffeck
@@ -36,10 +37,10 @@ public:
bool take(Transfer *transfer);
protected:
- bool forMe( Transfer *transfer ) const;
+ virtual bool forMe( const Transfer *transfer ) const;
signals:
void incomingFileTransfer( const QString &who, const QString &url, long expires, const QString &msg ,
- const QString &fname, unsigned long size );
+ const QString &fname, unsigned long size, const QPixmap &preview );
private:
void parseFileTransfer( YMSGTransfer *transfer );
void parseFileTransfer7( YMSGTransfer *transfer );
diff --git a/kopete/protocols/yahoo/libkyahoo/inputprotocolbase.cpp b/kopete/protocols/yahoo/libkyahoo/inputprotocolbase.cpp
index 5c2dfcc3..eca3318a 100644
--- a/kopete/protocols/yahoo/libkyahoo/inputprotocolbase.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/inputprotocolbase.cpp
@@ -18,6 +18,7 @@
#include "inputprotocolbase.h"
+
InputProtocolBase::InputProtocolBase(QObject *parent, const char *name)
: QObject(parent, name)
{
@@ -59,6 +60,7 @@ bool InputProtocolBase::okToProceed()
return false;
}
+// FIXME: need to be checked
bool InputProtocolBase::safeReadBytes( QCString & data, uint & len )
{
// read the length of the bytes
@@ -81,8 +83,8 @@ bool InputProtocolBase::safeReadBytes( QCString & data, uint & len )
// the rest of the string will be filled with FF,
// so look for that in the last position instead of \0
// this caused a crash - guessing that temp.length() is set to the number of bytes actually read...
- // if ( (Q_UINT8)( * ( temp.data() + ( temp.length() - 1 ) ) ) == 0xFF )
- if ( temp.length() < ( val - 1 ) )
+ // if ( (quint8)( * ( temp.data() + ( temp.length() - 1 ) ) ) == 0xFF )
+ if ( temp.length() < static_cast<int>( val - 1 ) )
{
qDebug( "InputProtocol::safeReadBytes() - string broke, giving up, only got: %i bytes out of %i", temp.length(), val );
m_state = NeedMore;
diff --git a/kopete/protocols/yahoo/libkyahoo/inputprotocolbase.h b/kopete/protocols/yahoo/libkyahoo/inputprotocolbase.h
index d65bd8f7..18a3dab3 100644
--- a/kopete/protocols/yahoo/libkyahoo/inputprotocolbase.h
+++ b/kopete/protocols/yahoo/libkyahoo/inputprotocolbase.h
@@ -57,7 +57,7 @@ protected:
*/
bool okToProceed();
/**
- * read a Q_UINT32 giving the number of following bytes, then a string of that length
+ * read a quint32 giving the number of following bytes, then a string of that length
* updates the bytes parsed counter
* @return false if the string was broken or there was no data available at all
*/
@@ -66,7 +66,7 @@ protected:
protected:
uint m_state;
uint m_bytes;
- QDataStream * m_din;
+ QDataStream *m_din;
};
#endif
diff --git a/kopete/protocols/yahoo/libkyahoo/listtask.cpp b/kopete/protocols/yahoo/libkyahoo/listtask.cpp
index 261e7896..b1e35940 100644
--- a/kopete/protocols/yahoo/libkyahoo/listtask.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/listtask.cpp
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Handles several lists such as buddylist, ignorelist and so on
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -15,18 +15,17 @@
*/
#include <qstring.h>
+#include <qstringlist.h>
#include "listtask.h"
#include "transfer.h"
#include "ymsgtransfer.h"
#include "client.h"
-#include <qstring.h>
-#include <qstringlist.h>
#include <kdebug.h>
ListTask::ListTask(Task* parent) : Task(parent)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
}
ListTask::~ListTask()
@@ -36,11 +35,9 @@ ListTask::~ListTask()
bool ListTask::take( Transfer* transfer )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
-
if ( !forMe( transfer ) )
return false;
-
+
YMSGTransfer *t = static_cast<YMSGTransfer *>(transfer);
parseBuddyList( t );
@@ -49,16 +46,15 @@ bool ListTask::take( Transfer* transfer )
return true;
}
-bool ListTask::forMe( Transfer* transfer ) const
+bool ListTask::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;
- if ( t->service() == Yahoo::ServiceList )
+ if ( t->service() == Yahoo::ServiceBuddyList )
return true;
else
return false;
@@ -66,40 +62,49 @@ bool ListTask::forMe( Transfer* transfer ) const
void ListTask::parseBuddyList( YMSGTransfer *t )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
- QString raw;
- m_list.append( t->firstParam( 87 ) );
-
- if( t->firstParam( 59 ).isEmpty() )
- return;
+ QString group;
+ QString buddy;
+ // We need some low-level parsing here
- QStringList groups;
- groups = QStringList::split( "\n", m_list );
+ // FIXME same: need to check
+ //foreach( const Param &p, t->paramList() )
- for ( QStringList::Iterator groupIt = groups.begin(); groupIt != groups.end(); ++groupIt )
+ ParamList paramList = t->paramList();
+ ParamList::const_iterator it;
+ for ( it = paramList.begin(); it != paramList.end(); ++it )
{
- QString group = (*groupIt).section(":", 0, 0);
- QStringList buddies;
- buddies = QStringList::split( ",", (*groupIt).section(":", 1,1) );
- for ( QStringList::Iterator buddyIt = buddies.begin(); buddyIt != buddies.end(); ++buddyIt )
+ const Param &p = *it;
+
+ kdDebug(YAHOO_RAW_DEBUG) << "1:" << p.first << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "2:" << p.second << endl;
+ switch( p.first )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Parsed buddy: " << *buddyIt << " in group " << group << endl;
- emit gotBuddy( *buddyIt, QString::null, group );
+ case 65:
+ group = p.second;
+ break;
+ case 7:
+ buddy = p.second;
+ break;
+ case 301:
+ if( p.second == "319"){
+ kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Parsed buddy: " << buddy << " in group " << group << endl;
+ emit gotBuddy( buddy, QString(), group );
+ }
}
}
- m_list.truncate( 0 );
}
void ListTask::parseStealthList( YMSGTransfer *t )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
QString raw;
raw = t->firstParam( 185 );
- QStringList buddies = QStringList::split( ",", raw );
- for ( QStringList::Iterator it = buddies.begin(); it != buddies.end(); ++it )
+ const QStringList buddies = QStringList::split( ',', raw );
+ for ( QStringList::ConstIterator it = buddies.begin(); it != buddies.end(); ++it )
{
emit stealthStatusChanged( *it, Yahoo::StealthActive );
}
diff --git a/kopete/protocols/yahoo/libkyahoo/listtask.h b/kopete/protocols/yahoo/libkyahoo/listtask.h
index 09b98495..cc058004 100644
--- a/kopete/protocols/yahoo/libkyahoo/listtask.h
+++ b/kopete/protocols/yahoo/libkyahoo/listtask.h
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Handles several lists such as buddylist, ignorelist and so on
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -31,18 +31,16 @@ Q_OBJECT
public:
ListTask(Task *parent);
~ListTask();
-
+
bool take(Transfer *transfer);
protected:
- bool forMe( Transfer *transfer ) const;
+ virtual bool forMe( const Transfer *transfer ) const;
void parseBuddyList( YMSGTransfer *transfer );
- void parseStealthList( YMSGTransfer *transfer );
+ void parseStealthList( YMSGTransfer *transfer );
signals:
void gotBuddy(const QString&, const QString&, const QString&);
void stealthStatusChanged( const QString&, Yahoo::StealthStatus );
-private:
- QString m_list;
};
#endif
diff --git a/kopete/protocols/yahoo/libkyahoo/logintask.cpp b/kopete/protocols/yahoo/libkyahoo/logintask.cpp
index 72c598bc..d3b5be7b 100644
--- a/kopete/protocols/yahoo/libkyahoo/logintask.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/logintask.cpp
@@ -3,10 +3,10 @@
Handles logging into to the Yahoo service
Copyright (c) 2004 Duncan Mac-Vicar P. <duncan@kde.org>
+ Copyright (c) 2005-2006 André Duffeck <duffeck@kde.org>
+ Copyright 2009 Matt Rogers <mattr@kde.org>
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
-
- Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
+ Kopete (c) 2002-2009 by the Kopete developers <kopete-devel@kde.org>
*************************************************************************
* *
@@ -18,7 +18,7 @@
*************************************************************************
*/
-#include <qstring.h>
+
#include "logintask.h"
#include "transfer.h"
@@ -28,6 +28,10 @@
#include <qstring.h>
#include <kdebug.h>
#include <stdlib.h>
+
+#include <kio/job.h>
+#include <kmdcodec.h>
+
extern "C"
{
#include "libyahoo.h"
@@ -35,7 +39,7 @@ extern "C"
LoginTask::LoginTask(Task* parent) : Task(parent)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
mState = InitialState;
}
@@ -46,10 +50,9 @@ LoginTask::~LoginTask()
bool LoginTask::take(Transfer* transfer)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
/*
Yahoo login task has various stages
-
+
1 .- Initial State
1.1 .- OnGo is called
1.2 .- SendVerify() - send a service verify ack
@@ -61,12 +64,18 @@ bool LoginTask::take(Transfer* transfer)
2.3 - Need to decode and send a transfer back
4.- SentAuthResp
*/
-
+
if ( !forMe( transfer ) )
return false;
YMSGTransfer *t = static_cast<YMSGTransfer *>(transfer);
+
+ if ( t->service() == Yahoo::ServicePing) {
+ emit buddyListReady();
+ return true;
+ }
+
switch (mState)
{
case (InitialState):
@@ -93,14 +102,16 @@ bool LoginTask::take(Transfer* transfer)
}
}
-bool LoginTask::forMe(Transfer* transfer) const
+bool LoginTask::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;
+ if ( t->service() == Yahoo::ServicePing)
+ return true;
+
switch (mState)
{
case (InitialState):
@@ -128,12 +139,12 @@ bool LoginTask::forMe(Transfer* transfer) const
void LoginTask::onGo()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
/* initial state, we have to send a ServiceVerify */
if (mState == InitialState)
sendVerify();
else
- client()->notifyError( "Error in login procedure.", "take called while not in initial state", Client::Debug );
+ client()->notifyError( "Error in login procedure.", "onGo called while not in initial state", Client::Debug );
}
void LoginTask::reset()
@@ -144,20 +155,20 @@ void LoginTask::reset()
void LoginTask::sendVerify()
{
/* send a ServiceVerify */
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceVerify);
send( t );
- mState = SentVerify;
+ mState = SentVerify;
}
void LoginTask::sendAuth(YMSGTransfer* transfer)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
// transfer is the verify ack transfer, no useful data in it.
Q_UNUSED(transfer);
-
+
/* got ServiceVerify ACK, send a ServiceAuth with username */
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
YMSGTransfer *t = new YMSGTransfer( Yahoo::ServiceAuth );
t->setParam( 1 , client()->userId().local8Bit() );
send(t);
@@ -166,76 +177,225 @@ void LoginTask::sendAuth(YMSGTransfer* transfer)
void LoginTask::sendAuthResp(YMSGTransfer* t)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
-
+ kdDebug(YAHOO_RAW_DEBUG) ;
+
QString sn = t->firstParam( 1 );
QString seed = t->firstParam( 94 );
+ m_challengeString = seed;
QString version_s = t->firstParam( 13 );
- uint sessionID = t->id();
+ m_sessionID = t->id();
int version = version_s.toInt();
-
+
switch (version)
{
case 0:
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Version pre 0x0b "<< version_s << endl;
- break;
+ case 1:
+ case 2:
+ kdDebug(YAHOO_RAW_DEBUG) << "Using version 16 authorization" << endl;
+ sendAuthSixteenStage1(sn, seed);
+ break;
default:
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Version 0x0b "<< version_s << endl;
- sendAuthResp_0x0b(sn, seed, sessionID);
+ kdDebug(YAHOO_RAW_DEBUG) << "Unknown authentication method used!"
+ << "Attempting current authentication anyways" << endl;
+ sendAuthSixteenStage1(sn, seed);
break;
- }
+ }
mState = SentAuthResp;
- emit haveSessionID( sessionID );
+ emit haveSessionID( m_sessionID );
}
-void LoginTask::sendAuthResp_0x0b(const QString &sn, const QString &seed, uint sessionID)
+void LoginTask::sendAuthSixteenStage1(const QString& sn, const QString& seed)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " with seed " << seed << endl;
- char *resp_6 = (char *) malloc(100);
- char *resp_96 = (char *) malloc(100);
- authresp_0x0b(seed.latin1(), sn.latin1(), (client()->password()).latin1(), resp_6, resp_96);
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "resp_6: " << resp_6 << " resp_69: " << resp_96 << endl;
- YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceAuthResp, m_stateOnConnect);
- t->setId( sessionID );
- t->setParam( 0 , sn.local8Bit());
- t->setParam( 6 , resp_6);
- t->setParam( 96 , resp_96);
- t->setParam( 59 , "B\\tfckeert1kk1nl&b=2" ); // ???
- t->setParam( 135 , "7,0,0,437" ); // Client version
- t->setParam( 148 , -60 );
- t->setParam( 244 , 524223 );
- t->setParam( 1 , sn.local8Bit());
-
- if( !m_verificationWord.isEmpty() )
+ const QString YahooTokenUrl = "https://login.yahoo.com/config/pwtoken_get?src=ymsgr&ts=&login=%1&passwd=%2&chal=%3";
+ kdDebug(YAHOO_RAW_DEBUG) << "seed:" << seed << endl;
+ m_stage1Data= QString::null;
+ /* construct a URL from the seed and request tokens */
+ QByteArray encodedUrl;
+ QString fullUrl = YahooTokenUrl.arg(sn, client()->password(), seed);
+ KURL tokenUrl(fullUrl);
+ KIO::Job* job = KIO::get(tokenUrl, true, false);
+ connect(job, SIGNAL(data(KIO::Job*, const QByteArray&)),
+ this, SLOT(handleAuthSixteenStage1Data(KIO::Job*, const QByteArray&)));
+ connect(job, SIGNAL(result(KIO::Job*)),
+ this, SLOT(handleAuthSixteenStage1Result(KIO::Job*)));
+}
+
+void LoginTask::handleAuthSixteenStage1Data(KIO::Job* job, const QByteArray& data)
+{
+ kdDebug(YAHOO_RAW_DEBUG) << "data:" << data << endl;
+ m_stage1Data.append(data);
+}
+
+void LoginTask::handleAuthSixteenStage1Result(KIO::Job* job)
+{
+ int responseNumber = -1;
+ QString token;
+ int error = job->error();
+ kdDebug(YAHOO_RAW_DEBUG) << "error:" << error << endl;
+ if (error == 0)
+ {
+ QStringList responses = QStringList::split("\r\n", m_stage1Data);
+ responseNumber = responses[0].toInt();
+ if (responses.count() >= 3)
+ {
+ token = responses[1];
+ token.remove("ymsgr=");
+ kdDebug(YAHOO_RAW_DEBUG) << "response is:" << responseNumber << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "token is:" << token << endl;
+ }
+ if (responseNumber != 0)
+ {
+ switch(responseNumber)
+ {
+ case -1:
+ /* error in the received stream */
+ emit loginResponse(Yahoo::LoginSock, QString());
+ kdDebug(YAHOO_RAW_DEBUG) << "unknown error logging in" << endl;
+ break;
+ case 1212:
+ /* password incorrect */
+ emit loginResponse(Yahoo::LoginPasswd, QString());
+ kdDebug(YAHOO_RAW_DEBUG) << "password incorrect" << endl;
+ break;
+ case 1213:
+ /* security lock */
+ emit loginResponse(Yahoo::LoginLock, QString());
+ break;
+ case 1235:
+ /* username does not exist */
+ emit loginResponse(Yahoo::LoginUname, QString());
+ kdDebug(YAHOO_RAW_DEBUG) << "user does not exist" << endl;
+ break;
+ case 1214:
+ case 1236:
+ emit loginResponse(Yahoo::LoginVerify, QString());
+ break;
+ case 100: /* username or password missing */
+ /*FIXME handle this */
+ break;
+ default:
+ /* FIXME unknown error. handle it! */
+ break;
+ }
+ }
+ else
+ {
+ /* start stage 2 here */
+ sendAuthSixteenStage2(token);
+ }
+ }
+}
+
+void LoginTask::sendAuthSixteenStage2(const QString& token)
+{
+ const QString YahooLoginUrl = "https://login.yahoo.com/config/pwtoken_login?src=ymsgr&ts=&token=%1";
+ kdDebug(YAHOO_RAW_DEBUG) << "token:" << token << endl;
+ m_stage2Data = QString::null;
+ QString fullUrl = YahooLoginUrl.arg(token);
+ KURL loginUrl(fullUrl);
+ KIO::Job* job = KIO::get(loginUrl, true, false);
+ connect(job, SIGNAL(data(KIO::Job*, const QByteArray&)),
+ this, SLOT(handleAuthSixteenStage2Data(KIO::Job*, const QByteArray&)));
+ connect(job, SIGNAL(result(KIO::Job*)),
+ this, SLOT(handleAuthSixteenStage2Result(KIO::Job*)));
+}
+
+void LoginTask::handleAuthSixteenStage2Data(KIO::Job*, const QByteArray& data)
+{
+ kdDebug(YAHOO_RAW_DEBUG) << "data:" << data << endl;
+ m_stage2Data.append(data);
+}
+
+void LoginTask::handleAuthSixteenStage2Result(KIO::Job* job)
+{
+ QString crumb;
+ int responseNumber = -1;
+ int error = job->error();
+ kdDebug(YAHOO_RAW_DEBUG) << "error:" << error << endl;
+ if (error == 0)
{
- t->setParam( 227 , m_verificationWord.local8Bit() );
- m_verificationWord = QString::null;
+ QStringList responses = QStringList::split("\r\n", m_stage2Data);
+ kdDebug(YAHOO_RAW_DEBUG) << responses << endl;
+ responseNumber = responses[0].toInt();
+ if (responseNumber == 0)
+ {
+ crumb = responses[1];
+ crumb.remove("crumb=");
+ m_yCookie = responses[2].remove(0,2); /* remove Y= */
+ m_tCookie = responses[3].remove(0,2); /* remove T= */
+ }
+
+ if (responseNumber != 0)
+ {
+ switch(responseNumber)
+ {
+ case -1:
+ emit loginResponse(Yahoo::LoginSock, QString());
+ break;
+ case 100:
+ emit loginResponse(Yahoo::LoginSock, QString());
+ break;
+ default: /* try to login anyways */
+ break;
+ }
+ }
+ else
+ {
+ QString cryptString = crumb;
+ cryptString.append(m_challengeString);
+ sendAuthSixteenStage3(cryptString);
+ }
}
+}
+
+void LoginTask::sendAuthSixteenStage3(const QString& cryptString)
+{
+ kdDebug(YAHOO_RAW_DEBUG) << " with crypt string" << cryptString << endl;
+
+ //QByteArray cryptStringHash = QCryptographicHash::hash( cryptString.toAscii(),
+ // QCryptographicHash::Md5 );
+ //cryptStringHash = cryptStringHash.toBase64();
+
+ QString cryptStringHash = KMD5( cryptString.ascii() ).base64Digest();
+
+ cryptStringHash = cryptStringHash.replace('+', '.');
+ cryptStringHash = cryptStringHash.replace('/', '_');
+ cryptStringHash = cryptStringHash.replace('=', '-');
+
+ YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceAuthResp, m_stateOnConnect);
+ t->setId( m_sessionID );
+ t->setParam( 1, client()->userId().local8Bit());
+ t->setParam( 0 , client()->userId().local8Bit());
+ t->setParam( 277, m_yCookie.local8Bit() );
+ t->setParam( 278, m_tCookie.local8Bit() );
+ t->setParam( 307, cryptStringHash.local8Bit() );
+ t->setParam( 244, 2097087 );
+ t->setParam( 2 , client()->userId().local8Bit());
+ t->setParam( 2, 1 ); // Both parameter 2s wind up in the packet
+ t->setParam( 135, YMSG_PROGRAM_VERSION_STRING );
- free(resp_6);
- free(resp_96);
send(t);
}
void LoginTask::sendAuthResp_pre_0x0b(const QString &/*sn*/, const QString &/*seed*/)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
}
void LoginTask::handleAuthResp(YMSGTransfer *t)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
switch( t->service() )
{
case( Yahoo::ServiceList ):
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Emitting Signal" << endl;
- emit loginResponse( Yahoo::LoginOk, QString::null );
+ kdDebug(YAHOO_RAW_DEBUG) << "Emitting Signal" << endl;
+ emit loginResponse( Yahoo::LoginOk, QString() );
break;
case( Yahoo::ServiceAuthResp ):
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Emitting Signal" << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "Emitting Signal" << endl;
emit loginResponse( t->firstParam( 66 ).toInt(), t->firstParam( 20 ) );
break;
default:
@@ -251,10 +411,10 @@ void LoginTask::setStateOnConnect( Yahoo::Status status )
void LoginTask::parseCookies( YMSGTransfer *t )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
for( int i = 0; i < t->paramCount( 59 ); ++i)
- {
+ {
QString cookie;
cookie = t->nthParam( 59, i );
if( cookie.startsWith( "Y" ) )
@@ -271,8 +431,7 @@ void LoginTask::parseCookies( YMSGTransfer *t )
m_cCookie = getcookie( cookie.latin1() );
}
}
- if( !m_yCookie.isEmpty() && !m_tCookie.isEmpty() &&
- !m_cCookie.isEmpty() )
+ if( !m_yCookie.isEmpty() && !m_tCookie.isEmpty())
emit haveCookies();
}
diff --git a/kopete/protocols/yahoo/libkyahoo/logintask.h b/kopete/protocols/yahoo/libkyahoo/logintask.h
index 2ad68853..a3701692 100644
--- a/kopete/protocols/yahoo/libkyahoo/logintask.h
+++ b/kopete/protocols/yahoo/libkyahoo/logintask.h
@@ -4,7 +4,7 @@
Copyright (c) 2004 Duncan Mac-Vicar P. <duncan@kde.org>
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005 André Duffeck <duffeck@kde.org>
Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
@@ -27,6 +27,11 @@
class QString;
class YMSGTransfer;
+namespace KIO
+{
+ class Job;
+}
+
/**
@author Duncan Mac-Vicar
*/
@@ -36,7 +41,7 @@ Q_OBJECT
public:
LoginTask(Task *parent);
~LoginTask();
-
+
bool take(Transfer* transfer);
virtual void onGo();
@@ -49,7 +54,7 @@ public:
const QString &tCookie();
const QString &loginCookie();
protected:
- bool forMe( Transfer* transfer ) const;
+ virtual bool forMe( const Transfer* transfer ) const;
enum State { InitialState, SentVerify, GotVerifyACK, SentAuth, GotAuthACK, SentAuthResp };
void sendVerify();
void sendAuth(YMSGTransfer* transfer);
@@ -58,10 +63,20 @@ protected:
void sendAuthResp_pre_0x0b(const QString &sn, const QString &seed);
void handleAuthResp(YMSGTransfer *transfer);
void parseCookies( YMSGTransfer *transfer );
+ void sendAuthSixteenStage1(const QString& sn, const QString& seed);
+ void sendAuthSixteenStage2(const QString& token);
+ void sendAuthSixteenStage3(const QString& cryptString);
+protected slots:
+ void handleAuthSixteenStage1Data(KIO::Job*, const QByteArray& data);
+ void handleAuthSixteenStage1Result(KIO::Job*);
+ void handleAuthSixteenStage2Data(KIO::Job*, const QByteArray& data);
+ void handleAuthSixteenStage2Result(KIO::Job*);
+
signals:
void haveSessionID( uint );
void haveCookies();
void loginResponse( int, const QString& );
+ void buddyListReady();
private:
State mState;
Yahoo::Status m_stateOnConnect;
@@ -70,6 +85,10 @@ private:
QString m_cCookie;
QString m_loginCookie;
QString m_verificationWord;
+ QString m_stage1Data;
+ QString m_stage2Data;
+ QString m_challengeString;
+ uint m_sessionID;
};
#endif
diff --git a/kopete/protocols/yahoo/libkyahoo/logofftask.cpp b/kopete/protocols/yahoo/libkyahoo/logofftask.cpp
index ed79245e..0531283b 100644
--- a/kopete/protocols/yahoo/libkyahoo/logofftask.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/logofftask.cpp
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Log off the Yahoo server
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -24,7 +24,7 @@
LogoffTask::LogoffTask(Task* parent) : Task(parent)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
}
LogoffTask::~LogoffTask()
@@ -33,11 +33,11 @@ LogoffTask::~LogoffTask()
void LogoffTask::onGo()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceLogoff);
t->setId( client()->sessionID() );
send( t );
-
- setSuccess( true );
+
+ setSuccess();
}
diff --git a/kopete/protocols/yahoo/libkyahoo/logofftask.h b/kopete/protocols/yahoo/libkyahoo/logofftask.h
index 7ef6799d..b04f8f53 100644
--- a/kopete/protocols/yahoo/libkyahoo/logofftask.h
+++ b/kopete/protocols/yahoo/libkyahoo/logofftask.h
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Log off the Yahoo server
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -19,7 +19,6 @@
#include "task.h"
-class QString;
/**
@author André Duffeck
diff --git a/kopete/protocols/yahoo/libkyahoo/mailnotifiertask.cpp b/kopete/protocols/yahoo/libkyahoo/mailnotifiertask.cpp
index 7bea2c8f..1d637877 100644
--- a/kopete/protocols/yahoo/libkyahoo/mailnotifiertask.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/mailnotifiertask.cpp
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Notifies about new mails
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -21,12 +21,11 @@
#include "ymsgtransfer.h"
#include "yahootypes.h"
#include "client.h"
-#include <qstring.h>
#include <kdebug.h>
MailNotifierTask::MailNotifierTask(Task* parent) : Task(parent)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
}
MailNotifierTask::~MailNotifierTask()
@@ -36,8 +35,6 @@ MailNotifierTask::~MailNotifierTask()
bool MailNotifierTask::take( Transfer* transfer )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
-
if ( !forMe( transfer ) )
return false;
@@ -48,11 +45,10 @@ bool MailNotifierTask::take( Transfer* transfer )
return true;
}
-bool MailNotifierTask::forMe( Transfer* transfer ) const
+bool MailNotifierTask::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;
@@ -64,7 +60,7 @@ bool MailNotifierTask::forMe( Transfer* transfer ) const
void MailNotifierTask::parseMail( YMSGTransfer *t )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
QString count = t->firstParam( 9 );
QString mail = t->firstParam( 42 );
@@ -74,7 +70,7 @@ void MailNotifierTask::parseMail( YMSGTransfer *t )
if( !mail.isEmpty() && !from.isEmpty() && !subject.isEmpty() )
emit mailNotify( QString::fromLatin1( "%1 <%2>").arg( from, mail ), subject, count.toInt() );
else
- emit mailNotify( QString::null, QString::null, count.toInt());
+ emit mailNotify( QString(), QString(), count.toInt());
}
#include "mailnotifiertask.moc"
diff --git a/kopete/protocols/yahoo/libkyahoo/mailnotifiertask.h b/kopete/protocols/yahoo/libkyahoo/mailnotifiertask.h
index 9fcf8ad4..1564eb16 100644
--- a/kopete/protocols/yahoo/libkyahoo/mailnotifiertask.h
+++ b/kopete/protocols/yahoo/libkyahoo/mailnotifiertask.h
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Notifies about new mails
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -35,7 +35,7 @@ public:
bool take(Transfer *transfer);
protected:
- bool forMe( Transfer *transfer ) const;
+ virtual bool forMe( const Transfer *transfer ) const;
void parseMail( YMSGTransfer *transfer );
signals:
void mailNotify(const QString&, const QString&, int);
diff --git a/kopete/protocols/yahoo/libkyahoo/md5.c b/kopete/protocols/yahoo/libkyahoo/md5.c
index ede1fc11..5a537e04 100644
--- a/kopete/protocols/yahoo/libkyahoo/md5.c
+++ b/kopete/protocols/yahoo/libkyahoo/md5.c
@@ -37,9 +37,7 @@
1999-05-03 lpd Original version.
*/
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
+#include "../../../../config.h"
#include "md5.h"
diff --git a/kopete/protocols/yahoo/libkyahoo/messagereceivertask.cpp b/kopete/protocols/yahoo/libkyahoo/messagereceivertask.cpp
index f814d244..698552a3 100644
--- a/kopete/protocols/yahoo/libkyahoo/messagereceivertask.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/messagereceivertask.cpp
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Receive Messages
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -21,12 +21,11 @@
#include "ymsgtransfer.h"
#include "yahootypes.h"
#include "client.h"
-#include <qstring.h>
#include <kdebug.h>
MessageReceiverTask::MessageReceiverTask(Task* parent) : Task(parent)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
}
MessageReceiverTask::~MessageReceiverTask()
@@ -35,8 +34,6 @@ MessageReceiverTask::~MessageReceiverTask()
bool MessageReceiverTask::take( Transfer* transfer )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
-
if ( !forMe( transfer ) )
return false;
@@ -44,7 +41,7 @@ bool MessageReceiverTask::take( Transfer* transfer )
t = dynamic_cast<YMSGTransfer*>(transfer);
if (!t)
return false;
-
+
if( t->service() == Yahoo::ServiceNotify )
parseNotify( t );
else
@@ -53,19 +50,17 @@ bool MessageReceiverTask::take( Transfer* transfer )
return true;
}
-bool MessageReceiverTask::forMe( Transfer* transfer ) const
+bool MessageReceiverTask::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;
if ( t->service() == Yahoo::ServiceMessage ||
t->service() == Yahoo::ServiceGameMsg ||
t->service() == Yahoo::ServiceSysMessage ||
- t->service() == Yahoo::ServiceNotify )
+ t->service() == Yahoo::ServiceNotify )
return true;
else
return false;
@@ -73,7 +68,7 @@ bool MessageReceiverTask::forMe( Transfer* transfer ) const
void MessageReceiverTask::parseMessage( YMSGTransfer *t )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
int cnt = t->paramCount( 5 );
for( int i = 0; i < cnt; ++i )
@@ -89,26 +84,26 @@ void MessageReceiverTask::parseMessage( YMSGTransfer *t )
// Separating by key "5" (sender) doesn't work in that case, because the "1" and "4" keys are sent before the "5" key
if( cnt == 1 )
from = t->firstParam( 1 ).isEmpty() ? t->firstParam( 4 ) : t->firstParam( 1 );
-
+
if( !sysmsg.isEmpty() )
{
client()->notifyError( "Server message received: ", sysmsg, Client::Error );
continue;
}
-
+
if( msg.isEmpty() )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Got a empty message. Dropped." << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "Got a empty message. Dropped." << endl;
continue;
}
-
+
if( utf8.startsWith( "1" ) )
msg = QString::fromUtf8( msg.latin1() );
-
+
if( t->service() == Yahoo::ServiceSysMessage )
emit systemMessage( sysmsg );
else
- {
+ {
if( msg.startsWith( "<ding>" ) )
emit gotBuzz( from, timestamp.toLong() );
else
@@ -119,7 +114,7 @@ void MessageReceiverTask::parseMessage( YMSGTransfer *t )
void MessageReceiverTask::parseNotify( YMSGTransfer *t )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
QString from = t->firstParam( 4 );
//QString to = t->firstParam( 5 );
@@ -135,12 +130,12 @@ void MessageReceiverTask::parseNotify( YMSGTransfer *t )
{
if( ind.startsWith(" ") )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Got a WebcamInvitation." << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "Got a WebcamInvitation." << endl;
emit gotWebcamInvite( from );
}
else
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Got a WebcamRequest-Response: " << ind.toInt() << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "Got a WebcamRequest-Response: " << ind.toInt() << endl;
}
}
}
diff --git a/kopete/protocols/yahoo/libkyahoo/messagereceivertask.h b/kopete/protocols/yahoo/libkyahoo/messagereceivertask.h
index b9682315..6ff26bca 100644
--- a/kopete/protocols/yahoo/libkyahoo/messagereceivertask.h
+++ b/kopete/protocols/yahoo/libkyahoo/messagereceivertask.h
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Receive Messages
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -35,7 +35,7 @@ public:
bool take(Transfer *transfer);
protected:
- bool forMe( Transfer *transfer ) const;
+ virtual bool forMe( const Transfer *transfer ) const;
void parseMessage( YMSGTransfer *transfer );
void parseNotify( YMSGTransfer *transfer );
signals:
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 <andre.duffeck@kdemail.net>
+ Copyright (c) 2005-2006 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -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"
diff --git a/kopete/protocols/yahoo/libkyahoo/modifybuddytask.h b/kopete/protocols/yahoo/libkyahoo/modifybuddytask.h
index 7438a25f..4b135f93 100644
--- a/kopete/protocols/yahoo/libkyahoo/modifybuddytask.h
+++ b/kopete/protocols/yahoo/libkyahoo/modifybuddytask.h
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Add, remove or move a buddy to the Contactlist
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -26,6 +26,7 @@ class QString;
*/
class ModifyBuddyTask : public Task
{
+Q_OBJECT
public:
enum Type { AddBuddy, RemoveBuddy, MoveBuddy };
ModifyBuddyTask(Task *parent);
@@ -33,11 +34,22 @@ public:
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();
diff --git a/kopete/protocols/yahoo/libkyahoo/modifyyabtask.cpp b/kopete/protocols/yahoo/libkyahoo/modifyyabtask.cpp
index fe741726..825f958d 100644
--- a/kopete/protocols/yahoo/libkyahoo/modifyyabtask.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/modifyyabtask.cpp
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
modifyyabtask.h - Handles the Yahoo Address Book
- Copyright (c) 2006 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2006 André Duffeck <duffeck@kde.org>
Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
*************************************************************************
@@ -33,7 +33,7 @@
using namespace KNetwork;
ModifyYABTask::ModifyYABTask(Task* parent) : Task(parent)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
m_socket = 0;
}
@@ -44,7 +44,7 @@ ModifyYABTask::~ModifyYABTask()
void ModifyYABTask::onGo()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
m_socket = new KBufferedSocket( "address.yahoo.com", QString::number(80) );
connect( m_socket, SIGNAL( connected( const KResolverEntry& ) ), this, SLOT( connectSucceeded() ) );
connect( m_socket, SIGNAL( gotError(int) ), this, SLOT( connectFailed(int) ) );
@@ -66,7 +66,7 @@ void ModifyYABTask::setEntry( const YABEntry &entry )
root.setAttribute( "k", client()->userId() );
root.setAttribute( "cc", "1" );
doc.appendChild( root );
-
+
QDomElement contact = doc.createElement( "ct" );
entry.fillQDomElement( contact );
switch( m_action )
@@ -90,13 +90,14 @@ void ModifyYABTask::setEntry( const YABEntry &entry )
void ModifyYABTask::connectFailed( int i)
{
m_socket->close();
- client()->notifyError( i18n( "An error occured saving the Addressbook entry." ),
+ client()->notifyError( i18n( "An error occurred while saving the address book entry." ),
QString( "%1 - %2").arg(i).arg(static_cast<const KBufferedSocket*>( sender() )->errorString()), Client::Error );
}
void ModifyYABTask::connectSucceeded()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
+ KBufferedSocket* socket = const_cast<KBufferedSocket*>( static_cast<const KBufferedSocket*>( sender() ) );
QString header = QString::fromLatin1("POST /yab/us?v=XM&prog=ymsgr&.intl=us&sync=1&tags=short&noclear=1& HTTP/1.1\r\n"
"Cookie: Y=%1; T=%2; C=%3 ;B=fckeert1kk1nl&b=2\r\n"
@@ -112,38 +113,36 @@ void ModifyYABTask::connectSucceeded()
QDataStream stream( buffer, IO_WriteOnly );
stream.writeRawBytes( header.local8Bit(), header.length() );
stream.writeRawBytes( m_postData.utf8(), m_postData.utf8().size() );
-
- if( m_socket->writeBlock( buffer, buffer.size() ) )
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Upload Successful. Waiting for confirmation..." << endl;
+
+ if( socket->writeBlock( buffer, buffer.size() ) )
+ kdDebug(YAHOO_RAW_DEBUG) << "Upload Successful. Waiting for confirmation..." << endl;
else
{
- client()->notifyError( i18n( "An error occured saving the Addressbook entry." ), m_socket->errorString(), Client::Error );
- setSuccess( false );
+ client()->notifyError( i18n( "An error occurred while saving the address book entry." ), m_socket->errorString(), Client::Error );
+ setError();
return;
}
-
+
connect( m_socket, SIGNAL( readyRead() ), this, SLOT( slotRead() ) );
}
void ModifyYABTask::slotRead()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
- QByteArray ar( m_socket->bytesAvailable() );
- m_socket->readBlock ( ar.data (), ar.size () );
- QString buf( ar );
- m_data += buf.right( buf.length() - buf.find("<?xml") );
+ KBufferedSocket* socket = const_cast<KBufferedSocket*>( static_cast<const KBufferedSocket*>( sender() ) );
+ QByteArray ar( socket->bytesAvailable() );
+ socket->readBlock( ar.data (), ar.size () );
+ QString data( ar );
+ data = data.right( data.length() - data.find("<?xml") );
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << m_data.find("</ab>") << endl;
if( m_data.find("</ab>") < 0 )
return; // Need more data
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << m_data.find("</ab>") << endl;
m_socket->close();
QDomDocument doc;
QDomNodeList list;
QDomElement e;
- uint it = 0;
-
+ int it = 0;
+
doc.setContent( m_data );
list = doc.elementsByTagName( "ab" ); // Get the Addressbook
@@ -151,7 +150,7 @@ void ModifyYABTask::slotRead()
if( !list.item( it ).isElement() )
continue;
e = list.item( it ).toElement();
-
+
if( !e.attribute( "lm" ).isEmpty() )
emit gotRevision( e.attribute( "lm" ).toLong(), true );
@@ -161,11 +160,11 @@ void ModifyYABTask::slotRead()
list = doc.elementsByTagName( "ct" ); // Get records
for( it = 0; it < list.count(); it++ ) {
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Parsing entry..." << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "Parsing entry..." << endl;
if( !list.item( it ).isElement() )
continue;
e = list.item( it ).toElement();
-
+
YABEntry *entry = new YABEntry;
entry->fromQDomElement( e );
entry->source = YABEntry::SourceYAB;
@@ -175,31 +174,31 @@ void ModifyYABTask::slotRead()
case EditEntry:
if( !e.attribute( "es" ).isEmpty() && e.attribute( "es" ) != "0" ) // Check for edit errors
{
- emit error( entry, i18n("The Yahoo Addressbook entry could not be saved:\n%1 - %2").arg( e.attribute("es") ).arg( e.attribute("ee") ) );
+ emit error( entry, i18n("The Yahoo Address Book entry could not be saved:\n%1 - %2").arg( e.attribute("es") ).arg( e.attribute("ee") ) );
continue;
}
break;
case AddEntry:
if( !e.attribute( "as" ).isEmpty() && e.attribute( "as" ) != "0" ) // Check for add errors
{
- emit error( entry, i18n("The Yahoo Addressbook entry could not be created:\n%1 - %2").arg( e.attribute("as") ).arg( e.attribute("ae") ) );
+ emit error( entry, i18n("The Yahoo Address Book entry could not be created:\n%1 - %2").arg( e.attribute("as") ).arg( e.attribute("ae") ) );
continue;
}
break;
case DeleteEntry:
if( !e.attribute( "ds" ).isEmpty() && e.attribute( "ds" ) != "0" ) // Check for delete errors
{
- emit error( entry, i18n("The Yahoo Addressbook entry could not be deleted:\n%1 - %2").arg( e.attribute("ds") ).arg( e.attribute("de") ) );
+ emit error( entry, i18n("The Yahoo Address Book entry could not be deleted:\n%1 - %2").arg( e.attribute("ds") ).arg( e.attribute("de") ) );
continue;
}
break;
}
- // No errors occured
+ // No errors occurred
emit gotEntry( entry );
}
-
- setSuccess( true );
+
+ setSuccess();
}
#include "modifyyabtask.moc"
diff --git a/kopete/protocols/yahoo/libkyahoo/modifyyabtask.h b/kopete/protocols/yahoo/libkyahoo/modifyyabtask.h
index 488ae741..cb9acde8 100644
--- a/kopete/protocols/yahoo/libkyahoo/modifyyabtask.h
+++ b/kopete/protocols/yahoo/libkyahoo/modifyyabtask.h
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
modifyyabtask.h - Saves a YAB entry
- Copyright (c) 2006 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2006 André Duffeck <duffeck@kde.org>
Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
*************************************************************************
@@ -21,7 +21,6 @@
#include "task.h"
#include "yabentry.h"
-struct KURL;
namespace KIO {
class Job;
class TransferJob;
@@ -29,7 +28,6 @@ namespace KIO {
namespace KNetwork {
class KBufferedSocket;
}
-class QDomElement;
/**
@author André Duffeck
diff --git a/kopete/protocols/yahoo/libkyahoo/oscartypes.h b/kopete/protocols/yahoo/libkyahoo/oscartypes.h
index 944019e7..74ee818e 100644
--- a/kopete/protocols/yahoo/libkyahoo/oscartypes.h
+++ b/kopete/protocols/yahoo/libkyahoo/oscartypes.h
@@ -16,16 +16,16 @@
*************************************************************************
*/
-#ifndef _YAHOOTYPES_H_
-#define _YAHOOTYPES_H_
+#ifndef OSCARTYPES_H
+#define OSCARTYPES_H
#include <qglobal.h>
namespace Yahoo
{
- typedef Q_UINT8 BYTE;
- typedef Q_UINT16 WORD;
- typedef Q_UINT32 DWORD;
+ typedef quint8 BYTE;
+ typedef quint16 WORD;
+ typedef quint32 DWORD;
}
-#endif
+#endif // OSCARTYPES_H
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 <andre.duffeck@kdemail.net>
+ Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -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 );
}
}
diff --git a/kopete/protocols/yahoo/libkyahoo/picturenotifiertask.h b/kopete/protocols/yahoo/libkyahoo/picturenotifiertask.h
index b6580903..1a6536af 100644
--- a/kopete/protocols/yahoo/libkyahoo/picturenotifiertask.h
+++ b/kopete/protocols/yahoo/libkyahoo/picturenotifiertask.h
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Notifies about buddy icons
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -19,8 +19,9 @@
#include "task.h"
+#include <kurl.h>
+
class QString;
-class KURL;
class YMSGTransfer;
/**
@author André Duffeck
@@ -31,11 +32,11 @@ Q_OBJECT
public:
PictureNotifierTask(Task *parent);
~PictureNotifierTask();
-
+
bool take(Transfer *transfer);
protected:
- bool forMe( Transfer *transfer ) const;
+ virtual bool forMe( const Transfer *transfer ) const;
void parsePictureChecksum( YMSGTransfer *transfer );
void parsePictureStatus( YMSGTransfer *transfer );
void parsePicture( YMSGTransfer *transfer );
@@ -43,9 +44,9 @@ protected:
signals:
void pictureStatusNotify( const QString &, int );
void pictureChecksumNotify( const QString &, int );
- void pictureInfoNotify( const QString &, KURL, int );
+ void pictureInfoNotify( const QString &, KURL, int );
void pictureRequest( const QString & );
- void pictureUploaded( const QString & );
+ void pictureUploaded( const QString &, int );
};
#endif
diff --git a/kopete/protocols/yahoo/libkyahoo/pingtask.cpp b/kopete/protocols/yahoo/libkyahoo/pingtask.cpp
index 022d8e7f..c8a97cd7 100644
--- a/kopete/protocols/yahoo/libkyahoo/pingtask.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/pingtask.cpp
@@ -2,7 +2,7 @@
pingtask.cpp
Send a ping to the server
- Copyright (c) 2006 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2006 André Duffeck <duffeck@kde.org>
Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
@@ -26,7 +26,7 @@
PingTask::PingTask(Task* parent) : Task(parent)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
}
PingTask::~PingTask()
@@ -35,12 +35,12 @@ PingTask::~PingTask()
void PingTask::onGo()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServicePing7);
t->setParam( 0, client()->userId().local8Bit() );
t->setId( client()->sessionID() );
send( t );
- setSuccess( true );
+ setSuccess();
}
diff --git a/kopete/protocols/yahoo/libkyahoo/pingtask.h b/kopete/protocols/yahoo/libkyahoo/pingtask.h
index 955e7304..f1c2f6a7 100644
--- a/kopete/protocols/yahoo/libkyahoo/pingtask.h
+++ b/kopete/protocols/yahoo/libkyahoo/pingtask.h
@@ -2,7 +2,7 @@
pingtask.h
Send a ping to the server
- Copyright (c) 2006 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2006 André Duffeck <duffeck@kde.org>
Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
diff --git a/kopete/protocols/yahoo/libkyahoo/receivefiletask.cpp b/kopete/protocols/yahoo/libkyahoo/receivefiletask.cpp
index 7b4f2fc3..3bca2217 100644
--- a/kopete/protocols/yahoo/libkyahoo/receivefiletask.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/receivefiletask.cpp
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Receive a file
- Copyright (c) 2006 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2006 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -19,8 +19,9 @@
#include "ymsgtransfer.h"
#include "yahootypes.h"
#include "client.h"
-#include <qstring.h>
+
#include <qtimer.h>
+#include <qfile.h>
#include <kdebug.h>
#include <klocale.h>
#include <kio/global.h>
@@ -29,7 +30,7 @@
ReceiveFileTask::ReceiveFileTask(Task* parent) : Task(parent)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
m_transmitted = 0;
m_file = 0;
m_transferJob = 0;
@@ -43,7 +44,7 @@ ReceiveFileTask::~ReceiveFileTask()
void ReceiveFileTask::onGo()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceFileTransfer7);
switch( m_type )
{
@@ -52,7 +53,8 @@ void ReceiveFileTask::onGo()
if( !m_file->open( IO_WriteOnly ) )
{
emit error( m_transferId, KIO::ERR_CANNOT_OPEN_FOR_WRITING, i18n("Could not open file for writing.") );
- setSuccess( false );
+ setError();
+ delete t;
return;
}
m_transferJob = KIO::get( m_remoteUrl, false, false );
@@ -66,7 +68,7 @@ void ReceiveFileTask::onGo()
t->setParam( 5, m_userId.local8Bit() );
t->setParam( 265, m_remoteUrl.url().local8Bit() );
t->setParam( 222, 3 );
-
+
send( t );
break;
case FileTransfer7Reject:
@@ -75,7 +77,7 @@ void ReceiveFileTask::onGo()
t->setParam( 5, m_userId.local8Bit() );
t->setParam( 265, m_remoteUrl.url().local8Bit() );
t->setParam( 222, 4 );
-
+
send( t );
break;
default:
@@ -85,23 +87,23 @@ void ReceiveFileTask::onGo()
bool ReceiveFileTask::take( Transfer* transfer )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
-
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
+
if ( !forMe( transfer ) )
return false;
-
+
YMSGTransfer *t = static_cast<YMSGTransfer*>(transfer);
parseFileTransfer7Info( t );
-
+
return true;
}
-bool ReceiveFileTask::forMe( Transfer *transfer ) const
+bool ReceiveFileTask::forMe( const Transfer *transfer ) const
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
- YMSGTransfer *t = 0L;
- t = dynamic_cast<YMSGTransfer*>(transfer);
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
+ const YMSGTransfer *t = 0L;
+ t = dynamic_cast<const YMSGTransfer*>(transfer);
if (!t)
return false;
@@ -113,7 +115,7 @@ bool ReceiveFileTask::forMe( Transfer *transfer ) const
return true;
else
return false;
- }
+ }
else
return false;
}
@@ -121,17 +123,16 @@ bool ReceiveFileTask::forMe( Transfer *transfer ) const
void ReceiveFileTask::slotData( KIO::Job *job, const QByteArray& data )
{
Q_UNUSED( job );
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
m_transmitted += data.size();
emit bytesProcessed( m_transferId, m_transmitted );
m_file->writeBlock( data.data() , data.size() );
-
}
void ReceiveFileTask::slotComplete( KIO::Job *job )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
KIO::TransferJob *transfer = static_cast< KIO::TransferJob * >(job);
@@ -139,19 +140,19 @@ void ReceiveFileTask::slotComplete( KIO::Job *job )
m_file->close();
if ( job->error () || transfer->isErrorPage () )
{
- emit error( m_transferId, KIO::ERR_ABORTED, i18n("An error occured while downloading the file.") );
- setSuccess( false );
+ emit error( m_transferId, KIO::ERR_ABORTED, i18n("An error occurred while downloading the file.") );
+ setError();
}
else
{
emit complete( m_transferId );
- setSuccess( true );
+ setSuccess();
}
}
void ReceiveFileTask::parseFileTransfer7Info( YMSGTransfer *transfer )
-{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+{
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
if( transfer->firstParam( 249 ).toInt() == 1 )
{
@@ -162,7 +163,7 @@ void ReceiveFileTask::parseFileTransfer7Info( YMSGTransfer *transfer )
t->setParam( 5, transfer->firstParam( 4 ) );
t->setParam( 265, transfer->firstParam( 265 ) );
t->setParam( 66, -3 );
-
+
send( t );
}
else if( transfer->firstParam( 249 ).toInt() == 3 )
@@ -171,7 +172,7 @@ void ReceiveFileTask::parseFileTransfer7Info( YMSGTransfer *transfer )
if( !m_file->open( IO_WriteOnly ) )
{
emit error( m_transferId, KIO::ERR_CANNOT_OPEN_FOR_WRITING, i18n("Could not open file for writing.") );
- setSuccess( false );
+ setError();
return;
}
@@ -183,23 +184,23 @@ void ReceiveFileTask::parseFileTransfer7Info( YMSGTransfer *transfer )
t->setParam( 27, transfer->firstParam( 27 ) );
t->setParam( 249, 3 ); // Use Reflection server
t->setParam( 251, transfer->firstParam( 251 ) );
-
+
send( t );
// The server expects a HTTP HEAD command prior to the GET
m_mimetypeJob = KIO::mimetype(QString::fromLatin1("http://%1/relay?token=%2&sender=%3&recver=%4")
- .arg(transfer->firstParam( 250 )).arg(transfer->firstParam( 251 )).arg(m_userId).arg(client()->userId()), false);
+ .arg( QString(transfer->firstParam( 250 )) ).arg( QString(transfer->firstParam( 251 )) ).arg(m_userId).arg(client()->userId()), false);
m_mimetypeJob->addMetaData("cookies", "manual");
m_mimetypeJob->addMetaData("setcookies", QString::fromLatin1("Cookie: T=%1; path=/; domain=.yahoo.com; Y=%2; C=%3;")
.arg(client()->tCookie()).arg(client()->yCookie()).arg(client()->cCookie()) );
m_transferJob = KIO::get( QString::fromLatin1("http://%1/relay?token=%2&sender=%3&recver=%4")
- .arg(transfer->firstParam( 250 )).arg(transfer->firstParam( 251 )).arg(m_userId).arg(client()->userId()), false, false );
+ .arg( QString(transfer->firstParam( 250 )) ).arg( QString(transfer->firstParam( 251 )) ).arg(m_userId).arg(client()->userId()), false, false );
QObject::connect( m_transferJob, SIGNAL( result( KIO::Job* ) ), this, SLOT( slotComplete( KIO::Job* ) ) );
QObject::connect( m_transferJob, SIGNAL( data( KIO::Job*, const QByteArray & ) ), this, SLOT( slotData( KIO::Job*, const QByteArray & ) ) );
m_transferJob->addMetaData("cookies", "manual");
- m_transferJob->addMetaData("setcookies", QString::fromLatin1("Cookie: T=%1; path=/; domain=.yahoo.com; Y=%2; C=%3;")
- .arg(client()->tCookie()).arg(client()->yCookie()).arg(client()->cCookie()) );
+ m_transferJob->addMetaData("setcookies", QString::fromLatin1("Cookie: T=%1; path=/; domain=.yahoo.com; Y=%2; path=/; domain=.yahoo.com;")
+ .arg(client()->tCookie()).arg(client()->yCookie()) );
}
}
@@ -232,11 +233,11 @@ void ReceiveFileTask::canceled( unsigned int id )
{
if( m_transferId != id )
return;
-
+
if( m_transferJob )
m_transferJob->kill();
-
- setSuccess( false );
+
+ setError();
}
#include "receivefiletask.moc"
diff --git a/kopete/protocols/yahoo/libkyahoo/receivefiletask.h b/kopete/protocols/yahoo/libkyahoo/receivefiletask.h
index 79bcb605..01644178 100644
--- a/kopete/protocols/yahoo/libkyahoo/receivefiletask.h
+++ b/kopete/protocols/yahoo/libkyahoo/receivefiletask.h
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Receive a file
- Copyright (c) 2006 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2006 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -18,16 +18,16 @@
#define RECEIVEFILETASK_H
#include "task.h"
-#include <qfile.h>
#include <kurl.h>
class QString;
class QFile;
-namespace KIO {
+namespace KIO {
class Job;
class TransferJob;
class MimetypeJob;
}
+
class YMSGTransfer;
/**
@@ -40,20 +40,20 @@ public:
enum Type { FileTransferAccept, FileTransfer7Accept, FileTransfer7Reject };
ReceiveFileTask(Task *parent);
~ReceiveFileTask();
-
+
virtual void onGo();
-
+
void setRemoteUrl( KURL url );
void setLocalUrl( KURL url );
void setFileName( const QString &filename );
void setTransferId( unsigned int transferId );
void setType( Type type );
void setUserId( const QString & userId );
-
+
bool take(Transfer *transfer);
protected:
- bool forMe( Transfer *transfer ) const;
+ virtual bool forMe( const Transfer *transfer ) const;
signals:
void bytesProcessed( unsigned int, unsigned int );
diff --git a/kopete/protocols/yahoo/libkyahoo/requestpicturetask.cpp b/kopete/protocols/yahoo/libkyahoo/requestpicturetask.cpp
index 6527737f..27a35430 100644
--- a/kopete/protocols/yahoo/libkyahoo/requestpicturetask.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/requestpicturetask.cpp
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Request a Picture of a Buddy
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005-2006 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -19,12 +19,12 @@
#include "ymsgtransfer.h"
#include "yahootypes.h"
#include "client.h"
-#include <qstring.h>
+
#include <kdebug.h>
RequestPictureTask::RequestPictureTask(Task* parent) : Task(parent)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
}
RequestPictureTask::~RequestPictureTask()
@@ -35,12 +35,12 @@ void RequestPictureTask::onGo()
{
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServicePicture);
t->setId( client()->sessionID() );
- t->setParam( 4, client()->userId().local8Bit());
+ t->setParam( 1, client()->userId().local8Bit());
t->setParam( 5, m_target.local8Bit() );
t->setParam( 13, "1" );
send( t );
-
- setSuccess( true );
+
+ setSuccess();
}
void RequestPictureTask::setTarget( const QString &target )
diff --git a/kopete/protocols/yahoo/libkyahoo/requestpicturetask.h b/kopete/protocols/yahoo/libkyahoo/requestpicturetask.h
index 146f585e..8a96f6e7 100644
--- a/kopete/protocols/yahoo/libkyahoo/requestpicturetask.h
+++ b/kopete/protocols/yahoo/libkyahoo/requestpicturetask.h
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Request a Picture of a Buddy
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -29,10 +29,10 @@ class RequestPictureTask : public Task
Q_OBJECT
public:
RequestPictureTask(Task *parent);
- ~RequestPictureTask();
-
+ virtual ~RequestPictureTask();
+
virtual void onGo();
-
+
void setTarget( const QString &target );
private:
QString m_target;
diff --git a/kopete/protocols/yahoo/libkyahoo/safedelete.cpp b/kopete/protocols/yahoo/libkyahoo/safedelete.cpp
index 703e8ed3..2b6b09cf 100644
--- a/kopete/protocols/yahoo/libkyahoo/safedelete.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/safedelete.cpp
@@ -3,7 +3,7 @@
Copyright (c) 2004 SUSE Linux AG http://www.suse.com
- Based on Iris, Copyright (C) 2003 Justin Karneges
+ Based on Iris, Copyright (C) 2003 Justin Karneges <justin@affinix.com>
Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
@@ -55,8 +55,9 @@ void SafeDelete::deleteAll()
return;
QObjectListIt it(list);
- for(QObject *o; (o = it.current()); ++it)
+ for(QObject *o; (o = it.current()); ++it)
deleteSingle(o);
+
list.clear();
}
diff --git a/kopete/protocols/yahoo/libkyahoo/safedelete.h b/kopete/protocols/yahoo/libkyahoo/safedelete.h
index e8215c06..fd2ef937 100644
--- a/kopete/protocols/yahoo/libkyahoo/safedelete.h
+++ b/kopete/protocols/yahoo/libkyahoo/safedelete.h
@@ -3,7 +3,7 @@
Copyright (c) 2004 SUSE Linux AG http://www.suse.com
- Based on Iris, Copyright (C) 2003 Justin Karneges
+ Based on Iris, Copyright (C) 2003 Justin Karneges <justin@affinix.com>
Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
diff --git a/kopete/protocols/yahoo/libkyahoo/sendauthresptask.cpp b/kopete/protocols/yahoo/libkyahoo/sendauthresptask.cpp
index 7c40e708..28dfc664 100644
--- a/kopete/protocols/yahoo/libkyahoo/sendauthresptask.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/sendauthresptask.cpp
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Send a authorization request response
- Copyright (c) 2006 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2006 André Duffeck <duffeck@kde.org>
Kopete (c) 2003-2006 by the Kopete developers <kopete-devel@kde.org>
*************************************************************************
@@ -25,7 +25,7 @@
SendAuthRespTask::SendAuthRespTask(Task* parent) : Task(parent)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
}
SendAuthRespTask::~SendAuthRespTask()
@@ -51,7 +51,7 @@ void SendAuthRespTask::onGo()
}
send( t );
- setSuccess( true );
+ setSuccess();
}
void SendAuthRespTask::setGranted( bool granted )
diff --git a/kopete/protocols/yahoo/libkyahoo/sendauthresptask.h b/kopete/protocols/yahoo/libkyahoo/sendauthresptask.h
index 8c0beb90..fed15168 100644
--- a/kopete/protocols/yahoo/libkyahoo/sendauthresptask.h
+++ b/kopete/protocols/yahoo/libkyahoo/sendauthresptask.h
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Send a authorization request response
- Copyright (c) 2006 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2006 André Duffeck <duffeck@kde.org>
Kopete (c) 2003-2006 by the Kopete developers <kopete-devel@kde.org>
*************************************************************************
diff --git a/kopete/protocols/yahoo/libkyahoo/sendfiletask.cpp b/kopete/protocols/yahoo/libkyahoo/sendfiletask.cpp
index d0f843f2..5cdcf5c3 100644
--- a/kopete/protocols/yahoo/libkyahoo/sendfiletask.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/sendfiletask.cpp
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Send a file
- Copyright (c) 2006 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2006 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -21,6 +21,7 @@
#include "client.h"
#include <qstring.h>
#include <qtimer.h>
+#include <kapplication.h> // for random()
#include <kdebug.h>
#include <klocale.h>
#include <kstreamsocket.h>
@@ -30,9 +31,11 @@ using namespace KNetwork;
SendFileTask::SendFileTask(Task* parent) : Task(parent)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
m_transmitted = 0;
m_socket = 0;
+
+ QTime epoch(0, 0, 0);
}
SendFileTask::~SendFileTask()
@@ -41,47 +44,159 @@ SendFileTask::~SendFileTask()
m_socket = 0;
}
+bool SendFileTask::forMe( const Transfer *transfer ) const
+{
+ const YMSGTransfer *t = static_cast<const YMSGTransfer*>(transfer);
+
+ if(!t)
+ return false;
+
+ if((t->service() == Yahoo::ServiceFileTransfer7 ||
+ t->service() == Yahoo::ServiceFileTransfer7Accept) &&
+ t->firstParam(265).data() == m_yahooTransferId)
+ {
+ return true;
+ }
+
+ return false;
+}
+
+bool SendFileTask::take(Transfer* transfer)
+{
+ if( !forMe( transfer ) )
+ return false;
+
+ YMSGTransfer *t = static_cast<YMSGTransfer*>(transfer);
+
+ kdDebug(YAHOO_RAW_DEBUG) << t->service() << endl;
+
+ if(t->service() == Yahoo::ServiceFileTransfer7)
+ parseFileTransfer(t);
+ else if(t->service() == Yahoo::ServiceFileTransfer7Accept)
+ parseTransferAccept(t);
+
+ return true;
+}
+
+void SendFileTask::parseFileTransfer( const Transfer *transfer )
+{
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
+
+ const YMSGTransfer *t = static_cast<const YMSGTransfer*>(transfer);
+
+ if(!t)
+ return;
+
+ if(t->firstParam(222).toInt() == 4)
+ {
+ emit declined();
+ }
+ else if(t->firstParam(222).toInt() == 3)
+ {
+ sendFileTransferInfo();
+ }
+ else
+ {
+ setError();
+ emit error(m_transferId, 0, i18n("Unknown error"));
+ }
+}
+
void SendFileTask::onGo()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
+
+ m_file.setName( m_url.path() );
+
+ m_yahooTransferId = newYahooTransferId();
+
+ YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceFileTransfer7);
+ t->setId( client()->sessionID() );
+
+ t->setParam( 1, client()->userId().local8Bit() );
+ t->setParam( 5, m_target.local8Bit() );
+ t->setParam( 265, m_yahooTransferId.local8Bit() );
+ t->setParam( 222, 1 );
+ t->setParam( 266, 1 );
+ t->setParam( 302, 268 );
+ t->setParam( 300, 268 );
+ t->setParam( 27, m_url.fileName().local8Bit() );
+ t->setParam( 28, m_file.size());
+ t->setParam( 301, 268 );
+ t->setParam( 303, 268 );
- QTimer::singleShot( 0, this, SLOT(initiateUpload()) );
+ send( t );
}
-void SendFileTask::initiateUpload()
+void SendFileTask::sendFileTransferInfo()
+{
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
+
+ KResolverResults results = KResolver::resolve("filetransfer.msg.yahoo.com", QString::number(80));
+ if(results.count() > 0)
+ {
+ m_relayHost = results.first().address().toString();
+ m_relayHost = m_relayHost.left( m_relayHost.length() - 3 ); // Remove the :80 from the end
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << m_relayHost << endl;
+ }
+ else
+ {
+ emit error(m_transferId, 0, i18n("Unable to connect to file transfer server"));
+ setError();
+ return;
+ }
+
+ YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceFileTransfer7Info);
+ t->setId( client()->sessionID() );
+
+ t->setParam( 1, client()->userId().local8Bit() );
+ t->setParam( 5, m_target.local8Bit() );
+ t->setParam( 265, m_yahooTransferId.local8Bit() );
+ t->setParam( 27, m_url.fileName().local8Bit() );
+ t->setParam( 249, 3 );
+ t->setParam( 250, m_relayHost.local8Bit() );
+
+ send( t );
+}
+
+void SendFileTask::parseTransferAccept(const Transfer *transfer)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
- m_socket = new KStreamSocket( "filetransfer.msg.yahoo.com", QString::number(80) );
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
+
+ const YMSGTransfer *t = static_cast<const YMSGTransfer*>(transfer);
+
+ // Disconnected
+ if(t->status() == Yahoo::StatusDisconnected)
+ {
+ setError();
+ return;
+ }
+
+ m_token = KURL::encode_string(t->firstParam(251));
+ kdDebug(YAHOO_RAW_DEBUG) << "Token: " << m_token << endl;
+
+ m_socket = new KStreamSocket( m_relayHost, QString::number(80) );
m_socket->setBlocking( true );
connect( m_socket, SIGNAL( connected( const KResolverEntry& ) ), this, SLOT( connectSucceeded() ) );
connect( m_socket, SIGNAL( gotError(int) ), this, SLOT( connectFailed(int) ) );
m_socket->connect();
+
}
void SendFileTask::connectFailed( int i )
{
- QString err = m_socket->errorString();
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << i << ": " << err << endl;
+ QString err = KSocketBase::errorString(m_socket->error());
+ kdDebug(YAHOO_RAW_DEBUG) << i << ": " << err << endl;
emit error( m_transferId, i, err );
- setSuccess( false );
+ setError();
}
void SendFileTask::connectSucceeded()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
- YMSGTransfer t( Yahoo::ServiceFileTransfer );
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
- m_file.setName( m_url.path() );
-
- t.setId( client()->sessionID() );
- t.setParam( 0, client()->userId().local8Bit());
- t.setParam( 5, m_target.local8Bit());
- t.setParam( 28, m_file.size() );
- t.setParam( 27, m_url.fileName().local8Bit() );
- t.setParam( 14, "" );
QByteArray buffer;
- QByteArray paket;
QDataStream stream( buffer, IO_WriteOnly );
if ( m_file.open(IO_ReadOnly ) )
@@ -90,22 +205,25 @@ void SendFileTask::connectSucceeded()
}
else
{
- client()->notifyError( i18n( "An error occured sending the file." ), m_file.errorString(), Client::Error );
- setSuccess( false );
+ kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Error opening file: " << m_file.errorString() << endl;
+ client()->notifyError( i18n( "An error occurred while sending the file." ), m_file.errorString(), Client::Error );
+ setError();
return;
}
- paket = t.serialize();
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Sizes: File (" << m_url << "): " << m_file.size() << " - paket: " << paket.size() << endl;
- QString header = QString::fromLatin1("POST http://filetransfer.msg.yahoo.com:80/notifyft HTTP/1.1\r\n"
- "Cookie: Y=%1; T=%2; C=%3 ;B=fckeert1kk1nl&b=2\r\n"
- "User-Agent: Mozilla/4.0 (compatible; MSIE 5.5)\r\n"
- "Host: filetransfer.msg.yahoo.com:80\r\n"
- "Content-length: %4\r\n"
- "Cache-Control: no-cache\r\n\r\n").arg(client()->yCookie()).arg(client()->tCookie()).arg(client()->cCookie()).arg(m_file.size()+4+paket.size());
+ kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Sizes: File (" << m_url << "): " << m_file.size() << endl;
+ QString header =
+ "POST /relay?token=" + m_token +
+ "&sender=" + client()->userId() +
+ "&recver=" + m_target + " HTTP/1.1\r\n"
+ "User-Agent: Mozilla/5.0\r\n"
+ "Cache-Control: no-cache\r\n"
+ "Cookie: T=" + client()->tCookie() + "; Y=" + client()->yCookie() + "\r\n"
+ "Host: " + m_relayHost + "\r\n"
+ "Content-Length: " + QString::number(m_file.size()) + "\r\n"
+ "Connection: Close\r\n\r\n";
+ kdDebug() << header << endl;
stream.writeRawBytes( header.local8Bit(), header.length() );
- stream.writeRawBytes( paket.data(), paket.size() );
- stream << (Q_INT8)0x32 << (Q_INT8)0x39 << (Q_INT8)0xc0 << (Q_INT8)0x80;
if( !m_socket->writeBlock( buffer, buffer.size() ) )
{
@@ -121,7 +239,7 @@ void SendFileTask::connectSucceeded()
void SendFileTask::transmitData()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
int read = 0;
int written = 0;
char buf[1024];
@@ -138,14 +256,14 @@ void SendFileTask::transmitData()
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Upload Failed!" << endl;
emit error( m_transferId, m_socket->error(), m_socket->errorString() );
- setSuccess( false );
+ setError();
return;
}
if( m_transmitted == m_file.size() )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Upload Successful: " << m_transmitted << endl;
emit complete( m_transferId );
- setSuccess( true );
+ setSuccess();
m_socket->close();
}
else
@@ -182,7 +300,32 @@ void SendFileTask::canceled( unsigned int id )
if( m_socket )
m_socket->close();
- setSuccess( false );
+ setError();
+}
+
+QString SendFileTask::newYahooTransferId()
+{
+ // Adapted from libpurple/protocols/yahoo/yahoo_filexfer.c yahoo_xfer_new_xfer_id()
+
+ QString newId;
+
+ for(int i = 0; i < 22; i++)
+ {
+ char j = KApplication::random() % 61;
+
+ if(j < 26)
+ newId += j + 'a';
+ else if(j < 52)
+ newId += j - 26 + 'A';
+ else
+ newId += j - 52 + '0';
+ }
+
+ newId += "$$";
+
+ kdDebug() << "New Yahoo Transfer Id: " << newId << endl;
+
+ return newId;
}
#include "sendfiletask.moc"
diff --git a/kopete/protocols/yahoo/libkyahoo/sendfiletask.h b/kopete/protocols/yahoo/libkyahoo/sendfiletask.h
index 41e62f77..83a205e2 100644
--- a/kopete/protocols/yahoo/libkyahoo/sendfiletask.h
+++ b/kopete/protocols/yahoo/libkyahoo/sendfiletask.h
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Send a file
- Copyright (c) 2006 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2006 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -38,6 +38,8 @@ public:
virtual void onGo();
+ bool take(Transfer *transfer);
+
void setTarget( const QString &to );
void setMessage( const QString &msg );
void setFileUrl( KURL url );
@@ -48,8 +50,17 @@ signals:
void complete( unsigned int );
void error( unsigned int, int, const QString & );
+ void declined();
+
+protected:
+ bool forMe( const Transfer *transfer ) const;
+ void sendFileTransferInfo();
+ void parseFileTransfer( const Transfer *transfer );
+ void parseTransferAccept(const Transfer *transfer);
+
+ QString newYahooTransferId();
+
private slots:
- void initiateUpload();
void connectSucceeded();
void connectFailed( int );
void transmitData();
@@ -63,6 +74,10 @@ private:
unsigned int m_transferId;
unsigned int m_transmitted;
KNetwork::KStreamSocket *m_socket;
+
+ QString m_relayHost;
+ QString m_token;
+ QString m_yahooTransferId;
};
#endif
diff --git a/kopete/protocols/yahoo/libkyahoo/sendmessagetask.cpp b/kopete/protocols/yahoo/libkyahoo/sendmessagetask.cpp
index d93ffcb9..bb6e4802 100644
--- a/kopete/protocols/yahoo/libkyahoo/sendmessagetask.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/sendmessagetask.cpp
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Send a message
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -25,7 +25,7 @@
SendMessageTask::SendMessageTask(Task* parent) : Task(parent)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
}
SendMessageTask::~SendMessageTask()
@@ -34,15 +34,15 @@ SendMessageTask::~SendMessageTask()
void SendMessageTask::onGo()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
if( m_text.isEmpty() )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Text to send is empty." << endl;
- client()->notifyError( i18n( "An error occured sending the message" ), i18n( "The message is empty." ), Client::Debug );
+ kdDebug(YAHOO_RAW_DEBUG) << "Text to send is empty." << endl;
+ client()->notifyError( i18n( "An error occurred while sending the message" ), i18n( "The message is empty." ), Client::Debug );
return;
}
- uint pos=0;
+ int pos=0;
// split messages that are longer than 800 chars. they get dropped otherwise
while( pos < m_text.length() )
@@ -61,7 +61,7 @@ void SendMessageTask::onGo()
pos += 700;
}
- setSuccess( true );
+ setSuccess();
}
void SendMessageTask::setTarget( const QString &to )
diff --git a/kopete/protocols/yahoo/libkyahoo/sendmessagetask.h b/kopete/protocols/yahoo/libkyahoo/sendmessagetask.h
index 41a44ded..b4c31efe 100644
--- a/kopete/protocols/yahoo/libkyahoo/sendmessagetask.h
+++ b/kopete/protocols/yahoo/libkyahoo/sendmessagetask.h
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Send a message
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
diff --git a/kopete/protocols/yahoo/libkyahoo/sendnotifytask.cpp b/kopete/protocols/yahoo/libkyahoo/sendnotifytask.cpp
index 8fd56115..ed424bd3 100644
--- a/kopete/protocols/yahoo/libkyahoo/sendnotifytask.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/sendnotifytask.cpp
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Send a notification
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005-2006 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -19,12 +19,12 @@
#include "ymsgtransfer.h"
#include "yahootypes.h"
#include "client.h"
-#include <qstring.h>
+
#include <kdebug.h>
SendNotifyTask::SendNotifyTask(Task* parent) : Task(parent)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
}
SendNotifyTask::~SendNotifyTask()
@@ -36,29 +36,35 @@ void SendNotifyTask::onGo()
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceNotify);
t->setId( client()->sessionID() );
t->setStatus( Yahoo::StatusNotify );
- t->setParam( 4, client()->userId().local8Bit() );
- t->setParam( 5, m_target.local8Bit() );
- t->setParam( 14, " " );
+
switch( m_type )
{
case NotifyTyping:
+ t->setParam( 4, client()->userId().local8Bit() );
+ t->setParam( 5, m_target.local8Bit() );
t->setParam( 13, m_state );
+ t->setParam( 14, " " );
t->setParam( 49, "TYPING" );
break;
case NotifyWebcamInvite:
+
+ kdDebug(YAHOO_RAW_DEBUG) << "send invitation set Param" << endl;
+ t->setParam( 1, client()->userId().local8Bit() );
+ t->setParam( 5, m_target.local8Bit() );
t->setParam( 13, 0 );
- t->setParam( 49, "WEBCAMINVITE" );
+ t->setParam( 14, " " );
+ t->setParam( 49, "WEBCAMINVITE" );
break;
case NotifyGame:
default:
- setSuccess( false );
+ setError();
delete t;
return;
break;
}
send( t );
-
- setSuccess( true );
+
+ setSuccess();
}
void SendNotifyTask::setType( Type type )
diff --git a/kopete/protocols/yahoo/libkyahoo/sendnotifytask.h b/kopete/protocols/yahoo/libkyahoo/sendnotifytask.h
index 6eb9f6dd..67c0547a 100644
--- a/kopete/protocols/yahoo/libkyahoo/sendnotifytask.h
+++ b/kopete/protocols/yahoo/libkyahoo/sendnotifytask.h
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Send a notification
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
diff --git a/kopete/protocols/yahoo/libkyahoo/sendpicturetask.cpp b/kopete/protocols/yahoo/libkyahoo/sendpicturetask.cpp
index c1b1f5f0..84edecaa 100644
--- a/kopete/protocols/yahoo/libkyahoo/sendpicturetask.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/sendpicturetask.cpp
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
sendpicturetask.cpp - Send our picture or information about it
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -21,7 +21,6 @@
#include "client.h"
#include <qstring.h>
#include <qfile.h>
-#include <qcstring.h>
#include <qdatastream.h>
#include <kio/global.h>
#include <kio/job.h>
@@ -34,7 +33,7 @@ using namespace KNetwork;
SendPictureTask::SendPictureTask(Task* parent) : Task(parent)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
m_socket = 0;
}
@@ -55,6 +54,7 @@ void SendPictureTask::onGo()
break;
case SendInformation:
sendInformation();
+ break;
case SendStatus:
sendStatus();
break;
@@ -62,26 +62,27 @@ void SendPictureTask::onGo()
}
void SendPictureTask::initiateUpload()
-{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+{
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
m_socket = new KBufferedSocket( "filetransfer.msg.yahoo.com", QString::number(80) );
connect( m_socket, SIGNAL( connected( const KResolverEntry& ) ), this, SLOT( connectSucceeded() ) );
connect( m_socket, SIGNAL( gotError(int) ), this, SLOT( connectFailed(int) ) );
+ connect( m_socket, SIGNAL( readyRead() ), this, SLOT( readResult() ) );
m_socket->connect();
}
void SendPictureTask::connectFailed( int i)
{
- m_socket->close();
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << i << ": " << static_cast<const KBufferedSocket*>( sender() )->errorString() << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << i << ": " << static_cast<const KBufferedSocket*>( sender() )->errorString() << endl;
+
client()->notifyError(i18n("The picture was not successfully uploaded"), QString("%1 - %2").arg(i).arg(static_cast<const KBufferedSocket*>( sender() )->errorString()), Client::Error );
- setSuccess( false );
+ setError();
}
void SendPictureTask::connectSucceeded()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
YMSGTransfer t(Yahoo::ServicePictureUpload);
QFile file( m_path );
@@ -90,26 +91,26 @@ void SendPictureTask::connectSucceeded()
t.setParam( 1, client()->userId().local8Bit());
t.setParam( 38, 604800);
t.setParam( 0, client()->userId().local8Bit());
- t.setParam( 28, file.size() );
+ t.setParam( 28, file.size() );
t.setParam( 27, m_fileName.local8Bit() );
t.setParam( 14, "" );
QByteArray buffer;
QByteArray paket;
QDataStream stream( buffer, IO_WriteOnly );
- if ( file.open(IO_ReadOnly ) )
+ if ( file.open( IO_ReadOnly ) )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "File successfully opened. Reading..." << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "File successfully opened. Reading..." << endl;
}
else
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Error opening file: " << file.errorString() << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "Error opening file: " << file.errorString() << endl;
client()->notifyError(i18n("Error opening file: %1").arg(m_path), file.errorString(), Client::Error );
return;
}
paket = t.serialize();
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Sizes: File (" << m_path << "): " << file.size() << " - paket: " << paket.size() << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "Sizes: File (" << m_path << "): " << file.size() << " - paket: " << paket.size() << endl;
QString header = QString::fromLatin1("POST /notifyft HTTP/1.1\r\n"
"Cookie: Y=%1; T=%2; C=%3 ;\r\n"
"User-Agent: Mozilla/4.0 (compatible; MSIE 5.5)\r\n"
@@ -121,43 +122,62 @@ void SendPictureTask::connectSucceeded()
stream << (Q_INT8)0x32 << (Q_INT8)0x39 << (Q_INT8)0xc0 << (Q_INT8)0x80;
stream.writeRawBytes( file.readAll(), file.size() );
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Buffersize: " << buffer.size() << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "Buffersize: " << buffer.size() << endl;
if( m_socket->writeBlock( buffer, buffer.size() ) )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Upload Successful." << endl;
- connect( m_socket, SIGNAL( readyRead() ), this, SLOT( readResult() ) );
+ kdDebug(YAHOO_RAW_DEBUG) << "Upload Successful!" << endl;
+ m_socket->enableRead( true );
+// setSuccess();
}
else
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Upload Failed." << endl;
- m_socket->close();
- setSuccess( false );
+ kdDebug(YAHOO_RAW_DEBUG) << "Upload Failed!" << endl;
+ setError();
}
}
void SendPictureTask::readResult()
{
+ kdDebug(YAHOO_RAW_DEBUG) << m_socket->bytesAvailable() << endl;
+
+ // FIXME: to check
+// m_socket->enableRead( false );
+// QByteArray buf;
+// buf.resize( m_socket->bytesAvailable() );
+// m_socket->read( buf.data(), m_socket->bytesAvailable() );
+//
+// if( buf.indexOf( "error", 0 ) >= 0 )
+// {
+// kdDebug(YAHOO_RAW_DEBUG) << "Picture upload failed" << endl;
+// setError();
+// }
+// else
+// {
+// kdDebug(YAHOO_RAW_DEBUG) << "Picture upload acknowledged." << endl;
+// setSuccess();
+// }
+
+ // from original file
QByteArray ar( m_socket->bytesAvailable() );
- m_socket->readBlock ( ar.data (), ar.size () );
- QString buf( ar );
-
- m_socket->close();
- if( buf.find( "error", 0, false ) >= 0 )
- {
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Picture upload failed" << endl;
- setSuccess( false );
- }
- else
- {
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Picture upload acknowledged." << endl;
- setSuccess( true );
- }
-
+ m_socket->readBlock ( ar.data (), ar.size () );
+ QString buf( ar );
+
+ m_socket->close();
+ if( buf.find( "error", 0, false ) >= 0 )
+ {
+ kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Picture upload failed" << endl;
+ setSuccess( false );
+ }
+ else
+ {
+ kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Picture upload acknowledged." << endl;
+ setSuccess( true );
+ }
}
void SendPictureTask::sendChecksum()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServicePictureChecksum);
t->setId( client()->sessionID() );
@@ -167,41 +187,39 @@ void SendPictureTask::sendChecksum()
t->setParam(192, m_checksum);
t->setParam(212, 1);
send( t );
-
- setSuccess( true );
+
+ setSuccess();
}
void SendPictureTask::sendInformation()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServicePicture);
t->setId( client()->sessionID() );
t->setParam(1, client()->userId().local8Bit());
- t->setParam(4, client()->userId().local8Bit());
t->setParam(13, 2 );
t->setParam(5, m_target.local8Bit() );
t->setParam(20, m_url.local8Bit() );
t->setParam(192, m_checksum);
send( t );
-
- setSuccess( true );
+
+ setSuccess();
}
void SendPictureTask::sendStatus()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
- YMSGTransfer *t = new YMSGTransfer(Yahoo::ServicePictureUpdate);
+ YMSGTransfer *t = new YMSGTransfer(Yahoo::ServicePictureStatus);
t->setId( client()->sessionID() );
- t->setParam(1, client()->userId().local8Bit());
- t->setParam(5, m_target.local8Bit() );
- t->setParam(206, m_status );
+ t->setParam(3, client()->userId().local8Bit());
+ t->setParam(213, m_status );
send( t );
-
- setSuccess( true );
+
+ setSuccess();
}
void SendPictureTask::setType( Type type )
diff --git a/kopete/protocols/yahoo/libkyahoo/sendpicturetask.h b/kopete/protocols/yahoo/libkyahoo/sendpicturetask.h
index da008eb5..b4d0d27e 100644
--- a/kopete/protocols/yahoo/libkyahoo/sendpicturetask.h
+++ b/kopete/protocols/yahoo/libkyahoo/sendpicturetask.h
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
sendpicturetask.h - Send our picture or information about it
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -21,11 +21,11 @@
class QString;
class QFile;
-namespace KIO {
+namespace KIO {
class Job;
- class TransferJob;
+ class TransferJob;
}
-namespace KNetwork {
+namespace KNetwork {
class KBufferedSocket;
}
@@ -39,8 +39,8 @@ public:
enum Type { UploadPicture, SendChecksum, SendInformation, SendStatus };
SendPictureTask(Task *parent);
- ~SendPictureTask();
-
+ virtual ~SendPictureTask();
+
virtual void onGo();
void setType( Type type );
diff --git a/kopete/protocols/yahoo/libkyahoo/sha1.c b/kopete/protocols/yahoo/libkyahoo/sha1.c
index c9a0edbf..69ee51c2 100644
--- a/kopete/protocols/yahoo/libkyahoo/sha1.c
+++ b/kopete/protocols/yahoo/libkyahoo/sha1.c
@@ -37,14 +37,12 @@
* 34aa973c d4c4daa4 f61eeb2b dbad2731 6534016f
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif /* HAVE_CONFIG_H */
+/* #include <config-kopete.h> */
-#if HAVE_INTTYPES_H
+#ifdef HAVE_INTTYPES_H
# include <inttypes.h>
#else
-# if HAVE_STDINT_H
+# ifdef HAVE_STDINT_H
# include <stdint.h>
# endif
#endif
diff --git a/kopete/protocols/yahoo/libkyahoo/sha1.h b/kopete/protocols/yahoo/libkyahoo/sha1.h
index 02a4c732..4c43db17 100644
--- a/kopete/protocols/yahoo/libkyahoo/sha1.h
+++ b/kopete/protocols/yahoo/libkyahoo/sha1.h
@@ -29,6 +29,7 @@
#ifndef _SHA1_H
#define _SHA1_H
+#include "../../../../config.h"
#if HAVE_INTTYPES_H
# include <inttypes.h>
#else
diff --git a/kopete/protocols/yahoo/libkyahoo/statusnotifiertask.cpp b/kopete/protocols/yahoo/libkyahoo/statusnotifiertask.cpp
index 763d560c..c7fcaeac 100644
--- a/kopete/protocols/yahoo/libkyahoo/statusnotifiertask.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/statusnotifiertask.cpp
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Notifies about status changes of buddies
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -26,7 +26,7 @@
StatusNotifierTask::StatusNotifierTask(Task* parent) : Task(parent)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
}
StatusNotifierTask::~StatusNotifierTask()
@@ -36,11 +36,9 @@ StatusNotifierTask::~StatusNotifierTask()
bool StatusNotifierTask::take( Transfer* transfer )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
-
if ( !forMe( transfer ) )
return false;
-
+
YMSGTransfer *t = static_cast<YMSGTransfer*>(transfer);
if( t->service() == Yahoo::ServiceStealthOffline )
@@ -48,16 +46,15 @@ bool StatusNotifierTask::take( Transfer* transfer )
else if( t->service() == Yahoo::ServiceAuthorization )
parseAuthorization( t );
else
- parseStatus( t );
+ parseStatus( t );
return true;
}
-bool StatusNotifierTask::forMe( Transfer* transfer ) const
+bool StatusNotifierTask::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;
@@ -72,7 +69,8 @@ bool StatusNotifierTask::forMe( Transfer* transfer ) const
t->service() == Yahoo::ServiceIddeAct ||
t->service() == Yahoo::ServiceStatus ||
t->service() == Yahoo::ServiceStealthOffline ||
- t->service() == Yahoo::ServiceAuthorization
+ t->service() == Yahoo::ServiceAuthorization ||
+ t->service() == Yahoo::ServiceBuddyStatus
)
return true;
else
@@ -81,12 +79,12 @@ bool StatusNotifierTask::forMe( Transfer* transfer ) const
void StatusNotifierTask::parseStatus( YMSGTransfer* t )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
- if( t->status() == Yahoo::StatusDisconnected &&
+ if( t->status() == Yahoo::StatusDisconnected &&
t->service() == Yahoo::ServiceLogoff )
{
- emit loginResponse( Yahoo::LoginDupl, QString::null );
+ emit loginResponse( Yahoo::LoginDupl, QString() );
}
QString myNick; /* key = 1 */
@@ -98,14 +96,14 @@ void StatusNotifierTask::parseStatus( YMSGTransfer* t )
int away; /* key = 47 */
int idle; /* key = 137 */
bool utf; /* key = 97 */
- int checksum; /* key = 192 */
+ int pictureChecksum; /* key = 192 */
customError = t->firstParam( 16 );
if( !customError.isEmpty() )
- client()->notifyError( i18n("An unknown error has occured."), customError, Client::Warning );
+ client()->notifyError( i18n("An unknown error has occurred."), customError, Client::Warning );
myNick = t->firstParam( 1 );
-
+
for( int i = 0; i < t->paramCount( 7 ); ++i)
{
nick = t->nthParam( 7, i );
@@ -114,27 +112,24 @@ void StatusNotifierTask::parseStatus( YMSGTransfer* t )
away = t->nthParamSeparated( 47, i, 7 ).toInt();
idle = t->nthParamSeparated( 137, i, 7 ).toInt();
utf = t->nthParamSeparated( 97, i, 7 ).toInt() == 1;
- checksum = t->nthParamSeparated( 192, i, 7 ).toInt();
+ pictureChecksum = t->nthParamSeparated( 192, i, 7 ).toInt();
if( utf )
message = QString::fromUtf8( t->nthParamSeparated( 19, i, 7 ) );
else
message = t->nthParamSeparated( 19, i, 7 );
if( t->service() == Yahoo::ServiceLogoff || ( state != 0 && flags == 0 ) )
- emit statusChanged( nick, Yahoo::StatusOffline, QString::null, 0, 0 );
+ emit statusChanged( nick, Yahoo::StatusOffline, QString(), 0, 0, 0 );
else
- emit statusChanged( nick, state, message, away, idle );
-
- if( checksum )
- emit gotPictureChecksum( nick, checksum );
+ emit statusChanged( nick, state, message, away, idle, pictureChecksum );
}
}
void StatusNotifierTask::parseAuthorization( YMSGTransfer* t )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
- QString nick; /* key = 4 */
+ QString nick; /* key = 4 */
QString msg; /* key = 14 */
int state; /* key = 13 */
bool utf; /* key = 97 */
@@ -163,14 +158,14 @@ void StatusNotifierTask::parseAuthorization( YMSGTransfer* t )
if( !fname.isEmpty() || !lname.isEmpty() )
name = QString("%1 %2").arg(fname).arg(lname);
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Emitting gotAuthorizationRequest( " << nick<< ", " << msg << ", " << name << " )" << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "Emitting gotAuthorizationRequest( " << nick<< ", " << msg << ", " << name << " )" << endl;
emit gotAuthorizationRequest( nick, msg, name );
}
}
void StatusNotifierTask::parseStealthStatus( YMSGTransfer* t )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
QString nick; /* key = 7 */
int state; /* key = 31 */
diff --git a/kopete/protocols/yahoo/libkyahoo/statusnotifiertask.h b/kopete/protocols/yahoo/libkyahoo/statusnotifiertask.h
index c7b45b1c..5cc63d8a 100644
--- a/kopete/protocols/yahoo/libkyahoo/statusnotifiertask.h
+++ b/kopete/protocols/yahoo/libkyahoo/statusnotifiertask.h
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Notifies about status changes of buddies
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -36,18 +36,17 @@ public:
bool take(Transfer *transfer);
protected:
- bool forMe( Transfer *transfer ) const;
+ virtual bool forMe( const Transfer *transfer ) const;
void parseStatus( YMSGTransfer *transfer );
void parseStealthStatus( YMSGTransfer *transfer );
void parseAuthorization( YMSGTransfer *transfer );
signals:
- void statusChanged( const QString&, int, const QString&, int, int );
+ void statusChanged( const QString &nick, int state, const QString &message, int away, int idle, int pictureChecksum );
void stealthStatusChanged( const QString&, Yahoo::StealthStatus );
void loginResponse( int, const QString& );
void authorizationAccepted( const QString & );
void authorizationRejected( const QString &, const QString & );
void gotAuthorizationRequest( const QString &, const QString &, const QString & );
- void gotPictureChecksum( const QString &, int );
};
#endif
diff --git a/kopete/protocols/yahoo/libkyahoo/stealthtask.cpp b/kopete/protocols/yahoo/libkyahoo/stealthtask.cpp
index 01ab4e27..89474ab4 100644
--- a/kopete/protocols/yahoo/libkyahoo/stealthtask.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/stealthtask.cpp
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Stealth/Unstealth a buddy
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -23,7 +23,7 @@
StealthTask::StealthTask(Task* parent) : Task(parent)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
}
StealthTask::~StealthTask()
@@ -37,7 +37,7 @@ void StealthTask::onGo()
{
t->setService( Yahoo::ServiceStealthOnline );
t->setParam( 13, "1" );
- t->setParam( 31, m_state );
+ t->setParam( 31, m_state );
}
else if( m_mode == Yahoo::StealthOffline )
{
@@ -53,11 +53,16 @@ void StealthTask::onGo()
}
t->setId( client()->sessionID() );
t->setParam( 1, client()->userId().local8Bit());
- if( !m_target.isEmpty() )
+ if( !m_target.isEmpty() ) {
+ t->setParam( 302, 319 );
+ t->setParam( 300, 319 );
t->setParam( 7, m_target.local8Bit() );
+ t->setParam( 301, 319 );
+ t->setParam( 303, 319 );
+ }
send( t );
-
- setSuccess( true );
+
+ setSuccess();
}
void StealthTask::setTarget( const QString &to )
diff --git a/kopete/protocols/yahoo/libkyahoo/stealthtask.h b/kopete/protocols/yahoo/libkyahoo/stealthtask.h
index 62e70340..6c33da1e 100644
--- a/kopete/protocols/yahoo/libkyahoo/stealthtask.h
+++ b/kopete/protocols/yahoo/libkyahoo/stealthtask.h
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Stealth/Unstealth a buddy
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
diff --git a/kopete/protocols/yahoo/libkyahoo/stream.cpp b/kopete/protocols/yahoo/libkyahoo/stream.cpp
index 02967416..8173281c 100644
--- a/kopete/protocols/yahoo/libkyahoo/stream.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/stream.cpp
@@ -3,7 +3,7 @@
Copyright (c) 2004 SUSE Linux AG http://www.suse.com
- Based on Iris, Copyright (C) 2003 Justin Karneges
+ Based on Iris, Copyright (C) 2003 Justin Karneges <justin@affinix.com>
Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
diff --git a/kopete/protocols/yahoo/libkyahoo/stream.h b/kopete/protocols/yahoo/libkyahoo/stream.h
index b5aa0452..71bcae5c 100644
--- a/kopete/protocols/yahoo/libkyahoo/stream.h
+++ b/kopete/protocols/yahoo/libkyahoo/stream.h
@@ -4,7 +4,7 @@
Copyright (c) 2004 Matt Rogers <matt.rogers@kdemail.net>
Based on code copyright (c) 2004 SuSE Linux AG <http://www.suse.com>
- Based on Iris, Copyright (C) 2003 Justin Karneges
+ Based on Iris, Copyright (C) 2003 Justin Karneges <justin@affinix.com>
Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
@@ -63,7 +63,7 @@ public:
* Send a message to the server
*/
virtual void write( Transfer *request) = 0;
-
+
signals:
void connectionClosed();
diff --git a/kopete/protocols/yahoo/libkyahoo/task.cpp b/kopete/protocols/yahoo/libkyahoo/task.cpp
index 805168a9..f3d1a98c 100644
--- a/kopete/protocols/yahoo/libkyahoo/task.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/task.cpp
@@ -1,12 +1,12 @@
/*
task.cpp - Kopete Groupwise Protocol
-
+
Copyright (c) 2004 SUSE Linux AG http://www.suse.com
-
- Based on Iris, Copyright (C) 2003 Justin Karneges
-
+
+ Based on Iris, Copyright (C) 2003 Justin Karneges <justin@affinix.com>
+
Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
-
+
*************************************************************************
* *
* This library is free software; you can redistribute it and/or *
@@ -16,7 +16,7 @@
* *
*************************************************************************
*/
-
+
#include <qtimer.h>
#include "client.h"
@@ -131,20 +131,19 @@ bool Task::take( Transfer * transfer)
// pass along the transfer to our children
QObjectListIt it(*p);
Task *t;
- for(; it.current(); ++it) {
+ for(; it.current(); ++it)
+ {
QObject *obj = it.current();
if(!obj->inherits("Task"))
continue;
t = static_cast<Task*>(obj);
-
+
if(t->take( transfer ))
{
qDebug( "Transfer ACCEPTED by: %s", t->className() );
return true;
}
-/* else
- qDebug( "Transfer refused by: %s", t->className() );*/
}
return false;
@@ -232,22 +231,22 @@ void Task::clientDisconnected()
// QString str;
// int size = 1024;
// int r;
-//
+//
// do {
// buf = new char[size];
// va_list ap;
// va_start(ap, fmt);
// r = vsnprintf(buf, size, fmt, ap);
// va_end(ap);
-//
+//
// if(r != -1)
// str = QString(buf);
-//
+//
// delete [] buf;
-//
+//
// size *= 2;
// } while(r == -1);
-//
+//
// debug(str);
// }
diff --git a/kopete/protocols/yahoo/libkyahoo/task.h b/kopete/protocols/yahoo/libkyahoo/task.h
index 581512b3..a1a64e45 100644
--- a/kopete/protocols/yahoo/libkyahoo/task.h
+++ b/kopete/protocols/yahoo/libkyahoo/task.h
@@ -3,7 +3,7 @@
Copyright (c) 2004 SUSE Linux AG http://www.suse.com
- Based on Iris, Copyright (C) 2003 Justin Karneges
+ Based on Iris, Copyright (C) 2003 Justin Karneges <justin@affinix.com>
Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
@@ -25,7 +25,6 @@
class QString;
class Client;
-class Request;
class Transfer;
class Task : public QObject
diff --git a/kopete/protocols/yahoo/libkyahoo/webcamtask.cpp b/kopete/protocols/yahoo/libkyahoo/webcamtask.cpp
index 29087440..fe3c6d7c 100644
--- a/kopete/protocols/yahoo/libkyahoo/webcamtask.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/webcamtask.cpp
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Handles incoming webcam connections
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -20,10 +20,11 @@
#include "ymsgtransfer.h"
#include "yahootypes.h"
#include "client.h"
-#include <qstring.h>
+
#include <qbuffer.h>
#include <qfile.h>
#include <qtimer.h>
+#include <qpixmap.h>
#include <ktempfile.h>
#include <kprocess.h>
#include <kstreamsocket.h>
@@ -34,7 +35,7 @@ using namespace KNetwork;
WebcamTask::WebcamTask(Task* parent) : Task(parent)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
transmittingData = false;
transmissionPending = false;
timestamp = 1;
@@ -46,13 +47,11 @@ WebcamTask::~WebcamTask()
bool WebcamTask::take( Transfer* transfer )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
-
if ( !forMe( transfer ) )
return false;
YMSGTransfer *t = static_cast<YMSGTransfer*>(transfer);
-
+
if( t->service() == Yahoo::ServiceWebcam )
parseWebcamInformation( t );
// else
@@ -61,16 +60,14 @@ bool WebcamTask::take( Transfer* transfer )
return true;
}
-bool WebcamTask::forMe( Transfer* transfer ) const
+bool WebcamTask::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;
- if ( t->service() == Yahoo::ServiceWebcam )
+ if ( t->service() == Yahoo::ServiceWebcam )
return true;
else
return false;
@@ -78,8 +75,8 @@ bool WebcamTask::forMe( Transfer* transfer ) const
void WebcamTask::requestWebcam( const QString &who )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
-
+ kdDebug(YAHOO_RAW_DEBUG) ;
+
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceWebcam);
t->setId( client()->sessionID() );
t->setParam( 1, client()->userId().local8Bit());
@@ -91,7 +88,7 @@ void WebcamTask::requestWebcam( const QString &who )
void WebcamTask::parseWebcamInformation( YMSGTransfer *t )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
YahooWebcamInformation info;
info.sender = keyPending;
@@ -108,8 +105,8 @@ void WebcamTask::parseWebcamInformation( YMSGTransfer *t )
}
else
info.direction = Incoming;
-
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Got WebcamInformation: Sender: " << info.sender << " Server: " << info.server << " Key: " << info.key << endl;
+
+ kdDebug(YAHOO_RAW_DEBUG) << "Got WebcamInformation: Sender: " << info.sender << " Server: " << info.server << " Key: " << info.key << endl;
KStreamSocket *socket = new KStreamSocket( info.server, QString::number(5100) );
socketMap[socket] = info;
@@ -117,8 +114,8 @@ void WebcamTask::parseWebcamInformation( YMSGTransfer *t )
connect( socket, SIGNAL( connected( const KResolverEntry& ) ), this, SLOT( slotConnectionStage1Established() ) );
connect( socket, SIGNAL( gotError(int) ), this, SLOT( slotConnectionFailed(int) ) );
connect( socket, SIGNAL( readyRead() ), this, SLOT( slotRead() ) );
-
- socket->connect();
+
+ socket->connect();
}
void WebcamTask::slotConnectionStage1Established()
@@ -126,11 +123,11 @@ void WebcamTask::slotConnectionStage1Established()
KStreamSocket* socket = const_cast<KStreamSocket*>( dynamic_cast<const KStreamSocket*>( sender() ) );
if( !socket )
return;
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Webcam connection Stage1 to the user " << socketMap[socket].sender << " established." << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "Webcam connection Stage1 to the user " << socketMap[socket].sender << " established." << endl;
disconnect( socket, SIGNAL( connected( const KResolverEntry& ) ), this, SLOT( slotConnectionStage1Established() ) );
disconnect( socket, SIGNAL( gotError(int) ), this, SLOT( slotConnectionFailed(int) ) );
socketMap[socket].status = ConnectedStage1;
-
+
QByteArray buffer;
QDataStream stream( buffer, IO_WriteOnly );
@@ -146,10 +143,10 @@ void WebcamTask::slotConnectionStage1Established()
s = QString("f=1\r\n");
}
- // Header: 08 00 01 00 00 00 00
+ // Header: 08 00 01 00 00 00 00
stream << (Q_INT8)0x08 << (Q_INT8)0x00 << (Q_INT8)0x01 << (Q_INT8)0x00 << (Q_INT32)s.length();
stream.writeRawBytes( s.local8Bit(), s.length() );
-
+
socket->writeBlock( buffer.data(), buffer.size() );
}
@@ -159,7 +156,7 @@ void WebcamTask::slotConnectionStage2Established()
if( !socket )
return;
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Webcam connection Stage2 to the user " << socketMap[socket].sender << " established." << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "Webcam connection Stage2 to the user " << socketMap[socket].sender << " established." << endl;
disconnect( socket, SIGNAL( connected( const KResolverEntry& ) ), this, SLOT( slotConnectionStage2Established() ) );
disconnect( socket, SIGNAL( gotError(int) ), this, SLOT( slotConnectionFailed(int) ) );
socketMap[socket].status = ConnectedStage2;
@@ -176,7 +173,7 @@ void WebcamTask::slotConnectionStage2Established()
// Send request information
s = QString("a=2\r\nc=us\r\ne=21\r\nu=%1\r\nt=%2\r\ni=\r\ng=%3\r\no=w-2-5-1\r\np=1")
.arg(client()->userId()).arg(socketMap[socket].key).arg(socketMap[socket].sender);
- // Header: 08 00 01 00 00 00 00
+ // Header: 08 00 01 00 00 00 00
stream << (Q_INT8)0x08 << (Q_INT8)0x00 << (Q_INT8)0x01 << (Q_INT8)0x00 << (Q_INT32)s.length();
}
else
@@ -190,17 +187,19 @@ void WebcamTask::slotConnectionStage2Established()
stream << (Q_INT8)0x0d << (Q_INT8)0x00 << (Q_INT8)0x05 << (Q_INT8)0x00 << (Q_INT32)s.length()
<< (Q_INT8)0x01 << (Q_INT8)0x00 << (Q_INT8)0x00 << (Q_INT8)0x00 << (Q_INT8)0x01;
}
+
socket->writeBlock( buffer.data(), buffer.size() );
- socket->writeBlock( s.local8Bit(), s.length() );
+ socket->writeBlock( s.local8Bit(), s.length() );
}
void WebcamTask::slotConnectionFailed( int error )
{
KStreamSocket* socket = const_cast<KStreamSocket*>( dynamic_cast<const KStreamSocket*>( sender() ) );
- client()->notifyError( i18n("Webcam connection to the user %1 could not be established.\n\nPlease relogin and try again.")
- .arg(socketMap[socket].sender), QString("%1 - %2").arg(error).arg( socket->errorString()), Client::Error );
- socketMap.remove( socket );
- socket->deleteLater();
+ kdDebug(YAHOO_RAW_DEBUG) << "Webcam connection to the user " << socketMap[socket].sender << " failed. Error " << error << " - " << socket->errorString() << endl;
+ client()->notifyError( i18n("Webcam connection to the user %1 could not be established.\n\nPlease relogin and try again.")
+ .arg(socketMap[socket].sender), QString("%1 - %2").arg(error).arg( socket->errorString()), Client::Error );
+ socketMap.remove( socket );
+ socket->deleteLater();
}
void WebcamTask::slotRead()
@@ -208,7 +207,7 @@ void WebcamTask::slotRead()
KStreamSocket* socket = const_cast<KStreamSocket*>( dynamic_cast<const KStreamSocket*>( sender() ) );
if( !socket )
return;
-
+
switch( socketMap[socket].status )
{
case ConnectedStage1:
@@ -226,10 +225,10 @@ void WebcamTask::slotRead()
void WebcamTask::connectStage2( KStreamSocket *socket )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
QByteArray data( socket->bytesAvailable() );
socket->readBlock ( data.data (), data.size () );
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Magic Byte:" << data[2] << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "Magic Byte:" << data[2] << endl;
socketMap[socket].status = ConnectedStage2;
@@ -245,14 +244,14 @@ void WebcamTask::connectStage2( KStreamSocket *socket )
case (Q_INT8)0x07:
while( (const char)data[i] != (Q_INT8)0x00 )
server += data[i++];
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Server:" << server << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "Server:" << server << endl;
if( server.isEmpty() )
{
emit webcamNotAvailable(socketMap[socket].sender);
break;
}
-
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Connecting to " << server << endl;
+
+ kdDebug(YAHOO_RAW_DEBUG) << "Connecting to " << server << endl;
newSocket = new KStreamSocket( server, QString::number(5100) );
socketMap[newSocket] = socketMap[socket];
newSocket->enableRead( true );
@@ -264,8 +263,8 @@ void WebcamTask::connectStage2( KStreamSocket *socket )
newSocket->enableWrite( true );
connect( newSocket, SIGNAL( readyWrite() ), this, SLOT( transmitWebcamImage() ) );
}
-
- newSocket->connect();
+
+ newSocket->connect();
break;
default:
break;
@@ -277,28 +276,29 @@ void WebcamTask::connectStage2( KStreamSocket *socket )
void WebcamTask::processData( KStreamSocket *socket )
{
QByteArray data( socket->bytesAvailable() );
-
+
socket->readBlock ( data.data (), data.size () );
+
if( data.size() <= 0 )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "No data read." << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "No data read." << endl;
return;
}
-
+
parseData( data, socket );
}
void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket )
{
- uint headerLength = 0;
- uint read = 0;
+ int headerLength = 0;
+ int read = 0;
YahooWebcamInformation *info = &socketMap[socket];
if( !info->headerRead )
{
- headerLength = data[0];
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "headerLength " << headerLength << endl;
+ headerLength = data[0];
+ kdDebug(YAHOO_RAW_DEBUG) << "headerLength " << headerLength << endl;
if( data.size() < headerLength )
- return;
+ return;
if( headerLength >= 8 )
{
kdDebug() << data[0] << data[1] << data[2] << data[3] << data[4] << data[5] << data[6] << data[7] << endl;
@@ -309,7 +309,7 @@ void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket )
{
kdDebug() << data[8] << data[9] << data[10] << data[11] << data[12] << endl;
info->timestamp = yahoo_get32(data.data() + 9);
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "PacketType: " << data[8] << " reason: " << info->reason << " timestamp: " << info->timestamp << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "PacketType: " << data[8] << " reason: " << info->reason << " timestamp: " << info->timestamp << endl;
QStringList::iterator it;
switch( data[8] )
{
@@ -328,7 +328,7 @@ void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket )
info->headerRead = true;
}
break;
- case 0x02:
+ case 0x02:
info->type = Image;
info->headerRead = true;
break;
@@ -339,7 +339,7 @@ void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket )
}
break;
case 0x05:
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Ready for Transmission. " << info->timestamp << " watchers." << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "Ready for Transmission" << endl;
if( info->timestamp == 1 )
{
info->status = Sending;
@@ -351,7 +351,7 @@ void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket )
emit stopTransmission();
sendEmptyWebcamImage();
}
-
+
// Send Invitation packets
for(it = pendingInvitations.begin(); it != pendingInvitations.end(); it++)
{
@@ -359,12 +359,12 @@ void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket )
snt->setTarget( *it );
snt->setType( SendNotifyTask::NotifyWebcamInvite );
snt->go( true );
- it = pendingInvitations.remove( it );
+ it = pendingInvitations.erase( it );
it--;
}
break;
- case 0x07:
-
+ case 0x07:
+
info->type = ConnectionClosed;
emit webcamClosed( info->sender, info->reason );
cleanUpConnection( socket );
@@ -383,41 +383,41 @@ void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket )
if( !info->headerRead && data.size() > headerLength )
{
// More headers to read
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "More data to read..." << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "More data to read..." << endl;
QByteArray newData( data.size() - headerLength );
QDataStream stream( newData, IO_WriteOnly );
stream.writeRawBytes( data.data() + headerLength, data.size() - headerLength );
parseData( newData, socket );
return;
}
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Parsed Packet: HeaderLen: " << headerLength << " DataLen: " << info->dataLength << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "Parsed Packet: HeaderLen: " << headerLength << " DataLen: " << info->dataLength << endl;
}
-
+
if( info->dataLength <= 0 )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "No data to read. (info->dataLength <= 0)" << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "No data to read. (info->dataLength <= 0)" << endl;
if( info->headerRead )
info->headerRead = false;
return;
}
if( headerLength >= data.size() )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "No data to read. (headerLength >= data.size())" << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "No data to read. (headerLength >= data.size())" << endl;
return; //Nothing to read here...
}
if( !info->buffer )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Buffer created" << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "Buffer created" << endl;
info->buffer = new QBuffer();
info->buffer->open( IO_WriteOnly );
}
-
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "data.size() " << data.size() << " headerLength " << headerLength << " buffersize " << info->buffer->size() << endl;
+
+ kdDebug(YAHOO_RAW_DEBUG) << "data.size() " << data.size() << " headerLength " << headerLength << " buffersize " << info->buffer->size() << endl;
read = headerLength + info->dataLength - info->buffer->size();
info->buffer->writeBlock( data.data() + headerLength, data.size() - headerLength );//info->dataLength - info->buffer->size() );
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "read " << data.size() - headerLength << " Bytes, Buffer is now " << info->buffer->size() << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "read " << data.size() - headerLength << " Bytes, Buffer is now " << info->buffer->size() << endl;
if( info->buffer->size() >= static_cast<uint>(info->dataLength) )
- {
+ {
info->buffer->close();
QString who;
switch( info->type )
@@ -426,7 +426,7 @@ void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket )
{
who.append( info->buffer->buffer() );
who = who.mid( 2, who.find('\n') - 3);
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "User wants to view webcam: " << who << " len: " << who.length() << " Index: " << accessGranted.findIndex( who ) << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "User wants to view webcam: " << who << " len: " << who.length() << " Index: " << accessGranted.findIndex( who ) << endl;
if( accessGranted.findIndex( who ) >= 0 )
{
grantAccess( who );
@@ -438,13 +438,13 @@ void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket )
case NewWatcher:
who.append( info->buffer->buffer() );
who = who.left( who.length() - 1 );
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "New Watcher of webcam: " << who << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "New Watcher of webcam: " << who << endl;
emit viewerJoined( who );
break;
case WatcherLeft:
who.append( info->buffer->buffer() );
who = who.left( who.length() - 1 );
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "A Watcher left: " << who << " len: " << who.length() << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "A Watcher left: " << who << " len: " << who.length() << endl;
accessGranted.remove( who );
emit viewerLeft( who );
break;
@@ -452,17 +452,28 @@ void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket )
{
QPixmap webcamImage;
//webcamImage.loadFromData( info->buffer->buffer() );
-
+
+ // FIXME (same)
+ //KTemporaryFile jpcTmpImageFile;
+ //jpcTmpImageFile.setAutoRemove(false);
+ //jpcTmpImageFile.open();
+ //KTemporaryFile bmpTmpImageFile;
+ //bmpTmpImageFile.setAutoRemove(false);
+ //bmpTmpImageFile.open();
+
+ //jpcTmpImageFile.write((info->buffer->buffer()).data(), info->buffer->size());
+ //jpcTmpImageFile.close();
+
KTempFile jpcTmpImageFile;
- KTempFile bmpTmpImageFile;
- QFile *file = jpcTmpImageFile.file();
- file->writeBlock((info->buffer->buffer()).data(), info->buffer->size());
- file->close();
-
+ KTempFile bmpTmpImageFile;
+ QFile *file = jpcTmpImageFile.file();
+ file->writeBlock((info->buffer->buffer()).data(), info->buffer->size());
+ file->close();
+
KProcess p;
p << "jasper";
p << "--input" << jpcTmpImageFile.name() << "--output" << bmpTmpImageFile.name() << "--output-format" << "bmp";
-
+
p.start( KProcess::Block );
if( p.exitStatus() != 0 )
{
@@ -475,15 +486,15 @@ void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket )
emit webcamImageReceived( info->sender, webcamImage );
}
QFile::remove(jpcTmpImageFile.name());
- QFile::remove(bmpTmpImageFile.name());
-
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Image Received. Size: " << webcamImage.size() << endl;
+ QFile::remove(bmpTmpImageFile.name());
+
+ kdDebug(YAHOO_RAW_DEBUG) << "Image Received. Size: " << webcamImage.size() << endl;
}
break;
default:
break;
}
-
+
info->headerRead = false;
delete info->buffer;
info->buffer = 0L;
@@ -491,7 +502,7 @@ void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket )
if( data.size() > read )
{
// More headers to read
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "More data to read..." << data.size() - read << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "More data to read..." << data.size() - read << endl;
QByteArray newData( data.size() - read );
QDataStream stream( newData, IO_WriteOnly );
stream.writeRawBytes( data.data() + read, data.size() - read );
@@ -506,33 +517,33 @@ void WebcamTask::cleanUpConnection( KStreamSocket *socket )
if( info->buffer )
delete info->buffer;
socketMap.remove( socket );
- delete socket;
+ delete socket;
}
void WebcamTask::closeWebcam( const QString & who )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
SocketInfoMap::Iterator it;
for( it = socketMap.begin(); it != socketMap.end(); it++ )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << it.data().sender << " - " << who << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << it.data().sender << " - " << who << endl;
if( it.data().sender == who )
{
cleanUpConnection( it.key() );
return;
}
}
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Error. You tried to close a connection that didn't exist." << endl;
- client()->notifyError( i18n( "An error occured closing the webcam session. " ), i18n( "You tried to close a connection that didn't exist." ), Client::Debug );
+ kdDebug(YAHOO_RAW_DEBUG) << "Error. You tried to close a connection that did not exist." << endl;
+ client()->notifyError( i18n( "An error occurred closing the webcam session. " ), i18n( "You tried to close a connection that did not exist." ), Client::Debug );
}
-// Sending
+// Sending
void WebcamTask::registerWebcam()
-{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
-
+{
+ kdDebug(YAHOO_RAW_DEBUG) ;
+
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceWebcam);
t->setId( client()->sessionID() );
t->setParam( 1, client()->userId().local8Bit());
@@ -543,14 +554,14 @@ void WebcamTask::registerWebcam()
void WebcamTask::addPendingInvitation( const QString &userId )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Inviting " << userId << " to watch the webcam." << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "Inviting " << userId << " to watch the webcam." << endl;
pendingInvitations.append( userId );
accessGranted.append( userId );
}
void WebcamTask::grantAccess( const QString &userId )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
KStreamSocket *socket = 0L;
SocketInfoMap::Iterator it;
for( it = socketMap.begin(); it != socketMap.end(); it++ )
@@ -563,7 +574,7 @@ void WebcamTask::grantAccess( const QString &userId )
}
if( !socket )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Error. No outgoing socket found." << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "Error. No outgoing socket found." << endl;
return;
}
QByteArray ar;
@@ -573,12 +584,12 @@ void WebcamTask::grantAccess( const QString &userId )
stream << (Q_INT8)0x0d << (Q_INT8)0x00 << (Q_INT8)0x05 << (Q_INT8)0x00 << (Q_INT32)user.length()
<< (Q_INT8)0x00 << (Q_INT8)0x00 << (Q_INT8)0x00 << (Q_INT8)0x00 << (Q_INT8)0x01;
socket->writeBlock( ar.data(), ar.size() );
- socket->writeBlock( user.local8Bit(), user.length() );
+ socket->writeBlock( user.local8Bit(), user.length() );
}
void WebcamTask::closeOutgoingWebcam()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
KStreamSocket *socket = 0L;
SocketInfoMap::Iterator it;
for( it = socketMap.begin(); it != socketMap.end(); it++ )
@@ -591,17 +602,17 @@ void WebcamTask::closeOutgoingWebcam()
}
if( !socket )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Error. No outgoing socket found." << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "Error. No outgoing socket found." << endl;
return;
}
-
+
cleanUpConnection( socket );
transmittingData = false;
}
void WebcamTask::sendEmptyWebcamImage()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
KStreamSocket *socket = 0L;
SocketInfoMap::Iterator it;
@@ -615,11 +626,11 @@ void WebcamTask::sendEmptyWebcamImage()
}
if( !socket )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Error. No outgoing socket found." << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "Error. No outgoing socket found." << endl;
return;
}
if( socketMap[socket].status != SendingEmpty )
- return;
+ return;
pictureBuffer.resize( 0 );
transmissionPending = true;
@@ -630,8 +641,8 @@ void WebcamTask::sendEmptyWebcamImage()
void WebcamTask::sendWebcamImage( const QByteArray &image )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
- pictureBuffer.duplicate( image );
+ kdDebug(YAHOO_RAW_DEBUG) ;
+ pictureBuffer = image;
transmissionPending = true;
KStreamSocket *socket = 0L;
SocketInfoMap::Iterator it;
@@ -645,7 +656,7 @@ void WebcamTask::sendWebcamImage( const QByteArray &image )
}
if( !socket )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Error. No outgoing socket found." << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "Error. No outgoing socket found." << endl;
return;
}
@@ -656,7 +667,7 @@ void WebcamTask::transmitWebcamImage()
{
if( !transmissionPending )
return;
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "arraysize: " << pictureBuffer.size() << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "arraysize: " << pictureBuffer.size() << endl;
// Find outgoing socket
KStreamSocket *socket = 0L;
@@ -671,7 +682,7 @@ void WebcamTask::transmitWebcamImage()
}
if( !socket )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Error. No outgoing socket found." << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "Error. No outgoing socket found." << endl;
return;
}
@@ -683,7 +694,7 @@ void WebcamTask::transmitWebcamImage()
socket->writeBlock( buffer.data(), buffer.size() );
if( pictureBuffer.size() )
socket->writeBlock( pictureBuffer.data(), pictureBuffer.size() );
-
+
transmissionPending = false;
}
#include "webcamtask.moc"
diff --git a/kopete/protocols/yahoo/libkyahoo/webcamtask.h b/kopete/protocols/yahoo/libkyahoo/webcamtask.h
index 71dd2a95..23639b8d 100644
--- a/kopete/protocols/yahoo/libkyahoo/webcamtask.h
+++ b/kopete/protocols/yahoo/libkyahoo/webcamtask.h
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Handles incoming webcam connections
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -60,15 +60,14 @@ class WebcamTask : public Task
public:
WebcamTask(Task *parent);
~WebcamTask();
-
+
bool take(Transfer *transfer);
- bool forMe( Transfer* transfer ) const;
bool transmitting() { return transmittingData; }
-
+
void requestWebcam( const QString &who );
void closeWebcam( const QString &who );
-
+
void registerWebcam();
void sendWebcamImage( const QByteArray &image );
void addPendingInvitation( const QString &userId );
@@ -91,13 +90,15 @@ private slots:
void slotRead();
void sendEmptyWebcamImage();
void transmitWebcamImage();
+protected:
+ virtual bool forMe( const Transfer* transfer ) const;
private:
void parseWebcamInformation( YMSGTransfer *transfer );
void parseData( QByteArray &data, KStreamSocket *socket );
void connectStage2( KStreamSocket *socket );
void processData( KStreamSocket *socket );
- void cleanUpConnection( KStreamSocket *socket );
+ void cleanUpConnection( KStreamSocket *socket );
QString keyPending; // the buddy we have requested the webcam from
SocketInfoMap socketMap;
diff --git a/kopete/protocols/yahoo/libkyahoo/yabentry.cpp b/kopete/protocols/yahoo/libkyahoo/yabentry.cpp
index 9eab5ef1..d726d6d6 100644
--- a/kopete/protocols/yahoo/libkyahoo/yabentry.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/yabentry.cpp
@@ -1,7 +1,7 @@
/*
yabcpp - Encapsulate Yahoo Adressbook information
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005 André Duffeck <duffeck@kde.org>
Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
*************************************************************************
@@ -48,9 +48,9 @@ void YABEntry::fromQDomElement( const QDomElement &e )
privateZIP = e.attribute("hz");
privateCountry = e.attribute("hn");
QString birtday = e.attribute("bi");
- birthday = QDate( birtday.section("/",2,2).toInt(), birtday.section("/",1,1).toInt(), birtday.section("/",0,0).toInt() );
+ birthday = QDate( birtday.section('/',2,2).toInt(), birtday.section('/',1,1).toInt(), birtday.section('/',0,0).toInt() );
QString an = e.attribute("an");
- anniversary = QDate( an.section("/",2,2).toInt(), an.section("/",1,1).toInt(), an.section("/",0,0).toInt() );
+ anniversary = QDate( an.section('/',2,2).toInt(), an.section('/',1,1).toInt(), an.section('/',0,0).toInt() );
additional1 = e.attribute("c1");
additional2 = e.attribute("c2");
additional3 = e.attribute("c3");
@@ -67,8 +67,8 @@ void YABEntry::fromQDomElement( const QDomElement &e )
void YABEntry::fromQDomDocument( const QDomDocument &d )
{
- kdDebug() << d.toString() <<
- d.elementsByTagName("yi").item(0).toElement().text();
+ kdDebug() << d.toString() <<
+ d.elementsByTagName("yi").item(0).toElement().text() << endl;
yahooId = d.elementsByTagName("yi").item(0).toElement().text();
firstName = d.elementsByTagName("fn").item(0).toElement().text();
secondName = d.elementsByTagName("mn").item(0).toElement().text();
@@ -98,9 +98,9 @@ void YABEntry::fromQDomDocument( const QDomDocument &d )
privateZIP = d.elementsByTagName("hz").item(0).toElement().text();
privateCountry = d.elementsByTagName("hn").item(0).toElement().text();
QString birtday = d.elementsByTagName("bi").item(0).toElement().text();
- birthday = QDate( birtday.section("/",2,2).toInt(), birtday.section("/",1,1).toInt(), birtday.section("/",0,0).toInt() );
+ birthday = QDate( birtday.section('/',2,2).toInt(), birtday.section('/',1,1).toInt(), birtday.section('/',0,0).toInt() );
QString an = d.elementsByTagName("an").item(0).toElement().text();
- anniversary = QDate( an.section("/",2,2).toInt(), an.section("/",1,1).toInt(), an.section("/",0,0).toInt() );
+ anniversary = QDate( an.section('/',2,2).toInt(), an.section('/',1,1).toInt(), an.section('/',0,0).toInt() );
additional1 = d.elementsByTagName("c1").item(0).toElement().text();
additional2 = d.elementsByTagName("c2").item(0).toElement().text();
additional3 = d.elementsByTagName("c3").item(0).toElement().text();
@@ -135,13 +135,13 @@ void YABEntry::fillQDomElement( QDomElement &e ) const
e.setAttribute( "pu", privateURL );
e.setAttribute( "ti", title );
e.setAttribute( "co", corporation );
- e.setAttribute( "wa", QString( workAdress ).replace( "\n", "&#xd;&#xa;" ) );
+ e.setAttribute( "wa", QString( workAdress ).replace( '\n', "&#xd;&#xa;" ) );
e.setAttribute( "wc", workCity );
e.setAttribute( "ws", workState );
e.setAttribute( "wz", workZIP );
e.setAttribute( "wn", workCountry );
e.setAttribute( "wu", workURL );
- e.setAttribute( "ha", QString( privateAdress ).replace( "\n", "&#xd;&#xa;" ) );
+ e.setAttribute( "ha", QString( privateAdress ).replace( '\n', "&#xd;&#xa;" ) );
e.setAttribute( "hc", privateCity );
e.setAttribute( "hs", privateState );
e.setAttribute( "hz", privateZIP );
@@ -152,7 +152,7 @@ void YABEntry::fillQDomElement( QDomElement &e ) const
e.setAttribute( "c2", additional2 );
e.setAttribute( "c3", additional3 );
e.setAttribute( "c4", additional4 );
- e.setAttribute( "cm", QString( notes ).replace( "\n", "&#xd;&#xa;" ) );
+ e.setAttribute( "cm", QString( notes ).replace( '\n', "&#xd;&#xa;" ) );
e.setAttribute( "ima", imAIM );
e.setAttribute( "img", imGoogleTalk );
e.setAttribute( "imq", imICQ );
@@ -164,38 +164,38 @@ void YABEntry::fillQDomElement( QDomElement &e ) const
void YABEntry::dump() const
{
- kdDebug() << "firstName: " << firstName << endl <<
- "secondName: " << secondName << endl <<
- "lastName: " << lastName << endl <<
- "nickName: " << nickName << endl <<
- "title: " << title << endl <<
- "phoneMobile: " << phoneMobile << endl <<
- "email: " << email << endl <<
- "yahooId: " << yahooId << endl <<
- "pager: " << pager << endl <<
- "fax: " << fax << endl <<
- "additionalNumber: " << additionalNumber << endl <<
- "altEmail1: " << altEmail1 << endl <<
- "altEmail2: " << altEmail2 << endl <<
- "privateAdress: " << privateAdress << endl <<
- "privateCity: " << privateCity << endl <<
- "privateState: " << privateState << endl <<
- "privateZIP: " << privateZIP << endl <<
- "privateCountry: " << privateCountry << endl <<
- "privatePhone: " << privatePhone << endl <<
- "privateURL: " << privateURL << endl <<
- "corporation: " << corporation << endl <<
- "workAdress: " << workAdress << endl <<
- "workCity: " << workCity << endl <<
- "workState: " << workState << endl <<
- "workZIP: " << workZIP << endl <<
- "workCountry: " << workCountry << endl <<
- "workURL: " << workURL << endl <<
- "birthday: " << birthday.toString() << endl <<
- "anniversary: " << anniversary.toString() << endl <<
- "notes: " << notes << endl <<
- "additional1: " << additional1 << endl <<
- "additional2: " << additional2 << endl <<
- "additional3: " << additional3 << endl <<
+ kdDebug() << "firstName: " << firstName << endl <<
+ "secondName: " << secondName << endl <<
+ "lastName: " << lastName << endl <<
+ "nickName: " << nickName << endl <<
+ "title: " << title << endl <<
+ "phoneMobile: " << phoneMobile << endl <<
+ "email: " << email << endl <<
+ "yahooId: " << yahooId << endl <<
+ "pager: " << pager << endl <<
+ "fax: " << fax << endl <<
+ "additionalNumber: " << additionalNumber << endl <<
+ "altEmail1: " << altEmail1 << endl <<
+ "altEmail2: " << altEmail2 << endl <<
+ "privateAdress: " << privateAdress << endl <<
+ "privateCity: " << privateCity << endl <<
+ "privateState: " << privateState << endl <<
+ "privateZIP: " << privateZIP << endl <<
+ "privateCountry: " << privateCountry << endl <<
+ "privatePhone: " << privatePhone << endl <<
+ "privateURL: " << privateURL << endl <<
+ "corporation: " << corporation << endl <<
+ "workAdress: " << workAdress << endl <<
+ "workCity: " << workCity << endl <<
+ "workState: " << workState << endl <<
+ "workZIP: " << workZIP << endl <<
+ "workCountry: " << workCountry << endl <<
+ "workURL: " << workURL << endl <<
+ "birthday: " << birthday.toString() << endl <<
+ "anniversary: " << anniversary.toString() << endl <<
+ "notes: " << notes << endl <<
+ "additional1: " << additional1 << endl <<
+ "additional2: " << additional2 << endl <<
+ "additional3: " << additional3 << endl <<
"additional4: " << additional4 << endl;
}
diff --git a/kopete/protocols/yahoo/libkyahoo/yabentry.h b/kopete/protocols/yahoo/libkyahoo/yabentry.h
index b12845ce..da042032 100644
--- a/kopete/protocols/yahoo/libkyahoo/yabentry.h
+++ b/kopete/protocols/yahoo/libkyahoo/yabentry.h
@@ -1,7 +1,7 @@
/*
yabentry.h - Encapsulate Yahoo Adressbook information
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005 André Duffeck <duffeck@kde.org>
Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
*************************************************************************
@@ -71,7 +71,7 @@ struct YABEntry
QString workPhone;
QString workURL;
- // Miscellanous
+ // Miscellaneous
QDate birthday;
QDate anniversary;
QString notes;
diff --git a/kopete/protocols/yahoo/libkyahoo/yabtask.cpp b/kopete/protocols/yahoo/libkyahoo/yabtask.cpp
index 38aea9ca..3cc66dba 100644
--- a/kopete/protocols/yahoo/libkyahoo/yabtask.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/yabtask.cpp
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
yabtask.h - Handles the Yahoo Address Book
- Copyright (c) 2006 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2006 André Duffeck <duffeck@kde.org>
Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
*************************************************************************
@@ -29,7 +29,7 @@
YABTask::YABTask(Task* parent) : Task(parent)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
}
YABTask::~YABTask()
@@ -38,29 +38,25 @@ YABTask::~YABTask()
bool YABTask::take( Transfer* transfer )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
-
if ( !forMe( transfer ) )
return false;
YMSGTransfer *t = static_cast<YMSGTransfer*>(transfer);
-
+
if( t->service() == Yahoo::ServiceContactDetails )
parseContactDetails( t );
-
+
return true;
}
-bool YABTask::forMe( Transfer* transfer ) const
+bool YABTask::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;
- if ( t->service() == Yahoo::ServiceContactDetails )
+ if ( t->service() == Yahoo::ServiceContactDetails )
return true;
else
return false;
@@ -68,14 +64,14 @@ bool YABTask::forMe( Transfer* transfer ) const
void YABTask::parseContactDetails( YMSGTransfer* t )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
QString from; /* key = 7 */
int count;
from = t->firstParam( 4 );
count = t->paramCount( 5 );
-
+
for( int i = 0; i < count; i++ )
{
QString who = t->nthParam( 5, i );
@@ -96,7 +92,7 @@ void YABTask::parseContactDetails( YMSGTransfer* t )
void YABTask::getAllEntries( long lastMerge, long lastRemoteRevision )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "LastMerge: " << lastMerge << " LastRemoteRevision: " << lastRemoteRevision << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "LastMerge: " << lastMerge << " LastRemoteRevision: " << lastRemoteRevision << endl;
m_data = QString::null;
QString url = QString::fromLatin1("http://address.yahoo.com/yab/us?v=XM&prog=ymsgr&.intl=us&diffs=1&t=%1&tags=short&rt=%2&prog-ver=%3")
.arg( lastMerge ).arg( lastRemoteRevision ).arg( YMSG_PROGRAM_VERSION_STRING );
@@ -111,44 +107,47 @@ void YABTask::getAllEntries( long lastMerge, long lastRemoteRevision )
void YABTask::slotData( KIO::Job* /*job*/, const QByteArray &info )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
m_data += info;
}
void YABTask::slotResult( KIO::Job* job )
{
if( job->error () || m_transferJob->isErrorPage () )
- client()->notifyError( i18n( "Could not retrieve server side addressbook for user info." ), job->errorString(), Client::Info );
- else
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Server side addressbook retrieved." << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "Could not retrieve server side addressbook for user info." << endl;
+ client()->notifyError( i18n( "Could not retrieve server side address book for user info." ), job->errorString(), Client::Info );
+ }
+ else
+ {
+ kdDebug(YAHOO_RAW_DEBUG) << "Server side addressbook retrieved." << endl;
QDomDocument doc;
QDomNodeList list;
QDomElement e;
- uint it = 0;
+ int it = 0;
kdDebug(YAHOO_RAW_DEBUG) << m_data << endl;
doc.setContent( m_data );
-
+
list = doc.elementsByTagName( "ab" ); // Get the Addressbook
for( it = 0; it < list.count(); it++ ) {
if( !list.item( it ).isElement() )
continue;
e = list.item( it ).toElement();
-
+
if( !e.attribute( "lm" ).isEmpty() )
emit gotRevision( e.attribute( "lm" ).toLong(), true );
if( !e.attribute( "rt" ).isEmpty() )
emit gotRevision( e.attribute( "rt" ).toLong(), false );
}
-
+
list = doc.elementsByTagName( "ct" ); // Get records
for( it = 0; it < list.count(); it++ ) {
if( !list.item( it ).isElement() )
continue;
e = list.item( it ).toElement();
-
+
YABEntry *entry = new YABEntry;
entry->fromQDomElement( e );
entry->source = YABEntry::SourceYAB;
diff --git a/kopete/protocols/yahoo/libkyahoo/yabtask.h b/kopete/protocols/yahoo/libkyahoo/yabtask.h
index bd22ead7..fe9cae3c 100644
--- a/kopete/protocols/yahoo/libkyahoo/yabtask.h
+++ b/kopete/protocols/yahoo/libkyahoo/yabtask.h
@@ -2,7 +2,7 @@
Kopete Yahoo Protocol
yabtask.h - Handles the Yahoo Address Book
- Copyright (c) 2006 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2006 André Duffeck <duffeck@kde.org>
Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
*************************************************************************
@@ -22,12 +22,11 @@
#include "yabentry.h"
class YMSGTransfer;
-struct KURL;
-namespace KIO {
+
+namespace KIO {
class Job;
- class TransferJob;
+ class TransferJob;
}
-class QDomElement;
/**
@author André Duffeck
@@ -38,9 +37,8 @@ class YABTask : public Task
public:
YABTask(Task *parent);
~YABTask();
-
+
bool take(Transfer *transfer);
- bool forMe( Transfer* transfer ) const;
void getAllEntries( long lastMerge, long lastRemoteRevision );
void saveEntry( const YABEntry & );
@@ -48,6 +46,7 @@ signals:
void gotEntry( YABEntry * );
void gotRevision( long rev, bool merged );
protected:
+ virtual bool forMe( const Transfer* transfer ) const;
void parseContactDetails( YMSGTransfer* t );
private slots:
void slotData( KIO::Job*, const QByteArray & );
diff --git a/kopete/protocols/yahoo/libkyahoo/yahoo_fn.h b/kopete/protocols/yahoo/libkyahoo/yahoo_fn.h
index e1a49082..c4b34c81 100644
--- a/kopete/protocols/yahoo/libkyahoo/yahoo_fn.h
+++ b/kopete/protocols/yahoo/libkyahoo/yahoo_fn.h
@@ -18,6 +18,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#ifndef YAHOO_FN_H
+#define YAHOO_FN_H
+
#define IDENT 1 /* identify function */
#define XOR 2 /* xor with arg1 */
#define MULADD 3 /* multipy by arg1 then add arg2 */
@@ -31,3 +34,5 @@ struct yahoo_fn
};
int yahoo_xfrm( int table, int depth, int seed );
+
+#endif // YAHOO_FN_H
diff --git a/kopete/protocols/yahoo/libkyahoo/yahoobuddyiconloader.cpp b/kopete/protocols/yahoo/libkyahoo/yahoobuddyiconloader.cpp
index 1608cd6f..5e704efa 100644
--- a/kopete/protocols/yahoo/libkyahoo/yahoobuddyiconloader.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/yahoobuddyiconloader.cpp
@@ -1,7 +1,7 @@
/*
yahoobuddyiconloader.cpp - Fetches YahooBuddyIcons
- Copyright (c) 2005 by André Duffeck <andre@duffeck.de>
+ Copyright (c) 2005 by André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -42,12 +42,12 @@ YahooBuddyIconLoader::~YahooBuddyIconLoader()
void YahooBuddyIconLoader::fetchBuddyIcon( const QString &who, KURL url, int checksum )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << url << endl;
KIO::TransferJob *transfer;
QString Url = url.url();
QString ext = Url.left( Url.findRev( "?" ) );
ext = ext.right( ext.length() - ext.findRev( "." ) );
-
+
transfer = KIO::get( url, false, false );
connect( transfer, SIGNAL( result( KIO::Job* ) ), this, SLOT( slotComplete( KIO::Job* ) ) );
connect( transfer, SIGNAL( data( KIO::Job*, const QByteArray& ) ), this, SLOT( slotData( KIO::Job*, const QByteArray& ) ) );
@@ -55,48 +55,37 @@ void YahooBuddyIconLoader::fetchBuddyIcon( const QString &who, KURL url, int che
m_jobs[transfer].url = url;
m_jobs[transfer].who = who;
m_jobs[transfer].checksum = checksum;
- m_jobs[transfer].file = new KTempFile( locateLocal( "tmp", "yahoobuddyicon-" ), ext );
- m_jobs[transfer].file->setAutoDelete( true );
}
void YahooBuddyIconLoader::slotData( KIO::Job *job, const QByteArray& data )
{
-
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
KIO::TransferJob *transfer = static_cast< KIO::TransferJob * >(job);
- if( m_jobs[transfer].file )
- m_jobs[transfer].file->file()->writeBlock( data.data() , data.size() );
-
+ // FIXME need to check
+ //m_jobs[transfer].icon.append( data );
+ int oldsize = m_jobs[transfer].icon.size();
+ m_jobs[transfer].icon.resize( data.size() + oldsize );
+ memcpy( m_jobs[transfer].icon.data() + oldsize, data.data(), data.size() );
}
void YahooBuddyIconLoader::slotComplete( KIO::Job *job )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
KIO::TransferJob *transfer = static_cast< KIO::TransferJob * >(job);
if ( job->error () || transfer->isErrorPage () )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "An error occured while downloading buddy icon." << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "An error occurred while downloading buddy icon." << endl;
if( m_client )
- m_client->notifyError( i18n( "An error occured while downloading buddy icon (%1)" ).arg(m_jobs[transfer].url.url()), job->errorString(), Client::Info );
+ m_client->notifyError( i18n( "An error occurred while downloading a buddy icon (%1)").arg( m_jobs[transfer].url.url() ), job->errorString(), Client::Info );
}
else
{
- if ( m_jobs[transfer].file )
- {
- m_jobs[transfer].file->close();
- emit fetchedBuddyIcon( m_jobs[transfer].who, m_jobs[transfer].file, m_jobs[transfer].checksum );
- }
- else
- {
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Fatal Error occured. IconLoadJob has an empty KTempFile pointer." << endl;
- if( m_client )
- m_client->notifyError( i18n( "Fatal Error occured while downloading buddy icon." ), i18n( "IconLoadJob has an empty KTempFile pointer." ), Client::Info );
- }
+ emit fetchedBuddyIcon( m_jobs[transfer].who, m_jobs[transfer].icon, m_jobs[transfer].checksum );
}
m_jobs.remove( transfer );
diff --git a/kopete/protocols/yahoo/libkyahoo/yahoobuddyiconloader.h b/kopete/protocols/yahoo/libkyahoo/yahoobuddyiconloader.h
index c1a943c2..76f70cdc 100644
--- a/kopete/protocols/yahoo/libkyahoo/yahoobuddyiconloader.h
+++ b/kopete/protocols/yahoo/libkyahoo/yahoobuddyiconloader.h
@@ -1,7 +1,7 @@
/*
yahoobuddyiconloader.h - Fetches YahooBuddyIcons
- Copyright (c) 2005 by André Duffeck <andre@duffeck.de>
+ Copyright (c) 2005 by André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -24,7 +24,7 @@
// KDE Includes
#include <kurl.h>
-class KTempFile;
+class KJob;
class Client;
namespace KIO {
class Job;
@@ -35,7 +35,7 @@ struct IconLoadJob {
KURL url;
QString who;
int checksum;
- KTempFile *file;
+ QByteArray icon;
};
/**
@@ -60,9 +60,9 @@ public:
signals:
/**
* The account can connect to this signal and append the icon
- * stored in 'file' to the apropriate contact
+ * stored in 'file' to the appropriate contact
*/
- void fetchedBuddyIcon( const QString &who, KTempFile *file, int checksum );
+ void fetchedBuddyIcon( const QString &who, const QByteArray &icon, int checksum );
private slots:
void slotData( KIO::Job *job, const QByteArray &data );
diff --git a/kopete/protocols/yahoo/libkyahoo/yahoobytestream.cpp b/kopete/protocols/yahoo/libkyahoo/yahoobytestream.cpp
index 87cf54d1..b0d1cbb9 100644
--- a/kopete/protocols/yahoo/libkyahoo/yahoobytestream.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/yahoobytestream.cpp
@@ -22,10 +22,10 @@
#include "yahoobytestream.h"
-KNetworkByteStream::KNetworkByteStream( QObject *parent, const char */*name*/ )
+KNetworkByteStream::KNetworkByteStream( QObject *parent )
: ByteStream ( parent )
{
- kdDebug( 14181 ) << k_funcinfo << "Instantiating new KNetwork byte stream." << endl;
+ kdDebug( 14181 ) << "Instantiating new KNetwork byte stream." << endl;
// reset close tracking flag
mClosing = false;
@@ -45,7 +45,7 @@ KNetworkByteStream::KNetworkByteStream( QObject *parent, const char */*name*/ )
bool KNetworkByteStream::connect( QString host, QString service )
{
- kdDebug( 14181 ) << k_funcinfo << "Connecting to " << host << ", service " << service << endl;
+ kdDebug( 14181 ) << "Connecting to " << host << ", service " << service << endl;
return socket()->connect( host, service );
}
@@ -58,7 +58,7 @@ bool KNetworkByteStream::isOpen() const
void KNetworkByteStream::close ()
{
- kdDebug ( 14181 ) << k_funcinfo << "Closing stream." << endl;
+ kdDebug ( 14181 ) << "Closing stream." << endl;
// close the socket and set flag that we are closing it ourselves
mClosing = true;
@@ -69,8 +69,8 @@ int KNetworkByteStream::tryWrite ()
{
// send all data from the buffers to the socket
QByteArray writeData = takeWrite();
- kdDebug( 14181 ) << k_funcinfo << "[writeData.size() = " << writeData.size() << "]" << endl;
-
+ kdDebug( 14181 ) << "[writeData.size() = " << writeData.size() << "]" << endl;
+
socket()->writeBlock( writeData.data(), writeData.size () );
return writeData.size();
@@ -93,13 +93,13 @@ void KNetworkByteStream::slotConnected()
void KNetworkByteStream::slotConnectionClosed()
{
- kdDebug( 14181 ) << k_funcinfo << "Socket has been closed." << endl;
+ kdDebug( 14181 ) << "Socket has been closed." << endl;
// depending on who closed the socket, emit different signals
if ( mClosing )
{
kdDebug( 14181 ) << "..by ourselves!" << endl;
- kdDebug( 14181 ) << "socket error is " << socket()->errorString( socket()->error() ) << endl;
+ kdDebug( 14181 ) << "socket error is " << socket()->errorString() << endl;
emit connectionClosed ();
}
else
@@ -111,9 +111,10 @@ void KNetworkByteStream::slotConnectionClosed()
void KNetworkByteStream::slotReadyRead()
{
- kdDebug( 14181 ) << endl;
+ kdDebug( 14181 );
// stuff all available data into our buffers
- QByteArray readBuffer( socket()->bytesAvailable () );
+ QByteArray readBuffer;
+ readBuffer.resize( socket()->bytesAvailable () );
socket()->readBlock( readBuffer.data (), readBuffer.size () );
@@ -130,7 +131,7 @@ void KNetworkByteStream::slotBytesWritten( int bytes )
void KNetworkByteStream::slotError( int code )
{
- kdDebug( 14181 ) << k_funcinfo << "Socket error " << code << endl;
+ kdDebug( 14181 ) << "Socket error " << code << endl;
emit error( code );
}
diff --git a/kopete/protocols/yahoo/libkyahoo/yahoobytestream.h b/kopete/protocols/yahoo/libkyahoo/yahoobytestream.h
index ac8aef63..d48bcf36 100644
--- a/kopete/protocols/yahoo/libkyahoo/yahoobytestream.h
+++ b/kopete/protocols/yahoo/libkyahoo/yahoobytestream.h
@@ -15,8 +15,8 @@
*************************************************************************
*/
-#ifndef KNETWORKBYTESTREAM_H
-#define KNETWORKBYTESTREAM_H
+#ifndef YAHOOBYTESTREAM_H
+#define YAHOOBYTESTREAM_H
#include <kbufferedsocket.h>
@@ -27,14 +27,14 @@
* Low level socket class, using KDE's KNetwork socket classes
* @author Till Gerken
*/
-
+
class KNetworkByteStream : public ByteStream
{
Q_OBJECT
public:
- KNetworkByteStream ( QObject *parent = 0, const char *name = 0 );
+ KNetworkByteStream ( QObject *parent = 0 );
~KNetworkByteStream ();
@@ -63,7 +63,6 @@ private:
};
-#endif
+#endif // YAHOOBYTESTREAM_H
// kate: indent-width 4; replace-tabs off; tab-width 4; space-indent off;
-
diff --git a/kopete/protocols/yahoo/libkyahoo/yahooclientstream.cpp b/kopete/protocols/yahoo/libkyahoo/yahooclientstream.cpp
index 548140b1..3279bbd0 100644
--- a/kopete/protocols/yahoo/libkyahoo/yahooclientstream.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/yahooclientstream.cpp
@@ -1,13 +1,13 @@
/*
oscarclientstream.cpp - Kopete Oscar Protocol
-
+
Copyright (c) 2004 Matt Rogers <matt.rogers@kdemail.net>
-
+
Based on code Copyright (c) 2004 SuSE Linux AG <http://www.suse.com>
- Based on Iris, Copyright (C) 2003 Justin Karneges
-
+ Based on Iris, Copyright (C) 2003 Justin Karneges <justin@affinix.com>
+
Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
-
+
*************************************************************************
* *
* This library is free software; you can redistribute it and/or *
@@ -21,7 +21,7 @@
#include <qapplication.h> // for qdebug
-#include <qguardedptr.h>
+#include <qguardedptr.h>
#include <qobject.h>
#include <qptrqueue.h>
#include <qtimer.h>
@@ -57,7 +57,7 @@ public:
{
conn = 0;
bs = 0;
-
+
username = QString::null;
password = QString::null;
server = QString::null;
@@ -72,7 +72,7 @@ public:
notify = 0;
newTransfers = false;
}
-
+
QString username;
QString password;
QString server;
@@ -92,7 +92,7 @@ public:
int state;
int notify;
bool newTransfers;
-
+
int errCond;
QString errText;
@@ -103,12 +103,10 @@ public:
};
ClientStream::ClientStream(Connector *conn, QObject *parent)
-:Stream(parent)
+:Stream(parent), d(new Private())
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
-
- d = new Private;
+ kdDebug(YAHOO_RAW_DEBUG) ;
+
d->mode = Client;
d->conn = conn;
connect( d->conn, SIGNAL(connected()), SLOT(cr_connected()) );
@@ -128,15 +126,16 @@ ClientStream::~ClientStream()
void ClientStream::reset(bool all)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
d->reset();
d->noopTimer.stop();
// client
if(d->mode == Client) {
-
+
// reset connector
if(d->bs) {
+ disconnect(d->bs, 0, this, 0);
d->bs->close();
d->bs = 0;
}
@@ -151,7 +150,7 @@ void ClientStream::reset(bool all)
void ClientStream::connectToServer(const QString& server, bool auth)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
reset(true);
d->state = Connecting;
d->doAuth = auth;
@@ -162,7 +161,7 @@ void ClientStream::connectToServer(const QString& server, bool auth)
void ClientStream::continueAfterWarning()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
/* unneeded?
if(d->state == WaitVersion) {
d->state = Connecting;
@@ -235,7 +234,7 @@ void ClientStream::close()
bool ClientStream::transfersAvailable() const
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
return ( !d->in.isEmpty() );
}
@@ -243,17 +242,17 @@ Transfer* ClientStream::read()
{
if(d->in.isEmpty())
return 0; //first from queue...
- else
+ else
return d->in.dequeue();
}
void ClientStream::write( Transfer *request )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
// pass to CoreProtocol for transformation into wire format
d->client.outgoingTransfer( request );
}
-
+
void cs_dump( const QByteArray &bytes )
{
#if 0
@@ -278,7 +277,7 @@ void cs_dump( const QByteArray &bytes )
if ( count + i < bytes.count() )
{
int j = bytes [ count + i ];
- if ( j >= 0x20 && j <= 0x7e )
+ if ( j >= 0x20 && j <= 0x7e )
printf( "%2c ", j );
else
printf( "%2c ", '.' );
@@ -298,32 +297,35 @@ void cs_dump( const QByteArray &bytes )
void ClientStream::cp_outgoingData( const QByteArray& outgoingBytes )
{
+ if ( !d->bs )
+ return;
+
// take formatted bytes from CoreProtocol and put them on the wire
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "[data size: " << outgoingBytes.size() << "]" << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "[data size: " << outgoingBytes.size() << "]" << endl;
//cs_dump( outgoingBytes );
d->bs->write( outgoingBytes );
}
void ClientStream::cp_incomingData()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+// kdDebug(YAHOO_RAW_DEBUG) ;
Transfer * incoming = d->client.incomingTransfer();
if ( incoming )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " - got a new transfer" << endl;
+// kdDebug(YAHOO_RAW_DEBUG) << " - got a new transfer";
d->in.enqueue( incoming );
d->newTransfers = true;
emit doReadyRead();
}
else
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " - client signalled incomingData but none was available, state is: "<< d->client.state() << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " - client signalled incomingData but none was available, state is: "<< d->client.state() << endl;
}
/* Connector connected */
void ClientStream::cr_connected()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
-
+ kdDebug(YAHOO_RAW_DEBUG) ;
+
d->bs = d->conn->stream();
connect(d->bs, SIGNAL(connectionClosed()), SLOT(bs_connectionClosed()));
connect(d->bs, SIGNAL(delayedCloseFinished()), SLOT(bs_delayedCloseFinished()));
@@ -341,12 +343,12 @@ void ClientStream::cr_connected()
void ClientStream::cr_error()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
reset();
emit error(ErrConnection);
}
-void ClientStream::bs_connectionClosed()
+void ClientStream::bs_connectionClosed()
{
reset();
emit connectionClosed();
@@ -359,20 +361,20 @@ void ClientStream::bs_delayedCloseFinished()
void ClientStream::bs_error(int)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
// TODO
}
void ClientStream::bs_readyRead()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+// kdDebug(YAHOO_RAW_DEBUG) ;
QByteArray a;
//qDebug( "size of storage for incoming data is %i bytes.", a.size() );
a = d->bs->read();
//QCString cs(a.data(), a.size()+1);
//qDebug("ClientStream: recv: %d [%s]\n", a.size(), cs.data());
- //kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " recv: " << a.size() <<" bytes" <<endl;
+ //kdDebug(YAHOO_RAW_DEBUG) << " recv: " << a.size() <<" bytes";
//cs_dump( a );
d->client.addIncomingData(a);
@@ -380,7 +382,7 @@ void ClientStream::bs_readyRead()
void ClientStream::bs_bytesWritten(int bytes)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " written: " << bytes <<" bytes" <<endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " written: " << bytes <<" bytes" << endl;
}
void ClientStream::srvProcessNext()
@@ -389,13 +391,13 @@ void ClientStream::srvProcessNext()
void ClientStream::doReadyRead()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+// kdDebug(YAHOO_RAW_DEBUG) ;
emit readyRead();
}
void ClientStream::processNext()
{
- if( !d->in.isEmpty() )
+ if( !d->in.isEmpty() )
{
QTimer::singleShot(0, this, SLOT(doReadyRead()));
}
diff --git a/kopete/protocols/yahoo/libkyahoo/yahooclientstream.h b/kopete/protocols/yahoo/libkyahoo/yahooclientstream.h
index 28301843..01ca6a2a 100644
--- a/kopete/protocols/yahoo/libkyahoo/yahooclientstream.h
+++ b/kopete/protocols/yahoo/libkyahoo/yahooclientstream.h
@@ -1,13 +1,13 @@
/*
oscarclientstream.h - Kopete Yahoo Protocol
-
+
Copyright (c) 2004 Matt Rogers <matt.rogers@kdemail.net>
-
+
Based on code Copyright (c) 2004 SuSE Linux AG <http://www.suse.com>
- Based on Iris, Copyright (C) 2003 Justin Karneges
-
+ Based on Iris, Copyright (C) 2003 Justin Karneges <justin@affinix.com>
+
Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
-
+
*************************************************************************
* *
* This library is free software; you can redistribute it and/or *
@@ -26,7 +26,6 @@
class QHostAddress;
// forward defines
-class ByteStream;
class Connector;
class Transfer;
@@ -40,20 +39,20 @@ public:
ErrAuth, // Auth error, see condition
ErrBind // Resource binding error
};
-
+
enum Warning {
- WarnOldVersion, // server uses older XMPP/Jabber "0.9" protocol // can be customised for novell versions
+ WarnOldVersion, // server uses older XMPP/Jabber "0.9" protocol // can be customized for novell versions
WarnNoTLS // there is no chance for TLS at this point
};
-
+
enum NegCond {
HostGone, // host no longer hosted
HostUnknown, // unknown host
RemoteConnectionFailed, // unable to connect to a required remote resource
SeeOtherHost, // a 'redirect', see errorText() for other host
UnsupportedVersion // unsupported XMPP version
- };
-
+ }
+;
enum AuthCond {
GenericAuthError, // all-purpose "can't login" error
NoMech, // No appropriate auth mech available
@@ -66,13 +65,13 @@ public:
NotAuthorized, // bad user, bad password, bad creditials
TemporaryAuthFailure // please try again later!
};
-
+
enum BindCond {
BindNotAllowed, // not allowed to bind a resource
BindConflict // resource in-use
};
- ClientStream(Connector *conn, QObject *parent=0);
+ explicit ClientStream(Connector *conn, QObject *parent=0);
~ClientStream();
void connectToServer(const QString& server, bool auth=true);
@@ -87,12 +86,12 @@ public:
void setLocalAddr(const QHostAddress &addr, Q_UINT16 port);
void close();
-
+
/**
* Are there any messages waiting to be read
*/
bool transfersAvailable() const;
-
+
/**
* Read a message received from the server
*/
@@ -124,7 +123,7 @@ private slots:
void cr_error();
/**
* collects wire ready outgoing data from the core protocol and sends
- */
+ */
void cp_outgoingData( const QByteArray& );
/**
* collects parsed incoming data as a transfer from the core protocol and queues
@@ -142,15 +141,15 @@ private slots:
private:
class Private;
- Private *d;
+ Private * const d;
void reset(bool all=false);
void processNext();
bool handleNeed();
void handleError();
void srvProcessNext();
-
- /**
+
+ /**
* convert internal method representation to wire
*/
static char* encode_method(Q_UINT8 method);
diff --git a/kopete/protocols/yahoo/libkyahoo/yahooconnector.cpp b/kopete/protocols/yahoo/libkyahoo/yahooconnector.cpp
index 0e163de8..fce630db 100644
--- a/kopete/protocols/yahoo/libkyahoo/yahooconnector.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/yahooconnector.cpp
@@ -4,7 +4,7 @@
-------------------
begin : Wed Jul 7 2004
copyright : (C) 2004 by Till Gerken <till@tantalo.net>
-
+
Kopete (C) 2004 Kopete developers <kopete-devel@kde.org>
***************************************************************************/
@@ -25,10 +25,10 @@
#include "yahoobytestream.h"
#include "yahootypes.h"
-KNetworkConnector::KNetworkConnector( QObject *parent, const char */*name*/ )
+KNetworkConnector::KNetworkConnector( QObject *parent )
: Connector( parent )
{
- kdDebug( YAHOO_RAW_DEBUG ) << k_funcinfo << "New KNetwork connector." << endl;
+ kdDebug( YAHOO_RAW_DEBUG ) << "New KNetwork connector." << endl;
mErrorCode = KNetwork::KSocketBase::NoError;
@@ -47,7 +47,7 @@ KNetworkConnector::~KNetworkConnector()
void KNetworkConnector::connectToServer( const QString &server )
{
Q_UNUSED( server );
- kdDebug( YAHOO_RAW_DEBUG ) << k_funcinfo << "Initiating connection to " << mHost << endl;
+ kdDebug( YAHOO_RAW_DEBUG ) << "Initiating connection to " << mHost << endl;
Q_ASSERT( !mHost.isNull() );
Q_ASSERT( mPort );
@@ -63,7 +63,7 @@ void KNetworkConnector::connectToServer( const QString &server )
void KNetworkConnector::slotConnected()
{
- kdDebug( YAHOO_RAW_DEBUG ) << k_funcinfo << "We are connected." << endl;
+ kdDebug( YAHOO_RAW_DEBUG ) << "We are connected." << endl;
// FIXME: setPeerAddress() is something different, find out correct usage later
//KInetSocketAddress inetAddress = mStreamSocket->address().asInet().makeIPv6 ();
@@ -74,7 +74,7 @@ void KNetworkConnector::slotConnected()
void KNetworkConnector::slotError( int code )
{
- kdDebug( YAHOO_RAW_DEBUG ) << k_funcinfo << "Error detected: " << code << endl;
+ kdDebug( YAHOO_RAW_DEBUG ) << "Error detected: " << code << endl;
mErrorCode = code;
emit error ();
@@ -87,19 +87,19 @@ int KNetworkConnector::errorCode()
ByteStream *KNetworkConnector::stream() const
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
return mByteStream;
}
void KNetworkConnector::done()
{
- kdDebug ( YAHOO_RAW_DEBUG ) << k_funcinfo << endl;
+ kdDebug ( YAHOO_RAW_DEBUG ) ;
mByteStream->close ();
}
void KNetworkConnector::setOptHostPort( const QString &host, Q_UINT16 port )
{
- kdDebug ( YAHOO_RAW_DEBUG ) << k_funcinfo << "Manually specifying host " << host << " and port " << port << endl;
+ kdDebug ( YAHOO_RAW_DEBUG ) << "Manually specifying host " << host << " and port " << port << endl;
mHost = host;
mPort = port;
diff --git a/kopete/protocols/yahoo/libkyahoo/yahooconnector.h b/kopete/protocols/yahoo/libkyahoo/yahooconnector.h
index 09070d87..10c86ce0 100644
--- a/kopete/protocols/yahoo/libkyahoo/yahooconnector.h
+++ b/kopete/protocols/yahoo/libkyahoo/yahooconnector.h
@@ -25,7 +25,6 @@
class ByteStream;
class KNetworkByteStream;
-class KResolverEntry;
/**
@author Till Gerken
@@ -37,7 +36,7 @@ class KNetworkConnector : public Connector
Q_OBJECT
public:
- KNetworkConnector( QObject *parent = 0, const char *name = 0 );
+ KNetworkConnector( QObject *parent = 0 );
virtual ~KNetworkConnector();
diff --git a/kopete/protocols/yahoo/libkyahoo/yahootypes.h b/kopete/protocols/yahoo/libkyahoo/yahootypes.h
index e254bab7..244d4022 100644
--- a/kopete/protocols/yahoo/libkyahoo/yahootypes.h
+++ b/kopete/protocols/yahoo/libkyahoo/yahootypes.h
@@ -19,14 +19,15 @@
#define YAHOOTYPESH
#include <qglobal.h>
+#include <qstring.h>
const int YAHOO_RAW_DEBUG = 14181;
const int YAHOO_GEN_DEBUG = 14180;
namespace Yahoo
{
- enum Service
- {
+ enum Service
+ {
/* these are easier to see in hex */
ServiceLogon = 1,
ServiceLogoff,
@@ -71,8 +72,8 @@ namespace Yahoo
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) */
@@ -95,15 +96,17 @@ namespace Yahoo
ServiceStatus = 0xc6, /* YMSG13 */
ServicePictureStatus = 0xc7, /* YMSG13, key 213: 0 = none, 1 = avatar, 2 = picture */
ServiceContactDetails = 0xd3, /* YMSG13 */
- ServiceChatSession = 0xd4,
+ ServiceChatSession = 0xd4,
ServiceAuthorization = 0xd6, /* YMSG13 */
ServiceFileTransfer7 = 0xdc, /* YMSG13 */
- ServiceFileTransfer7Info, /* YMSG13 */
- ServiceFileTransfer7Accept, /* YMSG13 */
- ServiceBuddyChangeGroup = 0xe7 /* YMSG13 */
+ ServiceFileTransfer7Info = 0xdd, /* YMSG13 */
+ ServiceFileTransfer7Accept = 0xde, /* YMSG13 */
+ ServiceBuddyChangeGroup = 0xe7, /* YMSG13 */
+ ServiceBuddyStatus = 0xf0,
+ ServiceBuddyList = 0xf1
};
-
- enum Status
+
+ enum Status
{
StatusConnecting = -2,
StatusDisconnected = -1,
@@ -132,13 +135,13 @@ namespace Yahoo
};
enum LoginStatus {
- LoginOk = 0,
- LoginUname = 3,
- LoginPasswd = 13,
- LoginLock = 14,
- LoginVerify = 29, // FIXME: Find the reason for this response
- LoginDupl = 99,
- LoginSock = -1
+ LoginOk = 0,
+ LoginUname = 3,
+ LoginPasswd = 13,
+ LoginLock = 14,
+ LoginVerify = 29, // FIXME: Find the reason for this response
+ LoginDupl = 99,
+ LoginSock = -1
};
enum StealthMode {
@@ -158,9 +161,26 @@ namespace Yahoo
ResponseDecline
};
+ enum PictureStatus {
+ NoPicture = 0,
+ Avatar = 1,
+ Picture = 2
+ };
+
typedef Q_UINT8 BYTE;
typedef Q_UINT16 WORD;
typedef Q_UINT32 DWORD;
+
+ struct ChatRoom {
+ QString name;
+ QString topic;
+ int id;
+ };
+
+ struct ChatCategory {
+ QString name;
+ int id;
+ };
}
#define yahoo_put16(buf, data) ( \
diff --git a/kopete/protocols/yahoo/libkyahoo/ymsgprotocol.cpp b/kopete/protocols/yahoo/libkyahoo/ymsgprotocol.cpp
index 79687073..ce2c65eb 100644
--- a/kopete/protocols/yahoo/libkyahoo/ymsgprotocol.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/ymsgprotocol.cpp
@@ -3,7 +3,7 @@
Copyright (c) 2004 Duncan Mac-Vicar Prett <duncan@kde.org>
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005 André Duffeck <duffeck@kde.org>
Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
*************************************************************************
@@ -16,14 +16,18 @@
*************************************************************************
*/
-#include <stdlib.h>
+//#include <QDataStream>
+//#include <QMap>
+//#include <QObject>
+//#include <QStringList>
-#include <qcstring.h>
+//#include <qcstring.h>
#include <qdatastream.h>
#include <qmap.h>
#include <qobject.h>
#include <qstringlist.h>
+
#include <kdebug.h>
#include "ymsgprotocol.h"
@@ -55,188 +59,252 @@ Transfer* YMSGProtocol::parse( const QByteArray & packet, uint& bytes )
/ 0 - 65535* |
+-------------------------------------------------+
*/
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << packet << endl;
-
+ kdDebug(YAHOO_RAW_DEBUG) << packet << endl;
+
int pos = 0;
int len = 0;
-
+
Yahoo::Status status = Yahoo::StatusAvailable;
Yahoo::Service service = Yahoo::ServiceAuth;
int statusnum = 0;
int sessionid = 0;
int servicenum;
int version1, version2;
-
+
QMap<QString, QString> params;
-
+
// Skip the YMSG header
pos += 4;
-
+
// Skip the version
version1 = yahoo_get16(packet.data() + pos);
pos += 2;
version2 = yahoo_get16(packet.data() + pos);
pos += 2;
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " - parsed packet version " << version1 << " " << version2 << endl;
-
+ kdDebug(YAHOO_RAW_DEBUG) << " - parsed packet version " << version1 << " " << version2 << endl;
+
len = yahoo_get16(packet.data() + pos);
pos += 2;
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " - parsed packet len " << len << endl;
-
+ kdDebug(YAHOO_RAW_DEBUG) << " - parsed packet len " << len << endl;
+
servicenum = yahoo_get16(packet.data() + pos);
pos += 2;
-
+
switch (servicenum)
{
// TODO add remamining services
case (Yahoo::ServiceAuth) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceAuth " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceAuth " << servicenum << endl;
service = Yahoo::ServiceAuth;
break;
case (Yahoo::ServiceAuthResp) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceAuthResp " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceAuthResp " << servicenum << endl;
service = Yahoo::ServiceAuthResp;
break;
case (Yahoo::ServiceVerify) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceVerify " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceVerify " << servicenum << endl;
service = Yahoo::ServiceVerify;
break;
case (Yahoo::ServiceList) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceList " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceList " << servicenum << endl;
service = Yahoo::ServiceList;
break;
case (Yahoo::ServiceLogon) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceLogon " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceLogon " << servicenum << endl;
service = Yahoo::ServiceLogon;
break;
case (Yahoo::ServicePing) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServicePing " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServicePing " << servicenum << endl;
service = Yahoo::ServicePing;
break;
case (Yahoo::ServiceNewMail) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceNewMail " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceNewMail " << servicenum << endl;
service = Yahoo::ServiceNewMail;
break;
case (Yahoo::ServiceLogoff) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceLogoff " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceLogoff " << servicenum << endl;
service = Yahoo::ServiceLogoff;
break;
case (Yahoo::ServiceIsAway) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceIsAway " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceIsAway " << servicenum << endl;
service = Yahoo::ServiceIsAway;
break;
case (Yahoo::ServiceIsBack) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceIsBack " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceIsBack " << servicenum << endl;
service = Yahoo::ServiceIsBack;
break;
case (Yahoo::ServiceGameLogon) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceGameLogon " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceGameLogon " << servicenum << endl;
service = Yahoo::ServiceGameLogon;
break;
case (Yahoo::ServiceGameLogoff) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceGameLogoff " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceGameLogoff " << servicenum << endl;
service = Yahoo::ServiceGameLogoff;
break;
case (Yahoo::ServiceIdAct) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceIdAct " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceIdAct " << servicenum << endl;
service = Yahoo::ServiceIdAct;
break;
case (Yahoo::ServiceIddeAct) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceIddeAct " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceIddeAct " << servicenum << endl;
service = Yahoo::ServiceIddeAct;
break;
case (Yahoo::ServiceStatus) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceStatus " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceStatus " << servicenum << endl;
service = Yahoo::ServiceStatus;
break;
case (Yahoo::ServiceMessage) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceMessage " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceMessage " << servicenum << endl;
service = Yahoo::ServiceMessage;
break;
case (Yahoo::ServiceNotify) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceNotify " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceNotify " << servicenum << endl;
service = Yahoo::ServiceNotify;
break;
- case (Yahoo::ServiceAddBuddy) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceAddBuddy " << servicenum << endl;
- service = Yahoo::ServiceAddBuddy;
- break;
+ case (Yahoo::ServiceBuddyAdd) :
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceBuddyAdd " << servicenum << endl;
+ service = Yahoo::ServiceBuddyAdd;
+ break;
+ case (Yahoo::ServiceBuddyRemove) :
+ kdDebug(YAHOO_RAW_DEBUG) << "Parsed packet service - This means ServiceBuddyRemove " << servicenum << endl;
+ service = Yahoo::ServiceBuddyRemove;
+ break;
+ case (Yahoo::ServiceBuddyChangeGroup) :
+ kdDebug(YAHOO_RAW_DEBUG) << "Parsed packet service - This means ServiceBuddyChangeGroup " << servicenum << endl;
+ service = Yahoo::ServiceBuddyChangeGroup;
+ break;
case (Yahoo::ServicePictureChecksum) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServicePictureChecksum " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServicePictureChecksum " << servicenum << endl;
service = Yahoo::ServicePictureChecksum;
break;
case (Yahoo::ServicePictureStatus) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServicePictureStatus " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServicePictureStatus " << servicenum << endl;
service = Yahoo::ServicePictureStatus;
break;
case (Yahoo::ServicePicture) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServicePicture " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServicePicture " << servicenum << endl;
service = Yahoo::ServicePicture;
break;
case (Yahoo::ServiceStealthOnline) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceStealthOnline " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceStealthOnline " << servicenum << endl;
service = Yahoo::ServiceStealthOnline;
break;
case (Yahoo::ServiceStealthOffline) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceStealthOffline " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceStealthOffline " << servicenum << endl;
service = Yahoo::ServiceStealthOffline;
break;
case (Yahoo::ServicePictureUpload) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServicePictureUpload " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServicePictureUpload " << servicenum << endl;
service = Yahoo::ServicePictureUpload;
break;
case (Yahoo::ServiceWebcam) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceWebcam " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceWebcam " << servicenum << endl;
service = Yahoo::ServiceWebcam;
break;
case (Yahoo::ServiceConfInvite) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceConfInvite " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceConfInvite " << servicenum << endl;
service = Yahoo::ServiceConfInvite;
break;
case (Yahoo::ServiceConfLogon) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceConfLogon " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceConfLogon " << servicenum << endl;
service = Yahoo::ServiceConfLogon;
break;
case (Yahoo::ServiceConfDecline) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceConfDecline " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceConfDecline " << servicenum << endl;
service = Yahoo::ServiceConfDecline;
break;
case (Yahoo::ServiceConfLogoff) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceConfLogoff " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceConfLogoff " << servicenum << endl;
service = Yahoo::ServiceConfLogoff;
break;
case (Yahoo::ServiceConfAddInvite) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceConfAddInvite " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceConfAddInvite " << servicenum << endl;
service = Yahoo::ServiceConfAddInvite;
break;
case (Yahoo::ServiceConfMsg) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceConfMsg " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceConfMsg " << servicenum << endl;
service = Yahoo::ServiceConfMsg;
break;
case (Yahoo::ServiceAuthorization) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceAuthorization " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceAuthorization " << servicenum << endl;
service = Yahoo::ServiceAuthorization;
break;
case (Yahoo::ServiceContactDetails) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceContactDetails " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceContactDetails " << servicenum << endl;
service = Yahoo::ServiceContactDetails;
break;
case (Yahoo::ServiceFileTransfer) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceFileTransfer " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceFileTransfer " << servicenum << endl;
service = Yahoo::ServiceFileTransfer;
break;
case (Yahoo::ServiceFileTransfer7) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceFileTransfer7 " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceFileTransfer7 " << servicenum << endl;
service = Yahoo::ServiceFileTransfer7;
break;
case (Yahoo::ServiceFileTransfer7Info) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceFileTransfer7Info " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceFileTransfer7Info " << servicenum << endl;
service = Yahoo::ServiceFileTransfer7Info;
break;
+ case (Yahoo::ServiceFileTransfer7Accept) :
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceFileTransfer7Accept " << servicenum << endl;
+ service = Yahoo::ServiceFileTransfer7Accept;
+ break;
case (Yahoo::ServicePeerToPeer) :
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServicePeerToPeer " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServicePeerToPeer " << servicenum << endl;
service = Yahoo::ServicePeerToPeer;
break;
+ case (Yahoo::ServiceChatOnline) :
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceChatOnline " << servicenum << endl;
+ service = Yahoo::ServiceChatOnline;
+ break;
+ case (Yahoo::ServiceChatGoto) :
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceChatGoto " << servicenum << endl;
+ service = Yahoo::ServiceChatGoto;
+ break;
+ case (Yahoo::ServiceChatJoin) :
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceChatJoin " << servicenum << endl;
+ service = Yahoo::ServiceChatJoin;
+ break;
+ case (Yahoo::ServiceChatleave) :
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceChatleave " << servicenum << endl;
+ service = Yahoo::ServiceChatleave;
+ break;
+ case (Yahoo::ServiceChatExit) :
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceChatExit " << servicenum << endl;
+ service = Yahoo::ServiceChatExit;
+ break;
+ case (Yahoo::ServiceChatLogout) :
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceChatLogout " << servicenum << endl;
+ service = Yahoo::ServiceChatLogout;
+ break;
+ case (Yahoo::ServiceChatPing) :
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServicePeerToPeer " << servicenum << endl;
+ service = Yahoo::ServiceChatPing;
+ break;
+ case (Yahoo::ServiceChatLogon) :
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceChatLogon " << servicenum << endl;
+ service = Yahoo::ServiceChatLogon;
+ break;
+ case (Yahoo::ServiceChatLogoff) :
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceChatLogoff " << servicenum << endl;
+ service = Yahoo::ServiceChatLogoff;
+ break;
+ case (Yahoo::ServiceChatMsg) :
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceChatMsg " << servicenum << endl;
+ service = Yahoo::ServiceChatMsg;
+ break;
+ case (Yahoo::ServiceComment) :
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceComment " << servicenum << endl;
+ service = Yahoo::ServiceComment;
+ break;
+ case (Yahoo::ServiceBuddyStatus) :
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceBuddyStatus " << servicenum << endl;
+ service = Yahoo::ServiceBuddyStatus;
+ break;
+ case (Yahoo::ServiceBuddyList) :
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceBuddyList " << servicenum << endl;
+ service = Yahoo::ServiceBuddyList;
+ break;
/*
ServiceIdle, // 5 (placemarker)
ServiceMailStat,
@@ -250,9 +318,6 @@ Transfer* YMSGProtocol::parse( const QByteArray & packet, uint& bytes )
ServiceGotGroupRename, // < 1, 36(old), 37(new)
ServiceSysMessage = 0x14,
ServicePassThrough2 = 0x16,
- ServiceChatLogon,
- ServiceChatLogoff,
- ServiceChatMsg = 0x20,
ServiceGameMsg = 0x2a,
ServiceFileTransfer = 0x46,
ServiceVoiceChat = 0x4A,
@@ -261,28 +326,20 @@ Transfer* YMSGProtocol::parse( const QByteArray & packet, uint& bytes )
ServiceRemBuddy,
ServiceIgnoreContact, // > 1, 7, 13 < 1, 66, 13, 0
ServiceRejectContact,
- ServiceGroupRename = 0x89, // > 1, 65(new), 66(0), 67(old)
- ServiceChatOnline = 0x96, // > 109(id), 1, 6(abcde) < 0,1
- ServiceChatGoto,
- ServiceChatJoin, // > 1 104-room 129-1600326591 62-2
- ServiceChatleave,
- ServiceChatExit = 0x9b,
- ServiceChatLogout = 0xa0,
- ServiceChatPing,
- ServiceComment = 0xa8
+ ServiceGroupRename = 0x89, // > 1, 65(new), 66(0), 67(old)
ServicePictureUpdate = 0xc1,
- ServiceVisibility = 0xc5, // YMSG13, key 13: 2 = invisible, 1 = visible
- ServiceStatus = 0xc6, // YMSG13
+ ServiceVisibility = 0xc5, // YMSG13, key 13: 2 = invisible, 1 = visible
+ ServiceStatus = 0xc6, // YMSG13
*/
default:
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means an unknown service " << servicenum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means an unknown service " << servicenum << endl;
break;
}
-
+
statusnum = yahoo_get32(packet.data() + pos);
pos += 4;
-
+
switch (statusnum)
{
// TODO add remaining status
@@ -309,37 +366,37 @@ Transfer* YMSGProtocol::parse( const QByteArray & packet, uint& bytes )
StatusOffline
StatusNotify*/
default:
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " - unknown status " << statusnum << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " - unknown status " << statusnum << endl;
break;
}
-
+
sessionid = yahoo_get32(packet.data() + pos);
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed session id: " << (void *)sessionid << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Parsed session id: " << (void *)sessionid << endl;
pos += 4;
-
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Setting incoming transfer basic information." << endl;
+
+ kdDebug(YAHOO_RAW_DEBUG) << " Setting incoming transfer basic information." << endl;
YMSGTransfer *t = new YMSGTransfer();
t->setService(service);
t->setId(sessionid);
t->setStatus(status);
+ t->setPacketLength(len);
- QString d = QString::fromAscii( packet.data() + pos, packet.size() - pos );
- QStringList list;
- list = QStringList::split( "\xc0\x80", d );
- for( uint i = 0; i+1 < list.size() && pos+1 < len+20; i += 2 ) {
- QString key = list[i];
- QString value = QString::fromUtf8( list[i+1].ascii() );
- pos += key.utf8().length() + value.utf8().length() + 4;
- t->setParam( QString(key).toInt(), value.utf8() );
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Key: " << key << " Value: " << value << endl;
- }
+ QString d = QString::fromAscii( packet.data() + pos, packet.size() - pos );
+ QStringList list = QStringList::split( "\xc0\x80", d );
+ for( int i = 0; i+1 < list.size() && pos+1 < len+20; i += 2 ) {
+ QString key = list[i];
+ QString value = QString::fromUtf8( list[i+1].ascii() );
+ pos += key.utf8().length() + value.utf8().length() + 4;
+ t->setParam( QString(key).toInt(), value.utf8() );
+ kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Key: " << key << " Value: " << value << endl;
+ }
- while( (uint)pos < packet.size() && packet.data()[pos] == '\x00' )
- pos++;
+ while( pos < packet.size() && packet.data()[pos] == '\x00' )
+ pos++;
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Returning transfer" << endl;
+// kdDebug(YAHOO_RAW_DEBUG) << " Returning transfer";
// tell them we have parsed offset bytes
-
+
bytes = pos;
return t;
}
diff --git a/kopete/protocols/yahoo/libkyahoo/ymsgprotocol.h b/kopete/protocols/yahoo/libkyahoo/ymsgprotocol.h
index 97de7477..230745ef 100644
--- a/kopete/protocols/yahoo/libkyahoo/ymsgprotocol.h
+++ b/kopete/protocols/yahoo/libkyahoo/ymsgprotocol.h
@@ -3,7 +3,7 @@
Copyright (c) 2004 Duncan Mac-Vicar Prett <duncan@kde.org>
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005 André Duffeck <duffeck@kde.org>
Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
*************************************************************************
@@ -26,17 +26,17 @@ class YMSGProtocol : public InputProtocolBase
{
Q_OBJECT
public:
-
+
YMSGProtocol( QObject *parent = 0, const char *name = 0 );
~YMSGProtocol();
-
- /**
- * Attempt to parse the supplied data into an @ref YMSGTransfer object.
- * The exact state of the parse attempt can be read using @ref state.
+
+ /**
+ * Attempt to parse the supplied data into an @ref YMSGTransfer object.
+ * The exact state of the parse attempt can be read using @ref state.
* @param rawData The unparsed data.
* @param bytes An integer used to return the number of bytes read.
- * @return A pointer to an EventTransfer object if successfull, otherwise 0. The caller is responsible for deleting this object.
+ * @return A pointer to an EventTransfer object if successful, otherwise 0. The caller is responsible for deleting this object.
*/
Transfer * parse( const QByteArray &, uint & bytes );
};
diff --git a/kopete/protocols/yahoo/libkyahoo/ymsgtransfer.cpp b/kopete/protocols/yahoo/libkyahoo/ymsgtransfer.cpp
index f47a07d1..233b0c85 100644
--- a/kopete/protocols/yahoo/libkyahoo/ymsgtransfer.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/ymsgtransfer.cpp
@@ -4,7 +4,7 @@
Copyright (c) 2004 Duncan Mac-Vicar P. <duncan@kde.org>
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005 André Duffeck <duffeck@kde.org>
Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
@@ -23,6 +23,7 @@
#include "ymsgtransfer.h"
#include "yahootypes.h"
#include "kdebug.h"
+
#include <qdatastream.h>
#include <qmap.h>
#include <qstring.h>
@@ -39,7 +40,7 @@ public:
int packetLength;
Yahoo::Service service;
Yahoo::Status status;
- unsigned int id;
+ unsigned int id;
ParamList data;
bool valid;
};
@@ -80,12 +81,12 @@ Transfer::TransferType YMSGTransfer::type()
return Transfer::YMSGTransfer;
}
-bool YMSGTransfer::isValid()
+bool YMSGTransfer::isValid() const
{
return d->valid;
}
-Yahoo::Service YMSGTransfer::service()
+Yahoo::Service YMSGTransfer::service() const
{
return d->service;
}
@@ -95,7 +96,7 @@ void YMSGTransfer::setService(Yahoo::Service service)
d->service = service;
}
-Yahoo::Status YMSGTransfer::status()
+Yahoo::Status YMSGTransfer::status() const
{
return d->status;
}
@@ -105,7 +106,7 @@ void YMSGTransfer::setStatus(Yahoo::Status status)
d->status = status;
}
-unsigned int YMSGTransfer::id()
+unsigned int YMSGTransfer::id() const
{
return d->id;
}
@@ -115,15 +116,25 @@ void YMSGTransfer::setId(unsigned int id)
d->id = id;
}
-ParamList YMSGTransfer::paramList()
+int YMSGTransfer::packetLength() const
+{
+ return d->packetLength;
+}
+
+void YMSGTransfer::setPacketLength(int len)
+{
+ d->packetLength = len;
+}
+
+ParamList YMSGTransfer::paramList() const
{
return d->data;
}
-int YMSGTransfer::paramCount( int index )
+int YMSGTransfer::paramCount( int index ) const
{
int cnt = 0;
- for (ParamList::ConstIterator it = d->data.begin(); it != d->data.end(); ++it)
+ for (ParamList::ConstIterator it = d->data.constBegin(); it != d->data.constEnd(); ++it)
{
if( (*it).first == index )
cnt++;
@@ -132,34 +143,34 @@ int YMSGTransfer::paramCount( int index )
}
-QCString YMSGTransfer::nthParam( int index, int occurence )
+QCString YMSGTransfer::nthParam( int index, int occurrence ) const
{
int cnt = 0;
- for (ParamList::ConstIterator it = d->data.begin(); it != d->data.end(); ++it)
+ for (ParamList::ConstIterator it = d->data.constBegin(); it != d->data.constEnd(); ++it)
{
- if( (*it).first == index && cnt++ == occurence)
+ if( (*it).first == index && cnt++ == occurrence)
return (*it).second;
}
return QCString();
}
-QCString YMSGTransfer::nthParamSeparated( int index, int occurence, int separator )
+QCString YMSGTransfer::nthParamSeparated( int index, int occurrence, int separator ) const
{
int cnt = -1;
- for (ParamList::ConstIterator it = d->data.begin(); it != d->data.end(); ++it)
+ for (ParamList::ConstIterator it = d->data.constBegin(); it != d->data.constEnd(); ++it)
{
if( (*it).first == separator )
cnt++;
- if( (*it).first == index && cnt == occurence)
+ if( (*it).first == index && cnt == occurrence)
return (*it).second;
}
return QCString();
}
-QCString YMSGTransfer::firstParam( int index )
+QCString YMSGTransfer::firstParam( int index ) const
{
- for (ParamList::ConstIterator it = d->data.begin(); it != d->data.end(); ++it)
+ for (ParamList::ConstIterator it = d->data.constBegin(); it != d->data.constEnd(); ++it)
{
if( (*it).first == index )
return (*it).second;
@@ -177,10 +188,10 @@ void YMSGTransfer::setParam( int index, int data )
d->data.append( Param( index, QString::number( data ).local8Bit() ) );
}
-int YMSGTransfer::length()
+int YMSGTransfer::length() const
{
int len = 0;
- for (ParamList::ConstIterator it = d->data.begin(); it != d->data.end(); ++it)
+ for (ParamList::ConstIterator it = d->data.constBegin(); it != d->data.constEnd(); ++it)
{
len += QString::number( (*it).first ).length();
len += 2;
@@ -191,7 +202,7 @@ int YMSGTransfer::length()
}
-QByteArray YMSGTransfer::serialize()
+QByteArray YMSGTransfer::serialize() const
{
/*
<------- 4B -------><------- 4B -------><---2B--->
@@ -205,17 +216,17 @@ QByteArray YMSGTransfer::serialize()
/ 0 - 65535* |
+-------------------------------------------------+
*/
-
+
int pos = 0;
QStringList::ConstIterator listIt = 0;
QByteArray buffer;
QDataStream stream( buffer, IO_WriteOnly );
-
+
stream << (Q_INT8)'Y' << (Q_INT8)'M' << (Q_INT8)'S' << (Q_INT8)'G';
if( d->service == Yahoo::ServicePictureUpload )
- stream << (Q_INT16)0x0e00;
+ stream << (Q_INT16)0x0f00;
else
- stream << (Q_INT16)0x000e;
+ stream << (Q_INT16)0x000f;
stream << (Q_INT16)0x0000;
if( d->service == Yahoo::ServicePictureUpload ||
d->service == Yahoo::ServiceFileTransfer )
@@ -225,15 +236,15 @@ QByteArray YMSGTransfer::serialize()
stream << (Q_INT16)d->service;
stream << (Q_INT32)d->status;
stream << (Q_INT32)d->id;
- for (ParamList::ConstIterator it = d->data.begin(); it != d->data.end(); ++it)
+ for (ParamList::ConstIterator it = d->data.constBegin(); it != d->data.constEnd(); ++it)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Serializing key " << (*it).first << " value " << (*it).second << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " Serializing key " << (*it).first << " value " << (*it).second << endl;
stream.writeRawBytes ( QString::number( (*it).first ).local8Bit(), QString::number( (*it).first ).length() );
stream << (Q_INT8)0xc0 << (Q_INT8)0x80;
stream.writeRawBytes( (*it).second, (*it).second.length() );
stream << (Q_INT8)0xc0 << (Q_INT8)0x80;
}
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " pos=" << pos << " (packet size)" << buffer << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " pos=" << pos << " (packet size)" << buffer << endl;
return buffer;
}
diff --git a/kopete/protocols/yahoo/libkyahoo/ymsgtransfer.h b/kopete/protocols/yahoo/libkyahoo/ymsgtransfer.h
index 79655766..662ca4d2 100644
--- a/kopete/protocols/yahoo/libkyahoo/ymsgtransfer.h
+++ b/kopete/protocols/yahoo/libkyahoo/ymsgtransfer.h
@@ -4,7 +4,7 @@
Copyright (c) 2004 Duncan Mac-Vicar P. <duncan@kde.org>
- Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
+ Copyright (c) 2005 André Duffeck <duffeck@kde.org>
Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
@@ -24,12 +24,11 @@
#include "transfer.h"
#include "yahootypes.h"
-#include <qcstring.h>
+
#include <qpair.h>
#include <qvaluelist.h>
class YMSGTransferPrivate;
-class QString;
typedef QPair< int, QCString > Param;
typedef QValueList< Param > ParamList;
@@ -49,26 +48,29 @@ public:
TransferType type();
//! Get the validity of the transfer object
- bool isValid();
- Yahoo::Service service();
+ bool isValid() const;
+ Yahoo::Service service() const;
void setService(Yahoo::Service service);
- Yahoo::Status status();
+ Yahoo::Status status() const;
void setStatus(Yahoo::Status status);
- unsigned int id();
+ unsigned int id() const;
void setId(unsigned int id);
+ int packetLength() const;
+ void setPacketLength(int len);
+
+
+ ParamList paramList() const;
+ QCString firstParam( int index ) const;
+ QCString nthParam( int index, int occurrence ) const;
+ QCString nthParamSeparated( int index, int occurrence, int separator ) const;
+ int paramCount( int index ) const;
- ParamList paramList();
- QCString firstParam( int index );
- QCString nthParam( int index, int occurence );
- QCString nthParamSeparated( int index, int occurence, int separator );
- int paramCount( int index );
-
void setParam(int index, const QCString &data);
void setParam(int index, int data);
- QByteArray serialize();
-
- int length();
+ QByteArray serialize() const;
+
+ int length() const;
private:
YMSGTransferPrivate* d;
};