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 \
webcamtask.cpp conferencetask.cpp sendauthresptask.cpp pingtask.cpp yabtask.cpp \
yabentry.cpp modifyyabtask.cpp chatsessiontask.cpp sendfiletask.cpp filetransfernotifiertask.cpp \
receivefiletask.cpp
receivefiletask.cpp yahoochattask.cpp
libkyahoo_la_LDFLAGS = -no-undefined $(all_libraries)
libkyahoo_la_LIBADD = $(LIB_QT)
noinst_HEADERS = logintask.h yabentry.h yabtask.h modifyyabtask.h \
chatsessiontask.h
chatsessiontask.h yahoochattask.h
KDE_OPTIONS = nofinal

@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Change our Status
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2005-2006 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@ -19,12 +19,12 @@
#include "ymsgtransfer.h"
#include "yahootypes.h"
#include "client.h"
#include <qstring.h>
#include <kdebug.h>
ChangeStatusTask::ChangeStatusTask(Task* parent) : Task(parent)
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
}
ChangeStatusTask::~ChangeStatusTask()
@ -33,7 +33,7 @@ ChangeStatusTask::~ChangeStatusTask()
void ChangeStatusTask::onGo()
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
if( m_status == Yahoo::StatusInvisible ) // status --> Invisible
{
@ -58,7 +58,7 @@ void ChangeStatusTask::onGo()
if( client()->status() == Yahoo::StatusInvisible ) // Invisible --> Status
sendVisibility( Visible );
}
setSuccess( true );
setSuccess();
}
void ChangeStatusTask::sendVisibility( Visibility visible )

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

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

@ -2,7 +2,7 @@
Kopete Yahoo Protocol
chatsessiontask.h - Register / Unregister a chatsession
Copyright (c) 2006 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2006 André Duffeck <duffeck@kde.org>
Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>

