1 /* *************************************************************************
2 * copyright: (C) 2003 Richard Lärkäng <nouseforaname@home.se> *
3 * copyright: (C) 2003 Gav Wood <gav@kde.org> *
4 *************************************************************************
7 /* *************************************************************************
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
14 *************************************************************************
17 #include <kgenericfactory.h>
20 #include <kmessagebox.h>
22 #include "kopeteaccountmanager.h"
23 #include "kopeteonlinestatusmanager.h"
24 #include "smsprotocol.h"
25 #include "smseditaccountwidget.h"
26 #include "smscontact.h"
27 #include "smsaddcontactpage.h"
28 #include "smsaccount.h"
30 K_PLUGIN_FACTORY( SMSProtocolFactory
, registerPlugin
<SMSProtocol
>(); )
31 K_EXPORT_PLUGIN( SMSProtocolFactory( "kopete_sms" ) )
33 SMSProtocol
* SMSProtocol::s_protocol
= 0L;
35 SMSProtocol::SMSProtocol(QObject
*parent
, const QVariantList
&)
36 : Kopete::Protocol( SMSProtocolFactory::componentData(), parent
),
37 SMSOnline( Kopete::OnlineStatus::Online
, 25, this, 0, QStringList(), i18n( "Online" ), i18n( "Online" ), Kopete::OnlineStatusManager::Online
),
38 SMSOffline( Kopete::OnlineStatus::Offline
, 0, this, 2, QStringList(), i18n( "Offline" ), i18n( "Offline" ), Kopete::OnlineStatusManager::Offline
),
39 SMSConnecting( Kopete::OnlineStatus::Connecting
,2, this, 3, QStringList(), i18n( "Connecting" ) )
43 kWarning( 14160 ) << "s_protocol already defined!";
47 addAddressBookField("messaging/sms", Kopete::Plugin::MakeIndexField
);
50 SMSProtocol::~SMSProtocol()
55 AddContactPage
*SMSProtocol::createAddContactWidget(QWidget
*parent
, Kopete::Account
*i
)
58 return new SMSAddContactPage(parent
);
61 KopeteEditAccountWidget
* SMSProtocol::createEditAccountWidget(Kopete::Account
*account
, QWidget
*parent
)
63 return new SMSEditAccountWidget(this, account
, parent
);
66 SMSProtocol
* SMSProtocol::protocol()
71 Kopete::Contact
*SMSProtocol::deserializeContact(Kopete::MetaContact
*metaContact
,
72 const QMap
<QString
, QString
> &serializedData
,
73 const QMap
<QString
, QString
> &/* addressBookData */)
75 QString contactId
= serializedData
["contactId"];
76 QString accountId
= serializedData
["accountId"];
77 QString displayName
= serializedData
["displayName"];
79 QList
<Kopete::Account
*> accounts
=Kopete::AccountManager::self()->accounts(this);
81 QList
<Kopete::Account
*>::iterator curacct
, lastacct
= accounts
.end();
82 Kopete::Account
*account
= (Kopete::Account
*) NULL
;
84 for (curacct
= accounts
.begin(); curacct
!= lastacct
; curacct
++) {
85 Kopete::Account
*one
= static_cast<Kopete::Account
*>(*curacct
);
86 if (one
->accountId() == accountId
) {
94 kDebug(14160) << "Account doesn't exist, skipping";
98 return new SMSContact(account
, contactId
, displayName
, metaContact
);
101 Kopete::Account
* SMSProtocol::createNewAccount(const QString
&accountId
)
103 return new SMSAccount(this, accountId
);
106 #include "smsprotocol.moc"
108 // vim: set noet ts=4 sts=4 sw=4: