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/sms/smsprotocol.cpp | 97 ++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 kopete/protocols/sms/smsprotocol.cpp (limited to 'kopete/protocols/sms/smsprotocol.cpp') diff --git a/kopete/protocols/sms/smsprotocol.cpp b/kopete/protocols/sms/smsprotocol.cpp new file mode 100644 index 00000000..6b6cd838 --- /dev/null +++ b/kopete/protocols/sms/smsprotocol.cpp @@ -0,0 +1,97 @@ +/* ************************************************************************* + * copyright: (C) 2003 Richard Lärkäng * + * copyright: (C) 2003 Gav Wood * + ************************************************************************* +*/ + +/* ************************************************************************* + * * + * 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 +#include +#include +#include + +#include "kopeteaccountmanager.h" +#include "kopeteonlinestatusmanager.h" +#include "smsprotocol.h" +#include "smseditaccountwidget.h" +#include "smscontact.h" +#include "smsaddcontactpage.h" +#include "smsaccount.h" + +typedef KGenericFactory SMSProtocolFactory; +K_EXPORT_COMPONENT_FACTORY( kopete_sms, SMSProtocolFactory( "kopete_sms" ) ) + +SMSProtocol* SMSProtocol::s_protocol = 0L; + +SMSProtocol::SMSProtocol(QObject *parent, const char *name, const QStringList &/*args*/) +: Kopete::Protocol( SMSProtocolFactory::instance(), parent, name ), + SMSOnline( Kopete::OnlineStatus::Online, 25, this, 0, QString::null, i18n( "Online" ), i18n( "Online" ), Kopete::OnlineStatusManager::Online ), + SMSConnecting( Kopete::OnlineStatus::Connecting,2, this, 3, QString::null, i18n( "Connecting" ) ), + SMSOffline( Kopete::OnlineStatus::Offline, 0, this, 2, QString::null, i18n( "Offline" ), i18n( "Offline" ), Kopete::OnlineStatusManager::Offline ) +{ + if (s_protocol) + kdWarning( 14160 ) << k_funcinfo << "s_protocol already defined!" << endl; + else + s_protocol = this; + + addAddressBookField("messaging/sms", Kopete::Plugin::MakeIndexField); +} + +SMSProtocol::~SMSProtocol() +{ + s_protocol = 0L; +} + +AddContactPage *SMSProtocol::createAddContactWidget(QWidget *parent, Kopete::Account */*i*/) +{ + return new SMSAddContactPage(parent); +} + +KopeteEditAccountWidget* SMSProtocol::createEditAccountWidget(Kopete::Account *account, QWidget *parent) +{ + return new SMSEditAccountWidget(this, account, parent); +} + +SMSProtocol* SMSProtocol::protocol() +{ + return s_protocol; +} + +Kopete::Contact *SMSProtocol::deserializeContact(Kopete::MetaContact *metaContact, + const QMap &serializedData, + const QMap &/* addressBookData */) +{ + QString contactId = serializedData["contactId"]; + QString accountId = serializedData["accountId"]; + QString displayName = serializedData["displayName"]; + + QDict accounts=Kopete::AccountManager::self()->accounts(this); + + Kopete::Account *account = accounts[accountId]; + if (!account) + { + kdDebug(14160) << "Account doesn't exist, skipping" << endl; + return 0; + } + + return new SMSContact(account, contactId, displayName, metaContact); +} + +Kopete::Account* SMSProtocol::createNewAccount(const QString &accountId) +{ + return new SMSAccount(this, accountId); +} + +#include "smsprotocol.moc" + +// vim: set noet ts=4 sts=4 sw=4: + -- cgit v1.2.1