@ -1,11 +1,11 @@
/*
Kopete Yahoo Protocol
Copyright (c) 2005-2006 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2005-2006 André Duffeck <duffeck@kde.org>
Copyright (c) 2004 Duncan Mac-Vicar P. <duncan@kde.org>
Copyright (c) 2004 Matt Rogers <matt.rogers@kdemail.net>
Copyright (c) 2004 SuSE Linux AG <http://www.suse.com>
Copyright (C) 2003 Justin Karneges
Copyright (C) 2003 Justin Karneges <justin@affinix.com>
Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
@ -20,9 +20,9 @@
*/
#include <qtimer.h>
#include <qpixmap.h>
#include <kdebug.h>
#include <kurl.h>
#include <ksocketbase.h>
#include "yahooclientstream.h"
@ -52,6 +52,7 @@
#include "sendfiletask.h"
#include "filetransfernotifiertask.h"
#include "receivefiletask.h"
#include "yahoochattask.h"
#include "client.h"
#include "yahootypes.h"
#include "yahoobuddyiconloader.h"
@ -86,6 +87,8 @@ public:
ConferenceTask *conferenceTask;
YABTask *yabTask;
FileTransferNotifierTask *fileTransferTask;
YahooChatTask *yahooChatTask;
ReceiveFileTask *receiveFileTask;
// Connection data
uint sessionID;
@ -95,10 +98,13 @@ public:
Yahoo::Status status;
Yahoo::Status statusOnConnect;
QString statusMessageOnConnect;
int pictureFlag;
Yahoo::PictureStatus pictureFlag;
int pictureChecksum;
bool buddyListReady;
QStringList pictureRequestQueue;
};
Client::Client(QObject *par) :QObject(par, "yahooclient" )
Client::Client(QObject *par) :QObject(par, "yahooclient")
{
d = new ClientPrivate;
/* d->tzoffset = 0;*/
@ -112,13 +118,15 @@ Client::Client(QObject *par) :QObject(par, "yahooclient" )
d->iconLoader = 0L;
d->loginTask = new LoginTask( d->root );
d->listTask = new ListTask( d->root );
d->pictureFlag = 0;
d->pictureFlag = Yahoo::NoPicture;
d->buddyListReady = false;
m_connector = 0L;
m_pingTimer = new QTimer( this );
QObject::connect( m_pingTimer, SIGNAL( timeout() ), this, SLOT( sendPing() ) );
QObject::connect( d->loginTask, SIGNAL( haveSessionID( uint ) ), SLOT( lt_gotSessionID( uint ) ) );
QObject::connect( d->loginTask, SIGNAL( buddyListReady() ), SLOT( processPictureQueue() ) );
QObject::connect( d->loginTask, SIGNAL( loginResponse( int, const QString& ) ),
SLOT( slotLoginResponse( int, const QString& ) ) );
QObject::connect( d->loginTask, SIGNAL( haveCookies() ), SLOT( slotGotCookies() ) );
@ -138,7 +146,7 @@ Client::~Client()
void Client::connect( const QString &host, const uint port, const QString &userId, const QString &pass )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
d->host = host;
d->port = port;
d->user = userId;
@ -151,6 +159,7 @@ void Client::connect( const QString &host, const uint port, const QString &userI
QObject::connect( d->stream, SIGNAL( connected() ), this, SLOT( cs_connected() ) );
QObject::connect( d->stream, SIGNAL( error(int) ), this, SLOT( streamError(int) ) );
QObject::connect( d->stream, SIGNAL( readyRead() ), this, SLOT( streamReadyRead() ) );
QObject::connect( d->stream, SIGNAL( connectionClosed() ), this, SLOT( streamDisconnected() ) );
d->stream->connectToServer( host, false );
}
@ -162,9 +171,9 @@ void Client::cancelConnect()
void Client::cs_connected()
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
emit connected();
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " starting login task ... "<< endl;
kdDebug(YAHOO_RAW_DEBUG) << " starting login task ... " << endl;
d->loginTask->setStateOnConnect( (d->statusOnConnect == Yahoo::StatusInvisible) ? Yahoo::StatusInvisible : Yahoo::StatusAvailable );
d->loginTask->go();
@ -173,7 +182,7 @@ void Client::cs_connected()
void Client::close()
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
m_pingTimer->stop();
if( d->active )
{
@ -191,6 +200,8 @@ void Client::close()
if( m_connector )
m_connector->deleteLater();
m_connector = 0L;
d->active = false;
d->buddyListReady = false;
}
int Client::error()
@ -211,18 +222,18 @@ QString Client::errorInformation()
// SLOTS //
void Client::streamError( int error )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "CLIENT ERROR (Error " << error << ")" << endl;
kdDebug(YAHOO_RAW_DEBUG) << "CLIENT ERROR (Error " << error << ")" << endl;
QString msg;
d->active = false;
// Examine error
if( error == ClientStream::ErrConnection ) // Ask Connector in this case
if( error == ClientStream::ErrConnection && m_connector ) // Ask Connector in this case
{
d->error = m_connector->errorCode();
d->errorString = KSocketBase::errorString( (KSocketBase::SocketError)d->error );
}
else
else if( d->stream )
{
d->error = error;
d->errorString = d->stream->errorText();
@ -241,9 +252,15 @@ void Client::streamReadyRead()
distribute( transfer );
}
void Client::streamDisconnected()
{
d->active = false;
emit disconnected();
}
void Client::lt_loginFinished()
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
slotLoginResponse( d->loginTask->statusCode(), d->loginTask->statusString() );
}
@ -258,26 +275,27 @@ void Client::slotLoginResponse( int response, const QString &msg )
changeStatus( d->statusOnConnect, d->statusMessageOnConnect, Yahoo::StatusTypeAway );
d->statusMessageOnConnect = QString::null;
setStatus( d->statusOnConnect );
m_pingTimer->start( 60 * 1000 );
/* only send a ping every hour. we get disconnected otherwise */
m_pingTimer->start( 60 * 60 * 1000 );
initTasks();
} else {
d->active = false;
close();
}
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Emitting loggedIn" << endl;
kdDebug(YAHOO_RAW_DEBUG) << "Emitting loggedIn" << endl;
emit loggedIn( response, msg );
}
void Client::lt_gotSessionID( uint id )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Got SessionID: " << id << endl;
kdDebug(YAHOO_RAW_DEBUG) << "Got SessionID: " << id << endl;
d->sessionID = id;
}
void Client::slotGotCookies()
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Y: " << d->loginTask->yCookie()
kdDebug(YAHOO_RAW_DEBUG) << "Y: " << d->loginTask->yCookie()
<< " T: " << d->loginTask->tCookie()
<< " C: " << d->loginTask->cCookie() << endl;
d->yCookie = d->loginTask->yCookie();
@ -388,7 +406,7 @@ void Client::cancelFileTransfer( unsigned int transferId )
void Client::changeStatus( Yahoo::Status status, const QString &message, Yahoo::StatusType type )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "status: " << status
kdDebug(YAHOO_RAW_DEBUG) << "status: " << status
<< " message: " << message
<< " type: " << type << endl;
ChangeStatusTask *cst = new ChangeStatusTask( d->root );
@ -398,7 +416,7 @@ void Client::changeStatus( Yahoo::Status status, const QString &message, Yahoo::
cst->go( true );
if( status == Yahoo::StatusInvisible )
stealthContact( QString::null, Yahoo::StealthOnline, Yahoo::StealthClear );
stealthContact( QString(), Yahoo::StealthOnline, Yahoo::StealthClear );
setStatus( status );
}
@ -416,10 +434,10 @@ void Client::sendPing()
{
if( !d->active )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Disconnected. NOT sending a PING." << endl;
kdDebug(YAHOO_RAW_DEBUG) << "Disconnected. NOT sending a PING." << endl;
return;
}
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Sending a PING." << endl;
kdDebug(YAHOO_RAW_DEBUG) << "Sending a PING." << endl;
PingTask *pt = new PingTask( d->root );
pt->go( true );
}
@ -438,6 +456,10 @@ void Client::stealthContact(QString const &userId, Yahoo::StealthMode mode, Yaho
void Client::addBuddy( const QString &userId, const QString &group, const QString &message )
{
ModifyBuddyTask *mbt = new ModifyBuddyTask( d->root );
QObject::connect(mbt, SIGNAL(buddyAddResult( const QString &, const QString &, bool )),
SIGNAL(buddyAddResult( const QString &, const QString &, bool)));
mbt->setType( ModifyBuddyTask::AddBuddy );
mbt->setTarget( userId );
mbt->setGroup( group );
@ -448,6 +470,10 @@ void Client::addBuddy( const QString &userId, const QString &group, const QStrin
void Client::removeBuddy( const QString &userId, const QString &group )
{
ModifyBuddyTask *mbt = new ModifyBuddyTask( d->root );
QObject::connect(mbt, SIGNAL(buddyRemoveResult( const QString &, const QString &, bool )),
SIGNAL(buddyRemoveResult( const QString &, const QString &, bool)));
mbt->setType( ModifyBuddyTask::RemoveBuddy );
mbt->setTarget( userId );
mbt->setGroup( group );
@ -457,6 +483,10 @@ void Client::removeBuddy( const QString &userId, const QString &group )
void Client::moveBuddy( const QString &userId, const QString &oldGroup, const QString &newGroup )
{
ModifyBuddyTask *mbt = new ModifyBuddyTask( d->root );
QObject::connect(mbt, SIGNAL(buddyChangeGroupResult( const QString &, const QString &, bool )),
SIGNAL(buddyChangeGroupResult( const QString &, const QString &, bool)));
mbt->setType( ModifyBuddyTask::MoveBuddy );
mbt->setTarget( userId );
mbt->setOldGroup( oldGroup );
@ -466,8 +496,33 @@ void Client::moveBuddy( const QString &userId, const QString &oldGroup, const QS
// ***** Buddyicon handling *****
void Client::processPictureQueue()
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
d->buddyListReady = true;
if( d->pictureRequestQueue.isEmpty() )
{
return;
}
requestPicture( d->pictureRequestQueue.front() );
d->pictureRequestQueue.pop_front();
if( !d->pictureRequestQueue.isEmpty() )
{
QTimer::singleShot( 1000, this, SLOT(processPictureQueue()) );
}
}
void Client::requestPicture( const QString &userId )
{
if( !d->buddyListReady )
{
d->pictureRequestQueue << userId;
return;
}
RequestPictureTask *rpt = new RequestPictureTask( d->root );
rpt->setTarget( userId );
rpt->go( true );
@ -478,8 +533,8 @@ void Client::downloadPicture( const QString &userId, KURL url, int checksum )
if( !d->iconLoader )
{
d->iconLoader = new YahooBuddyIconLoader( this );
QObject::connect( d->iconLoader, SIGNAL(fetchedBuddyIcon(const QString&, KTempFile*, int )),
SIGNAL(pictureDownloaded(const QString&, KTempFile*, int ) ) );
QObject::connect( d->iconLoader, SIGNAL(fetchedBuddyIcon(const QString&, const QByteArray &, int )),
SIGNAL(pictureDownloaded(const QString&, const QByteArray &, int ) ) );
}
d->iconLoader->fetchBuddyIcon( QString(userId), KURL(url), checksum );
@ -487,32 +542,31 @@ void Client::downloadPicture( const QString &userId, KURL url, int checksum )
void Client::uploadPicture( KURL url )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "URL: " << url.url() << endl;
kdDebug(YAHOO_RAW_DEBUG) << "URL: " << url.url() << endl;
SendPictureTask *spt = new SendPictureTask( d->root );
spt->setType( SendPictureTask::UploadPicture );
spt->setFilename( url.fileName() );
if ( url.isLocalFile() )
spt->setPath( url.path() );
spt->setPath( url.path() ); // FIXME: to test if is what we want
else
spt->setPath( url.url() );
d->pictureFlag = 2;
spt->go( true );
}
void Client::sendPictureChecksum( int checksum, const QString &who )
void Client::sendPictureChecksum( const QString &userId, int checksum )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "checksum: " << checksum << endl;
kdDebug(YAHOO_RAW_DEBUG) << "checksum: " << checksum << endl;
SendPictureTask *spt = new SendPictureTask( d->root );
spt->setType( SendPictureTask::SendChecksum );
spt->setChecksum( checksum );
if( !who.isEmpty() )
spt->setTarget( who );
if( !userId.isEmpty() )
spt->setTarget( userId );
spt->go( true );
}
void Client::sendPictureInformation( const QString &userId, const QString &url, int checksum )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "checksum: " << checksum << endl;
kdDebug(YAHOO_RAW_DEBUG) << "checksum: " << checksum << endl;
SendPictureTask *spt = new SendPictureTask( d->root );
spt->setType( SendPictureTask::SendInformation );
spt->setChecksum( checksum );
@ -521,13 +575,16 @@ void Client::sendPictureInformation( const QString &userId, const QString &url,
spt->go( true );
}
void Client::sendPictureStatusUpdate( const QString &userId, int type )
void Client::setPictureStatus( Yahoo::PictureStatus status )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Setting PictureStatus to: " << type << endl;
if( d->pictureFlag == status )
return;
kdDebug(YAHOO_RAW_DEBUG) << "Setting PictureStatus to: " << status << endl;
d->pictureFlag = status;
SendPictureTask *spt = new SendPictureTask( d->root );
spt->setType( SendPictureTask::SendStatus );
spt->setStatus( type );
spt->setTarget( userId );
spt->setStatus( status );
spt->go( true );
}
@ -624,10 +681,36 @@ void Client::deleteYABEntry( YABEntry &entry )
myt->go(true);
}
// ***** Yahoo Chat *****
void Client::getYahooChatCategories()
{
d->yahooChatTask->getYahooChatCategories();
}
void Client::getYahooChatRooms( const Yahoo::ChatCategory &category )
{
d->yahooChatTask->getYahooChatRooms( category );
}
void Client::joinYahooChatRoom( const Yahoo::ChatRoom &room )
{
d->yahooChatTask->joinRoom( room );
}
void Client::sendYahooChatMessage( const QString &msg, const QString &handle )
{
d->yahooChatTask->sendYahooChatMessage( msg, handle );
}
void Client::leaveChat()
{
d->yahooChatTask->logout();
}
// ***** other *****
void Client::notifyError( const QString &info, const QString & errorString, LogLevel level )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << QString::fromLatin1("\nThe following error occured: %1\n Reason: %2\n LogLevel: %3")
kdDebug(YAHOO_RAW_DEBUG) << QString::fromLatin1("\nThe following error occurred: %1\n Reason: %2\n LogLevel: %3")
.arg(info).arg(errorString).arg(level) << endl;
d->errorString = errorString;
d->errorInformation = info;
@ -675,12 +758,6 @@ QString Client::password()
return d->pass;
}
QCString Client::ipAddress()
{
//TODO determine ip address
return "127.0.0.1";
}
QString Client::host()
{
return d->host;
@ -701,9 +778,14 @@ int Client::pictureFlag()
return d->pictureFlag;
}
void Client::setPictureFlag( int flag )
int Client::pictureChecksum()
{
d->pictureFlag = flag;
return d->pictureChecksum;
}
void Client::setPictureChecksum( int cs )
{
d->pictureChecksum = cs;
}
QString Client::yCookie()
@ -723,7 +805,7 @@ QString Client::cCookie()
void Client::distribute( Transfer * transfer )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
if( !rootTask()->take( transfer ) )
kdDebug(YAHOO_RAW_DEBUG) << "CLIENT: root task refused transfer" << endl;
delete transfer;
@ -731,7 +813,7 @@ void Client::distribute( Transfer * transfer )
void Client::send( Transfer* request )
{
kdDebug(YAHOO_RAW_DEBUG) << "CLIENT::send()"<< endl;
kdDebug(YAHOO_RAW_DEBUG) << "CLIENT::send()" << endl;
if( !d->stream )
{
kdDebug(YAHOO_RAW_DEBUG) << "CLIENT - NO STREAM TO SEND ON!" << endl;
@ -757,8 +839,8 @@ void Client::initTasks()
return;
d->statusTask = new StatusNotifierTask( d->root );
QObject::connect( d->statusTask, SIGNAL( statusChanged( const QString&, int, const QString&, int, int ) ),
SIGNAL( statusChanged( const QString&, int, const QString&, int, int ) ) );
QObject::connect( d->statusTask, SIGNAL( statusChanged(const QString&,int,const QString&,int,int,int) ),
SIGNAL( statusChanged(const QString&,int,const QString&,int,int,int) ) );
QObject::connect( d->statusTask, SIGNAL( stealthStatusChanged( const QString&, Yahoo::StealthStatus ) ),
SIGNAL( stealthStatusChanged( const QString&, Yahoo::StealthStatus ) ) );
QObject::connect( d->statusTask, SIGNAL( loginResponse( int, const QString& ) ),
@ -769,8 +851,6 @@ void Client::initTasks()
SIGNAL( authorizationAccepted( const QString& ) ) );
QObject::connect( d->statusTask, SIGNAL( gotAuthorizationRequest( const QString &, const QString &, const QString & ) ),
SIGNAL( gotAuthorizationRequest( const QString &, const QString &, const QString & ) ) );
QObject::connect( d->statusTask, SIGNAL( gotPictureChecksum( const QString &, int ) ),
SIGNAL( pictureChecksumNotify( const QString &, int ) ) );
d->mailTask = new MailNotifierTask( d->root );
QObject::connect( d->mailTask, SIGNAL( mailNotify(const QString&, const QString&, int) ),
@ -797,8 +877,8 @@ void Client::initTasks()
SIGNAL( pictureInfoNotify( const QString &, KURL, int ) ) );
QObject::connect( d->pictureNotifierTask, SIGNAL( pictureRequest( const QString & ) ),
SIGNAL( pictureRequest( const QString & ) ) );
QObject::connect( d->pictureNotifierTask, SIGNAL( pictureUploaded( const QString & ) ),
SIGNAL( pictureUploaded( const QString & ) ) );
QObject::connect( d->pictureNotifierTask, SIGNAL( pictureUploaded( const QString &, int ) ),
SIGNAL( pictureUploaded( const QString &, int ) ) );
d->webcamTask = new WebcamTask( d->root );
QObject::connect( d->webcamTask, SIGNAL( webcamImageReceived( const QString &, const QPixmap &) ),
@ -840,9 +920,23 @@ void Client::initTasks()
d->fileTransferTask = new FileTransferNotifierTask( d->root );
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 &,
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()
@ -864,6 +958,10 @@ void Client::deleteTasks()
d->yabTask = 0L;
d->fileTransferTask->deleteLater();
d->fileTransferTask = 0;
d->yahooChatTask->deleteLater();
d->yahooChatTask = 0;
d->receiveFileTask->deleteLater();
d->receiveFileTask = 0;
}
#include "client.moc"

@ -1,13 +1,13 @@
/*
Kopete Yahoo Protocol
Copyright (c) 2005-2006 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2005-2006 André Duffeck <duffeck@kde.org>
Copyright (c) 2004 Duncan Mac-Vicar P. <duncan@kde.org>
Copyright (c) 2004 Matt Rogers <matt.rogers@kdemail.net>
Copyright (c) 2004 SuSE Linux AG <http://www.suse.com>
Copyright (C) 2003 Justin Karneges
Copyright (C) 2003 Justin Karneges <justin@affinix.com>
Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
*************************************************************************
* *
@ -23,21 +23,22 @@
#define LIBYAHOO_CLIENT_H
#include <qobject.h>
#include <kurl.h>
#include "transfer.h"
#include "yahootypes.h"
#define YMSG_PROGRAM_VERSION_STRING "7,5,0,33"
#define YMSG_PROGRAM_VERSION_STRING "8.1.0.209"
class QString;
class QTimer;
class QPixmap;
class QDomDocument;
class ClientStream;
class KNetworkConnector;
class Task;
class KURL;
class KTempFile;
class YABEntry;
class SendFileTask;
class KTemporaryFile;
struct YABEntry;
class Client : public QObject
{
@ -53,41 +54,43 @@ Q_OBJECT
Client(QObject *parent=0);
~Client();
/**
* Set the Yahoo Id of the account
* @param username The Yahoo Id
*/
void setUserId( const QString& userName );
/**
* Set the picture checksum
* @param username The checksum
*/
void setPictureChecksum( int cs );
/**
* Start a connection to the server using the supplied @ref ClientStream.
* This is only a transport layer connection.
* Needed for protocol action P1.
* @param s initialised client stream to use for the connection.
* @param server the server to connect to - but this is also set on the connector used to construct the clientstream??
* @param auth indicate whether we're connecting to the authorizer or the bos server
* @param host The server to connect to.
* @param port The port to be used. The Yahoo server allows connection on arbitrary ports.
* @param userId The yahoo ID that will be connected.
* @param pass The password.
*/
void connect( const QString &host, const uint port, const QString &userId, const QString &pass );
/**
* Cancel active login attemps
*/
/** Cancel active login attemps */
void cancelConnect();
/**
* Logout and disconnect
*/
/** Logout and disconnect */
void close();
/**
* Returns the errorcode
*/
/** Returns the errorcode */
int error();
/**
* Returns a description of the error
*/
/** Returns a description of the error */
QString errorString();
/**
* Returns information about what went wrong
*/
/** Returns information about what went wrong */
QString errorInformation();
/**
@ -106,23 +109,10 @@ Q_OBJECT
*/
void setStatusMessageOnConnect( const QString &msg );
/**
* Accessors needed for login
*/
/** Accessors needed for login */
QString host();
int port();
/**
* return the pictureFlag describing the status of our buddy icon
* 0 = no icon, 2 = icon, 1 = avatar (?)
*/
int pictureFlag();
/**
* set the pictureFlag describing the status of our buddy icon
*/
void setPictureFlag( int flag );
/**
* Send a Typing notification
* @param to the buddy that should be notified
@ -175,159 +165,243 @@ Q_OBJECT
/**
* Remove a buddy from the contact list
* @param userId the yahoo ID of the buddy that should be removed
* @param group the group where the buddy belongs to
*/
void removeBuddy( const QString &userId, const QString &group );
/**
* Move a buddy into another group
* @param userId the yahoo ID of the buddy that should be moved
* @param oldGroup the group where the buddy belongs to
* @param newGroup the group where the buddy will be placed
*/
void moveBuddy( const QString &userId, const QString &oldGroup, const QString &newGroup );
/**
* Change the stealth status of a buddy
* @param userId the yahoo ID of the buddy that should be moved
* @param mode defines the Stealth mode that is changed. That can be "Appear Offline", "Appear Online" or "Apper permanently offline"
* @param state the status of the specified Stealth mode. Active, Not Active or Clear
*/
void stealthContact( QString const &userId, Yahoo::StealthMode mode, Yahoo::StealthStatus state );
/**
* Request the buddy's picture
* @param userId the yahoo ID of the buddy
*/
void requestPicture( const QString &userId );
/**
* Download the buddy's picture
* @param userId the yahoo ID of the buddy
* @param url the url of the picture
* @param checksum the checksum of the picture
*/
void downloadPicture( const QString &userId, KURL url, int checksum );
/**
* Send our picture
* @param url the file that should be sent as our buddy picture
*/
void uploadPicture( KURL url );
/**
* Send checksum of our picture
* @param userId the yahoo ID of the buddy. Can be a null string if the picture has changed.
* @param checksum the checksum of the picture
*/
void sendPictureChecksum( int checksum, const QString & );
void sendPictureChecksum( const QString &userId, int checksum );
/**
* Send information about our picture
* @param userId the yahoo ID of the buddy that should be informed
* @param url the url of our picture
* @param checksum the checksum of the picture
*/
void sendPictureInformation( const QString &userId, const QString &url, int checksum );
/**
* Notify the buddies about our new status
* @param flag the type of our picture (0=none, 1=avatar, 2=picture)
*/
void sendPictureStatusUpdate( const QString &userId, int type );
void setPictureStatus( Yahoo::PictureStatus flag );
/**
* Send a response to the webcam invite ( Accept / Decline )
* @param userId the yahoo ID of the sender
*/
void requestWebcam( const QString &userId );
/**
* Stop receiving of webcam
* @param userId the yahoo ID of the sender
*/
void closeWebcam( const QString &userId );
/**
* Invite the user to view your Webcam
* @param userId the yahoo ID of the receiver
*/
void sendWebcamInvite( const QString &userId );
/**
* transmit a new image to the watchers
* @param image the image data
*/
void sendWebcamImage( const QByteArray &image );
/**
* Stop transmission
*/
/** Stop the webcam transmission */
void closeOutgoingWebcam();
/**
* Allow a buddy to watch the cam
* @param userId the yahoo ID of the receiver
*/
void grantWebcamAccess( const QString &userId );
/**
* Invite buddies to a conference
* @param room the name of the conference
* @param members a list of members that are invited to the conference
* @param msg the invite message
*/
void inviteConference( const QString &room, const QStringList &members, const QString &msg );
/**
* Invite buddies to a already existing conference
* @param room the name of the conference
* @param who a list of members that are additionally invited to the conference
* @param members a list of members that are already in the conference
* @param msg the invite message
*/
void addInviteConference( const QString &room, const QStringList &who, const QStringList &members, const QString &msg );
/**
* Join a conference
* @param room the name of the conference
* @param members a list of members that are already in the conference
*/
void joinConference( const QString &room, const QStringList &members );
/**
* Decline to join a conference
* @param room the name of the conference
* @param members a list of members that are in the conference
* @param msg the reason why we don't want to join
*/
void declineConference( const QString &room, const QStringList &members, const QString &msg );
/**
* Leave the conference
* @param room the name of the conference
* @param members a list of members that are in the conference
*/
void leaveConference( const QString &room, const QStringList &members );
/**
* Send a message to the conference
* @param room the name of the conference
* @param members a list of members that are in the conference
* @param msg the message
*/
void sendConferenceMessage( const QString &room, const QStringList &members, const QString &msg );
/**
* Send a authorization request response
* @param userId the yahoo ID of the requesting buddy
* @param accept true, if the user is allowed to see our status, false if not
* @param msg the reason for our decision
*/
void sendAuthReply( const QString &userId, bool accept, const QString &msg );
/**
* Fetches all entries of the YAB
* @param lastMerge the YAB-Revision that was last merged with the local YAB
* @param lastRemoteRevision the latest known YAB-Revision
*/
void getYABEntries( long lastMerge, long lastRemoteRevision );
/**
* Saves a modified YAB entry
* @param entry the YAB entry
*/
void saveYABEntry( YABEntry &entry );
/**
* Creates a new YAB entry
* @param entry the YAB entry
*/
void addYABEntry( YABEntry &entry );
/**
* Deletes a YAB entry
* @param entry the YAB entry
*/
void deleteYABEntry( YABEntry &entry );
/**
* Send a file to a buddy
* @param transferId the unique ID of the transfer
* @param userId yahoo ID of the receiver
* @param msg a description of the file to be sent
* @param url the location of the file to be sent
*/
void sendFile( unsigned int transferId, const QString &userId, const QString &msg, KURL url );
/**
* Receive a file from a buddy
* @param transferId the unique ID of the transfer
* @param userId yahoo ID of the sender
* @param remoteURL the url of the file
* @param localURL the location where the file should be stored
*/
void receiveFile( unsigned int transferId, const QString &userId, KURL remoteURL, KURL localURL );
/**
* Reject a file offered by a buddy
* @param userId yahoo ID of the sender
* @param remoteURL the url of the file
*/
void rejectFile( const QString &userId, KURL remoteURL );
/**
* The user canceled the filetransfer
* Canceled a filetransfer
* @param transferId the unique ID of the transfer
*/
void cancelFileTransfer( unsigned int transferId );
/**
* Get the list of yahoo chat categories
*/
void getYahooChatCategories();
/**
* Get the list of chatrooms for the given category
*/
void getYahooChatRooms( const Yahoo::ChatCategory &category );
/**
* Join a chat room
*/
void joinYahooChatRoom( const Yahoo::ChatRoom &room );
/**
* Leave the chat room
*/
void leaveChat();
/**
* Send a chat message
*/
void sendYahooChatMessage( const QString &msg, const QString &handle );
/*************
INTERNAL (FOR USE BY TASKS) METHODS
*************/
/**
* Send an outgoing request to the server
* @param request the transfer to be sent
*/
void send( Transfer *request );
@ -336,39 +410,36 @@ Q_OBJECT
*/
void debug( const QString &str );
/**
* The current user's user ID
*/
/** The current user's user ID */
QString userId();
/**
* The current user's password
*/
/** The current user's password */
QString password();
/**
* Host's IP address
*/
QCString ipAddress();
/** current Session ID */
uint sessionID();
/**
* current Session ID
* return the pictureFlag describing the status of our buddy icon
* 0 = no icon, 2 = icon, 1 = avatar (?)
*/
uint sessionID();
int pictureFlag();
/**
* Get our status
* return the picture checksum
*/
int pictureChecksum();
/** Get our status */
Yahoo::Status status();
/**
* Set our status
* @param status the new status
*/
void setStatus( Yahoo::Status );
void setStatus( Yahoo::Status status );
/**
* Access the root Task for this client, so tasks may be added to it.
*/
/** Access the root Task for this client, so tasks may be added to it. */
Task* rootTask();
/**
@ -412,10 +483,22 @@ Q_OBJECT
* Notifies about our buddies and groups
*/
void gotBuddy( const QString &, const QString &, const QString & );
/**
* Notifies about adding buddies
*/
void buddyAddResult( const QString &, const QString &, bool );
/**
* Notifies about removing buddies
*/
void buddyRemoveResult( const QString &, const QString &, bool );
/**
* Notifies about buddies changing groups
*/
void buddyChangeGroupResult( const QString &, const QString &, bool );
/**
* Notifies about the status of online buddies
*/
void statusChanged( const QString&, int, const QString&, int, int );
void statusChanged( const QString&, int, const QString&, int, int, int );
/**
* Notifies about the stealth status of buddies
*/
@ -459,7 +542,7 @@ Q_OBJECT
/**
* The iconLoader has successfully downloaded a picutre
*/
void pictureDownloaded( const QString &, KTempFile *, int );
void pictureDownloaded( const QString &, const QByteArray &, int );
/**
* A Buddy asks for our picture
*/
@ -467,7 +550,7 @@ Q_OBJECT
/**
* Information about the picture upload
*/
void pictureUploaded( const QString & );
void pictureUploaded( const QString &, int );
/**
* We've received a webcam image from a buddy
*/
@ -545,7 +628,7 @@ Q_OBJECT
*/
void gotYABEntry( YABEntry * );
/**
* An error occured while saving a Yahoo Addressbook entry
* An error occurred while saving a Yahoo Addressbook entry
*/
void modifyYABEntryError( YABEntry *, const QString & );
/**
@ -557,7 +640,7 @@ Q_OBJECT
*/
void fileTransferComplete( unsigned int );
/**
* An error occured during the filetransfer
* An error occurred during the filetransfer
*/
void fileTransferError( unsigned int, int, const QString & );
/**
@ -568,13 +651,38 @@ Q_OBJECT
* A buddy is trying to send us a file
*/
void incomingFileTransfer( const QString &, const QString &, long, const QString &,
const QString &, unsigned long );
const QString &, unsigned long, const QPixmap & );
/**
* We have received the list of yahoo chat categories
*/
void gotYahooChatCategories( const QDomDocument & );
/**
* We have received the list of chatrooms for the categories
*/
void gotYahooChatRooms( const Yahoo::ChatCategory &, const QDomDocument & );
/**
* We have joined a chatroom
*/
void chatRoomJoined( int, int, const QString &, const QString & );
/**
* A buddy has joined a chatroom
*/
void chatBuddyHasJoined( const QString &, const QString &, bool );
/**
* A buddy has left a chatroom
*/
void chatBuddyHasLeft( const QString &, const QString & );
/**
* We have received a message in a chatroom
*/
void chatMessageReceived( const QString &, const QString &, const QString & );
protected slots:
// INTERNAL, FOR USE BY TASKS' finished() SIGNALS //
void lt_loginFinished();
void lt_gotSessionID( uint );
void cs_connected();
void slotGotCookies();
void streamDisconnected();
/**
* Used by tasks to identify a response to a login attempt
@ -595,6 +703,12 @@ Q_OBJECT
* Send a Yahoo Ping packet to the server
*/
void sendPing();
/**
* Send all queued buddy icon requests
*/
void processPictureQueue();
private:
void distribute( Transfer *transfer );
@ -604,7 +718,7 @@ Q_OBJECT
void initTasks();
/**
* remove static tasks and their singal connections
* remove static tasks and their signal connections
*/
void deleteTasks();

@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Handles conferences
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@ -25,7 +25,7 @@
ConferenceTask::ConferenceTask(Task* parent) : Task(parent)
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
}
ConferenceTask::~ConferenceTask()
@ -34,8 +34,6 @@ ConferenceTask::~ConferenceTask()
bool ConferenceTask::take( Transfer* transfer )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
if ( !forMe( transfer ) )
return false;
@ -57,12 +55,10 @@ bool ConferenceTask::take( Transfer* transfer )
return true;
}
bool ConferenceTask::forMe( Transfer* transfer ) const
bool ConferenceTask::forMe( const Transfer* transfer ) const
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
YMSGTransfer *t = 0L;
t = dynamic_cast<YMSGTransfer*>(transfer);
const YMSGTransfer *t = 0L;
t = dynamic_cast<const YMSGTransfer*>(transfer);
if (!t)
return false;
@ -79,7 +75,7 @@ bool ConferenceTask::forMe( Transfer* transfer ) const
void ConferenceTask::parseInvitation( YMSGTransfer *t )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
int i = 0;
QString who = t->firstParam( 50 );
@ -92,9 +88,9 @@ void ConferenceTask::parseInvitation( YMSGTransfer *t )
msg = t->firstParam( 58 );
QStringList members;
for( i = 0; i < t->paramCount( 52 ); i++ )
for( i = 0; i < t->paramCount( 52 ); ++i )
members.append( t->nthParam( 52, i ) );
for( i = 0; i < t->paramCount( 53 ); i++ )
for( i = 0; i < t->paramCount( 53 ); ++i )
members.append( t->nthParam( 53, i ) );
if( who == client()->userId() )
return;
@ -105,7 +101,7 @@ void ConferenceTask::parseInvitation( YMSGTransfer *t )
void ConferenceTask::parseMessage( YMSGTransfer *t )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
QString room = t->firstParam( 57 );
QString from = t->firstParam( 3 );
@ -122,7 +118,7 @@ void ConferenceTask::parseMessage( YMSGTransfer *t )
void ConferenceTask::parseUserJoined( YMSGTransfer *t )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
QString room = t->firstParam( 57 );
QString who = t->firstParam( 53 );
@ -133,7 +129,7 @@ void ConferenceTask::parseUserJoined( YMSGTransfer *t )
void ConferenceTask::parseUserLeft( YMSGTransfer *t )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
QString room = t->firstParam( 57 );
QString who = t->firstParam( 56 );
@ -144,7 +140,7 @@ void ConferenceTask::parseUserLeft( YMSGTransfer *t )
void ConferenceTask::parseUserDeclined( YMSGTransfer *t )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
QString room = t->firstParam( 57 );
QString who = t->firstParam( 54 );
@ -156,7 +152,7 @@ void ConferenceTask::parseUserDeclined( YMSGTransfer *t )
void ConferenceTask::inviteConference( const QString &room, const QStringList &members, const QString &msg )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceConfInvite);
t->setId( client()->sessionID() );
@ -165,7 +161,7 @@ void ConferenceTask::inviteConference( const QString &room, const QStringList &m
t->setParam( 57, room.local8Bit() );
t->setParam( 58, msg.local8Bit() );
t->setParam( 97, 1 );
for( QStringList::const_iterator it = members.begin(); it != members.end(); it++ )
for( QStringList::const_iterator it = members.begin(); it != members.end(); ++it )
t->setParam( 52, (*it).local8Bit() );
t->setParam( 13, "0" );
@ -174,21 +170,21 @@ void ConferenceTask::inviteConference( const QString &room, const QStringList &m
void ConferenceTask::addInvite( const QString &room, const QStringList &who, const QStringList &members, const QString &msg )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceConfAddInvite);
t->setId( client()->sessionID() );
t->setParam( 1, client()->userId().local8Bit() );
QString whoList = who.first();
for( uint i = 1; i < who.size(); i++ )
for( int i = 1; i < who.size(); i++ )
whoList += QString(",%1").arg( who[i] );
t->setParam( 51, whoList.local8Bit() );
t->setParam( 57, room.local8Bit() );
t->setParam( 58, msg.local8Bit() );
t->setParam( 97, 1 );
for( QStringList::const_iterator it = members.begin(); it != members.end(); it++ )
for( QStringList::const_iterator it = members.begin(); it != members.end(); ++it )
{
t->setParam( 52, (*it).local8Bit() );
t->setParam( 53, (*it).local8Bit() ); // Note: this field should only be set if the buddy has already joined the conference, but no harm is done this way
@ -200,12 +196,12 @@ void ConferenceTask::addInvite( const QString &room, const QStringList &who, con
void ConferenceTask::joinConference( const QString &room, const QStringList &members )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceConfLogon);
t->setId( client()->sessionID() );
t->setParam( 1, client()->userId().local8Bit() );
for( QStringList::const_iterator it = members.begin(); it != members.end(); it++ )
for( QStringList::const_iterator it = members.begin(); it != members.end(); ++it )
t->setParam( 3, (*it).local8Bit() );
t->setParam( 57, room.local8Bit() );
@ -214,12 +210,12 @@ void ConferenceTask::joinConference( const QString &room, const QStringList &mem
void ConferenceTask::declineConference( const QString &room, const QStringList &members, const QString &msg )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceConfDecline);
t->setId( client()->sessionID() );
t->setParam( 1, client()->userId().local8Bit() );
for( QStringList::const_iterator it = members.begin(); it != members.end(); it++ )
for( QStringList::const_iterator it = members.begin(); it != members.end(); ++it )
t->setParam( 3, (*it).local8Bit() );
t->setParam( 57, room.local8Bit() );
t->setParam( 14, msg.utf8() );
@ -229,12 +225,12 @@ void ConferenceTask::declineConference( const QString &room, const QStringList &
}
void ConferenceTask::leaveConference( const QString &room, const QStringList &members )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceConfLogoff);
t->setId( client()->sessionID() );
t->setParam( 1, client()->userId().local8Bit() );
for( QStringList::const_iterator it = members.begin(); it != members.end(); it++ )
for( QStringList::const_iterator it = members.begin(); it != members.end(); ++it )
t->setParam( 3, (*it).local8Bit() );
t->setParam( 57, room.local8Bit() );
@ -243,12 +239,12 @@ void ConferenceTask::leaveConference( const QString &room, const QStringList &me
void ConferenceTask::sendMessage( const QString &room, const QStringList &members, const QString &msg )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceConfMsg);
t->setId( client()->sessionID() );
t->setParam( 1, client()->userId().local8Bit() );
for( QStringList::const_iterator it = members.begin(); it != members.end(); it++ )
for( QStringList::const_iterator it = members.begin(); it != members.end(); ++it )
t->setParam( 53, (*it).local8Bit() );
t->setParam( 57, room.local8Bit() );
t->setParam( 14, msg.utf8() );

@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Handles conferences
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@ -32,7 +32,7 @@ public:
~ConferenceTask();
bool take(Transfer *transfer);
bool forMe( Transfer* transfer ) const;
bool forMe( const Transfer* transfer ) const;
void joinConference( const QString &room, const QStringList &members );
void declineConference( const QString &room, const QStringList &members, const QString &msg );

@ -4,7 +4,7 @@
Copyright (c) 2004 Matt Rogers <matt.rogers@kdemail.net>
Based on Iris, Copyright (C) 2003 Justin Karneges
Based on Iris, Copyright (C) 2003 Justin Karneges <justin@affinix.com>
Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>

@ -4,7 +4,7 @@
Copyright (c) 2004 Matt Rogers <matt.rogers@kdemail.net>
Based on code Copyright (c) 2004 SuSE Linux AG <http://www.suse.com>
Based on Iris, Copyright (C) 2003 Justin Karneges
Based on Iris, Copyright (C) 2003 Justin Karneges <justin@affinix.com>
Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>

@ -5,7 +5,7 @@
Based on code
Copyright (c) 2004 SuSE Linux AG <http://www.suse.com>
Copyright (C) 2003 Justin Karneges
Copyright (C) 2003 Justin Karneges <justin@affinix.com>
Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
@ -26,7 +26,6 @@
#include <qdatetime.h>
#include <qtextstream.h>
#include <kdebug.h>
#include <kurl.h>
@ -52,7 +51,7 @@ void CoreProtocol::addIncomingData( const QByteArray & incomingBytes )
{
// store locally
int oldsize = m_in.size();
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << incomingBytes.size() << " bytes. already had " << oldsize << " bytes" << endl;
kdDebug(YAHOO_RAW_DEBUG) << incomingBytes.size() << " bytes. already had " << oldsize << " bytes" << endl;
m_in.resize( oldsize + incomingBytes.size() );
memcpy( m_in.data() + oldsize, incomingBytes.data(), incomingBytes.size() );
@ -67,11 +66,14 @@ void CoreProtocol::addIncomingData( const QByteArray & incomingBytes )
while ( m_in.size() && ( parsedBytes = wireToTransfer(m_in) ) )
{
transferCount++;
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " parsed transfer " << transferCount << " in chunk of "<< parsedBytes << " bytes" << endl;
kdDebug(YAHOO_RAW_DEBUG) << " parsed transfer " << transferCount << " in chunk of "<< parsedBytes << " bytes" << endl;
int size = m_in.size();
if ( parsedBytes < size )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " more data in chunk! ( I have parsed " << parsedBytes << " and total data of " << size << ")" << endl;
kdDebug(YAHOO_RAW_DEBUG) << " more data in chunk! ( I have parsed " << parsedBytes << " and total data of " << size << ")" << endl;
// remove parsed bytes from the buffer
//m_in.remove( 0, parsedBytes );
// copy the unparsed bytes into a new qbytearray and replace m_in with that
QByteArray remainder( size - parsedBytes );
memcpy( remainder.data(), m_in.data() + parsedBytes, remainder.size() );
@ -81,7 +83,7 @@ void CoreProtocol::addIncomingData( const QByteArray & incomingBytes )
m_in.truncate( 0 );
}
if ( m_state == NeedMore )
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " message was incomplete, waiting for more..." << endl;
kdDebug(YAHOO_RAW_DEBUG) << " message was incomplete, waiting for more..." << endl;
/*
if ( m_eventProtocol->state() == EventProtocol::OutOfSync )
{
@ -89,23 +91,23 @@ void CoreProtocol::addIncomingData( const QByteArray & incomingBytes )
m_in.truncate( 0 );
}
*/
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " done processing chunk" << endl;
kdDebug(YAHOO_RAW_DEBUG) << " done processing chunk" << endl;
}
Transfer* CoreProtocol::incomingTransfer()
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
if ( m_state == Available )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " - got a transfer" << endl;
// kdDebug(YAHOO_RAW_DEBUG) << " - got a transfer";
m_state = NoData;
return m_inTransfer;
m_inTransfer = 0;
}
else
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " no milk today" << endl;
kdDebug(YAHOO_RAW_DEBUG) << " no milk today" << endl;
return 0;
}
}
@ -113,7 +115,7 @@ Transfer* CoreProtocol::incomingTransfer()
void cp_dump( const QByteArray &bytes )
{
#ifdef YAHOO_COREPROTOCOL_DEBUG
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " contains " << bytes.count() << " bytes" << endl;
kdDebug(YAHOO_RAW_DEBUG) << " contains " << bytes.count() << " bytes" << endl;
for ( uint i = 0; i < bytes.count(); ++i )
{
printf( "%02x ", bytes[ i ] );
@ -126,18 +128,18 @@ void cp_dump( const QByteArray &bytes )
void CoreProtocol::outgoingTransfer( Transfer* outgoing )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
if ( outgoing->type() == Transfer::YMSGTransfer )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " got YMSGTransfer" << endl;
kdDebug(YAHOO_RAW_DEBUG) << " got YMSGTransfer" << endl;
YMSGTransfer *yt = (YMSGTransfer *) outgoing;
QByteArray bytesOut = yt->serialize();
//QTextStream dout( bytesOut, IO_WriteOnly );
//QTextStream dout( bytesOut, QIODevice::WriteOnly );
//dout.setEncoding( QTextStream::Latin1 );
//dout.setByteOrder( QDataStream::LittleEndian );
//dout << bytesOut;
//kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " " << bytesOut << endl;
//kdDebug(YAHOO_RAW_DEBUG) << " " << bytesOut;
emit outgoingData( bytesOut );
// now convert
//fieldsToWire( fields );
@ -149,7 +151,7 @@ void CoreProtocol::outgoingTransfer( Transfer* outgoing )
int CoreProtocol::wireToTransfer( const QByteArray& wire )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
// processing incoming data and reassembling it into transfers
// may be an event or a response
@ -161,20 +163,27 @@ int CoreProtocol::wireToTransfer( const QByteArray& wire )
return bytesParsed;
}
QDataStream din( wire, IO_ReadOnly );
QByteArray tempWire = wire;
QDataStream din( tempWire, IO_ReadOnly );
// look at first four bytes and decide what to do with the chunk
if ( okToProceed( din ) )
{
if ( (wire[0] == 'Y') && (wire[1] == 'M') && (wire[2] == 'S') && (wire[3] == 'G'))
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " - looks like a valid YMSG packet" << endl;
Transfer *t = m_YMSGProtocol->parse( wire, bytesParsed );
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " - YMSG Protocol parsed " << bytesParsed << " bytes" << endl;
// kdDebug(YAHOO_RAW_DEBUG) << " - looks like a valid YMSG packet";
YMSGTransfer *t = static_cast<YMSGTransfer *>(m_YMSGProtocol->parse( wire, bytesParsed ));
// kdDebug(YAHOO_RAW_DEBUG) << " - YMSG Protocol parsed " << bytesParsed << " bytes";
if ( t )
{
if( wire.size() < t->packetLength() )
{
m_state = NeedMore;
delete t;
return 0;
}
m_inTransfer = t;
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " - got a valid packet " << endl;
// kdDebug(YAHOO_RAW_DEBUG) << " - got a valid packet ";
m_state = Available;
emit incomingData();
@ -184,18 +193,18 @@ int CoreProtocol::wireToTransfer( const QByteArray& wire )
}
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 );
QString remaining = s.read();
int pos = remaining.find( "YMSG", bytesParsed );
if( pos >= 0 )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Recover successful." << endl;
kdDebug(YAHOO_RAW_DEBUG) << "Recover successful." << endl;
bytesParsed += pos;
}
else
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Recover failed. Dump it!" << endl;
kdDebug(YAHOO_RAW_DEBUG) << "Recover failed. Dump it!" << endl;
bytesParsed = wire.size();
}
}
@ -208,7 +217,7 @@ void CoreProtocol::reset()
m_in.resize( 0 );
}
void CoreProtocol::slotOutgoingData( const QCString &out )
void CoreProtocol::slotOutgoingData( const QByteArray &out )
{
qDebug( "%s", out.data() );
}
@ -218,7 +227,7 @@ bool CoreProtocol::okToProceed( QDataStream &din)
if ( din.atEnd() )
{
m_state = NeedMore;
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " saved message prematurely" << endl;
kdDebug(YAHOO_RAW_DEBUG) << " saved message prematurely" << endl;
return false;
}
else

