forked from fchat-pidgin/fchat-pidgin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
f-list.h
434 lines (365 loc) · 13.7 KB
/
f-list.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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
/*
* F-List Pidgin - a libpurple protocol plugin for F-Chat
*
* Copyright 2011 F-List Pidgin developers.
*
* This file is part of F-List Pidgin.
*
* F-List Pidgin 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.
*
* F-List Pidgin is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with F-List Pidgin. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef FLIST_H
#define FLIST_H
#include <glib.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <glib/gi18n.h>
#include <sys/types.h>
#include <unistd.h>
#ifdef _WIN32
# include "win32dep.h"
# define dlopen(a,b) LoadLibrary(a)
# define RTLD_LAZY
# define dlsym(a,b) GetProcAddress(a,b)
# define dlclose(a) FreeLibrary(a)
#else
# include <arpa/inet.h>
# include <dlfcn.h>
# include <netinet/in.h>
# include <sys/socket.h>
#endif
//json-glib sources
#include <json-glib/json-glib.h>
//libpurple sources
#include "util.h"
#include "debug.h"
#include "cmds.h"
#include "request.h"
#include "smiley.h"
#include "savedstatuses.h"
typedef struct FListCharacter_ FListCharacter;
typedef struct FListAccount_ FListAccount;
typedef struct FListRoomlistChannel_ FListRoomlistChannel;
typedef struct FListKinks_ FListKinks;
typedef struct FListProfiles_ FListProfiles;
typedef struct FListWebRequestData_ FListWebRequestData;
typedef struct FListFriends_ FListFriends;
#define FLIST_CLIENT_NAME "F-List Pidgin"
#define FLIST_PLUGIN_VERSION "0.6.0"
#define USER_AGENT "Pidgin F-Chat " FLIST_PLUGIN_VERSION
#define FLIST_PLUGIN_ID "prpl-flist"
#define FLIST_PORT_SECURE 9799
#define GLOBAL_NAME "#FList"
#define FLIST_DEBUG "flist"
#define FLIST_PIDGIN_CHANNEL "ADH-1509b63f1b1a98c79ab9"
#define FLIST_PIDGIN_UPDATE_URL "https://fchat-pidgin.github.io/version/stable"
#define FLIST_PIDGIN_RELEASE_URL "https://github.com/fchat-pidgin/fchat-pidgin/releases/latest"
#define FLIST_RPAD_DEFAULT_BACKGROUND "#d4ffd0"
#define CONVO_SHOW_CHAT "CONVO_SHOW_CHAT"
#define CONVO_SHOW_ADS "CONVO_SHOW_ADS"
#define CHANNEL_JOIN_TIMEOUT (5*(G_USEC_PER_SEC))
#define FLIST_STATUS_MESSAGE_KEY "message"
#define CHANNEL_COMPONENTS_NAME "channel"
#define FLIST_CHANNEL_INVITE "CIU"
#define FLIST_REQUEST_CHANNEL_BANLIST "CBL"
#define FLIST_REQUEST_CHANNEL_LIST "CHA"
#define FLIST_REQUEST_PRIVATE_CHANNEL_LIST "ORS"
#define FLIST_REQUEST_CHANNEL_OPS "COL"
#define FLIST_CHANNEL_BAN "CBU"
#define FLIST_CHANNEL_UNBAN "CUB"
#define FLIST_CHANNEL_KICK "CKU"
#define FLIST_CHANNEL_ADD_OP "COA"
#define FLIST_CHANNEL_REMOVE_OP "COR"
#define FLIST_CHANNEL_CREATE "CCR"
#define FLIST_CHANNEL_TIMEOUT "CTU"
#define FLIST_CHANNEL_SET_MODE "RMO"
#define FLIST_SET_CHANNEL_DESCRIPTION "CDS"
#define FLIST_SET_CHANNEL_MODE "RMO"
#define FLIST_SET_CHANNEL_OWNER "CSO"
#define FLIST_SET_CHANNEL_STATUS "RST"
#define FLIST_SET_STATUS "STA"
#define FLIST_CHANNEL_JOIN "JCH"
#define FLIST_ROLL_DICE "RLL"
#define FLIST_CHANNEL_LEAVE "LCH"
#define FLIST_REQUEST_CHANNEL_MESSAGE "MSG"
#define FLIST_CHANNEL_ADVERSTISEMENT "LRP"
#define FLIST_KINK_SEARCH "FKS"
#define FLIST_REQUEST_PRIVATE_MESSAGE "PRI"
#define FLIST_REQUEST_CHARACTER_KINKS "KIN"
#define FLIST_REQUEST_PROFILE "PRO"
#define FLIST_PING "PIN"
#define FLIST_NOTIFY_TYPING "TPN"
#define FLIST_CHANNEL_GET_BANLIST "CBL"
#define FLIST_IGNORE "IGN"
#define FLIST_ALERT_STAFF "SFC"
/* admin commands */
#define FLIST_ADD_GLOBAL_OPERATOR "AOP"
#define FLIST_REMOVE_GLOBAL_OPERATOR "DOP"
#define FLIST_BROADCAST "BRO"
#define FLIST_PUBLIC_CHANNEL_CREATE "CRC"
#define FLIST_PUBLIC_CHANNEL_DELETE "KIC"
/* more */
#define FLIST_GLOBAL_KICK "KIK"
#define FLIST_GLOBAL_ACCOUNT_BAN "ACB"
#define FLIST_GLOBAL_IP_BAN "IPB"
#define FLIST_GLOBAL_UNBAN "UBN"
#define FLIST_GLOBAL_TIMEOUT "TMO"
#define FLIST_REWARD "RWD"
#define FLIST_REQUEST_PENDING_REPORTS "PCR"
#define FLIST_REQUEST_UPTIME "UPT"
#define LOGIN_TIMEOUT 5000
#define FLIST_SCHEME "https://"
#define FLIST_DOMAIN "www.f-list.net"
#define FLIST_CHAT_SERVER "chat.f-list.net"
#define FLIST_SUFFIX_DOMAIN "f-list.net"
#define FLIST_URL FLIST_SCHEME FLIST_DOMAIN "/"
#define FLIST_URL_CHARACTER FLIST_URL "c/%s"
#define FLIST_URL_NEWSPOST FLIST_URL "newspost/%d/"
#define FLIST_URL_CHANGELOG FLIST_URL "log.php?id=%d"
#define FLIST_URL_NOTE FLIST_URL "view_note.php?note_id=%d"
#define FLIST_URL_BUGREPORT FLIST_URL "view_bugreport.php?id=%d"
#define FLIST_URL_HELPDESKTICKET FLIST_URL "view_ticket.php?id=%d"
#define FLIST_URL_FEATUREREQUEST FLIST_URL "vote.php?fid=%d"
#define FLIST_URL_GETLOG FLIST_URL "fchat/getLog.php?log=%d"
#define FLIST_URL_COMMENT_ANCHOR "#Comment%d"
#define FLIST_URL_NEWSPOST_COMMENT FLIST_URL_NEWSPOST FLIST_URL_COMMENT_ANCHOR
#define FLIST_URL_BUGREPORT_COMMENT FLIST_URL_BUGREPORT FLIST_URL_COMMENT_ANCHOR
#define FLIST_URL_CHANGELOG_COMMENT FLIST_URL_CHANGELOG FLIST_URL_COMMENT_ANCHOR
#define FLIST_URL_FEATURE_COMMENT FLIST_URL_FEATUREREQUEST FLIST_URL_COMMENT_ANCHOR
enum FListConnectionStatus_ {
FLIST_OFFLINE,
FLIST_CONNECT,
FLIST_HANDSHAKE,
FLIST_IDENTIFY,
FLIST_ONLINE
};
enum FListFlags_ {
FLIST_FLAG_GLOBAL_OP = 0x01,
FLIST_FLAG_CHANNEL_OP = 0x02,
FLIST_FLAG_CHANNEL_FOUNDER = 0x04,
FLIST_FLAG_ADMIN = 0x08
};
enum FListStatus_ {
FLIST_STATUS_AVAILABLE,
FLIST_STATUS_LOOKING,
FLIST_STATUS_BUSY,
FLIST_STATUS_DND,
FLIST_STATUS_CROWN,
FLIST_STATUS_AWAY,
FLIST_STATUS_IDLE,
FLIST_STATUS_OFFLINE,
FLIST_STATUS_UNKNOWN /* if we don't recognize the status string */
};
enum FListGender_ { /* flags make for quick comparisons */
FLIST_GENDER_NONE = 0x1,
FLIST_GENDER_MALE = 0x2,
FLIST_GENDER_FEMALE = 0x4,
FLIST_GENDER_HERM = 0x8,
FLIST_GENDER_TRANSGENDER = 0x10,
FLIST_GENDER_SHEMALE = 0x20,
FLIST_GENDER_MALEHERM = 0x40,
FLIST_GENDER_CUNTBOY = 0x80,
FLIST_GENDER_UNKNOWN = 0x100
};
enum FListChannelMode_ {
CHANNEL_MODE_BOTH = 0x0,
CHANNEL_MODE_ADS_ONLY = 0x01,
CHANNEL_MODE_CHAT_ONLY = 0x02,
CHANNEL_MODE_UNKNOWN = 0x10
};
enum FListFriendStatus_ {
FLIST_NOT_FRIEND = 0x0, /* no friend status */
FLIST_PENDING_OUT_FRIEND = 0x1, /* awaiting his authorization */
FLIST_PENDING_IN_FRIEND = 0x2, /* needs your authorization */
FLIST_MUTUAL_FRIEND = 0x4, /* mutual friend */
FLIST_FRIEND_STATUS_UNKNOWN = 0x10
};
enum FListFriendsRequestType_ {
FLIST_FRIEND_REQUEST,
FLIST_FRIEND_CANCEL,
FLIST_FRIEND_REMOVE,
FLIST_BOOKMARK_ADD,
FLIST_BOOKMARK_REMOVE,
FLIST_FRIEND_AUTHORIZE,
FLIST_FRIEND_DENY,
FLIST_FRIENDS_UPDATE
};
enum FListIgnoreActionType_ {
FLIST_NODE_IGNORE,
FLIST_NODE_UNIGNORE
};
typedef enum FListFlags_ FListFlags;
typedef enum FListGender_ FListGender;
typedef enum FListStatus_ FListStatus;
typedef enum FListChannelMode_ FListChannelMode;
typedef enum FListFriendStatus_ FListFriendStatus;
typedef enum FListFriendsRequestType_ FListFriendsRequestType;
typedef enum FListConnectionStatus_ FListConnectionStatus;
typedef enum FListIgnoreActionType_ FListIgnoreActionType;
/* gender conversion */
GSList *flist_get_gender_list();
FListGender flist_parse_gender(const gchar *gender_string);
const gchar *flist_format_gender(FListGender gender);
const gchar *flist_format_gender_color(FListGender gender);
const gchar *flist_gender_color(FListGender gender);
/* status conversion */
GSList *flist_get_status_list();
FListStatus flist_parse_status(const gchar *status_string);
const gchar *flist_format_status(FListStatus status);
const gchar *flist_internal_status(FListStatus status);
/* channel mode conversion */
FListChannelMode flist_parse_channel_mode(const gchar *);
/* friend status conversion */
const gchar *flist_format_friend_status(FListFriendStatus);
/* groups */
PurpleGroup *flist_get_filter_group(FListAccount*);
PurpleGroup *flist_get_bookmarks_group(FListAccount*);
PurpleGroup *flist_get_friends_group(FListAccount*);
PurpleGroup *flist_get_chat_group(FListAccount*);
PurpleGroup *flist_get_im_group(FListAccount*);
PurpleTypingState flist_typing_state(const gchar *state);
const gchar *flist_typing_state_string(PurpleTypingState state);
GList *flist_status_types(PurpleAccount *account);
void flist_g_list_free(GList *to_free);
void flist_g_list_free_full(GList *to_free, GDestroyNotify f);
void flist_g_slist_free_full(GSList *to_free, GDestroyNotify f);
GSList *flist_g_slist_intersect_and_free(GSList *list1, GSList *list2);
guint flist_str_hash(const char *);
gboolean flist_str_equal(const char *, const char *);
gint flist_strcmp(const char *nick1, const char *nick2);
const char *flist_normalize(const PurpleAccount *, const char *);
PurpleChat *flist_get_chat(FListAccount*, const gchar*);
void flist_remove_chat(FListAccount*, const gchar*);
gint json_object_get_parse_int_member(JsonObject *, const gchar *, gboolean *success);
gint json_array_get_parse_int_element(JsonArray *, guint, gboolean *success);
FListCharacter *flist_get_character(FListAccount *, const gchar *identity);
GSList *flist_get_all_characters(FListAccount *);
const gchar *flist_serialize_account(PurpleAccount *);
PurpleAccount *flist_deserialize_account(const gchar*);
gboolean flist_get_channel_show_ads(FListAccount *, const gchar *);
gboolean flist_get_channel_show_chat(FListAccount *, const gchar *);
void flist_set_channel_show_ads(FListAccount *, const gchar *, gboolean);
void flist_set_channel_show_chat(FListAccount *, const gchar *, gboolean);
struct FListGenderStruct_ {
FListGender gender;
const gchar *name;
const gchar *display_name;
const gchar *color;
const gchar *colored_name;
};
struct FListCharacter_ {
gchar* name;
FListGender gender;
FListStatus status;
gchar* status_message; /* this is stored html-escaped */
};
struct FListRoomlistChannel_ {
gchar *name;
gchar *title;
gboolean is_public;
guint users;
};
struct FListAccount_ {
PurpleAccount *pa;
PurpleConnection *pc;
GHashTable *global_ops; //hash table of global operators
GHashTable *all_characters; //hash table of FListCharacter, all that are online
gint characters_remaining;
gboolean online; //whether or not we've set pidgin to say we're online
guint32 character_count; //total number of characters online, should be count(all_characters)
gchar *username;
gchar *character;
gchar *password;
PurpleUtilFetchUrlData *url_request;
gchar *fls_cookie;
FListConnectionStatus connection_status;
/* for tickets */
guint ticket_timer;
FListWebRequestData *ticket_request;
/* cookies */
GHashTable *cookies; //Website cookies, needed for log uploading
/* connection data */
PurpleSslConnection *ssl_con;
gchar *rx_buf;
gsize rx_len;
int fd;
int input_handle;
GByteArray *frame_buffer;
PurpleRoomlist *roomlist;
gboolean input_request;
guint ping_timeout_handle;
/* Server variables */
gsize chat_max;
gsize priv_max;
gsize lfrp_max;
gfloat lfrp_flood;
gfloat msg_flood;
GSList *icon_blacklist;
guint32 permissions;
/* for the channel subsystem */
GHashTable *chat_table; /* a hash table of open PurpleConvChat */
GHashTable *chat_timestamp; /* the last time we attempted to join the chat */
/* for the icon subsystem */
GSList *icon_requests;
GSList *icon_request_queue;
/* connection options */
gchar *server_address;
gint server_port;
/* filter subsystem */
gchar *filter_channel;
gboolean filter_looking;
/* kinks subsystem */
FListKinks *flist_kinks;
/* profile subsystem */
FListProfiles *flist_profiles;
/* friends subsystem */
gboolean sync_bookmarks;
gboolean sync_friends;
FListFriends *flist_friends;
/* status handling */
gboolean sync_status;
/* ignore list */
GList *ignore_list;
/* command conversation output */
PurpleConversationType saved_type;
gchar *saved_name;
/* other options */
gboolean receive_notifications;
gboolean debug_mode;
gboolean show_own_character;
};
//f-list sources
#include "f-list_callbacks.h"
#include "f-list_commands.h"
#include "f-list_autobuddy.h"
#include "f-list_connection.h"
#include "f-list_icon.h"
#include "f-list_kinks.h"
#include "f-list_profile.h"
#include "f-list_bbcode.h"
#include "f-list_admin.h"
#include "f-list_channels.h"
#include "f-list_json.h"
#include "f-list_friends.h"
#include "f-list_status.h"
#include "f-list_rtb.h"
#include "f-list_ignore.h"
#include "f-list_report.h"
#include "f-list_util.h"
#include "f-list_pidgin.h"
#ifndef DISABLE_NSSFIX
#include "f-list_nssfix.h"
#endif
#endif