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
v3.5.13-sru
tpearson 14 years ago
parent 1fc8db4874
commit 5527e01e06

@ -14,10 +14,10 @@ libkyahoo_la_SOURCES = client.cpp task.cpp connector.cpp inputprotocolbase.cpp \
requestpicturetask.cpp yahoobuddyiconloader.cpp stealthtask.cpp sendpicturetask.cpp \ requestpicturetask.cpp yahoobuddyiconloader.cpp stealthtask.cpp sendpicturetask.cpp \
webcamtask.cpp conferencetask.cpp sendauthresptask.cpp pingtask.cpp yabtask.cpp \ webcamtask.cpp conferencetask.cpp sendauthresptask.cpp pingtask.cpp yabtask.cpp \
yabentry.cpp modifyyabtask.cpp chatsessiontask.cpp sendfiletask.cpp filetransfernotifiertask.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_LDFLAGS = -no-undefined $(all_libraries)
libkyahoo_la_LIBADD = $(LIB_QT) libkyahoo_la_LIBADD = $(LIB_QT)
noinst_HEADERS = logintask.h yabentry.h yabtask.h modifyyabtask.h \ noinst_HEADERS = logintask.h yabentry.h yabtask.h modifyyabtask.h \
chatsessiontask.h chatsessiontask.h yahoochattask.h
KDE_OPTIONS = nofinal KDE_OPTIONS = nofinal

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Change our Status 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 "ymsgtransfer.h"
#include "yahootypes.h" #include "yahootypes.h"
#include "client.h" #include "client.h"
#include <qstring.h>
#include <kdebug.h> #include <kdebug.h>
ChangeStatusTask::ChangeStatusTask(Task* parent) : Task(parent) ChangeStatusTask::ChangeStatusTask(Task* parent) : Task(parent)
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
} }
ChangeStatusTask::~ChangeStatusTask() ChangeStatusTask::~ChangeStatusTask()
@ -33,7 +33,7 @@ ChangeStatusTask::~ChangeStatusTask()
void ChangeStatusTask::onGo() void ChangeStatusTask::onGo()
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
if( m_status == Yahoo::StatusInvisible ) // status --> Invisible if( m_status == Yahoo::StatusInvisible ) // status --> Invisible
{ {
@ -52,13 +52,13 @@ void ChangeStatusTask::onGo()
t->setParam( 10, m_status ); t->setParam( 10, m_status );
t->setParam( 47, m_type ); t->setParam( 47, m_type );
t->setParam( 97, 1 ); // it's utf8 t->setParam( 97, 1 ); // it's utf8
send( t ); send( t );
if( client()->status() == Yahoo::StatusInvisible ) // Invisible --> Status if( client()->status() == Yahoo::StatusInvisible ) // Invisible --> Status
sendVisibility( Visible ); sendVisibility( Visible );
} }
setSuccess( true ); setSuccess();
} }
void ChangeStatusTask::sendVisibility( Visibility visible ) void ChangeStatusTask::sendVisibility( Visibility visible )

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Change our Status 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 }; enum Type { Available, Away };
ChangeStatusTask(Task *parent); ChangeStatusTask(Task *parent);
~ChangeStatusTask(); ~ChangeStatusTask();
virtual void onGo(); virtual void onGo();
void setMessage( const QString &msg ); void setMessage( const QString &msg );

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
chatsessiontask.cpp - Register / Unregister a chatsession 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> Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
@ -26,7 +26,7 @@
ChatSessionTask::ChatSessionTask(Task* parent) : Task(parent) ChatSessionTask::ChatSessionTask(Task* parent) : Task(parent)
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
} }
ChatSessionTask::~ChatSessionTask() ChatSessionTask::~ChatSessionTask()
@ -35,7 +35,7 @@ ChatSessionTask::~ChatSessionTask()
void ChatSessionTask::onGo() void ChatSessionTask::onGo()
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
YMSGTransfer *t = new YMSGTransfer( Yahoo::ServiceChatSession ); YMSGTransfer *t = new YMSGTransfer( Yahoo::ServiceChatSession );
t->setId( client()->sessionID() ); t->setId( client()->sessionID() );
@ -52,7 +52,7 @@ void ChatSessionTask::onGo()
} }
send( t ); send( t );
setSuccess( true ); setSuccess();
} }
void ChatSessionTask::setTarget( const QString &to ) void ChatSessionTask::setTarget( const QString &to )

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
chatsessiontask.h - Register / Unregister a chatsession 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> Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>

@ -1,14 +1,14 @@
/* /*
Kopete Yahoo Protocol 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 Duncan Mac-Vicar P. <duncan@kde.org>
Copyright (c) 2004 Matt Rogers <matt.rogers@kdemail.net> Copyright (c) 2004 Matt Rogers <matt.rogers@kdemail.net>
Copyright (c) 2004 SuSE Linux AG <http://www.suse.com> 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> Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
************************************************************************* *************************************************************************
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
@ -20,9 +20,9 @@
*/ */
#include <qtimer.h> #include <qtimer.h>
#include <qpixmap.h>
#include <kdebug.h> #include <kdebug.h>
#include <kurl.h>
#include <ksocketbase.h> #include <ksocketbase.h>
#include "yahooclientstream.h" #include "yahooclientstream.h"
@ -52,6 +52,7 @@
#include "sendfiletask.h" #include "sendfiletask.h"
#include "filetransfernotifiertask.h" #include "filetransfernotifiertask.h"
#include "receivefiletask.h" #include "receivefiletask.h"
#include "yahoochattask.h"
#include "client.h" #include "client.h"
#include "yahootypes.h" #include "yahootypes.h"
#include "yahoobuddyiconloader.h" #include "yahoobuddyiconloader.h"
@ -73,7 +74,7 @@ public:
int error; int error;
QString errorString; QString errorString;
QString errorInformation; QString errorInformation;
// tasks // tasks
bool tasksInitialized; bool tasksInitialized;
LoginTask * loginTask; LoginTask * loginTask;
@ -86,6 +87,8 @@ public:
ConferenceTask *conferenceTask; ConferenceTask *conferenceTask;
YABTask *yabTask; YABTask *yabTask;
FileTransferNotifierTask *fileTransferTask; FileTransferNotifierTask *fileTransferTask;
YahooChatTask *yahooChatTask;
ReceiveFileTask *receiveFileTask;
// Connection data // Connection data
uint sessionID; uint sessionID;
@ -95,10 +98,13 @@ public:
Yahoo::Status status; Yahoo::Status status;
Yahoo::Status statusOnConnect; Yahoo::Status statusOnConnect;
QString statusMessageOnConnect; 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 = new ClientPrivate;
/* d->tzoffset = 0;*/ /* d->tzoffset = 0;*/
@ -112,19 +118,21 @@ Client::Client(QObject *par) :QObject(par, "yahooclient" )
d->iconLoader = 0L; d->iconLoader = 0L;
d->loginTask = new LoginTask( d->root ); d->loginTask = new LoginTask( d->root );
d->listTask = new ListTask( d->root ); d->listTask = new ListTask( d->root );
d->pictureFlag = 0; d->pictureFlag = Yahoo::NoPicture;
d->buddyListReady = false;
m_connector = 0L; m_connector = 0L;
m_pingTimer = new QTimer( this ); m_pingTimer = new QTimer( this );
QObject::connect( m_pingTimer, SIGNAL( timeout() ), this, SLOT( sendPing() ) ); 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( 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& ) ) ); SLOT( slotLoginResponse( int, const QString& ) ) );
QObject::connect( d->loginTask, SIGNAL( haveCookies() ), SLOT( slotGotCookies() ) ); 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 &) ) ); 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 ) ) ); 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 ) 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->host = host;
d->port = port; d->port = port;
d->user = userId; 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( connected() ), this, SLOT( cs_connected() ) );
QObject::connect( d->stream, SIGNAL( error(int) ), this, SLOT( streamError(int) ) ); 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( readyRead() ), this, SLOT( streamReadyRead() ) );
QObject::connect( d->stream, SIGNAL( connectionClosed() ), this, SLOT( streamDisconnected() ) );
d->stream->connectToServer( host, false ); d->stream->connectToServer( host, false );
} }
@ -162,9 +171,9 @@ void Client::cancelConnect()
void Client::cs_connected() void Client::cs_connected()
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
emit connected(); 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->setStateOnConnect( (d->statusOnConnect == Yahoo::StatusInvisible) ? Yahoo::StatusInvisible : Yahoo::StatusAvailable );
d->loginTask->go(); d->loginTask->go();
@ -173,7 +182,7 @@ void Client::cs_connected()
void Client::close() void Client::close()
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
m_pingTimer->stop(); m_pingTimer->stop();
if( d->active ) if( d->active )
{ {
@ -181,7 +190,7 @@ void Client::close()
lt->go( true ); lt->go( true );
} }
if( d->tasksInitialized) if( d->tasksInitialized)
deleteTasks(); deleteTasks();
d->loginTask->reset(); d->loginTask->reset();
if( d->stream ) { if( d->stream ) {
QObject::disconnect( d->stream, SIGNAL( readyRead() ), this, SLOT( streamReadyRead() ) ); QObject::disconnect( d->stream, SIGNAL( readyRead() ), this, SLOT( streamReadyRead() ) );
@ -191,6 +200,8 @@ void Client::close()
if( m_connector ) if( m_connector )
m_connector->deleteLater(); m_connector->deleteLater();
m_connector = 0L; m_connector = 0L;
d->active = false;
d->buddyListReady = false;
} }
int Client::error() int Client::error()
@ -211,18 +222,18 @@ QString Client::errorInformation()
// SLOTS // // SLOTS //
void Client::streamError( int error ) 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; QString msg;
d->active = false; d->active = false;
// Examine error // 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->error = m_connector->errorCode();
d->errorString = KSocketBase::errorString( (KSocketBase::SocketError)d->error ); d->errorString = KSocketBase::errorString( (KSocketBase::SocketError)d->error );
} }
else else if( d->stream )
{ {
d->error = error; d->error = error;
d->errorString = d->stream->errorText(); d->errorString = d->stream->errorText();
@ -241,9 +252,15 @@ void Client::streamReadyRead()
distribute( transfer ); distribute( transfer );
} }
void Client::streamDisconnected()
{
d->active = false;
emit disconnected();
}
void Client::lt_loginFinished() 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() ); 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 ); changeStatus( d->statusOnConnect, d->statusMessageOnConnect, Yahoo::StatusTypeAway );
d->statusMessageOnConnect = QString::null; d->statusMessageOnConnect = QString::null;
setStatus( d->statusOnConnect ); 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(); initTasks();
} else { } else {
d->active = false; d->active = false;
close(); close();
} }
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Emitting loggedIn" << endl; kdDebug(YAHOO_RAW_DEBUG) << "Emitting loggedIn" << endl;
emit loggedIn( response, msg ); emit loggedIn( response, msg );
} }
void Client::lt_gotSessionID( uint id ) 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; d->sessionID = id;
} }
void Client::slotGotCookies() 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() << " T: " << d->loginTask->tCookie()
<< " C: " << d->loginTask->cCookie() << endl; << " C: " << d->loginTask->cCookie() << endl;
d->yCookie = d->loginTask->yCookie(); 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 ) 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 << " message: " << message
<< " type: " << type << endl; << " type: " << type << endl;
ChangeStatusTask *cst = new ChangeStatusTask( d->root ); ChangeStatusTask *cst = new ChangeStatusTask( d->root );
cst->setStatus( status ); cst->setStatus( status );
cst->setMessage( message ); cst->setMessage( message );
cst->setType( type ); cst->setType( type );
cst->go( true ); cst->go( true );
if( status == Yahoo::StatusInvisible ) if( status == Yahoo::StatusInvisible )
stealthContact( QString::null, Yahoo::StealthOnline, Yahoo::StealthClear ); stealthContact( QString(), Yahoo::StealthOnline, Yahoo::StealthClear );
setStatus( status ); setStatus( status );
} }
@ -416,10 +434,10 @@ void Client::sendPing()
{ {
if( !d->active ) 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; 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 ); PingTask *pt = new PingTask( d->root );
pt->go( true ); 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 ) void Client::addBuddy( const QString &userId, const QString &group, const QString &message )
{ {
ModifyBuddyTask *mbt = new ModifyBuddyTask( d->root ); 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->setType( ModifyBuddyTask::AddBuddy );
mbt->setTarget( userId ); mbt->setTarget( userId );
mbt->setGroup( group ); 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 ) void Client::removeBuddy( const QString &userId, const QString &group )
{ {
ModifyBuddyTask *mbt = new ModifyBuddyTask( d->root ); 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->setType( ModifyBuddyTask::RemoveBuddy );
mbt->setTarget( userId ); mbt->setTarget( userId );
mbt->setGroup( group ); 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 ) void Client::moveBuddy( const QString &userId, const QString &oldGroup, const QString &newGroup )
{ {
ModifyBuddyTask *mbt = new ModifyBuddyTask( d->root ); 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->setType( ModifyBuddyTask::MoveBuddy );
mbt->setTarget( userId ); mbt->setTarget( userId );
mbt->setOldGroup( oldGroup ); mbt->setOldGroup( oldGroup );
@ -466,8 +496,33 @@ void Client::moveBuddy( const QString &userId, const QString &oldGroup, const QS
// ***** Buddyicon handling ***** // ***** 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 ) void Client::requestPicture( const QString &userId )
{ {
if( !d->buddyListReady )
{
d->pictureRequestQueue << userId;
return;
}
RequestPictureTask *rpt = new RequestPictureTask( d->root ); RequestPictureTask *rpt = new RequestPictureTask( d->root );
rpt->setTarget( userId ); rpt->setTarget( userId );
rpt->go( true ); rpt->go( true );
@ -478,8 +533,8 @@ void Client::downloadPicture( const QString &userId, KURL url, int checksum )
if( !d->iconLoader ) if( !d->iconLoader )
{ {
d->iconLoader = new YahooBuddyIconLoader( this ); d->iconLoader = new YahooBuddyIconLoader( this );
QObject::connect( d->iconLoader, SIGNAL(fetchedBuddyIcon(const QString&, KTempFile*, int )), QObject::connect( d->iconLoader, SIGNAL(fetchedBuddyIcon(const QString&, const QByteArray &, int )),
SIGNAL(pictureDownloaded(const QString&, KTempFile*, int ) ) ); SIGNAL(pictureDownloaded(const QString&, const QByteArray &, int ) ) );
} }
d->iconLoader->fetchBuddyIcon( QString(userId), KURL(url), checksum ); 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 ) 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 ); SendPictureTask *spt = new SendPictureTask( d->root );
spt->setType( SendPictureTask::UploadPicture ); spt->setType( SendPictureTask::UploadPicture );
spt->setFilename( url.fileName() ); spt->setFilename( url.fileName() );
if ( url.isLocalFile() ) if ( url.isLocalFile() )
spt->setPath( url.path() ); spt->setPath( url.path() ); // FIXME: to test if is what we want
else else
spt->setPath( url.url() ); spt->setPath( url.url() );
d->pictureFlag = 2;
spt->go( true ); 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 ); SendPictureTask *spt = new SendPictureTask( d->root );
spt->setType( SendPictureTask::SendChecksum ); spt->setType( SendPictureTask::SendChecksum );
spt->setChecksum( checksum ); spt->setChecksum( checksum );
if( !who.isEmpty() ) if( !userId.isEmpty() )
spt->setTarget( who ); spt->setTarget( userId );
spt->go( true ); spt->go( true );
} }
void Client::sendPictureInformation( const QString &userId, const QString &url, int checksum ) 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 ); SendPictureTask *spt = new SendPictureTask( d->root );
spt->setType( SendPictureTask::SendInformation ); spt->setType( SendPictureTask::SendInformation );
spt->setChecksum( checksum ); spt->setChecksum( checksum );
@ -521,13 +575,16 @@ void Client::sendPictureInformation( const QString &userId, const QString &url,
spt->go( true ); 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 ); SendPictureTask *spt = new SendPictureTask( d->root );
spt->setType( SendPictureTask::SendStatus ); spt->setType( SendPictureTask::SendStatus );
spt->setStatus( type ); spt->setStatus( status );
spt->setTarget( userId );
spt->go( true ); spt->go( true );
} }
@ -624,10 +681,36 @@ void Client::deleteYABEntry( YABEntry &entry )
myt->go(true); 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 ***** // ***** other *****
void Client::notifyError( const QString &info, const QString & errorString, LogLevel level ) 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; .arg(info).arg(errorString).arg(level) << endl;
d->errorString = errorString; d->errorString = errorString;
d->errorInformation = info; d->errorInformation = info;
@ -675,12 +758,6 @@ QString Client::password()
return d->pass; return d->pass;
} }
QCString Client::ipAddress()
{
//TODO determine ip address
return "127.0.0.1";
}
QString Client::host() QString Client::host()
{ {
return d->host; return d->host;
@ -701,9 +778,14 @@ int Client::pictureFlag()
return d->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() QString Client::yCookie()
@ -723,7 +805,7 @@ QString Client::cCookie()
void Client::distribute( Transfer * transfer ) void Client::distribute( Transfer * transfer )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
if( !rootTask()->take( transfer ) ) if( !rootTask()->take( transfer ) )
kdDebug(YAHOO_RAW_DEBUG) << "CLIENT: root task refused transfer" << endl; kdDebug(YAHOO_RAW_DEBUG) << "CLIENT: root task refused transfer" << endl;
delete transfer; delete transfer;
@ -731,9 +813,9 @@ void Client::distribute( Transfer * transfer )
void Client::send( Transfer* request ) void Client::send( Transfer* request )
{ {
kdDebug(YAHOO_RAW_DEBUG) << "CLIENT::send()"<< endl; kdDebug(YAHOO_RAW_DEBUG) << "CLIENT::send()" << endl;
if( !d->stream ) if( !d->stream )
{ {
kdDebug(YAHOO_RAW_DEBUG) << "CLIENT - NO STREAM TO SEND ON!" << endl; kdDebug(YAHOO_RAW_DEBUG) << "CLIENT - NO STREAM TO SEND ON!" << endl;
return; return;
} }
@ -743,7 +825,7 @@ void Client::send( Transfer* request )
void Client::debug(const QString &str) void Client::debug(const QString &str)
{ {
qDebug( "CLIENT: %s", str.ascii() ); qDebug( "CLIENT: %s", str.ascii() );
} }
Task * Client::rootTask() Task * Client::rootTask()
@ -757,23 +839,21 @@ void Client::initTasks()
return; return;
d->statusTask = new StatusNotifierTask( d->root ); d->statusTask = new StatusNotifierTask( d->root );
QObject::connect( d->statusTask, SIGNAL( statusChanged( const QString&, int, const QString&, int, int ) ), QObject::connect( d->statusTask, SIGNAL( statusChanged(const QString&,int,const QString&,int,int,int) ),
SIGNAL( statusChanged( const QString&, int, const QString&, int, int ) ) ); SIGNAL( statusChanged(const QString&,int,const QString&,int,int,int) ) );
QObject::connect( d->statusTask, SIGNAL( stealthStatusChanged( const QString&, Yahoo::StealthStatus ) ), QObject::connect( d->statusTask, SIGNAL( stealthStatusChanged( const QString&, Yahoo::StealthStatus ) ),
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& ) ) ); 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& ) ) ); 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& ) ) ); 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 & ) ) ); 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 ); 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) ) ); SIGNAL( mailNotify(const QString&, const QString&, int) ) );
d->messageReceiverTask = new MessageReceiverTask( d->root ); d->messageReceiverTask = new MessageReceiverTask( d->root );
@ -797,8 +877,8 @@ void Client::initTasks()
SIGNAL( pictureInfoNotify( const QString &, KURL, int ) ) ); SIGNAL( pictureInfoNotify( const QString &, KURL, int ) ) );
QObject::connect( d->pictureNotifierTask, SIGNAL( pictureRequest( const QString & ) ), QObject::connect( d->pictureNotifierTask, SIGNAL( pictureRequest( const QString & ) ),
SIGNAL( pictureRequest( const QString & ) ) ); SIGNAL( pictureRequest( const QString & ) ) );
QObject::connect( d->pictureNotifierTask, SIGNAL( pictureUploaded( const QString & ) ), QObject::connect( d->pictureNotifierTask, SIGNAL( pictureUploaded( const QString &, int ) ),
SIGNAL( pictureUploaded( const QString & ) ) ); SIGNAL( pictureUploaded( const QString &, int ) ) );
d->webcamTask = new WebcamTask( d->root ); d->webcamTask = new WebcamTask( d->root );
QObject::connect( d->webcamTask, SIGNAL( webcamImageReceived( const QString &, const QPixmap &) ), QObject::connect( d->webcamTask, SIGNAL( webcamImageReceived( const QString &, const QPixmap &) ),
@ -839,10 +919,24 @@ void Client::initTasks()
SIGNAL( gotYABRevision( long, bool ) ) ); SIGNAL( gotYABRevision( long, bool ) ) );
d->fileTransferTask = new FileTransferNotifierTask( d->root ); d->fileTransferTask = new FileTransferNotifierTask( d->root );
QObject::connect( d->fileTransferTask, SIGNAL(incomingFileTransfer( const QString &, const QString &, QObject::connect( d->fileTransferTask, SIGNAL(incomingFileTransfer( const QString &, const QString &,
long, const QString &, const QString &, unsigned long )), long, const QString &, const QString &, unsigned long, const QPixmap & )),
SIGNAL(incomingFileTransfer( const QString &, const QString &, SIGNAL(incomingFileTransfer( const QString &, const QString &,
long, const QString &, const QString &, unsigned long )) ); 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() void Client::deleteTasks()
@ -864,6 +958,10 @@ void Client::deleteTasks()
d->yabTask = 0L; d->yabTask = 0L;
d->fileTransferTask->deleteLater(); d->fileTransferTask->deleteLater();
d->fileTransferTask = 0; d->fileTransferTask = 0;
d->yahooChatTask->deleteLater();
d->yahooChatTask = 0;
d->receiveFileTask->deleteLater();
d->receiveFileTask = 0;
} }
#include "client.moc" #include "client.moc"

@ -1,14 +1,14 @@
/* /*
Kopete Yahoo Protocol 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 Duncan Mac-Vicar P. <duncan@kde.org>
Copyright (c) 2004 Matt Rogers <matt.rogers@kdemail.net> Copyright (c) 2004 Matt Rogers <matt.rogers@kdemail.net>
Copyright (c) 2004 SuSE Linux AG <http://www.suse.com> 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> Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
************************************************************************* *************************************************************************
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
@ -23,77 +23,80 @@
#define LIBYAHOO_CLIENT_H #define LIBYAHOO_CLIENT_H
#include <qobject.h> #include <qobject.h>
#include <kurl.h>
#include "transfer.h" #include "transfer.h"
#include "yahootypes.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 QString;
class QTimer; class QTimer;
class QPixmap;
class QDomDocument;
class ClientStream; class ClientStream;
class KNetworkConnector; class KNetworkConnector;
class Task; class Task;
class KURL; class KTemporaryFile;
class KTempFile; struct YABEntry;
class YABEntry;
class SendFileTask;
class Client : public QObject class Client : public QObject
{ {
Q_OBJECT Q_OBJECT
public: 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(QObject *parent=0);
~Client(); ~Client();
/**
* Set the Yahoo Id of the account
* @param username The Yahoo Id
*/
void setUserId( const QString& userName ); 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. * Start a connection to the server using the supplied @ref ClientStream.
* This is only a transport layer connection. * This is only a transport layer connection.
* Needed for protocol action P1. * Needed for protocol action P1.
* @param s initialised client stream to use for the connection. * @param host The server to connect to.
* @param server the server to connect to - but this is also set on the connector used to construct the clientstream?? * @param port The port to be used. The Yahoo server allows connection on arbitrary ports.
* @param auth indicate whether we're connecting to the authorizer or the bos server * @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 ); void connect( const QString &host, const uint port, const QString &userId, const QString &pass );
/** /** Cancel active login attemps */
* Cancel active login attemps
*/
void cancelConnect(); void cancelConnect();
/** /** Logout and disconnect */
* Logout and disconnect
*/
void close(); void close();
/** /** Returns the errorcode */
* Returns the errorcode
*/
int error(); int error();
/** /** Returns a description of the error */
* Returns a description of the error
*/
QString errorString(); QString errorString();
/** /** Returns information about what went wrong */
* Returns information about what went wrong
*/
QString errorInformation(); QString errorInformation();
/** /**
* Specifies the status we connect with. * Specifies the status we connect with.
* The Yahoo protocol supports connecting into Online and Invisible state. * 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 * @param status the status to connect with
*/ */
void setStatusOnConnect( Yahoo::Status status ); void setStatusOnConnect( Yahoo::Status status );
@ -106,22 +109,9 @@ Q_OBJECT
*/ */
void setStatusMessageOnConnect( const QString &msg ); void setStatusMessageOnConnect( const QString &msg );
/** /** Accessors needed for login */
* Accessors needed for login
*/
QString host(); QString host();
int port(); 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 * Send a Typing notification
@ -129,7 +119,7 @@ Q_OBJECT
* @param typing true if there is typing activity, false if not * @param typing true if there is typing activity, false if not
*/ */
void sendTyping( const QString &to, bool typing ); void sendTyping( const QString &to, bool typing );
/** /**
* Send a Message * Send a Message
* @param to the buddy that should receive the message * @param to the buddy that should receive the message
@ -139,7 +129,7 @@ Q_OBJECT
/** /**
* Register / Unregister a chatsession * 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 * @param close if true, the chatsession will be closed, if false, it will be opened
*/ */
void setChatSessionState( const QString &to, bool close ); void setChatSessionState( const QString &to, bool close );
@ -155,7 +145,7 @@ Q_OBJECT
* @param status the status that will be set * @param status the status that will be set
* @param message the status message 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 * @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); void changeStatus(Yahoo::Status status, const QString &message, Yahoo::StatusType type);
/** /**
@ -175,200 +165,281 @@ Q_OBJECT
/** /**
* Remove a buddy from the contact list * 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 ); void removeBuddy( const QString &userId, const QString &group );
/** /**
* Move a buddy into another 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 ); void moveBuddy( const QString &userId, const QString &oldGroup, const QString &newGroup );
/** /**
* Change the stealth status of a buddy * 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 ); void stealthContact( QString const &userId, Yahoo::StealthMode mode, Yahoo::StealthStatus state );
/** /**
* Request the buddy's picture * Request the buddy's picture
* @param userId the yahoo ID of the buddy
*/ */
void requestPicture( const QString &userId ); void requestPicture( const QString &userId );
/** /**
* Download the buddy's picture * 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 ); void downloadPicture( const QString &userId, KURL url, int checksum );
/** /**
* Send our picture * Send our picture
* @param url the file that should be sent as our buddy picture
*/ */
void uploadPicture( KURL url ); void uploadPicture( KURL url );
/** /**
* Send checksum of our picture * 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 * 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 ); void sendPictureInformation( const QString &userId, const QString &url, int checksum );
/** /**
* Notify the buddies about our new status * 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 ) * Send a response to the webcam invite ( Accept / Decline )
* @param userId the yahoo ID of the sender
*/ */
void requestWebcam( const QString &userId ); void requestWebcam( const QString &userId );
/** /**
* Stop receiving of webcam * Stop receiving of webcam
* @param userId the yahoo ID of the sender
*/ */
void closeWebcam( const QString &userId ); void closeWebcam( const QString &userId );
/** /**
* Invite the user to view your Webcam * Invite the user to view your Webcam
* @param userId the yahoo ID of the receiver
*/ */
void sendWebcamInvite( const QString &userId ); void sendWebcamInvite( const QString &userId );
/** /**
* transmit a new image to the watchers * transmit a new image to the watchers
* @param image the image data
*/ */
void sendWebcamImage( const QByteArray &image ); void sendWebcamImage( const QByteArray &image );
/** /** Stop the webcam transmission */
* Stop transmission
*/
void closeOutgoingWebcam(); void closeOutgoingWebcam();
/** /**
* Allow a buddy to watch the cam * Allow a buddy to watch the cam
* @param userId the yahoo ID of the receiver
*/ */
void grantWebcamAccess( const QString &userId ); void grantWebcamAccess( const QString &userId );
/** /**
* Invite buddies to a conference * 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 ); void inviteConference( const QString &room, const QStringList &members, const QString &msg );
/** /**
* Invite buddies to a already existing conference * 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 ); void addInviteConference( const QString &room, const QStringList &who, const QStringList &members, const QString &msg );
/** /**
* Join a conference * 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 ); void joinConference( const QString &room, const QStringList &members );
/** /**
* Decline to join a conference * 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 ); void declineConference( const QString &room, const QStringList &members, const QString &msg );
/** /**
* Leave the conference * 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 ); void leaveConference( const QString &room, const QStringList &members );
/** /**
* Send a message to the conference * 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 ); void sendConferenceMessage( const QString &room, const QStringList &members, const QString &msg );
/** /**
* Send a authorization request response * 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 ); void sendAuthReply( const QString &userId, bool accept, const QString &msg );
/** /**
* Fetches all entries of the YAB * 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 ); void getYABEntries( long lastMerge, long lastRemoteRevision );
/** /**
* Saves a modified YAB entry * Saves a modified YAB entry
* @param entry the YAB entry
*/ */
void saveYABEntry( YABEntry &entry ); void saveYABEntry( YABEntry &entry );
/** /**
* Creates a new YAB entry * Creates a new YAB entry
* @param entry the YAB entry
*/ */
void addYABEntry( YABEntry &entry ); void addYABEntry( YABEntry &entry );
/** /**
* Deletes a YAB entry * Deletes a YAB entry
* @param entry the YAB entry
*/ */
void deleteYABEntry( YABEntry &entry ); void deleteYABEntry( YABEntry &entry );
/** /**
* Send a file to a buddy * 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 ); void sendFile( unsigned int transferId, const QString &userId, const QString &msg, KURL url );
/** /**
* Receive a file from a buddy * 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 ); void receiveFile( unsigned int transferId, const QString &userId, KURL remoteURL, KURL localURL );
/** /**
* Reject a file offered by a buddy * 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 ); 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 * Send an outgoing request to the server
* @param request the transfer to be sent
*/ */
void send( Transfer *request ); void send( Transfer *request );
/** /**
* Print a debug statement * Print a debug statement
*/ */
void debug( const QString &str ); void debug( const QString &str );
/** /** The current user's user ID */
* The current user's user ID
*/
QString userId(); QString userId();
/** /** The current user's password */
* The current user's password
*/
QString password(); QString password();
/** /** current Session ID */
* Host's IP address uint sessionID();
*/
QCString ipAddress();
/** /**
* 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(); Yahoo::Status status();
/** /**
* Set our 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(); Task* rootTask();
/** /**
@ -389,11 +460,11 @@ Q_OBJECT
*/ */
void loggedIn( int, const QString& ); void loggedIn( int, const QString& );
/** /**
* Notifies that the login process has failed * Notifies that the login process has failed
*/ */
void loginFailed(); void loginFailed();
/** /**
* Notifies tasks and account so they can react properly * Notifies tasks and account so they can react properly
*/ */
@ -412,10 +483,22 @@ Q_OBJECT
* Notifies about our buddies and groups * Notifies about our buddies and groups
*/ */
void gotBuddy( const QString &, const QString &, const QString & ); 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 * 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 * Notifies about the stealth status of buddies
*/ */
@ -459,7 +542,7 @@ Q_OBJECT
/** /**
* The iconLoader has successfully downloaded a picutre * 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 * A Buddy asks for our picture
*/ */
@ -467,7 +550,7 @@ Q_OBJECT
/** /**
* Information about the picture upload * Information about the picture upload
*/ */
void pictureUploaded( const QString & ); void pictureUploaded( const QString &, int );
/** /**
* We've received a webcam image from a buddy * We've received a webcam image from a buddy
*/ */
@ -545,7 +628,7 @@ Q_OBJECT
*/ */
void gotYABEntry( YABEntry * ); 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 & ); void modifyYABEntryError( YABEntry *, const QString & );
/** /**
@ -557,7 +640,7 @@ Q_OBJECT
*/ */
void fileTransferComplete( unsigned int ); void fileTransferComplete( unsigned int );
/** /**
* An error occured during the filetransfer * An error occurred during the filetransfer
*/ */
void fileTransferError( unsigned int, int, const QString & ); void fileTransferError( unsigned int, int, const QString & );
/** /**
@ -568,14 +651,39 @@ Q_OBJECT
* A buddy is trying to send us a file * A buddy is trying to send us a file
*/ */
void incomingFileTransfer( const QString &, const QString &, long, const QString &, 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: protected slots:
// INTERNAL, FOR USE BY TASKS' finished() SIGNALS // // INTERNAL, FOR USE BY TASKS' finished() SIGNALS //
void lt_loginFinished(); void lt_loginFinished();
void lt_gotSessionID( uint ); void lt_gotSessionID( uint );
void cs_connected(); void cs_connected();
void slotGotCookies(); void slotGotCookies();
void streamDisconnected();
/** /**
* Used by tasks to identify a response to a login attempt * 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. * Used by the client stream to notify errors to upper layers.
*/ */
void streamError( int error ); void streamError( int error );
/** /**
* The client stream has data ready to read. * The client stream has data ready to read.
*/ */
@ -595,16 +703,22 @@ Q_OBJECT
* Send a Yahoo Ping packet to the server * Send a Yahoo Ping packet to the server
*/ */
void sendPing(); void sendPing();
/**
* Send all queued buddy icon requests
*/
void processPictureQueue();
private: private:
void distribute( Transfer *transfer ); void distribute( Transfer *transfer );
/** /**
* create static tasks and connect their signals * create static tasks and connect their signals
*/ */
void initTasks(); void initTasks();
/** /**
* remove static tasks and their singal connections * remove static tasks and their signal connections
*/ */
void deleteTasks(); void deleteTasks();

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Handles conferences 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) ConferenceTask::ConferenceTask(Task* parent) : Task(parent)
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
} }
ConferenceTask::~ConferenceTask() ConferenceTask::~ConferenceTask()
@ -34,14 +34,12 @@ ConferenceTask::~ConferenceTask()
bool ConferenceTask::take( Transfer* transfer ) bool ConferenceTask::take( Transfer* transfer )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
if ( !forMe( transfer ) ) if ( !forMe( transfer ) )
return false; return false;
YMSGTransfer *t = 0L; YMSGTransfer *t = 0L;
t = static_cast<YMSGTransfer*>(transfer); t = static_cast<YMSGTransfer*>(transfer);
if( t->service() == Yahoo::ServiceConfInvite || if( t->service() == Yahoo::ServiceConfInvite ||
t->service() == Yahoo::ServiceConfAddInvite) t->service() == Yahoo::ServiceConfAddInvite)
parseInvitation( t ); parseInvitation( t );
@ -57,12 +55,10 @@ bool ConferenceTask::take( Transfer* transfer )
return true; return true;
} }
bool ConferenceTask::forMe( Transfer* transfer ) const bool ConferenceTask::forMe( const Transfer* transfer ) const
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; const YMSGTransfer *t = 0L;
t = dynamic_cast<const YMSGTransfer*>(transfer);
YMSGTransfer *t = 0L;
t = dynamic_cast<YMSGTransfer*>(transfer);
if (!t) if (!t)
return false; return false;
@ -71,7 +67,7 @@ bool ConferenceTask::forMe( Transfer* transfer ) const
t->service() == Yahoo::ServiceConfDecline || t->service() == Yahoo::ServiceConfDecline ||
t->service() == Yahoo::ServiceConfLogoff || t->service() == Yahoo::ServiceConfLogoff ||
t->service() == Yahoo::ServiceConfAddInvite || t->service() == Yahoo::ServiceConfAddInvite ||
t->service() == Yahoo::ServiceConfMsg ) t->service() == Yahoo::ServiceConfMsg )
return true; return true;
else else
return false; return false;
@ -79,8 +75,8 @@ bool ConferenceTask::forMe( Transfer* transfer ) const
void ConferenceTask::parseInvitation( YMSGTransfer *t ) void ConferenceTask::parseInvitation( YMSGTransfer *t )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
int i = 0; int i = 0;
QString who = t->firstParam( 50 ); QString who = t->firstParam( 50 );
QString room = t->firstParam( 57 ); QString room = t->firstParam( 57 );
@ -92,9 +88,9 @@ void ConferenceTask::parseInvitation( YMSGTransfer *t )
msg = t->firstParam( 58 ); msg = t->firstParam( 58 );
QStringList members; QStringList members;
for( i = 0; i < t->paramCount( 52 ); i++ ) for( i = 0; i < t->paramCount( 52 ); ++i )
members.append( t->nthParam( 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 ) ); members.append( t->nthParam( 53, i ) );
if( who == client()->userId() ) if( who == client()->userId() )
return; return;
@ -105,7 +101,7 @@ void ConferenceTask::parseInvitation( YMSGTransfer *t )
void ConferenceTask::parseMessage( YMSGTransfer *t ) void ConferenceTask::parseMessage( YMSGTransfer *t )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
QString room = t->firstParam( 57 ); QString room = t->firstParam( 57 );
QString from = t->firstParam( 3 ); QString from = t->firstParam( 3 );
@ -117,12 +113,12 @@ void ConferenceTask::parseMessage( YMSGTransfer *t )
msg = t->firstParam( 14 ); msg = t->firstParam( 14 );
if( !msg.isEmpty() ) if( !msg.isEmpty() )
emit gotMessage( from, room, msg ); emit gotMessage( from, room, msg );
} }
void ConferenceTask::parseUserJoined( YMSGTransfer *t ) void ConferenceTask::parseUserJoined( YMSGTransfer *t )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
QString room = t->firstParam( 57 ); QString room = t->firstParam( 57 );
QString who = t->firstParam( 53 ); QString who = t->firstParam( 53 );
@ -133,7 +129,7 @@ void ConferenceTask::parseUserJoined( YMSGTransfer *t )
void ConferenceTask::parseUserLeft( YMSGTransfer *t ) void ConferenceTask::parseUserLeft( YMSGTransfer *t )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
QString room = t->firstParam( 57 ); QString room = t->firstParam( 57 );
QString who = t->firstParam( 56 ); QString who = t->firstParam( 56 );
@ -144,7 +140,7 @@ void ConferenceTask::parseUserLeft( YMSGTransfer *t )
void ConferenceTask::parseUserDeclined( YMSGTransfer *t ) void ConferenceTask::parseUserDeclined( YMSGTransfer *t )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
QString room = t->firstParam( 57 ); QString room = t->firstParam( 57 );
QString who = t->firstParam( 54 ); 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 ) 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); YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceConfInvite);
t->setId( client()->sessionID() ); t->setId( client()->sessionID() );
@ -165,7 +161,7 @@ void ConferenceTask::inviteConference( const QString &room, const QStringList &m
t->setParam( 57, room.local8Bit() ); t->setParam( 57, room.local8Bit() );
t->setParam( 58, msg.local8Bit() ); t->setParam( 58, msg.local8Bit() );
t->setParam( 97, 1 ); 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( 52, (*it).local8Bit() );
t->setParam( 13, "0" ); 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 ) 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); YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceConfAddInvite);
t->setId( client()->sessionID() ); t->setId( client()->sessionID() );
t->setParam( 1, client()->userId().local8Bit() ); t->setParam( 1, client()->userId().local8Bit() );
QString whoList = who.first(); 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] ); whoList += QString(",%1").arg( who[i] );
t->setParam( 51, whoList.local8Bit() ); t->setParam( 51, whoList.local8Bit() );
t->setParam( 57, room.local8Bit() ); t->setParam( 57, room.local8Bit() );
t->setParam( 58, msg.local8Bit() ); t->setParam( 58, msg.local8Bit() );
t->setParam( 97, 1 ); 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( 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 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 ) 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); YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceConfLogon);
t->setId( client()->sessionID() ); t->setId( client()->sessionID() );
t->setParam( 1, client()->userId().local8Bit() ); 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( 3, (*it).local8Bit() );
t->setParam( 57, room.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 ) 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); YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceConfDecline);
t->setId( client()->sessionID() ); t->setId( client()->sessionID() );
t->setParam( 1, client()->userId().local8Bit() ); 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( 3, (*it).local8Bit() );
t->setParam( 57, room.local8Bit() ); t->setParam( 57, room.local8Bit() );
t->setParam( 14, msg.utf8() ); t->setParam( 14, msg.utf8() );
t->setParam( 97, 1 ); 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 ) 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); YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceConfLogoff);
t->setId( client()->sessionID() ); t->setId( client()->sessionID() );
t->setParam( 1, client()->userId().local8Bit() ); 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( 3, (*it).local8Bit() );
t->setParam( 57, room.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 ) 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); YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceConfMsg);
t->setId( client()->sessionID() ); t->setId( client()->sessionID() );
t->setParam( 1, client()->userId().local8Bit() ); 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( 53, (*it).local8Bit() );
t->setParam( 57, room.local8Bit() ); t->setParam( 57, room.local8Bit() );
t->setParam( 14, msg.utf8() ); t->setParam( 14, msg.utf8() );

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Handles conferences 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: public:
ConferenceTask(Task *parent); ConferenceTask(Task *parent);
~ConferenceTask(); ~ConferenceTask();
bool take(Transfer *transfer); bool take(Transfer *transfer);
bool forMe( Transfer* transfer ) const; bool forMe( const Transfer* transfer ) const;
void joinConference( const QString &room, const QStringList &members ); void joinConference( const QString &room, const QStringList &members );
void declineConference( const QString &room, const QStringList &members, const QString &msg ); void declineConference( const QString &room, const QStringList &members, const QString &msg );