@ -5,7 +5,7 @@
Based on code
Copyright (c) 2004 SuSE Linux AG <http://www.suse.com>
Copyright (C) 2003 Justin Karneges
Copyright (C) 2003 Justin Karneges <justin@affinix.com>
Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
@ -22,9 +22,7 @@
#ifndef YAHOO_CORE_PROTOCOL_H
#define YAHOO_CORE_PROTOCOL_H
#include <qcstring.h>
#include <qobject.h>
#include <qptrlist.h>
class Transfer;
class YMSGProtocol;
@ -81,7 +79,7 @@ protected slots:
/**
* Just a debug method to test emitting to the socket, atm - should go to the ClientStream
*/
void slotOutgoingData( const QCString & );
void slotOutgoingData( const QByteArray & );
protected:
/**

@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Notifies about incoming filetransfers
Copyright (c) 2006 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2006 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@ -19,12 +19,15 @@
#include "ymsgtransfer.h"
#include "yahootypes.h"
#include "client.h"
#include <qstring.h>
#include <qpixmap.h>
#include <kdebug.h>
//#include <kcodecs.h>
FileTransferNotifierTask::FileTransferNotifierTask(Task* parent) : Task(parent)
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
}
FileTransferNotifierTask::~FileTransferNotifierTask()
@ -34,8 +37,6 @@ FileTransferNotifierTask::~FileTransferNotifierTask()
bool FileTransferNotifierTask::take( Transfer* transfer )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
if ( !forMe( transfer ) )
return false;
@ -52,11 +53,10 @@ bool FileTransferNotifierTask::take( Transfer* transfer )
return true;
}
bool FileTransferNotifierTask::forMe( Transfer *transfer ) const
bool FileTransferNotifierTask::forMe( const Transfer *transfer ) const
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
YMSGTransfer *t = 0L;
t = dynamic_cast<YMSGTransfer*>(transfer);
const YMSGTransfer *t = 0L;
t = dynamic_cast<const YMSGTransfer*>(transfer);
if (!t)
return false;
@ -64,7 +64,8 @@ bool FileTransferNotifierTask::forMe( Transfer *transfer ) const
if( t->service() == Yahoo::ServiceP2PFileXfer ||
t->service() == Yahoo::ServicePeerToPeer ||
t->service() == Yahoo::ServiceFileTransfer ||
t->service() == Yahoo::ServiceFileTransfer7
(t->service() == Yahoo::ServiceFileTransfer7 &&
t->firstParam(222).toInt() == 1)
)
return true;
else
@ -73,7 +74,7 @@ bool FileTransferNotifierTask::forMe( Transfer *transfer ) const
void FileTransferNotifierTask::parseFileTransfer( YMSGTransfer *t )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
QString from; /* key = 4 */
QString to; /* key = 5 */
@ -107,12 +108,12 @@ void FileTransferNotifierTask::parseFileTransfer( YMSGTransfer *t )
unsigned int right = url.findRev( '?' );
filename = url.mid( left, right - left );
emit incomingFileTransfer( from, url, expires, msg, filename, size );
emit incomingFileTransfer( from, url, expires, msg, filename, size, QPixmap() );
}
void FileTransferNotifierTask::parseFileTransfer7( YMSGTransfer *t )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
QString from; /* key = 4 */
QString to; /* key = 5 */
@ -121,6 +122,8 @@ void FileTransferNotifierTask::parseFileTransfer7( YMSGTransfer *t )
QString msg; /* key = 14 */
QString filename; /* key = 27 */
unsigned long size; /* key = 28 */
QByteArray preview; /* key = 267 */
QPixmap previewPixmap;
if( t->firstParam( 222 ).toInt() == 2 )
return; // user cancelled the file transfer
@ -128,17 +131,25 @@ void FileTransferNotifierTask::parseFileTransfer7( YMSGTransfer *t )
from = t->firstParam( 4 );
to = t->firstParam( 5 );
url = t->firstParam( 265 );
expires = t->firstParam( 38 ).toLong();
msg = t->firstParam( 14 );
expires = t->firstParam( 38 ).toLong();
filename = t->firstParam( 27 );
size = t->firstParam( 28 ).toULong();
emit incomingFileTransfer( from, url, expires, msg, filename, size );
// FIXME (same)
//preview = QByteArray::fromBase64( t->firstParam( 267 ) );
if( preview.size() > 0 )
{
previewPixmap.loadFromData( preview );
}
emit incomingFileTransfer( from, url, expires, msg, filename, size, previewPixmap );
}
void FileTransferNotifierTask::acceptFileTransfer( YMSGTransfer *transfer )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServicePeerToPeer);
t->setId( client()->sessionID() );

@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Notifies about incoming filetransfers
Copyright (c) 2006 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2006 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@ -22,6 +22,7 @@
class QString;
class YMSGTransfer;
class QPixmap;
/**
@author André Duffeck
@ -36,10 +37,10 @@ public:
bool take(Transfer *transfer);
protected:
bool forMe( Transfer *transfer ) const;
virtual bool forMe( const Transfer *transfer ) const;
signals:
void incomingFileTransfer( const QString &who, const QString &url, long expires, const QString &msg ,
const QString &fname, unsigned long size );
const QString &fname, unsigned long size, const QPixmap &preview );
private:
void parseFileTransfer( YMSGTransfer *transfer );
void parseFileTransfer7( YMSGTransfer *transfer );

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

@ -57,7 +57,7 @@ protected:
*/
bool okToProceed();
/**
* read a Q_UINT32 giving the number of following bytes, then a string of that length
* read a quint32 giving the number of following bytes, then a string of that length
* updates the bytes parsed counter
* @return false if the string was broken or there was no data available at all
*/
@ -66,7 +66,7 @@ protected:
protected:
uint m_state;
uint m_bytes;
QDataStream * m_din;
QDataStream *m_din;
};
#endif

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

@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Handles several lists such as buddylist, ignorelist and so on
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@ -35,14 +35,12 @@ public:
bool take(Transfer *transfer);
protected:
bool forMe( Transfer *transfer ) const;
virtual bool forMe( const Transfer *transfer ) const;
void parseBuddyList( YMSGTransfer *transfer );
void parseStealthList( YMSGTransfer *transfer );
signals:
void gotBuddy(const QString&, const QString&, const QString&);
void stealthStatusChanged( const QString&, Yahoo::StealthStatus );
private:
QString m_list;
};
#endif

@ -3,10 +3,10 @@
Handles logging into to the Yahoo service
Copyright (c) 2004 Duncan Mac-Vicar P. <duncan@kde.org>
Copyright (c) 2005-2006 André Duffeck <duffeck@kde.org>
Copyright 2009 Matt Rogers <mattr@kde.org>
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
Kopete (c) 2002-2009 by the Kopete developers <kopete-devel@kde.org>
*************************************************************************
* *
@ -18,7 +18,7 @@
*************************************************************************
*/
#include <qstring.h>
#include "logintask.h"
#include "transfer.h"
@ -28,6 +28,10 @@
#include <qstring.h>
#include <kdebug.h>
#include <stdlib.h>
#include <kio/job.h>
#include <kmdcodec.h>
extern "C"
{
#include "libyahoo.h"
@ -35,7 +39,7 @@ extern "C"
LoginTask::LoginTask(Task* parent) : Task(parent)
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
mState = InitialState;
}
@ -46,7 +50,6 @@ LoginTask::~LoginTask()
bool LoginTask::take(Transfer* transfer)
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
/*
Yahoo login task has various stages
@ -67,6 +70,12 @@ bool LoginTask::take(Transfer* transfer)
YMSGTransfer *t = static_cast<YMSGTransfer *>(transfer);
if ( t->service() == Yahoo::ServicePing) {
emit buddyListReady();
return true;
}
switch (mState)
{
case (InitialState):
@ -93,14 +102,16 @@ bool LoginTask::take(Transfer* transfer)
}
}
bool LoginTask::forMe(Transfer* transfer) const
bool LoginTask::forMe(const Transfer* transfer) const
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
YMSGTransfer *t = 0L;
t = dynamic_cast<YMSGTransfer*>(transfer);
const YMSGTransfer *t = 0L;
t = dynamic_cast<const YMSGTransfer*>(transfer);
if (!t)
return false;
if ( t->service() == Yahoo::ServicePing)
return true;
switch (mState)
{
case (InitialState):
@ -128,12 +139,12 @@ bool LoginTask::forMe(Transfer* transfer) const
void LoginTask::onGo()
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
/* initial state, we have to send a ServiceVerify */
if (mState == InitialState)
sendVerify();
else
client()->notifyError( "Error in login procedure.", "take called while not in initial state", Client::Debug );
client()->notifyError( "Error in login procedure.", "onGo called while not in initial state", Client::Debug );
}
void LoginTask::reset()
@ -144,7 +155,7 @@ void LoginTask::reset()
void LoginTask::sendVerify()
{
/* send a ServiceVerify */
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceVerify);
send( t );
mState = SentVerify;
@ -152,12 +163,12 @@ void LoginTask::sendVerify()
void LoginTask::sendAuth(YMSGTransfer* transfer)
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
// transfer is the verify ack transfer, no useful data in it.
Q_UNUSED(transfer);
/* got ServiceVerify ACK, send a ServiceAuth with username */
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
YMSGTransfer *t = new YMSGTransfer( Yahoo::ServiceAuth );
t->setParam( 1 , client()->userId().local8Bit() );
send(t);
@ -166,76 +177,225 @@ void LoginTask::sendAuth(YMSGTransfer* transfer)
void LoginTask::sendAuthResp(YMSGTransfer* t)
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
QString sn = t->firstParam( 1 );
QString seed = t->firstParam( 94 );
m_challengeString = seed;
QString version_s = t->firstParam( 13 );
uint sessionID = t->id();
m_sessionID = t->id();
int version = version_s.toInt();
switch (version)
{
case 0:
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Version pre 0x0b "<< version_s << endl;
case 1:
case 2:
kdDebug(YAHOO_RAW_DEBUG) << "Using version 16 authorization" << endl;
sendAuthSixteenStage1(sn, seed);
break;
default:
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Version 0x0b "<< version_s << endl;
sendAuthResp_0x0b(sn, seed, sessionID);
kdDebug(YAHOO_RAW_DEBUG) << "Unknown authentication method used!"
<< "Attempting current authentication anyways" << endl;
sendAuthSixteenStage1(sn, seed);
break;
}
mState = SentAuthResp;
emit haveSessionID( sessionID );
emit haveSessionID( m_sessionID );
}
void LoginTask::sendAuthResp_0x0b(const QString &sn, const QString &seed, uint sessionID)
void LoginTask::sendAuthSixteenStage1(const QString& sn, const QString& seed)
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " with seed " << seed << endl;
char *resp_6 = (char *) malloc(100);
char *resp_96 = (char *) malloc(100);
authresp_0x0b(seed.latin1(), sn.latin1(), (client()->password()).latin1(), resp_6, resp_96);
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "resp_6: " << resp_6 << " resp_69: " << resp_96 << endl;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceAuthResp, m_stateOnConnect);
t->setId( sessionID );
t->setParam( 0 , sn.local8Bit());
t->setParam( 6 , resp_6);
t->setParam( 96 , resp_96);
t->setParam( 59 , "B\\tfckeert1kk1nl&b=2" ); // ???
t->setParam( 135 , "7,0,0,437" ); // Client version
t->setParam( 148 , -60 );
t->setParam( 244 , 524223 );
t->setParam( 1 , sn.local8Bit());
if( !m_verificationWord.isEmpty() )
const QString YahooTokenUrl = "https://login.yahoo.com/config/pwtoken_get?src=ymsgr&ts=&login=%1&passwd=%2&chal=%3";
kdDebug(YAHOO_RAW_DEBUG) << "seed:" << seed << endl;
m_stage1Data= QString::null;
/* construct a URL from the seed and request tokens */
QByteArray encodedUrl;
QString fullUrl = YahooTokenUrl.arg(sn, client()->password(), seed);
KURL tokenUrl(fullUrl);
KIO::Job* job = KIO::get(tokenUrl, true, false);
connect(job, SIGNAL(data(KIO::Job*, const QByteArray&)),
this, SLOT(handleAuthSixteenStage1Data(KIO::Job*, const QByteArray&)));
connect(job, SIGNAL(result(KIO::Job*)),
this, SLOT(handleAuthSixteenStage1Result(KIO::Job*)));
}
void LoginTask::handleAuthSixteenStage1Data(KIO::Job* job, const QByteArray& data)
{
kdDebug(YAHOO_RAW_DEBUG) << "data:" << data << endl;
m_stage1Data.append(data);
}
void LoginTask::handleAuthSixteenStage1Result(KIO::Job* job)
{
int responseNumber = -1;
QString token;
int error = job->error();
kdDebug(YAHOO_RAW_DEBUG) << "error:" << error << endl;
if (error == 0)
{
QStringList responses = QStringList::split("\r\n", m_stage1Data);
responseNumber = responses[0].toInt();
if (responses.count() >= 3)
{
token = responses[1];
token.remove("ymsgr=");
kdDebug(YAHOO_RAW_DEBUG) << "response is:" << responseNumber << endl;
kdDebug(YAHOO_RAW_DEBUG) << "token is:" << token << endl;
}
if (responseNumber != 0)
{
switch(responseNumber)
{
case -1:
/* error in the received stream */
emit loginResponse(Yahoo::LoginSock, QString());
kdDebug(YAHOO_RAW_DEBUG) << "unknown error logging in" << endl;
break;
case 1212:
/* password incorrect */
emit loginResponse(Yahoo::LoginPasswd, QString());
kdDebug(YAHOO_RAW_DEBUG) << "password incorrect" << endl;
break;
case 1213:
/* security lock */
emit loginResponse(Yahoo::LoginLock, QString());
break;
case 1235:
/* username does not exist */
emit loginResponse(Yahoo::LoginUname, QString());
kdDebug(YAHOO_RAW_DEBUG) << "user does not exist" << endl;
break;
case 1214:
case 1236:
emit loginResponse(Yahoo::LoginVerify, QString());
break;
case 100: /* username or password missing */
/*FIXME handle this */
break;
default:
/* FIXME unknown error. handle it! */
break;
}
}
else
{
t->setParam( 227 , m_verificationWord.local8Bit() );
m_verificationWord = QString::null;
/* 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)
{
QStringList responses = QStringList::split("\r\n", m_stage2Data);
kdDebug(YAHOO_RAW_DEBUG) << responses << endl;
responseNumber = responses[0].toInt();
if (responseNumber == 0)
{
crumb = responses[1];
crumb.remove("crumb=");
m_yCookie = responses[2].remove(0,2); /* remove Y= */
m_tCookie = responses[3].remove(0,2); /* remove T= */
}
if (responseNumber != 0)
{
switch(responseNumber)
{
case -1:
emit loginResponse(Yahoo::LoginSock, QString());
break;
case 100:
emit loginResponse(Yahoo::LoginSock, QString());
break;
default: /* try to login anyways */
break;
}
}
else
{
QString cryptString = crumb;
cryptString.append(m_challengeString);
sendAuthSixteenStage3(cryptString);
}
}
}
void LoginTask::sendAuthSixteenStage3(const QString& cryptString)
{
kdDebug(YAHOO_RAW_DEBUG) << " with crypt string" << cryptString << endl;
//QByteArray cryptStringHash = QCryptographicHash::hash( cryptString.toAscii(),
// QCryptographicHash::Md5 );
//cryptStringHash = cryptStringHash.toBase64();
QString cryptStringHash = KMD5( cryptString.ascii() ).base64Digest();
cryptStringHash = cryptStringHash.replace('+', '.');
cryptStringHash = cryptStringHash.replace('/', '_');
cryptStringHash = cryptStringHash.replace('=', '-');
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceAuthResp, m_stateOnConnect);
t->setId( m_sessionID );
t->setParam( 1, client()->userId().local8Bit());
t->setParam( 0 , client()->userId().local8Bit());
t->setParam( 277, m_yCookie.local8Bit() );
t->setParam( 278, m_tCookie.local8Bit() );
t->setParam( 307, cryptStringHash.local8Bit() );
t->setParam( 244, 2097087 );
t->setParam( 2 , client()->userId().local8Bit());
t->setParam( 2, 1 ); // Both parameter 2s wind up in the packet
t->setParam( 135, YMSG_PROGRAM_VERSION_STRING );
free(resp_6);
free(resp_96);
send(t);
}
void LoginTask::sendAuthResp_pre_0x0b(const QString &/*sn*/, const QString &/*seed*/)
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
}
void LoginTask::handleAuthResp(YMSGTransfer *t)
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
switch( t->service() )
{
case( Yahoo::ServiceList ):
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Emitting Signal" << endl;
emit loginResponse( Yahoo::LoginOk, QString::null );
kdDebug(YAHOO_RAW_DEBUG) << "Emitting Signal" << endl;
emit loginResponse( Yahoo::LoginOk, QString() );
break;
case( Yahoo::ServiceAuthResp ):
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Emitting Signal" << endl;
kdDebug(YAHOO_RAW_DEBUG) << "Emitting Signal" << endl;
emit loginResponse( t->firstParam( 66 ).toInt(), t->firstParam( 20 ) );
break;
default:
@ -251,7 +411,7 @@ void LoginTask::setStateOnConnect( Yahoo::Status status )
void LoginTask::parseCookies( YMSGTransfer *t )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
for( int i = 0; i < t->paramCount( 59 ); ++i)
{
@ -271,8 +431,7 @@ void LoginTask::parseCookies( YMSGTransfer *t )
m_cCookie = getcookie( cookie.latin1() );
}
}
if( !m_yCookie.isEmpty() && !m_tCookie.isEmpty() &&
!m_cCookie.isEmpty() )
if( !m_yCookie.isEmpty() && !m_tCookie.isEmpty())
emit haveCookies();
}

@ -4,7 +4,7 @@
Copyright (c) 2004 Duncan Mac-Vicar P. <duncan@kde.org>
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2005 André Duffeck <duffeck@kde.org>
Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
@ -27,6 +27,11 @@
class QString;
class YMSGTransfer;
namespace KIO
{
class Job;
}
/**
@author Duncan Mac-Vicar
*/
@ -49,7 +54,7 @@ public:
const QString &tCookie();
const QString &loginCookie();
protected:
bool forMe( Transfer* transfer ) const;
virtual bool forMe( const Transfer* transfer ) const;
enum State { InitialState, SentVerify, GotVerifyACK, SentAuth, GotAuthACK, SentAuthResp };
void sendVerify();
void sendAuth(YMSGTransfer* transfer);
@ -58,10 +63,20 @@ protected:
void sendAuthResp_pre_0x0b(const QString &sn, const QString &seed);
void handleAuthResp(YMSGTransfer *transfer);
void parseCookies( YMSGTransfer *transfer );
void sendAuthSixteenStage1(const QString& sn, const QString& seed);
void sendAuthSixteenStage2(const QString& token);
void sendAuthSixteenStage3(const QString& cryptString);
protected slots:
void handleAuthSixteenStage1Data(KIO::Job*, const QByteArray& data);
void handleAuthSixteenStage1Result(KIO::Job*);
void handleAuthSixteenStage2Data(KIO::Job*, const QByteArray& data);
void handleAuthSixteenStage2Result(KIO::Job*);
signals:
void haveSessionID( uint );
void haveCookies();
void loginResponse( int, const QString& );
void buddyListReady();
private:
State mState;
Yahoo::Status m_stateOnConnect;
@ -70,6 +85,10 @@ private:
QString m_cCookie;
QString m_loginCookie;
QString m_verificationWord;
QString m_stage1Data;
QString m_stage2Data;
QString m_challengeString;
uint m_sessionID;
};
#endif

@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Log off the Yahoo server
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@ -24,7 +24,7 @@
LogoffTask::LogoffTask(Task* parent) : Task(parent)
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
}
LogoffTask::~LogoffTask()
@ -33,11 +33,11 @@ LogoffTask::~LogoffTask()
void LogoffTask::onGo()
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceLogoff);
t->setId( client()->sessionID() );
send( t );
setSuccess( true );
setSuccess();
}

