/
webqqaccount.h
266 lines (237 loc) · 8.94 KB
/
webqqaccount.h
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
/*
webqqaccount.h - Kopete Webqq Account
Copyright (c) 2014 by Jun Zhang <jun.zhang@i-soft.com.cn>
Copyright (c) 2003 by Will Stephenson <will@stevello.free-online.co.uk>
Kopete (c) 2002-2003 by the Kopete developers <kopete-devel@kde.org>
*************************************************************************
* *
* This library 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. *
* *
*************************************************************************
*/
#ifndef TESTBEDACCOUNT_H
#define TESTBEDACCOUNT_H
//#include <kopeteaccount.h>
#include <kopetepasswordedaccount.h>
#include "webqqwebcamdialog.h"
#include <QMap>
#include <QList>
#include "webqqbridgecallback.h"
/*include the header of lwqq*/
extern "C"
{
#include "lwqq.h"
#include "lwdb.h"
}
#include "qq_types.h"
class KActionMenu;
namespace Kopete
{
class Contact;
class MetaContact;
class StatusMessage;
class Message;
}
class WebqqProtocol;
class QByteArray;
class WebqqContact;
typedef QList<group_msg> MsgDataList;
/**
* This represents an account connected to the webqq
* @author Will Stephenson
*/
class WebqqAccount : public Kopete::PasswordedAccount
{
Q_OBJECT
public:
WebqqAccount( WebqqProtocol *parent, const QString& accountID );
~WebqqAccount();
/**
* Construct the context menu used for the status bar icon
*/
virtual void fillActionMenu( KActionMenu *actionMenu );
/**
* Called when Kopete is set globally away
*/
virtual void setAway(bool away, const QString& reason);
/**
* Called when Kopete status is changed globally
*/
virtual void setOnlineStatus(const Kopete::OnlineStatus& status , const Kopete::StatusMessage &reason = Kopete::StatusMessage(),
const OnlineStatusOptions& options = None);
virtual void setStatusMessage(const Kopete::StatusMessage& statusMessage);
void initCategory();
/**
*
*/
enum Find_Type{Buddy, Group};
void find_add_contact(const QString name, Find_Type type ,QString groupName);
/*
* instance of LwqqClient
*/
LwqqClient *m_lc;
QString m_groupName;
QString m_contactName;
QString m_contactQQ;
QString m_contactNick;
/*
* got a message, then send it to contact
*/
void buddy_message(LwqqClient* lc,LwqqMsgMessage* msg);
void group_message(LwqqClient* lc,LwqqMsgMessage* msg);
WebqqContact *contact(const QString &id);
bool isOffline();
public slots:
/**
* Called by the server when it has a message for us.
* This identifies the sending Kopete::Contact and passes it a Kopete::Message
*/
void receivedMessage( const QString &message );
/**
* Connect to the WebQQ service
*/
virtual void connectWithPassword( const QString & );
/**
* Disconnect from the Yahoo service
*/
virtual void disconnect();
void initLwqqAccount();
void destoryLwqqAccount();
void friend_come(LwqqClient *lc, LwqqBuddy *buddy);
void group_come(LwqqClient* lc,LwqqGroup* group);
void discu_come(LwqqClient* lc,LwqqGroup* group);
void ac_need_verify2(LwqqClient* lc, LwqqVerifyCode *code);
void ac_login_stage_1(LwqqClient* lc, LwqqErrorCode *p_err);
void ac_login_stage_2(LwqqAsyncEvent* event,LwqqClient* lc);
void ac_login_stage_3(LwqqClient* lc);
void ac_login_stage_f(LwqqClient* lc);
void ac_friend_avatar(LwqqClient *lc, LwqqBuddy *buddy);
void ac_group_avatar(LwqqClient *lc, LwqqGroup *group);
void ac_group_members(LwqqClient *lc, LwqqGroup *group);
void ac_qq_msg_check(LwqqClient *lc);
void ac_show_confirm_table(LwqqClient* lc, LwqqConfirmTable* table, add_info *info);
void ac_show_messageBox(msg_type type, const char *title, const char *message );
void ac_friend_come(LwqqClient* lc,LwqqBuddy* b);
void ac_rewrite_whole_message_list(LwqqAsyncEvent* ev,qq_account* ac,LwqqGroup* group);
void ac_qq_set_group_name(LwqqGroup* group);
void ac_display_user_info(qq_account* ac, LwqqBuddy* b, char* who);
void slotReceivedInstanceSignal(CallbackObject cb);
void blist_change(LwqqClient* lc,LwqqMsgBlistChange* blist);
void pollMessage();
void afterLogin(LwqqClient* lc);
/**
* get group or disu all members
*/
void slotGetGroupMembers(QString id);
void slotBlock(QString id);
void slotGetUserInfo(QString id, ConType type);
protected:
/**
* This simulates contacts going on and offline in sync with the account's status changes
*/
void updateContactStatus();
/**
* Creates a protocol specific Kopete::Contact subclass and adds it to the supplie
* Kopete::MetaContact
*/
virtual bool createContact(const QString &contactId, Kopete::MetaContact *parentContact);
bool createChatSessionContact( const QString &id, const QString &name );
protected slots:
/**
* Change the account's status. Called by KActions and internally.
*/
void slotGoOnline();
/**
* Change the account's status. Called by KActions and internally.
*/
void slotGoAway();
/**
* Change the account's status. Called by KActions and internally.
*/
void slotGoBusy();
/**
* Change the account's status. Called by KActions and internally.
*/
void slotGoOffline();
/**
* Show webcam. Called by KActions and internally.
*/
void slotShowVideo();
/**
* change the account's status, called by Kactions and internally.
*/
void slotGoHidden();
void slotChangeNick();
private:
/*
* use lwqq library login
*/
int login();
/*
* use lwqq library logout
*/
void logout();
/*
* init client events
*/
void init_client_events(LwqqClient* lc);
/*
* clean all contact
*/
void cleanAll_contacts();
void whisper_message(LwqqClient* lc,LwqqMsgMessage* mmsg);
void receivedGroupMessage(LwqqGroup* group, LwqqMsgMessage *msg);
bool group_is_qun(LwqqGroup *group);
void rewrite_group_msg(const QString &id);
QString stransMsg(const QString &message);
QString m_username;
QString m_password;
Kopete::OnlineStatus m_targetStatus;
/* lwqq async option */
LwqqEvents m_async_opt;
WebqqProtocol *m_protocol;
QTimer *pollTimer;
QByteArray avatarData;
add_info *m_addInfo;
QMap<QString, MsgDataList> m_msgMap;
/*called by login stage1*/
//void login_stage_2(LwqqAsyncEvent* ev,LwqqClient* lc);
};
static void cb_need_verify2(LwqqClient* lc, LwqqVerifyCode **code);
static void cb_login_stage_1(LwqqClient* lc, LwqqErrorCode *err);
static void cb_login_stage_2(LwqqAsyncEvent* event,LwqqClient* lc);
static void cb_login_stage_3(LwqqClient* lc);
static void cb_login_stage_f(LwqqClient* lc);
static void cb_friend_avatar(LwqqClient *lc, LwqqBuddy *buddy);
static void cb_group_avatar(LwqqClient *lc, LwqqGroup *group);
static void cb_group_members(LwqqClient *lc, LwqqGroup *group);
static void cb_qq_msg_check(LwqqClient* lc);
static void cb_show_confirm_table(LwqqClient* lc, LwqqConfirmTable* table, add_info *info);
static void cb_show_messageBox(msg_type type, const char *title, const char *message);
static void cb_friend_come(LwqqClient* lc, LwqqBuddy **buddy);
static void cb_group_come(LwqqClient* lc, LwqqGroup **group);
static void cb_lost_connection(LwqqClient* lc);
static void cb_upload_content_fail(LwqqClient* lc, const char **serv_id, LwqqMsgContent **c, int err);
static void cb_delete_group_local(LwqqClient* lc, const LwqqGroup **g);
static void cb_flush_group_members(LwqqClient* lc, LwqqGroup **g);
static void cb_return_friend_come(LwqqClient* lc,LwqqBuddy* b);
static void cb_rewrite_whole_message_list(LwqqAsyncEvent* ev,qq_account* ac,LwqqGroup* group);
static void cb_qq_set_group_name(LwqqGroup* group);
static void cb_display_user_info(qq_account* ac, LwqqBuddy* b, char *who);
static void set_cgroup_block(LwqqConfirmTable* ct,LwqqClient* lc,LwqqGroup* g);
static void confirm_table_yes(LwqqConfirmTable* table, const char *input, LwqqAnswer answer);
static void confirm_table_no(LwqqConfirmTable* table,const char *input);
static void system_message(LwqqClient* lc,LwqqMsgSystem* system,LwqqBuddy* buddy);
static char* hash_with_local_file(const char* uin,const char* ptwebqq,void* js);
static char* hash_with_remote_file(const char* uin,const char* ptwebqq,void* js);
static void friends_valid_hash(LwqqAsyncEvent* ev,LwqqHashFunc last_hash);
void qq_add_buddy( LwqqClient* lc, const char *username, const char *message);
static void add_friend(LwqqClient* lc,LwqqConfirmTable* c,LwqqBuddy* b,char* message);
static void get_friends_info_retry(LwqqClient* lc,LwqqHashFunc hashtry);
static void write_buddy_to_db(LwqqClient* lc,LwqqBuddy* b);
static void display_self_longnick(LwqqClient* lc);
Kopete::OnlineStatus statusFromLwqqStatus(LwqqStatus status);
#endif