Show invite menu in wlm chat window immediately
[kdenetwork.git] / kopete / protocols / testbed / testbedprotocol.cpp
blobaf10e1410574afa9cf1c749ac01a44e937e59cb5
1 /*
2 testbedprotocol.cpp - Kopete Testbed 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 *************************************************************************
8 * *
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. *
13 * *
14 *************************************************************************
16 #include <QList>
17 #include <kgenericfactory.h>
18 #include <kdebug.h>
20 #include "kopeteaccountmanager.h"
21 #include "testbedaccount.h"
22 #include "testbedcontact.h"
23 #include "testbedprotocol.h"
24 #include "testbedaddcontactpage.h"
25 #include "testbededitaccountwidget.h"
27 K_PLUGIN_FACTORY( TestbedProtocolFactory, registerPlugin<TestbedProtocol>(); )
28 K_EXPORT_PLUGIN( TestbedProtocolFactory( "kopete_testbed" ) )
30 TestbedProtocol *TestbedProtocol::s_protocol = 0L;
32 TestbedProtocol::TestbedProtocol( QObject* parent, const QVariantList &/*args*/ )
33 : Kopete::Protocol( TestbedProtocolFactory::componentData(), parent ),
34 testbedOnline( Kopete::OnlineStatus::Online, 25, this, 0, QStringList(QString()),
35 i18n( "Online" ), i18n( "O&nline" ), Kopete::OnlineStatusManager::Online ),
36 testbedAway( Kopete::OnlineStatus::Away, 25, this, 1, QStringList(QLatin1String("msn_away")),
37 i18n( "Away" ), i18n( "&Away" ), Kopete::OnlineStatusManager::Away ),
38 testbedOffline( Kopete::OnlineStatus::Offline, 25, this, 2, QStringList(QString()),
39 i18n( "Offline" ), i18n( "O&ffline" ), Kopete::OnlineStatusManager::Offline )
42 kDebug( 14210 ) ;
44 s_protocol = this;
47 TestbedProtocol::~TestbedProtocol()
51 Kopete::Contact *TestbedProtocol::deserializeContact(
52 Kopete::MetaContact *metaContact, const QMap<QString, QString> &serializedData,
53 const QMap<QString, QString> &/* addressBookData */)
55 QString contactId = serializedData[ "contactId" ];
56 QString accountId = serializedData[ "accountId" ];
57 QString displayName = serializedData[ "displayName" ];
58 QString type = serializedData[ "contactType" ];
60 TestbedContact::Type tbcType;
61 if ( type == QLatin1String( "group" ) )
62 tbcType = TestbedContact::Group;
63 else if ( type == QLatin1String( "echo" ) )
64 tbcType = TestbedContact::Echo;
65 else if ( type == QLatin1String( "null" ) )
66 tbcType = TestbedContact::Null;
67 else
68 tbcType = TestbedContact::Null;
70 QList<Kopete::Account*> accounts = Kopete::AccountManager::self()->accounts( this );
71 Kopete::Account* account = 0;
72 foreach( Kopete::Account* acct, accounts )
74 if ( acct->accountId() == accountId )
75 account = acct;
78 if ( !account )
80 kDebug(14210) << "Account doesn't exist, skipping";
81 return 0;
84 TestbedContact * contact = new TestbedContact(account, contactId, displayName, metaContact);
85 contact->setType( tbcType );
86 return contact;
89 AddContactPage * TestbedProtocol::createAddContactWidget( QWidget *parent, Kopete::Account * /* account */ )
91 kDebug( 14210 ) << "Creating Add Contact Page";
92 return new TestbedAddContactPage( parent );
95 KopeteEditAccountWidget * TestbedProtocol::createEditAccountWidget( Kopete::Account *account, QWidget *parent )
97 kDebug(14210) << "Creating Edit Account Page";
98 return new TestbedEditAccountWidget( parent, account );
101 Kopete::Account *TestbedProtocol::createNewAccount( const QString &accountId )
103 return new TestbedAccount( this, accountId );
106 TestbedProtocol *TestbedProtocol::protocol()
108 return s_protocol;
113 #include "testbedprotocol.moc"