@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Log off the Yahoo server
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@ -19,7 +19,6 @@
#include "task.h"
class QString;
/**
@author André Duffeck

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

@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Notifies about new mails
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@ -35,7 +35,7 @@ public:
bool take(Transfer *transfer);
protected:
bool forMe( Transfer *transfer ) const;
virtual bool forMe( const Transfer *transfer ) const;
void parseMail( YMSGTransfer *transfer );
signals:
void mailNotify(const QString&, const QString&, int);

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

@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Receive Messages
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@ -21,12 +21,11 @@
#include "ymsgtransfer.h"
#include "yahootypes.h"
#include "client.h"
#include <qstring.h>
#include <kdebug.h>
MessageReceiverTask::MessageReceiverTask(Task* parent) : Task(parent)
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
}
MessageReceiverTask::~MessageReceiverTask()
@ -35,8 +34,6 @@ MessageReceiverTask::~MessageReceiverTask()
bool MessageReceiverTask::take( Transfer* transfer )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
if ( !forMe( transfer ) )
return false;
@ -53,12 +50,10 @@ bool MessageReceiverTask::take( Transfer* transfer )
return true;
}
bool MessageReceiverTask::forMe( Transfer* transfer ) const
bool MessageReceiverTask::forMe( const Transfer* transfer ) const
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
YMSGTransfer *t = 0L;
t = dynamic_cast<YMSGTransfer*>(transfer);
const YMSGTransfer *t = 0L;
t = dynamic_cast<const YMSGTransfer*>(transfer);
if (!t)
return false;
@ -73,7 +68,7 @@ bool MessageReceiverTask::forMe( Transfer* transfer ) const
void MessageReceiverTask::parseMessage( YMSGTransfer *t )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
int cnt = t->paramCount( 5 );
for( int i = 0; i < cnt; ++i )
@ -98,7 +93,7 @@ void MessageReceiverTask::parseMessage( YMSGTransfer *t )
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;
}
@ -119,7 +114,7 @@ void MessageReceiverTask::parseMessage( YMSGTransfer *t )
void MessageReceiverTask::parseNotify( YMSGTransfer *t )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
QString from = t->firstParam( 4 );
//QString to = t->firstParam( 5 );
@ -135,12 +130,12 @@ void MessageReceiverTask::parseNotify( YMSGTransfer *t )
{
if( ind.startsWith(" ") )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Got a WebcamInvitation." << endl;
kdDebug(YAHOO_RAW_DEBUG) << "Got a WebcamInvitation." << endl;
emit gotWebcamInvite( from );
}
else
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Got a WebcamRequest-Response: " << ind.toInt() << endl;
kdDebug(YAHOO_RAW_DEBUG) << "Got a WebcamRequest-Response: " << ind.toInt() << endl;
}
}
}

@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Receive Messages
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@ -35,7 +35,7 @@ public:
bool take(Transfer *transfer);
protected:
bool forMe( Transfer *transfer ) const;
virtual bool forMe( const Transfer *transfer ) const;
void parseMessage( YMSGTransfer *transfer );
void parseNotify( YMSGTransfer *transfer );
signals:

@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Add a buddy to the Contactlist
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2005-2006 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@ -19,21 +19,70 @@
#include "ymsgtransfer.h"
#include "yahootypes.h"
#include "client.h"
#include <qstring.h>
#include <kdebug.h>
ModifyBuddyTask::ModifyBuddyTask(Task* parent) : Task(parent)
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
}
ModifyBuddyTask::~ModifyBuddyTask()
{
}
bool ModifyBuddyTask::take( Transfer* transfer )
{
if( !forMe( transfer ) )
return false;
YMSGTransfer *t = static_cast<YMSGTransfer *>(transfer);
bool success = t->firstParam(66) == "0";
switch(t->service())
{
case Yahoo::ServiceBuddyAdd:
emit buddyAddResult(m_target, m_group, success);
break;
case Yahoo::ServiceBuddyRemove:
emit buddyRemoveResult(m_target, m_group, success);
break;
case Yahoo::ServiceBuddyChangeGroup:
emit buddyChangeGroupResult(m_target, m_group, success);
default:
return false;
}
if(success)
setSuccess();
else
setError();
return true;
}
bool ModifyBuddyTask::forMe( const Transfer* transfer ) const
{
const YMSGTransfer *t = 0L;
t = dynamic_cast<const YMSGTransfer*>(transfer);
if(!t)
return false;
if( (t->service() == Yahoo::ServiceBuddyAdd ||
t->service() == Yahoo::ServiceBuddyRemove) &&
m_target == t->firstParam(7).data() )
{
return true;
}
return false;
}
void ModifyBuddyTask::onGo()
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
switch( m_type )
{
@ -47,27 +96,27 @@ void ModifyBuddyTask::onGo()
moveBuddy();
break;
}
setSuccess( true );
}
void ModifyBuddyTask::addBuddy()
{
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceAddBuddy);
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceBuddyAdd);
t->setId( client()->sessionID() );
t->setParam( 1, client()->userId().local8Bit() );
t->setParam( 7, m_target.local8Bit() );
t->setParam( 14, m_message.utf8() );
t->setParam( 65, m_group.local8Bit() );
t->setParam( 97, 1 ); // UTF-8
t->setParam( 1, client()->userId().local8Bit() );
t->setParam( 302, 319 );
t->setParam( 300, 319 );
t->setParam( 7, m_target.local8Bit() );
t->setParam( 334, 0 );
t->setParam( 301, 319 );
t->setParam( 303, 319 );
send( t );
}
void ModifyBuddyTask::removeBuddy()
{
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceRemBuddy);
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceBuddyRemove);
t->setId( client()->sessionID() );
t->setParam( 1, client()->userId().local8Bit() );
t->setParam( 7, m_target.local8Bit() );
@ -114,3 +163,5 @@ void ModifyBuddyTask::setType( Type type )
{
m_type = type;
}
#include "modifybuddytask.moc"

@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Add, remove or move a buddy to the Contactlist
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@ -26,6 +26,7 @@ class QString;
*/
class ModifyBuddyTask : public Task
{
Q_OBJECT
public:
enum Type { AddBuddy, RemoveBuddy, MoveBuddy };
ModifyBuddyTask(Task *parent);
@ -33,11 +34,22 @@ public:
virtual void onGo();
bool take(Transfer *transfer);
void setType( Type type );
void setMessage( const QString &text );
void setTarget( const QString &target );
void setGroup( const QString &group );
void setOldGroup( const QString &group );
signals:
void buddyAddResult( const QString &, const QString &, bool );
void buddyRemoveResult( const QString &, const QString &, bool );
void buddyChangeGroupResult( const QString &, const QString &, bool );
protected:
virtual bool forMe( const Transfer *transfer ) const;
private:
void addBuddy();
void removeBuddy();

@ -2,7 +2,7 @@
Kopete Yahoo Protocol
modifyyabtask.h - Handles the Yahoo Address Book
Copyright (c) 2006 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2006 André Duffeck <duffeck@kde.org>
Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
*************************************************************************
@ -33,7 +33,7 @@
using namespace KNetwork;
ModifyYABTask::ModifyYABTask(Task* parent) : Task(parent)
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
m_socket = 0;
}
@ -44,7 +44,7 @@ ModifyYABTask::~ModifyYABTask()
void ModifyYABTask::onGo()
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
m_socket = new KBufferedSocket( "address.yahoo.com", QString::number(80) );
connect( m_socket, SIGNAL( connected( const KResolverEntry& ) ), this, SLOT( connectSucceeded() ) );
connect( m_socket, SIGNAL( gotError(int) ), this, SLOT( connectFailed(int) ) );
@ -90,13 +90,14 @@ void ModifyYABTask::setEntry( const YABEntry &entry )
void ModifyYABTask::connectFailed( int i)
{
m_socket->close();
client()->notifyError( i18n( "An error occured saving the Addressbook entry." ),
client()->notifyError( i18n( "An error occurred while saving the address book entry." ),
QString( "%1 - %2").arg(i).arg(static_cast<const KBufferedSocket*>( sender() )->errorString()), Client::Error );
}
void ModifyYABTask::connectSucceeded()
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
KBufferedSocket* socket = const_cast<KBufferedSocket*>( static_cast<const KBufferedSocket*>( sender() ) );
QString header = QString::fromLatin1("POST /yab/us?v=XM&prog=ymsgr&.intl=us&sync=1&tags=short&noclear=1& HTTP/1.1\r\n"
"Cookie: Y=%1; T=%2; C=%3 ;B=fckeert1kk1nl&b=2\r\n"
@ -113,12 +114,12 @@ void ModifyYABTask::connectSucceeded()
stream.writeRawBytes( header.local8Bit(), header.length() );
stream.writeRawBytes( m_postData.utf8(), m_postData.utf8().size() );
if( m_socket->writeBlock( buffer, buffer.size() ) )
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Upload Successful. Waiting for confirmation..." << endl;
if( socket->writeBlock( buffer, buffer.size() ) )
kdDebug(YAHOO_RAW_DEBUG) << "Upload Successful. Waiting for confirmation..." << endl;
else
{
client()->notifyError( i18n( "An error occured saving the Addressbook entry." ), m_socket->errorString(), Client::Error );
setSuccess( false );
client()->notifyError( i18n( "An error occurred while saving the address book entry." ), m_socket->errorString(), Client::Error );
setError();
return;
}
@ -127,22 +128,20 @@ void ModifyYABTask::connectSucceeded()
void ModifyYABTask::slotRead()
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
QByteArray ar( m_socket->bytesAvailable() );
m_socket->readBlock ( ar.data (), ar.size () );
QString buf( ar );
m_data += buf.right( buf.length() - buf.find("<?xml") );
KBufferedSocket* socket = const_cast<KBufferedSocket*>( static_cast<const KBufferedSocket*>( sender() ) );
QByteArray ar( socket->bytesAvailable() );
socket->readBlock( ar.data (), ar.size () );
QString data( ar );
data = data.right( data.length() - data.find("<?xml") );
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << m_data.find("</ab>") << endl;
if( m_data.find("</ab>") < 0 )
return; // Need more data
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << m_data.find("</ab>") << endl;
m_socket->close();
QDomDocument doc;
QDomNodeList list;
QDomElement e;
uint it = 0;
int it = 0;
doc.setContent( m_data );
@ -161,7 +160,7 @@ void ModifyYABTask::slotRead()
list = doc.elementsByTagName( "ct" ); // Get records
for( it = 0; it < list.count(); it++ ) {
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Parsing entry..." << endl;
kdDebug(YAHOO_RAW_DEBUG) << "Parsing entry..." << endl;
if( !list.item( it ).isElement() )
continue;
e = list.item( it ).toElement();
@ -175,31 +174,31 @@ void ModifyYABTask::slotRead()
case EditEntry:
if( !e.attribute( "es" ).isEmpty() && e.attribute( "es" ) != "0" ) // Check for edit errors
{
emit error( entry, i18n("The Yahoo Addressbook entry could not be saved:\n%1 - %2").arg( e.attribute("es") ).arg( e.attribute("ee") ) );
emit error( entry, i18n("The Yahoo Address Book entry could not be saved:\n%1 - %2").arg( e.attribute("es") ).arg( e.attribute("ee") ) );
continue;
}
break;
case AddEntry:
if( !e.attribute( "as" ).isEmpty() && e.attribute( "as" ) != "0" ) // Check for add errors
{
emit error( entry, i18n("The Yahoo Addressbook entry could not be created:\n%1 - %2").arg( e.attribute("as") ).arg( e.attribute("ae") ) );
emit error( entry, i18n("The Yahoo Address Book entry could not be created:\n%1 - %2").arg( e.attribute("as") ).arg( e.attribute("ae") ) );
continue;
}
break;
case DeleteEntry:
if( !e.attribute( "ds" ).isEmpty() && e.attribute( "ds" ) != "0" ) // Check for delete errors
{
emit error( entry, i18n("The Yahoo Addressbook entry could not be deleted:\n%1 - %2").arg( e.attribute("ds") ).arg( e.attribute("de") ) );
emit error( entry, i18n("The Yahoo Address Book entry could not be deleted:\n%1 - %2").arg( e.attribute("ds") ).arg( e.attribute("de") ) );
continue;
}
break;
}
// No errors occured
// No errors occurred
emit gotEntry( entry );
}
setSuccess( true );
setSuccess();
}
#include "modifyyabtask.moc"

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

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

@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Notifies about buddy icons
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@ -19,15 +19,15 @@
#include "ymsgtransfer.h"
#include "yahootypes.h"
#include "client.h"
#include <qstring.h>
#include <qstringlist.h>
#include <kurl.h>
#include <kdebug.h>
#include <klocale.h>
PictureNotifierTask::PictureNotifierTask(Task* parent) : Task(parent)
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
}
PictureNotifierTask::~PictureNotifierTask()
@ -37,8 +37,6 @@ PictureNotifierTask::~PictureNotifierTask()
bool PictureNotifierTask::take( Transfer* transfer )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
if ( !forMe( transfer ) )
return false;
@ -51,9 +49,11 @@ bool PictureNotifierTask::take( Transfer* transfer )
{
case Yahoo::ServicePictureStatus:
parsePictureStatus( t );
parsePicture( t );
break;
case Yahoo::ServicePictureChecksum:
parsePictureChecksum( t );
parsePicture( t );
break;
case Yahoo::ServicePicture:
parsePicture( t );
@ -68,11 +68,10 @@ bool PictureNotifierTask::take( Transfer* transfer )
return true;
}
bool PictureNotifierTask::forMe( Transfer* transfer ) const
bool PictureNotifierTask::forMe( const Transfer* transfer ) const
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
YMSGTransfer *t = 0L;
t = dynamic_cast<YMSGTransfer*>(transfer);
const YMSGTransfer *t = 0L;
t = dynamic_cast<const YMSGTransfer*>(transfer);
if (!t)
return false;
@ -89,7 +88,7 @@ bool PictureNotifierTask::forMe( Transfer* transfer ) const
void PictureNotifierTask::parsePictureStatus( YMSGTransfer *t )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
QString nick; /* key = 4 */
int state; /* key = 213 */
@ -102,7 +101,7 @@ void PictureNotifierTask::parsePictureStatus( YMSGTransfer *t )
void PictureNotifierTask::parsePictureChecksum( YMSGTransfer *t )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
QString nick; /* key = 4 */
int checksum; /* key = 192 */
@ -116,10 +115,10 @@ void PictureNotifierTask::parsePictureChecksum( YMSGTransfer *t )
void PictureNotifierTask::parsePicture( YMSGTransfer *t )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
QString nick; /* key = 4 */
int type; /* key = 13: 1 = request, 2 = notification */
int type; /* key = 13: 1 = request, 2 = notification, 0 = Just changed */
QString url; /* key = 20 */
int checksum; /* key = 192 */
@ -130,27 +129,31 @@ void PictureNotifierTask::parsePicture( YMSGTransfer *t )
if( type == 1 )
emit pictureRequest( nick );
else if( type == 0 )
emit pictureInfoNotify( nick, KURL( url ), checksum );
else if( type == 2 )
emit pictureInfoNotify( nick, KURL( url ), checksum );
}
void PictureNotifierTask::parsePictureUploadResponse( YMSGTransfer *t )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
QString url;
QString error;
int expires;
url = t->firstParam( 20 );
error = t->firstParam( 16 );
expires = t->firstParam( 38 ).toInt();
if( !error.isEmpty() )
client()->notifyError(i18n("The picture was not successfully uploaded"), error, Client::Error );
if( !url.isEmpty() )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Emitting url: " << url << endl;
emit pictureUploaded( url );
kdDebug(YAHOO_RAW_DEBUG) << "Emitting url: " << url << " Picture expires: " << expires << endl;
emit pictureUploaded( url, expires );
}
}

@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Notifies about buddy icons
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@ -19,8 +19,9 @@
#include "task.h"
#include <kurl.h>
class QString;
class KURL;
class YMSGTransfer;
/**
@author André Duffeck
@ -35,7 +36,7 @@ public:
bool take(Transfer *transfer);
protected:
bool forMe( Transfer *transfer ) const;
virtual bool forMe( const Transfer *transfer ) const;
void parsePictureChecksum( YMSGTransfer *transfer );
void parsePictureStatus( YMSGTransfer *transfer );
void parsePicture( YMSGTransfer *transfer );
@ -45,7 +46,7 @@ signals:
void pictureChecksumNotify( const QString &, int );
void pictureInfoNotify( const QString &, KURL, int );
void pictureRequest( const QString & );
void pictureUploaded( const QString & );
void pictureUploaded( const QString &, int );
};
#endif

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

@ -2,7 +2,7 @@
pingtask.h
Send a ping to the server
Copyright (c) 2006 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2006 André Duffeck <duffeck@kde.org>
Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>

@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Receive a file
Copyright (c) 2006 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2006 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@ -19,8 +19,9 @@
#include "ymsgtransfer.h"
#include "yahootypes.h"
#include "client.h"
#include <qstring.h>
#include <qtimer.h>
#include <qfile.h>
#include <kdebug.h>
#include <klocale.h>
#include <kio/global.h>
@ -29,7 +30,7 @@
ReceiveFileTask::ReceiveFileTask(Task* parent) : Task(parent)
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
m_transmitted = 0;
m_file = 0;
m_transferJob = 0;
@ -43,7 +44,7 @@ ReceiveFileTask::~ReceiveFileTask()
void ReceiveFileTask::onGo()
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceFileTransfer7);
switch( m_type )
{
@ -52,7 +53,8 @@ void ReceiveFileTask::onGo()
if( !m_file->open( IO_WriteOnly ) )
{
emit error( m_transferId, KIO::ERR_CANNOT_OPEN_FOR_WRITING, i18n("Could not open file for writing.") );
setSuccess( false );
setError();
delete t;
return;
}
m_transferJob = KIO::get( m_remoteUrl, false, false );
@ -85,7 +87,7 @@ void ReceiveFileTask::onGo()
bool ReceiveFileTask::take( Transfer* transfer )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
if ( !forMe( transfer ) )
return false;
@ -97,11 +99,11 @@ bool ReceiveFileTask::take( Transfer* transfer )
return true;
}
bool ReceiveFileTask::forMe( Transfer *transfer ) const
bool ReceiveFileTask::forMe( const Transfer *transfer ) const
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
YMSGTransfer *t = 0L;
t = dynamic_cast<YMSGTransfer*>(transfer);
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
const YMSGTransfer *t = 0L;
t = dynamic_cast<const YMSGTransfer*>(transfer);
if (!t)
return false;
@ -121,17 +123,16 @@ bool ReceiveFileTask::forMe( Transfer *transfer ) const
void ReceiveFileTask::slotData( KIO::Job *job, const QByteArray& data )
{
Q_UNUSED( job );
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
m_transmitted += data.size();
emit bytesProcessed( m_transferId, m_transmitted );
m_file->writeBlock( data.data() , data.size() );
}
void ReceiveFileTask::slotComplete( KIO::Job *job )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
KIO::TransferJob *transfer = static_cast< KIO::TransferJob * >(job);
@ -139,19 +140,19 @@ void ReceiveFileTask::slotComplete( KIO::Job *job )
m_file->close();
if ( job->error () || transfer->isErrorPage () )
{
emit error( m_transferId, KIO::ERR_ABORTED, i18n("An error occured while downloading the file.") );
setSuccess( false );
emit error( m_transferId, KIO::ERR_ABORTED, i18n("An error occurred while downloading the file.") );
setError();
}
else
{
emit complete( m_transferId );
setSuccess( true );
setSuccess();
}
}
void ReceiveFileTask::parseFileTransfer7Info( YMSGTransfer *transfer )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
if( transfer->firstParam( 249 ).toInt() == 1 )
{
@ -171,7 +172,7 @@ void ReceiveFileTask::parseFileTransfer7Info( YMSGTransfer *transfer )
if( !m_file->open( IO_WriteOnly ) )
{
emit error( m_transferId, KIO::ERR_CANNOT_OPEN_FOR_WRITING, i18n("Could not open file for writing.") );
setSuccess( false );
setError();
return;
}
@ -187,19 +188,19 @@ void ReceiveFileTask::parseFileTransfer7Info( YMSGTransfer *transfer )
send( t );
// The server expects a HTTP HEAD command prior to the GET
m_mimetypeJob = KIO::mimetype(QString::fromLatin1("http://%1/relay?token=%2&sender=%3&recver=%4")
.arg(transfer->firstParam( 250 )).arg(transfer->firstParam( 251 )).arg(m_userId).arg(client()->userId()), false);
.arg( QString(transfer->firstParam( 250 )) ).arg( QString(transfer->firstParam( 251 )) ).arg(m_userId).arg(client()->userId()), false);
m_mimetypeJob->addMetaData("cookies", "manual");
m_mimetypeJob->addMetaData("setcookies", QString::fromLatin1("Cookie: T=%1; path=/; domain=.yahoo.com; Y=%2; C=%3;")
.arg(client()->tCookie()).arg(client()->yCookie()).arg(client()->cCookie()) );
m_transferJob = KIO::get( QString::fromLatin1("http://%1/relay?token=%2&sender=%3&recver=%4")
.arg(transfer->firstParam( 250 )).arg(transfer->firstParam( 251 )).arg(m_userId).arg(client()->userId()), false, false );
.arg( QString(transfer->firstParam( 250 )) ).arg( QString(transfer->firstParam( 251 )) ).arg(m_userId).arg(client()->userId()), false, false );
QObject::connect( m_transferJob, SIGNAL( result( KIO::Job* ) ), this, SLOT( slotComplete( KIO::Job* ) ) );
QObject::connect( m_transferJob, SIGNAL( data( KIO::Job*, const QByteArray & ) ), this, SLOT( slotData( KIO::Job*, const QByteArray & ) ) );
m_transferJob->addMetaData("cookies", "manual");
m_transferJob->addMetaData("setcookies", QString::fromLatin1("Cookie: T=%1; path=/; domain=.yahoo.com; Y=%2; C=%3;")
.arg(client()->tCookie()).arg(client()->yCookie()).arg(client()->cCookie()) );
m_transferJob->addMetaData("setcookies", QString::fromLatin1("Cookie: T=%1; path=/; domain=.yahoo.com; Y=%2; path=/; domain=.yahoo.com;")
.arg(client()->tCookie()).arg(client()->yCookie()) );
}
}
@ -236,7 +237,7 @@ void ReceiveFileTask::canceled( unsigned int id )
if( m_transferJob )
m_transferJob->kill();
setSuccess( false );
setError();
}
#include "receivefiletask.moc"

@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Receive a file
Copyright (c) 2006 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2006 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@ -18,7 +18,6 @@
#define RECEIVEFILETASK_H
#include "task.h"
#include <qfile.h>
#include <kurl.h>
class QString;
@ -28,6 +27,7 @@ namespace KIO {
class TransferJob;
class MimetypeJob;
}
class YMSGTransfer;
/**
@ -53,7 +53,7 @@ public:
bool take(Transfer *transfer);
protected:
bool forMe( Transfer *transfer ) const;
virtual bool forMe( const Transfer *transfer ) const;
signals:
void bytesProcessed( unsigned int, unsigned int );

@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Request a Picture of a Buddy
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2005-2006 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@ -19,12 +19,12 @@
#include "ymsgtransfer.h"
#include "yahootypes.h"
#include "client.h"
#include <qstring.h>
#include <kdebug.h>
RequestPictureTask::RequestPictureTask(Task* parent) : Task(parent)
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
}
RequestPictureTask::~RequestPictureTask()
@ -35,12 +35,12 @@ void RequestPictureTask::onGo()
{
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServicePicture);
t->setId( client()->sessionID() );
t->setParam( 4, client()->userId().local8Bit());
t->setParam( 1, client()->userId().local8Bit());
t->setParam( 5, m_target.local8Bit() );
t->setParam( 13, "1" );
send( t );
setSuccess( true );
setSuccess();
}
void RequestPictureTask::setTarget( const QString &target )

@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Request a Picture of a Buddy
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@ -29,7 +29,7 @@ class RequestPictureTask : public Task
Q_OBJECT
public:
RequestPictureTask(Task *parent);
~RequestPictureTask();
virtual ~RequestPictureTask();
virtual void onGo();

@ -3,7 +3,7 @@
Copyright (c) 2004 SUSE Linux AG http://www.suse.com
Based on Iris, Copyright (C) 2003 Justin Karneges
Based on Iris, Copyright (C) 2003 Justin Karneges <justin@affinix.com>
Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
@ -57,6 +57,7 @@ void SafeDelete::deleteAll()
QObjectListIt it(list);
for(QObject *o; (o = it.current()); ++it)
deleteSingle(o);
list.clear();
}

@ -3,7 +3,7 @@
Copyright (c) 2004 SUSE Linux AG http://www.suse.com
Based on Iris, Copyright (C) 2003 Justin Karneges
Based on Iris, Copyright (C) 2003 Justin Karneges <justin@affinix.com>
Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>

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

@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Send a authorization request response
Copyright (c) 2006 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2006 André Duffeck <duffeck@kde.org>
Kopete (c) 2003-2006 by the Kopete developers <kopete-devel@kde.org>
*************************************************************************

@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Send a file
Copyright (c) 2006 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2006 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@ -21,6 +21,7 @@
#include "client.h"
#include <qstring.h>
#include <qtimer.h>
#include <kapplication.h> // for random()
#include <kdebug.h>
#include <klocale.h>
#include <kstreamsocket.h>
@ -30,9 +31,11 @@ using namespace KNetwork;
SendFileTask::SendFileTask(Task* parent) : Task(parent)
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
m_transmitted = 0;
m_socket = 0;
QTime epoch(0, 0, 0);
}
SendFileTask::~SendFileTask()
@ -41,47 +44,159 @@ SendFileTask::~SendFileTask()
m_socket = 0;
}
bool SendFileTask::forMe( const Transfer *transfer ) const
{
const YMSGTransfer *t = static_cast<const YMSGTransfer*>(transfer);
if(!t)
return false;
if((t->service() == Yahoo::ServiceFileTransfer7 ||
t->service() == Yahoo::ServiceFileTransfer7Accept) &&
t->firstParam(265).data() == m_yahooTransferId)
{
return true;
}
return false;
}
bool SendFileTask::take(Transfer* transfer)
{
if( !forMe( transfer ) )
return false;
YMSGTransfer *t = static_cast<YMSGTransfer*>(transfer);
kdDebug(YAHOO_RAW_DEBUG) << t->service() << endl;
if(t->service() == Yahoo::ServiceFileTransfer7)
parseFileTransfer(t);
else if(t->service() == Yahoo::ServiceFileTransfer7Accept)
parseTransferAccept(t);
return true;
}
void SendFileTask::parseFileTransfer( const Transfer *transfer )
{
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
const YMSGTransfer *t = static_cast<const YMSGTransfer*>(transfer);
if(!t)
return;
if(t->firstParam(222).toInt() == 4)
{
emit declined();
}
else if(t->firstParam(222).toInt() == 3)
{
sendFileTransferInfo();
}
else
{
setError();
emit error(m_transferId, 0, i18n("Unknown error"));
}
}
void SendFileTask::onGo()
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
m_file.setName( m_url.path() );
m_yahooTransferId = newYahooTransferId();
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceFileTransfer7);
t->setId( client()->sessionID() );
t->setParam( 1, client()->userId().local8Bit() );
t->setParam( 5, m_target.local8Bit() );
t->setParam( 265, m_yahooTransferId.local8Bit() );
t->setParam( 222, 1 );
t->setParam( 266, 1 );
t->setParam( 302, 268 );
t->setParam( 300, 268 );
t->setParam( 27, m_url.fileName().local8Bit() );
t->setParam( 28, m_file.size());
t->setParam( 301, 268 );
t->setParam( 303, 268 );
send( t );
}
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() );
QTimer::singleShot( 0, this, SLOT(initiateUpload()) );
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::initiateUpload()
void SendFileTask::parseTransferAccept(const Transfer *transfer)
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
m_socket = new KStreamSocket( "filetransfer.msg.yahoo.com", QString::number(80) );
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
const YMSGTransfer *t = static_cast<const YMSGTransfer*>(transfer);
// Disconnected
if(t->status() == Yahoo::StatusDisconnected)
{
setError();
return;
}
m_token = KURL::encode_string(t->firstParam(251));
kdDebug(YAHOO_RAW_DEBUG) << "Token: " << m_token << endl;
m_socket = new KStreamSocket( m_relayHost, QString::number(80) );
m_socket->setBlocking( true );
connect( m_socket, SIGNAL( connected( const KResolverEntry& ) ), this, SLOT( connectSucceeded() ) );
connect( m_socket, SIGNAL( gotError(int) ), this, SLOT( connectFailed(int) ) );
m_socket->connect();
}
void SendFileTask::connectFailed( int i )
{
QString err = m_socket->errorString();
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << i << ": " << err << endl;
QString err = KSocketBase::errorString(m_socket->error());
kdDebug(YAHOO_RAW_DEBUG) << i << ": " << err << endl;
emit error( m_transferId, i, err );
setSuccess( false );
setError();
}
void SendFileTask::connectSucceeded()
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
YMSGTransfer t( Yahoo::ServiceFileTransfer );
m_file.setName( m_url.path() );
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
t.setId( client()->sessionID() );
t.setParam( 0, client()->userId().local8Bit());
t.setParam( 5, m_target.local8Bit());
t.setParam( 28, m_file.size() );
t.setParam( 27, m_url.fileName().local8Bit() );
t.setParam( 14, "" );
QByteArray buffer;
QByteArray paket;
QDataStream stream( buffer, IO_WriteOnly );
if ( m_file.open(IO_ReadOnly ) )
@ -90,22 +205,25 @@ void SendFileTask::connectSucceeded()
}
else
{
client()->notifyError( i18n( "An error occured sending the file." ), m_file.errorString(), Client::Error );
setSuccess( false );
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Error opening file: " << m_file.errorString() << endl;
client()->notifyError( i18n( "An error occurred while sending the file." ), m_file.errorString(), Client::Error );
setError();
return;
}
paket = t.serialize();
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Sizes: File (" << m_url << "): " << m_file.size() << " - paket: " << paket.size() << endl;
QString header = QString::fromLatin1("POST http://filetransfer.msg.yahoo.com:80/notifyft HTTP/1.1\r\n"
"Cookie: Y=%1; T=%2; C=%3 ;B=fckeert1kk1nl&b=2\r\n"
"User-Agent: Mozilla/4.0 (compatible; MSIE 5.5)\r\n"
"Host: filetransfer.msg.yahoo.com:80\r\n"
"Content-length: %4\r\n"
"Cache-Control: no-cache\r\n\r\n").arg(client()->yCookie()).arg(client()->tCookie()).arg(client()->cCookie()).arg(m_file.size()+4+paket.size());
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Sizes: File (" << m_url << "): " << m_file.size() << endl;
QString header =
"POST /relay?token=" + m_token +
"&sender=" + client()->userId() +
"&recver=" + m_target + " HTTP/1.1\r\n"
"User-Agent: Mozilla/5.0\r\n"
"Cache-Control: no-cache\r\n"
"Cookie: T=" + client()->tCookie() + "; Y=" + client()->yCookie() + "\r\n"
"Host: " + m_relayHost + "\r\n"
"Content-Length: " + QString::number(m_file.size()) + "\r\n"
"Connection: Close\r\n\r\n";
kdDebug() << header << endl;
stream.writeRawBytes( header.local8Bit(), header.length() );
stream.writeRawBytes( paket.data(), paket.size() );
stream << (Q_INT8)0x32 << (Q_INT8)0x39 << (Q_INT8)0xc0 << (Q_INT8)0x80;
if( !m_socket->writeBlock( buffer, buffer.size() ) )
{
@ -121,7 +239,7 @@ void SendFileTask::connectSucceeded()
void SendFileTask::transmitData()
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
int read = 0;
int written = 0;
char buf[1024];
@ -138,14 +256,14 @@ void SendFileTask::transmitData()
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Upload Failed!" << endl;
emit error( m_transferId, m_socket->error(), m_socket->errorString() );
setSuccess( false );
setError();
return;
}
if( m_transmitted == m_file.size() )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Upload Successful: " << m_transmitted << endl;
emit complete( m_transferId );
setSuccess( true );
setSuccess();
m_socket->close();
}
else
@ -182,7 +300,32 @@ void SendFileTask::canceled( unsigned int id )
if( m_socket )
m_socket->close();
setSuccess( false );
setError();
}
QString SendFileTask::newYahooTransferId()
{
// Adapted from libpurple/protocols/yahoo/yahoo_filexfer.c yahoo_xfer_new_xfer_id()
QString newId;
for(int i = 0; i < 22; i++)
{
char j = KApplication::random() % 61;
if(j < 26)
newId += j + 'a';
else if(j < 52)
newId += j - 26 + 'A';
else
newId += j - 52 + '0';
}
newId += "$$";
kdDebug() << "New Yahoo Transfer Id: " << newId << endl;
return newId;
}
#include "sendfiletask.moc"

@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Send a file
Copyright (c) 2006 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2006 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@ -38,6 +38,8 @@ public:
virtual void onGo();
bool take(Transfer *transfer);
void setTarget( const QString &to );
void setMessage( const QString &msg );
void setFileUrl( KURL url );
@ -48,8 +50,17 @@ signals:
void complete( unsigned int );
void error( unsigned int, int, const QString & );
void declined();
protected:
bool forMe( const Transfer *transfer ) const;
void sendFileTransferInfo();
void parseFileTransfer( const Transfer *transfer );
void parseTransferAccept(const Transfer *transfer);
QString newYahooTransferId();
private slots:
void initiateUpload();
void connectSucceeded();
void connectFailed( int );
void transmitData();
@ -63,6 +74,10 @@ private:
unsigned int m_transferId;
unsigned int m_transmitted;
KNetwork::KStreamSocket *m_socket;
QString m_relayHost;
QString m_token;
QString m_yahooTransferId;
};
#endif

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

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

@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Send a notification
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2005-2006 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@ -19,12 +19,12 @@
#include "ymsgtransfer.h"
#include "yahootypes.h"
#include "client.h"
#include <qstring.h>
#include <kdebug.h>
SendNotifyTask::SendNotifyTask(Task* parent) : Task(parent)
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
}
SendNotifyTask::~SendNotifyTask()
@ -36,29 +36,35 @@ void SendNotifyTask::onGo()
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceNotify);
t->setId( client()->sessionID() );
t->setStatus( Yahoo::StatusNotify );
t->setParam( 4, client()->userId().local8Bit() );
t->setParam( 5, m_target.local8Bit() );
t->setParam( 14, " " );
switch( m_type )
{
case NotifyTyping:
t->setParam( 4, client()->userId().local8Bit() );
t->setParam( 5, m_target.local8Bit() );
t->setParam( 13, m_state );
t->setParam( 14, " " );
t->setParam( 49, "TYPING" );
break;
case NotifyWebcamInvite:
kdDebug(YAHOO_RAW_DEBUG) << "send invitation set Param" << endl;
t->setParam( 1, client()->userId().local8Bit() );
t->setParam( 5, m_target.local8Bit() );
t->setParam( 13, 0 );
t->setParam( 14, " " );
t->setParam( 49, "WEBCAMINVITE" );
break;
case NotifyGame:
default:
setSuccess( false );
setError();
delete t;
return;
break;
}
send( t );
setSuccess( true );
setSuccess();
}
void SendNotifyTask::setType( Type type )

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

@ -2,7 +2,7 @@
Kopete Yahoo Protocol
sendpicturetask.cpp - Send our picture or information about it
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@ -21,7 +21,6 @@
#include "client.h"
#include <qstring.h>
#include <qfile.h>
#include <qcstring.h>
#include <qdatastream.h>
#include <kio/global.h>
#include <kio/job.h>
@ -34,7 +33,7 @@ using namespace KNetwork;
SendPictureTask::SendPictureTask(Task* parent) : Task(parent)
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
m_socket = 0;
}
@ -55,6 +54,7 @@ void SendPictureTask::onGo()
break;
case SendInformation:
sendInformation();
break;
case SendStatus:
sendStatus();
break;
@ -63,25 +63,26 @@ void SendPictureTask::onGo()
void SendPictureTask::initiateUpload()
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
m_socket = new KBufferedSocket( "filetransfer.msg.yahoo.com", QString::number(80) );
connect( m_socket, SIGNAL( connected( const KResolverEntry& ) ), this, SLOT( connectSucceeded() ) );
connect( m_socket, SIGNAL( gotError(int) ), this, SLOT( connectFailed(int) ) );
connect( m_socket, SIGNAL( readyRead() ), this, SLOT( readResult() ) );
m_socket->connect();
}
void SendPictureTask::connectFailed( int i)
{
m_socket->close();
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << i << ": " << static_cast<const KBufferedSocket*>( sender() )->errorString() << endl;
kdDebug(YAHOO_RAW_DEBUG) << i << ": " << static_cast<const KBufferedSocket*>( sender() )->errorString() << endl;
client()->notifyError(i18n("The picture was not successfully uploaded"), QString("%1 - %2").arg(i).arg(static_cast<const KBufferedSocket*>( sender() )->errorString()), Client::Error );
setSuccess( false );
setError();
}
void SendPictureTask::connectSucceeded()
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
YMSGTransfer t(Yahoo::ServicePictureUpload);
QFile file( m_path );
@ -97,19 +98,19 @@ void SendPictureTask::connectSucceeded()
QByteArray paket;
QDataStream stream( buffer, IO_WriteOnly );
if ( file.open(IO_ReadOnly ) )
if ( file.open( IO_ReadOnly ) )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "File successfully opened. Reading..." << endl;
kdDebug(YAHOO_RAW_DEBUG) << "File successfully opened. Reading..." << endl;
}
else
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Error opening file: " << file.errorString() << endl;
kdDebug(YAHOO_RAW_DEBUG) << "Error opening file: " << file.errorString() << endl;
client()->notifyError(i18n("Error opening file: %1").arg(m_path), file.errorString(), Client::Error );
return;
}
paket = t.serialize();
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Sizes: File (" << m_path << "): " << file.size() << " - paket: " << paket.size() << endl;
kdDebug(YAHOO_RAW_DEBUG) << "Sizes: File (" << m_path << "): " << file.size() << " - paket: " << paket.size() << endl;
QString header = QString::fromLatin1("POST /notifyft HTTP/1.1\r\n"
"Cookie: Y=%1; T=%2; C=%3 ;\r\n"
"User-Agent: Mozilla/4.0 (compatible; MSIE 5.5)\r\n"
@ -121,22 +122,42 @@ void SendPictureTask::connectSucceeded()
stream << (Q_INT8)0x32 << (Q_INT8)0x39 << (Q_INT8)0xc0 << (Q_INT8)0x80;
stream.writeRawBytes( file.readAll(), file.size() );
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Buffersize: " << buffer.size() << endl;
kdDebug(YAHOO_RAW_DEBUG) << "Buffersize: " << buffer.size() << endl;
if( m_socket->writeBlock( buffer, buffer.size() ) )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Upload Successful." << endl;
connect( m_socket, SIGNAL( readyRead() ), this, SLOT( readResult() ) );
kdDebug(YAHOO_RAW_DEBUG) << "Upload Successful!" << endl;
m_socket->enableRead( true );
// setSuccess();
}
else
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Upload Failed." << endl;
m_socket->close();
setSuccess( false );
kdDebug(YAHOO_RAW_DEBUG) << "Upload Failed!" << endl;
setError();
}
}
void SendPictureTask::readResult()
{
kdDebug(YAHOO_RAW_DEBUG) << m_socket->bytesAvailable() << endl;
// FIXME: to check
// m_socket->enableRead( false );
// QByteArray buf;
// buf.resize( m_socket->bytesAvailable() );
// m_socket->read( buf.data(), m_socket->bytesAvailable() );
//
// if( buf.indexOf( "error", 0 ) >= 0 )
// {
// kdDebug(YAHOO_RAW_DEBUG) << "Picture upload failed" << endl;
// setError();
// }
// else
// {
// kdDebug(YAHOO_RAW_DEBUG) << "Picture upload acknowledged." << endl;
// setSuccess();
// }
// from original file
QByteArray ar( m_socket->bytesAvailable() );
m_socket->readBlock ( ar.data (), ar.size () );
QString buf( ar );
@ -152,12 +173,11 @@ void SendPictureTask::readResult()
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Picture upload acknowledged." << endl;
setSuccess( true );
}
}
void SendPictureTask::sendChecksum()
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServicePictureChecksum);
t->setId( client()->sessionID() );
@ -168,17 +188,16 @@ void SendPictureTask::sendChecksum()
t->setParam(212, 1);
send( t );
setSuccess( true );
setSuccess();
}
void SendPictureTask::sendInformation()
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServicePicture);
t->setId( client()->sessionID() );
t->setParam(1, client()->userId().local8Bit());
t->setParam(4, client()->userId().local8Bit());
t->setParam(13, 2 );
t->setParam(5, m_target.local8Bit() );
t->setParam(20, m_url.local8Bit() );
@ -186,22 +205,21 @@ void SendPictureTask::sendInformation()
send( t );
setSuccess( true );
setSuccess();
}
void SendPictureTask::sendStatus()
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServicePictureUpdate);
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServicePictureStatus);
t->setId( client()->sessionID() );
t->setParam(1, client()->userId().local8Bit());
t->setParam(5, m_target.local8Bit() );
t->setParam(206, m_status );
t->setParam(3, client()->userId().local8Bit());
t->setParam(213, m_status );
send( t );
setSuccess( true );
setSuccess();
}
void SendPictureTask::setType( Type type )

@ -2,7 +2,7 @@
Kopete Yahoo Protocol
sendpicturetask.h - Send our picture or information about it
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@ -39,7 +39,7 @@ public:
enum Type { UploadPicture, SendChecksum, SendInformation, SendStatus };
SendPictureTask(Task *parent);
~SendPictureTask();
virtual ~SendPictureTask();
virtual void onGo();

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

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

@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Notifies about status changes of buddies
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@ -26,7 +26,7 @@
StatusNotifierTask::StatusNotifierTask(Task* parent) : Task(parent)
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
}
StatusNotifierTask::~StatusNotifierTask()
@ -36,8 +36,6 @@ StatusNotifierTask::~StatusNotifierTask()
bool StatusNotifierTask::take( Transfer* transfer )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
if ( !forMe( transfer ) )
return false;
@ -53,11 +51,10 @@ bool StatusNotifierTask::take( Transfer* transfer )
return true;
}
bool StatusNotifierTask::forMe( Transfer* transfer ) const
bool StatusNotifierTask::forMe( const Transfer* transfer ) const
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
YMSGTransfer *t = 0L;
t = dynamic_cast<YMSGTransfer*>(transfer);
const YMSGTransfer *t = 0L;
t = dynamic_cast<const YMSGTransfer*>(transfer);
if (!t)
return false;
@ -72,7 +69,8 @@ bool StatusNotifierTask::forMe( Transfer* transfer ) const
t->service() == Yahoo::ServiceIddeAct ||
t->service() == Yahoo::ServiceStatus ||
t->service() == Yahoo::ServiceStealthOffline ||
t->service() == Yahoo::ServiceAuthorization
t->service() == Yahoo::ServiceAuthorization ||
t->service() == Yahoo::ServiceBuddyStatus
)
return true;
else
@ -81,12 +79,12 @@ bool StatusNotifierTask::forMe( Transfer* transfer ) const
void StatusNotifierTask::parseStatus( YMSGTransfer* t )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
if( t->status() == Yahoo::StatusDisconnected &&
t->service() == Yahoo::ServiceLogoff )
{
emit loginResponse( Yahoo::LoginDupl, QString::null );
emit loginResponse( Yahoo::LoginDupl, QString() );
}
QString myNick; /* key = 1 */
@ -98,11 +96,11 @@ void StatusNotifierTask::parseStatus( YMSGTransfer* t )
int away; /* key = 47 */
int idle; /* key = 137 */
bool utf; /* key = 97 */
int checksum; /* key = 192 */
int pictureChecksum; /* key = 192 */
customError = t->firstParam( 16 );
if( !customError.isEmpty() )
client()->notifyError( i18n("An unknown error has occured."), customError, Client::Warning );
client()->notifyError( i18n("An unknown error has occurred."), customError, Client::Warning );
myNick = t->firstParam( 1 );
@ -114,25 +112,22 @@ void StatusNotifierTask::parseStatus( YMSGTransfer* t )
away = t->nthParamSeparated( 47, i, 7 ).toInt();
idle = t->nthParamSeparated( 137, i, 7 ).toInt();
utf = t->nthParamSeparated( 97, i, 7 ).toInt() == 1;
checksum = t->nthParamSeparated( 192, i, 7 ).toInt();
pictureChecksum = t->nthParamSeparated( 192, i, 7 ).toInt();
if( utf )
message = QString::fromUtf8( t->nthParamSeparated( 19, i, 7 ) );
else
message = t->nthParamSeparated( 19, i, 7 );
if( t->service() == Yahoo::ServiceLogoff || ( state != 0 && flags == 0 ) )
emit statusChanged( nick, Yahoo::StatusOffline, QString::null, 0, 0 );
emit statusChanged( nick, Yahoo::StatusOffline, QString(), 0, 0, 0 );
else
emit statusChanged( nick, state, message, away, idle );
if( checksum )
emit gotPictureChecksum( nick, checksum );
emit statusChanged( nick, state, message, away, idle, pictureChecksum );
}
}
void StatusNotifierTask::parseAuthorization( YMSGTransfer* t )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
QString nick; /* key = 4 */
QString msg; /* key = 14 */
@ -163,14 +158,14 @@ void StatusNotifierTask::parseAuthorization( YMSGTransfer* t )
if( !fname.isEmpty() || !lname.isEmpty() )
name = QString("%1 %2").arg(fname).arg(lname);
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Emitting gotAuthorizationRequest( " << nick<< ", " << msg << ", " << name << " )" << endl;
kdDebug(YAHOO_RAW_DEBUG) << "Emitting gotAuthorizationRequest( " << nick<< ", " << msg << ", " << name << " )" << endl;
emit gotAuthorizationRequest( nick, msg, name );
}
}
void StatusNotifierTask::parseStealthStatus( YMSGTransfer* t )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
QString nick; /* key = 7 */
int state; /* key = 31 */

@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Notifies about status changes of buddies
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@ -36,18 +36,17 @@ public:
bool take(Transfer *transfer);
protected:
bool forMe( Transfer *transfer ) const;
virtual bool forMe( const Transfer *transfer ) const;
void parseStatus( YMSGTransfer *transfer );
void parseStealthStatus( YMSGTransfer *transfer );
void parseAuthorization( YMSGTransfer *transfer );
signals:
void statusChanged( const QString&, int, const QString&, int, int );
void statusChanged( const QString &nick, int state, const QString &message, int away, int idle, int pictureChecksum );
void stealthStatusChanged( const QString&, Yahoo::StealthStatus );
void loginResponse( int, const QString& );
void authorizationAccepted( const QString & );
void authorizationRejected( const QString &, const QString & );
void gotAuthorizationRequest( const QString &, const QString &, const QString & );
void gotPictureChecksum( const QString &, int );
};
#endif

@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Stealth/Unstealth a buddy
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@ -23,7 +23,7 @@
StealthTask::StealthTask(Task* parent) : Task(parent)
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
}
StealthTask::~StealthTask()
@ -53,11 +53,16 @@ void StealthTask::onGo()
}
t->setId( client()->sessionID() );
t->setParam( 1, client()->userId().local8Bit());
if( !m_target.isEmpty() )
if( !m_target.isEmpty() ) {
t->setParam( 302, 319 );
t->setParam( 300, 319 );
t->setParam( 7, m_target.local8Bit() );
t->setParam( 301, 319 );
t->setParam( 303, 319 );
}
send( t );
setSuccess( true );
setSuccess();
}
void StealthTask::setTarget( const QString &to )

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

@ -3,7 +3,7 @@
Copyright (c) 2004 SUSE Linux AG http://www.suse.com
Based on Iris, Copyright (C) 2003 Justin Karneges
Based on Iris, Copyright (C) 2003 Justin Karneges <justin@affinix.com>
Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>

@ -4,7 +4,7 @@
Copyright (c) 2004 Matt Rogers <matt.rogers@kdemail.net>
Based on code copyright (c) 2004 SuSE Linux AG <http://www.suse.com>
Based on Iris, Copyright (C) 2003 Justin Karneges
Based on Iris, Copyright (C) 2003 Justin Karneges <justin@affinix.com>
Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>

