From bcb704366cb5e333a626c18c308c7e0448a8e69f Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: 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 --- kopete/protocols/testbed/Makefile.am | 15 ++ kopete/protocols/testbed/icons/Makefile.am | 3 + .../testbed/icons/cr128-app-testbed_protocol.png | Bin 0 -> 12571 bytes .../testbed/icons/cr16-app-testbed_protocol.png | Bin 0 -> 1003 bytes .../testbed/icons/cr32-app-testbed_protocol.png | Bin 0 -> 2613 bytes .../testbed/icons/cr48-app-testbed_protocol.png | Bin 0 -> 4576 bytes .../testbed/icons/cr64-app-testbed_protocol.png | Bin 0 -> 6607 bytes kopete/protocols/testbed/kopete_testbed.desktop | 97 ++++++++++++ kopete/protocols/testbed/testbedaccount.cpp | 176 +++++++++++++++++++++ kopete/protocols/testbed/testbedaccount.h | 105 ++++++++++++ .../protocols/testbed/testbedaccountpreferences.ui | 160 +++++++++++++++++++ kopete/protocols/testbed/testbedaddcontactpage.cpp | 68 ++++++++ kopete/protocols/testbed/testbedaddcontactpage.h | 50 ++++++ kopete/protocols/testbed/testbedaddui.ui | 107 +++++++++++++ kopete/protocols/testbed/testbedcontact.cpp | 141 +++++++++++++++++ kopete/protocols/testbed/testbedcontact.h | 95 +++++++++++ .../protocols/testbed/testbededitaccountwidget.cpp | 62 ++++++++ .../protocols/testbed/testbededitaccountwidget.h | 52 ++++++ kopete/protocols/testbed/testbedfakeserver.cpp | 64 ++++++++ kopete/protocols/testbed/testbedfakeserver.h | 66 ++++++++ .../protocols/testbed/testbedincomingmessage.cpp | 36 +++++ kopete/protocols/testbed/testbedincomingmessage.h | 55 +++++++ kopete/protocols/testbed/testbedprotocol.cpp | 101 ++++++++++++ kopete/protocols/testbed/testbedprotocol.h | 74 +++++++++ kopete/protocols/testbed/ui/Makefile.am | 7 + .../protocols/testbed/ui/testbedwebcamdialog.cpp | 80 ++++++++++ kopete/protocols/testbed/ui/testbedwebcamdialog.h | 60 +++++++ 27 files changed, 1674 insertions(+) create mode 100644 kopete/protocols/testbed/Makefile.am create mode 100644 kopete/protocols/testbed/icons/Makefile.am create mode 100644 kopete/protocols/testbed/icons/cr128-app-testbed_protocol.png create mode 100644 kopete/protocols/testbed/icons/cr16-app-testbed_protocol.png create mode 100644 kopete/protocols/testbed/icons/cr32-app-testbed_protocol.png create mode 100644 kopete/protocols/testbed/icons/cr48-app-testbed_protocol.png create mode 100644 kopete/protocols/testbed/icons/cr64-app-testbed_protocol.png create mode 100644 kopete/protocols/testbed/kopete_testbed.desktop create mode 100644 kopete/protocols/testbed/testbedaccount.cpp create mode 100644 kopete/protocols/testbed/testbedaccount.h create mode 100644 kopete/protocols/testbed/testbedaccountpreferences.ui create mode 100644 kopete/protocols/testbed/testbedaddcontactpage.cpp create mode 100644 kopete/protocols/testbed/testbedaddcontactpage.h create mode 100644 kopete/protocols/testbed/testbedaddui.ui create mode 100644 kopete/protocols/testbed/testbedcontact.cpp create mode 100644 kopete/protocols/testbed/testbedcontact.h create mode 100644 kopete/protocols/testbed/testbededitaccountwidget.cpp create mode 100644 kopete/protocols/testbed/testbededitaccountwidget.h create mode 100644 kopete/protocols/testbed/testbedfakeserver.cpp create mode 100644 kopete/protocols/testbed/testbedfakeserver.h create mode 100644 kopete/protocols/testbed/testbedincomingmessage.cpp create mode 100644 kopete/protocols/testbed/testbedincomingmessage.h create mode 100644 kopete/protocols/testbed/testbedprotocol.cpp create mode 100644 kopete/protocols/testbed/testbedprotocol.h create mode 100644 kopete/protocols/testbed/ui/Makefile.am create mode 100644 kopete/protocols/testbed/ui/testbedwebcamdialog.cpp create mode 100644 kopete/protocols/testbed/ui/testbedwebcamdialog.h (limited to 'kopete/protocols/testbed') diff --git a/kopete/protocols/testbed/Makefile.am b/kopete/protocols/testbed/Makefile.am new file mode 100644 index 00000000..b414547a --- /dev/null +++ b/kopete/protocols/testbed/Makefile.am @@ -0,0 +1,15 @@ +METASOURCES = AUTO + +SUBDIRS = ui . icons + +AM_CPPFLAGS = $(KOPETE_INCLUDES) -I$(srcdir)/ui -Iui $(all_includes) + +noinst_HEADERS = testbedprotocol.h testbedcontact.h testbedaccount.h testbedaddcontactpage.h testbededitaccountwidget.h testbedfakeserver.h testbedincomingmessage.h +kde_module_LTLIBRARIES = kopete_testbed.la +kopete_testbed_la_SOURCES = testbedprotocol.cpp testbedcontact.cpp testbedaccount.cpp testbedaddcontactpage.cpp testbedaddui.ui testbededitaccountwidget.cpp testbedaccountpreferences.ui testbedfakeserver.cpp testbedincomingmessage.cpp +kopete_testbed_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) +kopete_testbed_la_LIBADD = ../../libkopete/avdevice/libkopete_videodevice.la \ + ui/libkopetetestbedui.la ../../libkopete/libkopete.la $(LIB_KIO) + +service_DATA = kopete_testbed.desktop +servicedir= $(kde_servicesdir) diff --git a/kopete/protocols/testbed/icons/Makefile.am b/kopete/protocols/testbed/icons/Makefile.am new file mode 100644 index 00000000..224eb420 --- /dev/null +++ b/kopete/protocols/testbed/icons/Makefile.am @@ -0,0 +1,3 @@ +kopeteicondir = $(kde_datadir)/kopete/icons +kopeteicon_ICON = AUTO + diff --git a/kopete/protocols/testbed/icons/cr128-app-testbed_protocol.png b/kopete/protocols/testbed/icons/cr128-app-testbed_protocol.png new file mode 100644 index 00000000..edfa2a2a Binary files /dev/null and b/kopete/protocols/testbed/icons/cr128-app-testbed_protocol.png differ diff --git a/kopete/protocols/testbed/icons/cr16-app-testbed_protocol.png b/kopete/protocols/testbed/icons/cr16-app-testbed_protocol.png new file mode 100644 index 00000000..b97f23f4 Binary files /dev/null and b/kopete/protocols/testbed/icons/cr16-app-testbed_protocol.png differ diff --git a/kopete/protocols/testbed/icons/cr32-app-testbed_protocol.png b/kopete/protocols/testbed/icons/cr32-app-testbed_protocol.png new file mode 100644 index 00000000..82180b6a Binary files /dev/null and b/kopete/protocols/testbed/icons/cr32-app-testbed_protocol.png differ diff --git a/kopete/protocols/testbed/icons/cr48-app-testbed_protocol.png b/kopete/protocols/testbed/icons/cr48-app-testbed_protocol.png new file mode 100644 index 00000000..f88a938f Binary files /dev/null and b/kopete/protocols/testbed/icons/cr48-app-testbed_protocol.png differ diff --git a/kopete/protocols/testbed/icons/cr64-app-testbed_protocol.png b/kopete/protocols/testbed/icons/cr64-app-testbed_protocol.png new file mode 100644 index 00000000..daa9f28c Binary files /dev/null and b/kopete/protocols/testbed/icons/cr64-app-testbed_protocol.png differ diff --git a/kopete/protocols/testbed/kopete_testbed.desktop b/kopete/protocols/testbed/kopete_testbed.desktop new file mode 100644 index 00000000..2ab38536 --- /dev/null +++ b/kopete/protocols/testbed/kopete_testbed.desktop @@ -0,0 +1,97 @@ +[Desktop Entry] +Type=Service +X-Kopete-Version=1000900 +Icon=testbed_protocol +ServiceTypes=Kopete/Protocol +X-KDE-Library=kopete_testbed +X-Kopete-Messaging-Protocol=messaging/testbed +X-KDE-PluginInfo-Author=Will Stephenson +X-KDE-PluginInfo-Email=will@stevello.free-online.co.uk +X-KDE-PluginInfo-Name=kopete_testbed +X-KDE-PluginInfo-Version=0.8.0 +X-KDE-PluginInfo-Website=http://kopete.kde.org +X-KDE-PluginInfo-Category=Protocols +X-KDE-PluginInfo-Depends= +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=false +Name=Testbed +Name[ar]=مكان اختبار +Name[bn]=পরীক্ষাস্থল +Name[cy]=Mainc Arbrofi +Name[eo]=Testejo +Name[et]=Testija +Name[fi]=Testipenkki +Name[gl]=testbed +Name[hi]=टेस्टबेड +Name[hr]=Probno okruženje +Name[hu]=Tesztelési +Name[is]=Prufuhorn +Name[lt]=Tikrinimas +Name[nb]=Testbenk +Name[ne]=टेस्टबेड +Name[nl]=Testomgeving +Name[nn]=Testbenk +Name[pl]=Testowy +Name[pt]=Testes +Name[sk]=Test +Name[sr]=Пробни сто +Name[sr@Latn]=Probni sto +Name[sv]=Testomgivning +Name[tr]=Deneme ortamı +Name[uk]=Тест +Name[zh_CN]=测试床 +Comment=Kopete test protocol +Comment[ar]=بروتوكول اختبار Kopete +Comment[be]=Тэставы пратакол Kopete +Comment[bg]=Пробен протокол на Kopete +Comment[bn]=কপেট পরীক্ষা প্রোটোকল +Comment[bs]=Kopete testni protokol +Comment[ca]=Protocol per a proves en Kopete +Comment[cy]=Protocol arbrofi Kopete +Comment[da]=Kopete test-protokol +Comment[de]=Kopete Testprotokoll +Comment[el]=Πρωτόκολλο ελέγχου του Kopete +Comment[es]=Protocolo de prueba de Kopete +Comment[et]=Kopete testprotokoll +Comment[eu]=Kopete proba protokoloa +Comment[fa]=Kopete قرارداد را آزمایش می‌کند +Comment[fi]=Kopeten testiyhteyskäytäntö +Comment[fr]=Protocole de test de Kopete +Comment[ga]=Prótacal tástála Kopete +Comment[gl]=Protocolo de Kopete para probas +Comment[he]=פרוטוקול הניסוי של Kopete +Comment[hi]=के-ऑप्टी टेस्ट प्रोटोकॉल +Comment[hr]=Kopete protokol za testiranje +Comment[hu]=Kopete tesztprotokoll +Comment[is]=Kopete prufuíhlutur +Comment[it]=Protocollo di test di Kopete +Comment[ja]=Kopete テストプロトコル +Comment[ka]=Kopete-ს ტესტირების ოქმი +Comment[kk]=Kopete сынау протоколы +Comment[km]=ពិធីការ​សាកល្បង Kopete +Comment[lt]=Kopete tikrinimo protokolas +Comment[mk]=Протокол за тестирање на Kopete +Comment[nb]=Kopete protokoll for tester +Comment[nds]=Kopete-Pröövprotokoll +Comment[ne]=कोपेट परीक्षण प्रोटोकल +Comment[nl]=Kopete testprotocol +Comment[nn]=Kopete-protokoll for testing +Comment[pl]=Protokół testowy Kopete +Comment[pt]=Protocolo de teste do Kopete +Comment[pt_BR]=Protocolo de Teste do Kopete +Comment[ro]=Protocol de test Kopete +Comment[ru]=Тестовый протокол Kopete +Comment[se]=Kopete geahččalanprotokolla +Comment[sk]=Testovací protokol Kopete +Comment[sl]=Preskusni protokol za Kopete +Comment[sr]=Kopete-ов протокол за тестирање +Comment[sr@Latn]=Kopete-ov protokol za testiranje +Comment[sv]=Testprotokoll för Kopete +Comment[ta]=Kopete விதிமுறை சோதனை +Comment[tg]=Қарордоди санҷишии Kopete +Comment[tr]=Kopete deneme protokolü +Comment[uk]=Тестовий протокол Kopete +Comment[wa]=Protocole di saye po Kopete +Comment[zh_CN]=Kopete 测试协议 +Comment[zh_HK]=Kopete 測試通訊協定 +Comment[zh_TW]=Kopete 測試協定 diff --git a/kopete/protocols/testbed/testbedaccount.cpp b/kopete/protocols/testbed/testbedaccount.cpp new file mode 100644 index 00000000..fbb3462a --- /dev/null +++ b/kopete/protocols/testbed/testbedaccount.cpp @@ -0,0 +1,176 @@ +/* + testbedaccount.cpp - Kopete Testbed Protocol + + Copyright (c) 2003 by Will Stephenson + Kopete (c) 2002-2003 by the Kopete developers + + ************************************************************************* + * * + * This library 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 "testbedaccount.h" + +#include +#include +#include +#include + +#include "kopetemetacontact.h" +#include "kopetecontactlist.h" + +#include "testbedcontact.h" +#include "testbedfakeserver.h" +#include "testbedprotocol.h" + + +TestbedAccount::TestbedAccount( TestbedProtocol *parent, const QString& accountID, const char *name ) +: Kopete::Account ( parent, accountID , name ) +{ + // Init the myself contact + setMyself( new TestbedContact( this, accountId(), TestbedContact::Null, accountId(), Kopete::ContactList::self()->myself() ) ); + myself()->setOnlineStatus( TestbedProtocol::protocol()->testbedOffline ); + m_server = new TestbedFakeServer();; +} + +TestbedAccount::~TestbedAccount() +{ + delete m_server; +} + +KActionMenu* TestbedAccount::actionMenu() +{ + KActionMenu *mActionMenu = Kopete::Account::actionMenu(); + + mActionMenu->popupMenu()->insertSeparator(); + + KAction *action; + + action = new KAction (i18n ("Show my own video..."), "testbed_showvideo", 0, this, SLOT (slotShowVideo ()), this, "actionShowVideo"); + mActionMenu->insert(action); + action->setEnabled( isConnected() ); + + return mActionMenu; +} + +bool TestbedAccount::createContact(const QString& contactId, Kopete::MetaContact* parentContact) +{ + TestbedContact* newContact = new TestbedContact( this, contactId, TestbedContact::Echo, parentContact->displayName(), parentContact ); + return newContact != 0L; +} + +void TestbedAccount::setAway( bool away, const QString & /* reason */ ) +{ + if ( away ) + slotGoAway(); + else + slotGoOnline(); +} + +void TestbedAccount::setOnlineStatus(const Kopete::OnlineStatus& status, const QString &reason ) +{ + if ( status.status() == Kopete::OnlineStatus::Online && + myself()->onlineStatus().status() == Kopete::OnlineStatus::Offline ) + slotGoOnline(); + else if (status.status() == Kopete::OnlineStatus::Online && + myself()->onlineStatus().status() == Kopete::OnlineStatus::Away ) + setAway( false, reason ); + else if ( status.status() == Kopete::OnlineStatus::Offline ) + slotGoOffline(); + else if ( status.status() == Kopete::OnlineStatus::Away ) + slotGoAway( /* reason */ ); +} + +void TestbedAccount::connect( const Kopete::OnlineStatus& /* initialStatus */ ) +{ + kdDebug ( 14210 ) << k_funcinfo << endl; + myself()->setOnlineStatus( TestbedProtocol::protocol()->testbedOnline ); + QObject::connect ( m_server, SIGNAL ( messageReceived( const QString & ) ), + this, SLOT ( receivedMessage( const QString & ) ) ); +} + +void TestbedAccount::disconnect() +{ + kdDebug ( 14210 ) << k_funcinfo << endl; + myself()->setOnlineStatus( TestbedProtocol::protocol()->testbedOffline ); + QObject::disconnect ( m_server, 0, 0, 0 ); +} + +TestbedFakeServer * TestbedAccount::server() +{ + return m_server; +} + +void TestbedAccount::slotGoOnline () +{ + kdDebug ( 14210 ) << k_funcinfo << endl; + + if (!isConnected ()) + connect (); + else + myself()->setOnlineStatus( TestbedProtocol::protocol()->testbedOnline ); + updateContactStatus(); +} + +void TestbedAccount::slotGoAway () +{ + kdDebug ( 14210 ) << k_funcinfo << endl; + + if (!isConnected ()) + connect(); + + myself()->setOnlineStatus( TestbedProtocol::protocol()->testbedAway ); + updateContactStatus(); +} + + +void TestbedAccount::slotGoOffline () +{ + kdDebug ( 14210 ) << k_funcinfo << endl; + + if (isConnected ()) + disconnect (); + updateContactStatus(); +} + +void TestbedAccount::slotShowVideo () +{ + kdDebug ( 14210 ) << k_funcinfo << endl; + + if (isConnected ()) + TestbedWebcamDialog *testbedWebcamDialog = new TestbedWebcamDialog(0, 0, "Testbed video window"); + updateContactStatus(); +} + +void TestbedAccount::receivedMessage( const QString &message ) +{ + // Look up the contact the message is from + QString from; + TestbedContact* messageSender; + + from = message.section( ':', 0, 0 ); + Kopete::Contact* contact = contacts()[from]; + messageSender = dynamic_cast( contact ); + + kdDebug( 14210 ) << k_funcinfo << " got a message from " << from << ", " << messageSender << ", is: " << message << endl; + // Pass it on to the contact to process and display via a KMM + if ( messageSender ) + messageSender->receivedMessage( message ); + else + kdWarning(14210) << k_funcinfo << "unable to look up contact for delivery" << endl; +} + +void TestbedAccount::updateContactStatus() +{ + QDictIterator itr( contacts() ); + for ( ; itr.current(); ++itr ) + itr.current()->setOnlineStatus( myself()->onlineStatus() ); +} + + +#include "testbedaccount.moc" diff --git a/kopete/protocols/testbed/testbedaccount.h b/kopete/protocols/testbed/testbedaccount.h new file mode 100644 index 00000000..34429300 --- /dev/null +++ b/kopete/protocols/testbed/testbedaccount.h @@ -0,0 +1,105 @@ +/* + testbedaccount.h - Kopete Testbed Protocol + + Copyright (c) 2003 by Will Stephenson + Kopete (c) 2002-2003 by the Kopete developers + + ************************************************************************* + * * + * This library 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. * + * * + ************************************************************************* +*/ + +#ifndef TESTBEDACCOUNT_H +#define TESTBEDACCOUNT_H + +#include +#include "testbedwebcamdialog.h" + +class KActionMenu; +namespace Kopete { class Contact; } +namespace Kopete { class MetaContact; } + +class TestbedContact; +class TestbedProtocol; +class TestbedFakeServer; + +/** + * This represents an account connected to the testbed + * @author Will Stephenson +*/ +class TestbedAccount : public Kopete::Account +{ + Q_OBJECT +public: + TestbedAccount( TestbedProtocol *parent, const QString& accountID, const char *name = 0 ); + ~TestbedAccount(); + /** + * Construct the context menu used for the status bar icon + */ + virtual KActionMenu* actionMenu(); + + /** + * Creates a protocol specific Kopete::Contact subclass and adds it to the supplie + * Kopete::MetaContact + */ + virtual bool createContact(const QString& contactId, Kopete::MetaContact* parentContact); + /** + * Called when Kopete is set globally away + */ + virtual void setAway(bool away, const QString& reason); + /** + * Called when Kopete status is changed globally + */ + virtual void setOnlineStatus(const Kopete::OnlineStatus& status , const QString &reason = QString::null); + /** + * 'Connect' to the testbed server. Only sets myself() online. + */ + virtual void connect( const Kopete::OnlineStatus& initialStatus = Kopete::OnlineStatus::OnlineStatus() ); + /** + * Disconnect from the server. Only sets myself() offline. + */ + virtual void disconnect(); + /** + * Return a reference to the server stub + */ + TestbedFakeServer* server(); +public slots: + /** + * Called by the server when it has a message for us. + * This identifies the sending Kopete::Contact and passes it a Kopete::Message + */ + void receivedMessage( const QString &message ); + +protected: + /** + * This simulates contacts going on and offline in sync with the account's status changes + */ + void updateContactStatus(); + TestbedFakeServer* m_server; + +protected slots: + /** + * Change the account's status. Called by KActions and internally. + */ + void slotGoOnline(); + /** + * Change the account's status. Called by KActions and internally. + */ + void slotGoAway(); + /** + * Change the account's status. Called by KActions and internally. + */ + void slotGoOffline(); + /** + * Show webcam. Called by KActions and internally. + */ + void slotShowVideo(); + +}; + +#endif diff --git a/kopete/protocols/testbed/testbedaccountpreferences.ui b/kopete/protocols/testbed/testbedaccountpreferences.ui new file mode 100644 index 00000000..e1c75ca6 --- /dev/null +++ b/kopete/protocols/testbed/testbedaccountpreferences.ui @@ -0,0 +1,160 @@ + +TestbedAccountPreferences + + + TestbedAccountPreferences + + + + 0 + 0 + 387 + 372 + + + + Account Preferences - Testbed + + + + unnamed + + + 0 + + + 0 + + + + tabWidget11 + + + + tab + + + B&asic Setup + + + + unnamed + + + + groupBox55_2 + + + Account Information + + + + unnamed + + + + layout1_2 + + + + unnamed + + + + accountLabel + + + &Account name: + + + m_acctName + + + The account name of your account. + + + The account name of your account. + + + + + m_acctName + + + The account name of your account. + + + The account name of your account. + + + + + + + + + groupBox22 + + + Information + + + + unnamed + + + + textLabel12 + + + + 3 + 1 + 0 + 0 + + + + To use the testbed protocol, just make up an account name. This protocol has no real networking capability. + + + WordBreak|AlignTop + + + + + + + spacer27 + + + Vertical + + + Expanding + + + + 20 + 131 + + + + + + + + + labelStatusMessage + + + + + + AlignCenter + + + + + + diff --git a/kopete/protocols/testbed/testbedaddcontactpage.cpp b/kopete/protocols/testbed/testbedaddcontactpage.cpp new file mode 100644 index 00000000..5327b5b4 --- /dev/null +++ b/kopete/protocols/testbed/testbedaddcontactpage.cpp @@ -0,0 +1,68 @@ +/* + testbedaddcontactpage.cpp - Kopete Testbed Protocol + + Copyright (c) 2003 by Will Stephenson + Kopete (c) 2002-2003 by the Kopete developers + + ************************************************************************* + * * + * This library 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 "testbedaddcontactpage.h" + +#include +#include +#include +#include + +#include "kopeteaccount.h" +#include "kopetemetacontact.h" + +#include "testbedaddui.h" + +TestbedAddContactPage::TestbedAddContactPage( QWidget* parent, const char* name ) + : AddContactPage(parent, name) +{ + kdDebug(14210) << k_funcinfo << endl; + ( new QVBoxLayout( this ) )->setAutoAdd( true ); + m_testbedAddUI = new TestbedAddUI( this ); +} + +TestbedAddContactPage::~TestbedAddContactPage() +{ +} + +bool TestbedAddContactPage::apply( Kopete::Account* a, Kopete::MetaContact* m ) +{ + if ( validateData() ) + { + bool ok = false; + QString type; + QString name; + if ( m_testbedAddUI->m_rbEcho->isOn() ) + { + type = m_testbedAddUI->m_uniqueName->text(); + name = QString::fromLatin1( "Echo Contact" ); + ok = true; + } + if ( ok ) + return a->addContact(type, /* FIXME: ? name, */ m, Kopete::Account::ChangeKABC ); + else + return false; + } + return false; +} + +bool TestbedAddContactPage::validateData() +{ + return true; +} + + +#include "testbedaddcontactpage.moc" diff --git a/kopete/protocols/testbed/testbedaddcontactpage.h b/kopete/protocols/testbed/testbedaddcontactpage.h new file mode 100644 index 00000000..fd7642f3 --- /dev/null +++ b/kopete/protocols/testbed/testbedaddcontactpage.h @@ -0,0 +1,50 @@ +/* + testbedaddcontactpage.h - Kopete Testbed Protocol + + Copyright (c) 2003 by Will Stephenson + Kopete (c) 2002-2003 by the Kopete developers + + ************************************************************************* + * * + * This library 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. * + * * + ************************************************************************* +*/ + +#ifndef TESTBEDADDCONTACTPAGE_H +#define TESTBEDADDCONTACTPAGE_H + +#include + +namespace Kopete { class Account; } +namespace Kopete { class MetaContact; } +class TestbedAddUI; + +/** + * A page in the Add Contact Wizard + * @author Will Stephenson +*/ +class TestbedAddContactPage : public AddContactPage +{ + Q_OBJECT +public: + TestbedAddContactPage( QWidget* parent = 0, const char* name = 0 ); + ~TestbedAddContactPage(); + + /** + * Make a contact out of the entered data + */ + virtual bool apply(Kopete::Account* a, Kopete::MetaContact* m); + /** + * Is the data correct? + */ + virtual bool validateData(); + +protected: + TestbedAddUI *m_testbedAddUI; +}; + +#endif diff --git a/kopete/protocols/testbed/testbedaddui.ui b/kopete/protocols/testbed/testbedaddui.ui new file mode 100644 index 00000000..c81a4d2f --- /dev/null +++ b/kopete/protocols/testbed/testbedaddui.ui @@ -0,0 +1,107 @@ + +TestbedAddUI + + + TestbedAddUI + + + + 0 + 0 + 375 + 241 + + + + + unnamed + + + + layout2 + + + + unnamed + + + + textLabel1 + + + &Contact name: + + + m_uniqueName + + + The account name of the account you would like to add. + + + The account name of the account you would like to add. + + + + + m_uniqueName + + + The account name of the account you would like to add. + + + The account name of the account you would like to add. + + + + + + + buttonGroup1 + + + Contact Type + + + + unnamed + + + + m_rbEcho + + + &Echo + + + true + + + Hey look! Only one option. Could you please make this a dropdown and add Null? + + + Hey look! Only one option. Could you please make this a dropdown and add Null? + + + + + + + spacer2 + + + Vertical + + + Expanding + + + + 20 + 252 + + + + + + + diff --git a/kopete/protocols/testbed/testbedcontact.cpp b/kopete/protocols/testbed/testbedcontact.cpp new file mode 100644 index 00000000..b5fc1c2c --- /dev/null +++ b/kopete/protocols/testbed/testbedcontact.cpp @@ -0,0 +1,141 @@ +/* + testbedcontact.cpp - Kopete Testbed Protocol + + Copyright (c) 2003 by Will Stephenson + Kopete (c) 2002-2003 by the Kopete developers + + ************************************************************************* + * * + * This library 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 "testbedcontact.h" + +#include +#include +#include + +#include "kopeteaccount.h" +#include "kopetechatsessionmanager.h" +#include "kopetemetacontact.h" + +#include "testbedaccount.h" +#include "testbedfakeserver.h" +#include "testbedprotocol.h" + +TestbedContact::TestbedContact( Kopete::Account* _account, const QString &uniqueName, + const TestbedContactType type, const QString &displayName, Kopete::MetaContact *parent ) +: Kopete::Contact( _account, uniqueName, parent ) +{ + kdDebug( 14210 ) << k_funcinfo << " uniqueName: " << uniqueName << ", displayName: " << displayName << endl; + m_type = type; + // FIXME: ? setDisplayName( displayName ); + m_msgManager = 0L; + + setOnlineStatus( TestbedProtocol::protocol()->testbedOffline ); +} + +TestbedContact::~TestbedContact() +{ +} + +bool TestbedContact::isReachable() +{ + return true; +} + +void TestbedContact::serialize( QMap< QString, QString > &serializedData, QMap< QString, QString > & /* addressBookData */ ) +{ + QString value; + switch ( m_type ) + { + case Null: + value = "null"; + case Echo: + value = "echo"; + } + serializedData[ "contactType" ] = value; +} + +Kopete::ChatSession* TestbedContact::manager( CanCreateFlags ) +{ + kdDebug( 14210 ) << k_funcinfo << endl; + if ( m_msgManager ) + { + return m_msgManager; + } + else + { + QPtrList contacts; + contacts.append(this); + m_msgManager = Kopete::ChatSessionManager::self()->create(account()->myself(), contacts, protocol()); + connect(m_msgManager, SIGNAL(messageSent(Kopete::Message&, Kopete::ChatSession*)), + this, SLOT( sendMessage( Kopete::Message& ) ) ); + connect(m_msgManager, SIGNAL(destroyed()), this, SLOT(slotChatSessionDestroyed())); + return m_msgManager; + } +} + + +QPtrList *TestbedContact::customContextMenuActions() //OBSOLETE +{ + //FIXME!!! this function is obsolete, we should use XMLGUI instead + /*m_actionCollection = new KActionCollection( this, "userColl" ); + m_actionPrefs = new KAction(i18n( "&Contact Settings" ), 0, this, + SLOT( showContactSettings( )), m_actionCollection, "contactSettings" ); + + return m_actionCollection;*/ + return 0L; +} + +void TestbedContact::showContactSettings() +{ + //TestbedContactSettings* p = new TestbedContactSettings( this ); + //p->show(); +} + +void TestbedContact::sendMessage( Kopete::Message &message ) +{ + kdDebug( 14210 ) << k_funcinfo << endl; + // convert to the what the server wants + // For this 'protocol', there's nothing to do + // send it + static_cast( account() )->server()->sendMessage( + message.to().first()->contactId(), + message.plainBody() ); + // give it back to the manager to display + manager()->appendMessage( message ); + // tell the manager it was sent successfully + manager()->messageSucceeded(); +} + +void TestbedContact::receivedMessage( const QString &message ) +{ + // Create a Kopete::Message + Kopete::Message *newMessage; + Kopete::ContactPtrList contactList; + account(); + contactList.append( account()->myself() ); + newMessage = new Kopete::Message( this, contactList, message, Kopete::Message::Inbound ); + + // Add it to the manager + manager()->appendMessage (*newMessage); + + delete newMessage; +} + +void TestbedContact::slotChatSessionDestroyed() +{ + //FIXME: the chat window was closed? Take appropriate steps. + m_msgManager = 0L; +} + +#include "testbedcontact.moc" + +// vim: set noet ts=4 sts=4 sw=4: + diff --git a/kopete/protocols/testbed/testbedcontact.h b/kopete/protocols/testbed/testbedcontact.h new file mode 100644 index 00000000..7f7c168a --- /dev/null +++ b/kopete/protocols/testbed/testbedcontact.h @@ -0,0 +1,95 @@ +/* + testbedcontact.h - Kopete Testbed Protocol + + Copyright (c) 2003 by Will Stephenson + Kopete (c) 2002-2003 by the Kopete developers + + ************************************************************************* + * * + * This library 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. * + * * + ************************************************************************* +*/ + +#ifndef TESTBEDCONTACT_H +#define TESTBEDCONTACT_H + +#include +#include "kopetecontact.h" +#include "kopetemessage.h" + +class KAction; +class KActionCollection; +namespace Kopete { class Account; } +namespace Kopete { class ChatSession; } +namespace Kopete { class MetaContact; } + +/** +@author Will Stephenson +*/ +class TestbedContact : public Kopete::Contact +{ + Q_OBJECT +public: + /** + * The range of possible contact types + */ + enum TestbedContactType { Null, Echo }; + + TestbedContact( Kopete::Account* _account, const QString &uniqueName, + const TestbedContact::TestbedContactType type, const QString &displayName, + Kopete::MetaContact *parent ); + + ~TestbedContact(); + + virtual bool isReachable(); + /** + * Serialize the contact's data into a key-value map + * suitable for writing to a file + */ + virtual void serialize(QMap< QString, QString >& serializedData, + QMap< QString, QString >& addressBookData); + /** + * Return the actions for this contact + */ + virtual QPtrList *customContextMenuActions(); + /** + * Returns a Kopete::ChatSession associated with this contact + */ + virtual Kopete::ChatSession *manager( CanCreateFlags canCreate = CannotCreate ); + +public slots: + /** + * Transmits an outgoing message to the server + * Called when the chat window send button has been pressed + * (in response to the relevant Kopete::ChatSession signal) + */ + void sendMessage( Kopete::Message &message ); + /** + * Called when an incoming message arrived + * This displays it in the chatwindow + */ + void receivedMessage( const QString &message ); + +protected slots: + /** + * Show the settings dialog + */ + void showContactSettings(); + /** + * Notify the contact that its current Kopete::ChatSession was + * destroyed - probably by the chatwindow being closed + */ + void slotChatSessionDestroyed(); + +protected: + Kopete::ChatSession* m_msgManager; + KActionCollection* m_actionCollection; + TestbedContactType m_type; + KAction* m_actionPrefs; +}; + +#endif diff --git a/kopete/protocols/testbed/testbededitaccountwidget.cpp b/kopete/protocols/testbed/testbededitaccountwidget.cpp new file mode 100644 index 00000000..270b887a --- /dev/null +++ b/kopete/protocols/testbed/testbededitaccountwidget.cpp @@ -0,0 +1,62 @@ +/* + testbededitaccountwidget.h - Kopete Testbed Protocol + + Copyright (c) 2003 by Will Stephenson + Kopete (c) 2002-2003 by the Kopete developers + + ************************************************************************* + * * + * This library 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 "testbededitaccountwidget.h" + +#include +#include +#include +#include "kopeteaccount.h" +#include "testbedaccountpreferences.h" +#include "testbedaccount.h" +#include "testbedprotocol.h" + +TestbedEditAccountWidget::TestbedEditAccountWidget( QWidget* parent, Kopete::Account* account) +: QWidget( parent ), KopeteEditAccountWidget( account ) +{ + ( new QVBoxLayout( this ) )->setAutoAdd( true ); + kdDebug(14210) << k_funcinfo << endl; + m_preferencesWidget = new TestbedAccountPreferences( this ); +} + +TestbedEditAccountWidget::~TestbedEditAccountWidget() +{ +} + +Kopete::Account* TestbedEditAccountWidget::apply() +{ + QString accountName; + if ( m_preferencesWidget->m_acctName->text().isEmpty() ) + accountName = "Testbed Account"; + else + accountName = m_preferencesWidget->m_acctName->text(); + + if ( account() ) + // FIXME: ? account()->setAccountLabel(accountName); + account()->myself()->setProperty( Kopete::Global::Properties::self()->nickName(), accountName ); + else + setAccount( new TestbedAccount( TestbedProtocol::protocol(), accountName ) ); + + return account(); +} + +bool TestbedEditAccountWidget::validateData() +{ + //return !( m_preferencesWidget->m_acctName->text().isEmpty() ); + return true; +} + +#include "testbededitaccountwidget.moc" diff --git a/kopete/protocols/testbed/testbededitaccountwidget.h b/kopete/protocols/testbed/testbededitaccountwidget.h new file mode 100644 index 00000000..9d2e6089 --- /dev/null +++ b/kopete/protocols/testbed/testbededitaccountwidget.h @@ -0,0 +1,52 @@ +/* + testbededitaccountwidget.h - Kopete Testbed Protocol + + Copyright (c) 2003 by Will Stephenson + Kopete (c) 2002-2003 by the Kopete developers + + ************************************************************************* + * * + * This library 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. * + * * + ************************************************************************* +*/ + +#ifndef TESTBEDEDITACCOUNTWIDGET_H +#define TESTBEDEDITACCOUNTWIDGET_H + +#include +#include + +class QVBoxLayout; +namespace Kopete { class Account; } +class TestbedAccountPreferences; + +/** + * A widget for editing this protocol's accounts + * @author Will Stephenson +*/ +class TestbedEditAccountWidget : public QWidget, public KopeteEditAccountWidget +{ +Q_OBJECT +public: + TestbedEditAccountWidget( QWidget* parent, Kopete::Account* account); + + ~TestbedEditAccountWidget(); + + /** + * Make an account out of the entered data + */ + virtual Kopete::Account* apply(); + /** + * Is the data correct? + */ + virtual bool validateData(); +protected: + Kopete::Account *m_account; + TestbedAccountPreferences *m_preferencesWidget; +}; + +#endif diff --git a/kopete/protocols/testbed/testbedfakeserver.cpp b/kopete/protocols/testbed/testbedfakeserver.cpp new file mode 100644 index 00000000..b1bb3e1e --- /dev/null +++ b/kopete/protocols/testbed/testbedfakeserver.cpp @@ -0,0 +1,64 @@ +/* + testbedfakeserver.cpp - Kopete Testbed Protocol + + Copyright (c) 2003 by Will Stephenson + Kopete (c) 2002-2003 by the Kopete developers + + ************************************************************************* + * * + * This library 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 "testbedfakeserver.h" +#include +#include +#include "testbedincomingmessage.h" + + +TestbedFakeServer::TestbedFakeServer() +{ + m_incomingMessages.setAutoDelete( true ); +} + +TestbedFakeServer::~TestbedFakeServer() +{ +} + +void TestbedFakeServer::sendMessage( QString contactId, QString message ) +{ + // see what contact the message is for + // if it's for Echo, respond immediately + kdDebug( 14210 ) << k_funcinfo << "Message for: " << contactId << ", is: " << message << endl; + kdDebug( 14210 ) << "recipient is echo, coming back at you." << endl; + // put the message in a map and start a timer to tell it to deliver itself. + //emit messageReceived( QString::fromLatin1( "echo: " ) + message ); + QString messageId = contactId + QString::fromLatin1(": "); + TestbedIncomingMessage* msg = new TestbedIncomingMessage( this, messageId + message ); + m_incomingMessages.append( msg ); + QTimer::singleShot( 1000, msg, SLOT( deliver() ) ); + + // This removes any delivered messages + purgeMessages(); +} + +void TestbedFakeServer::incomingMessage( QString message ) +{ + emit messageReceived( message ); +} + +void TestbedFakeServer::purgeMessages() +{ + TestbedIncomingMessage* msg; + for ( msg = m_incomingMessages.first(); msg; msg = m_incomingMessages.next() ) + { + if ( msg->delivered() ) + m_incomingMessages.remove(); + } +} + +#include "testbedfakeserver.moc" diff --git a/kopete/protocols/testbed/testbedfakeserver.h b/kopete/protocols/testbed/testbedfakeserver.h new file mode 100644 index 00000000..c5daabe4 --- /dev/null +++ b/kopete/protocols/testbed/testbedfakeserver.h @@ -0,0 +1,66 @@ +/* + testbedfakeserver.h - Kopete Testbed Protocol + + Copyright (c) 2003 by Will Stephenson + Kopete (c) 2002-2003 by the Kopete developers + + ************************************************************************* + * * + * This library 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. * + * * + ************************************************************************* +*/ + +#ifndef TESTBEDFAKESERVER_H +#define TESTBEDFAKESERVER_H + +#include "qobject.h" +#include + +class TestbedIncomingMessage; + +/** + * This is a interface to a dummy IM server + * @author Will Stephenson + */ +class TestbedFakeServer : public QObject +{ + Q_OBJECT +public: + TestbedFakeServer(); + ~TestbedFakeServer(); + /** + * Called to simulate sending a message to a remote contact + */ + void sendMessage( QString contactId, QString message ); + +public slots: + /** + * A message came in off the simulated wire. + * In reality, a message on the incoming message list + * connects to this slot when it's time to 'arrive' + */ + void incomingMessage( QString message ); + +signals: + /** + * Tells the account that a message arrived + */ + void messageReceived( const QString &message ); + +protected: + /** + * Utility method, just clears delivered messages from the + * incoming message list + */ + void purgeMessages(); + /** + * List of incoming messages + */ + QPtrList m_incomingMessages; +}; + +#endif diff --git a/kopete/protocols/testbed/testbedincomingmessage.cpp b/kopete/protocols/testbed/testbedincomingmessage.cpp new file mode 100644 index 00000000..fbbd4c83 --- /dev/null +++ b/kopete/protocols/testbed/testbedincomingmessage.cpp @@ -0,0 +1,36 @@ +/* + testbedincomingmessage.cpp - Kopete Testbed Protocol + + Copyright (c) 2003 by Will Stephenson + Kopete (c) 2002-2003 by the Kopete developers + + ************************************************************************* + * * + * This library 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 "testbedincomingmessage.h" + +TestbedIncomingMessage::TestbedIncomingMessage( TestbedFakeServer* const server , QString message ) +{ + m_server = server; + m_message = message; + m_delivered = false; +} + +TestbedIncomingMessage::~TestbedIncomingMessage() +{ +} + +void TestbedIncomingMessage::deliver() +{ + m_server->incomingMessage( m_message ); + m_delivered = true; +} + +#include "testbedincomingmessage.moc" diff --git a/kopete/protocols/testbed/testbedincomingmessage.h b/kopete/protocols/testbed/testbedincomingmessage.h new file mode 100644 index 00000000..226368d9 --- /dev/null +++ b/kopete/protocols/testbed/testbedincomingmessage.h @@ -0,0 +1,55 @@ +/* + testbedincomingmessage.h - Kopete Testbed Protocol + + Copyright (c) 2003 by Will Stephenson + Kopete (c) 2002-2003 by the Kopete developers + + ************************************************************************* + * * + * This library 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. * + * * + ************************************************************************* +*/ + +#ifndef TESTBEDINCOMINGMESSAGE_H +#define TESTBEDINCOMINGMESSAGE_H + +#include +#include "testbedfakeserver.h" + +/** + * A simulated incoming message, that hasn't yet arrived at the + * Kopete side 'client' of the simulated IM system. + * @author Will Stephenson + */ +class TestbedIncomingMessage : public QObject +{ +Q_OBJECT +public: + /** + * Create a new incoming message + * @param server The simulated Kopete side 'client' of the IM system where the message will arrive when 'delivered' + * @param message The simulated message + */ + TestbedIncomingMessage( TestbedFakeServer* const server , QString message ); + virtual ~TestbedIncomingMessage(); + /** + * Has this message already been delivered? + */ + bool delivered() { return m_delivered; } +public slots: + /** + * 'Deliver' the message to Kopete by calling TestbedFakeServer::incomingMessage(). + * This marks the message as delivered so it can be purged from the incoming list. + */ + void deliver(); +protected: + QString m_message; + TestbedFakeServer* m_server; + bool m_delivered; +}; + +#endif diff --git a/kopete/protocols/testbed/testbedprotocol.cpp b/kopete/protocols/testbed/testbedprotocol.cpp new file mode 100644 index 00000000..838a74b4 --- /dev/null +++ b/kopete/protocols/testbed/testbedprotocol.cpp @@ -0,0 +1,101 @@ +/* + testbedprotocol.cpp - Kopete Testbed Protocol + + Copyright (c) 2003 by Will Stephenson + Kopete (c) 2002-2003 by the Kopete developers + + ************************************************************************* + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + ************************************************************************* +*/ +#include +#include + +#include "kopeteaccountmanager.h" + +#include "testbedaccount.h" +#include "testbedcontact.h" +#include "testbedprotocol.h" +#include "testbedaddcontactpage.h" +#include "testbededitaccountwidget.h" + +typedef KGenericFactory TestbedProtocolFactory; +K_EXPORT_COMPONENT_FACTORY( kopete_testbed, TestbedProtocolFactory( "kopete_testbed" ) ) + +TestbedProtocol *TestbedProtocol::s_protocol = 0L; + +TestbedProtocol::TestbedProtocol( QObject* parent, const char *name, const QStringList &/*args*/ ) + : Kopete::Protocol( TestbedProtocolFactory::instance(), parent, name ), + testbedOnline( Kopete::OnlineStatus::Online, 25, this, 0, QString::null, i18n( "Online" ), i18n( "O&nline" ) ), + testbedAway( Kopete::OnlineStatus::Away, 25, this, 1, "msn_away", i18n( "Away" ), i18n( "&Away" ) ), + testbedOffline( Kopete::OnlineStatus::Offline, 25, this, 2, QString::null, i18n( "Offline" ), i18n( "O&ffline" ) ) + +{ + kdDebug( 14210 ) << k_funcinfo << endl; + + s_protocol = this; +} + +TestbedProtocol::~TestbedProtocol() +{ +} + +Kopete::Contact *TestbedProtocol::deserializeContact( + Kopete::MetaContact *metaContact, const QMap &serializedData, + const QMap &/* addressBookData */) +{ + QString contactId = serializedData[ "contactId" ]; + QString accountId = serializedData[ "accountId" ]; + QString displayName = serializedData[ "displayName" ]; + QString type = serializedData[ "contactType" ]; + + TestbedContact::TestbedContactType tbcType; + if ( type == QString::fromLatin1( "echo" ) ) + tbcType = TestbedContact::Echo; + if ( type == QString::fromLatin1( "null" ) ) + tbcType = TestbedContact::Null; + else + tbcType = TestbedContact::Null; + + QDict accounts = Kopete::AccountManager::self()->accounts( this ); + + Kopete::Account *account = accounts[ accountId ]; + if ( !account ) + { + kdDebug(14210) << "Account doesn't exist, skipping" << endl; + return 0; + } + + return new TestbedContact(account, contactId, tbcType, displayName, metaContact); +} + +AddContactPage * TestbedProtocol::createAddContactWidget( QWidget *parent, Kopete::Account * /* account */ ) +{ + kdDebug( 14210 ) << "Creating Add Contact Page" << endl; + return new TestbedAddContactPage( parent ); +} + +KopeteEditAccountWidget * TestbedProtocol::createEditAccountWidget( Kopete::Account *account, QWidget *parent ) +{ + kdDebug(14210) << "Creating Edit Account Page" << endl; + return new TestbedEditAccountWidget( parent, account ); +} + +Kopete::Account *TestbedProtocol::createNewAccount( const QString &accountId ) +{ + return new TestbedAccount( this, accountId ); +} + +TestbedProtocol *TestbedProtocol::protocol() +{ + return s_protocol; +} + + + +#include "testbedprotocol.moc" diff --git a/kopete/protocols/testbed/testbedprotocol.h b/kopete/protocols/testbed/testbedprotocol.h new file mode 100644 index 00000000..7ee04b7d --- /dev/null +++ b/kopete/protocols/testbed/testbedprotocol.h @@ -0,0 +1,74 @@ +/* + testbedprotocol.h - Kopete Testbed Protocol + + Copyright (c) 2003 by Will Stephenson + Kopete (c) 2002-2003 by the Kopete developers + + ************************************************************************* + * * + * This library 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. * + * * + ************************************************************************* +*/ + +#ifndef TESTBEDPROTOCOL_H +#define TESTBEDPROTOCOL_H + +#include + + +/** + * Encapsulates the generic actions associated with this protocol + * @author Will Stephenson + */ +class TestbedProtocol : public Kopete::Protocol +{ + Q_OBJECT +public: + TestbedProtocol(QObject *parent, const char *name, const QStringList &args); + ~TestbedProtocol(); + /** + * Convert the serialised data back into a TestbedContact and add this + * to its Kopete::MetaContact + */ + virtual Kopete::Contact *deserializeContact( + Kopete::MetaContact *metaContact, + const QMap< QString, QString > & serializedData, + const QMap< QString, QString > & addressBookData + ); + /** + * Generate the widget needed to add TestbedContacts + */ + virtual AddContactPage * createAddContactWidget( QWidget *parent, Kopete::Account *account ); + /** + * Generate the widget needed to add/edit accounts for this protocol + */ + virtual KopeteEditAccountWidget * createEditAccountWidget( Kopete::Account *account, QWidget *parent ); + /** + * Generate a TestbedAccount + */ + virtual Kopete::Account * createNewAccount( const QString &accountId ); + /** + * Access the instance of this protocol + */ + static TestbedProtocol *protocol(); + /** + * Represents contacts that are Online + */ + const Kopete::OnlineStatus testbedOnline; + /** + * Represents contacts that are Away + */ + const Kopete::OnlineStatus testbedAway; + /** + * Represents contacts that are Offline + */ + const Kopete::OnlineStatus testbedOffline; +protected: + static TestbedProtocol *s_protocol; +}; + +#endif diff --git a/kopete/protocols/testbed/ui/Makefile.am b/kopete/protocols/testbed/ui/Makefile.am new file mode 100644 index 00000000..1bbf604c --- /dev/null +++ b/kopete/protocols/testbed/ui/Makefile.am @@ -0,0 +1,7 @@ +INCLUDES = +METASOURCES = AUTO +AM_CPPFLAGS = $(KOPETE_INCLUDES) -I$(srcdir)/.. $(all_includes) +libkopetetestbedui_la_LDFLAGS = $(all_libraries) +noinst_LTLIBRARIES = libkopetetestbedui.la +noinst_HEADERS = testbedwebcamdialog.h +libkopetetestbedui_la_SOURCES = testbedwebcamdialog.cpp diff --git a/kopete/protocols/testbed/ui/testbedwebcamdialog.cpp b/kopete/protocols/testbed/ui/testbedwebcamdialog.cpp new file mode 100644 index 00000000..22884036 --- /dev/null +++ b/kopete/protocols/testbed/ui/testbedwebcamdialog.cpp @@ -0,0 +1,80 @@ +/* + Kopete Testbed Protocol + + Copyright (c) 2006 by Cláudio da Silveira Pinheiro + Kopete (c) 2002-2006 by the Kopete developers + + ************************************************************************* + * * + * 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 "testbedwebcamdialog.h" +#include +#include "avdevice/videodevicepool.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +TestbedWebcamDialog::TestbedWebcamDialog( const QString &contactId, QWidget * parent, const char * name ) +: KDialogBase( KDialogBase::Plain, Qt::WDestructiveClose, parent, name, false, i18n( "Webcam for %1" ).arg( contactId ), + KDialogBase::Close, KDialogBase::Close, true /*seperator*/ ) +{ + setInitialSize( QSize(320,290), false ); + + setEscapeButton( KDialogBase::Close ); +// QObject::connect( this, SIGNAL( closeClicked() ), this, SIGNAL( closingWebcamDialog() ) ); + + QWidget *page = plainPage(); + setMainWidget(page); + + QVBoxLayout *topLayout = new QVBoxLayout( page, 0, spacingHint() ); + mImageContainer = new Kopete::WebcamWidget( page ); + mImageContainer->setMinimumSize(320,240); + mImageContainer->setText( i18n( "No webcam image received" ) ); + mImageContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + topLayout->add( mImageContainer ); + + show(); + + mVideoDevicePool = Kopete::AV::VideoDevicePool::self(); + mVideoDevicePool->open(); + mVideoDevicePool->setSize(320, 240); + mVideoDevicePool->startCapturing(); + mVideoDevicePool->getFrame(); + mVideoDevicePool->getImage(&mImage); +kdDebug() << "Just captured 1st frame" << endl; + + mPixmap=QPixmap(320,240,-1, QPixmap::DefaultOptim); + if (mPixmap.convertFromImage(mImage,0) == true) + mImageContainer->updatePixmap(mPixmap); + connect(&qtimer, SIGNAL(timeout()), this, SLOT(slotUpdateImage()) ); + qtimer.start(0,FALSE); +} + +TestbedWebcamDialog::~ TestbedWebcamDialog( ) +{ + mVideoDevicePool->stopCapturing(); + mVideoDevicePool->close(); +} + +void TestbedWebcamDialog::slotUpdateImage() +{ + mVideoDevicePool->getFrame(); + mVideoDevicePool->getImage(&mImage); + mImageContainer->updatePixmap( QPixmap( mImage ) ); +} + + +#include "testbedwebcamdialog.moc" diff --git a/kopete/protocols/testbed/ui/testbedwebcamdialog.h b/kopete/protocols/testbed/ui/testbedwebcamdialog.h new file mode 100644 index 00000000..59f43e68 --- /dev/null +++ b/kopete/protocols/testbed/ui/testbedwebcamdialog.h @@ -0,0 +1,60 @@ +/* + Kopete Testbed Protocol + + Copyright (c) 2006 by Cláudio da Silveira Pinheiro + Kopete (c) 2002-2006 by the Kopete developers + + ************************************************************************* + * * + * 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. * + * * + ************************************************************************* +*/ + +#ifndef TESTBEDWEBCAMDIALOG_H +#define TESTBEDWEBCAMDIALOG_H + +#include +#include +#include +#include +#include + +/** + @author Kopete Developers +*/ +class QPixmap; +class QWidget; +class TestbedContact; + +namespace Kopete { + namespace AV { + class VideoDevicePool; + } + class WebcamWidget; +} + +class TestbedWebcamDialog : public KDialogBase +{ +Q_OBJECT +public: + TestbedWebcamDialog( const QString &, QWidget* parent = 0, const char* name = 0 ); + ~TestbedWebcamDialog(); + +public slots: + void slotUpdateImage(); +//signals: +// void closingWebcamDialog(); + +private: + Kopete::WebcamWidget *mImageContainer; + QImage mImage; + QTimer qtimer; + QPixmap mPixmap; + Kopete::AV::VideoDevicePool *mVideoDevicePool; +}; + +#endif -- cgit v1.2.1