@ -4,7 +4,7 @@
Copyright (c) 2004 Matt Rogers <matt.rogers@kdemail.net> 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> Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>

@ -4,7 +4,7 @@
Copyright (c) 2004 Matt Rogers <matt.rogers@kdemail.net> Copyright (c) 2004 Matt Rogers <matt.rogers@kdemail.net>
Based on code Copyright (c) 2004 SuSE Linux AG <http://www.suse.com> 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> Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>

@ -1,14 +1,14 @@
/* /*
Kopete Yahoo Protocol Kopete Yahoo Protocol
Copyright (c) 2004 Duncan Mac-Vicar P. <duncan@kde.org> 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) 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> Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
************************************************************************* *************************************************************************
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
@ -26,7 +26,6 @@
#include <qdatetime.h> #include <qdatetime.h>
#include <qtextstream.h> #include <qtextstream.h>
#include <kdebug.h> #include <kdebug.h>
#include <kurl.h> #include <kurl.h>
@ -39,7 +38,7 @@ CoreProtocol::CoreProtocol() : QObject()
m_YMSGProtocol = new YMSGProtocol( this, "ymsgprotocol" ); m_YMSGProtocol = new YMSGProtocol( this, "ymsgprotocol" );
} }
CoreProtocol::~CoreProtocol() CoreProtocol::~CoreProtocol()
{ {
} }
@ -52,60 +51,63 @@ void CoreProtocol::addIncomingData( const QByteArray & incomingBytes )
{ {
// store locally // store locally
int oldsize = m_in.size(); 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() ); m_in.resize( oldsize + incomingBytes.size() );
memcpy( m_in.data() + oldsize, incomingBytes.data(), incomingBytes.size() ); memcpy( m_in.data() + oldsize, incomingBytes.data(), incomingBytes.size() );
m_state = Available; m_state = Available;
// convert every event in the chunk to a Transfer, signalling it back to the clientstream // convert every event in the chunk to a Transfer, signalling it back to the clientstream
int parsedBytes = 0; int parsedBytes = 0;
int transferCount = 0; int transferCount = 0;
// while there is data left in the input buffer, and we are able to parse something out of it // 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) ) ) while ( m_in.size() && ( parsedBytes = wireToTransfer(m_in) ) )
{ {
transferCount++; 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(); int size = m_in.size();
if ( parsedBytes < 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 // copy the unparsed bytes into a new qbytearray and replace m_in with that
QByteArray remainder( size - parsedBytes ); QByteArray remainder( size - parsedBytes );
memcpy( remainder.data(), m_in.data() + parsedBytes, remainder.size() ); memcpy( remainder.data(), m_in.data() + parsedBytes, remainder.size() );
m_in = remainder; m_in = remainder;
} }
else else
m_in.truncate( 0 ); m_in.truncate( 0 );
} }
if ( m_state == NeedMore ) 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 ) 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..." ); 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 ); 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() Transfer* CoreProtocol::incomingTransfer()
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
if ( m_state == Available ) if ( m_state == Available )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " - got a transfer" << endl; // kdDebug(YAHOO_RAW_DEBUG) << " - got a transfer";
m_state = NoData; m_state = NoData;
return m_inTransfer; return m_inTransfer;
m_inTransfer = 0; m_inTransfer = 0;
} }
else else
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " no milk today" << endl; kdDebug(YAHOO_RAW_DEBUG) << " no milk today" << endl;
return 0; return 0;
} }
} }
@ -113,7 +115,7 @@ Transfer* CoreProtocol::incomingTransfer()
void cp_dump( const QByteArray &bytes ) void cp_dump( const QByteArray &bytes )
{ {
#ifdef YAHOO_COREPROTOCOL_DEBUG #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 ) for ( uint i = 0; i < bytes.count(); ++i )
{ {
printf( "%02x ", bytes[ i ] ); printf( "%02x ", bytes[ i ] );
@ -126,20 +128,20 @@ void cp_dump( const QByteArray &bytes )
void CoreProtocol::outgoingTransfer( Transfer* outgoing ) void CoreProtocol::outgoingTransfer( Transfer* outgoing )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
if ( outgoing->type() == Transfer::YMSGTransfer ) 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; YMSGTransfer *yt = (YMSGTransfer *) outgoing;
QByteArray bytesOut = yt->serialize(); QByteArray bytesOut = yt->serialize();
//QTextStream dout( bytesOut, IO_WriteOnly ); //QTextStream dout( bytesOut, QIODevice::WriteOnly );
//dout.setEncoding( QTextStream::Latin1 ); //dout.setEncoding( QTextStream::Latin1 );
//dout.setByteOrder( QDataStream::LittleEndian ); //dout.setByteOrder( QDataStream::LittleEndian );
//dout << bytesOut; //dout << bytesOut;
//kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " " << bytesOut << endl; //kdDebug(YAHOO_RAW_DEBUG) << " " << bytesOut;
emit outgoingData( bytesOut ); emit outgoingData( bytesOut );
// now convert // now convert
//fieldsToWire( fields ); //fieldsToWire( fields );
} }
delete outgoing; delete outgoing;
@ -149,53 +151,60 @@ void CoreProtocol::outgoingTransfer( Transfer* outgoing )
int CoreProtocol::wireToTransfer( const QByteArray& wire ) 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 // processing incoming data and reassembling it into transfers
// may be an event or a response // may be an event or a response
uint bytesParsed = 0; uint bytesParsed = 0;
if ( wire.size() < 20 ) // minimal value of a YMSG header if ( wire.size() < 20 ) // minimal value of a YMSG header
{ {
m_state = NeedMore; m_state = NeedMore;
return bytesParsed; 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 // look at first four bytes and decide what to do with the chunk
if ( okToProceed( din ) ) if ( okToProceed( din ) )
{ {
if ( (wire[0] == 'Y') && (wire[1] == 'M') && (wire[2] == 'S') && (wire[3] == 'G')) 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; // kdDebug(YAHOO_RAW_DEBUG) << " - looks like a valid YMSG packet";
Transfer *t = m_YMSGProtocol->parse( wire, bytesParsed ); YMSGTransfer *t = static_cast<YMSGTransfer *>(m_YMSGProtocol->parse( wire, bytesParsed ));
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " - YMSG Protocol parsed " << bytesParsed << " bytes" << endl; // kdDebug(YAHOO_RAW_DEBUG) << " - YMSG Protocol parsed " << bytesParsed << " bytes";
if ( t ) if ( t )
{ {
if( wire.size() < t->packetLength() )
{
m_state = NeedMore;
delete t;
return 0;
}
m_inTransfer = t; 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; m_state = Available;
emit incomingData(); emit incomingData();
} }
else else
bytesParsed = 0; bytesParsed = 0;
} }
else else
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " - not a valid YMSG packet. Trying to recover: " << wire << endl; kdDebug(YAHOO_RAW_DEBUG) << " - not a valid YMSG packet. Trying to recover." << endl;
QTextStream s( wire, IO_ReadOnly ); QTextStream s( wire, IO_ReadOnly );
QString remaining = s.read(); QString remaining = s.read();
int pos = remaining.find( "YMSG", bytesParsed ); int pos = remaining.find( "YMSG", bytesParsed );
if( pos >= 0 ) if( pos >= 0 )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Recover successful." << endl; kdDebug(YAHOO_RAW_DEBUG) << "Recover successful." << endl;
bytesParsed += pos; bytesParsed += pos;
} }
else else
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Recover failed. Dump it!" << endl; kdDebug(YAHOO_RAW_DEBUG) << "Recover failed. Dump it!" << endl;
bytesParsed = wire.size(); bytesParsed = wire.size();
} }
} }
@ -208,7 +217,7 @@ void CoreProtocol::reset()
m_in.resize( 0 ); m_in.resize( 0 );
} }
void CoreProtocol::slotOutgoingData( const QCString &out ) void CoreProtocol::slotOutgoingData( const QByteArray &out )
{ {
qDebug( "%s", out.data() ); qDebug( "%s", out.data() );
} }
@ -218,7 +227,7 @@ bool CoreProtocol::okToProceed( QDataStream &din)
if ( din.atEnd() ) if ( din.atEnd() )
{ {
m_state = NeedMore; m_state = NeedMore;
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " saved message prematurely" << endl; kdDebug(YAHOO_RAW_DEBUG) << " saved message prematurely" << endl;
return false; return false;
} }
else else

@ -1,14 +1,14 @@
/* /*
Kopete Yahoo Protocol Kopete Yahoo Protocol
Copyright (c) 2004 Duncan Mac-Vicar P. <duncan@kde.org> 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) 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> Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
************************************************************************* *************************************************************************
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
@ -22,9 +22,7 @@
#ifndef YAHOO_CORE_PROTOCOL_H #ifndef YAHOO_CORE_PROTOCOL_H
#define YAHOO_CORE_PROTOCOL_H #define YAHOO_CORE_PROTOCOL_H
#include <qcstring.h>
#include <qobject.h> #include <qobject.h>
#include <qptrlist.h>
class Transfer; class Transfer;
class YMSGProtocol; class YMSGProtocol;
@ -36,43 +34,43 @@ public:
enum State { NeedMore, Available, NoData, OutOfSync }; enum State { NeedMore, Available, NoData, OutOfSync };
CoreProtocol(); CoreProtocol();
virtual ~CoreProtocol(); virtual ~CoreProtocol();
/** /**
* Reset the protocol, clear buffers * Reset the protocol, clear buffers
*/ */
void reset(); void reset();
/** /**
* Accept data from the network, and buffer it into a useful message * Accept data from the network, and buffer it into a useful message
* This requires parsing out each FLAP, etc. from the incoming data * This requires parsing out each FLAP, etc. from the incoming data
* @param incomingBytes Raw data in wire format. * @param incomingBytes Raw data in wire format.
*/ */
void addIncomingData( const QByteArray& incomingBytes ); void addIncomingData( const QByteArray& incomingBytes );
/** /**
* @return the incoming transfer or 0 if none is available. * @return the incoming transfer or 0 if none is available.
*/ */
Transfer* incomingTransfer(); Transfer* incomingTransfer();
/** /**
* Convert a request into an outgoing transfer * Convert a request into an outgoing transfer
* emits @ref outgoingData() with each part of the transfer * emits @ref outgoingData() with each part of the transfer
*/ */
void outgoingTransfer( Transfer* outgoing ); void outgoingTransfer( Transfer* outgoing );
/** /**
* Get the state of the protocol * Get the state of the protocol
*/ */
int state(); int state();
signals: signals:
/** /**
* Emitted as the core protocol converts fields to wire ready data * Emitted as the core protocol converts fields to wire ready data
*/ */
void outgoingData( const QByteArray& ); void outgoingData( const QByteArray& );
/** /**
* Emitted when there is incoming data, parsed into a Transfer * 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 * 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: protected:
/** /**
* Check that there is data to read, and set the protocol's state if there isn't any. * 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 * Convert incoming wire data into a Transfer object and queue it
* @return number of bytes from the input that were parsed into a Transfer * @return number of bytes from the input that were parsed into a Transfer
*/ */
int wireToTransfer( const QByteArray& wire ); int wireToTransfer( const QByteArray& wire );
private: private:

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Notifies about incoming filetransfers 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 "ymsgtransfer.h"
#include "yahootypes.h" #include "yahootypes.h"
#include "client.h" #include "client.h"
#include <qstring.h> #include <qstring.h>
#include <qpixmap.h>
#include <kdebug.h> #include <kdebug.h>
//#include <kcodecs.h>
FileTransferNotifierTask::FileTransferNotifierTask(Task* parent) : Task(parent) FileTransferNotifierTask::FileTransferNotifierTask(Task* parent) : Task(parent)
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
} }
FileTransferNotifierTask::~FileTransferNotifierTask() FileTransferNotifierTask::~FileTransferNotifierTask()
@ -34,11 +37,9 @@ FileTransferNotifierTask::~FileTransferNotifierTask()
bool FileTransferNotifierTask::take( Transfer* transfer ) bool FileTransferNotifierTask::take( Transfer* transfer )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
if ( !forMe( transfer ) ) if ( !forMe( transfer ) )
return false; return false;
YMSGTransfer *t = static_cast<YMSGTransfer*>(transfer); YMSGTransfer *t = static_cast<YMSGTransfer*>(transfer);
if( t->service() == Yahoo::ServiceFileTransfer ) if( t->service() == Yahoo::ServiceFileTransfer )
@ -47,24 +48,24 @@ bool FileTransferNotifierTask::take( Transfer* transfer )
parseFileTransfer7( t ); parseFileTransfer7( t );
else if( t->service() == Yahoo::ServicePeerToPeer ) else if( t->service() == Yahoo::ServicePeerToPeer )
acceptFileTransfer( t ); acceptFileTransfer( t );
return true; return true;
} }
bool FileTransferNotifierTask::forMe( Transfer *transfer ) const bool FileTransferNotifierTask::forMe( const Transfer *transfer ) const
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; const YMSGTransfer *t = 0L;
YMSGTransfer *t = 0L; t = dynamic_cast<const YMSGTransfer*>(transfer);
t = dynamic_cast<YMSGTransfer*>(transfer);
if (!t) if (!t)
return false; return false;
if( t->service() == Yahoo::ServiceP2PFileXfer || if( t->service() == Yahoo::ServiceP2PFileXfer ||
t->service() == Yahoo::ServicePeerToPeer || t->service() == Yahoo::ServicePeerToPeer ||
t->service() == Yahoo::ServiceFileTransfer || t->service() == Yahoo::ServiceFileTransfer ||
t->service() == Yahoo::ServiceFileTransfer7 (t->service() == Yahoo::ServiceFileTransfer7 &&
t->firstParam(222).toInt() == 1)
) )
return true; return true;
else else
@ -73,7 +74,7 @@ bool FileTransferNotifierTask::forMe( Transfer *transfer ) const
void FileTransferNotifierTask::parseFileTransfer( YMSGTransfer *t ) void FileTransferNotifierTask::parseFileTransfer( YMSGTransfer *t )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
QString from; /* key = 4 */ QString from; /* key = 4 */
QString to; /* key = 5 */ QString to; /* key = 5 */
@ -97,22 +98,22 @@ void FileTransferNotifierTask::parseFileTransfer( YMSGTransfer *t )
{ {
client()->notifyError( "Fileupload result received.", msg, Client::Notice ); client()->notifyError( "Fileupload result received.", msg, Client::Notice );
return; return;
} }
if( url.isEmpty() ) if( url.isEmpty() )
return; return;
unsigned int left = url.findRev( '/' ) + 1; unsigned int left = url.findRev( '/' ) + 1;
unsigned int right = url.findRev( '?' ); unsigned int right = url.findRev( '?' );
filename = url.mid( left, right - left ); 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 ) void FileTransferNotifierTask::parseFileTransfer7( YMSGTransfer *t )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
QString from; /* key = 4 */ QString from; /* key = 4 */
QString to; /* key = 5 */ QString to; /* key = 5 */
@ -121,25 +122,35 @@ void FileTransferNotifierTask::parseFileTransfer7( YMSGTransfer *t )
QString msg; /* key = 14 */ QString msg; /* key = 14 */
QString filename; /* key = 27 */ QString filename; /* key = 27 */
unsigned long size; /* key = 28 */ unsigned long size; /* key = 28 */
QByteArray preview; /* key = 267 */
QPixmap previewPixmap;
if( t->firstParam( 222 ).toInt() == 2 ) if( t->firstParam( 222 ).toInt() == 2 )
return; // user cancelled the file transfer return; // user cancelled the file transfer
from = t->firstParam( 4 ); from = t->firstParam( 4 );
to = t->firstParam( 5 ); to = t->firstParam( 5 );
url = t->firstParam( 265 ); url = t->firstParam( 265 );
expires = t->firstParam( 38 ).toLong();
msg = t->firstParam( 14 ); msg = t->firstParam( 14 );
expires = t->firstParam( 38 ).toLong();
filename = t->firstParam( 27 ); filename = t->firstParam( 27 );
size = t->firstParam( 28 ).toULong(); 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 ) void FileTransferNotifierTask::acceptFileTransfer( YMSGTransfer *transfer )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServicePeerToPeer); YMSGTransfer *t = new YMSGTransfer(Yahoo::ServicePeerToPeer);
t->setId( client()->sessionID() ); t->setId( client()->sessionID() );
t->setParam( 4, client()->userId().local8Bit() ); t->setParam( 4, client()->userId().local8Bit() );

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Notifies about incoming filetransfers 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 QString;
class YMSGTransfer; class YMSGTransfer;
class QPixmap;
/** /**
@author André Duffeck @author André Duffeck
@ -36,10 +37,10 @@ public:
bool take(Transfer *transfer); bool take(Transfer *transfer);
protected: protected:
bool forMe( Transfer *transfer ) const; virtual bool forMe( const Transfer *transfer ) const;
signals: signals:
void incomingFileTransfer( const QString &who, const QString &url, long expires, const QString &msg , 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: private:
void parseFileTransfer( YMSGTransfer *transfer ); void parseFileTransfer( YMSGTransfer *transfer );
void parseFileTransfer7( YMSGTransfer *transfer ); void parseFileTransfer7( YMSGTransfer *transfer );

@ -18,6 +18,7 @@
#include "inputprotocolbase.h" #include "inputprotocolbase.h"
InputProtocolBase::InputProtocolBase(QObject *parent, const char *name) InputProtocolBase::InputProtocolBase(QObject *parent, const char *name)
: QObject(parent, name) : QObject(parent, name)
{ {
@ -59,6 +60,7 @@ bool InputProtocolBase::okToProceed()
return false; return false;
} }
// FIXME: need to be checked
bool InputProtocolBase::safeReadBytes( QCString & data, uint & len ) bool InputProtocolBase::safeReadBytes( QCString & data, uint & len )
{ {
// read the length of the bytes // 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, // the rest of the string will be filled with FF,
// so look for that in the last position instead of \0 // 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... // 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 ( (quint8)( * ( temp.data() + ( temp.length() - 1 ) ) ) == 0xFF )
if ( temp.length() < ( val - 1 ) ) 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 ); qDebug( "InputProtocol::safeReadBytes() - string broke, giving up, only got: %i bytes out of %i", temp.length(), val );
m_state = NeedMore; m_state = NeedMore;

@ -57,7 +57,7 @@ protected:
*/ */
bool okToProceed(); 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 * updates the bytes parsed counter
* @return false if the string was broken or there was no data available at all * @return false if the string was broken or there was no data available at all
*/ */
@ -66,7 +66,7 @@ protected:
protected: protected:
uint m_state; uint m_state;
uint m_bytes; uint m_bytes;
QDataStream * m_din; QDataStream *m_din;
}; };
#endif #endif

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Handles several lists such as buddylist, ignorelist and so on 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 <qstring.h>
#include <qstringlist.h>
#include "listtask.h" #include "listtask.h"
#include "transfer.h" #include "transfer.h"
#include "ymsgtransfer.h" #include "ymsgtransfer.h"
#include "client.h" #include "client.h"
#include <qstring.h>
#include <qstringlist.h>
#include <kdebug.h> #include <kdebug.h>
ListTask::ListTask(Task* parent) : Task(parent) ListTask::ListTask(Task* parent) : Task(parent)
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
} }
ListTask::~ListTask() ListTask::~ListTask()
@ -36,11 +35,9 @@ ListTask::~ListTask()
bool ListTask::take( Transfer* transfer ) bool ListTask::take( Transfer* transfer )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
if ( !forMe( transfer ) ) if ( !forMe( transfer ) )
return false; return false;
YMSGTransfer *t = static_cast<YMSGTransfer *>(transfer); YMSGTransfer *t = static_cast<YMSGTransfer *>(transfer);
parseBuddyList( t ); parseBuddyList( t );
@ -49,16 +46,15 @@ bool ListTask::take( Transfer* transfer )
return true; return true;
} }
bool ListTask::forMe( Transfer* transfer ) const bool ListTask::forMe( const Transfer* transfer ) const
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; const YMSGTransfer *t = 0L;
YMSGTransfer *t = 0L; t = dynamic_cast<const YMSGTransfer*>(transfer);
t = dynamic_cast<YMSGTransfer*>(transfer);
if (!t) if (!t)
return false; return false;
if ( t->service() == Yahoo::ServiceList ) if ( t->service() == Yahoo::ServiceBuddyList )
return true; return true;
else else
return false; return false;
@ -66,40 +62,49 @@ bool ListTask::forMe( Transfer* transfer ) const
void ListTask::parseBuddyList( YMSGTransfer *t ) void ListTask::parseBuddyList( YMSGTransfer *t )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
QString raw; QString group;
m_list.append( t->firstParam( 87 ) ); QString buddy;
// We need some low-level parsing here
if( t->firstParam( 59 ).isEmpty() )
return;
QStringList groups; // FIXME same: need to check
groups = QStringList::split( "\n", m_list ); //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); const Param &p = *it;
QStringList buddies;
buddies = QStringList::split( ",", (*groupIt).section(":", 1,1) ); kdDebug(YAHOO_RAW_DEBUG) << "1:" << p.first << endl;
for ( QStringList::Iterator buddyIt = buddies.begin(); buddyIt != buddies.end(); ++buddyIt ) kdDebug(YAHOO_RAW_DEBUG) << "2:" << p.second << endl;
switch( p.first )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Parsed buddy: " << *buddyIt << " in group " << group << endl; case 65:
emit gotBuddy( *buddyIt, QString::null, group ); 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 ) void ListTask::parseStealthList( YMSGTransfer *t )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
QString raw; QString raw;
raw = t->firstParam( 185 ); raw = t->firstParam( 185 );
QStringList buddies = QStringList::split( ",", raw ); const QStringList buddies = QStringList::split( ',', raw );
for ( QStringList::Iterator it = buddies.begin(); it != buddies.end(); ++it ) for ( QStringList::ConstIterator it = buddies.begin(); it != buddies.end(); ++it )
{ {
emit stealthStatusChanged( *it, Yahoo::StealthActive ); emit stealthStatusChanged( *it, Yahoo::StealthActive );
} }

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Handles several lists such as buddylist, ignorelist and so on 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: public:
ListTask(Task *parent); ListTask(Task *parent);
~ListTask(); ~ListTask();
bool take(Transfer *transfer); bool take(Transfer *transfer);
protected: protected:
bool forMe( Transfer *transfer ) const; virtual bool forMe( const Transfer *transfer ) const;
void parseBuddyList( YMSGTransfer *transfer ); void parseBuddyList( YMSGTransfer *transfer );
void parseStealthList( YMSGTransfer *transfer ); void parseStealthList( YMSGTransfer *transfer );
signals: signals:
void gotBuddy(const QString&, const QString&, const QString&); void gotBuddy(const QString&, const QString&, const QString&);
void stealthStatusChanged( const QString&, Yahoo::StealthStatus ); void stealthStatusChanged( const QString&, Yahoo::StealthStatus );
private:
QString m_list;
}; };
#endif #endif