@ -3,7 +3,7 @@
Copyright (c) 2004 SUSE Linux AG http://www.suse.com
Based on Iris, Copyright (C) 2003 Justin Karneges
Based on Iris, Copyright (C) 2003 Justin Karneges <justin@affinix.com>
Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
@ -131,7 +131,8 @@ bool Task::take( Transfer * transfer)
// pass along the transfer to our children
QObjectListIt it(*p);
Task *t;
for(; it.current(); ++it) {
for(; it.current(); ++it)
{
QObject *obj = it.current();
if(!obj->inherits("Task"))
continue;
@ -143,8 +144,6 @@ bool Task::take( Transfer * transfer)
qDebug( "Transfer ACCEPTED by: %s", t->className() );
return true;
}
/* else
qDebug( "Transfer refused by: %s", t->className() );*/
}
return false;

@ -3,7 +3,7 @@
Copyright (c) 2004 SUSE Linux AG http://www.suse.com
Based on Iris, Copyright (C) 2003 Justin Karneges
Based on Iris, Copyright (C) 2003 Justin Karneges <justin@affinix.com>
Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
@ -25,7 +25,6 @@
class QString;
class Client;
class Request;
class Transfer;
class Task : public QObject

@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Handles incoming webcam connections
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@ -20,10 +20,11 @@
#include "ymsgtransfer.h"
#include "yahootypes.h"
#include "client.h"
#include <qstring.h>
#include <qbuffer.h>
#include <qfile.h>
#include <qtimer.h>
#include <qpixmap.h>
#include <ktempfile.h>
#include <kprocess.h>
#include <kstreamsocket.h>
@ -34,7 +35,7 @@ using namespace KNetwork;
WebcamTask::WebcamTask(Task* parent) : Task(parent)
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
transmittingData = false;
transmissionPending = false;
timestamp = 1;
@ -46,8 +47,6 @@ WebcamTask::~WebcamTask()
bool WebcamTask::take( Transfer* transfer )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
if ( !forMe( transfer ) )
return false;
@ -61,12 +60,10 @@ bool WebcamTask::take( Transfer* transfer )
return true;
}
bool WebcamTask::forMe( Transfer* transfer ) const
bool WebcamTask::forMe( const Transfer* transfer ) const
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
YMSGTransfer *t = 0L;
t = dynamic_cast<YMSGTransfer*>(transfer);
const YMSGTransfer *t = 0L;
t = dynamic_cast<const YMSGTransfer*>(transfer);
if (!t)
return false;
@ -78,7 +75,7 @@ bool WebcamTask::forMe( Transfer* transfer ) const
void WebcamTask::requestWebcam( const QString &who )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceWebcam);
t->setId( client()->sessionID() );
@ -91,7 +88,7 @@ void WebcamTask::requestWebcam( const QString &who )
void WebcamTask::parseWebcamInformation( YMSGTransfer *t )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
YahooWebcamInformation info;
info.sender = keyPending;
@ -109,7 +106,7 @@ void WebcamTask::parseWebcamInformation( YMSGTransfer *t )
else
info.direction = Incoming;
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Got WebcamInformation: Sender: " << info.sender << " Server: " << info.server << " Key: " << info.key << endl;
kdDebug(YAHOO_RAW_DEBUG) << "Got WebcamInformation: Sender: " << info.sender << " Server: " << info.server << " Key: " << info.key << endl;
KStreamSocket *socket = new KStreamSocket( info.server, QString::number(5100) );
socketMap[socket] = info;
@ -126,7 +123,7 @@ void WebcamTask::slotConnectionStage1Established()
KStreamSocket* socket = const_cast<KStreamSocket*>( dynamic_cast<const KStreamSocket*>( sender() ) );
if( !socket )
return;
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Webcam connection Stage1 to the user " << socketMap[socket].sender << " established." << endl;
kdDebug(YAHOO_RAW_DEBUG) << "Webcam connection Stage1 to the user " << socketMap[socket].sender << " established." << endl;
disconnect( socket, SIGNAL( connected( const KResolverEntry& ) ), this, SLOT( slotConnectionStage1Established() ) );
disconnect( socket, SIGNAL( gotError(int) ), this, SLOT( slotConnectionFailed(int) ) );
socketMap[socket].status = ConnectedStage1;
@ -159,7 +156,7 @@ void WebcamTask::slotConnectionStage2Established()
if( !socket )
return;
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Webcam connection Stage2 to the user " << socketMap[socket].sender << " established." << endl;
kdDebug(YAHOO_RAW_DEBUG) << "Webcam connection Stage2 to the user " << socketMap[socket].sender << " established." << endl;
disconnect( socket, SIGNAL( connected( const KResolverEntry& ) ), this, SLOT( slotConnectionStage2Established() ) );
disconnect( socket, SIGNAL( gotError(int) ), this, SLOT( slotConnectionFailed(int) ) );
socketMap[socket].status = ConnectedStage2;
@ -190,6 +187,7 @@ void WebcamTask::slotConnectionStage2Established()
stream << (Q_INT8)0x0d << (Q_INT8)0x00 << (Q_INT8)0x05 << (Q_INT8)0x00 << (Q_INT32)s.length()
<< (Q_INT8)0x01 << (Q_INT8)0x00 << (Q_INT8)0x00 << (Q_INT8)0x00 << (Q_INT8)0x01;
}
socket->writeBlock( buffer.data(), buffer.size() );
socket->writeBlock( s.local8Bit(), s.length() );
}
@ -197,6 +195,7 @@ void WebcamTask::slotConnectionStage2Established()
void WebcamTask::slotConnectionFailed( int error )
{
KStreamSocket* socket = const_cast<KStreamSocket*>( dynamic_cast<const KStreamSocket*>( sender() ) );
kdDebug(YAHOO_RAW_DEBUG) << "Webcam connection to the user " << socketMap[socket].sender << " failed. Error " << error << " - " << socket->errorString() << endl;
client()->notifyError( i18n("Webcam connection to the user %1 could not be established.\n\nPlease relogin and try again.")
.arg(socketMap[socket].sender), QString("%1 - %2").arg(error).arg( socket->errorString()), Client::Error );
socketMap.remove( socket );
@ -226,10 +225,10 @@ void WebcamTask::slotRead()
void WebcamTask::connectStage2( KStreamSocket *socket )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
QByteArray data( socket->bytesAvailable() );
socket->readBlock ( data.data (), data.size () );
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Magic Byte:" << data[2] << endl;
kdDebug(YAHOO_RAW_DEBUG) << "Magic Byte:" << data[2] << endl;
socketMap[socket].status = ConnectedStage2;
@ -245,14 +244,14 @@ void WebcamTask::connectStage2( KStreamSocket *socket )
case (Q_INT8)0x07:
while( (const char)data[i] != (Q_INT8)0x00 )
server += data[i++];
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Server:" << server << endl;
kdDebug(YAHOO_RAW_DEBUG) << "Server:" << server << endl;
if( server.isEmpty() )
{
emit webcamNotAvailable(socketMap[socket].sender);
break;
}
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Connecting to " << server << endl;
kdDebug(YAHOO_RAW_DEBUG) << "Connecting to " << server << endl;
newSocket = new KStreamSocket( server, QString::number(5100) );
socketMap[newSocket] = socketMap[socket];
newSocket->enableRead( true );
@ -279,9 +278,10 @@ void WebcamTask::processData( KStreamSocket *socket )
QByteArray data( socket->bytesAvailable() );
socket->readBlock ( data.data (), data.size () );
if( data.size() <= 0 )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "No data read." << endl;
kdDebug(YAHOO_RAW_DEBUG) << "No data read." << endl;
return;
}
@ -290,13 +290,13 @@ void WebcamTask::processData( KStreamSocket *socket )
void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket )
{
uint headerLength = 0;
uint read = 0;
int headerLength = 0;
int read = 0;
YahooWebcamInformation *info = &socketMap[socket];
if( !info->headerRead )
{
headerLength = data[0];
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "headerLength " << headerLength << endl;
kdDebug(YAHOO_RAW_DEBUG) << "headerLength " << headerLength << endl;
if( data.size() < headerLength )
return;
if( headerLength >= 8 )
@ -309,7 +309,7 @@ void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket )
{
kdDebug() << data[8] << data[9] << data[10] << data[11] << data[12] << endl;
info->timestamp = yahoo_get32(data.data() + 9);
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "PacketType: " << data[8] << " reason: " << info->reason << " timestamp: " << info->timestamp << endl;
kdDebug(YAHOO_RAW_DEBUG) << "PacketType: " << data[8] << " reason: " << info->reason << " timestamp: " << info->timestamp << endl;
QStringList::iterator it;
switch( data[8] )
{
@ -339,7 +339,7 @@ void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket )
}
break;
case 0x05:
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Ready for Transmission. " << info->timestamp << " watchers." << endl;
kdDebug(YAHOO_RAW_DEBUG) << "Ready for Transmission" << endl;
if( info->timestamp == 1 )
{
info->status = Sending;
@ -359,7 +359,7 @@ void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket )
snt->setTarget( *it );
snt->setType( SendNotifyTask::NotifyWebcamInvite );
snt->go( true );
it = pendingInvitations.remove( it );
it = pendingInvitations.erase( it );
it--;
}
break;
@ -383,39 +383,39 @@ void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket )
if( !info->headerRead && data.size() > headerLength )
{
// More headers to read
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "More data to read..." << endl;
kdDebug(YAHOO_RAW_DEBUG) << "More data to read..." << endl;
QByteArray newData( data.size() - headerLength );
QDataStream stream( newData, IO_WriteOnly );
stream.writeRawBytes( data.data() + headerLength, data.size() - headerLength );
parseData( newData, socket );
return;
}
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Parsed Packet: HeaderLen: " << headerLength << " DataLen: " << info->dataLength << endl;
kdDebug(YAHOO_RAW_DEBUG) << "Parsed Packet: HeaderLen: " << headerLength << " DataLen: " << info->dataLength << endl;
}
if( info->dataLength <= 0 )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "No data to read. (info->dataLength <= 0)" << endl;
kdDebug(YAHOO_RAW_DEBUG) << "No data to read. (info->dataLength <= 0)" << endl;
if( info->headerRead )
info->headerRead = false;
return;
}
if( headerLength >= data.size() )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "No data to read. (headerLength >= data.size())" << endl;
kdDebug(YAHOO_RAW_DEBUG) << "No data to read. (headerLength >= data.size())" << endl;
return; //Nothing to read here...
}
if( !info->buffer )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Buffer created" << endl;
kdDebug(YAHOO_RAW_DEBUG) << "Buffer created" << endl;
info->buffer = new QBuffer();
info->buffer->open( IO_WriteOnly );
}
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "data.size() " << data.size() << " headerLength " << headerLength << " buffersize " << info->buffer->size() << endl;
kdDebug(YAHOO_RAW_DEBUG) << "data.size() " << data.size() << " headerLength " << headerLength << " buffersize " << info->buffer->size() << endl;
read = headerLength + info->dataLength - info->buffer->size();
info->buffer->writeBlock( data.data() + headerLength, data.size() - headerLength );//info->dataLength - info->buffer->size() );
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "read " << data.size() - headerLength << " Bytes, Buffer is now " << info->buffer->size() << endl;
kdDebug(YAHOO_RAW_DEBUG) << "read " << data.size() - headerLength << " Bytes, Buffer is now " << info->buffer->size() << endl;
if( info->buffer->size() >= static_cast<uint>(info->dataLength) )
{
info->buffer->close();
@ -426,7 +426,7 @@ void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket )
{
who.append( info->buffer->buffer() );
who = who.mid( 2, who.find('\n') - 3);
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "User wants to view webcam: " << who << " len: " << who.length() << " Index: " << accessGranted.findIndex( who ) << endl;
kdDebug(YAHOO_RAW_DEBUG) << "User wants to view webcam: " << who << " len: " << who.length() << " Index: " << accessGranted.findIndex( who ) << endl;
if( accessGranted.findIndex( who ) >= 0 )
{
grantAccess( who );
@ -438,13 +438,13 @@ void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket )
case NewWatcher:
who.append( info->buffer->buffer() );
who = who.left( who.length() - 1 );
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "New Watcher of webcam: " << who << endl;
kdDebug(YAHOO_RAW_DEBUG) << "New Watcher of webcam: " << who << endl;
emit viewerJoined( who );
break;
case WatcherLeft:
who.append( info->buffer->buffer() );
who = who.left( who.length() - 1 );
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "A Watcher left: " << who << " len: " << who.length() << endl;
kdDebug(YAHOO_RAW_DEBUG) << "A Watcher left: " << who << " len: " << who.length() << endl;
accessGranted.remove( who );
emit viewerLeft( who );
break;
@ -453,6 +453,17 @@ void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket )
QPixmap webcamImage;
//webcamImage.loadFromData( info->buffer->buffer() );
// FIXME (same)
//KTemporaryFile jpcTmpImageFile;
//jpcTmpImageFile.setAutoRemove(false);
//jpcTmpImageFile.open();
//KTemporaryFile bmpTmpImageFile;
//bmpTmpImageFile.setAutoRemove(false);
//bmpTmpImageFile.open();
//jpcTmpImageFile.write((info->buffer->buffer()).data(), info->buffer->size());
//jpcTmpImageFile.close();
KTempFile jpcTmpImageFile;
KTempFile bmpTmpImageFile;
QFile *file = jpcTmpImageFile.file();
@ -477,7 +488,7 @@ void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket )
QFile::remove(jpcTmpImageFile.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;
default:
@ -491,7 +502,7 @@ void WebcamTask::parseData( QByteArray &data, KStreamSocket *socket )
if( data.size() > read )
{
// More headers to read
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "More data to read..." << data.size() - read << endl;
kdDebug(YAHOO_RAW_DEBUG) << "More data to read..." << data.size() - read << endl;
QByteArray newData( data.size() - read );
QDataStream stream( newData, IO_WriteOnly );
stream.writeRawBytes( data.data() + read, data.size() - read );
@ -511,19 +522,19 @@ void WebcamTask::cleanUpConnection( KStreamSocket *socket )
void WebcamTask::closeWebcam( const QString & who )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
SocketInfoMap::Iterator it;
for( it = socketMap.begin(); it != socketMap.end(); it++ )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << it.data().sender << " - " << who << endl;
kdDebug(YAHOO_RAW_DEBUG) << it.data().sender << " - " << who << endl;
if( it.data().sender == who )
{
cleanUpConnection( it.key() );
return;
}
}
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Error. You tried to close a connection that didn't exist." << endl;
client()->notifyError( i18n( "An error occured closing the webcam session. " ), i18n( "You tried to close a connection that didn't exist." ), Client::Debug );
kdDebug(YAHOO_RAW_DEBUG) << "Error. You tried to close a connection that did not exist." << endl;
client()->notifyError( i18n( "An error occurred closing the webcam session. " ), i18n( "You tried to close a connection that did not exist." ), Client::Debug );
}
@ -531,7 +542,7 @@ void WebcamTask::closeWebcam( const QString & who )
void WebcamTask::registerWebcam()
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
YMSGTransfer *t = new YMSGTransfer(Yahoo::ServiceWebcam);
t->setId( client()->sessionID() );
@ -543,14 +554,14 @@ void WebcamTask::registerWebcam()
void WebcamTask::addPendingInvitation( const QString &userId )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Inviting " << userId << " to watch the webcam." << endl;
kdDebug(YAHOO_RAW_DEBUG) << "Inviting " << userId << " to watch the webcam." << endl;
pendingInvitations.append( userId );
accessGranted.append( userId );
}
void WebcamTask::grantAccess( const QString &userId )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
KStreamSocket *socket = 0L;
SocketInfoMap::Iterator it;
for( it = socketMap.begin(); it != socketMap.end(); it++ )
@ -563,7 +574,7 @@ void WebcamTask::grantAccess( const QString &userId )
}
if( !socket )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Error. No outgoing socket found." << endl;
kdDebug(YAHOO_RAW_DEBUG) << "Error. No outgoing socket found." << endl;
return;
}
QByteArray ar;
@ -578,7 +589,7 @@ void WebcamTask::grantAccess( const QString &userId )
void WebcamTask::closeOutgoingWebcam()
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
KStreamSocket *socket = 0L;
SocketInfoMap::Iterator it;
for( it = socketMap.begin(); it != socketMap.end(); it++ )
@ -591,7 +602,7 @@ void WebcamTask::closeOutgoingWebcam()
}
if( !socket )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Error. No outgoing socket found." << endl;
kdDebug(YAHOO_RAW_DEBUG) << "Error. No outgoing socket found." << endl;
return;
}
@ -601,7 +612,7 @@ void WebcamTask::closeOutgoingWebcam()
void WebcamTask::sendEmptyWebcamImage()
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
KStreamSocket *socket = 0L;
SocketInfoMap::Iterator it;
@ -615,7 +626,7 @@ void WebcamTask::sendEmptyWebcamImage()
}
if( !socket )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Error. No outgoing socket found." << endl;
kdDebug(YAHOO_RAW_DEBUG) << "Error. No outgoing socket found." << endl;
return;
}
if( socketMap[socket].status != SendingEmpty )
@ -630,8 +641,8 @@ void WebcamTask::sendEmptyWebcamImage()
void WebcamTask::sendWebcamImage( const QByteArray &image )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
pictureBuffer.duplicate( image );
kdDebug(YAHOO_RAW_DEBUG) ;
pictureBuffer = image;
transmissionPending = true;
KStreamSocket *socket = 0L;
SocketInfoMap::Iterator it;
@ -645,7 +656,7 @@ void WebcamTask::sendWebcamImage( const QByteArray &image )
}
if( !socket )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Error. No outgoing socket found." << endl;
kdDebug(YAHOO_RAW_DEBUG) << "Error. No outgoing socket found." << endl;
return;
}
@ -656,7 +667,7 @@ void WebcamTask::transmitWebcamImage()
{
if( !transmissionPending )
return;
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "arraysize: " << pictureBuffer.size() << endl;
kdDebug(YAHOO_RAW_DEBUG) << "arraysize: " << pictureBuffer.size() << endl;
// Find outgoing socket
KStreamSocket *socket = 0L;
@ -671,7 +682,7 @@ void WebcamTask::transmitWebcamImage()
}
if( !socket )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Error. No outgoing socket found." << endl;
kdDebug(YAHOO_RAW_DEBUG) << "Error. No outgoing socket found." << endl;
return;
}

@ -2,7 +2,7 @@
Kopete Yahoo Protocol
Handles incoming webcam connections
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2005 André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@ -62,7 +62,6 @@ public:
~WebcamTask();
bool take(Transfer *transfer);
bool forMe( Transfer* transfer ) const;
bool transmitting() { return transmittingData; }
@ -91,6 +90,8 @@ private slots:
void slotRead();
void sendEmptyWebcamImage();
void transmitWebcamImage();
protected:
virtual bool forMe( const Transfer* transfer ) const;
private:
void parseWebcamInformation( YMSGTransfer *transfer );
void parseData( QByteArray &data, KStreamSocket *socket );

@ -1,7 +1,7 @@
/*
yabcpp - Encapsulate Yahoo Adressbook information
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2005 André Duffeck <duffeck@kde.org>
Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
*************************************************************************
@ -48,9 +48,9 @@ void YABEntry::fromQDomElement( const QDomElement &e )
privateZIP = e.attribute("hz");
privateCountry = e.attribute("hn");
QString birtday = e.attribute("bi");
birthday = QDate( birtday.section("/",2,2).toInt(), birtday.section("/",1,1).toInt(), birtday.section("/",0,0).toInt() );
birthday = QDate( birtday.section('/',2,2).toInt(), birtday.section('/',1,1).toInt(), birtday.section('/',0,0).toInt() );
QString an = e.attribute("an");
anniversary = QDate( an.section("/",2,2).toInt(), an.section("/",1,1).toInt(), an.section("/",0,0).toInt() );
anniversary = QDate( an.section('/',2,2).toInt(), an.section('/',1,1).toInt(), an.section('/',0,0).toInt() );
additional1 = e.attribute("c1");
additional2 = e.attribute("c2");
additional3 = e.attribute("c3");
@ -68,7 +68,7 @@ void YABEntry::fromQDomElement( const QDomElement &e )
void YABEntry::fromQDomDocument( const QDomDocument &d )
{
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();
firstName = d.elementsByTagName("fn").item(0).toElement().text();
secondName = d.elementsByTagName("mn").item(0).toElement().text();
@ -98,9 +98,9 @@ void YABEntry::fromQDomDocument( const QDomDocument &d )
privateZIP = d.elementsByTagName("hz").item(0).toElement().text();
privateCountry = d.elementsByTagName("hn").item(0).toElement().text();
QString birtday = d.elementsByTagName("bi").item(0).toElement().text();
birthday = QDate( birtday.section("/",2,2).toInt(), birtday.section("/",1,1).toInt(), birtday.section("/",0,0).toInt() );
birthday = QDate( birtday.section('/',2,2).toInt(), birtday.section('/',1,1).toInt(), birtday.section('/',0,0).toInt() );
QString an = d.elementsByTagName("an").item(0).toElement().text();
anniversary = QDate( an.section("/",2,2).toInt(), an.section("/",1,1).toInt(), an.section("/",0,0).toInt() );
anniversary = QDate( an.section('/',2,2).toInt(), an.section('/',1,1).toInt(), an.section('/',0,0).toInt() );
additional1 = d.elementsByTagName("c1").item(0).toElement().text();
additional2 = d.elementsByTagName("c2").item(0).toElement().text();
additional3 = d.elementsByTagName("c3").item(0).toElement().text();
@ -135,13 +135,13 @@ void YABEntry::fillQDomElement( QDomElement &e ) const
e.setAttribute( "pu", privateURL );
e.setAttribute( "ti", title );
e.setAttribute( "co", corporation );
e.setAttribute( "wa", QString( workAdress ).replace( "\n", "&#xd;&#xa;" ) );
e.setAttribute( "wa", QString( workAdress ).replace( '\n', "&#xd;&#xa;" ) );
e.setAttribute( "wc", workCity );
e.setAttribute( "ws", workState );
e.setAttribute( "wz", workZIP );
e.setAttribute( "wn", workCountry );
e.setAttribute( "wu", workURL );
e.setAttribute( "ha", QString( privateAdress ).replace( "\n", "&#xd;&#xa;" ) );
e.setAttribute( "ha", QString( privateAdress ).replace( '\n', "&#xd;&#xa;" ) );
e.setAttribute( "hc", privateCity );
e.setAttribute( "hs", privateState );
e.setAttribute( "hz", privateZIP );
@ -152,7 +152,7 @@ void YABEntry::fillQDomElement( QDomElement &e ) const
e.setAttribute( "c2", additional2 );
e.setAttribute( "c3", additional3 );
e.setAttribute( "c4", additional4 );
e.setAttribute( "cm", QString( notes ).replace( "\n", "&#xd;&#xa;" ) );
e.setAttribute( "cm", QString( notes ).replace( '\n', "&#xd;&#xa;" ) );
e.setAttribute( "ima", imAIM );
e.setAttribute( "img", imGoogleTalk );
e.setAttribute( "imq", imICQ );

@ -1,7 +1,7 @@
/*
yabentry.h - Encapsulate Yahoo Adressbook information
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2005 André Duffeck <duffeck@kde.org>
Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
*************************************************************************
@ -71,7 +71,7 @@ struct YABEntry
QString workPhone;
QString workURL;
// Miscellanous
// Miscellaneous
QDate birthday;
QDate anniversary;
QString notes;

@ -2,7 +2,7 @@
Kopete Yahoo Protocol
yabtask.h - Handles the Yahoo Address Book
Copyright (c) 2006 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2006 André Duffeck <duffeck@kde.org>
Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
*************************************************************************
@ -29,7 +29,7 @@
YABTask::YABTask(Task* parent) : Task(parent)
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
}
YABTask::~YABTask()
@ -38,8 +38,6 @@ YABTask::~YABTask()
bool YABTask::take( Transfer* transfer )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
if ( !forMe( transfer ) )
return false;
@ -51,12 +49,10 @@ bool YABTask::take( Transfer* transfer )
return true;
}
bool YABTask::forMe( Transfer* transfer ) const
bool YABTask::forMe( const Transfer* transfer ) const
{
// kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
YMSGTransfer *t = 0L;
t = dynamic_cast<YMSGTransfer*>(transfer);
const YMSGTransfer *t = 0L;
t = dynamic_cast<const YMSGTransfer*>(transfer);
if (!t)
return false;
@ -68,7 +64,7 @@ bool YABTask::forMe( Transfer* transfer ) const
void YABTask::parseContactDetails( YMSGTransfer* t )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
QString from; /* key = 7 */
int count;
@ -96,7 +92,7 @@ void YABTask::parseContactDetails( YMSGTransfer* t )
void YABTask::getAllEntries( long lastMerge, long lastRemoteRevision )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "LastMerge: " << lastMerge << " LastRemoteRevision: " << lastRemoteRevision << endl;
kdDebug(YAHOO_RAW_DEBUG) << "LastMerge: " << lastMerge << " LastRemoteRevision: " << lastRemoteRevision << endl;
m_data = QString::null;
QString url = QString::fromLatin1("http://address.yahoo.com/yab/us?v=XM&prog=ymsgr&.intl=us&diffs=1&t=%1&tags=short&rt=%2&prog-ver=%3")
.arg( lastMerge ).arg( lastRemoteRevision ).arg( YMSG_PROGRAM_VERSION_STRING );
@ -111,21 +107,24 @@ void YABTask::getAllEntries( long lastMerge, long lastRemoteRevision )
void YABTask::slotData( KIO::Job* /*job*/, const QByteArray &info )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
m_data += info;
}
void YABTask::slotResult( KIO::Job* job )
{
if( job->error () || m_transferJob->isErrorPage () )
client()->notifyError( i18n( "Could not retrieve server side addressbook for user info." ), job->errorString(), Client::Info );
{
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) << k_funcinfo << "Server side addressbook retrieved." << endl;
kdDebug(YAHOO_RAW_DEBUG) << "Server side addressbook retrieved." << endl;
QDomDocument doc;
QDomNodeList list;
QDomElement e;
uint it = 0;
int it = 0;
kdDebug(YAHOO_RAW_DEBUG) << m_data << endl;
doc.setContent( m_data );

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

@ -18,6 +18,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef YAHOO_FN_H
#define YAHOO_FN_H
#define IDENT 1 /* identify function */
#define XOR 2 /* xor with arg1 */
#define MULADD 3 /* multipy by arg1 then add arg2 */
@ -31,3 +34,5 @@ struct yahoo_fn
};
int yahoo_xfrm( int table, int depth, int seed );
#endif // YAHOO_FN_H

@ -1,7 +1,7 @@
/*
yahoobuddyiconloader.cpp - Fetches YahooBuddyIcons
Copyright (c) 2005 by André Duffeck <andre@duffeck.de>
Copyright (c) 2005 by André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@ -42,7 +42,7 @@ YahooBuddyIconLoader::~YahooBuddyIconLoader()
void YahooBuddyIconLoader::fetchBuddyIcon( const QString &who, KURL url, int checksum )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << url << endl;
KIO::TransferJob *transfer;
QString Url = url.url();
QString ext = Url.left( Url.findRev( "?" ) );
@ -55,48 +55,37 @@ void YahooBuddyIconLoader::fetchBuddyIcon( const QString &who, KURL url, int che
m_jobs[transfer].url = url;
m_jobs[transfer].who = who;
m_jobs[transfer].checksum = checksum;
m_jobs[transfer].file = new KTempFile( locateLocal( "tmp", "yahoobuddyicon-" ), ext );
m_jobs[transfer].file->setAutoDelete( true );
}
void YahooBuddyIconLoader::slotData( KIO::Job *job, const QByteArray& data )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
KIO::TransferJob *transfer = static_cast< KIO::TransferJob * >(job);
if( m_jobs[transfer].file )
m_jobs[transfer].file->file()->writeBlock( data.data() , data.size() );
// FIXME need to check
//m_jobs[transfer].icon.append( data );
int oldsize = m_jobs[transfer].icon.size();
m_jobs[transfer].icon.resize( data.size() + oldsize );
memcpy( m_jobs[transfer].icon.data() + oldsize, data.data(), data.size() );
}
void YahooBuddyIconLoader::slotComplete( KIO::Job *job )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
KIO::TransferJob *transfer = static_cast< KIO::TransferJob * >(job);
if ( job->error () || transfer->isErrorPage () )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "An error occured while downloading buddy icon." << endl;
kdDebug(YAHOO_RAW_DEBUG) << "An error occurred while downloading buddy icon." << endl;
if( m_client )
m_client->notifyError( i18n( "An error occured while downloading buddy icon (%1)" ).arg(m_jobs[transfer].url.url()), job->errorString(), Client::Info );
}
else
{
if ( m_jobs[transfer].file )
{
m_jobs[transfer].file->close();
emit fetchedBuddyIcon( m_jobs[transfer].who, m_jobs[transfer].file, m_jobs[transfer].checksum );
m_client->notifyError( i18n( "An error occurred while downloading a buddy icon (%1)").arg( m_jobs[transfer].url.url() ), job->errorString(), Client::Info );
}
else
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Fatal Error occured. IconLoadJob has an empty KTempFile pointer." << endl;
if( m_client )
m_client->notifyError( i18n( "Fatal Error occured while downloading buddy icon." ), i18n( "IconLoadJob has an empty KTempFile pointer." ), Client::Info );
}
emit fetchedBuddyIcon( m_jobs[transfer].who, m_jobs[transfer].icon, m_jobs[transfer].checksum );
}
m_jobs.remove( transfer );

@ -1,7 +1,7 @@
/*
yahoobuddyiconloader.h - Fetches YahooBuddyIcons
Copyright (c) 2005 by André Duffeck <andre@duffeck.de>
Copyright (c) 2005 by André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@ -24,7 +24,7 @@
// KDE Includes
#include <kurl.h>
class KTempFile;
class KJob;
class Client;
namespace KIO {
class Job;
@ -35,7 +35,7 @@ struct IconLoadJob {
KURL url;
QString who;
int checksum;
KTempFile *file;
QByteArray icon;
};
/**
@ -60,9 +60,9 @@ public:
signals:
/**
* The account can connect to this signal and append the icon
* stored in 'file' to the apropriate contact
* stored in 'file' to the appropriate contact
*/
void fetchedBuddyIcon( const QString &who, KTempFile *file, int checksum );
void fetchedBuddyIcon( const QString &who, const QByteArray &icon, int checksum );
private slots:
void slotData( KIO::Job *job, const QByteArray &data );

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

@ -15,8 +15,8 @@
*************************************************************************
*/
#ifndef KNETWORKBYTESTREAM_H
#define KNETWORKBYTESTREAM_H
#ifndef YAHOOBYTESTREAM_H
#define YAHOOBYTESTREAM_H
#include <kbufferedsocket.h>
@ -34,7 +34,7 @@ class KNetworkByteStream : public ByteStream
Q_OBJECT
public:
KNetworkByteStream ( QObject *parent = 0, const char *name = 0 );
KNetworkByteStream ( QObject *parent = 0 );
~KNetworkByteStream ();
@ -63,7 +63,6 @@ private:
};
#endif
#endif // YAHOOBYTESTREAM_H
// kate: indent-width 4; replace-tabs off; tab-width 4; space-indent off;

@ -4,7 +4,7 @@
Copyright (c) 2004 Matt Rogers <matt.rogers@kdemail.net>
Based on code Copyright (c) 2004 SuSE Linux AG <http://www.suse.com>
Based on Iris, Copyright (C) 2003 Justin Karneges
Based on Iris, Copyright (C) 2003 Justin Karneges <justin@affinix.com>
Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
@ -103,12 +103,10 @@ public:
};
ClientStream::ClientStream(Connector *conn, QObject *parent)
:Stream(parent)
:Stream(parent), d(new Private())
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
d = new Private;
d->mode = Client;
d->conn = conn;
connect( d->conn, SIGNAL(connected()), SLOT(cr_connected()) );
@ -128,7 +126,7 @@ ClientStream::~ClientStream()
void ClientStream::reset(bool all)
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
d->reset();
d->noopTimer.stop();
@ -137,6 +135,7 @@ void ClientStream::reset(bool all)
// reset connector
if(d->bs) {
disconnect(d->bs, 0, this, 0);
d->bs->close();
d->bs = 0;
}
@ -151,7 +150,7 @@ void ClientStream::reset(bool all)
void ClientStream::connectToServer(const QString& server, bool auth)
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
reset(true);
d->state = Connecting;
d->doAuth = auth;
@ -162,7 +161,7 @@ void ClientStream::connectToServer(const QString& server, bool auth)
void ClientStream::continueAfterWarning()
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
/* unneeded?
if(d->state == WaitVersion) {
d->state = Connecting;
@ -235,7 +234,7 @@ void ClientStream::close()
bool ClientStream::transfersAvailable() const
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
return ( !d->in.isEmpty() );
}
@ -249,7 +248,7 @@ Transfer* ClientStream::read()
void ClientStream::write( Transfer *request )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
// pass to CoreProtocol for transformation into wire format
d->client.outgoingTransfer( request );
}
@ -298,31 +297,34 @@ void cs_dump( const QByteArray &bytes )
void ClientStream::cp_outgoingData( const QByteArray& outgoingBytes )
{
if ( !d->bs )
return;
// take formatted bytes from CoreProtocol and put them on the wire
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "[data size: " << outgoingBytes.size() << "]" << endl;
kdDebug(YAHOO_RAW_DEBUG) << "[data size: " << outgoingBytes.size() << "]" << endl;
//cs_dump( outgoingBytes );
d->bs->write( outgoingBytes );
}
void ClientStream::cp_incomingData()
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
// kdDebug(YAHOO_RAW_DEBUG) ;
Transfer * incoming = d->client.incomingTransfer();
if ( incoming )
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " - got a new transfer" << endl;
// kdDebug(YAHOO_RAW_DEBUG) << " - got a new transfer";
d->in.enqueue( incoming );
d->newTransfers = true;
emit doReadyRead();
}
else
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " - client signalled incomingData but none was available, state is: "<< d->client.state() << endl;
kdDebug(YAHOO_RAW_DEBUG) << " - client signalled incomingData but none was available, state is: "<< d->client.state() << endl;
}
/* Connector connected */
void ClientStream::cr_connected()
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
d->bs = d->conn->stream();
connect(d->bs, SIGNAL(connectionClosed()), SLOT(bs_connectionClosed()));
@ -341,7 +343,7 @@ void ClientStream::cr_connected()
void ClientStream::cr_error()
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
reset();
emit error(ErrConnection);
}
@ -359,20 +361,20 @@ void ClientStream::bs_delayedCloseFinished()
void ClientStream::bs_error(int)
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
// TODO
}
void ClientStream::bs_readyRead()
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
// kdDebug(YAHOO_RAW_DEBUG) ;
QByteArray a;
//qDebug( "size of storage for incoming data is %i bytes.", a.size() );
a = d->bs->read();
//QCString cs(a.data(), a.size()+1);
//qDebug("ClientStream: recv: %d [%s]\n", a.size(), cs.data());
//kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " recv: " << a.size() <<" bytes" <<endl;
//kdDebug(YAHOO_RAW_DEBUG) << " recv: " << a.size() <<" bytes";
//cs_dump( a );
d->client.addIncomingData(a);
@ -380,7 +382,7 @@ void ClientStream::bs_readyRead()
void ClientStream::bs_bytesWritten(int bytes)
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " written: " << bytes <<" bytes" <<endl;
kdDebug(YAHOO_RAW_DEBUG) << " written: " << bytes <<" bytes" << endl;
}
void ClientStream::srvProcessNext()
@ -389,7 +391,7 @@ void ClientStream::srvProcessNext()
void ClientStream::doReadyRead()
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
// kdDebug(YAHOO_RAW_DEBUG) ;
emit readyRead();
}

@ -4,7 +4,7 @@
Copyright (c) 2004 Matt Rogers <matt.rogers@kdemail.net>
Based on code Copyright (c) 2004 SuSE Linux AG <http://www.suse.com>
Based on Iris, Copyright (C) 2003 Justin Karneges
Based on Iris, Copyright (C) 2003 Justin Karneges <justin@affinix.com>
Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
@ -26,7 +26,6 @@
class QHostAddress;
// forward defines
class ByteStream;
class Connector;
class Transfer;
@ -42,7 +41,7 @@ public:
};
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
};
@ -52,8 +51,8 @@ public:
RemoteConnectionFailed, // unable to connect to a required remote resource
SeeOtherHost, // a 'redirect', see errorText() for other host
UnsupportedVersion // unsupported XMPP version
};
}
;
enum AuthCond {
GenericAuthError, // all-purpose "can't login" error
NoMech, // No appropriate auth mech available
@ -72,7 +71,7 @@ public:
BindConflict // resource in-use
};
ClientStream(Connector *conn, QObject *parent=0);
explicit ClientStream(Connector *conn, QObject *parent=0);
~ClientStream();
void connectToServer(const QString& server, bool auth=true);
@ -142,7 +141,7 @@ private slots:
private:
class Private;
Private *d;
Private * const d;
void reset(bool all=false);
void processNext();

