2 qqprotocol.cpp - Kopete QQ Protocol
4 Copyright (c) 2003 by Will Stephenson <will@stevello.free-online.co.u>
5 Kopete (c) 2002-2003 by the Kopete developers <kopete-devel@kde.org>
7 *************************************************************************
9 * This library is free software; you can redistribute it and/or *
10 * modify it under the terms of the GNU Lesser General Public *
11 * License as published by the Free Software Foundation; either *
12 * version 2 of the License, or (at your option) any later version. *
14 *************************************************************************
17 #include <kgenericfactory.h>
20 #include "kopeteaccountmanager.h"
21 #include "qqaccount.h"
22 #include "qqcontact.h"
23 #include "qqprotocol.h"
24 #include "qqaddcontactpage.h"
25 #include "ui/qqeditaccountwidget.h"
27 K_PLUGIN_FACTORY( QQProtocolFactory
, registerPlugin
<QQProtocol
>(); )
28 K_EXPORT_PLUGIN( QQProtocolFactory( "kopete_qq" ) )
30 QQProtocol
*QQProtocol::s_protocol
= 0L;
32 QQProtocol::QQProtocol( QObject
* parent
, const QVariantList
&/*args*/ )
33 : Kopete::Protocol( QQProtocolFactory::componentData(), parent
),
34 qqOnline( Kopete::OnlineStatus::Online
, 25, this, 0, QStringList(QString()),
35 i18n( "Online" ), i18n( "O&nline" ) ),
36 qqAway( Kopete::OnlineStatus::Away
, 25, this, 1, QStringList(QLatin1String("msn_away")),
37 i18n( "Away" ), i18n( "&Away" ) ),
38 qqOffline( Kopete::OnlineStatus::Offline
, 25, this, 2, QStringList(QString()),
39 i18n( "Offline" ), i18n( "O&ffline" ) ),
40 propNickName(Kopete::Global::Properties::self()->nickName()),
41 propFullName(Kopete::Global::Properties::self()->fullName()),
42 propCountry("QQVCardCountry", i18n("Country"), QString(), Kopete::PropertyTmpl::PersistentProperty
),
43 propState("QQVCardState", i18n("State"), QString(), Kopete::PropertyTmpl::PersistentProperty
),
44 propCity("QQVCardCity", i18n("State"), QString(), Kopete::PropertyTmpl::PersistentProperty
),
45 propStreet("QQVCardAddress", i18n("Home Address"), QString(), Kopete::PropertyTmpl::PersistentProperty
),
46 propZipcode("QQVCardZipcode", i18n("Zipcode"), QString(), Kopete::PropertyTmpl::PersistentProperty
),
47 propAge("QQVCardAge", i18n("Age"), QString(), Kopete::PropertyTmpl::PersistentProperty
),
48 propEmail(Kopete::Global::Properties::self()->emailAddress())
54 QQProtocol::~QQProtocol()
58 Kopete::Contact
*QQProtocol::deserializeContact(
59 Kopete::MetaContact
*metaContact
, const QMap
<QString
, QString
> &serializedData
,
60 const QMap
<QString
, QString
> &/* addressBookData */)
62 QString contactId
= serializedData
[ "contactId" ];
63 QString accountId
= serializedData
[ "accountId" ];
64 QString displayName
= serializedData
[ "displayName" ];
65 QString type
= serializedData
[ "contactType" ];
67 QQContact::QQContactType tbcType;
68 if ( type == QString::fromLatin1( "echo" ) )
69 tbcType = QQContact::Echo;
70 if ( type == QString::fromLatin1( "null" ) )
71 tbcType = QQContact::Null;
73 tbcType = QQContact::Null;
75 QList
<Kopete::Account
*> accounts
= Kopete::AccountManager::self()->accounts( this );
76 Kopete::Account
* account
= 0;
77 foreach( Kopete::Account
* acct
, accounts
)
79 if ( acct
->accountId() == accountId
)
85 kDebug(14210) << "Account doesn't exist, skipping";
89 return new QQContact(account
, contactId
, metaContact
);
92 AddContactPage
* QQProtocol::createAddContactWidget( QWidget
*parent
, Kopete::Account
* /* account */ )
94 kDebug( 14210 ) << "Creating Add Contact Page";
95 return new QQAddContactPage( parent
);
98 KopeteEditAccountWidget
* QQProtocol::createEditAccountWidget( Kopete::Account
*account
, QWidget
*parent
)
100 kDebug(14210) << "Creating Edit Account Page";
101 return new QQEditAccountWidget( this, account
, parent
);
104 Kopete::Account
*QQProtocol::createNewAccount( const QString
&accountId
)
106 return new QQAccount( this, accountId
);
109 bool QQProtocol::validContactId( const QString
& userId
)
111 QRegExp
re("[1-9][0-9]*");
112 return re
.exactMatch( userId
);
115 QQProtocol
*QQProtocol::protocol()
120 #include "qqprotocol.moc"