@ -3,10 +3,10 @@
Handles logging into to the Yahoo service Handles logging into to the Yahoo service
Copyright (c) 2004 Duncan Mac-Vicar P. <duncan@kde.org> 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-2009 by the Kopete developers <kopete-devel@kde.org>
Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
************************************************************************* *************************************************************************
* * * *
@ -18,7 +18,7 @@
************************************************************************* *************************************************************************
*/ */
#include <qstring.h>
#include "logintask.h" #include "logintask.h"
#include "transfer.h" #include "transfer.h"
@ -28,6 +28,10 @@
#include <qstring.h> #include <qstring.h>
#include <kdebug.h> #include <kdebug.h>
#include <stdlib.h> #include <stdlib.h>
#include <kio/job.h>
#include <kmdcodec.h>
extern "C" extern "C"
{ {
#include "libyahoo.h" #include "libyahoo.h"
@ -35,7 +39,7 @@ extern "C"
LoginTask::LoginTask(Task* parent) : Task(parent) LoginTask::LoginTask(Task* parent) : Task(parent)
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
mState = InitialState; mState = InitialState;
} }
@ -46,10 +50,9 @@ LoginTask::~LoginTask()
bool LoginTask::take(Transfer* transfer) bool LoginTask::take(Transfer* transfer)
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
/* /*
Yahoo login task has various stages Yahoo login task has various stages
1 .- Initial State 1 .- Initial State
1.1 .- OnGo is called 1.1 .- OnGo is called
1.2 .- SendVerify() - send a service verify ack 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 2.3 - Need to decode and send a transfer back
4.- SentAuthResp 4.- SentAuthResp
*/ */
if ( !forMe( transfer ) ) if ( !forMe( transfer ) )
return false; return false;
YMSGTransfer *t = static_cast<YMSGTransfer *>(transfer); YMSGTransfer *t = static_cast<YMSGTransfer *>(transfer);
if ( t->service() == Yahoo::ServicePing) {
emit buddyListReady();
return true;
}
switch (mState) switch (mState)
{ {
case (InitialState): 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; const YMSGTransfer *t = 0L;
YMSGTransfer *t = 0L; t = dynamic_cast<const YMSGTransfer*>(transfer);
t = dynamic_cast<YMSGTransfer*>(transfer);
if (!t) if (!t)
return false; return false;
if ( t->service() == Yahoo::ServicePing)
return true;
switch (mState) switch (mState)
{ {
case (InitialState): case (InitialState):
@ -128,12 +139,12 @@ bool LoginTask::forMe(Transfer* transfer) const
void LoginTask::onGo() void LoginTask::onGo()
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
/* initial state, we have to send a ServiceVerify */ /* initial state, we have to send a ServiceVerify */
if (mState == InitialState) if (mState == InitialState)
sendVerify(); sendVerify();
else 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() void LoginTask::reset()
@ -144,20 +155,20 @@ void LoginTask::reset()
void LoginTask::sendVerify() void LoginTask::sendVerify()
{ {
/* send a ServiceVerify */ /* send a ServiceVerify */
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceVerify); YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceVerify);
send( t ); send( t );
mState = SentVerify; mState = SentVerify;
} }
void LoginTask::sendAuth(YMSGTransfer* transfer) 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. // transfer is the verify ack transfer, no useful data in it.
Q_UNUSED(transfer); Q_UNUSED(transfer);
/* got ServiceVerify ACK, send a ServiceAuth with username */ /* 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 ); YMSGTransfer *t = new YMSGTransfer( Yahoo::ServiceAuth );
t->setParam( 1 , client()->userId().local8Bit() ); t->setParam( 1 , client()->userId().local8Bit() );
send(t); send(t);
@ -166,76 +177,225 @@ void LoginTask::sendAuth(YMSGTransfer* transfer)
void LoginTask::sendAuthResp(YMSGTransfer* t) void LoginTask::sendAuthResp(YMSGTransfer* t)
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
QString sn = t->firstParam( 1 ); QString sn = t->firstParam( 1 );
QString seed = t->firstParam( 94 ); QString seed = t->firstParam( 94 );
m_challengeString = seed;
QString version_s = t->firstParam( 13 ); QString version_s = t->firstParam( 13 );
uint sessionID = t->id(); m_sessionID = t->id();
int version = version_s.toInt(); int version = version_s.toInt();
switch (version) switch (version)
{ {
case 0: case 0:
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Version pre 0x0b "<< version_s << endl; case 1:
break; case 2:
kdDebug(YAHOO_RAW_DEBUG) << "Using version 16 authorization" << endl;
sendAuthSixteenStage1(sn, seed);
break;
default: default:
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Version 0x0b "<< version_s << endl; kdDebug(YAHOO_RAW_DEBUG) << "Unknown authentication method used!"
sendAuthResp_0x0b(sn, seed, sessionID); << "Attempting current authentication anyways" << endl;
sendAuthSixteenStage1(sn, seed);
break; break;
} }
mState = SentAuthResp; 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; const QString YahooTokenUrl = "https://login.yahoo.com/config/pwtoken_get?src=ymsgr&ts=&login=%1&passwd=%2&chal=%3";
char *resp_6 = (char *) malloc(100); kdDebug(YAHOO_RAW_DEBUG) << "seed:" << seed << endl;
char *resp_96 = (char *) malloc(100); m_stage1Data= QString::null;
authresp_0x0b(seed.latin1(), sn.latin1(), (client()->password()).latin1(), resp_6, resp_96); /* construct a URL from the seed and request tokens */
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "resp_6: " << resp_6 << " resp_69: " << resp_96 << endl; QByteArray encodedUrl;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceAuthResp, m_stateOnConnect); QString fullUrl = YahooTokenUrl.arg(sn, client()->password(), seed);
t->setId( sessionID ); KURL tokenUrl(fullUrl);
t->setParam( 0 , sn.local8Bit()); KIO::Job* job = KIO::get(tokenUrl, true, false);
t->setParam( 6 , resp_6); connect(job, SIGNAL(data(KIO::Job*, const QByteArray&)),
t->setParam( 96 , resp_96); this, SLOT(handleAuthSixteenStage1Data(KIO::Job*, const QByteArray&)));
t->setParam( 59 , "B\\tfckeert1kk1nl&b=2" ); // ??? connect(job, SIGNAL(result(KIO::Job*)),
t->setParam( 135 , "7,0,0,437" ); // Client version this, SLOT(handleAuthSixteenStage1Result(KIO::Job*)));
t->setParam( 148 , -60 ); }
t->setParam( 244 , 524223 );
t->setParam( 1 , sn.local8Bit()); void LoginTask::handleAuthSixteenStage1Data(KIO::Job* job, const QByteArray& data)
{
if( !m_verificationWord.isEmpty() ) 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() ); QStringList responses = QStringList::split("\r\n", m_stage2Data);
m_verificationWord = QString::null; 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); send(t);
} }
void LoginTask::sendAuthResp_pre_0x0b(const QString &/*sn*/, const QString &/*seed*/) 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) void LoginTask::handleAuthResp(YMSGTransfer *t)
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
switch( t->service() ) switch( t->service() )
{ {
case( Yahoo::ServiceList ): case( Yahoo::ServiceList ):
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Emitting Signal" << endl; kdDebug(YAHOO_RAW_DEBUG) << "Emitting Signal" << endl;
emit loginResponse( Yahoo::LoginOk, QString::null ); emit loginResponse( Yahoo::LoginOk, QString() );
break; break;
case( Yahoo::ServiceAuthResp ): 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 ) ); emit loginResponse( t->firstParam( 66 ).toInt(), t->firstParam( 20 ) );
break; break;
default: default:
@ -251,10 +411,10 @@ void LoginTask::setStateOnConnect( Yahoo::Status status )
void LoginTask::parseCookies( YMSGTransfer *t ) 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) for( int i = 0; i < t->paramCount( 59 ); ++i)
{ {
QString cookie; QString cookie;
cookie = t->nthParam( 59, i ); cookie = t->nthParam( 59, i );
if( cookie.startsWith( "Y" ) ) if( cookie.startsWith( "Y" ) )
@ -271,8 +431,7 @@ void LoginTask::parseCookies( YMSGTransfer *t )
m_cCookie = getcookie( cookie.latin1() ); m_cCookie = getcookie( cookie.latin1() );
} }
} }
if( !m_yCookie.isEmpty() && !m_tCookie.isEmpty() && if( !m_yCookie.isEmpty() && !m_tCookie.isEmpty())
!m_cCookie.isEmpty() )
emit haveCookies(); emit haveCookies();
} }

@ -4,7 +4,7 @@
Copyright (c) 2004 Duncan Mac-Vicar P. <duncan@kde.org> 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> Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
@ -27,6 +27,11 @@
class QString; class QString;
class YMSGTransfer; class YMSGTransfer;
namespace KIO
{
class Job;
}
/** /**
@author Duncan Mac-Vicar @author Duncan Mac-Vicar
*/ */
@ -36,7 +41,7 @@ Q_OBJECT
public: public:
LoginTask(Task *parent); LoginTask(Task *parent);
~LoginTask(); ~LoginTask();
bool take(Transfer* transfer); bool take(Transfer* transfer);
virtual void onGo(); virtual void onGo();
@ -49,7 +54,7 @@ public:
const QString &tCookie(); const QString &tCookie();
const QString &loginCookie(); const QString &loginCookie();
protected: protected:
bool forMe( Transfer* transfer ) const; virtual bool forMe( const Transfer* transfer ) const;
enum State { InitialState, SentVerify, GotVerifyACK, SentAuth, GotAuthACK, SentAuthResp }; enum State { InitialState, SentVerify, GotVerifyACK, SentAuth, GotAuthACK, SentAuthResp };
void sendVerify(); void sendVerify();
void sendAuth(YMSGTransfer* transfer); void sendAuth(YMSGTransfer* transfer);
@ -58,10 +63,20 @@ protected:
void sendAuthResp_pre_0x0b(const QString &sn, const QString &seed); void sendAuthResp_pre_0x0b(const QString &sn, const QString &seed);
void handleAuthResp(YMSGTransfer *transfer); void handleAuthResp(YMSGTransfer *transfer);
void parseCookies( 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: signals:
void haveSessionID( uint ); void haveSessionID( uint );
void haveCookies(); void haveCookies();
void loginResponse( int, const QString& ); void loginResponse( int, const QString& );
void buddyListReady();
private: private:
State mState; State mState;
Yahoo::Status m_stateOnConnect; Yahoo::Status m_stateOnConnect;
@ -70,6 +85,10 @@ private:
QString m_cCookie; QString m_cCookie;
QString m_loginCookie; QString m_loginCookie;
QString m_verificationWord; QString m_verificationWord;
QString m_stage1Data;
QString m_stage2Data;
QString m_challengeString;
uint m_sessionID;
}; };
#endif #endif

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Log off the Yahoo server 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) LogoffTask::LogoffTask(Task* parent) : Task(parent)
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
} }
LogoffTask::~LogoffTask() LogoffTask::~LogoffTask()
@ -33,11 +33,11 @@ LogoffTask::~LogoffTask()
void LogoffTask::onGo() void LogoffTask::onGo()
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceLogoff); YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceLogoff);
t->setId( client()->sessionID() ); t->setId( client()->sessionID() );
send( t ); send( t );
setSuccess( true ); setSuccess();
} }

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Log off the Yahoo server 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" #include "task.h"
class QString;
/** /**
@author André Duffeck @author André Duffeck

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Notifies about new mails 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 "ymsgtransfer.h"
#include "yahootypes.h" #include "yahootypes.h"
#include "client.h" #include "client.h"
#include <qstring.h>
#include <kdebug.h> #include <kdebug.h>
MailNotifierTask::MailNotifierTask(Task* parent) : Task(parent) MailNotifierTask::MailNotifierTask(Task* parent) : Task(parent)
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
} }
MailNotifierTask::~MailNotifierTask() MailNotifierTask::~MailNotifierTask()
@ -36,8 +35,6 @@ MailNotifierTask::~MailNotifierTask()
bool MailNotifierTask::take( Transfer* transfer ) bool MailNotifierTask::take( Transfer* transfer )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
if ( !forMe( transfer ) ) if ( !forMe( transfer ) )
return false; return false;
@ -48,11 +45,10 @@ bool MailNotifierTask::take( Transfer* transfer )
return true; return true;
} }
bool MailNotifierTask::forMe( Transfer* transfer ) const bool MailNotifierTask::forMe( const Transfer* transfer ) const
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; const YMSGTransfer *t = 0L;
YMSGTransfer *t = 0L; t = dynamic_cast<const YMSGTransfer*>(transfer);
t = dynamic_cast<YMSGTransfer*>(transfer);
if (!t) if (!t)
return false; return false;
@ -64,7 +60,7 @@ bool MailNotifierTask::forMe( Transfer* transfer ) const
void MailNotifierTask::parseMail( YMSGTransfer *t ) void MailNotifierTask::parseMail( YMSGTransfer *t )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
QString count = t->firstParam( 9 ); QString count = t->firstParam( 9 );
QString mail = t->firstParam( 42 ); QString mail = t->firstParam( 42 );
@ -74,7 +70,7 @@ void MailNotifierTask::parseMail( YMSGTransfer *t )
if( !mail.isEmpty() && !from.isEmpty() && !subject.isEmpty() ) if( !mail.isEmpty() && !from.isEmpty() && !subject.isEmpty() )
emit mailNotify( QString::fromLatin1( "%1 <%2>").arg( from, mail ), subject, count.toInt() ); emit mailNotify( QString::fromLatin1( "%1 <%2>").arg( from, mail ), subject, count.toInt() );
else else
emit mailNotify( QString::null, QString::null, count.toInt()); emit mailNotify( QString(), QString(), count.toInt());
} }
#include "mailnotifiertask.moc" #include "mailnotifiertask.moc"

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Notifies about new mails 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); bool take(Transfer *transfer);
protected: protected:
bool forMe( Transfer *transfer ) const; virtual bool forMe( const Transfer *transfer ) const;
void parseMail( YMSGTransfer *transfer ); void parseMail( YMSGTransfer *transfer );
signals: signals:
void mailNotify(const QString&, const QString&, int); void mailNotify(const QString&, const QString&, int);

@ -37,9 +37,7 @@
1999-05-03 lpd Original version. 1999-05-03 lpd Original version.
*/ */
#if HAVE_CONFIG_H #include "../../../../config.h"
# include <config.h>
#endif
#include "md5.h" #include "md5.h"

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Receive Messages 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 "ymsgtransfer.h"
#include "yahootypes.h" #include "yahootypes.h"
#include "client.h" #include "client.h"
#include <qstring.h>
#include <kdebug.h> #include <kdebug.h>
MessageReceiverTask::MessageReceiverTask(Task* parent) : Task(parent) MessageReceiverTask::MessageReceiverTask(Task* parent) : Task(parent)
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
} }
MessageReceiverTask::~MessageReceiverTask() MessageReceiverTask::~MessageReceiverTask()
@ -35,8 +34,6 @@ MessageReceiverTask::~MessageReceiverTask()
bool MessageReceiverTask::take( Transfer* transfer ) bool MessageReceiverTask::take( Transfer* transfer )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
if ( !forMe( transfer ) ) if ( !forMe( transfer ) )
return false; return false;
@ -44,7 +41,7 @@ bool MessageReceiverTask::take( Transfer* transfer )
t = dynamic_cast<YMSGTransfer*>(transfer); t = dynamic_cast<YMSGTransfer*>(transfer);
if (!t) if (!t)
return false; return false;
if( t->service() == Yahoo::ServiceNotify ) if( t->service() == Yahoo::ServiceNotify )
parseNotify( t ); parseNotify( t );
else else
@ -53,19 +50,17 @@ bool MessageReceiverTask::take( Transfer* transfer )
return true; return true;
} }
bool MessageReceiverTask::forMe( Transfer* transfer ) const bool MessageReceiverTask::forMe( const Transfer* transfer ) const
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; const YMSGTransfer *t = 0L;
t = dynamic_cast<const YMSGTransfer*>(transfer);
YMSGTransfer *t = 0L;
t = dynamic_cast<YMSGTransfer*>(transfer);
if (!t) if (!t)
return false; return false;
if ( t->service() == Yahoo::ServiceMessage || if ( t->service() == Yahoo::ServiceMessage ||
t->service() == Yahoo::ServiceGameMsg || t->service() == Yahoo::ServiceGameMsg ||
t->service() == Yahoo::ServiceSysMessage || t->service() == Yahoo::ServiceSysMessage ||
t->service() == Yahoo::ServiceNotify ) t->service() == Yahoo::ServiceNotify )
return true; return true;
else else
return false; return false;
@ -73,7 +68,7 @@ bool MessageReceiverTask::forMe( Transfer* transfer ) const
void MessageReceiverTask::parseMessage( YMSGTransfer *t ) void MessageReceiverTask::parseMessage( YMSGTransfer *t )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
int cnt = t->paramCount( 5 ); int cnt = t->paramCount( 5 );
for( int i = 0; i < cnt; ++i ) 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 // 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 ) if( cnt == 1 )
from = t->firstParam( 1 ).isEmpty() ? t->firstParam( 4 ) : t->firstParam( 1 ); from = t->firstParam( 1 ).isEmpty() ? t->firstParam( 4 ) : t->firstParam( 1 );
if( !sysmsg.isEmpty() ) if( !sysmsg.isEmpty() )
{ {
client()->notifyError( "Server message received: ", sysmsg, Client::Error ); client()->notifyError( "Server message received: ", sysmsg, Client::Error );
continue; continue;
} }
if( msg.isEmpty() ) 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; continue;
} }
if( utf8.startsWith( "1" ) ) if( utf8.startsWith( "1" ) )
msg = QString::fromUtf8( msg.latin1() ); msg = QString::fromUtf8( msg.latin1() );
if( t->service() == Yahoo::ServiceSysMessage ) if( t->service() == Yahoo::ServiceSysMessage )
emit systemMessage( sysmsg ); emit systemMessage( sysmsg );
else else
{ {
if( msg.startsWith( "<ding>" ) ) if( msg.startsWith( "<ding>" ) )
emit gotBuzz( from, timestamp.toLong() ); emit gotBuzz( from, timestamp.toLong() );
else else
@ -119,7 +114,7 @@ void MessageReceiverTask::parseMessage( YMSGTransfer *t )
void MessageReceiverTask::parseNotify( YMSGTransfer *t ) void MessageReceiverTask::parseNotify( YMSGTransfer *t )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
QString from = t->firstParam( 4 ); QString from = t->firstParam( 4 );
//QString to = t->firstParam( 5 ); //QString to = t->firstParam( 5 );
@ -135,12 +130,12 @@ void MessageReceiverTask::parseNotify( YMSGTransfer *t )
{ {
if( ind.startsWith(" ") ) if( ind.startsWith(" ") )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Got a WebcamInvitation." << endl; kdDebug(YAHOO_RAW_DEBUG) << "Got a WebcamInvitation." << endl;
emit gotWebcamInvite( from ); emit gotWebcamInvite( from );
} }
else 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;
} }
} }
} }

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Receive Messages 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); bool take(Transfer *transfer);
protected: protected:
bool forMe( Transfer *transfer ) const; virtual bool forMe( const Transfer *transfer ) const;
void parseMessage( YMSGTransfer *transfer ); void parseMessage( YMSGTransfer *transfer );
void parseNotify( YMSGTransfer *transfer ); void parseNotify( YMSGTransfer *transfer );
signals: signals:

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Add a buddy to the Contactlist 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 "ymsgtransfer.h"
#include "yahootypes.h" #include "yahootypes.h"
#include "client.h" #include "client.h"
#include <qstring.h>
#include <kdebug.h> #include <kdebug.h>
ModifyBuddyTask::ModifyBuddyTask(Task* parent) : Task(parent) ModifyBuddyTask::ModifyBuddyTask(Task* parent) : Task(parent)
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
} }
ModifyBuddyTask::~ModifyBuddyTask() 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() void ModifyBuddyTask::onGo()
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
switch( m_type ) switch( m_type )
{ {
@ -47,31 +96,31 @@ void ModifyBuddyTask::onGo()
moveBuddy(); moveBuddy();
break; break;
} }
setSuccess( true );
} }
void ModifyBuddyTask::addBuddy() void ModifyBuddyTask::addBuddy()
{ {
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceAddBuddy); YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceBuddyAdd);
t->setId( client()->sessionID() ); t->setId( client()->sessionID() );
t->setParam( 65, m_group.local8Bit() );
t->setParam( 97, 1 ); // UTF-8
t->setParam( 1, client()->userId().local8Bit() ); t->setParam( 1, client()->userId().local8Bit() );
t->setParam( 7, m_target.local8Bit() ); t->setParam( 302, 319 );
t->setParam( 14, m_message.utf8() ); t->setParam( 300, 319 );
t->setParam( 65, m_group.local8Bit() ); t->setParam( 7, m_target.local8Bit() );
t->setParam( 97, 1 ); // UTF-8 t->setParam( 334, 0 );
t->setParam( 301, 319 );
t->setParam( 303, 319 );
send( t ); send( t );
} }
void ModifyBuddyTask::removeBuddy() void ModifyBuddyTask::removeBuddy()
{ {
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceRemBuddy); YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceBuddyRemove);
t->setId( client()->sessionID() ); t->setId( client()->sessionID() );
t->setParam( 1, client()->userId().local8Bit() ); t->setParam( 1, client()->userId().local8Bit() );
t->setParam( 7, m_target.local8Bit() ); t->setParam( 7, m_target.local8Bit() );
t->setParam( 65, m_group.local8Bit() ); t->setParam( 65, m_group.local8Bit() );
send( t ); send( t );
} }
@ -114,3 +163,5 @@ void ModifyBuddyTask::setType( Type type )
{ {
m_type = type; m_type = type;
} }
#include "modifybuddytask.moc"

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Add, remove or move a buddy to the Contactlist 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 class ModifyBuddyTask : public Task
{ {
Q_OBJECT
public: public:
enum Type { AddBuddy, RemoveBuddy, MoveBuddy }; enum Type { AddBuddy, RemoveBuddy, MoveBuddy };
ModifyBuddyTask(Task *parent); ModifyBuddyTask(Task *parent);
@ -33,11 +34,22 @@ public:
virtual void onGo(); virtual void onGo();
bool take(Transfer *transfer);
void setType( Type type ); void setType( Type type );
void setMessage( const QString &text ); void setMessage( const QString &text );
void setTarget( const QString &target ); void setTarget( const QString &target );
void setGroup( const QString &group ); void setGroup( const QString &group );
void setOldGroup( 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: private:
void addBuddy(); void addBuddy();
void removeBuddy(); void removeBuddy();

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
modifyyabtask.h - Handles the Yahoo Address Book 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> Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
************************************************************************* *************************************************************************
@ -33,7 +33,7 @@
using namespace KNetwork; using namespace KNetwork;
ModifyYABTask::ModifyYABTask(Task* parent) : Task(parent) ModifyYABTask::ModifyYABTask(Task* parent) : Task(parent)
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
m_socket = 0; m_socket = 0;
} }
@ -44,7 +44,7 @@ ModifyYABTask::~ModifyYABTask()
void ModifyYABTask::onGo() void ModifyYABTask::onGo()
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
m_socket = new KBufferedSocket( "address.yahoo.com", QString::number(80) ); m_socket = new KBufferedSocket( "address.yahoo.com", QString::number(80) );
connect( m_socket, SIGNAL( connected( const KResolverEntry& ) ), this, SLOT( connectSucceeded() ) ); connect( m_socket, SIGNAL( connected( const KResolverEntry& ) ), this, SLOT( connectSucceeded() ) );
connect( m_socket, SIGNAL( gotError(int) ), this, SLOT( connectFailed(int) ) ); 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( "k", client()->userId() );
root.setAttribute( "cc", "1" ); root.setAttribute( "cc", "1" );
doc.appendChild( root ); doc.appendChild( root );
QDomElement contact = doc.createElement( "ct" ); QDomElement contact = doc.createElement( "ct" );
entry.fillQDomElement( contact ); entry.fillQDomElement( contact );
switch( m_action ) switch( m_action )
@ -90,13 +90,14 @@ void ModifyYABTask::setEntry( const YABEntry &entry )
void ModifyYABTask::connectFailed( int i) void ModifyYABTask::connectFailed( int i)
{ {
m_socket->close(); 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 ); QString( "%1 - %2").arg(i).arg(static_cast<const KBufferedSocket*>( sender() )->errorString()), Client::Error );
} }
void ModifyYABTask::connectSucceeded() 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" 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" "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 ); QDataStream stream( buffer, IO_WriteOnly );
stream.writeRawBytes( header.local8Bit(), header.length() ); stream.writeRawBytes( header.local8Bit(), header.length() );
stream.writeRawBytes( m_postData.utf8(), m_postData.utf8().size() ); stream.writeRawBytes( m_postData.utf8(), m_postData.utf8().size() );
if( m_socket->writeBlock( buffer, buffer.size() ) ) if( socket->writeBlock( buffer, buffer.size() ) )
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Upload Successful. Waiting for confirmation..." << endl; kdDebug(YAHOO_RAW_DEBUG) << "Upload Successful. Waiting for confirmation..." << endl;
else else
{ {
client()->notifyError( i18n( "An error occured saving the Addressbook entry." ), m_socket->errorString(), Client::Error ); client()->notifyError( i18n( "An error occurred while saving the address book entry." ), m_socket->errorString(), Client::Error );
setSuccess( false ); setError();
return; return;
} }
connect( m_socket, SIGNAL( readyRead() ), this, SLOT( slotRead() ) ); connect( m_socket, SIGNAL( readyRead() ), this, SLOT( slotRead() ) );
} }
void ModifyYABTask::slotRead() void ModifyYABTask::slotRead()
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; KBufferedSocket* socket = const_cast<KBufferedSocket*>( static_cast<const KBufferedSocket*>( sender() ) );
QByteArray ar( m_socket->bytesAvailable() ); QByteArray ar( socket->bytesAvailable() );
m_socket->readBlock ( ar.data (), ar.size () ); socket->readBlock( ar.data (), ar.size () );
QString buf( ar ); QString data( ar );
m_data += buf.right( buf.length() - buf.find("<?xml") ); 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 ) if( m_data.find("</ab>") < 0 )
return; // Need more data return; // Need more data
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << m_data.find("</ab>") << endl;
m_socket->close(); m_socket->close();
QDomDocument doc; QDomDocument doc;
QDomNodeList list; QDomNodeList list;
QDomElement e; QDomElement e;
uint it = 0; int it = 0;
doc.setContent( m_data ); doc.setContent( m_data );
list = doc.elementsByTagName( "ab" ); // Get the Addressbook list = doc.elementsByTagName( "ab" ); // Get the Addressbook
@ -151,7 +150,7 @@ void ModifyYABTask::slotRead()
if( !list.item( it ).isElement() ) if( !list.item( it ).isElement() )
continue; continue;
e = list.item( it ).toElement(); e = list.item( it ).toElement();
if( !e.attribute( "lm" ).isEmpty() ) if( !e.attribute( "lm" ).isEmpty() )
emit gotRevision( e.attribute( "lm" ).toLong(), true ); emit gotRevision( e.attribute( "lm" ).toLong(), true );
@ -161,11 +160,11 @@ void ModifyYABTask::slotRead()
list = doc.elementsByTagName( "ct" ); // Get records list = doc.elementsByTagName( "ct" ); // Get records
for( it = 0; it < list.count(); it++ ) { 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() ) if( !list.item( it ).isElement() )
continue; continue;
e = list.item( it ).toElement(); e = list.item( it ).toElement();
YABEntry *entry = new YABEntry; YABEntry *entry = new YABEntry;
entry->fromQDomElement( e ); entry->fromQDomElement( e );
entry->source = YABEntry::SourceYAB; entry->source = YABEntry::SourceYAB;
@ -175,31 +174,31 @@ void ModifyYABTask::slotRead()
case EditEntry: case EditEntry:
if( !e.attribute( "es" ).isEmpty() && e.attribute( "es" ) != "0" ) // Check for edit errors 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; continue;
} }
break; break;
case AddEntry: case AddEntry:
if( !e.attribute( "as" ).isEmpty() && e.attribute( "as" ) != "0" ) // Check for add errors 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; continue;
} }
break; break;
case DeleteEntry: case DeleteEntry:
if( !e.attribute( "ds" ).isEmpty() && e.attribute( "ds" ) != "0" ) // Check for delete errors 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; continue;
} }
break; break;
} }
// No errors occured // No errors occurred
emit gotEntry( entry ); emit gotEntry( entry );
} }
setSuccess( true ); setSuccess();
} }
#include "modifyyabtask.moc" #include "modifyyabtask.moc"

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
modifyyabtask.h - Saves a YAB entry 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> Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
************************************************************************* *************************************************************************
@ -21,7 +21,6 @@
#include "task.h" #include "task.h"
#include "yabentry.h" #include "yabentry.h"
struct KURL;
namespace KIO { namespace KIO {
class Job; class Job;
class TransferJob; class TransferJob;
@ -29,7 +28,6 @@ namespace KIO {
namespace KNetwork { namespace KNetwork {
class KBufferedSocket; class KBufferedSocket;
} }
class QDomElement;
/** /**
@author André Duffeck @author André Duffeck

@ -16,16 +16,16 @@
************************************************************************* *************************************************************************
*/ */
#ifndef _YAHOOTYPES_H_ #ifndef OSCARTYPES_H
#define _YAHOOTYPES_H_ #define OSCARTYPES_H
#include <qglobal.h> #include <qglobal.h>
namespace Yahoo namespace Yahoo
{ {
typedef Q_UINT8 BYTE; typedef quint8 BYTE;
typedef Q_UINT16 WORD; typedef quint16 WORD;
typedef Q_UINT32 DWORD; typedef quint32 DWORD;
} }
#endif #endif // OSCARTYPES_H

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Notifies about buddy icons 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 "ymsgtransfer.h"
#include "yahootypes.h" #include "yahootypes.h"
#include "client.h" #include "client.h"
#include <qstring.h>
#include <qstringlist.h> #include <qstringlist.h>
#include <kurl.h>
#include <kdebug.h> #include <kdebug.h>
#include <klocale.h> #include <klocale.h>
PictureNotifierTask::PictureNotifierTask(Task* parent) : Task(parent) PictureNotifierTask::PictureNotifierTask(Task* parent) : Task(parent)
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
} }
PictureNotifierTask::~PictureNotifierTask() PictureNotifierTask::~PictureNotifierTask()
@ -37,23 +37,23 @@ PictureNotifierTask::~PictureNotifierTask()
bool PictureNotifierTask::take( Transfer* transfer ) bool PictureNotifierTask::take( Transfer* transfer )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
if ( !forMe( transfer ) ) if ( !forMe( transfer ) )
return false; return false;
YMSGTransfer *t = 0L; YMSGTransfer *t = 0L;
t = dynamic_cast<YMSGTransfer*>(transfer); t = dynamic_cast<YMSGTransfer*>(transfer);
if (!t) if (!t)
return false; return false;
switch( t->service() ) switch( t->service() )
{ {
case Yahoo::ServicePictureStatus: case Yahoo::ServicePictureStatus:
parsePictureStatus( t ); parsePictureStatus( t );
parsePicture( t );
break; break;
case Yahoo::ServicePictureChecksum: case Yahoo::ServicePictureChecksum:
parsePictureChecksum( t ); parsePictureChecksum( t );
parsePicture( t );
break; break;
case Yahoo::ServicePicture: case Yahoo::ServicePicture:
parsePicture( t ); parsePicture( t );
@ -63,16 +63,15 @@ bool PictureNotifierTask::take( Transfer* transfer )
break; break;
default: default:
break; break;
} }
return true; return true;
} }
bool PictureNotifierTask::forMe( Transfer* transfer ) const bool PictureNotifierTask::forMe( const Transfer* transfer ) const
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; const YMSGTransfer *t = 0L;
YMSGTransfer *t = 0L; t = dynamic_cast<const YMSGTransfer*>(transfer);
t = dynamic_cast<YMSGTransfer*>(transfer);
if (!t) if (!t)
return false; return false;
@ -89,37 +88,37 @@ bool PictureNotifierTask::forMe( Transfer* transfer ) const
void PictureNotifierTask::parsePictureStatus( YMSGTransfer *t ) void PictureNotifierTask::parsePictureStatus( YMSGTransfer *t )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
QString nick; /* key = 4 */ QString nick; /* key = 4 */
int state; /* key = 213 */ int state; /* key = 213 */
nick = t->firstParam( 4 ); nick = t->firstParam( 4 );
state = t->firstParam( 213 ).toInt(); state = t->firstParam( 213 ).toInt();
emit pictureStatusNotify( nick, state ); emit pictureStatusNotify( nick, state );
} }
void PictureNotifierTask::parsePictureChecksum( YMSGTransfer *t ) void PictureNotifierTask::parsePictureChecksum( YMSGTransfer *t )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
QString nick; /* key = 4 */ QString nick; /* key = 4 */
int checksum; /* key = 192 */ int checksum; /* key = 192 */
nick = t->firstParam( 4 ); nick = t->firstParam( 4 );
checksum = t->firstParam( 192 ).toInt(); checksum = t->firstParam( 192 ).toInt();
if( nick != client()->userId() ) if( nick != client()->userId() )
emit pictureChecksumNotify( nick, checksum ); emit pictureChecksumNotify( nick, checksum );
} }
void PictureNotifierTask::parsePicture( YMSGTransfer *t ) void PictureNotifierTask::parsePicture( YMSGTransfer *t )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
QString nick; /* key = 4 */ 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 */ QString url; /* key = 20 */
int checksum; /* key = 192 */ int checksum; /* key = 192 */
@ -127,30 +126,34 @@ void PictureNotifierTask::parsePicture( YMSGTransfer *t )
url = t->firstParam( 20 ); url = t->firstParam( 20 );
checksum = t->firstParam( 192 ).toInt(); checksum = t->firstParam( 192 ).toInt();
type = t->firstParam( 13 ).toInt(); type = t->firstParam( 13 ).toInt();
if( type == 1 ) if( type == 1 )
emit pictureRequest( nick ); emit pictureRequest( nick );
else if( type == 0 )
emit pictureInfoNotify( nick, KURL( url ), checksum );
else if( type == 2 ) else if( type == 2 )
emit pictureInfoNotify( nick, KURL( url ), checksum ); emit pictureInfoNotify( nick, KURL( url ), checksum );
} }
void PictureNotifierTask::parsePictureUploadResponse( YMSGTransfer *t ) void PictureNotifierTask::parsePictureUploadResponse( YMSGTransfer *t )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
QString url; QString url;
QString error; QString error;
int expires;
url = t->firstParam( 20 ); url = t->firstParam( 20 );
error = t->firstParam( 16 ); error = t->firstParam( 16 );
expires = t->firstParam( 38 ).toInt();
if( !error.isEmpty() ) if( !error.isEmpty() )
client()->notifyError(i18n("The picture was not successfully uploaded"), error, Client::Error ); client()->notifyError(i18n("The picture was not successfully uploaded"), error, Client::Error );
if( !url.isEmpty() ) if( !url.isEmpty() )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Emitting url: " << url << endl; kdDebug(YAHOO_RAW_DEBUG) << "Emitting url: " << url << " Picture expires: " << expires << endl;
emit pictureUploaded( url ); emit pictureUploaded( url, expires );
} }
} }

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Notifies about buddy icons 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 "task.h"
#include <kurl.h>
class QString; class QString;
class KURL;
class YMSGTransfer; class YMSGTransfer;
/** /**
@author André Duffeck @author André Duffeck
@ -31,11 +32,11 @@ Q_OBJECT
public: public:
PictureNotifierTask(Task *parent); PictureNotifierTask(Task *parent);
~PictureNotifierTask(); ~PictureNotifierTask();
bool take(Transfer *transfer); bool take(Transfer *transfer);
protected: protected:
bool forMe( Transfer *transfer ) const; virtual bool forMe( const Transfer *transfer ) const;
void parsePictureChecksum( YMSGTransfer *transfer ); void parsePictureChecksum( YMSGTransfer *transfer );
void parsePictureStatus( YMSGTransfer *transfer ); void parsePictureStatus( YMSGTransfer *transfer );
void parsePicture( YMSGTransfer *transfer ); void parsePicture( YMSGTransfer *transfer );
@ -43,9 +44,9 @@ protected:
signals: signals:
void pictureStatusNotify( const QString &, int ); void pictureStatusNotify( const QString &, int );
void pictureChecksumNotify( 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 pictureRequest( const QString & );
void pictureUploaded( const QString & ); void pictureUploaded( const QString &, int );
}; };
#endif #endif

@ -2,7 +2,7 @@
pingtask.cpp pingtask.cpp
Send a ping to the server 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> Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
@ -26,7 +26,7 @@
PingTask::PingTask(Task* parent) : Task(parent) PingTask::PingTask(Task* parent) : Task(parent)
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
} }
PingTask::~PingTask() PingTask::~PingTask()
@ -35,12 +35,12 @@ PingTask::~PingTask()
void PingTask::onGo() void PingTask::onGo()
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServicePing7); YMSGTransfer *t = new YMSGTransfer(Yahoo::ServicePing7);
t->setParam( 0, client()->userId().local8Bit() ); t->setParam( 0, client()->userId().local8Bit() );
t->setId( client()->sessionID() ); t->setId( client()->sessionID() );
send( t ); send( t );
setSuccess( true ); setSuccess();
} }

@ -2,7 +2,7 @@
pingtask.h pingtask.h
Send a ping to the server 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> Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Receive a file 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 "ymsgtransfer.h"
#include "yahootypes.h" #include "yahootypes.h"
#include "client.h" #include "client.h"
#include <qstring.h>
#include <qtimer.h> #include <qtimer.h>
#include <qfile.h>
#include <kdebug.h> #include <kdebug.h>
#include <klocale.h> #include <klocale.h>
#include <kio/global.h> #include <kio/global.h>
@ -29,7 +30,7 @@
ReceiveFileTask::ReceiveFileTask(Task* parent) : Task(parent) ReceiveFileTask::ReceiveFileTask(Task* parent) : Task(parent)
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
m_transmitted = 0; m_transmitted = 0;
m_file = 0; m_file = 0;
m_transferJob = 0; m_transferJob = 0;
@ -43,7 +44,7 @@ ReceiveFileTask::~ReceiveFileTask()
void ReceiveFileTask::onGo() void ReceiveFileTask::onGo()
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceFileTransfer7); YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceFileTransfer7);
switch( m_type ) switch( m_type )
{ {
@ -52,7 +53,8 @@ void ReceiveFileTask::onGo()
if( !m_file->open( IO_WriteOnly ) ) if( !m_file->open( IO_WriteOnly ) )
{ {
emit error( m_transferId, KIO::ERR_CANNOT_OPEN_FOR_WRITING, i18n("Could not open file for writing.") ); emit error( m_transferId, KIO::ERR_CANNOT_OPEN_FOR_WRITING, i18n("Could not open file for writing.") );
setSuccess( false ); setError();
delete t;
return; return;
} }
m_transferJob = KIO::get( m_remoteUrl, false, false ); m_transferJob = KIO::get( m_remoteUrl, false, false );
@ -66,7 +68,7 @@ void ReceiveFileTask::onGo()
t->setParam( 5, m_userId.local8Bit() ); t->setParam( 5, m_userId.local8Bit() );
t->setParam( 265, m_remoteUrl.url().local8Bit() ); t->setParam( 265, m_remoteUrl.url().local8Bit() );
t->setParam( 222, 3 ); t->setParam( 222, 3 );
send( t ); send( t );
break; break;
case FileTransfer7Reject: case FileTransfer7Reject:
@ -75,7 +77,7 @@ void ReceiveFileTask::onGo()
t->setParam( 5, m_userId.local8Bit() ); t->setParam( 5, m_userId.local8Bit() );
t->setParam( 265, m_remoteUrl.url().local8Bit() ); t->setParam( 265, m_remoteUrl.url().local8Bit() );
t->setParam( 222, 4 ); t->setParam( 222, 4 );
send( t ); send( t );
break; break;
default: default:
@ -85,23 +87,23 @@ void ReceiveFileTask::onGo()
bool ReceiveFileTask::take( Transfer* transfer ) bool ReceiveFileTask::take( Transfer* transfer )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
if ( !forMe( transfer ) ) if ( !forMe( transfer ) )
return false; return false;
YMSGTransfer *t = static_cast<YMSGTransfer*>(transfer); YMSGTransfer *t = static_cast<YMSGTransfer*>(transfer);
parseFileTransfer7Info( t ); parseFileTransfer7Info( t );
return true; return true;
} }
bool ReceiveFileTask::forMe( Transfer *transfer ) const bool ReceiveFileTask::forMe( const Transfer *transfer ) const
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
YMSGTransfer *t = 0L; const YMSGTransfer *t = 0L;
t = dynamic_cast<YMSGTransfer*>(transfer); t = dynamic_cast<const YMSGTransfer*>(transfer);
if (!t) if (!t)
return false; return false;
@ -113,7 +115,7 @@ bool ReceiveFileTask::forMe( Transfer *transfer ) const
return true; return true;
else else
return false; return false;
} }
else else
return false; return false;
} }
@ -121,17 +123,16 @@ bool ReceiveFileTask::forMe( Transfer *transfer ) const
void ReceiveFileTask::slotData( KIO::Job *job, const QByteArray& data ) void ReceiveFileTask::slotData( KIO::Job *job, const QByteArray& data )
{ {
Q_UNUSED( job ); Q_UNUSED( job );
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
m_transmitted += data.size(); m_transmitted += data.size();
emit bytesProcessed( m_transferId, m_transmitted ); emit bytesProcessed( m_transferId, m_transmitted );
m_file->writeBlock( data.data() , data.size() ); m_file->writeBlock( data.data() , data.size() );
} }
void ReceiveFileTask::slotComplete( KIO::Job *job ) 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); KIO::TransferJob *transfer = static_cast< KIO::TransferJob * >(job);
@ -139,19 +140,19 @@ void ReceiveFileTask::slotComplete( KIO::Job *job )
m_file->close(); m_file->close();
if ( job->error () || transfer->isErrorPage () ) if ( job->error () || transfer->isErrorPage () )
{ {
emit error( m_transferId, KIO::ERR_ABORTED, i18n("An error occured while downloading the file.") ); emit error( m_transferId, KIO::ERR_ABORTED, i18n("An error occurred while downloading the file.") );
setSuccess( false ); setError();
} }
else else
{ {
emit complete( m_transferId ); emit complete( m_transferId );
setSuccess( true ); setSuccess();
} }
} }
void ReceiveFileTask::parseFileTransfer7Info( YMSGTransfer *transfer ) 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 ) if( transfer->firstParam( 249 ).toInt() == 1 )
{ {
@ -162,7 +163,7 @@ void ReceiveFileTask::parseFileTransfer7Info( YMSGTransfer *transfer )
t->setParam( 5, transfer->firstParam( 4 ) ); t->setParam( 5, transfer->firstParam( 4 ) );
t->setParam( 265, transfer->firstParam( 265 ) ); t->setParam( 265, transfer->firstParam( 265 ) );
t->setParam( 66, -3 ); t->setParam( 66, -3 );
send( t ); send( t );
} }
else if( transfer->firstParam( 249 ).toInt() == 3 ) else if( transfer->firstParam( 249 ).toInt() == 3 )
@ -171,7 +172,7 @@ void ReceiveFileTask::parseFileTransfer7Info( YMSGTransfer *transfer )
if( !m_file->open( IO_WriteOnly ) ) if( !m_file->open( IO_WriteOnly ) )
{ {
emit error( m_transferId, KIO::ERR_CANNOT_OPEN_FOR_WRITING, i18n("Could not open file for writing.") ); emit error( m_transferId, KIO::ERR_CANNOT_OPEN_FOR_WRITING, i18n("Could not open file for writing.") );
setSuccess( false ); setError();
return; return;
} }
@ -183,23 +184,23 @@ void ReceiveFileTask::parseFileTransfer7Info( YMSGTransfer *transfer )
t->setParam( 27, transfer->firstParam( 27 ) ); t->setParam( 27, transfer->firstParam( 27 ) );
t->setParam( 249, 3 ); // Use Reflection server t->setParam( 249, 3 ); // Use Reflection server
t->setParam( 251, transfer->firstParam( 251 ) ); t->setParam( 251, transfer->firstParam( 251 ) );
send( t ); send( t );
// The server expects a HTTP HEAD command prior to the GET // 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") 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("cookies", "manual");
m_mimetypeJob->addMetaData("setcookies", QString::fromLatin1("Cookie: T=%1; path=/; domain=.yahoo.com; Y=%2; C=%3;") 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()) ); .arg(client()->tCookie()).arg(client()->yCookie()).arg(client()->cCookie()) );
m_transferJob = KIO::get( QString::fromLatin1("http://%1/relay?token=%2&sender=%3&recver=%4") 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( 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 & ) ) ); 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("cookies", "manual");
m_transferJob->addMetaData("setcookies", QString::fromLatin1("Cookie: T=%1; path=/; domain=.yahoo.com; Y=%2; C=%3;") 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()).arg(client()->cCookie()) ); .arg(client()->tCookie()).arg(client()->yCookie()) );
} }
} }
@ -232,11 +233,11 @@ void ReceiveFileTask::canceled( unsigned int id )
{ {
if( m_transferId != id ) if( m_transferId != id )
return; return;
if( m_transferJob ) if( m_transferJob )
m_transferJob->kill(); m_transferJob->kill();
setSuccess( false ); setError();
} }
#include "receivefiletask.moc" #include "receivefiletask.moc"

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Receive a file 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 #define RECEIVEFILETASK_H
#include "task.h" #include "task.h"
#include <qfile.h>
#include <kurl.h> #include <kurl.h>
class QString; class QString;
class QFile; class QFile;
namespace KIO { namespace KIO {
class Job; class Job;
class TransferJob; class TransferJob;
class MimetypeJob; class MimetypeJob;
} }
class YMSGTransfer; class YMSGTransfer;
/** /**
@ -40,20 +40,20 @@ public:
enum Type { FileTransferAccept, FileTransfer7Accept, FileTransfer7Reject }; enum Type { FileTransferAccept, FileTransfer7Accept, FileTransfer7Reject };
ReceiveFileTask(Task *parent); ReceiveFileTask(Task *parent);
~ReceiveFileTask(); ~ReceiveFileTask();
virtual void onGo(); virtual void onGo();
void setRemoteUrl( KURL url ); void setRemoteUrl( KURL url );
void setLocalUrl( KURL url ); void setLocalUrl( KURL url );
void setFileName( const QString &filename ); void setFileName( const QString &filename );
void setTransferId( unsigned int transferId ); void setTransferId( unsigned int transferId );
void setType( Type type ); void setType( Type type );
void setUserId( const QString & userId ); void setUserId( const QString & userId );
bool take(Transfer *transfer); bool take(Transfer *transfer);
protected: protected:
bool forMe( Transfer *transfer ) const; virtual bool forMe( const Transfer *transfer ) const;
signals: signals:
void bytesProcessed( unsigned int, unsigned int ); void bytesProcessed( unsigned int, unsigned int );

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Request a Picture of a Buddy 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 "ymsgtransfer.h"
#include "yahootypes.h" #include "yahootypes.h"
#include "client.h" #include "client.h"
#include <qstring.h>
#include <kdebug.h> #include <kdebug.h>
RequestPictureTask::RequestPictureTask(Task* parent) : Task(parent) RequestPictureTask::RequestPictureTask(Task* parent) : Task(parent)
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
} }
RequestPictureTask::~RequestPictureTask() RequestPictureTask::~RequestPictureTask()
@ -35,12 +35,12 @@ void RequestPictureTask::onGo()
{ {
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServicePicture); YMSGTransfer *t = new YMSGTransfer(Yahoo::ServicePicture);
t->setId( client()->sessionID() ); t->setId( client()->sessionID() );
t->setParam( 4, client()->userId().local8Bit()); t->setParam( 1, client()->userId().local8Bit());
t->setParam( 5, m_target.local8Bit() ); t->setParam( 5, m_target.local8Bit() );
t->setParam( 13, "1" ); t->setParam( 13, "1" );
send( t ); send( t );
setSuccess( true ); setSuccess();
} }
void RequestPictureTask::setTarget( const QString &target ) void RequestPictureTask::setTarget( const QString &target )

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Request a Picture of a Buddy 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 Q_OBJECT
public: public:
RequestPictureTask(Task *parent); RequestPictureTask(Task *parent);
~RequestPictureTask(); virtual ~RequestPictureTask();
virtual void onGo(); virtual void onGo();
void setTarget( const QString &target ); void setTarget( const QString &target );
private: private:
QString m_target; QString m_target;

@ -3,7 +3,7 @@
Copyright (c) 2004 SUSE Linux AG http://www.suse.com 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> Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
@ -55,8 +55,9 @@ void SafeDelete::deleteAll()
return; return;
QObjectListIt it(list); QObjectListIt it(list);
for(QObject *o; (o = it.current()); ++it) for(QObject *o; (o = it.current()); ++it)
deleteSingle(o); deleteSingle(o);
list.clear(); list.clear();
} }

@ -3,7 +3,7 @@
Copyright (c) 2004 SUSE Linux AG http://www.suse.com 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> Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Send a authorization request response 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> Kopete (c) 2003-2006 by the Kopete developers <kopete-devel@kde.org>
************************************************************************* *************************************************************************
@ -25,7 +25,7 @@
SendAuthRespTask::SendAuthRespTask(Task* parent) : Task(parent) SendAuthRespTask::SendAuthRespTask(Task* parent) : Task(parent)
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
} }
SendAuthRespTask::~SendAuthRespTask() SendAuthRespTask::~SendAuthRespTask()
@ -51,7 +51,7 @@ void SendAuthRespTask::onGo()
} }
send( t ); send( t );
setSuccess( true ); setSuccess();
} }
void SendAuthRespTask::setGranted( bool granted ) void SendAuthRespTask::setGranted( bool granted )

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Send a authorization request response 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> Kopete (c) 2003-2006 by the Kopete developers <kopete-devel@kde.org>
************************************************************************* *************************************************************************

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Send a file 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 "client.h"
#include <qstring.h> #include <qstring.h>
#include <qtimer.h> #include <qtimer.h>
#include <kapplication.h> // for random()
#include <kdebug.h> #include <kdebug.h>
#include <klocale.h> #include <klocale.h>
#include <kstreamsocket.h> #include <kstreamsocket.h>
@ -30,9 +31,11 @@ using namespace KNetwork;
SendFileTask::SendFileTask(Task* parent) : Task(parent) SendFileTask::SendFileTask(Task* parent) : Task(parent)
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
m_transmitted = 0; m_transmitted = 0;
m_socket = 0; m_socket = 0;
QTime epoch(0, 0, 0);
} }
SendFileTask::~SendFileTask() SendFileTask::~SendFileTask()
@ -41,47 +44,159 @@ SendFileTask::~SendFileTask()
m_socket = 0; 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() 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; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
m_socket = new KStreamSocket( "filetransfer.msg.yahoo.com", QString::number(80) );
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 ); m_socket->setBlocking( true );
connect( m_socket, SIGNAL( connected( const KResolverEntry& ) ), this, SLOT( connectSucceeded() ) ); connect( m_socket, SIGNAL( connected( const KResolverEntry& ) ), this, SLOT( connectSucceeded() ) );
connect( m_socket, SIGNAL( gotError(int) ), this, SLOT( connectFailed(int) ) ); connect( m_socket, SIGNAL( gotError(int) ), this, SLOT( connectFailed(int) ) );
m_socket->connect(); m_socket->connect();
} }
void SendFileTask::connectFailed( int i ) void SendFileTask::connectFailed( int i )
{ {
QString err = m_socket->errorString(); QString err = KSocketBase::errorString(m_socket->error());
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << i << ": " << err << endl; kdDebug(YAHOO_RAW_DEBUG) << i << ": " << err << endl;
emit error( m_transferId, i, err ); emit error( m_transferId, i, err );
setSuccess( false ); setError();
} }
void SendFileTask::connectSucceeded() void SendFileTask::connectSucceeded()
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
YMSGTransfer t( Yahoo::ServiceFileTransfer );
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 buffer;
QByteArray paket;
QDataStream stream( buffer, IO_WriteOnly ); QDataStream stream( buffer, IO_WriteOnly );
if ( m_file.open(IO_ReadOnly ) ) if ( m_file.open(IO_ReadOnly ) )
@ -90,22 +205,25 @@ void SendFileTask::connectSucceeded()
} }
else else
{ {
client()->notifyError( i18n( "An error occured sending the file." ), m_file.errorString(), Client::Error ); kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Error opening file: " << m_file.errorString() << endl;
setSuccess( false ); client()->notifyError( i18n( "An error occurred while sending the file." ), m_file.errorString(), Client::Error );
setError();
return; return;
} }
paket = t.serialize(); kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Sizes: File (" << m_url << "): " << m_file.size() << endl;
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Sizes: File (" << m_url << "): " << m_file.size() << " - paket: " << paket.size() << endl; QString header =
QString header = QString::fromLatin1("POST http://filetransfer.msg.yahoo.com:80/notifyft HTTP/1.1\r\n" "POST /relay?token=" + m_token +
"Cookie: Y=%1; T=%2; C=%3 ;B=fckeert1kk1nl&b=2\r\n" "&sender=" + client()->userId() +
"User-Agent: Mozilla/4.0 (compatible; MSIE 5.5)\r\n" "&recver=" + m_target + " HTTP/1.1\r\n"
"Host: filetransfer.msg.yahoo.com:80\r\n" "User-Agent: Mozilla/5.0\r\n"
"Content-length: %4\r\n" "Cache-Control: no-cache\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()); "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( 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() ) ) if( !m_socket->writeBlock( buffer, buffer.size() ) )
{ {
@ -121,7 +239,7 @@ void SendFileTask::connectSucceeded()
void SendFileTask::transmitData() void SendFileTask::transmitData()
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
int read = 0; int read = 0;
int written = 0; int written = 0;
char buf[1024]; char buf[1024];
@ -138,14 +256,14 @@ void SendFileTask::transmitData()
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Upload Failed!" << endl; kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Upload Failed!" << endl;
emit error( m_transferId, m_socket->error(), m_socket->errorString() ); emit error( m_transferId, m_socket->error(), m_socket->errorString() );
setSuccess( false ); setError();
return; return;
} }
if( m_transmitted == m_file.size() ) if( m_transmitted == m_file.size() )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Upload Successful: " << m_transmitted << endl; kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Upload Successful: " << m_transmitted << endl;
emit complete( m_transferId ); emit complete( m_transferId );
setSuccess( true ); setSuccess();
m_socket->close(); m_socket->close();
} }
else else
@ -182,7 +300,32 @@ void SendFileTask::canceled( unsigned int id )
if( m_socket ) if( m_socket )
m_socket->close(); 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" #include "sendfiletask.moc"

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Send a file 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(); virtual void onGo();
bool take(Transfer *transfer);
void setTarget( const QString &to ); void setTarget( const QString &to );
void setMessage( const QString &msg ); void setMessage( const QString &msg );
void setFileUrl( KURL url ); void setFileUrl( KURL url );
@ -48,8 +50,17 @@ signals:
void complete( unsigned int ); void complete( unsigned int );
void error( unsigned int, int, const QString & ); 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: private slots:
void initiateUpload();
void connectSucceeded(); void connectSucceeded();
void connectFailed( int ); void connectFailed( int );
void transmitData(); void transmitData();
@ -63,6 +74,10 @@ private:
unsigned int m_transferId; unsigned int m_transferId;
unsigned int m_transmitted; unsigned int m_transmitted;
KNetwork::KStreamSocket *m_socket; KNetwork::KStreamSocket *m_socket;
QString m_relayHost;
QString m_token;
QString m_yahooTransferId;
}; };
#endif #endif

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Send a message 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) SendMessageTask::SendMessageTask(Task* parent) : Task(parent)
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
} }
SendMessageTask::~SendMessageTask() SendMessageTask::~SendMessageTask()
@ -34,15 +34,15 @@ SendMessageTask::~SendMessageTask()
void SendMessageTask::onGo() void SendMessageTask::onGo()
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
if( m_text.isEmpty() ) if( m_text.isEmpty() )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Text to send is empty." << endl; kdDebug(YAHOO_RAW_DEBUG) << "Text to send is empty." << endl;
client()->notifyError( i18n( "An error occured sending the message" ), i18n( "The message is empty." ), Client::Debug ); client()->notifyError( i18n( "An error occurred while sending the message" ), i18n( "The message is empty." ), Client::Debug );
return; return;
} }
uint pos=0; int pos=0;
// split messages that are longer than 800 chars. they get dropped otherwise // split messages that are longer than 800 chars. they get dropped otherwise
while( pos < m_text.length() ) while( pos < m_text.length() )
@ -61,7 +61,7 @@ void SendMessageTask::onGo()
pos += 700; pos += 700;
} }
setSuccess( true ); setSuccess();
} }
void SendMessageTask::setTarget( const QString &to ) void SendMessageTask::setTarget( const QString &to )

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Send a message Send a message
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net> Copyright (c) 2005 André Duffeck <duffeck@kde.org>
************************************************************************* *************************************************************************
* * * *

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Send a notification 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 "ymsgtransfer.h"
#include "yahootypes.h" #include "yahootypes.h"
#include "client.h" #include "client.h"
#include <qstring.h>
#include <kdebug.h> #include <kdebug.h>
SendNotifyTask::SendNotifyTask(Task* parent) : Task(parent) SendNotifyTask::SendNotifyTask(Task* parent) : Task(parent)
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
} }
SendNotifyTask::~SendNotifyTask() SendNotifyTask::~SendNotifyTask()
@ -36,29 +36,35 @@ void SendNotifyTask::onGo()
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceNotify); YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceNotify);
t->setId( client()->sessionID() ); t->setId( client()->sessionID() );
t->setStatus( Yahoo::StatusNotify ); t->setStatus( Yahoo::StatusNotify );
t->setParam( 4, client()->userId().local8Bit() );
t->setParam( 5, m_target.local8Bit() );
t->setParam( 14, " " );
switch( m_type ) switch( m_type )
{ {
case NotifyTyping: case NotifyTyping:
t->setParam( 4, client()->userId().local8Bit() );
t->setParam( 5, m_target.local8Bit() );
t->setParam( 13, m_state ); t->setParam( 13, m_state );
t->setParam( 14, " " );
t->setParam( 49, "TYPING" ); t->setParam( 49, "TYPING" );
break; break;
case NotifyWebcamInvite: 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( 13, 0 );
t->setParam( 49, "WEBCAMINVITE" ); t->setParam( 14, " " );
t->setParam( 49, "WEBCAMINVITE" );
break; break;
case NotifyGame: case NotifyGame:
default: default:
setSuccess( false ); setError();
delete t; delete t;
return; return;
break; break;
} }
send( t ); send( t );
setSuccess( true ); setSuccess();
} }
void SendNotifyTask::setType( Type type ) void SendNotifyTask::setType( Type type )

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Send a notification Send a notification
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net> Copyright (c) 2005 André Duffeck <duffeck@kde.org>
************************************************************************* *************************************************************************
* * * *

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
sendpicturetask.cpp - Send our picture or information about it 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 "client.h"
#include <qstring.h> #include <qstring.h>
#include <qfile.h> #include <qfile.h>
#include <qcstring.h>
#include <qdatastream.h> #include <qdatastream.h>
#include <kio/global.h> #include <kio/global.h>
#include <kio/job.h> #include <kio/job.h>
@ -34,7 +33,7 @@ using namespace KNetwork;
SendPictureTask::SendPictureTask(Task* parent) : Task(parent) SendPictureTask::SendPictureTask(Task* parent) : Task(parent)
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
m_socket = 0; m_socket = 0;
} }
@ -55,6 +54,7 @@ void SendPictureTask::onGo()
break; break;
case SendInformation: case SendInformation:
sendInformation(); sendInformation();
break;
case SendStatus: case SendStatus:
sendStatus(); sendStatus();
break; break;
@ -62,26 +62,27 @@ void SendPictureTask::onGo()
} }
void SendPictureTask::initiateUpload() 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) ); 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( connected( const KResolverEntry& ) ), this, SLOT( connectSucceeded() ) );
connect( m_socket, SIGNAL( gotError(int) ), this, SLOT( connectFailed(int) ) ); connect( m_socket, SIGNAL( gotError(int) ), this, SLOT( connectFailed(int) ) );
connect( m_socket, SIGNAL( readyRead() ), this, SLOT( readResult() ) );
m_socket->connect(); m_socket->connect();
} }
void SendPictureTask::connectFailed( int i) void SendPictureTask::connectFailed( int i)
{ {
m_socket->close(); kdDebug(YAHOO_RAW_DEBUG) << i << ": " << static_cast<const KBufferedSocket*>( sender() )->errorString() << endl;
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << 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 ); 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() void SendPictureTask::connectSucceeded()
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
YMSGTransfer t(Yahoo::ServicePictureUpload); YMSGTransfer t(Yahoo::ServicePictureUpload);
QFile file( m_path ); QFile file( m_path );
@ -90,26 +91,26 @@ void SendPictureTask::connectSucceeded()
t.setParam( 1, client()->userId().local8Bit()); t.setParam( 1, client()->userId().local8Bit());
t.setParam( 38, 604800); t.setParam( 38, 604800);
t.setParam( 0, client()->userId().local8Bit()); t.setParam( 0, client()->userId().local8Bit());
t.setParam( 28, file.size() ); t.setParam( 28, file.size() );
t.setParam( 27, m_fileName.local8Bit() ); t.setParam( 27, m_fileName.local8Bit() );
t.setParam( 14, "" ); t.setParam( 14, "" );
QByteArray buffer; QByteArray buffer;
QByteArray paket; QByteArray paket;
QDataStream stream( buffer, IO_WriteOnly ); 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 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 ); client()->notifyError(i18n("Error opening file: %1").arg(m_path), file.errorString(), Client::Error );
return; return;
} }
paket = t.serialize(); 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" QString header = QString::fromLatin1("POST /notifyft HTTP/1.1\r\n"
"Cookie: Y=%1; T=%2; C=%3 ;\r\n" "Cookie: Y=%1; T=%2; C=%3 ;\r\n"
"User-Agent: Mozilla/4.0 (compatible; MSIE 5.5)\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 << (Q_INT8)0x32 << (Q_INT8)0x39 << (Q_INT8)0xc0 << (Q_INT8)0x80;
stream.writeRawBytes( file.readAll(), file.size() ); 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() ) ) if( m_socket->writeBlock( buffer, buffer.size() ) )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Upload Successful." << endl; kdDebug(YAHOO_RAW_DEBUG) << "Upload Successful!" << endl;
connect( m_socket, SIGNAL( readyRead() ), this, SLOT( readResult() ) ); m_socket->enableRead( true );
// setSuccess();
} }
else else
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Upload Failed." << endl; kdDebug(YAHOO_RAW_DEBUG) << "Upload Failed!" << endl;
m_socket->close(); setError();
setSuccess( false );
} }
} }
void SendPictureTask::readResult() 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() ); QByteArray ar( m_socket->bytesAvailable() );
m_socket->readBlock ( ar.data (), ar.size () ); m_socket->readBlock ( ar.data (), ar.size () );
QString buf( ar ); QString buf( ar );
m_socket->close(); m_socket->close();
if( buf.find( "error", 0, false ) >= 0 ) if( buf.find( "error", 0, false ) >= 0 )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Picture upload failed" << endl; kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Picture upload failed" << endl;
setSuccess( false ); setSuccess( false );
} }
else else
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Picture upload acknowledged." << endl; kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Picture upload acknowledged." << endl;
setSuccess( true ); setSuccess( true );
} }
} }
void SendPictureTask::sendChecksum() void SendPictureTask::sendChecksum()
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServicePictureChecksum); YMSGTransfer *t = new YMSGTransfer(Yahoo::ServicePictureChecksum);
t->setId( client()->sessionID() ); t->setId( client()->sessionID() );
@ -167,41 +187,39 @@ void SendPictureTask::sendChecksum()
t->setParam(192, m_checksum); t->setParam(192, m_checksum);
t->setParam(212, 1); t->setParam(212, 1);
send( t ); send( t );
setSuccess( true ); setSuccess();
} }
void SendPictureTask::sendInformation() void SendPictureTask::sendInformation()
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServicePicture); YMSGTransfer *t = new YMSGTransfer(Yahoo::ServicePicture);
t->setId( client()->sessionID() ); t->setId( client()->sessionID() );
t->setParam(1, client()->userId().local8Bit()); t->setParam(1, client()->userId().local8Bit());
t->setParam(4, client()->userId().local8Bit());
t->setParam(13, 2 ); t->setParam(13, 2 );
t->setParam(5, m_target.local8Bit() ); t->setParam(5, m_target.local8Bit() );
t->setParam(20, m_url.local8Bit() ); t->setParam(20, m_url.local8Bit() );
t->setParam(192, m_checksum); t->setParam(192, m_checksum);
send( t ); send( t );
setSuccess( true ); setSuccess();
} }
void SendPictureTask::sendStatus() 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->setId( client()->sessionID() );
t->setParam(1, client()->userId().local8Bit()); t->setParam(3, client()->userId().local8Bit());
t->setParam(5, m_target.local8Bit() ); t->setParam(213, m_status );
t->setParam(206, m_status );
send( t ); send( t );
setSuccess( true ); setSuccess();
} }
void SendPictureTask::setType( Type type ) void SendPictureTask::setType( Type type )

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
sendpicturetask.h - Send our picture or information about it 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 QString;
class QFile; class QFile;
namespace KIO { namespace KIO {
class Job; class Job;
class TransferJob; class TransferJob;
} }
namespace KNetwork { namespace KNetwork {
class KBufferedSocket; class KBufferedSocket;
} }
@ -39,8 +39,8 @@ public:
enum Type { UploadPicture, SendChecksum, SendInformation, SendStatus }; enum Type { UploadPicture, SendChecksum, SendInformation, SendStatus };
SendPictureTask(Task *parent); SendPictureTask(Task *parent);
~SendPictureTask(); virtual ~SendPictureTask();
virtual void onGo(); virtual void onGo();
void setType( Type type ); void setType( Type type );

@ -37,14 +37,12 @@
* 34aa973c d4c4daa4 f61eeb2b dbad2731 6534016f * 34aa973c d4c4daa4 f61eeb2b dbad2731 6534016f
*/ */
#ifdef HAVE_CONFIG_H /* #include <config-kopete.h> */
#include <config.h>
#endif /* HAVE_CONFIG_H */
#if HAVE_INTTYPES_H #ifdef HAVE_INTTYPES_H
# include <inttypes.h> # include <inttypes.h>
#else #else
# if HAVE_STDINT_H # ifdef HAVE_STDINT_H
# include <stdint.h> # include <stdint.h>
# endif # endif
#endif #endif

@ -29,6 +29,7 @@
#ifndef _SHA1_H #ifndef _SHA1_H
#define _SHA1_H #define _SHA1_H
#include "../../../../config.h"
#if HAVE_INTTYPES_H #if HAVE_INTTYPES_H
# include <inttypes.h> # include <inttypes.h>
#else #else

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Notifies about status changes of buddies 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) StatusNotifierTask::StatusNotifierTask(Task* parent) : Task(parent)
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
} }
StatusNotifierTask::~StatusNotifierTask() StatusNotifierTask::~StatusNotifierTask()
@ -36,11 +36,9 @@ StatusNotifierTask::~StatusNotifierTask()
bool StatusNotifierTask::take( Transfer* transfer ) bool StatusNotifierTask::take( Transfer* transfer )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
if ( !forMe( transfer ) ) if ( !forMe( transfer ) )
return false; return false;
YMSGTransfer *t = static_cast<YMSGTransfer*>(transfer); YMSGTransfer *t = static_cast<YMSGTransfer*>(transfer);
if( t->service() == Yahoo::ServiceStealthOffline ) if( t->service() == Yahoo::ServiceStealthOffline )
@ -48,16 +46,15 @@ bool StatusNotifierTask::take( Transfer* transfer )
else if( t->service() == Yahoo::ServiceAuthorization ) else if( t->service() == Yahoo::ServiceAuthorization )
parseAuthorization( t ); parseAuthorization( t );
else else
parseStatus( t ); parseStatus( t );
return true; return true;
} }
bool StatusNotifierTask::forMe( Transfer* transfer ) const bool StatusNotifierTask::forMe( const Transfer* transfer ) const
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; const YMSGTransfer *t = 0L;
YMSGTransfer *t = 0L; t = dynamic_cast<const YMSGTransfer*>(transfer);
t = dynamic_cast<YMSGTransfer*>(transfer);
if (!t) if (!t)
return false; return false;
@ -72,7 +69,8 @@ bool StatusNotifierTask::forMe( Transfer* transfer ) const
t->service() == Yahoo::ServiceIddeAct || t->service() == Yahoo::ServiceIddeAct ||
t->service() == Yahoo::ServiceStatus || t->service() == Yahoo::ServiceStatus ||
t->service() == Yahoo::ServiceStealthOffline || t->service() == Yahoo::ServiceStealthOffline ||
t->service() == Yahoo::ServiceAuthorization t->service() == Yahoo::ServiceAuthorization ||
t->service() == Yahoo::ServiceBuddyStatus
) )
return true; return true;
else else
@ -81,12 +79,12 @@ bool StatusNotifierTask::forMe( Transfer* transfer ) const
void StatusNotifierTask::parseStatus( YMSGTransfer* t ) 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 ) t->service() == Yahoo::ServiceLogoff )
{ {
emit loginResponse( Yahoo::LoginDupl, QString::null ); emit loginResponse( Yahoo::LoginDupl, QString() );
} }
QString myNick; /* key = 1 */ QString myNick; /* key = 1 */
@ -98,14 +96,14 @@ void StatusNotifierTask::parseStatus( YMSGTransfer* t )
int away; /* key = 47 */ int away; /* key = 47 */
int idle; /* key = 137 */ int idle; /* key = 137 */
bool utf; /* key = 97 */ bool utf; /* key = 97 */
int checksum; /* key = 192 */ int pictureChecksum; /* key = 192 */
customError = t->firstParam( 16 ); customError = t->firstParam( 16 );
if( !customError.isEmpty() ) 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 ); myNick = t->firstParam( 1 );
for( int i = 0; i < t->paramCount( 7 ); ++i) for( int i = 0; i < t->paramCount( 7 ); ++i)
{ {
nick = t->nthParam( 7, i ); nick = t->nthParam( 7, i );
@ -114,27 +112,24 @@ void StatusNotifierTask::parseStatus( YMSGTransfer* t )
away = t->nthParamSeparated( 47, i, 7 ).toInt(); away = t->nthParamSeparated( 47, i, 7 ).toInt();
idle = t->nthParamSeparated( 137, i, 7 ).toInt(); idle = t->nthParamSeparated( 137, i, 7 ).toInt();
utf = t->nthParamSeparated( 97, i, 7 ).toInt() == 1; utf = t->nthParamSeparated( 97, i, 7 ).toInt() == 1;
checksum = t->nthParamSeparated( 192, i, 7 ).toInt(); pictureChecksum = t->nthParamSeparated( 192, i, 7 ).toInt();
if( utf ) if( utf )
message = QString::fromUtf8( t->nthParamSeparated( 19, i, 7 ) ); message = QString::fromUtf8( t->nthParamSeparated( 19, i, 7 ) );
else else
message = t->nthParamSeparated( 19, i, 7 ); message = t->nthParamSeparated( 19, i, 7 );
if( t->service() == Yahoo::ServiceLogoff || ( state != 0 && flags == 0 ) ) 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 else
emit statusChanged( nick, state, message, away, idle ); emit statusChanged( nick, state, message, away, idle, pictureChecksum );
if( checksum )
emit gotPictureChecksum( nick, checksum );
} }
} }
void StatusNotifierTask::parseAuthorization( YMSGTransfer* t ) 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 */ QString msg; /* key = 14 */
int state; /* key = 13 */ int state; /* key = 13 */
bool utf; /* key = 97 */ bool utf; /* key = 97 */
@ -163,14 +158,14 @@ void StatusNotifierTask::parseAuthorization( YMSGTransfer* t )
if( !fname.isEmpty() || !lname.isEmpty() ) if( !fname.isEmpty() || !lname.isEmpty() )
name = QString("%1 %2").arg(fname).arg(lname); 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 ); emit gotAuthorizationRequest( nick, msg, name );
} }
} }
void StatusNotifierTask::parseStealthStatus( YMSGTransfer* t ) void StatusNotifierTask::parseStealthStatus( YMSGTransfer* t )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
QString nick; /* key = 7 */ QString nick; /* key = 7 */
int state; /* key = 31 */ int state; /* key = 31 */

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Notifies about status changes of buddies 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); bool take(Transfer *transfer);
protected: protected:
bool forMe( Transfer *transfer ) const; virtual bool forMe( const Transfer *transfer ) const;
void parseStatus( YMSGTransfer *transfer ); void parseStatus( YMSGTransfer *transfer );
void parseStealthStatus( YMSGTransfer *transfer ); void parseStealthStatus( YMSGTransfer *transfer );
void parseAuthorization( YMSGTransfer *transfer ); void parseAuthorization( YMSGTransfer *transfer );
signals: 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 stealthStatusChanged( const QString&, Yahoo::StealthStatus );
void loginResponse( int, const QString& ); void loginResponse( int, const QString& );
void authorizationAccepted( const QString & ); void authorizationAccepted( const QString & );
void authorizationRejected( const QString &, const QString & ); void authorizationRejected( const QString &, const QString & );
void gotAuthorizationRequest( const QString &, const QString &, const QString & ); void gotAuthorizationRequest( const QString &, const QString &, const QString & );
void gotPictureChecksum( const QString &, int );
}; };
#endif #endif

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Stealth/Unstealth a buddy 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) StealthTask::StealthTask(Task* parent) : Task(parent)
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
} }
StealthTask::~StealthTask() StealthTask::~StealthTask()
@ -37,7 +37,7 @@ void StealthTask::onGo()
{ {
t->setService( Yahoo::ServiceStealthOnline ); t->setService( Yahoo::ServiceStealthOnline );
t->setParam( 13, "1" ); t->setParam( 13, "1" );
t->setParam( 31, m_state ); t->setParam( 31, m_state );
} }
else if( m_mode == Yahoo::StealthOffline ) else if( m_mode == Yahoo::StealthOffline )
{ {
@ -53,11 +53,16 @@ void StealthTask::onGo()
} }
t->setId( client()->sessionID() ); t->setId( client()->sessionID() );
t->setParam( 1, client()->userId().local8Bit()); 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( 7, m_target.local8Bit() );
t->setParam( 301, 319 );
t->setParam( 303, 319 );
}
send( t ); send( t );
setSuccess( true ); setSuccess();
} }
void StealthTask::setTarget( const QString &to ) void StealthTask::setTarget( const QString &to )

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Stealth/Unstealth a buddy Stealth/Unstealth a buddy
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net> Copyright (c) 2005 André Duffeck <duffeck@kde.org>
************************************************************************* *************************************************************************
* * * *