@ -25,10 +25,10 @@
#include "yahoobytestream.h"
#include "yahootypes.h"
KNetworkConnector::KNetworkConnector( QObject *parent, const char */*name*/ )
KNetworkConnector::KNetworkConnector( QObject *parent )
: Connector( parent )
{
kdDebug( YAHOO_RAW_DEBUG ) << k_funcinfo << "New KNetwork connector." << endl;
kdDebug( YAHOO_RAW_DEBUG ) << "New KNetwork connector." << endl;
mErrorCode = KNetwork::KSocketBase::NoError;
@ -47,7 +47,7 @@ KNetworkConnector::~KNetworkConnector()
void KNetworkConnector::connectToServer( const QString &server )
{
Q_UNUSED( server );
kdDebug( YAHOO_RAW_DEBUG ) << k_funcinfo << "Initiating connection to " << mHost << endl;
kdDebug( YAHOO_RAW_DEBUG ) << "Initiating connection to " << mHost << endl;
Q_ASSERT( !mHost.isNull() );
Q_ASSERT( mPort );
@ -63,7 +63,7 @@ void KNetworkConnector::connectToServer( const QString &server )
void KNetworkConnector::slotConnected()
{
kdDebug( YAHOO_RAW_DEBUG ) << k_funcinfo << "We are connected." << endl;
kdDebug( YAHOO_RAW_DEBUG ) << "We are connected." << endl;
// FIXME: setPeerAddress() is something different, find out correct usage later
//KInetSocketAddress inetAddress = mStreamSocket->address().asInet().makeIPv6 ();
@ -74,7 +74,7 @@ void KNetworkConnector::slotConnected()
void KNetworkConnector::slotError( int code )
{
kdDebug( YAHOO_RAW_DEBUG ) << k_funcinfo << "Error detected: " << code << endl;
kdDebug( YAHOO_RAW_DEBUG ) << "Error detected: " << code << endl;
mErrorCode = code;
emit error ();
@ -87,19 +87,19 @@ int KNetworkConnector::errorCode()
ByteStream *KNetworkConnector::stream() const
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
kdDebug(YAHOO_RAW_DEBUG) ;
return mByteStream;
}
void KNetworkConnector::done()
{
kdDebug ( YAHOO_RAW_DEBUG ) << k_funcinfo << endl;
kdDebug ( YAHOO_RAW_DEBUG ) ;
mByteStream->close ();
}
void KNetworkConnector::setOptHostPort( const QString &host, Q_UINT16 port )
{
kdDebug ( YAHOO_RAW_DEBUG ) << k_funcinfo << "Manually specifying host " << host << " and port " << port << endl;
kdDebug ( YAHOO_RAW_DEBUG ) << "Manually specifying host " << host << " and port " << port << endl;
mHost = host;
mPort = port;

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

@ -19,6 +19,7 @@
#define YAHOOTYPESH
#include <qglobal.h>
#include <qstring.h>
const int YAHOO_RAW_DEBUG = 14181;
const int YAHOO_GEN_DEBUG = 14180;
@ -71,8 +72,8 @@ namespace Yahoo
ServiceAuthResp = 0x54,
ServiceList = 85,
ServiceAuth = 0x57,
ServiceAddBuddy = 0x83,
ServiceRemBuddy,
ServiceBuddyAdd = 0x83,
ServiceBuddyRemove = 0x84,
ServiceIgnoreContact, /* > 1, 7, 13 < 1, 66, 13, 0*/
ServiceRejectContact,
ServiceGroupRename = 0x89, /* > 1, 65(new), 66(0), 67(old) */
@ -98,9 +99,11 @@ namespace Yahoo
ServiceChatSession = 0xd4,
ServiceAuthorization = 0xd6, /* YMSG13 */
ServiceFileTransfer7 = 0xdc, /* YMSG13 */
ServiceFileTransfer7Info, /* YMSG13 */
ServiceFileTransfer7Accept, /* YMSG13 */
ServiceBuddyChangeGroup = 0xe7 /* YMSG13 */
ServiceFileTransfer7Info = 0xdd, /* YMSG13 */
ServiceFileTransfer7Accept = 0xde, /* YMSG13 */
ServiceBuddyChangeGroup = 0xe7, /* YMSG13 */
ServiceBuddyStatus = 0xf0,
ServiceBuddyList = 0xf1
};
enum Status
@ -158,9 +161,26 @@ namespace Yahoo
ResponseDecline
};
enum PictureStatus {
NoPicture = 0,
Avatar = 1,
Picture = 2
};
typedef Q_UINT8 BYTE;
typedef Q_UINT16 WORD;
typedef Q_UINT32 DWORD;
struct ChatRoom {
QString name;
QString topic;
int id;
};
struct ChatCategory {
QString name;
int id;
};
}
#define yahoo_put16(buf, data) ( \

@ -3,7 +3,7 @@
Copyright (c) 2004 Duncan Mac-Vicar Prett <duncan@kde.org>
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2005 André Duffeck <duffeck@kde.org>
Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
*************************************************************************
@ -16,14 +16,18 @@
*************************************************************************
*/
#include <stdlib.h>
//#include <QDataStream>
//#include <QMap>
//#include <QObject>
//#include <QStringList>
#include <qcstring.h>
//#include <qcstring.h>
#include <qdatastream.h>
#include <qmap.h>
#include <qobject.h>
#include <qstringlist.h>
#include <kdebug.h>
#include "ymsgprotocol.h"
@ -55,7 +59,7 @@ Transfer* YMSGProtocol::parse( const QByteArray & packet, uint& bytes )
/ 0 - 65535* |
+-------------------------------------------------+
*/
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << packet << endl;
kdDebug(YAHOO_RAW_DEBUG) << packet << endl;
int pos = 0;
int len = 0;
@ -77,11 +81,11 @@ Transfer* YMSGProtocol::parse( const QByteArray & packet, uint& bytes )
pos += 2;
version2 = yahoo_get16(packet.data() + pos);
pos += 2;
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " - parsed packet version " << version1 << " " << version2 << endl;
kdDebug(YAHOO_RAW_DEBUG) << " - parsed packet version " << version1 << " " << version2 << endl;
len = yahoo_get16(packet.data() + pos);
pos += 2;
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " - parsed packet len " << len << endl;
kdDebug(YAHOO_RAW_DEBUG) << " - parsed packet len " << len << endl;
servicenum = yahoo_get16(packet.data() + pos);
pos += 2;
@ -90,153 +94,217 @@ Transfer* YMSGProtocol::parse( const QByteArray & packet, uint& bytes )
{
// TODO add remamining services
case (Yahoo::ServiceAuth) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceAuth " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceAuth " << servicenum << endl;
service = Yahoo::ServiceAuth;
break;
case (Yahoo::ServiceAuthResp) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceAuthResp " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceAuthResp " << servicenum << endl;
service = Yahoo::ServiceAuthResp;
break;
case (Yahoo::ServiceVerify) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceVerify " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceVerify " << servicenum << endl;
service = Yahoo::ServiceVerify;
break;
case (Yahoo::ServiceList) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceList " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceList " << servicenum << endl;
service = Yahoo::ServiceList;
break;
case (Yahoo::ServiceLogon) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceLogon " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceLogon " << servicenum << endl;
service = Yahoo::ServiceLogon;
break;
case (Yahoo::ServicePing) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServicePing " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServicePing " << servicenum << endl;
service = Yahoo::ServicePing;
break;
case (Yahoo::ServiceNewMail) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceNewMail " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceNewMail " << servicenum << endl;
service = Yahoo::ServiceNewMail;
break;
case (Yahoo::ServiceLogoff) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceLogoff " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceLogoff " << servicenum << endl;
service = Yahoo::ServiceLogoff;
break;
case (Yahoo::ServiceIsAway) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceIsAway " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceIsAway " << servicenum << endl;
service = Yahoo::ServiceIsAway;
break;
case (Yahoo::ServiceIsBack) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceIsBack " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceIsBack " << servicenum << endl;
service = Yahoo::ServiceIsBack;
break;
case (Yahoo::ServiceGameLogon) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceGameLogon " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceGameLogon " << servicenum << endl;
service = Yahoo::ServiceGameLogon;
break;
case (Yahoo::ServiceGameLogoff) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceGameLogoff " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceGameLogoff " << servicenum << endl;
service = Yahoo::ServiceGameLogoff;
break;
case (Yahoo::ServiceIdAct) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceIdAct " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceIdAct " << servicenum << endl;
service = Yahoo::ServiceIdAct;
break;
case (Yahoo::ServiceIddeAct) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceIddeAct " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceIddeAct " << servicenum << endl;
service = Yahoo::ServiceIddeAct;
break;
case (Yahoo::ServiceStatus) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceStatus " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceStatus " << servicenum << endl;
service = Yahoo::ServiceStatus;
break;
case (Yahoo::ServiceMessage) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceMessage " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceMessage " << servicenum << endl;
service = Yahoo::ServiceMessage;
break;
case (Yahoo::ServiceNotify) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceNotify " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceNotify " << servicenum << endl;
service = Yahoo::ServiceNotify;
break;
case (Yahoo::ServiceAddBuddy) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceAddBuddy " << servicenum << endl;
service = Yahoo::ServiceAddBuddy;
case (Yahoo::ServiceBuddyAdd) :
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceBuddyAdd " << servicenum << endl;
service = Yahoo::ServiceBuddyAdd;
break;
case (Yahoo::ServiceBuddyRemove) :
kdDebug(YAHOO_RAW_DEBUG) << "Parsed packet service - This means ServiceBuddyRemove " << servicenum << endl;
service = Yahoo::ServiceBuddyRemove;
break;
case (Yahoo::ServiceBuddyChangeGroup) :
kdDebug(YAHOO_RAW_DEBUG) << "Parsed packet service - This means ServiceBuddyChangeGroup " << servicenum << endl;
service = Yahoo::ServiceBuddyChangeGroup;
break;
case (Yahoo::ServicePictureChecksum) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServicePictureChecksum " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServicePictureChecksum " << servicenum << endl;
service = Yahoo::ServicePictureChecksum;
break;
case (Yahoo::ServicePictureStatus) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServicePictureStatus " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServicePictureStatus " << servicenum << endl;
service = Yahoo::ServicePictureStatus;
break;
case (Yahoo::ServicePicture) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServicePicture " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServicePicture " << servicenum << endl;
service = Yahoo::ServicePicture;
break;
case (Yahoo::ServiceStealthOnline) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceStealthOnline " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceStealthOnline " << servicenum << endl;
service = Yahoo::ServiceStealthOnline;
break;
case (Yahoo::ServiceStealthOffline) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceStealthOffline " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceStealthOffline " << servicenum << endl;
service = Yahoo::ServiceStealthOffline;
break;
case (Yahoo::ServicePictureUpload) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServicePictureUpload " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServicePictureUpload " << servicenum << endl;
service = Yahoo::ServicePictureUpload;
break;
case (Yahoo::ServiceWebcam) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceWebcam " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceWebcam " << servicenum << endl;
service = Yahoo::ServiceWebcam;
break;
case (Yahoo::ServiceConfInvite) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceConfInvite " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceConfInvite " << servicenum << endl;
service = Yahoo::ServiceConfInvite;
break;
case (Yahoo::ServiceConfLogon) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceConfLogon " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceConfLogon " << servicenum << endl;
service = Yahoo::ServiceConfLogon;
break;
case (Yahoo::ServiceConfDecline) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceConfDecline " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceConfDecline " << servicenum << endl;
service = Yahoo::ServiceConfDecline;
break;
case (Yahoo::ServiceConfLogoff) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceConfLogoff " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceConfLogoff " << servicenum << endl;
service = Yahoo::ServiceConfLogoff;
break;
case (Yahoo::ServiceConfAddInvite) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceConfAddInvite " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceConfAddInvite " << servicenum << endl;
service = Yahoo::ServiceConfAddInvite;
break;
case (Yahoo::ServiceConfMsg) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceConfMsg " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceConfMsg " << servicenum << endl;
service = Yahoo::ServiceConfMsg;
break;
case (Yahoo::ServiceAuthorization) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceAuthorization " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceAuthorization " << servicenum << endl;
service = Yahoo::ServiceAuthorization;
break;
case (Yahoo::ServiceContactDetails) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceContactDetails " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceContactDetails " << servicenum << endl;
service = Yahoo::ServiceContactDetails;
break;
case (Yahoo::ServiceFileTransfer) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceFileTransfer " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceFileTransfer " << servicenum << endl;
service = Yahoo::ServiceFileTransfer;
break;
case (Yahoo::ServiceFileTransfer7) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceFileTransfer7 " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceFileTransfer7 " << servicenum << endl;
service = Yahoo::ServiceFileTransfer7;
break;
case (Yahoo::ServiceFileTransfer7Info) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServiceFileTransfer7Info " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceFileTransfer7Info " << servicenum << endl;
service = Yahoo::ServiceFileTransfer7Info;
break;
case (Yahoo::ServiceFileTransfer7Accept) :
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceFileTransfer7Accept " << servicenum << endl;
service = Yahoo::ServiceFileTransfer7Accept;
break;
case (Yahoo::ServicePeerToPeer) :
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means ServicePeerToPeer " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServicePeerToPeer " << servicenum << endl;
service = Yahoo::ServicePeerToPeer;
break;
case (Yahoo::ServiceChatOnline) :
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceChatOnline " << servicenum << endl;
service = Yahoo::ServiceChatOnline;
break;
case (Yahoo::ServiceChatGoto) :
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceChatGoto " << servicenum << endl;
service = Yahoo::ServiceChatGoto;
break;
case (Yahoo::ServiceChatJoin) :
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceChatJoin " << servicenum << endl;
service = Yahoo::ServiceChatJoin;
break;
case (Yahoo::ServiceChatleave) :
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceChatleave " << servicenum << endl;
service = Yahoo::ServiceChatleave;
break;
case (Yahoo::ServiceChatExit) :
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceChatExit " << servicenum << endl;
service = Yahoo::ServiceChatExit;
break;
case (Yahoo::ServiceChatLogout) :
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceChatLogout " << servicenum << endl;
service = Yahoo::ServiceChatLogout;
break;
case (Yahoo::ServiceChatPing) :
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServicePeerToPeer " << servicenum << endl;
service = Yahoo::ServiceChatPing;
break;
case (Yahoo::ServiceChatLogon) :
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceChatLogon " << servicenum << endl;
service = Yahoo::ServiceChatLogon;
break;
case (Yahoo::ServiceChatLogoff) :
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceChatLogoff " << servicenum << endl;
service = Yahoo::ServiceChatLogoff;
break;
case (Yahoo::ServiceChatMsg) :
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceChatMsg " << servicenum << endl;
service = Yahoo::ServiceChatMsg;
break;
case (Yahoo::ServiceComment) :
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceComment " << servicenum << endl;
service = Yahoo::ServiceComment;
break;
case (Yahoo::ServiceBuddyStatus) :
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceBuddyStatus " << servicenum << endl;
service = Yahoo::ServiceBuddyStatus;
break;
case (Yahoo::ServiceBuddyList) :
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means ServiceBuddyList " << servicenum << endl;
service = Yahoo::ServiceBuddyList;
break;
/*
ServiceIdle, // 5 (placemarker)
ServiceMailStat,
@ -250,9 +318,6 @@ Transfer* YMSGProtocol::parse( const QByteArray & packet, uint& bytes )
ServiceGotGroupRename, // < 1, 36(old), 37(new)
ServiceSysMessage = 0x14,
ServicePassThrough2 = 0x16,
ServiceChatLogon,
ServiceChatLogoff,
ServiceChatMsg = 0x20,
ServiceGameMsg = 0x2a,
ServiceFileTransfer = 0x46,
ServiceVoiceChat = 0x4A,
@ -262,21 +327,13 @@ Transfer* YMSGProtocol::parse( const QByteArray & packet, uint& bytes )
ServiceIgnoreContact, // > 1, 7, 13 < 1, 66, 13, 0
ServiceRejectContact,
ServiceGroupRename = 0x89, // > 1, 65(new), 66(0), 67(old)
ServiceChatOnline = 0x96, // > 109(id), 1, 6(abcde) < 0,1
ServiceChatGoto,
ServiceChatJoin, // > 1 104-room 129-1600326591 62-2
ServiceChatleave,
ServiceChatExit = 0x9b,
ServiceChatLogout = 0xa0,
ServiceChatPing,
ServiceComment = 0xa8
ServicePictureUpdate = 0xc1,
ServiceVisibility = 0xc5, // YMSG13, key 13: 2 = invisible, 1 = visible
ServiceStatus = 0xc6, // YMSG13
*/
default:
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed packet service - This means an unknown service " << servicenum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed packet service - This means an unknown service " << servicenum << endl;
break;
}
@ -309,24 +366,24 @@ Transfer* YMSGProtocol::parse( const QByteArray & packet, uint& bytes )
StatusOffline
StatusNotify*/
default:
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " - unknown status " << statusnum << endl;
kdDebug(YAHOO_RAW_DEBUG) << " - unknown status " << statusnum << endl;
break;
}
sessionid = yahoo_get32(packet.data() + pos);
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Parsed session id: " << (void *)sessionid << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Parsed session id: " << (void *)sessionid << endl;
pos += 4;
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Setting incoming transfer basic information." << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Setting incoming transfer basic information." << endl;
YMSGTransfer *t = new YMSGTransfer();
t->setService(service);
t->setId(sessionid);
t->setStatus(status);
t->setPacketLength(len);
QString d = QString::fromAscii( packet.data() + pos, packet.size() - pos );
QStringList list;
list = QStringList::split( "\xc0\x80", d );
for( uint i = 0; i+1 < list.size() && pos+1 < len+20; i += 2 ) {
QStringList list = QStringList::split( "\xc0\x80", d );
for( int i = 0; i+1 < list.size() && pos+1 < len+20; i += 2 ) {
QString key = list[i];
QString value = QString::fromUtf8( list[i+1].ascii() );
pos += key.utf8().length() + value.utf8().length() + 4;
@ -334,10 +391,10 @@ Transfer* YMSGProtocol::parse( const QByteArray & packet, uint& bytes )
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++;
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Returning transfer" << endl;
// kdDebug(YAHOO_RAW_DEBUG) << " Returning transfer";
// tell them we have parsed offset bytes
bytes = pos;

@ -3,7 +3,7 @@
Copyright (c) 2004 Duncan Mac-Vicar Prett <duncan@kde.org>
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2005 André Duffeck <duffeck@kde.org>
Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
*************************************************************************
@ -36,7 +36,7 @@ public:
* The exact state of the parse attempt can be read using @ref state.
* @param rawData The unparsed data.
* @param bytes An integer used to return the number of bytes read.
* @return A pointer to an EventTransfer object if successfull, otherwise 0. The caller is responsible for deleting this object.
* @return A pointer to an EventTransfer object if successful, otherwise 0. The caller is responsible for deleting this object.
*/
Transfer * parse( const QByteArray &, uint & bytes );
};

@ -4,7 +4,7 @@
Copyright (c) 2004 Duncan Mac-Vicar P. <duncan@kde.org>
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2005 André Duffeck <duffeck@kde.org>
Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
@ -23,6 +23,7 @@
#include "ymsgtransfer.h"
#include "yahootypes.h"
#include "kdebug.h"
#include <qdatastream.h>
#include <qmap.h>
#include <qstring.h>
@ -80,12 +81,12 @@ Transfer::TransferType YMSGTransfer::type()
return Transfer::YMSGTransfer;
}
bool YMSGTransfer::isValid()
bool YMSGTransfer::isValid() const
{
return d->valid;
}
Yahoo::Service YMSGTransfer::service()
Yahoo::Service YMSGTransfer::service() const
{
return d->service;
}
@ -95,7 +96,7 @@ void YMSGTransfer::setService(Yahoo::Service service)
d->service = service;
}
Yahoo::Status YMSGTransfer::status()
Yahoo::Status YMSGTransfer::status() const
{
return d->status;
}
@ -105,7 +106,7 @@ void YMSGTransfer::setStatus(Yahoo::Status status)
d->status = status;
}
unsigned int YMSGTransfer::id()
unsigned int YMSGTransfer::id() const
{
return d->id;
}
@ -115,15 +116,25 @@ void YMSGTransfer::setId(unsigned int id)
d->id = id;
}
ParamList YMSGTransfer::paramList()
int YMSGTransfer::packetLength() const
{
return d->packetLength;
}
void YMSGTransfer::setPacketLength(int len)
{
d->packetLength = len;
}
ParamList YMSGTransfer::paramList() const
{
return d->data;
}
int YMSGTransfer::paramCount( int index )
int YMSGTransfer::paramCount( int index ) const
{
int cnt = 0;
for (ParamList::ConstIterator it = d->data.begin(); it != d->data.end(); ++it)
for (ParamList::ConstIterator it = d->data.constBegin(); it != d->data.constEnd(); ++it)
{
if( (*it).first == index )
cnt++;
@ -132,34 +143,34 @@ int YMSGTransfer::paramCount( int index )
}
QCString YMSGTransfer::nthParam( int index, int occurence )
QCString YMSGTransfer::nthParam( int index, int occurrence ) const
{
int cnt = 0;
for (ParamList::ConstIterator it = d->data.begin(); it != d->data.end(); ++it)
for (ParamList::ConstIterator it = d->data.constBegin(); it != d->data.constEnd(); ++it)
{
if( (*it).first == index && cnt++ == occurence)
if( (*it).first == index && cnt++ == occurrence)
return (*it).second;
}
return QCString();
}
QCString YMSGTransfer::nthParamSeparated( int index, int occurence, int separator )
QCString YMSGTransfer::nthParamSeparated( int index, int occurrence, int separator ) const
{
int cnt = -1;
for (ParamList::ConstIterator it = d->data.begin(); it != d->data.end(); ++it)
for (ParamList::ConstIterator it = d->data.constBegin(); it != d->data.constEnd(); ++it)
{
if( (*it).first == separator )
cnt++;
if( (*it).first == index && cnt == occurence)
if( (*it).first == index && cnt == occurrence)
return (*it).second;
}
return QCString();
}
QCString YMSGTransfer::firstParam( int index )
QCString YMSGTransfer::firstParam( int index ) const
{
for (ParamList::ConstIterator it = d->data.begin(); it != d->data.end(); ++it)
for (ParamList::ConstIterator it = d->data.constBegin(); it != d->data.constEnd(); ++it)
{
if( (*it).first == index )
return (*it).second;
@ -177,10 +188,10 @@ void YMSGTransfer::setParam( int index, int data )
d->data.append( Param( index, QString::number( data ).local8Bit() ) );
}
int YMSGTransfer::length()
int YMSGTransfer::length() const
{
int len = 0;
for (ParamList::ConstIterator it = d->data.begin(); it != d->data.end(); ++it)
for (ParamList::ConstIterator it = d->data.constBegin(); it != d->data.constEnd(); ++it)
{
len += QString::number( (*it).first ).length();
len += 2;
@ -191,7 +202,7 @@ int YMSGTransfer::length()
}
QByteArray YMSGTransfer::serialize()
QByteArray YMSGTransfer::serialize() const
{
/*
<------- 4B -------><------- 4B -------><---2B--->
@ -213,9 +224,9 @@ QByteArray YMSGTransfer::serialize()
stream << (Q_INT8)'Y' << (Q_INT8)'M' << (Q_INT8)'S' << (Q_INT8)'G';
if( d->service == Yahoo::ServicePictureUpload )
stream << (Q_INT16)0x0e00;
stream << (Q_INT16)0x0f00;
else
stream << (Q_INT16)0x000e;
stream << (Q_INT16)0x000f;
stream << (Q_INT16)0x0000;
if( d->service == Yahoo::ServicePictureUpload ||
d->service == Yahoo::ServiceFileTransfer )
@ -225,15 +236,15 @@ QByteArray YMSGTransfer::serialize()
stream << (Q_INT16)d->service;
stream << (Q_INT32)d->status;
stream << (Q_INT32)d->id;
for (ParamList::ConstIterator it = d->data.begin(); it != d->data.end(); ++it)
for (ParamList::ConstIterator it = d->data.constBegin(); it != d->data.constEnd(); ++it)
{
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " Serializing key " << (*it).first << " value " << (*it).second << endl;
kdDebug(YAHOO_RAW_DEBUG) << " Serializing key " << (*it).first << " value " << (*it).second << endl;
stream.writeRawBytes ( QString::number( (*it).first ).local8Bit(), QString::number( (*it).first ).length() );
stream << (Q_INT8)0xc0 << (Q_INT8)0x80;
stream.writeRawBytes( (*it).second, (*it).second.length() );
stream << (Q_INT8)0xc0 << (Q_INT8)0x80;
}
kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " pos=" << pos << " (packet size)" << buffer << endl;
kdDebug(YAHOO_RAW_DEBUG) << " pos=" << pos << " (packet size)" << buffer << endl;
return buffer;
}

@ -4,7 +4,7 @@
Copyright (c) 2004 Duncan Mac-Vicar P. <duncan@kde.org>
Copyright (c) 2005 André Duffeck <andre.duffeck@kdemail.net>
Copyright (c) 2005 André Duffeck <duffeck@kde.org>
Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
@ -24,12 +24,11 @@
#include "transfer.h"
#include "yahootypes.h"
#include <qcstring.h>
#include <qpair.h>
#include <qvaluelist.h>
class YMSGTransferPrivate;
class QString;
typedef QPair< int, QCString > Param;
typedef QValueList< Param > ParamList;
@ -49,26 +48,29 @@ public:
TransferType type();
//! Get the validity of the transfer object
bool isValid();
Yahoo::Service service();
bool isValid() const;
Yahoo::Service service() const;
void setService(Yahoo::Service service);
Yahoo::Status status();
Yahoo::Status status() const;
void setStatus(Yahoo::Status status);
unsigned int id();
unsigned int id() const;
void setId(unsigned int id);
int packetLength() const;
void setPacketLength(int len);
ParamList paramList();
QCString firstParam( int index );
QCString nthParam( int index, int occurence );
QCString nthParamSeparated( int index, int occurence, int separator );
int paramCount( int index );
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;
void setParam(int index, const QCString &data);
void setParam(int index, int data);
QByteArray serialize();
QByteArray serialize() const;
int length();
int length() const;
private:
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 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>
*************************************************************************
@ -17,16 +18,20 @@
*/
#ifndef YAHOOIDENTITY_H
#define YAHOOIDENTITY_H
#ifndef YAHOOACCOUNT_H
#define YAHOOACCOUNT_H
// Qt
#include <qobject.h>
#include <qmap.h>
#include <qpixmap.h>
#include <qpair.h>
// KDE
#include <kurl.h>
// Kopete
#include "kopetepasswordedaccount.h"
#include "kopeteawaydialog.h"
// Local
#include "yahooprotocol.h"
@ -40,27 +45,21 @@ class YahooAccount;
class YahooProtocol;
class YahooWebcam;
class YahooConferenceChatSession;
class KTempFile;
struct KURL;
class YahooChatChatSession;
class KTemporaryFile;
namespace Kopete{
class Transfer;
class ChatSession;
class StatusMessage;
class FileTransferInfo;
}
class Client;
class YABEntry;
struct YABEntry;
class KJob;
namespace KIO{
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
{
@ -70,7 +69,7 @@ public:
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();
/*
@ -117,11 +116,12 @@ public:
/**
* Set Buddy Icon
*/
void setBuddyIcon( KURL url );
void setBuddyIcon( const KURL &url );
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 sendFile( YahooContact *to, const KURL &url );
public slots:
@ -137,7 +137,6 @@ public slots:
/** Reimplemented from Kopete::Account */
void setOnlineStatus( const Kopete::OnlineStatus&, const QString &reason = QString::null);
signals:
/**
* 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 createChatContact( const QString &nick );
/**
* Gets the just-received message color
*/
@ -171,19 +172,25 @@ protected slots:
void slotOpenInbox(); // Open Yahoo Mailbox in browser
void slotOpenYAB(); // Open Yahoo Addressbook in browser
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 slotDisconnected();
void slotLoginFailed();
void slotGotBuddy(const QString &userid, const QString &alias, const QString &group);
void slotBuddyAddResult(const QString &userid, const QString &group, bool success);
void slotBuddyRemoveResult(const QString &userid, const QString &group, bool success);
void slotBuddyChangeGroupResult(const QString &userid, const QString &group, bool success);
void slotAuthorizationAccepted( const QString &who );
void slotAuthorizationRejected( const QString &who, const QString &msg );
void slotgotAuthorizationRequest( const QString &, const QString &, const QString & );
void slotContactAddedNotifyDialogClosed( const QString & );
void slotContactAddedNotifyDialogClosed( const QString &user );
//void slotAddedInfoEventActionActivated( uint actionId );
void slotGotIgnore(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 slotGotIm(const QString &who, const QString &msg, long tm, int stat);
void slotGotBuzz(const QString &who, long tm);
@ -195,7 +202,7 @@ protected slots:
void slotConfLeave( YahooConferenceChatSession *s );
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 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 slotRejected(const QString &, const QString &);
void slotTypingNotify(const QString &, int );
@ -215,16 +222,21 @@ protected slots:
void slotWebcamViewerJoined( const QString & );
void slotWebcamViewerLeft( const QString & );
void slotWebcamViewerRequest( const QString & );
void slotPictureStatusNotiy( const QString&, int);
void slotGotBuddyIcon(const QString&, KTempFile*, int);
void slotPictureStatusNotify( const QString&, int);
void slotGotBuddyIcon(const QString&, const QByteArray&, int);
void slotGotBuddyIconInfo(const QString&, KURL, int);
void slotGotBuddyIconChecksum(const QString&, int);
void slotGotBuddyIconRequest(const QString &);
void slotBuddyIconChanged(const QString&);
void slotBuddyIconChanged(const QString&, int);
void slotGotYABEntry( YABEntry *entry );
void slotGotYABRevision( long revision, bool merged );
void slotSaveYABEntry( YABEntry &entry );
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 slotReceiveFileRefused( const Kopete::FileTransferInfo& info );
@ -234,11 +246,6 @@ protected slots:
void slotFileTransferResult( KIO::Job * );
void slotError( int level );
private slots:
/**
* When a global identity key get changed.
*/
void slotGlobalIdentityChanged( const QString &key, const QVariant &value );
private:
/**
@ -246,6 +253,8 @@ private:
*/
void initConnectionSignals( enum SignalConnectionType sct );
void setupActions( bool connected );
QString prepareIncomingMessage( const QString &msg );
/**
@ -258,6 +267,7 @@ private:
* Conferences list, maped by room name (id)
*/
QMap<QString, YahooConferenceChatSession *> m_conferences;
YahooChatChatSession * m_chatChatSession;
QStringList m_pendingConfInvites;
QStringList m_pendingWebcamInvites;
QStringList m_pendingFileTransfers;
@ -281,15 +291,12 @@ private:
YahooWebcam *m_webcam;
YahooAwayDialog *theAwayDialog; // Our away message dialog
KAction *m_openInboxAction; // Menu item openInbox
KAction *m_openYABAction; // Menu item openYahooAddressbook
KAction *m_editOwnYABEntry; // Menu item editOwnYABEntry
KAction *m_joinChatAction; // Menu item joinChatAction
Client *m_session; // The Connection object
};
#endif
#endif // YAHOOACCOUNT_H

@ -526,7 +526,7 @@ void YahooContact::buzzContact()
void YahooContact::sendBuddyIconChecksum( int checksum )
{
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
m_account->yahooSession()->sendPictureChecksum( checksum, m_userId );
m_account->yahooSession()->sendPictureChecksum( m_userId, checksum );
}
@ -539,25 +539,32 @@ void YahooContact::sendBuddyIconInfo( const QString &url, int checksum )
void YahooContact::sendBuddyIconUpdate( int type )
{
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;
if( !f )
return;
// stolen from msncontact.cpp ;)
QString newlocation=locateLocal( "appdata", "yahoopictures/"+ contactId().lower().replace(QRegExp("[./~]"),"-") +".png" ) ;
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << data.size() << endl;
QString newlocation = locateLocal( "appdata", "yahoopictures/"+ contactId().lower().replace(QRegExp("[./~]"),"-") +".png" ) ;
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 ))
{
kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << "Saving of " << newlocation << " failed!" << endl;
return;
}
f.writeBlock(data.data(), data.size());
f.close();
f->setAutoDelete(false);
delete f;
setProperty( Kopete::Global::Properties::self()->photo(), QString() );
setProperty( Kopete::Global::Properties::self()->photo() , newlocation );
//let the time to KIO to copy the file
connect(j, SIGNAL(result(KIO::Job *)) , this, SLOT(slotEmitDisplayPictureChanged() ));
emit displayPictureChanged();
}

@ -83,7 +83,7 @@ public slots:
void requestWebcam();
void inviteWebcam();
void buzzContact();
void setDisplayPicture(KTempFile *f, int checksum);
void setDisplayPicture(const QByteArray &data, int checksum);
void sendBuddyIconInfo( const QString &url, int checksum );
void sendBuddyIconUpdate( int type );
void sendBuddyIconChecksum( int checksum );

Loading…
Cancel
Save