summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/yahoo/libkyahoo/yahooclientstream.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-05 08:45:53 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-05 08:45:53 +0000
commit5527e01e0675fbb06b632ccdae423756fbff622b (patch)
treec2dd1a478a7789d3b01e77fdf31f9011a96a81c5 /kopete/protocols/yahoo/libkyahoo/yahooclientstream.cpp
parent1fc8db48741fae272e2d29078b266a3d0f2e2dd1 (diff)
downloadtdenetwork-5527e01e0675fbb06b632ccdae423756fbff622b.tar.gz
tdenetwork-5527e01e0675fbb06b632ccdae423756fbff622b.zip
Many fixes to the Yahoo protocol, courtesy of Serghei Amelian
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1146108 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kopete/protocols/yahoo/libkyahoo/yahooclientstream.cpp')
-rw-r--r--kopete/protocols/yahoo/libkyahoo/yahooclientstream.cpp76
1 files changed, 39 insertions, 37 deletions
diff --git a/kopete/protocols/yahoo/libkyahoo/yahooclientstream.cpp b/kopete/protocols/yahoo/libkyahoo/yahooclientstream.cpp
index 548140b1..3279bbd0 100644
--- a/kopete/protocols/yahoo/libkyahoo/yahooclientstream.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/yahooclientstream.cpp
@@ -1,13 +1,13 @@
/*
oscarclientstream.cpp - Kopete Oscar Protocol
-
+
Copyright (c) 2004 Matt Rogers <matt.rogers@kdemail.net>
-
+
Based on code Copyright (c) 2004 SuSE Linux AG <http://www.suse.com>
- Based on Iris, Copyright (C) 2003 Justin Karneges
-
+ Based on Iris, Copyright (C) 2003 Justin Karneges <justin@affinix.com>
+
Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
-
+
*************************************************************************
* *
* This library is free software; you can redistribute it and/or *
@@ -21,7 +21,7 @@
#include <qapplication.h> // for qdebug
-#include <qguardedptr.h>
+#include <qguardedptr.h>
#include <qobject.h>
#include <qptrqueue.h>
#include <qtimer.h>
@@ -57,7 +57,7 @@ public:
{
conn = 0;
bs = 0;
-
+
username = QString::null;
password = QString::null;
server = QString::null;
@@ -72,7 +72,7 @@ public:
notify = 0;
newTransfers = false;
}
-
+
QString username;
QString password;
QString server;
@@ -92,7 +92,7 @@ public:
int state;
int notify;
bool newTransfers;
-
+
int errCond;
QString errText;
@@ -103,12 +103,10 @@ public:
};
ClientStream::ClientStream(Connector *conn, QObject *parent)
-:Stream(parent)
+:Stream(parent), d(new Private())
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
-
- d = new Private;
+ kdDebug(YAHOO_RAW_DEBUG) ;
+
d->mode = Client;
d->conn = conn;
connect( d->conn, SIGNAL(connected()), SLOT(cr_connected()) );
@@ -128,15 +126,16 @@ ClientStream::~ClientStream()
void ClientStream::reset(bool all)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
d->reset();
d->noopTimer.stop();
// client
if(d->mode == Client) {
-
+
// reset connector
if(d->bs) {
+ disconnect(d->bs, 0, this, 0);
d->bs->close();
d->bs = 0;
}
@@ -151,7 +150,7 @@ void ClientStream::reset(bool all)
void ClientStream::connectToServer(const QString& server, bool auth)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
reset(true);
d->state = Connecting;
d->doAuth = auth;
@@ -162,7 +161,7 @@ void ClientStream::connectToServer(const QString& server, bool auth)
void ClientStream::continueAfterWarning()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
/* unneeded?
if(d->state == WaitVersion) {
d->state = Connecting;
@@ -235,7 +234,7 @@ void ClientStream::close()
bool ClientStream::transfersAvailable() const
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
return ( !d->in.isEmpty() );
}
@@ -243,17 +242,17 @@ Transfer* ClientStream::read()
{
if(d->in.isEmpty())
return 0; //first from queue...
- else
+ else
return d->in.dequeue();
}
void ClientStream::write( Transfer *request )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
// pass to CoreProtocol for transformation into wire format
d->client.outgoingTransfer( request );
}
-
+
void cs_dump( const QByteArray &bytes )
{
#if 0
@@ -278,7 +277,7 @@ void cs_dump( const QByteArray &bytes )
if ( count + i < bytes.count() )
{
int j = bytes [ count + i ];
- if ( j >= 0x20 && j <= 0x7e )
+ if ( j >= 0x20 && j <= 0x7e )
printf( "%2c ", j );
else
printf( "%2c ", '.' );
@@ -298,32 +297,35 @@ void cs_dump( const QByteArray &bytes )
void ClientStream::cp_outgoingData( const QByteArray& outgoingBytes )
{
+ if ( !d->bs )
+ return;
+
// take formatted bytes from CoreProtocol and put them on the wire
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "[data size: " << outgoingBytes.size() << "]" << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "[data size: " << outgoingBytes.size() << "]" << endl;
//cs_dump( outgoingBytes );
d->bs->write( outgoingBytes );
}
void ClientStream::cp_incomingData()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+// kdDebug(YAHOO_RAW_DEBUG) ;
Transfer * incoming = d->client.incomingTransfer();
if ( incoming )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " - got a new transfer" << endl;
+// kdDebug(YAHOO_RAW_DEBUG) << " - got a new transfer";
d->in.enqueue( incoming );
d->newTransfers = true;
emit doReadyRead();
}
else
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " - client signalled incomingData but none was available, state is: "<< d->client.state() << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " - client signalled incomingData but none was available, state is: "<< d->client.state() << endl;
}
/* Connector connected */
void ClientStream::cr_connected()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
-
+ kdDebug(YAHOO_RAW_DEBUG) ;
+
d->bs = d->conn->stream();
connect(d->bs, SIGNAL(connectionClosed()), SLOT(bs_connectionClosed()));
connect(d->bs, SIGNAL(delayedCloseFinished()), SLOT(bs_delayedCloseFinished()));
@@ -341,12 +343,12 @@ void ClientStream::cr_connected()
void ClientStream::cr_error()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
reset();
emit error(ErrConnection);
}
-void ClientStream::bs_connectionClosed()
+void ClientStream::bs_connectionClosed()
{
reset();
emit connectionClosed();
@@ -359,20 +361,20 @@ void ClientStream::bs_delayedCloseFinished()
void ClientStream::bs_error(int)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) ;
// TODO
}
void ClientStream::bs_readyRead()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+// kdDebug(YAHOO_RAW_DEBUG) ;
QByteArray a;
//qDebug( "size of storage for incoming data is %i bytes.", a.size() );
a = d->bs->read();
//QCString cs(a.data(), a.size()+1);
//qDebug("ClientStream: recv: %d [%s]\n", a.size(), cs.data());
- //kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " recv: " << a.size() <<" bytes" <<endl;
+ //kdDebug(YAHOO_RAW_DEBUG) << " recv: " << a.size() <<" bytes";
//cs_dump( a );
d->client.addIncomingData(a);
@@ -380,7 +382,7 @@ void ClientStream::bs_readyRead()
void ClientStream::bs_bytesWritten(int bytes)
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << " written: " << bytes <<" bytes" <<endl;
+ kdDebug(YAHOO_RAW_DEBUG) << " written: " << bytes <<" bytes" << endl;
}
void ClientStream::srvProcessNext()
@@ -389,13 +391,13 @@ void ClientStream::srvProcessNext()
void ClientStream::doReadyRead()
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+// kdDebug(YAHOO_RAW_DEBUG) ;
emit readyRead();
}
void ClientStream::processNext()
{
- if( !d->in.isEmpty() )
+ if( !d->in.isEmpty() )
{
QTimer::singleShot(0, this, SLOT(doReadyRead()));
}