@ -3,7 +3,7 @@
Copyright (c) 2004 SUSE Linux AG http://www.suse.com 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> Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>

@ -4,7 +4,7 @@
Copyright (c) 2004 Matt Rogers <matt.rogers@kdemail.net> Copyright (c) 2004 Matt Rogers <matt.rogers@kdemail.net>
Based on code copyright (c) 2004 SuSE Linux AG <http://www.suse.com> 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> Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
@ -63,7 +63,7 @@ public:
* Send a message to the server * Send a message to the server
*/ */
virtual void write( Transfer *request) = 0; virtual void write( Transfer *request) = 0;
signals: signals:
void connectionClosed(); void connectionClosed();

@ -1,12 +1,12 @@
/* /*
task.cpp - Kopete Groupwise Protocol task.cpp - Kopete Groupwise Protocol
Copyright (c) 2004 SUSE Linux AG http://www.suse.com 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> Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
************************************************************************* *************************************************************************
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
@ -16,7 +16,7 @@
* * * *
************************************************************************* *************************************************************************
*/ */
#include <qtimer.h> #include <qtimer.h>
#include "client.h" #include "client.h"
@ -131,20 +131,19 @@ bool Task::take( Transfer * transfer)
// pass along the transfer to our children // pass along the transfer to our children
QObjectListIt it(*p); QObjectListIt it(*p);
Task *t; Task *t;
for(; it.current(); ++it) { for(; it.current(); ++it)
{
QObject *obj = it.current(); QObject *obj = it.current();
if(!obj->inherits("Task")) if(!obj->inherits("Task"))
continue; continue;
t = static_cast<Task*>(obj); t = static_cast<Task*>(obj);
if(t->take( transfer )) if(t->take( transfer ))
{ {
qDebug( "Transfer ACCEPTED by: %s", t->className() ); qDebug( "Transfer ACCEPTED by: %s", t->className() );
return true; return true;
} }
/* else
qDebug( "Transfer refused by: %s", t->className() );*/
} }
return false; return false;
@ -232,22 +231,22 @@ void Task::clientDisconnected()
// QString str; // QString str;
// int size = 1024; // int size = 1024;
// int r; // int r;
// //
// do { // do {
// buf = new char[size]; // buf = new char[size];
// va_list ap; // va_list ap;
// va_start(ap, fmt); // va_start(ap, fmt);
// r = vsnprintf(buf, size, fmt, ap); // r = vsnprintf(buf, size, fmt, ap);
// va_end(ap); // va_end(ap);
// //
// if(r != -1) // if(r != -1)
// str = QString(buf); // str = QString(buf);
// //
// delete [] buf; // delete [] buf;
// //
// size *= 2; // size *= 2;
// } while(r == -1); // } while(r == -1);
// //
// debug(str); // debug(str);
// } // }

@ -3,7 +3,7 @@
Copyright (c) 2004 SUSE Linux AG http://www.suse.com 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> Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
@ -25,7 +25,6 @@
class QString; class QString;
class Client; class Client;
class Request;
class Transfer; class Transfer;
class Task : public QObject class Task : public QObject

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Handles incoming webcam connections 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 "ymsgtransfer.h"
#include "yahootypes.h" #include "yahootypes.h"
#include "client.h" #include "client.h"
#include <qstring.h>
#include <qbuffer.h> #include <qbuffer.h>
#include <qfile.h> #include <qfile.h>
#include <qtimer.h> #include <qtimer.h>
#include <qpixmap.h>
#include <ktempfile.h> #include <ktempfile.h>
#include <kprocess.h> #include <kprocess.h>
#include <kstreamsocket.h> #include <kstreamsocket.h>
@ -34,7 +35,7 @@ using namespace KNetwork;
WebcamTask::WebcamTask(Task* parent) : Task(parent) WebcamTask::WebcamTask(Task* parent) : Task(parent)
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
transmittingData = false; transmittingData = false;
transmissionPending = false; transmissionPending = false;
timestamp = 1; timestamp = 1;
@ -46,13 +47,11 @@ WebcamTask::~WebcamTask()
bool WebcamTask::take( Transfer* transfer ) bool WebcamTask::take( Transfer* transfer )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
if ( !forMe( transfer ) ) if ( !forMe( transfer ) )
return false; return false;
YMSGTransfer *t = static_cast<YMSGTransfer*>(transfer); YMSGTransfer *t = static_cast<YMSGTransfer*>(transfer);
if( t->service() == Yahoo::ServiceWebcam ) if( t->service() == Yahoo::ServiceWebcam )
parseWebcamInformation( t ); parseWebcamInformation( t );
// else // else
@ -61,16 +60,14 @@ bool WebcamTask::take( Transfer* transfer )
return true; return true;
} }
bool WebcamTask::forMe( Transfer* transfer ) const bool WebcamTask::forMe( const Transfer* transfer ) const
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; const YMSGTransfer *t = 0L;
t = dynamic_cast<const YMSGTransfer*>(transfer);
YMSGTransfer *t = 0L;
t = dynamic_cast<YMSGTransfer*>(transfer);
if (!t) if (!t)
return false; return false;
if ( t->service() == Yahoo::ServiceWebcam ) if ( t->service() == Yahoo::ServiceWebcam )
return true; return true;
else else
return false; return false;
@ -78,8 +75,8 @@ bool WebcamTask::forMe( Transfer* transfer ) const
void WebcamTask::requestWebcam( const QString &who ) void WebcamTask::requestWebcam( const QString &who )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceWebcam); YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceWebcam);
t->setId( client()->sessionID() ); t->setId( client()->sessionID() );
t->setParam( 1, client()->userId().local8Bit()); t->setParam( 1, client()->userId().local8Bit());
@ -91,7 +88,7 @@ void WebcamTask::requestWebcam( const QString &who )
void WebcamTask::parseWebcamInformation( YMSGTransfer *t ) void WebcamTask::parseWebcamInformation( YMSGTransfer *t )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
YahooWebcamInformation info; YahooWebcamInformation info;
info.sender = keyPending; info.sender = keyPending;
@ -108,8 +105,8 @@ void WebcamTask::parseWebcamInformation( YMSGTransfer *t )
} }
else else
info.direction = Incoming; 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) ); KStreamSocket *socket = new KStreamSocket( info.server, QString::number(5100) );
socketMap[socket] = info; socketMap[socket] = info;
@ -117,8 +114,8 @@ void WebcamTask::parseWebcamInformation( YMSGTransfer *t )
connect( socket, SIGNAL( connected( const KResolverEntry& ) ), this, SLOT( slotConnectionStage1Established() ) ); connect( socket, SIGNAL( connected( const KResolverEntry& ) ), this, SLOT( slotConnectionStage1Established() ) );
connect( socket, SIGNAL( gotError(int) ), this, SLOT( slotConnectionFailed(int) ) ); connect( socket, SIGNAL( gotError(int) ), this, SLOT( slotConnectionFailed(int) ) );
connect( socket, SIGNAL( readyRead() ), this, SLOT( slotRead() ) ); connect( socket, SIGNAL( readyRead() ), this, SLOT( slotRead() ) );
socket->connect(); socket->connect();
} }
void WebcamTask::slotConnectionStage1Established() void WebcamTask::slotConnectionStage1Established()
@ -126,11 +123,11 @@ void WebcamTask::slotConnectionStage1Established()
KStreamSocket* socket = const_cast<KStreamSocket*>( dynamic_cast<const KStreamSocket*>( sender() ) ); KStreamSocket* socket = const_cast<KStreamSocket*>( dynamic_cast<const KStreamSocket*>( sender() ) );
if( !socket ) if( !socket )
return; 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( connected( const KResolverEntry& ) ), this, SLOT( slotConnectionStage1Established() ) );
disconnect( socket, SIGNAL( gotError(int) ), this, SLOT( slotConnectionFailed(int) ) ); disconnect( socket, SIGNAL( gotError(int) ), this, SLOT( slotConnectionFailed(int) ) );
socketMap[socket].status = ConnectedStage1; socketMap[socket].status = ConnectedStage1;
QByteArray buffer; QByteArray buffer;
QDataStream stream( buffer, IO_WriteOnly ); QDataStream stream( buffer, IO_WriteOnly );
@ -146,10 +143,10 @@ void WebcamTask::slotConnectionStage1Established()
s = QString("f=1\r\n"); 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 << (Q_INT8)0x08 << (Q_INT8)0x00 << (Q_INT8)0x01 << (Q_INT8)0x00 << (Q_INT32)s.length();
stream.writeRawBytes( s.local8Bit(), s.length() ); stream.writeRawBytes( s.local8Bit(), s.length() );
socket->writeBlock( buffer.data(), buffer.size() ); socket->writeBlock( buffer.data(), buffer.size() );
} }
@ -159,7 +156,7 @@ void WebcamTask::slotConnectionStage2Established()
if( !socket ) if( !socket )
return; 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( connected( const KResolverEntry& ) ), this, SLOT( slotConnectionStage2Established() ) );
disconnect( socket, SIGNAL( gotError(int) ), this, SLOT( slotConnectionFailed(int) ) ); disconnect( socket, SIGNAL( gotError(int) ), this, SLOT( slotConnectionFailed(int) ) );
socketMap[socket].status = ConnectedStage2; socketMap[socket].status = ConnectedStage2;
@ -176,7 +173,7 @@ void WebcamTask::slotConnectionStage2Established()
// Send request information // 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") 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); .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(); stream << (Q_INT8)0x08 << (Q_INT8)0x00 << (Q_INT8)0x01 << (Q_INT8)0x00 << (Q_INT32)s.length();
} }
else 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() 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; << (Q_INT8)0x01 << (Q_INT8)0x00 << (Q_INT8)0x00 << (Q_INT8)0x00 << (Q_INT8)0x01;
} }
socket->writeBlock( buffer.data(), buffer.size() ); socket->writeBlock( buffer.data(), buffer.size() );
socket->writeBlock( s.local8Bit(), s.length() ); socket->writeBlock( s.local8Bit(), s.length() );
} }
void WebcamTask::slotConnectionFailed( int error ) void WebcamTask::slotConnectionFailed( int error )
{ {
KStreamSocket* socket = const_cast<KStreamSocket*>( dynamic_cast<const KStreamSocket*>( sender() ) ); 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.") kdDebug(YAHOO_RAW_DEBUG) << "Webcam connection to the user " << socketMap[socket].sender << " failed. Error " << error << " - " << socket->errorString() << endl;
.arg(socketMap[socket].sender), QString("%1 - %2").arg(error).arg( socket->errorString()), Client::Error ); client()->notifyError( i18n("Webcam connection to the user %1 could not be established.\n\nPlease relogin and try again.")
socketMap.remove( socket ); .arg(socketMap[socket].sender), QString("%1 - %2").arg(error).arg( socket->errorString()), Client::Error );
socket->deleteLater(); socketMap.remove( socket );
socket->deleteLater();
} }
void WebcamTask::slotRead() void WebcamTask::slotRead()
@ -208,7 +207,7 @@ void WebcamTask::slotRead()
KStreamSocket* socket = const_cast<KStreamSocket*>( dynamic_cast<const KStreamSocket*>( sender() ) ); KStreamSocket* socket = const_cast<KStreamSocket*>( dynamic_cast<const KStreamSocket*>( sender() ) );
if( !socket ) if( !socket )
return; return;
switch( socketMap[socket].status ) switch( socketMap[socket].status )
{ {
case ConnectedStage1: case ConnectedStage1:
@ -226,10 +225,10 @@ void WebcamTask::slotRead()
void WebcamTask::connectStage2( KStreamSocket *socket ) void WebcamTask::connectStage2( KStreamSocket *socket )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
QByteArray data( socket->bytesAvailable() ); QByteArray data( socket->bytesAvailable() );
socket->readBlock ( data.data (), data.size () ); 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; socketMap[socket].status = ConnectedStage2;
@ -245,14 +244,14 @@ void WebcamTask::connectStage2( KStreamSocket *socket )
case (Q_INT8)0x07: case (Q_INT8)0x07:
while( (const char)data[i] != (Q_INT8)0x00 ) while( (const char)data[i] != (Q_INT8)0x00 )
server += data[i++]; server += data[i++];
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Server:" << server << endl; kdDebug(YAHOO_RAW_DEBUG) << "Server:" << server << endl;
if( server.isEmpty() ) if( server.isEmpty() )
{ {
emit webcamNotAvailable(socketMap[socket].sender); emit webcamNotAvailable(socketMap[socket].sender);
break; 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) ); newSocket = new KStreamSocket( server, QString::number(5100) );
socketMap[newSocket] = socketMap[socket]; socketMap[newSocket] = socketMap[socket];
newSocket->enableRead( true ); newSocket->enableRead( true );
@ -264,8 +263,8 @@ void WebcamTask::connectStage2( KStreamSocket *socket )
newSocket->enableWrite( true ); newSocket->enableWrite( true );
connect( newSocket, SIGNAL( readyWrite() ), this, SLOT( transmitWebcamImage() ) ); connect( newSocket, SIGNAL( readyWrite() ), this, SLOT( transmitWebcamImage() ) );
} }
newSocket->connect(); newSocket->connect();
break; break;
default: default:
break; break;
@ -277,28 +276,29 @@ void WebcamTask::connectStage2( KStreamSocket *socket )
void WebcamTask::processData( KStreamSocket *socket ) void WebcamTask::processData( KStreamSocket *socket )
{ {
QByteArray data( socket->bytesAvailable() ); QByteArray data( socket->bytesAvailable() );
socket->readBlock ( data.data (), data.size () ); socket->readBlock ( data.data (), data.size () );
if( data.size() <= 0 ) if( data.size() <= 0 )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "No data read." << endl; kdDebug(YAHOO_RAW_DEBUG) << "No data read." << endl;
return; return;
} }
parseData( data, socket ); parseData( data, socket );
} }
void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket ) void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket )
{ {
uint headerLength = 0; int headerLength = 0;
uint read = 0; int read = 0;
YahooWebcamInformation *info = &socketMap[socket]; YahooWebcamInformation *info = &socketMap[socket];
if( !info->headerRead ) if( !info->headerRead )
{ {
headerLength = data[0]; headerLength = data[0];
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "headerLength " << headerLength << endl; kdDebug(YAHOO_RAW_DEBUG) << "headerLength " << headerLength << endl;
if( data.size() < headerLength ) if( data.size() < headerLength )
return; return;
if( headerLength >= 8 ) if( headerLength >= 8 )
{ {
kdDebug() << data[0] << data[1] << data[2] << data[3] << data[4] << data[5] << data[6] << data[7] << endl; 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; kdDebug() << data[8] << data[9] << data[10] << data[11] << data[12] << endl;
info->timestamp = yahoo_get32(data.data() + 9); 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; QStringList::iterator it;
switch( data[8] ) switch( data[8] )
{ {
@ -328,7 +328,7 @@ void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket )
info->headerRead = true; info->headerRead = true;
} }
break; break;
case 0x02: case 0x02:
info->type = Image; info->type = Image;
info->headerRead = true; info->headerRead = true;
break; break;
@ -339,7 +339,7 @@ void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket )
} }
break; break;
case 0x05: 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 ) if( info->timestamp == 1 )
{ {
info->status = Sending; info->status = Sending;
@ -351,7 +351,7 @@ void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket )
emit stopTransmission(); emit stopTransmission();
sendEmptyWebcamImage(); sendEmptyWebcamImage();
} }
// Send Invitation packets // Send Invitation packets
for(it = pendingInvitations.begin(); it != pendingInvitations.end(); it++) for(it = pendingInvitations.begin(); it != pendingInvitations.end(); it++)
{ {
@ -359,12 +359,12 @@ void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket )
snt->setTarget( *it ); snt->setTarget( *it );
snt->setType( SendNotifyTask::NotifyWebcamInvite ); snt->setType( SendNotifyTask::NotifyWebcamInvite );
snt->go( true ); snt->go( true );
it = pendingInvitations.remove( it ); it = pendingInvitations.erase( it );
it--; it--;
} }
break; break;
case 0x07: case 0x07:
info->type = ConnectionClosed; info->type = ConnectionClosed;
emit webcamClosed( info->sender, info->reason ); emit webcamClosed( info->sender, info->reason );
cleanUpConnection( socket ); cleanUpConnection( socket );
@ -383,41 +383,41 @@ void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket )
if( !info->headerRead && data.size() > headerLength ) if( !info->headerRead && data.size() > headerLength )
{ {
// More headers to read // 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 ); QByteArray newData( data.size() - headerLength );
QDataStream stream( newData, IO_WriteOnly ); QDataStream stream( newData, IO_WriteOnly );
stream.writeRawBytes( data.data() + headerLength, data.size() - headerLength ); stream.writeRawBytes( data.data() + headerLength, data.size() - headerLength );
parseData( newData, socket ); parseData( newData, socket );
return; 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 ) 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 ) if( info->headerRead )
info->headerRead = false; info->headerRead = false;
return; return;
} }
if( headerLength >= data.size() ) 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... return; //Nothing to read here...
} }
if( !info->buffer ) 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 = new QBuffer();
info->buffer->open( IO_WriteOnly ); 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(); read = headerLength + info->dataLength - info->buffer->size();
info->buffer->writeBlock( data.data() + headerLength, data.size() - 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) ) if( info->buffer->size() >= static_cast<uint>(info->dataLength) )
{ {
info->buffer->close(); info->buffer->close();
QString who; QString who;
switch( info->type ) switch( info->type )
@ -426,7 +426,7 @@ void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket )
{ {
who.append( info->buffer->buffer() ); who.append( info->buffer->buffer() );
who = who.mid( 2, who.find('\n') - 3); 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 ) if( accessGranted.findIndex( who ) >= 0 )
{ {
grantAccess( who ); grantAccess( who );
@ -438,13 +438,13 @@ void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket )
case NewWatcher: case NewWatcher:
who.append( info->buffer->buffer() ); who.append( info->buffer->buffer() );
who = who.left( who.length() - 1 ); 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 ); emit viewerJoined( who );
break; break;
case WatcherLeft: case WatcherLeft:
who.append( info->buffer->buffer() ); who.append( info->buffer->buffer() );
who = who.left( who.length() - 1 ); 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 ); accessGranted.remove( who );
emit viewerLeft( who ); emit viewerLeft( who );
break; break;
@ -452,17 +452,28 @@ void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket )
{ {
QPixmap webcamImage; QPixmap webcamImage;
//webcamImage.loadFromData( info->buffer->buffer() ); //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 jpcTmpImageFile;
KTempFile bmpTmpImageFile; KTempFile bmpTmpImageFile;
QFile *file = jpcTmpImageFile.file(); QFile *file = jpcTmpImageFile.file();
file->writeBlock((info->buffer->buffer()).data(), info->buffer->size()); file->writeBlock((info->buffer->buffer()).data(), info->buffer->size());
file->close(); file->close();
KProcess p; KProcess p;
p << "jasper"; p << "jasper";
p << "--input" << jpcTmpImageFile.name() << "--output" << bmpTmpImageFile.name() << "--output-format" << "bmp"; p << "--input" << jpcTmpImageFile.name() << "--output" << bmpTmpImageFile.name() << "--output-format" << "bmp";
p.start( KProcess::Block ); p.start( KProcess::Block );
if( p.exitStatus() != 0 ) if( p.exitStatus() != 0 )
{ {
@ -475,15 +486,15 @@ void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket )
emit webcamImageReceived( info->sender, webcamImage ); emit webcamImageReceived( info->sender, webcamImage );
} }
QFile::remove(jpcTmpImageFile.name()); QFile::remove(jpcTmpImageFile.name());
QFile::remove(bmpTmpImageFile.name()); QFile::remove(bmpTmpImageFile.name());
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Image Received. Size: " << webcamImage.size() << endl; kdDebug(YAHOO_RAW_DEBUG) << "Image Received. Size: " << webcamImage.size() << endl;
} }
break; break;
default: default:
break; break;
} }
info->headerRead = false; info->headerRead = false;
delete info->buffer; delete info->buffer;
info->buffer = 0L; info->buffer = 0L;
@ -491,7 +502,7 @@ void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket )
if( data.size() > read ) if( data.size() > read )
{ {
// More headers to 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 ); QByteArray newData( data.size() - read );
QDataStream stream( newData, IO_WriteOnly ); QDataStream stream( newData, IO_WriteOnly );
stream.writeRawBytes( data.data() + read, data.size() - read ); stream.writeRawBytes( data.data() + read, data.size() - read );
@ -506,33 +517,33 @@ void WebcamTask::cleanUpConnection( KStreamSocket *socket )
if( info->buffer ) if( info->buffer )
delete info->buffer; delete info->buffer;
socketMap.remove( socket ); socketMap.remove( socket );
delete socket; delete socket;
} }
void WebcamTask::closeWebcam( const QString & who ) void WebcamTask::closeWebcam( const QString & who )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
SocketInfoMap::Iterator it; SocketInfoMap::Iterator it;
for( it = socketMap.begin(); it != socketMap.end(); 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 ) if( it.data().sender == who )
{ {
cleanUpConnection( it.key() ); cleanUpConnection( it.key() );
return; return;
} }
} }
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Error. You tried to close a connection that didn't exist." << endl; kdDebug(YAHOO_RAW_DEBUG) << "Error. You tried to close a connection that did not 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 ); 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() void WebcamTask::registerWebcam()
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceWebcam); YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceWebcam);
t->setId( client()->sessionID() ); t->setId( client()->sessionID() );
t->setParam( 1, client()->userId().local8Bit()); t->setParam( 1, client()->userId().local8Bit());
@ -543,14 +554,14 @@ void WebcamTask::registerWebcam()
void WebcamTask::addPendingInvitation( const QString &userId ) 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 ); pendingInvitations.append( userId );
accessGranted.append( userId ); accessGranted.append( userId );
} }
void WebcamTask::grantAccess( const QString &userId ) void WebcamTask::grantAccess( const QString &userId )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
KStreamSocket *socket = 0L; KStreamSocket *socket = 0L;
SocketInfoMap::Iterator it; SocketInfoMap::Iterator it;
for( it = socketMap.begin(); it != socketMap.end(); it++ ) for( it = socketMap.begin(); it != socketMap.end(); it++ )
@ -563,7 +574,7 @@ void WebcamTask::grantAccess( const QString &userId )
} }
if( !socket ) 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; return;
} }
QByteArray ar; 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() 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; << (Q_INT8)0x00 << (Q_INT8)0x00 << (Q_INT8)0x00 << (Q_INT8)0x00 << (Q_INT8)0x01;
socket->writeBlock( ar.data(), ar.size() ); socket->writeBlock( ar.data(), ar.size() );
socket->writeBlock( user.local8Bit(), user.length() ); socket->writeBlock( user.local8Bit(), user.length() );
} }
void WebcamTask::closeOutgoingWebcam() void WebcamTask::closeOutgoingWebcam()
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
KStreamSocket *socket = 0L; KStreamSocket *socket = 0L;
SocketInfoMap::Iterator it; SocketInfoMap::Iterator it;
for( it = socketMap.begin(); it != socketMap.end(); it++ ) for( it = socketMap.begin(); it != socketMap.end(); it++ )
@ -591,17 +602,17 @@ void WebcamTask::closeOutgoingWebcam()
} }
if( !socket ) 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; return;
} }
cleanUpConnection( socket ); cleanUpConnection( socket );
transmittingData = false; transmittingData = false;
} }
void WebcamTask::sendEmptyWebcamImage() void WebcamTask::sendEmptyWebcamImage()
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
KStreamSocket *socket = 0L; KStreamSocket *socket = 0L;
SocketInfoMap::Iterator it; SocketInfoMap::Iterator it;
@ -615,11 +626,11 @@ void WebcamTask::sendEmptyWebcamImage()
} }
if( !socket ) 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; return;
} }
if( socketMap[socket].status != SendingEmpty ) if( socketMap[socket].status != SendingEmpty )
return; return;
pictureBuffer.resize( 0 ); pictureBuffer.resize( 0 );
transmissionPending = true; transmissionPending = true;
@ -630,8 +641,8 @@ void WebcamTask::sendEmptyWebcamImage()
void WebcamTask::sendWebcamImage( const QByteArray &image ) void WebcamTask::sendWebcamImage( const QByteArray &image )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
pictureBuffer.duplicate( image ); pictureBuffer = image;
transmissionPending = true; transmissionPending = true;
KStreamSocket *socket = 0L; KStreamSocket *socket = 0L;
SocketInfoMap::Iterator it; SocketInfoMap::Iterator it;
@ -645,7 +656,7 @@ void WebcamTask::sendWebcamImage( const QByteArray &image )
} }
if( !socket ) 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; return;
} }
@ -656,7 +667,7 @@ void WebcamTask::transmitWebcamImage()
{ {
if( !transmissionPending ) if( !transmissionPending )
return; return;
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "arraysize: " << pictureBuffer.size() << endl; kdDebug(YAHOO_RAW_DEBUG) << "arraysize: " << pictureBuffer.size() << endl;
// Find outgoing socket // Find outgoing socket
KStreamSocket *socket = 0L; KStreamSocket *socket = 0L;
@ -671,7 +682,7 @@ void WebcamTask::transmitWebcamImage()
} }
if( !socket ) 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; return;
} }
@ -683,7 +694,7 @@ void WebcamTask::transmitWebcamImage()
socket->writeBlock( buffer.data(), buffer.size() ); socket->writeBlock( buffer.data(), buffer.size() );
if( pictureBuffer.size() ) if( pictureBuffer.size() )
socket->writeBlock( pictureBuffer.data(), pictureBuffer.size() ); socket->writeBlock( pictureBuffer.data(), pictureBuffer.size() );
transmissionPending = false; transmissionPending = false;
} }
#include "webcamtask.moc" #include "webcamtask.moc"

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
Handles incoming webcam connections 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: public:
WebcamTask(Task *parent); WebcamTask(Task *parent);
~WebcamTask(); ~WebcamTask();
bool take(Transfer *transfer); bool take(Transfer *transfer);
bool forMe( Transfer* transfer ) const;
bool transmitting() { return transmittingData; } bool transmitting() { return transmittingData; }
void requestWebcam( const QString &who ); void requestWebcam( const QString &who );
void closeWebcam( const QString &who ); void closeWebcam( const QString &who );
void registerWebcam(); void registerWebcam();
void sendWebcamImage( const QByteArray &image ); void sendWebcamImage( const QByteArray &image );
void addPendingInvitation( const QString &userId ); void addPendingInvitation( const QString &userId );
@ -91,13 +90,15 @@ private slots:
void slotRead(); void slotRead();
void sendEmptyWebcamImage(); void sendEmptyWebcamImage();
void transmitWebcamImage(); void transmitWebcamImage();
protected:
virtual bool forMe( const Transfer* transfer ) const;
private: private:
void parseWebcamInformation( YMSGTransfer *transfer ); void parseWebcamInformation( YMSGTransfer *transfer );
void parseData( QByteArray &data, KStreamSocket *socket ); void parseData( QByteArray &data, KStreamSocket *socket );
void connectStage2( KStreamSocket *socket ); void connectStage2( KStreamSocket *socket );
void processData( KStreamSocket *socket ); void processData( KStreamSocket *socket );
void cleanUpConnection( KStreamSocket *socket ); void cleanUpConnection( KStreamSocket *socket );
QString keyPending; // the buddy we have requested the webcam from QString keyPending; // the buddy we have requested the webcam from
SocketInfoMap socketMap; SocketInfoMap socketMap;

@ -1,7 +1,7 @@
/* /*
yabcpp - Encapsulate Yahoo Adressbook information 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> 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"); privateZIP = e.attribute("hz");
privateCountry = e.attribute("hn"); privateCountry = e.attribute("hn");
QString birtday = e.attribute("bi"); 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"); 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"); additional1 = e.attribute("c1");
additional2 = e.attribute("c2"); additional2 = e.attribute("c2");
additional3 = e.attribute("c3"); additional3 = e.attribute("c3");
@ -67,8 +67,8 @@ void YABEntry::fromQDomElement( const QDomElement &e )
void YABEntry::fromQDomDocument( const QDomDocument &d ) void YABEntry::fromQDomDocument( const QDomDocument &d )
{ {
kdDebug() << d.toString() << kdDebug() << d.toString() <<
d.elementsByTagName("yi").item(0).toElement().text(); d.elementsByTagName("yi").item(0).toElement().text() << endl;
yahooId = d.elementsByTagName("yi").item(0).toElement().text(); yahooId = d.elementsByTagName("yi").item(0).toElement().text();
firstName = d.elementsByTagName("fn").item(0).toElement().text(); firstName = d.elementsByTagName("fn").item(0).toElement().text();
secondName = d.elementsByTagName("mn").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(); privateZIP = d.elementsByTagName("hz").item(0).toElement().text();
privateCountry = d.elementsByTagName("hn").item(0).toElement().text(); privateCountry = d.elementsByTagName("hn").item(0).toElement().text();
QString birtday = d.elementsByTagName("bi").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(); 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(); additional1 = d.elementsByTagName("c1").item(0).toElement().text();
additional2 = d.elementsByTagName("c2").item(0).toElement().text(); additional2 = d.elementsByTagName("c2").item(0).toElement().text();
additional3 = d.elementsByTagName("c3").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( "pu", privateURL );
e.setAttribute( "ti", title ); e.setAttribute( "ti", title );
e.setAttribute( "co", corporation ); 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( "wc", workCity );
e.setAttribute( "ws", workState ); e.setAttribute( "ws", workState );
e.setAttribute( "wz", workZIP ); e.setAttribute( "wz", workZIP );
e.setAttribute( "wn", workCountry ); e.setAttribute( "wn", workCountry );
e.setAttribute( "wu", workURL ); 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( "hc", privateCity );
e.setAttribute( "hs", privateState ); e.setAttribute( "hs", privateState );
e.setAttribute( "hz", privateZIP ); e.setAttribute( "hz", privateZIP );
@ -152,7 +152,7 @@ void YABEntry::fillQDomElement( QDomElement &e ) const
e.setAttribute( "c2", additional2 ); e.setAttribute( "c2", additional2 );
e.setAttribute( "c3", additional3 ); e.setAttribute( "c3", additional3 );
e.setAttribute( "c4", additional4 ); 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( "ima", imAIM );
e.setAttribute( "img", imGoogleTalk ); e.setAttribute( "img", imGoogleTalk );
e.setAttribute( "imq", imICQ ); e.setAttribute( "imq", imICQ );
@ -164,38 +164,38 @@ void YABEntry::fillQDomElement( QDomElement &e ) const
void YABEntry::dump() const void YABEntry::dump() const
{ {
kdDebug() << "firstName: " << firstName << endl << kdDebug() << "firstName: " << firstName << endl <<
"secondName: " << secondName << endl << "secondName: " << secondName << endl <<
"lastName: " << lastName << endl << "lastName: " << lastName << endl <<
"nickName: " << nickName << endl << "nickName: " << nickName << endl <<
"title: " << title << endl << "title: " << title << endl <<
"phoneMobile: " << phoneMobile << endl << "phoneMobile: " << phoneMobile << endl <<
"email: " << email << endl << "email: " << email << endl <<
"yahooId: " << yahooId << endl << "yahooId: " << yahooId << endl <<
"pager: " << pager << endl << "pager: " << pager << endl <<
"fax: " << fax << endl << "fax: " << fax << endl <<
"additionalNumber: " << additionalNumber << endl << "additionalNumber: " << additionalNumber << endl <<
"altEmail1: " << altEmail1 << endl << "altEmail1: " << altEmail1 << endl <<
"altEmail2: " << altEmail2 << endl << "altEmail2: " << altEmail2 << endl <<
"privateAdress: " << privateAdress << endl << "privateAdress: " << privateAdress << endl <<
"privateCity: " << privateCity << endl << "privateCity: " << privateCity << endl <<
"privateState: " << privateState << endl << "privateState: " << privateState << endl <<
"privateZIP: " << privateZIP << endl << "privateZIP: " << privateZIP << endl <<
"privateCountry: " << privateCountry << endl << "privateCountry: " << privateCountry << endl <<
"privatePhone: " << privatePhone << endl << "privatePhone: " << privatePhone << endl <<
"privateURL: " << privateURL << endl << "privateURL: " << privateURL << endl <<
"corporation: " << corporation << endl << "corporation: " << corporation << endl <<
"workAdress: " << workAdress << endl << "workAdress: " << workAdress << endl <<
"workCity: " << workCity << endl << "workCity: " << workCity << endl <<
"workState: " << workState << endl << "workState: " << workState << endl <<
"workZIP: " << workZIP << endl << "workZIP: " << workZIP << endl <<
"workCountry: " << workCountry << endl << "workCountry: " << workCountry << endl <<
"workURL: " << workURL << endl << "workURL: " << workURL << endl <<
"birthday: " << birthday.toString() << endl << "birthday: " << birthday.toString() << endl <<
"anniversary: " << anniversary.toString() << endl << "anniversary: " << anniversary.toString() << endl <<
"notes: " << notes << endl << "notes: " << notes << endl <<
"additional1: " << additional1 << endl << "additional1: " << additional1 << endl <<
"additional2: " << additional2 << endl << "additional2: " << additional2 << endl <<
"additional3: " << additional3 << endl << "additional3: " << additional3 << endl <<
"additional4: " << additional4 << endl; "additional4: " << additional4 << endl;
} }

@ -1,7 +1,7 @@
/* /*
yabentry.h - Encapsulate Yahoo Adressbook information 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> Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
************************************************************************* *************************************************************************
@ -71,7 +71,7 @@ struct YABEntry
QString workPhone; QString workPhone;
QString workURL; QString workURL;
// Miscellanous // Miscellaneous
QDate birthday; QDate birthday;
QDate anniversary; QDate anniversary;
QString notes; QString notes;

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
yabtask.h - Handles the Yahoo Address Book 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> Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
************************************************************************* *************************************************************************
@ -29,7 +29,7 @@
YABTask::YABTask(Task* parent) : Task(parent) YABTask::YABTask(Task* parent) : Task(parent)
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
} }
YABTask::~YABTask() YABTask::~YABTask()
@ -38,29 +38,25 @@ YABTask::~YABTask()
bool YABTask::take( Transfer* transfer ) bool YABTask::take( Transfer* transfer )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
if ( !forMe( transfer ) ) if ( !forMe( transfer ) )
return false; return false;
YMSGTransfer *t = static_cast<YMSGTransfer*>(transfer); YMSGTransfer *t = static_cast<YMSGTransfer*>(transfer);
if( t->service() == Yahoo::ServiceContactDetails ) if( t->service() == Yahoo::ServiceContactDetails )
parseContactDetails( t ); parseContactDetails( t );
return true; return true;
} }
bool YABTask::forMe( Transfer* transfer ) const bool YABTask::forMe( const Transfer* transfer ) const
{ {
// kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; const YMSGTransfer *t = 0L;
t = dynamic_cast<const YMSGTransfer*>(transfer);
YMSGTransfer *t = 0L;
t = dynamic_cast<YMSGTransfer*>(transfer);
if (!t) if (!t)
return false; return false;
if ( t->service() == Yahoo::ServiceContactDetails ) if ( t->service() == Yahoo::ServiceContactDetails )
return true; return true;
else else
return false; return false;
@ -68,14 +64,14 @@ bool YABTask::forMe( Transfer* transfer ) const
void YABTask::parseContactDetails( YMSGTransfer* t ) void YABTask::parseContactDetails( YMSGTransfer* t )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
QString from; /* key = 7 */ QString from; /* key = 7 */
int count; int count;
from = t->firstParam( 4 ); from = t->firstParam( 4 );
count = t->paramCount( 5 ); count = t->paramCount( 5 );
for( int i = 0; i < count; i++ ) for( int i = 0; i < count; i++ )
{ {
QString who = t->nthParam( 5, i ); QString who = t->nthParam( 5, i );
@ -96,7 +92,7 @@ void YABTask::parseContactDetails( YMSGTransfer* t )
void YABTask::getAllEntries( long lastMerge, long lastRemoteRevision ) 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; 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") 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 ); .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 ) void YABTask::slotData( KIO::Job* /*job*/, const QByteArray &info )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
m_data += info; m_data += info;
} }
void YABTask::slotResult( KIO::Job* job ) void YABTask::slotResult( KIO::Job* job )
{ {
if( job->error () || m_transferJob->isErrorPage () ) 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; QDomDocument doc;
QDomNodeList list; QDomNodeList list;
QDomElement e; QDomElement e;
uint it = 0; int it = 0;
kdDebug(YAHOO_RAW_DEBUG) << m_data << endl; kdDebug(YAHOO_RAW_DEBUG) << m_data << endl;
doc.setContent( m_data ); doc.setContent( m_data );
list = doc.elementsByTagName( "ab" ); // Get the Addressbook list = doc.elementsByTagName( "ab" ); // Get the Addressbook
for( it = 0; it < list.count(); it++ ) { for( it = 0; it < list.count(); it++ ) {
if( !list.item( it ).isElement() ) if( !list.item( it ).isElement() )
continue; continue;
e = list.item( it ).toElement(); e = list.item( it ).toElement();
if( !e.attribute( "lm" ).isEmpty() ) if( !e.attribute( "lm" ).isEmpty() )
emit gotRevision( e.attribute( "lm" ).toLong(), true ); emit gotRevision( e.attribute( "lm" ).toLong(), true );
if( !e.attribute( "rt" ).isEmpty() ) if( !e.attribute( "rt" ).isEmpty() )
emit gotRevision( e.attribute( "rt" ).toLong(), false ); emit gotRevision( e.attribute( "rt" ).toLong(), false );
} }
list = doc.elementsByTagName( "ct" ); // Get records list = doc.elementsByTagName( "ct" ); // Get records
for( it = 0; it < list.count(); it++ ) { for( it = 0; it < list.count(); it++ ) {
if( !list.item( it ).isElement() ) if( !list.item( it ).isElement() )
continue; continue;
e = list.item( it ).toElement(); e = list.item( it ).toElement();
YABEntry *entry = new YABEntry; YABEntry *entry = new YABEntry;
entry->fromQDomElement( e ); entry->fromQDomElement( e );
entry->source = YABEntry::SourceYAB; entry->source = YABEntry::SourceYAB;

@ -2,7 +2,7 @@
Kopete Yahoo Protocol Kopete Yahoo Protocol
yabtask.h - Handles the Yahoo Address Book 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> Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
************************************************************************* *************************************************************************
@ -22,12 +22,11 @@
#include "yabentry.h" #include "yabentry.h"
class YMSGTransfer; class YMSGTransfer;
struct KURL;
namespace KIO { namespace KIO {
class Job; class Job;
class TransferJob; class TransferJob;
} }
class QDomElement;
/** /**
@author André Duffeck @author André Duffeck
@ -38,9 +37,8 @@ class YABTask : public Task
public: public:
YABTask(Task *parent); YABTask(Task *parent);
~YABTask(); ~YABTask();
bool take(Transfer *transfer); bool take(Transfer *transfer);
bool forMe( Transfer* transfer ) const;
void getAllEntries( long lastMerge, long lastRemoteRevision ); void getAllEntries( long lastMerge, long lastRemoteRevision );
void saveEntry( const YABEntry & ); void saveEntry( const YABEntry & );
@ -48,6 +46,7 @@ signals:
void gotEntry( YABEntry * ); void gotEntry( YABEntry * );
void gotRevision( long rev, bool merged ); void gotRevision( long rev, bool merged );
protected: protected:
virtual bool forMe( const Transfer* transfer ) const;
void parseContactDetails( YMSGTransfer* t ); void parseContactDetails( YMSGTransfer* t );
private slots: private slots:
void slotData( KIO::Job*, const QByteArray & ); void slotData( KIO::Job*, const QByteArray & );

@ -18,6 +18,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * 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 IDENT 1 /* identify function */
#define XOR 2 /* xor with arg1 */ #define XOR 2 /* xor with arg1 */
#define MULADD 3 /* multipy by arg1 then add arg2 */ #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 ); int yahoo_xfrm( int table, int depth, int seed );
#endif // YAHOO_FN_H

@ -1,7 +1,7 @@
/* /*
yahoobuddyiconloader.cpp - Fetches YahooBuddyIcons 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 ) 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; KIO::TransferJob *transfer;
QString Url = url.url(); QString Url = url.url();
QString ext = Url.left( Url.findRev( "?" ) ); QString ext = Url.left( Url.findRev( "?" ) );
ext = ext.right( ext.length() - ext.findRev( "." ) ); ext = ext.right( ext.length() - ext.findRev( "." ) );
transfer = KIO::get( url, false, false ); transfer = KIO::get( url, false, false );
connect( transfer, SIGNAL( result( KIO::Job* ) ), this, SLOT( slotComplete( KIO::Job* ) ) ); 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& ) ) ); 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].url = url;
m_jobs[transfer].who = who; m_jobs[transfer].who = who;
m_jobs[transfer].checksum = checksum; 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 ) void YahooBuddyIconLoader::slotData( KIO::Job *job, const QByteArray& data )
{ {
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
KIO::TransferJob *transfer = static_cast< KIO::TransferJob * >(job); KIO::TransferJob *transfer = static_cast< KIO::TransferJob * >(job);
if( m_jobs[transfer].file ) // FIXME need to check
m_jobs[transfer].file->file()->writeBlock( data.data() , data.size() ); //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 ) 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); KIO::TransferJob *transfer = static_cast< KIO::TransferJob * >(job);
if ( job->error () || transfer->isErrorPage () ) 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 ) 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 else
{ {
if ( m_jobs[transfer].file ) emit fetchedBuddyIcon( m_jobs[transfer].who, m_jobs[transfer].icon, m_jobs[transfer].checksum );
{
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 );
}
} }
m_jobs.remove( transfer ); m_jobs.remove( transfer );

@ -1,7 +1,7 @@
/* /*
yahoobuddyiconloader.h - Fetches YahooBuddyIcons 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 // KDE Includes
#include <kurl.h> #include <kurl.h>
class KTempFile; class KJob;
class Client; class Client;
namespace KIO { namespace KIO {
class Job; class Job;
@ -35,7 +35,7 @@ struct IconLoadJob {
KURL url; KURL url;
QString who; QString who;
int checksum; int checksum;
KTempFile *file; QByteArray icon;
}; };
/** /**
@ -60,9 +60,9 @@ public:
signals: signals:
/** /**
* The account can connect to this signal and append the icon * 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: private slots:
void slotData( KIO::Job *job, const QByteArray &data ); void slotData( KIO::Job *job, const QByteArray &data );

@ -22,10 +22,10 @@
#include "yahoobytestream.h" #include "yahoobytestream.h"
KNetworkByteStream::KNetworkByteStream( QObject *parent, const char */*name*/ ) KNetworkByteStream::KNetworkByteStream( QObject *parent )
: ByteStream ( 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 // reset close tracking flag
mClosing = false; mClosing = false;
@ -45,7 +45,7 @@ KNetworkByteStream::KNetworkByteStream( QObject *parent, const char */*name*/ )
bool KNetworkByteStream::connect( QString host, QString service ) 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 ); return socket()->connect( host, service );
} }
@ -58,7 +58,7 @@ bool KNetworkByteStream::isOpen() const
void KNetworkByteStream::close () 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 // close the socket and set flag that we are closing it ourselves
mClosing = true; mClosing = true;
@ -69,8 +69,8 @@ int KNetworkByteStream::tryWrite ()
{ {
// send all data from the buffers to the socket // send all data from the buffers to the socket
QByteArray writeData = takeWrite(); 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 () ); socket()->writeBlock( writeData.data(), writeData.size () );
return writeData.size(); return writeData.size();
@ -93,13 +93,13 @@ void KNetworkByteStream::slotConnected()
void KNetworkByteStream::slotConnectionClosed() 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 // depending on who closed the socket, emit different signals
if ( mClosing ) if ( mClosing )
{ {
kdDebug( 14181 ) << "..by ourselves!" << endl; 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 (); emit connectionClosed ();
} }
else else
@ -111,9 +111,10 @@ void KNetworkByteStream::slotConnectionClosed()
void KNetworkByteStream::slotReadyRead() void KNetworkByteStream::slotReadyRead()
{ {
kdDebug( 14181 ) << endl; kdDebug( 14181 );
// stuff all available data into our buffers // stuff all available data into our buffers
QByteArray readBuffer( socket()->bytesAvailable () ); QByteArray readBuffer;
readBuffer.resize( socket()->bytesAvailable () );
socket()->readBlock( readBuffer.data (), readBuffer.size () ); socket()->readBlock( readBuffer.data (), readBuffer.size () );
@ -130,7 +131,7 @@ void KNetworkByteStream::slotBytesWritten( int bytes )
void KNetworkByteStream::slotError( int code ) void KNetworkByteStream::slotError( int code )
{ {
kdDebug( 14181 ) << k_funcinfo << "Socket error " << code << endl; kdDebug( 14181 ) << "Socket error " << code << endl;
emit error( code ); emit error( code );
} }

@ -15,8 +15,8 @@
************************************************************************* *************************************************************************
*/ */
#ifndef KNETWORKBYTESTREAM_H #ifndef YAHOOBYTESTREAM_H
#define KNETWORKBYTESTREAM_H #define YAHOOBYTESTREAM_H
#include <kbufferedsocket.h> #include <kbufferedsocket.h>
@ -27,14 +27,14 @@
* Low level socket class, using KDE's KNetwork socket classes * Low level socket class, using KDE's KNetwork socket classes
* @author Till Gerken * @author Till Gerken
*/ */
class KNetworkByteStream : public ByteStream class KNetworkByteStream : public ByteStream
{ {
Q_OBJECT Q_OBJECT
public: public:
KNetworkByteStream ( QObject *parent = 0, const char *name = 0 ); KNetworkByteStream ( QObject *parent = 0 );
~KNetworkByteStream (); ~KNetworkByteStream ();
@ -63,7 +63,6 @@ private:
}; };
#endif #endif // YAHOOBYTESTREAM_H
// kate: indent-width 4; replace-tabs off; tab-width 4; space-indent off; // kate: indent-width 4; replace-tabs off; tab-width 4; space-indent off;

@ -1,13 +1,13 @@
/* /*
oscarclientstream.cpp - Kopete Oscar Protocol oscarclientstream.cpp - Kopete Oscar Protocol
Copyright (c) 2004 Matt Rogers <matt.rogers@kdemail.net> Copyright (c) 2004 Matt Rogers <matt.rogers@kdemail.net>
Based on code Copyright (c) 2004 SuSE Linux AG <http://www.suse.com> 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> Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
************************************************************************* *************************************************************************
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
@ -21,7 +21,7 @@
#include <qapplication.h> // for qdebug #include <qapplication.h> // for qdebug
#include <qguardedptr.h> #include <qguardedptr.h>
#include <qobject.h> #include <qobject.h>
#include <qptrqueue.h> #include <qptrqueue.h>
#include <qtimer.h> #include <qtimer.h>
@ -57,7 +57,7 @@ public:
{ {
conn = 0; conn = 0;
bs = 0; bs = 0;
username = QString::null; username = QString::null;
password = QString::null; password = QString::null;
server = QString::null; server = QString::null;
@ -72,7 +72,7 @@ public:
notify = 0; notify = 0;
newTransfers = false; newTransfers = false;
} }
QString username; QString username;
QString password; QString password;
QString server; QString server;
@ -92,7 +92,7 @@ public:
int state; int state;
int notify; int notify;
bool newTransfers; bool newTransfers;
int errCond; int errCond;
QString errText; QString errText;
@ -103,12 +103,10 @@ public:
}; };
ClientStream::ClientStream(Connector *conn, QObject *parent) ClientStream::ClientStream(Connector *conn, QObject *parent)
:Stream(parent) :Stream(parent), d(new Private())
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
d = new Private;
d->mode = Client; d->mode = Client;
d->conn = conn; d->conn = conn;
connect( d->conn, SIGNAL(connected()), SLOT(cr_connected()) ); connect( d->conn, SIGNAL(connected()), SLOT(cr_connected()) );
@ -128,15 +126,16 @@ ClientStream::~ClientStream()
void ClientStream::reset(bool all) void ClientStream::reset(bool all)
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
d->reset(); d->reset();
d->noopTimer.stop(); d->noopTimer.stop();
// client // client
if(d->mode == Client) { if(d->mode == Client) {
// reset connector // reset connector
if(d->bs) { if(d->bs) {
disconnect(d->bs, 0, this, 0);
d->bs->close(); d->bs->close();
d->bs = 0; d->bs = 0;
} }
@ -151,7 +150,7 @@ void ClientStream::reset(bool all)
void ClientStream::connectToServer(const QString& server, bool auth) void ClientStream::connectToServer(const QString& server, bool auth)
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
reset(true); reset(true);
d->state = Connecting; d->state = Connecting;
d->doAuth = auth; d->doAuth = auth;
@ -162,7 +161,7 @@ void ClientStream::connectToServer(const QString& server, bool auth)
void ClientStream::continueAfterWarning() void ClientStream::continueAfterWarning()
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
/* unneeded? /* unneeded?
if(d->state == WaitVersion) { if(d->state == WaitVersion) {
d->state = Connecting; d->state = Connecting;
@ -235,7 +234,7 @@ void ClientStream::close()
bool ClientStream::transfersAvailable() const bool ClientStream::transfersAvailable() const
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
return ( !d->in.isEmpty() ); return ( !d->in.isEmpty() );
} }
@ -243,17 +242,17 @@ Transfer* ClientStream::read()
{ {
if(d->in.isEmpty()) if(d->in.isEmpty())
return 0; //first from queue... return 0; //first from queue...
else else
return d->in.dequeue(); return d->in.dequeue();
} }
void ClientStream::write( Transfer *request ) void ClientStream::write( Transfer *request )
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
// pass to CoreProtocol for transformation into wire format // pass to CoreProtocol for transformation into wire format
d->client.outgoingTransfer( request ); d->client.outgoingTransfer( request );
} }
void cs_dump( const QByteArray &bytes ) void cs_dump( const QByteArray &bytes )
{ {
#if 0 #if 0
@ -278,7 +277,7 @@ void cs_dump( const QByteArray &bytes )
if ( count + i < bytes.count() ) if ( count + i < bytes.count() )
{ {
int j = bytes [ count + i ]; int j = bytes [ count + i ];
if ( j >= 0x20 && j <= 0x7e ) if ( j >= 0x20 && j <= 0x7e )
printf( "%2c ", j ); printf( "%2c ", j );
else else
printf( "%2c ", '.' ); printf( "%2c ", '.' );
@ -298,32 +297,35 @@ void cs_dump( const QByteArray &bytes )
void ClientStream::cp_outgoingData( const QByteArray& outgoingBytes ) void ClientStream::cp_outgoingData( const QByteArray& outgoingBytes )
{ {
if ( !d->bs )
return;
// take formatted bytes from CoreProtocol and put them on the wire // 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 ); //cs_dump( outgoingBytes );
d->bs->write( outgoingBytes ); d->bs->write( outgoingBytes );
} }
void ClientStream::cp_incomingData() void ClientStream::cp_incomingData()
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; // kdDebug(YAHOO_RAW_DEBUG) ;
Transfer * incoming = d->client.incomingTransfer(); Transfer * incoming = d->client.incomingTransfer();
if ( incoming ) 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->in.enqueue( incoming );
d->newTransfers = true; d->newTransfers = true;
emit doReadyRead(); emit doReadyRead();
} }
else 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 */ /* Connector connected */
void ClientStream::cr_connected() void ClientStream::cr_connected()
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
d->bs = d->conn->stream(); d->bs = d->conn->stream();
connect(d->bs, SIGNAL(connectionClosed()), SLOT(bs_connectionClosed())); connect(d->bs, SIGNAL(connectionClosed()), SLOT(bs_connectionClosed()));
connect(d->bs, SIGNAL(delayedCloseFinished()), SLOT(bs_delayedCloseFinished())); connect(d->bs, SIGNAL(delayedCloseFinished()), SLOT(bs_delayedCloseFinished()));
@ -341,12 +343,12 @@ void ClientStream::cr_connected()
void ClientStream::cr_error() void ClientStream::cr_error()
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
reset(); reset();
emit error(ErrConnection); emit error(ErrConnection);
} }
void ClientStream::bs_connectionClosed() void ClientStream::bs_connectionClosed()
{ {
reset(); reset();
emit connectionClosed(); emit connectionClosed();
@ -359,20 +361,20 @@ void ClientStream::bs_delayedCloseFinished()
void ClientStream::bs_error(int) void ClientStream::bs_error(int)
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
// TODO // TODO
} }
void ClientStream::bs_readyRead() void ClientStream::bs_readyRead()
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; // kdDebug(YAHOO_RAW_DEBUG) ;
QByteArray a; QByteArray a;
//qDebug( "size of storage for incoming data is %i bytes.", a.size() ); //qDebug( "size of storage for incoming data is %i bytes.", a.size() );
a = d->bs->read(); a = d->bs->read();
//QCString cs(a.data(), a.size()+1); //QCString cs(a.data(), a.size()+1);
//qDebug("ClientStream: recv: %d [%s]\n", a.size(), cs.data()); //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 ); //cs_dump( a );
d->client.addIncomingData(a); d->client.addIncomingData(a);
@ -380,7 +382,7 @@ void ClientStream::bs_readyRead()
void ClientStream::bs_bytesWritten(int bytes) 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() void ClientStream::srvProcessNext()
@ -389,13 +391,13 @@ void ClientStream::srvProcessNext()
void ClientStream::doReadyRead() void ClientStream::doReadyRead()
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; // kdDebug(YAHOO_RAW_DEBUG) ;
emit readyRead(); emit readyRead();
} }
void ClientStream::processNext() void ClientStream::processNext()
{ {
if( !d->in.isEmpty() ) if( !d->in.isEmpty() )
{ {
QTimer::singleShot(0, this, SLOT(doReadyRead())); QTimer::singleShot(0, this, SLOT(doReadyRead()));
} }

@ -1,13 +1,13 @@
/* /*
oscarclientstream.h - Kopete Yahoo Protocol oscarclientstream.h - Kopete Yahoo Protocol
Copyright (c) 2004 Matt Rogers <matt.rogers@kdemail.net> Copyright (c) 2004 Matt Rogers <matt.rogers@kdemail.net>
Based on code Copyright (c) 2004 SuSE Linux AG <http://www.suse.com> 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> Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
************************************************************************* *************************************************************************
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
@ -26,7 +26,6 @@
class QHostAddress; class QHostAddress;
// forward defines // forward defines
class ByteStream;
class Connector; class Connector;
class Transfer; class Transfer;
@ -40,20 +39,20 @@ public:
ErrAuth, // Auth error, see condition ErrAuth, // Auth error, see condition
ErrBind // Resource binding error ErrBind // Resource binding error
}; };
enum Warning { 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 WarnNoTLS // there is no chance for TLS at this point
}; };
enum NegCond { enum NegCond {
HostGone, // host no longer hosted HostGone, // host no longer hosted
HostUnknown, // unknown host HostUnknown, // unknown host
RemoteConnectionFailed, // unable to connect to a required remote resource RemoteConnectionFailed, // unable to connect to a required remote resource
SeeOtherHost, // a 'redirect', see errorText() for other host SeeOtherHost, // a 'redirect', see errorText() for other host
UnsupportedVersion // unsupported XMPP version UnsupportedVersion // unsupported XMPP version
}; }
;
enum AuthCond { enum AuthCond {
GenericAuthError, // all-purpose "can't login" error GenericAuthError, // all-purpose "can't login" error
NoMech, // No appropriate auth mech available NoMech, // No appropriate auth mech available
@ -66,13 +65,13 @@ public:
NotAuthorized, // bad user, bad password, bad creditials NotAuthorized, // bad user, bad password, bad creditials
TemporaryAuthFailure // please try again later! TemporaryAuthFailure // please try again later!
}; };
enum BindCond { enum BindCond {
BindNotAllowed, // not allowed to bind a resource BindNotAllowed, // not allowed to bind a resource
BindConflict // resource in-use BindConflict // resource in-use
}; };
ClientStream(Connector *conn, QObject *parent=0); explicit ClientStream(Connector *conn, QObject *parent=0);
~ClientStream(); ~ClientStream();
void connectToServer(const QString& server, bool auth=true); void connectToServer(const QString& server, bool auth=true);
@ -87,12 +86,12 @@ public:
void setLocalAddr(const QHostAddress &addr, Q_UINT16 port); void setLocalAddr(const QHostAddress &addr, Q_UINT16 port);
void close(); void close();
/** /**
* Are there any messages waiting to be read * Are there any messages waiting to be read
*/ */
bool transfersAvailable() const; bool transfersAvailable() const;
/** /**
* Read a message received from the server * Read a message received from the server
*/ */
@ -124,7 +123,7 @@ private slots:
void cr_error(); void cr_error();
/** /**
* collects wire ready outgoing data from the core protocol and sends * collects wire ready outgoing data from the core protocol and sends
*/ */
void cp_outgoingData( const QByteArray& ); void cp_outgoingData( const QByteArray& );
/** /**
* collects parsed incoming data as a transfer from the core protocol and queues * collects parsed incoming data as a transfer from the core protocol and queues
@ -142,15 +141,15 @@ private slots:
private: private:
class Private; class Private;
Private *d; Private * const d;
void reset(bool all=false); void reset(bool all=false);
void processNext(); void processNext();
bool handleNeed(); bool handleNeed();
void handleError(); void handleError();
void srvProcessNext(); void srvProcessNext();
/** /**
* convert internal method representation to wire * convert internal method representation to wire
*/ */
static char* encode_method(Q_UINT8 method); static char* encode_method(Q_UINT8 method);

@ -4,7 +4,7 @@
------------------- -------------------
begin : Wed Jul 7 2004 begin : Wed Jul 7 2004
copyright : (C) 2004 by Till Gerken <till@tantalo.net> copyright : (C) 2004 by Till Gerken <till@tantalo.net>
Kopete (C) 2004 Kopete developers <kopete-devel@kde.org> Kopete (C) 2004 Kopete developers <kopete-devel@kde.org>
***************************************************************************/ ***************************************************************************/
@ -25,10 +25,10 @@
#include "yahoobytestream.h" #include "yahoobytestream.h"
#include "yahootypes.h" #include "yahootypes.h"
KNetworkConnector::KNetworkConnector( QObject *parent, const char */*name*/ ) KNetworkConnector::KNetworkConnector( QObject *parent )
: Connector( 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; mErrorCode = KNetwork::KSocketBase::NoError;
@ -47,7 +47,7 @@ KNetworkConnector::~KNetworkConnector()
void KNetworkConnector::connectToServer( const QString &server ) void KNetworkConnector::connectToServer( const QString &server )
{ {
Q_UNUSED( 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( !mHost.isNull() );
Q_ASSERT( mPort ); Q_ASSERT( mPort );
@ -63,7 +63,7 @@ void KNetworkConnector::connectToServer( const QString &server )
void KNetworkConnector::slotConnected() 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 // FIXME: setPeerAddress() is something different, find out correct usage later
//KInetSocketAddress inetAddress = mStreamSocket->address().asInet().makeIPv6 (); //KInetSocketAddress inetAddress = mStreamSocket->address().asInet().makeIPv6 ();
@ -74,7 +74,7 @@ void KNetworkConnector::slotConnected()
void KNetworkConnector::slotError( int code ) 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; mErrorCode = code;
emit error (); emit error ();
@ -87,19 +87,19 @@ int KNetworkConnector::errorCode()
ByteStream *KNetworkConnector::stream() const ByteStream *KNetworkConnector::stream() const
{ {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_RAW_DEBUG) ;
return mByteStream; return mByteStream;
} }
void KNetworkConnector::done() void KNetworkConnector::done()
{ {
kdDebug ( YAHOO_RAW_DEBUG ) << k_funcinfo << endl; kdDebug ( YAHOO_RAW_DEBUG ) ;
mByteStream->close (); mByteStream->close ();
} }
void KNetworkConnector::setOptHostPort( const QString &host, Q_UINT16 port ) 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; mHost = host;
mPort = port; mPort = port;

@ -25,7 +25,6 @@
class ByteStream; class ByteStream;
class KNetworkByteStream; class KNetworkByteStream;
class KResolverEntry;
/** /**
@author Till Gerken @author Till Gerken
@ -37,7 +36,7 @@ class KNetworkConnector : public Connector
Q_OBJECT Q_OBJECT
public: public:
KNetworkConnector( QObject *parent = 0, const char *name = 0 ); KNetworkConnector( QObject *parent = 0 );
virtual ~KNetworkConnector(); virtual ~KNetworkConnector();

@ -19,14 +19,15 @@
#define YAHOOTYPESH #define YAHOOTYPESH
#include <qglobal.h> #include <qglobal.h>
#include <qstring.h>
const int YAHOO_RAW_DEBUG = 14181; const int YAHOO_RAW_DEBUG = 14181;
const int YAHOO_GEN_DEBUG = 14180; const int YAHOO_GEN_DEBUG = 14180;
namespace Yahoo namespace Yahoo
{ {
enum Service enum Service
{ {
/* these are easier to see in hex */ /* these are easier to see in hex */
ServiceLogon = 1, ServiceLogon = 1,
ServiceLogoff, ServiceLogoff,
@ -71,8 +72,8 @@ namespace Yahoo
ServiceAuthResp = 0x54, ServiceAuthResp = 0x54,
ServiceList = 85, ServiceList = 85,
ServiceAuth = 0x57, ServiceAuth = 0x57,
ServiceAddBuddy = 0x83, ServiceBuddyAdd = 0x83,
ServiceRemBuddy, ServiceBuddyRemove = 0x84,
ServiceIgnoreContact, /* > 1, 7, 13 < 1, 66, 13, 0*/ ServiceIgnoreContact, /* > 1, 7, 13 < 1, 66, 13, 0*/
ServiceRejectContact, ServiceRejectContact,
ServiceGroupRename = 0x89, /* > 1, 65(new), 66(0), 67(old) */ ServiceGroupRename = 0x89, /* > 1, 65(new), 66(0), 67(old) */
@ -95,15 +96,17 @@ namespace Yahoo
ServiceStatus = 0xc6, /* YMSG13 */ ServiceStatus = 0xc6, /* YMSG13 */
ServicePictureStatus = 0xc7, /* YMSG13, key 213: 0 = none, 1 = avatar, 2 = picture */ ServicePictureStatus = 0xc7, /* YMSG13, key 213: 0 = none, 1 = avatar, 2 = picture */
ServiceContactDetails = 0xd3, /* YMSG13 */ ServiceContactDetails = 0xd3, /* YMSG13 */
ServiceChatSession = 0xd4, ServiceChatSession = 0xd4,
ServiceAuthorization = 0xd6, /* YMSG13 */ ServiceAuthorization = 0xd6, /* YMSG13 */
ServiceFileTransfer7 = 0xdc, /* YMSG13 */ ServiceFileTransfer7 = 0xdc, /* YMSG13 */
ServiceFileTransfer7Info, /* YMSG13 */ ServiceFileTransfer7Info = 0xdd, /* YMSG13 */
ServiceFileTransfer7Accept, /* YMSG13 */ ServiceFileTransfer7Accept = 0xde, /* YMSG13 */
ServiceBuddyChangeGroup = 0xe7 /* YMSG13 */ ServiceBuddyChangeGroup = 0xe7, /* YMSG13 */
ServiceBuddyStatus = 0xf0,
ServiceBuddyList = 0xf1
}; };
enum Status enum Status
{ {
StatusConnecting = -2, StatusConnecting = -2,
StatusDisconnected = -1, StatusDisconnected = -1,
@ -132,13 +135,13 @@ namespace Yahoo
}; };
enum LoginStatus { enum LoginStatus {
LoginOk = 0, LoginOk = 0,
LoginUname = 3, LoginUname = 3,
LoginPasswd = 13, LoginPasswd = 13,
LoginLock = 14, LoginLock = 14,
LoginVerify = 29, // FIXME: Find the reason for this response LoginVerify = 29, // FIXME: Find the reason for this response
LoginDupl = 99, LoginDupl = 99,
LoginSock = -1 LoginSock = -1
}; };
enum StealthMode { enum StealthMode {
@ -158,9 +161,26 @@ namespace Yahoo
ResponseDecline ResponseDecline
}; };
enum PictureStatus {
NoPicture = 0,
Avatar = 1,
Picture = 2
};
typedef Q_UINT8 BYTE; typedef Q_UINT8 BYTE;
typedef Q_UINT16 WORD; typedef Q_UINT16 WORD;
typedef Q_UINT32 DWORD; typedef Q_UINT32 DWORD;
struct ChatRoom {
QString name;
QString topic;
int id;
};
struct ChatCategory {
QString name;
int id;
};
} }
#define yahoo_put16(buf, data) ( \ #define yahoo_put16(buf, data) ( \

@ -3,7 +3,7 @@
Copyright (c) 2004 Duncan Mac-Vicar Prett <duncan@kde.org> 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> 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 <qdatastream.h>
#include <qmap.h> #include <qmap.h>
#include <qobject.h> #include <qobject.h>
#include <qstringlist.h> #include <qstringlist.h>
#include <kdebug.h> #include <kdebug.h>
#include "ymsgprotocol.h" #include "ymsgprotocol.h"
@ -55,188 +59,252 @@ Transfer* YMSGProtocol::parse( const QByteArray & packet, uint& bytes )
/ 0 - 65535* | / 0 - 65535* |
+-------------------------------------------------+ +-------------------------------------------------+
*/ */
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << packet << endl; kdDebug(YAHOO_RAW_DEBUG) << packet << endl;
int pos = 0; int pos = 0;
int len = 0; int len = 0;
Yahoo::Status status = Yahoo::StatusAvailable; Yahoo::Status status = Yahoo::StatusAvailable;
Yahoo::Service service = Yahoo::ServiceAuth; Yahoo::Service service = Yahoo::ServiceAuth;
int statusnum = 0; int statusnum = 0;
int sessionid = 0; int sessionid = 0;
int servicenum; int servicenum;
int version1, version2; int version1, version2;
QMap<QString, QString> params; QMap<QString, QString> params;
// Skip the YMSG header // Skip the YMSG header
pos += 4; pos += 4;
// Skip the version // Skip the version
version1 = yahoo_get16(packet.data() + pos); version1 = yahoo_get16(packet.data() + pos);
pos += 2; pos += 2;
version2 = yahoo_get16(packet.data() + pos); version2 = yahoo_get16(packet.data() + pos);
pos += 2; 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); len = yahoo_get16(packet.data() + pos);
pos += 2; 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); servicenum = yahoo_get16(packet.data() + pos);
pos += 2; pos += 2;
switch (servicenum) switch (servicenum)
{ {
// TODO add remamining services // TODO add remamining services
case (Yahoo::ServiceAuth) : 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; service = Yahoo::ServiceAuth;
break; break;
case (Yahoo::ServiceAuthResp) : 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; service = Yahoo::ServiceAuthResp;
break; break;
case (Yahoo::ServiceVerify) : 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; service = Yahoo::ServiceVerify;
break; break;
case (Yahoo::ServiceList) : 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; service = Yahoo::ServiceList;
break; break;
case (Yahoo::ServiceLogon) : 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; service = Yahoo::ServiceLogon;
break; break;
case (Yahoo::ServicePing) : 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; service = Yahoo::ServicePing;
break; break;
case (Yahoo::ServiceNewMail) : 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; service = Yahoo::ServiceNewMail;
break; break;
case (Yahoo::ServiceLogoff) : 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; service = Yahoo::ServiceLogoff;
break; break;
case (Yahoo::ServiceIsAway) : 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; service = Yahoo::ServiceIsAway;
break; break;
case (Yahoo::ServiceIsBack) : 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; service = Yahoo::ServiceIsBack;
break; break;
case (Yahoo::ServiceGameLogon) : 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; service = Yahoo::ServiceGameLogon;
break; break;
case (Yahoo::ServiceGameLogoff) : 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; service = Yahoo::ServiceGameLogoff;
break; break;
case (Yahoo::ServiceIdAct) : 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; service = Yahoo::ServiceIdAct;
break; break;
case (Yahoo::ServiceIddeAct) : 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; service = Yahoo::ServiceIddeAct;
break; break;
case (Yahoo::ServiceStatus) : 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; service = Yahoo::ServiceStatus;
break; break;
case (Yahoo::ServiceMessage) : 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; service = Yahoo::ServiceMessage;
break; break;
case (Yahoo::ServiceNotify) : 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; service = Yahoo::ServiceNotify;
break; break;
case (Yahoo::ServiceAddBuddy) : case (Yahoo::ServiceBuddyAdd) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceAddBuddy " << servicenum << endl; kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceBuddyAdd " << servicenum << endl;
service = Yahoo::ServiceAddBuddy; service = Yahoo::ServiceBuddyAdd;
break; 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) : 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; service = Yahoo::ServicePictureChecksum;
break; break;
case (Yahoo::ServicePictureStatus) : 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; service = Yahoo::ServicePictureStatus;
break; break;
case (Yahoo::ServicePicture) : 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; service = Yahoo::ServicePicture;
break; break;
case (Yahoo::ServiceStealthOnline) : 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; service = Yahoo::ServiceStealthOnline;
break; break;
case (Yahoo::ServiceStealthOffline) : 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; service = Yahoo::ServiceStealthOffline;
break; break;
case (Yahoo::ServicePictureUpload) : 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; service = Yahoo::ServicePictureUpload;
break; break;
case (Yahoo::ServiceWebcam) : 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; service = Yahoo::ServiceWebcam;
break; break;
case (Yahoo::ServiceConfInvite) : 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; service = Yahoo::ServiceConfInvite;
break; break;
case (Yahoo::ServiceConfLogon) : 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; service = Yahoo::ServiceConfLogon;
break; break;
case (Yahoo::ServiceConfDecline) : 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; service = Yahoo::ServiceConfDecline;
break; break;
case (Yahoo::ServiceConfLogoff) : 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; service = Yahoo::ServiceConfLogoff;
break; break;
case (Yahoo::ServiceConfAddInvite) : 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; service = Yahoo::ServiceConfAddInvite;
break; break;
case (Yahoo::ServiceConfMsg) : 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; service = Yahoo::ServiceConfMsg;
break; break;
case (Yahoo::ServiceAuthorization) : 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; service = Yahoo::ServiceAuthorization;
break; break;
case (Yahoo::ServiceContactDetails) : 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; service = Yahoo::ServiceContactDetails;
break; break;
case (Yahoo::ServiceFileTransfer) : 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; service = Yahoo::ServiceFileTransfer;
break; break;
case (Yahoo::ServiceFileTransfer7) : 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; service = Yahoo::ServiceFileTransfer7;
break; break;
case (Yahoo::ServiceFileTransfer7Info) : 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; service = Yahoo::ServiceFileTransfer7Info;
break; break;
case (Yahoo::ServiceFileTransfer7Accept) :
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceFileTransfer7Accept " << servicenum << endl;
service = Yahoo::ServiceFileTransfer7Accept;
break;
case (Yahoo::ServicePeerToPeer) : 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; service = Yahoo::ServicePeerToPeer;
break; 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) ServiceIdle, // 5 (placemarker)
ServiceMailStat, ServiceMailStat,
@ -250,9 +318,6 @@ Transfer* YMSGProtocol::parse( const QByteArray & packet, uint& bytes )
ServiceGotGroupRename, // < 1, 36(old), 37(new) ServiceGotGroupRename, // < 1, 36(old), 37(new)
ServiceSysMessage = 0x14, ServiceSysMessage = 0x14,
ServicePassThrough2 = 0x16, ServicePassThrough2 = 0x16,
ServiceChatLogon,
ServiceChatLogoff,
ServiceChatMsg = 0x20,
ServiceGameMsg = 0x2a, ServiceGameMsg = 0x2a,
ServiceFileTransfer = 0x46, ServiceFileTransfer = 0x46,
ServiceVoiceChat = 0x4A, ServiceVoiceChat = 0x4A,
@ -261,28 +326,20 @@ Transfer* YMSGProtocol::parse( const QByteArray & packet, uint& bytes )
ServiceRemBuddy, ServiceRemBuddy,
ServiceIgnoreContact, // > 1, 7, 13 < 1, 66, 13, 0 ServiceIgnoreContact, // > 1, 7, 13 < 1, 66, 13, 0
ServiceRejectContact, ServiceRejectContact,
ServiceGroupRename = 0x89, // > 1, 65(new), 66(0), 67(old) 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
ServicePictureUpdate = 0xc1, ServicePictureUpdate = 0xc1,
ServiceVisibility = 0xc5, // YMSG13, key 13: 2 = invisible, 1 = visible ServiceVisibility = 0xc5, // YMSG13, key 13: 2 = invisible, 1 = visible
ServiceStatus = 0xc6, // YMSG13 ServiceStatus = 0xc6, // YMSG13
*/ */
default: 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; break;
} }
statusnum = yahoo_get32(packet.data() + pos); statusnum = yahoo_get32(packet.data() + pos);
pos += 4; pos += 4;
switch (statusnum) switch (statusnum)
{ {
// TODO add remaining status // TODO add remaining status
@ -309,37 +366,37 @@ Transfer* YMSGProtocol::parse( const QByteArray & packet, uint& bytes )
StatusOffline StatusOffline
StatusNotify*/ StatusNotify*/
default: default:
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " - unknown status " << statusnum << endl; kdDebug(YAHOO_RAW_DEBUG) << " - unknown status " << statusnum << endl;
break; break;
} }
sessionid = yahoo_get32(packet.data() + pos); 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; 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(); YMSGTransfer *t = new YMSGTransfer();
t->setService(service); t->setService(service);
t->setId(sessionid); t->setId(sessionid);
t->setStatus(status); t->setStatus(status);
t->setPacketLength(len);
QString d = QString::fromAscii( packet.data() + pos, packet.size() - pos ); QString d = QString::fromAscii( packet.data() + pos, packet.size() - pos );
QStringList list; QStringList list = QStringList::split( "\xc0\x80", d );
list = QStringList::split( "\xc0\x80", d ); for( int i = 0; i+1 < list.size() && pos+1 < len+20; i += 2 ) {
for( uint i = 0; i+1 < list.size() && pos+1 < len+20; i += 2 ) { QString key = list[i];
QString key = list[i]; QString value = QString::fromUtf8( list[i+1].ascii() );
QString value = QString::fromUtf8( list[i+1].ascii() ); pos += key.utf8().length() + value.utf8().length() + 4;
pos += key.utf8().length() + value.utf8().length() + 4; t->setParam( QString(key).toInt(), value.utf8() );
t->setParam( QString(key).toInt(), value.utf8() ); kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Key: " << key << " Value: " << value << endl;
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Key: " << key << " Value: " << value << endl; }
}
while( (uint)pos < packet.size() && packet.data()[pos] == '\x00' ) while( pos < packet.size() && packet.data()[pos] == '\x00' )
pos++; pos++;
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Returning transfer" << endl; // kdDebug(YAHOO_RAW_DEBUG) << " Returning transfer";
// tell them we have parsed offset bytes // tell them we have parsed offset bytes
bytes = pos; bytes = pos;
return t; return t;
} }

