-
Notifications
You must be signed in to change notification settings - Fork 2
/
tlen.h
190 lines (156 loc) · 6.3 KB
/
tlen.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
/*
* Copyright (c) 2005-2009 Aleksander Piotrowski <aleksander.piotrowski@nic.com.pl>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef TLEN_H
#define TLEN_H
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include <glib.h>
#include <fcntl.h>
#define PURPLE_PLUGINS
/* from libpurple/internal.h */
#ifndef G_GNUC_NULL_TERMINATED
# if __GNUC__ >= 4
# define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
# else
# define G_GNUC_NULL_TERMINATED
# endif /* __GNUC__ >= 4 */
#endif /* G_GNUC_NULL_TERMINATED */
/* pidgin headers */
#include <version.h>
#include <xmlnode.h>
#include <account.h>
#include <accountopt.h>
#include <debug.h>
#include <request.h>
#include <cipher.h>
#ifdef ENABLE_NLS
# include <locale.h>
# include <libintl.h>
# define _(x) gettext(x)
# ifdef gettext_noop
# define N_(String) gettext_noop (String)
# else
# define N_(String) (String)
# endif
#else
# define N_(String) (String)
# define _(x) ((char *)x)
#endif
#define TLEN_VERSION "20101112"
#define SERVER_ADDRESS "s1.tlen.pl"
#define SERVER_PORT 443
#define HUB_ADDRESS "idi.tlen.pl"
#define HUB_PORT 80
#define TLEN_BUFSIZE 16000
#define TLEN_LOGIN_QUERY "<s v='7'>"
#define TLEN_AUTH_QUERY "<iq type='set' id='%s'><query xmlns='jabber:iq:auth'>" \
"<username>%s</username><host>tlen.pl</host><digest>%s</digest><resource>t</resource>" \
"</query></iq>"
#define TLEN_GETROSTER_QUERY "<iq type='get' id='GetRoster'><query xmlns='jabber:iq:roster'></query></iq>"
#define TLEN_GETCONFIG_QUERY "<iq to='tcfg' type='get' id='TcfgGetAfterLoggedIn'></iq>"
#define TLEN_KEEPALIVE " \t "
#define TLEN_MESSAGE "<message to='%s' type='chat'><body>%s</body></message>"
#define TLEN_PRESENCE_STATE "<presence><show>%s</show><status>%s</status></presence>"
#define TLEN_PRESENCE "<presence><show>%s</show></presence>"
#define TLEN_PRESENCE_INVISIBLE "<presence type='invisible'></presence>"
#define TLEN_PRESENCE_SUBSCRIBE "<presence to='%s' type='subscribe'/>"
#define TLEN_PRESENCE_UNSUBSCRIBE "<presence to='%s' type='unsubscribe'/>"
#define TLEN_PRESENCE_ACCEPT "<presence to='%s' type='subscribed'/>"
#define TLEN_NOTIF_TYPING "<m to='%s' tp='%c'/>"
#define TLEN_BUDDY_REMOVE "<iq type='set'><query xmlns='jabber:iq:roster'><item jid='%s' subscription='remove'></item></query></iq>"
/* XXX: tutaj potrzebne sa jeszcze tagi <group> */
#define TLEN_BUDDY_ADD "<iq type='set' id='%s'><query xmlns='jabber:iq:roster'><item name='%s' jid='%s'><group>%s</group></item></query></iq>"
#define TLEN_BUDDY_ADD_WOGRP "<iq type='set' id='%s'><query xmlns='jabber:iq:roster'><item name='%s' jid='%s'></item></query></iq>"
#define TLEN_BUDDY_SET "<iq type='set'><query xmlns='jabber:iq:roster'><item jid='%s' name='%s'><group>%s</group></item></query></iq>"
#define TLEN_BUDDY_UNALIAS "<iq type='set'><query xmlns='jabber:iq:roster'><item jid='%s'><group>%s</group></item></query></iq>"
#define TLEN_GET_PUBDIR_MYSELF "<iq type='get' id='tr' to='tuba'><query xmlns='jabber:iq:register'></query></iq>"
#define TLEN_SET_PUBDIR_HEADER "<iq type='set' id='tw' to='tuba'><query xmlns='jabber:iq:register'>"
#define TLEN_SET_PUBDIR_FOOTER "</query></iq>"
#define TLEN_SEARCH_PUBDIR_HEADER "<iq type='get' id='%s' to='tuba'><query xmlns='jabber:iq:search'>"
#define TLEN_SEARCH_PUBDIR_FOOTER "</query></iq>"
#define UC_INVISIBLE_TEXT "invisible"
#define UC_UNAVAILABLE_TEXT "offline"
#define UC_UNAVAILABLE_DESCR "Offline"
#define UC_AVAILABLE 2
#define UC_AVAILABLE_TEXT "available"
#define UC_AVAILABLE_DESCR "Available"
#define UC_AWAY 3
#define UC_AWAY_TEXT "away"
#define UC_AWAY_DESCR "Away"
#define UC_CHAT 4
#define UC_CHAT_TEXT "chat"
#define UC_CHAT_DESCR "Chatty"
#define UC_XA 5
#define UC_XA_TEXT "xa"
#define UC_XA_DESCR "Extended away"
#define UC_DND 6
#define UC_DND_TEXT "dnd"
#define UC_DND_DESCR "Do not disturb"
#define SUB_BOTH 1
#define SUB_NONE 2
#define SUB_TO 3
typedef struct {
int subscription; /* Subscription status */
} TlenBuddy;
typedef struct {
PurpleConnection *gc;
gint fd;
char session_id[100]; /* Session ID used in many other places */
char *avatar_token; /* token used to access avatar web interface */
GMarkupParseContext *context; /* Parser context used to parse protocol traffic */
xmlnode *xml; /* XML object created from data sent by server */
int roster_parsed; /* Was roster already parsed? If not, then we ignore add_buddy calls */
PurpleAccount *account;
char *server;
int port;
char *user;
char *password;
/* Chat stuff */
PurpleRoomlist *roomlist;
GHashTable *room_hash; /* Temporary hashtable for the roomlist */
GHashTable *chat_hash; /* This is where we keep open chat rooms */
GHashTable *room_create_hash; /* Room creation request id hash */
} TlenSession;
typedef struct {
PurpleConnection *gc;
char *from;
} TlenRequest;
typedef struct {
char *tag;
char *desc;
int format;
int edit; /* Can user edit this value? */
int display; /* Should this value be shown in pubdir search results? */
} TlenUserInfoElement;
#define TlenUIE_RO 0
#define TlenUIE_RW 1
#define TlenUIE_DONTSHOW 0
#define TlenUIE_SHOW 1
#define TlenUIE_INT 0
#define TlenUIE_STR 1
#define TlenUIE_BOOL 2
#define TlenUIE_CHOICE 3
#define TlenUIE_MODE_EDIT 0
#define TlenUIE_MODE_SEARCH 1
typedef struct TlenUserInfo_s TlenUserInfo;
int tlen_send(TlenSession *tlen, char *command);
char * tlen_decode_and_convert(const char *str);
char * tlen_encode_and_convert(const char *str);
#endif /* TLEN_H */