-
Notifications
You must be signed in to change notification settings - Fork 1
/
qqprotocol.cpp
146 lines (121 loc) · 7.07 KB
/
qqprotocol.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
qqprotocol.cpp - Kopete Webqq Protocol
Copyright (c) 2014 by Jun Zhang <[email protected]>
Copyright (c) 2003 by Will Stephenson <[email protected]>
Kopete (c) 2002-2003 by the Kopete developers <[email protected]>
*************************************************************************
* *
* 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 <QList>
#include <kgenericfactory.h>
#include <kdebug.h>
#include "kopeteonlinestatusmanager.h"
#include "kopeteglobal.h"
#include "kopeteproperty.h"
#include "kopeteaccountmanager.h"
#include "qqaccount.h"
#include "qqcontact.h"
#include "qqaddcontactpage.h"
#include "qqeditaccountwidget.h"
#include "qqprotocol.h"
K_PLUGIN_FACTORY( WebqqProtocolFactory, registerPlugin<WebqqProtocol>(); )
K_EXPORT_PLUGIN( WebqqProtocolFactory( "kopete_webqq" ) )
WebqqProtocol *WebqqProtocol::s_protocol = 0L;
WebqqProtocol::WebqqProtocol( QObject* parent, const QVariantList &/*args*/ )
: Kopete::Protocol( WebqqProtocolFactory::componentData(), parent ),
WebqqLogout( Kopete::OnlineStatus::Offline, 25, this, 0, QStringList(QString()),
i18n( "Offline" ), i18n( "Of&fline" ), Kopete::OnlineStatusManager::Offline ),
WebqqOnline( Kopete::OnlineStatus::Online, 25, this, 0, QStringList(QString()),
i18n( "Online" ), i18n( "O&nline" ), Kopete::OnlineStatusManager::Online,Kopete::OnlineStatusManager::HasStatusMessage),
WebqqOffline( Kopete::OnlineStatus::Offline, 25, this, 2, QStringList(QString()),
i18n( "Offline" ), i18n( "Of&fline" ), Kopete::OnlineStatusManager::Offline ),
WebqqAway( Kopete::OnlineStatus::Away, 25, this, 1, QStringList(QLatin1String("away")),
i18n( "Away" ), i18n( "&Away" ), Kopete::OnlineStatusManager::Away ),
WebqqBusy( Kopete::OnlineStatus::Busy, 25, this, 1, QStringList(QLatin1String("Busy")),
i18n( "Busy" ), i18n( "&Busy" ), Kopete::OnlineStatusManager::Busy ),
WebqqHidden( Kopete::OnlineStatus::Invisible, 25, this, 1, QStringList(QLatin1String("Invisible")),
i18n( "Invisible" ), i18n( "&Invisible" ), Kopete::OnlineStatusManager::Invisible ),
WebqqConnecting( Kopete::OnlineStatus::Connecting,2, this, 555, QStringList(QString::fromUtf8("qq_connecting")),
i18n( "Connecting" ), i18n("Connecting"), 0, Kopete::OnlineStatusManager::HideFromMenu ),
iconCheckSum("iconCheckSum", i18n("Buddy Icon Checksum"), QString(), Kopete::PropertyTmpl::PersistentProperty | Kopete::PropertyTmpl::PrivateProperty),
propNick("iconCheckSum", i18n("Buddy Icon Checksum"), QString(), Kopete::PropertyTmpl::PersistentProperty | Kopete::PropertyTmpl::PrivateProperty),
propLongNick("iconCheckSum", i18n("Buddy Icon Checksum"), QString(), Kopete::PropertyTmpl::PersistentProperty | Kopete::PropertyTmpl::PrivateProperty),
propGender("iconCheckSum", i18n("Buddy Icon Checksum"), QString(), Kopete::PropertyTmpl::PersistentProperty | Kopete::PropertyTmpl::PrivateProperty),
propBirthday("iconCheckSum", i18n("Buddy Icon Checksum"), QString(), Kopete::PropertyTmpl::PersistentProperty | Kopete::PropertyTmpl::PrivateProperty),
propPhone("iconCheckSum", i18n("Buddy Icon Checksum"), QString(), Kopete::PropertyTmpl::PersistentProperty | Kopete::PropertyTmpl::PrivateProperty),
propProvince("iconCheckSum", i18n("Buddy Icon Checksum"), QString(), Kopete::PropertyTmpl::PersistentProperty | Kopete::PropertyTmpl::PrivateProperty),
propSchool("iconCheckSum", i18n("Buddy Icon Checksum"), QString(), Kopete::PropertyTmpl::PersistentProperty | Kopete::PropertyTmpl::PrivateProperty),
propEmail("iconCheckSum", i18n("Buddy Icon Checksum"), QString(), Kopete::PropertyTmpl::PersistentProperty | Kopete::PropertyTmpl::PrivateProperty),
propXingzuo("iconCheckSum", i18n("Buddy Icon Checksum"), QString(), Kopete::PropertyTmpl::PersistentProperty | Kopete::PropertyTmpl::PrivateProperty),
propCountry("iconCheckSum", i18n("Buddy Icon Checksum"), QString(), Kopete::PropertyTmpl::PersistentProperty | Kopete::PropertyTmpl::PrivateProperty),
propCity("iconCheckSum", i18n("Buddy Icon Checksum"), QString(), Kopete::PropertyTmpl::PersistentProperty | Kopete::PropertyTmpl::PrivateProperty),
propMobile("iconCheckSum", i18n("Buddy Icon Checksum"), QString(), Kopete::PropertyTmpl::PersistentProperty | Kopete::PropertyTmpl::PrivateProperty),
propPage("iconCheckSum", i18n("Buddy Icon Checksum"), QString(), Kopete::PropertyTmpl::PersistentProperty | Kopete::PropertyTmpl::PrivateProperty),
propJob("iconCheckSum", i18n("Buddy Icon Checksum"), QString(), Kopete::PropertyTmpl::PersistentProperty | Kopete::PropertyTmpl::PrivateProperty),
propPersonal("iconCheckSum", i18n("Buddy Icon Checksum"), QString(), Kopete::PropertyTmpl::PersistentProperty | Kopete::PropertyTmpl::PrivateProperty)
{
kDebug( 14210 ) ;
s_protocol = this;
setCapabilities( FullRTF);
}
WebqqProtocol::~WebqqProtocol()
{
}
Kopete::Contact *WebqqProtocol::deserializeContact(
Kopete::MetaContact *metaContact, const QMap<QString, QString> &serializedData,
const QMap<QString, QString> &/* addressBookData */)
{
QString contactId = serializedData[ "contactId" ];
QString accountId = serializedData[ "accountId" ];
QString displayName = serializedData[ "displayName" ];
QString type = serializedData[ "contactType" ];
QQContact::Type tbcType;
if ( type == QLatin1String( "group" ) )
tbcType = QQContact::Group;
else if ( type == QLatin1String( "echo" ) )
tbcType = QQContact::Echo;
else if ( type == QLatin1String( "null" ) )
tbcType = QQContact::Null;
else
tbcType = QQContact::Null;
QList<Kopete::Account*> accounts = Kopete::AccountManager::self()->accounts( this );
Kopete::Account* account = 0;
foreach( Kopete::Account* acct, accounts )
{
if ( acct->accountId() == accountId )
account = acct;
}
if ( !account )
{
kDebug(14210) << "Account doesn't exist, skipping";
return 0;
}
QQContact * contact = new QQContact(account, contactId, displayName, metaContact);
contact->setType( tbcType );
return contact;
}
AddContactPage * WebqqProtocol::createAddContactWidget( QWidget *parent, Kopete::Account * /* account */ )
{
kDebug( 14210 ) << "Creating Add Contact Page";
return new QQAddContactPage( parent );
}
KopeteEditAccountWidget * WebqqProtocol::createEditAccountWidget( Kopete::Account *account, QWidget *parent )
{
kDebug(14210) << "Creating Edit Account Page";
return new QQEditAccountWidget( parent, account );
}
Kopete::Account *WebqqProtocol::createNewAccount( const QString &accountId )
{
return new QQAccount( this, accountId );
}
WebqqProtocol *WebqqProtocol::protocol()
{
return s_protocol;
}
#include "qqprotocol.moc"