@ -3,7 +3,7 @@
Copyright (c) 2004 Duncan Mac-Vicar Prett <duncan@kde.org> 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> Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
************************************************************************* *************************************************************************
@ -26,17 +26,17 @@ class YMSGProtocol : public InputProtocolBase
{ {
Q_OBJECT Q_OBJECT
public: public:
YMSGProtocol( QObject *parent = 0, const char *name = 0 ); YMSGProtocol( QObject *parent = 0, const char *name = 0 );
~YMSGProtocol(); ~YMSGProtocol();
/** /**
* Attempt to parse the supplied data into an @ref YMSGTransfer object. * Attempt to parse the supplied data into an @ref YMSGTransfer object.
* The exact state of the parse attempt can be read using @ref state. * The exact state of the parse attempt can be read using @ref state.
* @param rawData The unparsed data. * @param rawData The unparsed data.
* @param bytes An integer used to return the number of bytes read. * @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 ); Transfer * parse( const QByteArray &, uint & bytes );
}; };

@ -4,7 +4,7 @@
Copyright (c) 2004 Duncan Mac-Vicar P. <duncan@kde.org> 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> Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
@ -23,6 +23,7 @@
#include "ymsgtransfer.h" #include "ymsgtransfer.h"
#include "yahootypes.h" #include "yahootypes.h"
#include "kdebug.h" #include "kdebug.h"
#include <qdatastream.h> #include <qdatastream.h>
#include <qmap.h> #include <qmap.h>
#include <qstring.h> #include <qstring.h>
@ -39,7 +40,7 @@ public:
int packetLength; int packetLength;
Yahoo::Service service; Yahoo::Service service;
Yahoo::Status status; Yahoo::Status status;
unsigned int id; unsigned int id;
ParamList data; ParamList data;
bool valid; bool valid;
}; };
@ -80,12 +81,12 @@ Transfer::TransferType YMSGTransfer::type()
return Transfer::YMSGTransfer; return Transfer::YMSGTransfer;
} }
bool YMSGTransfer::isValid() bool YMSGTransfer::isValid() const
{ {
return d->valid; return d->valid;
} }
Yahoo::Service YMSGTransfer::service() Yahoo::Service YMSGTransfer::service() const
{ {
return d->service; return d->service;
} }
@ -95,7 +96,7 @@ void YMSGTransfer::setService(Yahoo::Service service)
d->service = service; d->service = service;
} }
Yahoo::Status YMSGTransfer::status() Yahoo::Status YMSGTransfer::status() const
{ {
return d->status; return d->status;
} }
@ -105,7 +106,7 @@ void YMSGTransfer::setStatus(Yahoo::Status status)
d->status = status; d->status = status;
} }
unsigned int YMSGTransfer::id() unsigned int YMSGTransfer::id() const
{ {
return d->id; return d->id;
} }
@ -115,15 +116,25 @@ void YMSGTransfer::setId(unsigned int id)
d->id = 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; return d->data;
} }
int YMSGTransfer::paramCount( int index ) int YMSGTransfer::paramCount( int index ) const
{ {
int cnt = 0; 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 ) if( (*it).first == index )
cnt++; 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; 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 (*it).second;
} }
return QCString(); return QCString();
} }
QCString YMSGTransfer::nthParamSeparated( int index, int occurence, int separator ) QCString YMSGTransfer::nthParamSeparated( int index, int occurrence, int separator ) const
{ {
int cnt = -1; 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 ) if( (*it).first == separator )
cnt++; cnt++;
if( (*it).first == index && cnt == occurence) if( (*it).first == index && cnt == occurrence)
return (*it).second; return (*it).second;
} }
return QCString(); 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 ) if( (*it).first == index )
return (*it).second; return (*it).second;
@ -177,10 +188,10 @@ void YMSGTransfer::setParam( int index, int data )
d->data.append( Param( index, QString::number( data ).local8Bit() ) ); d->data.append( Param( index, QString::number( data ).local8Bit() ) );
} }
int YMSGTransfer::length() int YMSGTransfer::length() const
{ {
int len = 0; 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 += QString::number( (*it).first ).length();
len += 2; len += 2;
@ -191,7 +202,7 @@ int YMSGTransfer::length()
} }
QByteArray YMSGTransfer::serialize() QByteArray YMSGTransfer::serialize() const
{ {
/* /*
<------- 4B -------><------- 4B -------><---2B---> <------- 4B -------><------- 4B -------><---2B--->
@ -205,17 +216,17 @@ QByteArray YMSGTransfer::serialize()
/ 0 - 65535* | / 0 - 65535* |
+-------------------------------------------------+ +-------------------------------------------------+
*/ */
int pos = 0; int pos = 0;
QStringList::ConstIterator listIt = 0; QStringList::ConstIterator listIt = 0;
QByteArray buffer; QByteArray buffer;
QDataStream stream( buffer, IO_WriteOnly ); QDataStream stream( buffer, IO_WriteOnly );
stream << (Q_INT8)'Y' << (Q_INT8)'M' << (Q_INT8)'S' << (Q_INT8)'G'; stream << (Q_INT8)'Y' << (Q_INT8)'M' << (Q_INT8)'S' << (Q_INT8)'G';
if( d->service == Yahoo::ServicePictureUpload ) if( d->service == Yahoo::ServicePictureUpload )
stream << (Q_INT16)0x0e00; stream << (Q_INT16)0x0f00;
else else
stream << (Q_INT16)0x000e; stream << (Q_INT16)0x000f;
stream << (Q_INT16)0x0000; stream << (Q_INT16)0x0000;
if( d->service == Yahoo::ServicePictureUpload || if( d->service == Yahoo::ServicePictureUpload ||
d->service == Yahoo::ServiceFileTransfer ) d->service == Yahoo::ServiceFileTransfer )
@ -225,15 +236,15 @@ QByteArray YMSGTransfer::serialize()
stream << (Q_INT16)d->service; stream << (Q_INT16)d->service;
stream << (Q_INT32)d->status; stream << (Q_INT32)d->status;
stream << (Q_INT32)d->id; 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.writeRawBytes ( QString::number( (*it).first ).local8Bit(), QString::number( (*it).first ).length() );
stream << (Q_INT8)0xc0 << (Q_INT8)0x80; stream << (Q_INT8)0xc0 << (Q_INT8)0x80;
stream.writeRawBytes( (*it).second, (*it).second.length() ); stream.writeRawBytes( (*it).second, (*it).second.length() );
stream << (Q_INT8)0xc0 << (Q_INT8)0x80; 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; return buffer;
} }

@ -4,7 +4,7 @@
Copyright (c) 2004 Duncan Mac-Vicar P. <duncan@kde.org> 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> Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
@ -24,12 +24,11 @@
#include "transfer.h" #include "transfer.h"
#include "yahootypes.h" #include "yahootypes.h"
#include <qcstring.h>
#include <qpair.h> #include <qpair.h>
#include <qvaluelist.h> #include <qvaluelist.h>
class YMSGTransferPrivate; class YMSGTransferPrivate;
class QString;
typedef QPair< int, QCString > Param; typedef QPair< int, QCString > Param;
typedef QValueList< Param > ParamList; typedef QValueList< Param > ParamList;
@ -49,26 +48,29 @@ public:
TransferType type(); TransferType type();
//! Get the validity of the transfer object //! Get the validity of the transfer object
bool isValid(); bool isValid() const;
Yahoo::Service service(); Yahoo::Service service() const;
void setService(Yahoo::Service service); void setService(Yahoo::Service service);
Yahoo::Status status(); Yahoo::Status status() const;
void setStatus(Yahoo::Status status); void setStatus(Yahoo::Status status);
unsigned int id(); unsigned int id() const;
void setId(unsigned int id); 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, const QCString &data);
void setParam(int index, int data); void setParam(int index, int data);
QByteArray serialize(); QByteArray serialize() const;
int length(); int length() const;
private: private:
YMSGTransferPrivate* d; YMSGTransferPrivate* d;
}; };

File diff suppressed because it is too large Load Diff

@ -3,7 +3,8 @@
Copyright (c) 2003 by Gav Wood <gav@kde.org> Copyright (c) 2003 by Gav Wood <gav@kde.org>
Copyright (c) 2003 by Matt Rogers <mattrogers@sbcglobal.net> Copyright (c) 2003 by Matt Rogers <mattrogers@sbcglobal.net>
Based on code by Olivier Goffart <ogoffart @ kde.org> Based on code by Olivier Goffart <ogoffart@kde.org>
Kopete (c) 2003 by the Kopete developers <kopete-devel@kde.org> Kopete (c) 2003 by the Kopete developers <kopete-devel@kde.org>
************************************************************************* *************************************************************************
@ -17,16 +18,20 @@
*/ */
#ifndef YAHOOIDENTITY_H #ifndef YAHOOACCOUNT_H
#define YAHOOIDENTITY_H #define YAHOOACCOUNT_H
// Qt // Qt
#include <qobject.h> #include <qobject.h>
#include <qmap.h> #include <qmap.h>
#include <qpixmap.h>
#include <qpair.h>
// KDE
#include <kurl.h>
// Kopete // Kopete
#include "kopetepasswordedaccount.h" #include "kopetepasswordedaccount.h"
#include "kopeteawaydialog.h"
// Local // Local
#include "yahooprotocol.h" #include "yahooprotocol.h"
@ -40,27 +45,21 @@ class YahooAccount;
class YahooProtocol; class YahooProtocol;
class YahooWebcam; class YahooWebcam;
class YahooConferenceChatSession; class YahooConferenceChatSession;
class KTempFile; class YahooChatChatSession;
struct KURL; class KTemporaryFile;
namespace Kopete{ namespace Kopete{
class Transfer; class Transfer;
class ChatSession; class ChatSession;
class StatusMessage;
class FileTransferInfo; class FileTransferInfo;
} }
class Client; class Client;
class YABEntry; struct YABEntry;
class KJob;
namespace KIO{ namespace KIO{
class Job; class Job;
} }
class YahooAwayDialog : public KopeteAwayDialog
{
public:
YahooAwayDialog(YahooAccount *account, QWidget *parent = 0, const char *name = 0);
virtual void setAway(int awayType);
private:
YahooAccount *theAccount;
};
class YahooAccount : public Kopete::PasswordedAccount class YahooAccount : public Kopete::PasswordedAccount
{ {
@ -70,7 +69,7 @@ public:
enum SignalConnectionType { MakeConnections, DeleteConnections }; enum SignalConnectionType { MakeConnections, DeleteConnections };
YahooAccount(YahooProtocol *parent,const QString& accountID, const char *name = 0L); YahooAccount(YahooProtocol *parent,const QString& accountID, const char *name = 0);
~YahooAccount(); ~YahooAccount();
/* /*
@ -108,7 +107,7 @@ public:
* Set the pager server * Set the pager server
*/ */
void setServer( const QString &server ); void setServer( const QString &server );
/** /**
* Set the port of the pager server * Set the port of the pager server
*/ */
@ -117,11 +116,12 @@ public:
/** /**
* Set Buddy Icon * Set Buddy Icon
*/ */
void setBuddyIcon( KURL url ); void setBuddyIcon( const KURL &url );
void verifyAccount( const QString &word ); void verifyAccount( const QString &word );
void sendConfMessage( YahooConferenceChatSession *s, Kopete::Message &message ); void sendConfMessage( YahooConferenceChatSession *s, const Kopete::Message &message );
void sendChatMessage( const Kopete::Message &msg, const QString &handle );
void prepareConference( const QString &who ); void prepareConference( const QString &who );
void sendFile( YahooContact *to, const KURL &url ); void sendFile( YahooContact *to, const KURL &url );
public slots: public slots:
@ -137,7 +137,6 @@ public slots:
/** Reimplemented from Kopete::Account */ /** Reimplemented from Kopete::Account */
void setOnlineStatus( const Kopete::OnlineStatus&, const QString &reason = QString::null); void setOnlineStatus( const Kopete::OnlineStatus&, const QString &reason = QString::null);
signals: signals:
/** /**
* Emitted when we receive notification that the person we're talking to is typing * Emitted when we receive notification that the person we're talking to is typing
@ -155,6 +154,8 @@ protected:
*/ */
virtual bool createContact(const QString &contactId, Kopete::MetaContact *parentContact); virtual bool createContact(const QString &contactId, Kopete::MetaContact *parentContact);
virtual bool createChatContact( const QString &nick );
/** /**
* Gets the just-received message color * Gets the just-received message color
*/ */
@ -171,19 +172,25 @@ protected slots:
void slotOpenInbox(); // Open Yahoo Mailbox in browser void slotOpenInbox(); // Open Yahoo Mailbox in browser
void slotOpenYAB(); // Open Yahoo Addressbook in browser void slotOpenYAB(); // Open Yahoo Addressbook in browser
void slotEditOwnYABEntry(); // Show own Yahoo Addressbook entry void slotEditOwnYABEntry(); // Show own Yahoo Addressbook entry
void slotJoinChatRoom();
void slotChatCategorySelected( const Yahoo::ChatCategory &category );
void slotGoStatus(int status, const QString &awayMessage = QString::null); void slotGoStatus(int status, const QString &awayMessage = QString());
void slotLoginResponse(int succ, const QString &url); void slotLoginResponse(int succ, const QString &url);
void slotDisconnected(); void slotDisconnected();
void slotLoginFailed(); void slotLoginFailed();
void slotGotBuddy(const QString &userid, const QString &alias, const QString &group); void slotGotBuddy(const QString &userid, const QString &alias, const QString &group);
void slotBuddyAddResult(const QString &userid, const QString &group, bool success);
void slotBuddyRemoveResult(const QString &userid, const QString &group, bool success);
void slotBuddyChangeGroupResult(const QString &userid, const QString &group, bool success);
void slotAuthorizationAccepted( const QString &who ); void slotAuthorizationAccepted( const QString &who );
void slotAuthorizationRejected( const QString &who, const QString &msg ); void slotAuthorizationRejected( const QString &who, const QString &msg );
void slotgotAuthorizationRequest( const QString &, const QString &, const QString & ); void slotgotAuthorizationRequest( const QString &, const QString &, const QString & );
void slotContactAddedNotifyDialogClosed( const QString & ); void slotContactAddedNotifyDialogClosed( const QString &user );
//void slotAddedInfoEventActionActivated( uint actionId );
void slotGotIgnore(const QStringList &); void slotGotIgnore(const QStringList &);
void slotGotIdentities(const QStringList &); void slotGotIdentities(const QStringList &);
void slotStatusChanged(const QString &who, int stat, const QString &msg, int away, int idle); void slotStatusChanged(const QString &who, int stat, const QString &msg, int away, int idle, int pictureChecksum);
void slotStealthStatusChanged(const QString &who, Yahoo::StealthStatus state); void slotStealthStatusChanged(const QString &who, Yahoo::StealthStatus state);
void slotGotIm(const QString &who, const QString &msg, long tm, int stat); void slotGotIm(const QString &who, const QString &msg, long tm, int stat);
void slotGotBuzz(const QString &who, long tm); void slotGotBuzz(const QString &who, long tm);
@ -195,7 +202,7 @@ protected slots:
void slotConfLeave( YahooConferenceChatSession *s ); void slotConfLeave( YahooConferenceChatSession *s );
void slotInviteConference( const QString &room, const QStringList &who, const QStringList &members, const QString &msg ); void slotInviteConference( const QString &room, const QStringList &who, const QStringList &members, const QString &msg );
void slotAddInviteConference( const QString &room, const QStringList &who, const QStringList &members, const QString &msg ); void slotAddInviteConference( const QString &room, const QStringList &who, const QStringList &members, const QString &msg );
void slotGotFile(const QString &who, const QString &url, long expires, const QString &msg, const QString &fname, unsigned long fesize); void slotGotFile(const QString &who, const QString &url, long expires, const QString &msg, const QString &fname, unsigned long fesize, const QPixmap &);
void slotContactAdded(const QString &myid, const QString &who, const QString &msg); void slotContactAdded(const QString &myid, const QString &who, const QString &msg);
void slotRejected(const QString &, const QString &); void slotRejected(const QString &, const QString &);
void slotTypingNotify(const QString &, int ); void slotTypingNotify(const QString &, int );
@ -215,16 +222,21 @@ protected slots:
void slotWebcamViewerJoined( const QString & ); void slotWebcamViewerJoined( const QString & );
void slotWebcamViewerLeft( const QString & ); void slotWebcamViewerLeft( const QString & );
void slotWebcamViewerRequest( const QString & ); void slotWebcamViewerRequest( const QString & );
void slotPictureStatusNotiy( const QString&, int); void slotPictureStatusNotify( const QString&, int);
void slotGotBuddyIcon(const QString&, KTempFile*, int); void slotGotBuddyIcon(const QString&, const QByteArray&, int);
void slotGotBuddyIconInfo(const QString&, KURL, int); void slotGotBuddyIconInfo(const QString&, KURL, int);
void slotGotBuddyIconChecksum(const QString&, int); void slotGotBuddyIconChecksum(const QString&, int);
void slotGotBuddyIconRequest(const QString &); void slotGotBuddyIconRequest(const QString &);
void slotBuddyIconChanged(const QString&); void slotBuddyIconChanged(const QString&, int);
void slotGotYABEntry( YABEntry *entry ); void slotGotYABEntry( YABEntry *entry );
void slotGotYABRevision( long revision, bool merged ); void slotGotYABRevision( long revision, bool merged );
void slotSaveYABEntry( YABEntry &entry ); void slotSaveYABEntry( YABEntry &entry );
void slotModifyYABEntryError( YABEntry *entry, const QString & ); void slotModifyYABEntryError( YABEntry *entry, const QString & );
void slotChatJoined( int roomId, int categoryId, const QString &comment, const QString &handle );
void slotChatBuddyHasJoined( const QString &nick, const QString &handle, bool suppressNotification );
void slotChatBuddyHasLeft( const QString &nick, const QString &handle );
void slotChatMessageReceived( const QString &nick, const QString &message, const QString &handle );
void slotLeavChat();
void slotReceiveFileAccepted( Kopete::Transfer *trans, const QString& fileName ); void slotReceiveFileAccepted( Kopete::Transfer *trans, const QString& fileName );
void slotReceiveFileRefused( const Kopete::FileTransferInfo& info ); void slotReceiveFileRefused( const Kopete::FileTransferInfo& info );
@ -234,11 +246,6 @@ protected slots:
void slotFileTransferResult( KIO::Job * ); void slotFileTransferResult( KIO::Job * );
void slotError( int level ); void slotError( int level );
private slots:
/**
* When a global identity key get changed.
*/
void slotGlobalIdentityChanged( const QString &key, const QVariant &value );
private: private:
/** /**
@ -246,6 +253,8 @@ private:
*/ */
void initConnectionSignals( enum SignalConnectionType sct ); void initConnectionSignals( enum SignalConnectionType sct );
void setupActions( bool connected );
QString prepareIncomingMessage( const QString &msg ); QString prepareIncomingMessage( const QString &msg );
/** /**
@ -258,6 +267,7 @@ private:
* Conferences list, maped by room name (id) * Conferences list, maped by room name (id)
*/ */
QMap<QString, YahooConferenceChatSession *> m_conferences; QMap<QString, YahooConferenceChatSession *> m_conferences;
YahooChatChatSession * m_chatChatSession;
QStringList m_pendingConfInvites; QStringList m_pendingConfInvites;
QStringList m_pendingWebcamInvites; QStringList m_pendingWebcamInvites;
QStringList m_pendingFileTransfers; QStringList m_pendingFileTransfers;
@ -281,15 +291,12 @@ private:
YahooWebcam *m_webcam; YahooWebcam *m_webcam;
YahooAwayDialog *theAwayDialog; // Our away message dialog
KAction *m_openInboxAction; // Menu item openInbox KAction *m_openInboxAction; // Menu item openInbox
KAction *m_openYABAction; // Menu item openYahooAddressbook KAction *m_openYABAction; // Menu item openYahooAddressbook
KAction *m_editOwnYABEntry; // Menu item editOwnYABEntry KAction *m_editOwnYABEntry; // Menu item editOwnYABEntry
KAction *m_joinChatAction; // Menu item joinChatAction
Client *m_session; // The Connection object Client *m_session; // The Connection object
}; };
#endif // YAHOOACCOUNT_H
#endif

