diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | bcb704366cb5e333a626c18c308c7e0448a8e69f (patch) | |
tree | f0d6ab7d78ecdd9207cf46536376b44b91a1ca71 /kopete/protocols/oscar/liboscar/typingnotifytask.cpp | |
download | tdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.tar.gz tdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kopete/protocols/oscar/liboscar/typingnotifytask.cpp')
-rw-r--r-- | kopete/protocols/oscar/liboscar/typingnotifytask.cpp | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/kopete/protocols/oscar/liboscar/typingnotifytask.cpp b/kopete/protocols/oscar/liboscar/typingnotifytask.cpp new file mode 100644 index 00000000..76503116 --- /dev/null +++ b/kopete/protocols/oscar/liboscar/typingnotifytask.cpp @@ -0,0 +1,124 @@ +/* + typingnotifytask.h - Send/Recieve typing notifications + + Copyright (c) 2004 by Matt Rogers <mattr@kde.org> + Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org> + + ************************************************************************* + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ************************************************************************* +*/ + +#include "typingnotifytask.h" + +#include <qstring.h> +#include <kdebug.h> +#include "transfer.h" +#include "buffer.h" +#include "connection.h" + + + + +TypingNotifyTask::TypingNotifyTask( Task* parent ) +: Task( parent ) +{ + m_notificationType = 0x0000; +} + +TypingNotifyTask::~TypingNotifyTask() +{ +} + +bool TypingNotifyTask::forMe( const Transfer* transfer ) const +{ + const SnacTransfer* st = dynamic_cast<const SnacTransfer*>( transfer ); + if ( !st ) + return false; + + if ( st->snacService() == 0x0004 && st->snacSubtype() == 0x0014 ) + return true; + else + return false; +} + +bool TypingNotifyTask::take( Transfer* transfer ) +{ + if ( forMe( transfer ) ) + { + setTransfer( transfer ); + handleNotification(); + setTransfer( 0 ); + return true; + } + + return false; +} + +void TypingNotifyTask::onGo() +{ + FLAP f = { 0x02, 0, 0 }; + SNAC s = { 0x0004, 0x0014, 0x0000, client()->snacSequence() }; + Buffer* b = new Buffer(); + + //notification id cookie. it's a quad-word + b->addDWord( 0x00000000 ); + b->addDWord( 0x00000000 ); + + b->addWord( 0x0001 ); //mtn messages are always sent as type 1 messages + + b->addBUIN( m_contact.latin1() ); + + b->addWord( m_notificationType ); + + Transfer* t = createTransfer( f, s, b ); + send( t ); + + setSuccess( 0, QString::null ); +} + +void TypingNotifyTask::handleNotification() +{ + /* NB ICQ5 (windows) seems to only send 0x0002 and 0x0001, so I'm interpreting 0x001 as typing finished here - Will */ + Buffer* b = transfer()->buffer(); + + //I don't care about the QWORD or the channel + b->skipBytes( 10 ); + + QString contact( b->getBUIN() ); + + Q_UINT32 word = b->getWord(); + switch ( word ) + { + case 0x0000: + kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << contact << " has finished typing" << endl; + emit typingFinished( contact ); + break; + case 0x0001: + kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << contact << " has typed a word" << endl; + emit typingFinished( contact ); + break; + case 0x0002: + kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << contact << " has started typing" << endl; + emit typingStarted( contact ); + break; + default: + kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << contact << " typed an unknown typing notification - " << word << endl; + } +} + +void TypingNotifyTask::setParams( const QString& contact, int notifyType ) +{ + m_contact = contact; + m_notificationType = notifyType; +} + +#include "typingnotifytask.moc" + +// kate: indent-mode csands; space-indent off; replace-tabs off; + |