@ -79,10 +79,10 @@ YahooContact::YahooContact( YahooAccount *account, const QString &userId, const
setNickName( fullName ); setNickName( fullName );
setOnlineStatus( static_cast<YahooProtocol*>( m_account->protocol() )->Offline ); setOnlineStatus( static_cast<YahooProtocol*>( m_account->protocol() )->Offline );
setFileCapable( true ); setFileCapable( true );
if ( m_account->haveContactList() ) if ( m_account->haveContactList() )
syncToServer(); syncToServer();
m_webcamDialog = 0L; m_webcamDialog = 0L;
m_webcamAction = 0L; m_webcamAction = 0L;
m_stealthAction = 0L; m_stealthAction = 0L;
@ -108,7 +108,7 @@ void YahooContact::setOnlineStatus(const Kopete::OnlineStatus &status)
{ {
if( m_stealthed && status.internalStatus() <= 999) // Not Stealted -> Stealthed if( m_stealthed && status.internalStatus() <= 999) // Not Stealted -> Stealthed
{ {
Contact::setOnlineStatus( Contact::setOnlineStatus(
Kopete::OnlineStatus(status.status() , Kopete::OnlineStatus(status.status() ,
(status.weight()==0) ? 0 : (status.weight() -1) , (status.weight()==0) ? 0 : (status.weight() -1) ,
protocol() , protocol() ,
@ -120,8 +120,8 @@ void YahooContact::setOnlineStatus(const Kopete::OnlineStatus &status)
Contact::setOnlineStatus( static_cast< YahooProtocol *>( protocol() )->statusFromYahoo( status.internalStatus() - 1000 ) ); Contact::setOnlineStatus( static_cast< YahooProtocol *>( protocol() )->statusFromYahoo( status.internalStatus() - 1000 ) );
else else
Contact::setOnlineStatus( status ); Contact::setOnlineStatus( status );
if( status.status() == Kopete::OnlineStatus::Offline ) if( status.status() == Kopete::OnlineStatus::Offline )
removeProperty( ((YahooProtocol*)(m_account->protocol()))->awayMessage); removeProperty( ((YahooProtocol*)(m_account->protocol()))->awayMessage);
} }
@ -217,14 +217,14 @@ Kopete::ChatSession *YahooContact::manager( Kopete::Contact::CanCreateFlags canC
} }
QString YahooContact::prepareMessage( const QString &messageText ) QString YahooContact::prepareMessage( const QString &messageText )
{ {
// Yahoo does not understand XML/HTML message data, so send plain text // Yahoo does not understand XML/HTML message data, so send plain text
// instead. (Yahoo has its own format for "rich text".) // instead. (Yahoo has its own format for "rich text".)
QString newMsg( messageText ); QString newMsg( messageText );
QRegExp regExp; QRegExp regExp;
int pos = 0; int pos = 0;
regExp.setMinimal( true ); regExp.setMinimal( true );
// find and replace Bold-formattings // find and replace Bold-formattings
regExp.setPattern( "<span([^>]*)font-weight:600([^>]*)>(.*)</span>" ); regExp.setPattern( "<span([^>]*)font-weight:600([^>]*)>(.*)</span>" );
pos = 0; pos = 0;
@ -235,7 +235,7 @@ QString YahooContact::prepareMessage( const QString &messageText )
newMsg.replace( regExp, QString::fromLatin1("<span\\1font-weight:600\\2>\033[1m\\3\033[x1m</span>" ) ); newMsg.replace( regExp, QString::fromLatin1("<span\\1font-weight:600\\2>\033[1m\\3\033[x1m</span>" ) );
} }
} }
// find and replace Underline-formattings // find and replace Underline-formattings
regExp.setPattern( "<span([^>]*)text-decoration:underline([^>]*)>(.*)</span>" ); regExp.setPattern( "<span([^>]*)text-decoration:underline([^>]*)>(.*)</span>" );
pos = 0; pos = 0;
@ -246,7 +246,7 @@ QString YahooContact::prepareMessage( const QString &messageText )
newMsg.replace( regExp, QString::fromLatin1("<span\\1text-decoration:underline\\2>\033[4m\\3\033[x4m</span>" ) ); newMsg.replace( regExp, QString::fromLatin1("<span\\1text-decoration:underline\\2>\033[4m\\3\033[x4m</span>" ) );
} }
} }
// find and replace Italic-formattings // find and replace Italic-formattings
regExp.setPattern( "<span([^>]*)font-style:italic([^>]*)>(.*)</span>" ); regExp.setPattern( "<span([^>]*)font-style:italic([^>]*)>(.*)</span>" );
pos = 0; pos = 0;
@ -257,7 +257,7 @@ QString YahooContact::prepareMessage( const QString &messageText )
newMsg.replace( regExp, QString::fromLatin1("<span\\1font-style:italic\\2>\033[2m\\3\033[x2m</span>" ) ); newMsg.replace( regExp, QString::fromLatin1("<span\\1font-style:italic\\2>\033[2m\\3\033[x2m</span>" ) );
} }
} }
// find and replace Color-formattings // find and replace Color-formattings
regExp.setPattern( "<span([^>]*)color:#([0-9a-zA-Z]*)([^>]*)>(.*)</span>" ); regExp.setPattern( "<span([^>]*)color:#([0-9a-zA-Z]*)([^>]*)>(.*)</span>" );
pos = 0; pos = 0;
@ -268,7 +268,7 @@ QString YahooContact::prepareMessage( const QString &messageText )
newMsg.replace( regExp, QString::fromLatin1("<span\\1\\3>\033[#\\2m\\4\033[#000000m</span>" ) ); newMsg.replace( regExp, QString::fromLatin1("<span\\1\\3>\033[#\\2m\\4\033[#000000m</span>" ) );
} }
} }
// find and replace Font-formattings // find and replace Font-formattings
regExp.setPattern( "<span([^>]*)font-family:([^;\"]*)([^>]*)>(.*)</span>" ); regExp.setPattern( "<span([^>]*)font-family:([^;\"]*)([^>]*)>(.*)</span>" );
pos = 0; pos = 0;
@ -279,7 +279,7 @@ QString YahooContact::prepareMessage( const QString &messageText )
newMsg.replace( regExp, QString::fromLatin1("<span\\1\\3><font face=\"\\2\">\\4</span>" ) ); newMsg.replace( regExp, QString::fromLatin1("<span\\1\\3><font face=\"\\2\">\\4</span>" ) );
} }
} }
// find and replace Size-formattings // find and replace Size-formattings
regExp.setPattern( "<span([^>]*)font-size:([0-9]*)pt([^>]*)>(.*)</span>" ); regExp.setPattern( "<span([^>]*)font-size:([0-9]*)pt([^>]*)>(.*)</span>" );
pos = 0; pos = 0;
@ -290,7 +290,7 @@ QString YahooContact::prepareMessage( const QString &messageText )
newMsg.replace( regExp, QString::fromLatin1("<span\\1\\3><font size=\"\\2\">\\4</span>" ) ); newMsg.replace( regExp, QString::fromLatin1("<span\\1\\3><font size=\"\\2\">\\4</span>" ) );
} }
} }
// remove span-tags // remove span-tags
regExp.setPattern( "<span([^>]*)>(.*)</span>" ); regExp.setPattern( "<span([^>]*)>(.*)</span>" );
pos = 0; pos = 0;
@ -301,7 +301,7 @@ QString YahooContact::prepareMessage( const QString &messageText )
newMsg.replace( regExp, QString::fromLatin1("\\2") ); newMsg.replace( regExp, QString::fromLatin1("\\2") );
} }
} }
// convert escaped chars // convert escaped chars
newMsg.replace( QString::fromLatin1( "&gt;" ), QString::fromLatin1( ">" ) ); newMsg.replace( QString::fromLatin1( "&gt;" ), QString::fromLatin1( ">" ) );
newMsg.replace( QString::fromLatin1( "&lt;" ), QString::fromLatin1( "<" ) ); newMsg.replace( QString::fromLatin1( "&lt;" ), QString::fromLatin1( "<" ) );
@ -310,19 +310,19 @@ QString YahooContact::prepareMessage( const QString &messageText )
newMsg.replace( QString::fromLatin1( "&amp;" ), QString::fromLatin1( "&" ) ); newMsg.replace( QString::fromLatin1( "&amp;" ), QString::fromLatin1( "&" ) );
newMsg.replace( QString::fromLatin1( "<br />" ), QString::fromLatin1( "\r" ) ); newMsg.replace( QString::fromLatin1( "<br />" ), QString::fromLatin1( "\r" ) );
newMsg.replace( QString::fromLatin1( "<br/>" ), QString::fromLatin1( "\r" ) ); newMsg.replace( QString::fromLatin1( "<br/>" ), QString::fromLatin1( "\r" ) );
return newMsg; return newMsg;
} }
void YahooContact::slotSendMessage( Kopete::Message &message ) void YahooContact::slotSendMessage( Kopete::Message &message )
{ {
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
QString messageText = message.escapedBody(); QString messageText = message.escapedBody();
kdDebug(YAHOO_GEN_DEBUG) << "Original message: " << messageText << endl; kdDebug(YAHOO_GEN_DEBUG) << "Original message: " << messageText << endl;
messageText = prepareMessage( messageText ); messageText = prepareMessage( messageText );
kdDebug(YAHOO_GEN_DEBUG) << "Converted message: " << messageText << endl; kdDebug(YAHOO_GEN_DEBUG) << "Converted message: " << messageText << endl;
Kopete::ContactPtrList m_them = manager(Kopete::Contact::CanCreate)->members(); Kopete::ContactPtrList m_them = manager(Kopete::Contact::CanCreate)->members();
Kopete::Contact *target = m_them.first(); Kopete::Contact *target = m_them.first();
@ -331,9 +331,9 @@ void YahooContact::slotSendMessage( Kopete::Message &message )
m_account->yahooSession()->setChatSessionState( m_userId, false ); m_account->yahooSession()->setChatSessionState( m_userId, false );
m_sessionActive = true; m_sessionActive = true;
} }
m_account->yahooSession()->sendMessage( static_cast<YahooContact *>(target)->m_userId, messageText ); m_account->yahooSession()->sendMessage( static_cast<YahooContact *>(target)->m_userId, messageText );
// append message to window // append message to window
manager(Kopete::Contact::CanCreate)->appendMessage(message); manager(Kopete::Contact::CanCreate)->appendMessage(message);
manager(Kopete::Contact::CanCreate)->messageSucceeded(); manager(Kopete::Contact::CanCreate)->messageSucceeded();
@ -341,7 +341,7 @@ void YahooContact::slotSendMessage( Kopete::Message &message )
void YahooContact::sendFile( const KURL &sourceURL, const QString &fileName, uint fileSize ) void YahooContact::sendFile( const KURL &sourceURL, const QString &fileName, uint fileSize )
{ {
Kopete::TransferManager::transferManager()->sendFile( sourceURL, fileName, fileSize, Kopete::TransferManager::transferManager()->sendFile( sourceURL, fileName, fileSize,
false, this, SLOT(slotSendFile( const KURL & )) ); false, this, SLOT(slotSendFile( const KURL & )) );
} }
@ -374,7 +374,7 @@ QPtrList<KAction> *YahooContact::customContextMenuActions()
else else
m_webcamAction->setEnabled( false ); m_webcamAction->setEnabled( false );
actionCollection->append( m_webcamAction ); actionCollection->append( m_webcamAction );
if( !m_inviteWebcamAction ) if( !m_inviteWebcamAction )
{ {
m_inviteWebcamAction = new KAction( i18n( "Invite to view your Webcam" ), "webcamsend", KShortcut(), m_inviteWebcamAction = new KAction( i18n( "Invite to view your Webcam" ), "webcamsend", KShortcut(),
@ -385,7 +385,7 @@ QPtrList<KAction> *YahooContact::customContextMenuActions()
else else
m_inviteWebcamAction->setEnabled( false ); m_inviteWebcamAction->setEnabled( false );
actionCollection->append( m_inviteWebcamAction ); actionCollection->append( m_inviteWebcamAction );
if ( !m_buzzAction ) if ( !m_buzzAction )
{ {
m_buzzAction = new KAction( i18n( "&Buzz Contact" ), "bell", KShortcut(), this, SLOT( buzzContact() ), this, "buzz_contact"); m_buzzAction = new KAction( i18n( "&Buzz Contact" ), "bell", KShortcut(), this, SLOT( buzzContact() ), this, "buzz_contact");
@ -405,7 +405,7 @@ QPtrList<KAction> *YahooContact::customContextMenuActions()
else else
m_stealthAction->setEnabled( false ); m_stealthAction->setEnabled( false );
actionCollection->append( m_stealthAction ); actionCollection->append( m_stealthAction );
if ( !m_inviteConferenceAction ) if ( !m_inviteConferenceAction )
{ {
m_inviteConferenceAction = new KAction( i18n( "&Invite to Conference" ), "kontact_contacts", KShortcut(), this, SLOT( inviteConference() ), this, "invite_conference"); m_inviteConferenceAction = new KAction( i18n( "&Invite to Conference" ), "kontact_contacts", KShortcut(), this, SLOT( inviteConference() ), this, "invite_conference");
@ -415,16 +415,16 @@ QPtrList<KAction> *YahooContact::customContextMenuActions()
else else
m_inviteConferenceAction->setEnabled( false ); m_inviteConferenceAction->setEnabled( false );
actionCollection->append( m_inviteConferenceAction ); actionCollection->append( m_inviteConferenceAction );
if ( !m_profileAction ) if ( !m_profileAction )
{ {
m_profileAction = new KAction( i18n( "&View Yahoo Profile" ), "kontact_notes", KShortcut(), this, SLOT( slotUserProfile() ), this, "profile_contact"); m_profileAction = new KAction( i18n( "&View Yahoo Profile" ), "kontact_notes", KShortcut(), this, SLOT( slotUserProfile() ), this, "profile_contact");
} }
m_profileAction->setEnabled( true ); m_profileAction->setEnabled( true );
actionCollection->append( m_profileAction ); actionCollection->append( m_profileAction );
return actionCollection; return actionCollection;
//return 0L; //return 0L;
} }
@ -435,7 +435,7 @@ void YahooContact::slotUserInfo()
{ {
readYABEntry(); // No YABEntry was set, so read the one from contactlist.xml readYABEntry(); // No YABEntry was set, so read the one from contactlist.xml
} }
YahooUserInfoDialog *dlg = new YahooUserInfoDialog( this, Kopete::UI::Global::mainWidget(), "yahoo userinfo" ); YahooUserInfoDialog *dlg = new YahooUserInfoDialog( this, Kopete::UI::Global::mainWidget(), "yahoo userinfo" );
dlg->setData( *m_YABEntry ); dlg->setData( *m_YABEntry );
dlg->setAccountConnected( m_account->isConnected() ); dlg->setAccountConnected( m_account->isConnected() );
@ -446,7 +446,7 @@ void YahooContact::slotUserInfo()
void YahooContact::slotUserProfile() void YahooContact::slotUserProfile()
{ {
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
QString profileSiteString = QString::fromLatin1("http://profiles.yahoo.com/") + userId(); QString profileSiteString = QString::fromLatin1("http://profiles.yahoo.com/") + userId();
KRun::runURL( KURL( profileSiteString ) , "text/html" ); KRun::runURL( KURL( profileSiteString ) , "text/html" );
} }
@ -474,21 +474,21 @@ void YahooContact::stealthContact()
} }
if( stealthed() ) if( stealthed() )
stealthWidget->radioPermOffline->setChecked( true ); stealthWidget->radioPermOffline->setChecked( true );
// Show dialog // Show dialog
if ( stealthSettingDialog->exec() == QDialog::Rejected ) if ( stealthSettingDialog->exec() == QDialog::Rejected )
{ {
stealthSettingDialog->delayedDestruct(); stealthSettingDialog->delayedDestruct();
return; return;
} }
// Apply permanent setting // Apply permanent setting
if( stealthed() && !stealthWidget->radioPermOffline->isChecked() ) if( stealthed() && !stealthWidget->radioPermOffline->isChecked() )
m_account->yahooSession()->stealthContact( m_userId, Yahoo::StealthPermOffline, Yahoo::StealthNotActive ); m_account->yahooSession()->stealthContact( m_userId, Yahoo::StealthPermOffline, Yahoo::StealthNotActive );
else if( !stealthed() && stealthWidget->radioPermOffline->isChecked() ) else if( !stealthed() && stealthWidget->radioPermOffline->isChecked() )
m_account->yahooSession()->stealthContact( m_userId, Yahoo::StealthPermOffline, Yahoo::StealthActive ); m_account->yahooSession()->stealthContact( m_userId, Yahoo::StealthPermOffline, Yahoo::StealthActive );
// Apply temporary setting // Apply temporary setting
if( m_account->myself()->onlineStatus() == YahooProtocol::protocol()->Invisible ) if( m_account->myself()->onlineStatus() == YahooProtocol::protocol()->Invisible )
{ {
@ -509,7 +509,7 @@ void YahooContact::buzzContact()
{ {
Kopete::ContactPtrList m_them = manager(Kopete::Contact::CanCreate)->members(); Kopete::ContactPtrList m_them = manager(Kopete::Contact::CanCreate)->members();
Kopete::Contact *target = m_them.first(); Kopete::Contact *target = m_them.first();
m_account->yahooSession()->sendBuzz( static_cast<YahooContact*>(target)->m_userId ); m_account->yahooSession()->sendBuzz( static_cast<YahooContact*>(target)->m_userId );
KopeteView *view = manager(Kopete::Contact::CannotCreate)->view(false); KopeteView *view = manager(Kopete::Contact::CannotCreate)->view(false);
@ -526,8 +526,8 @@ void YahooContact::buzzContact()
void YahooContact::sendBuddyIconChecksum( int checksum ) void YahooContact::sendBuddyIconChecksum( int checksum )
{ {
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
m_account->yahooSession()->sendPictureChecksum( checksum, m_userId ); m_account->yahooSession()->sendPictureChecksum( m_userId, checksum );
} }
void YahooContact::sendBuddyIconInfo( const QString &url, int checksum ) void YahooContact::sendBuddyIconInfo( const QString &url, int checksum )
@ -539,25 +539,32 @@ void YahooContact::sendBuddyIconInfo( const QString &url, int checksum )
void YahooContact::sendBuddyIconUpdate( int type ) void YahooContact::sendBuddyIconUpdate( int type )
{ {
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
m_account->yahooSession()->sendPictureStatusUpdate( m_userId, type );
// FIXME (same)
//m_account->yahooSession()->sendPictureStatusUpdate( m_userId, type );
} }
void YahooContact::setDisplayPicture(KTempFile *f, int checksum) // new version
void YahooContact::setDisplayPicture(const QByteArray &data, int checksum)
{ {
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << data.size() << endl;
if( !f )
return; QString newlocation = locateLocal( "appdata", "yahoopictures/"+ contactId().lower().replace(QRegExp("[./~]"),"-") +".png" ) ;
// stolen from msncontact.cpp ;)
QString newlocation=locateLocal( "appdata", "yahoopictures/"+ contactId().lower().replace(QRegExp("[./~]"),"-") +".png" ) ;
setProperty( YahooProtocol::protocol()->iconCheckSum, checksum ); setProperty( YahooProtocol::protocol()->iconCheckSum, checksum );
KIO::Job *j=KIO::file_move( KURL::fromPathOrURL( f->name() ) , KURL::fromPathOrURL( newlocation ) , -1, true /*overwrite*/ , false /*resume*/ , false /*showProgressInfo*/ ); QFile f( newlocation );
if (!f.open( IO_WriteOnly ))
f->setAutoDelete(false); {
delete f; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << "Saving of " << newlocation << " failed!" << endl;
return;
//let the time to KIO to copy the file }
connect(j, SIGNAL(result(KIO::Job *)) , this, SLOT(slotEmitDisplayPictureChanged() )); f.writeBlock(data.data(), data.size());
f.close();
setProperty( Kopete::Global::Properties::self()->photo(), QString() );
setProperty( Kopete::Global::Properties::self()->photo() , newlocation );
emit displayPictureChanged();
} }
@ -566,10 +573,10 @@ void YahooContact::setYABEntry( YABEntry *entry, bool show )
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << userId() << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << userId() << endl;
if( m_YABEntry ) if( m_YABEntry )
delete m_YABEntry; delete m_YABEntry;
m_YABEntry = entry; m_YABEntry = entry;
writeYABEntry(); // Store data in Contact writeYABEntry(); // Store data in Contact
if( show ) if( show )
slotUserInfo(); slotUserInfo();
} }
@ -598,7 +605,7 @@ void YahooContact::inviteWebcam()
{ {
if ( !KStandardDirs::findExe("jasper") ) if ( !KStandardDirs::findExe("jasper") )
{ {
KMessageBox::queuedMessageBox( Kopete::UI::Global::mainWidget(), KMessageBox::Error, KMessageBox::queuedMessageBox( Kopete::UI::Global::mainWidget(), KMessageBox::Error,
i18n("I cannot find the jasper image convert program.\njasper is required to render the yahoo webcam images." i18n("I cannot find the jasper image convert program.\njasper is required to render the yahoo webcam images."
"\nPlease see %1 for further information.").arg("http://wiki.kde.org/tiki-index.php?page=Kopete%20Webcam%20Support") ); "\nPlease see %1 for further information.").arg("http://wiki.kde.org/tiki-index.php?page=Kopete%20Webcam%20Support") );
return; return;
@ -628,21 +635,21 @@ void YahooContact::webcamPaused()
void YahooContact::initWebcamViewer() void YahooContact::initWebcamViewer()
{ {
//KImageIO::registerFormats(); //KImageIO::registerFormats();
if ( !m_webcamDialog ) if ( !m_webcamDialog )
{ {
m_webcamDialog = new YahooWebcamDialog( userId(), Kopete::UI::Global::mainWidget() ); m_webcamDialog = new YahooWebcamDialog( userId(), Kopete::UI::Global::mainWidget() );
// QObject::connect( m_webcamDialog, SIGNAL( closeClicked() ), this, SLOT( closeWebcamDialog() ) ); // QObject::connect( m_webcamDialog, SIGNAL( closeClicked() ), this, SLOT( closeWebcamDialog() ) );
QObject::connect( this, SIGNAL( signalWebcamClosed( int ) ), QObject::connect( this, SIGNAL( signalWebcamClosed( int ) ),
m_webcamDialog, SLOT( webcamClosed( int ) ) ); m_webcamDialog, SLOT( webcamClosed( int ) ) );
QObject::connect( this, SIGNAL( signalWebcamPaused() ), QObject::connect( this, SIGNAL( signalWebcamPaused() ),
m_webcamDialog, SLOT( webcamPaused() ) ); m_webcamDialog, SLOT( webcamPaused() ) );
QObject::connect( this, SIGNAL ( signalReceivedWebcamImage( const QPixmap& ) ), QObject::connect( this, SIGNAL ( signalReceivedWebcamImage( const QPixmap& ) ),
m_webcamDialog, SLOT( newImage( const QPixmap& ) ) ); m_webcamDialog, SLOT( newImage( const QPixmap& ) ) );
QObject::connect( m_webcamDialog, SIGNAL ( closingWebcamDialog ( ) ), QObject::connect( m_webcamDialog, SIGNAL ( closingWebcamDialog ( ) ),
this, SLOT ( closeWebcamDialog ( ) ) ); this, SLOT ( closeWebcamDialog ( ) ) );
} }
@ -653,12 +660,12 @@ void YahooContact::requestWebcam()
{ {
if ( !KStandardDirs::findExe("jasper") ) if ( !KStandardDirs::findExe("jasper") )
{ {
KMessageBox::queuedMessageBox( Kopete::UI::Global::mainWidget(), KMessageBox::Error, KMessageBox::queuedMessageBox( Kopete::UI::Global::mainWidget(), KMessageBox::Error,
i18n("I cannot find the jasper image convert program.\njasper is required to render the yahoo webcam images." i18n("I cannot find the jasper image convert program.\njasper is required to render the yahoo webcam images."
"\nPlease see %1 for further information.").arg("http://wiki.kde.org/tiki-index.php?page=Kopete%20Webcam%20Support") ); "\nPlease see %1 for further information.").arg("http://wiki.kde.org/tiki-index.php?page=Kopete%20Webcam%20Support") );
return; return;
} }
if( !m_webcamDialog ) if( !m_webcamDialog )
initWebcamViewer(); initWebcamViewer();
m_account->yahooSession()->requestWebcam( contactId() ); m_account->yahooSession()->requestWebcam( contactId() );
@ -668,13 +675,13 @@ void YahooContact::closeWebcamDialog()
{ {
QObject::disconnect( this, SIGNAL( signalWebcamClosed( int ) ), QObject::disconnect( this, SIGNAL( signalWebcamClosed( int ) ),
m_webcamDialog, SLOT( webcamClosed( int ) ) ); m_webcamDialog, SLOT( webcamClosed( int ) ) );
QObject::disconnect( this, SIGNAL( signalWebcamPaused() ), QObject::disconnect( this, SIGNAL( signalWebcamPaused() ),
m_webcamDialog, SLOT( webcamPaused( ) ) ); m_webcamDialog, SLOT( webcamPaused( ) ) );
QObject::disconnect( this, SIGNAL ( signalReceivedWebcamImage( const QPixmap& ) ), QObject::disconnect( this, SIGNAL ( signalReceivedWebcamImage( const QPixmap& ) ),
m_webcamDialog, SLOT( newImage( const QPixmap& ) ) ); m_webcamDialog, SLOT( newImage( const QPixmap& ) ) );
QObject::disconnect( m_webcamDialog, SIGNAL ( closingWebcamDialog ( ) ), QObject::disconnect( m_webcamDialog, SIGNAL ( closingWebcamDialog ( ) ),
this, SLOT ( closeWebcamDialog ( ) ) ); this, SLOT ( closeWebcamDialog ( ) ) );
if( m_receivingWebcam ) if( m_receivingWebcam )
@ -686,10 +693,10 @@ void YahooContact::closeWebcamDialog()
void YahooContact::deleteContact() void YahooContact::deleteContact()
{ {
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
if( !m_account->isOnServer( contactId() ) ) if( !m_account->isOnServer( contactId() ) )
{ {
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << "Contact does not exist on server-side. Not removing..." << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << "Contact does not exist on server-side. Not removing..." << endl;
} }
else else
{ {
@ -699,7 +706,7 @@ void YahooContact::deleteContact()
readYABEntry(); readYABEntry();
if( m_YABEntry->YABId ) if( m_YABEntry->YABId )
m_account->yahooSession()->deleteYABEntry( *m_YABEntry ); m_account->yahooSession()->deleteYABEntry( *m_YABEntry );
// Now remove from the contactlist // Now remove from the contactlist
m_account->yahooSession()->removeBuddy( contactId(), m_groupName ); m_account->yahooSession()->removeBuddy( contactId(), m_groupName );
} }
@ -709,19 +716,19 @@ void YahooContact::deleteContact()
void YahooContact::writeYABEntry() void YahooContact::writeYABEntry()
{ {
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
// Personal // Personal
setProperty( YahooProtocol::protocol()->propfirstName, m_YABEntry->firstName ); setProperty( YahooProtocol::protocol()->propfirstName, m_YABEntry->firstName );
setProperty( YahooProtocol::protocol()->propSecondName, m_YABEntry->secondName ); setProperty( YahooProtocol::protocol()->propSecondName, m_YABEntry->secondName );
setProperty( YahooProtocol::protocol()->propLastName, m_YABEntry->lastName ); setProperty( YahooProtocol::protocol()->propLastName, m_YABEntry->lastName );
setProperty( YahooProtocol::protocol()->propNickName, m_YABEntry->nickName ); setProperty( YahooProtocol::protocol()->propNickName, m_YABEntry->nickName );
setProperty( YahooProtocol::protocol()->propTitle, m_YABEntry->title ); setProperty( YahooProtocol::protocol()->propTitle, m_YABEntry->title );
// Primary Information // Primary Information
setProperty( YahooProtocol::protocol()->propPhoneMobile, m_YABEntry->phoneMobile ); setProperty( YahooProtocol::protocol()->propPhoneMobile, m_YABEntry->phoneMobile );
setProperty( YahooProtocol::protocol()->propEmail, m_YABEntry->email ); setProperty( YahooProtocol::protocol()->propEmail, m_YABEntry->email );
setProperty( YahooProtocol::protocol()->propYABId, m_YABEntry->YABId ); setProperty( YahooProtocol::protocol()->propYABId, m_YABEntry->YABId );
// Additional Information // Additional Information
setProperty( YahooProtocol::protocol()->propPager, m_YABEntry->pager ); setProperty( YahooProtocol::protocol()->propPager, m_YABEntry->pager );
setProperty( YahooProtocol::protocol()->propFax, m_YABEntry->fax ); setProperty( YahooProtocol::protocol()->propFax, m_YABEntry->fax );
@ -735,7 +742,7 @@ void YahooContact::writeYABEntry()
setProperty( YahooProtocol::protocol()->propImSkype, m_YABEntry->imSkype ); setProperty( YahooProtocol::protocol()->propImSkype, m_YABEntry->imSkype );
setProperty( YahooProtocol::protocol()->propImIRC, m_YABEntry->imIRC ); setProperty( YahooProtocol::protocol()->propImIRC, m_YABEntry->imIRC );
setProperty( YahooProtocol::protocol()->propImQQ, m_YABEntry->imQQ ); setProperty( YahooProtocol::protocol()->propImQQ, m_YABEntry->imQQ );
// Private Information // Private Information
setProperty( YahooProtocol::protocol()->propPrivateAddress, m_YABEntry->privateAdress ); setProperty( YahooProtocol::protocol()->propPrivateAddress, m_YABEntry->privateAdress );
setProperty( YahooProtocol::protocol()->propPrivateCity, m_YABEntry->privateCity ); setProperty( YahooProtocol::protocol()->propPrivateCity, m_YABEntry->privateCity );
@ -744,7 +751,7 @@ void YahooContact::writeYABEntry()
setProperty( YahooProtocol::protocol()->propPrivateCountry, m_YABEntry->privateCountry ); setProperty( YahooProtocol::protocol()->propPrivateCountry, m_YABEntry->privateCountry );
setProperty( YahooProtocol::protocol()->propPrivatePhone, m_YABEntry->privatePhone ); setProperty( YahooProtocol::protocol()->propPrivatePhone, m_YABEntry->privatePhone );
setProperty( YahooProtocol::protocol()->propPrivateURL, m_YABEntry->privateURL ); setProperty( YahooProtocol::protocol()->propPrivateURL, m_YABEntry->privateURL );
// Work Information // Work Information
setProperty( YahooProtocol::protocol()->propCorporation, m_YABEntry->corporation ); setProperty( YahooProtocol::protocol()->propCorporation, m_YABEntry->corporation );
setProperty( YahooProtocol::protocol()->propWorkAddress, m_YABEntry->workAdress ); setProperty( YahooProtocol::protocol()->propWorkAddress, m_YABEntry->workAdress );
@ -754,7 +761,7 @@ void YahooContact::writeYABEntry()
setProperty( YahooProtocol::protocol()->propWorkCountry, m_YABEntry->workCountry ); setProperty( YahooProtocol::protocol()->propWorkCountry, m_YABEntry->workCountry );
setProperty( YahooProtocol::protocol()->propWorkPhone, m_YABEntry->workPhone ); setProperty( YahooProtocol::protocol()->propWorkPhone, m_YABEntry->workPhone );
setProperty( YahooProtocol::protocol()->propWorkURL, m_YABEntry->workURL ); setProperty( YahooProtocol::protocol()->propWorkURL, m_YABEntry->workURL );
// Miscellanous // Miscellanous
setProperty( YahooProtocol::protocol()->propBirthday, m_YABEntry->birthday.toString( Qt::ISODate ) ); setProperty( YahooProtocol::protocol()->propBirthday, m_YABEntry->birthday.toString( Qt::ISODate ) );
setProperty( YahooProtocol::protocol()->propAnniversary, m_YABEntry->anniversary.toString( Qt::ISODate ) ); setProperty( YahooProtocol::protocol()->propAnniversary, m_YABEntry->anniversary.toString( Qt::ISODate ) );
@ -770,7 +777,7 @@ void YahooContact::readYABEntry()
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl; kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
if( m_YABEntry ) if( m_YABEntry )
delete m_YABEntry; delete m_YABEntry;
m_YABEntry = new YABEntry; m_YABEntry = new YABEntry;
m_YABEntry->yahooId = userId(); m_YABEntry->yahooId = userId();
// Personal // Personal
@ -779,12 +786,12 @@ void YahooContact::readYABEntry()
m_YABEntry->lastName = property( YahooProtocol::protocol()->propLastName ).value().toString(); m_YABEntry->lastName = property( YahooProtocol::protocol()->propLastName ).value().toString();
m_YABEntry->nickName = property( YahooProtocol::protocol()->propNickName ).value().toString(); m_YABEntry->nickName = property( YahooProtocol::protocol()->propNickName ).value().toString();
m_YABEntry->title = property( YahooProtocol::protocol()->propTitle ).value().toString(); m_YABEntry->title = property( YahooProtocol::protocol()->propTitle ).value().toString();
// Primary Information // Primary Information
m_YABEntry->phoneMobile = property( YahooProtocol::protocol()->propPhoneMobile ).value().toString(); m_YABEntry->phoneMobile = property( YahooProtocol::protocol()->propPhoneMobile ).value().toString();
m_YABEntry->email = property( YahooProtocol::protocol()->propEmail ).value().toString(); m_YABEntry->email = property( YahooProtocol::protocol()->propEmail ).value().toString();
m_YABEntry->YABId = property( YahooProtocol::protocol()->propYABId ).value().toInt(); m_YABEntry->YABId = property( YahooProtocol::protocol()->propYABId ).value().toInt();
// Additional Information // Additional Information
m_YABEntry->pager = property( YahooProtocol::protocol()->propPager ).value().toString(); m_YABEntry->pager = property( YahooProtocol::protocol()->propPager ).value().toString();
m_YABEntry->fax = property( YahooProtocol::protocol()->propFax ).value().toString(); m_YABEntry->fax = property( YahooProtocol::protocol()->propFax ).value().toString();
@ -798,7 +805,7 @@ void YahooContact::readYABEntry()
m_YABEntry->imSkype = property( YahooProtocol::protocol()->propImSkype ).value().toString(); m_YABEntry->imSkype = property( YahooProtocol::protocol()->propImSkype ).value().toString();
m_YABEntry->imIRC = property( YahooProtocol::protocol()->propImIRC ).value().toString(); m_YABEntry->imIRC = property( YahooProtocol::protocol()->propImIRC ).value().toString();
m_YABEntry->imQQ = property( YahooProtocol::protocol()->propImQQ ).value().toString(); m_YABEntry->imQQ = property( YahooProtocol::protocol()->propImQQ ).value().toString();
// Private Information // Private Information
m_YABEntry->privateAdress = property( YahooProtocol::protocol()->propPrivateAddress ).value().toString(); m_YABEntry->privateAdress = property( YahooProtocol::protocol()->propPrivateAddress ).value().toString();
m_YABEntry->privateCity = property( YahooProtocol::protocol()->propPrivateCity ).value().toString(); m_YABEntry->privateCity = property( YahooProtocol::protocol()->propPrivateCity ).value().toString();
@ -807,8 +814,8 @@ void YahooContact::readYABEntry()
m_YABEntry->privateCountry = property( YahooProtocol::protocol()->propPrivateCountry ).value().toString(); m_YABEntry->privateCountry = property( YahooProtocol::protocol()->propPrivateCountry ).value().toString();
m_YABEntry->privatePhone = property( YahooProtocol::protocol()->propPrivatePhone ).value().toString(); m_YABEntry->privatePhone = property( YahooProtocol::protocol()->propPrivatePhone ).value().toString();
m_YABEntry->privateURL = property( YahooProtocol::protocol()->propPrivateURL ).value().toString(); m_YABEntry->privateURL = property( YahooProtocol::protocol()->propPrivateURL ).value().toString();
// Work Information // Work Information
m_YABEntry->corporation = property( YahooProtocol::protocol()->propCorporation ).value().toString(); m_YABEntry->corporation = property( YahooProtocol::protocol()->propCorporation ).value().toString();
m_YABEntry->workAdress = property( YahooProtocol::protocol()->propWorkAddress ).value().toString(); m_YABEntry->workAdress = property( YahooProtocol::protocol()->propWorkAddress ).value().toString();
m_YABEntry->workCity = property( YahooProtocol::protocol()->propWorkCity ).value().toString(); m_YABEntry->workCity = property( YahooProtocol::protocol()->propWorkCity ).value().toString();

@ -68,7 +68,7 @@ public:
void receivedWebcamImage( const QPixmap& ); void receivedWebcamImage( const QPixmap& );
void webcamClosed( int ); void webcamClosed( int );
void webcamPaused(); void webcamPaused();
const YABEntry *yabEntry(); const YABEntry *yabEntry();
static QString prepareMessage( const QString &messageText ); static QString prepareMessage( const QString &messageText );
@ -83,7 +83,7 @@ public slots:
void requestWebcam(); void requestWebcam();
void inviteWebcam(); void inviteWebcam();
void buzzContact(); void buzzContact();
void setDisplayPicture(KTempFile *f, int checksum); void setDisplayPicture(const QByteArray &data, int checksum);
void sendBuddyIconInfo( const QString &url, int checksum ); void sendBuddyIconInfo( const QString &url, int checksum );
void sendBuddyIconUpdate( int type ); void sendBuddyIconUpdate( int type );
void sendBuddyIconChecksum( int checksum ); void sendBuddyIconChecksum( int checksum );
@ -117,7 +117,7 @@ private slots:
void readYABEntry(); void readYABEntry();
private: private:
QString m_userId; QString m_userId;
QString m_groupName; QString m_groupName;
YABEntry *m_YABEntry; YABEntry *m_YABEntry;
YahooChatSession *m_manager; YahooChatSession *m_manager;
@ -126,12 +126,12 @@ private:
bool m_stealthed; bool m_stealthed;
bool m_receivingWebcam; bool m_receivingWebcam;
bool m_sessionActive; bool m_sessionActive;
KAction* m_stealthAction; KAction* m_stealthAction;
KAction* m_profileAction; KAction* m_profileAction;
KAction* m_webcamAction; KAction* m_webcamAction;
KAction* m_inviteWebcamAction; KAction* m_inviteWebcamAction;
KAction* m_buzzAction; KAction* m_buzzAction;
KAction* m_inviteConferenceAction; KAction* m_inviteConferenceAction;
}; };

Loading…
Cancel
Save