2086
|
1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
2
|
|
3 /*
|
|
4 * $Id: icq.h 2096 2001-07-31 01:00:39Z warmenhoven $
|
|
5 *
|
|
6 * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
|
|
7 * Bill Soudan <soudan@kde.org>
|
|
8 *
|
|
9 * This program is free software; you can redistribute it and/or modify
|
|
10 * it under the terms of the GNU General Public License as published by
|
|
11 * the Free Software Foundation; either version 2 of the License, or
|
|
12 * (at your option) any later version.
|
|
13 *
|
|
14 * This program is distributed in the hope that it will be useful,
|
|
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17 * GNU General Public License for more details.
|
|
18 *
|
|
19 * You should have received a copy of the GNU General Public License
|
|
20 * along with this program; if not, write to the Free Software
|
|
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
22 *
|
|
23 */
|
|
24
|
|
25 #ifndef _ICQ_H_
|
|
26 #define _ICQ_H_
|
|
27
|
|
28 #ifdef HAVE_CONFIG_H
|
|
29 #include <config.h>
|
|
30 #endif
|
|
31
|
|
32 #ifndef _WIN32
|
|
33 #include <sys/time.h>
|
|
34 #include <sys/types.h>
|
|
35 #include <unistd.h>
|
|
36 #else
|
|
37 #include <winsock.h>
|
|
38 #endif /* _WIN32 */
|
|
39
|
|
40 #ifdef __BEOS__
|
|
41 #include <socket.h>
|
|
42 #endif
|
|
43
|
|
44 #include <time.h>
|
|
45
|
|
46 /* ICQLIB version defines */
|
|
47 #define ICQLIBVER 0x010200
|
|
48 #define ICQLIBMAJOR 1
|
|
49 #define ICQLIBMINOR 2
|
|
50 #define ICQLIBMICRO 0
|
|
51
|
|
52
|
|
53 #define ICQ_LOG_OFF 0
|
|
54 #define ICQ_LOG_FATAL 1
|
|
55 #define ICQ_LOG_ERROR 2
|
|
56 #define ICQ_LOG_WARNING 3
|
|
57 #define ICQ_LOG_MESSAGE 4
|
|
58
|
|
59 #define STATUS_OFFLINE (-1L)
|
|
60 #define STATUS_ONLINE 0x0000L
|
|
61 #define STATUS_AWAY 0x0001L
|
|
62 #define STATUS_DND 0x0002L /* 0x13L */
|
|
63 #define STATUS_NA 0x0004L /* 0x05L */
|
|
64 #define STATUS_OCCUPIED 0x0010L /* 0x11L */
|
|
65 #define STATUS_FREE_CHAT 0x0020L
|
|
66 #define STATUS_INVISIBLE 0x0100L
|
|
67
|
|
68 #define ICQ_SEND_THRUSERVER 0
|
|
69 #define ICQ_SEND_DIRECT 1
|
|
70 #define ICQ_SEND_BESTWAY 2
|
|
71
|
|
72 #define ICQ_NOTIFY_SUCCESS 0
|
|
73 #define ICQ_NOTIFY_FAILED 1
|
|
74 #define ICQ_NOTIFY_CONNECTING 2
|
|
75 #define ICQ_NOTIFY_CONNECTED 3
|
|
76 #define ICQ_NOTIFY_SENT 4
|
|
77 #define ICQ_NOTIFY_ACK 5
|
|
78
|
|
79 #define ICQ_NOTIFY_CHATSESSION 7
|
|
80 #define ICQ_NOTIFY_FILESESSION 8
|
|
81
|
|
82 #define ICQ_MAX_MESSAGE_SIZE 1024
|
|
83 #define ICQ_MAX_UDP_MESSAGE_SIZE 480
|
|
84
|
|
85 #ifdef __cplusplus
|
|
86 extern "C" {
|
|
87 #endif /* __cplusplus */
|
|
88
|
|
89 typedef struct
|
|
90 {
|
|
91 const char *name;
|
|
92 unsigned short code;
|
|
93 } icq_ArrayType;
|
|
94
|
|
95 /* dummy forward declarations */
|
|
96 typedef struct icq_LinkPrivate_s icq_LinkPrivate;
|
|
97 typedef struct icq_TCPLink_s icq_TCPLink;
|
|
98 typedef struct icq_FileSession_s icq_FileSession;
|
|
99 typedef struct icq_ChatSession_s icq_ChatSession;
|
|
100 typedef struct icq_Link_s icq_Link;
|
|
101
|
|
102 /* Legacy compatibility - remove for icqlib 2.0.0 */
|
|
103 typedef struct icq_Link_s ICQLINK;
|
|
104 #define icq_ICQLINKNew icq_LinkNew
|
|
105 #define icq_ICQLINKDelete icq_LinkDelete
|
|
106
|
|
107 /**
|
|
108 * The icq_Link structure represents a single connection to the ICQ servers.
|
|
109 * It is returned as the result of an icq_ICQLINKNew function, and contains
|
|
110 * connection-specific parameters such as uin, sockets, current status, etc.
|
|
111 *
|
|
112 * This structure should be considered read-only. Modifying it will cause
|
|
113 * undefined results.
|
|
114 */
|
|
115 struct icq_Link_s
|
|
116 {
|
|
117 /* General parameters */
|
|
118
|
|
119 /** User Identification Number. This is your ICQ 'account' number. */
|
|
120 unsigned long icq_Uin;
|
|
121
|
|
122 /** Our IP as understood by the ICQ server. This will be set once an
|
|
123 * UDP_SRV_LOGIN_REPLY has been received from the ICQ servers, in host
|
|
124 * byteorder. Note this may be different from the actual IP in cases
|
|
125 * such as firewalls, ip masquerading, etc. */
|
|
126 unsigned long icq_OurIP;
|
|
127
|
|
128 /** The UDP port used to connect to the ICQ server, in host byteorder. */
|
|
129 unsigned short icq_OurPort;
|
|
130
|
|
131 /** Our current ICQ status: one of the STATUS_* defines.
|
|
132 * @see icq_StatusUpdate */
|
|
133 unsigned long icq_Status;
|
|
134
|
|
135 /** The password used to log into the ICQ server. */
|
|
136 char *icq_Password;
|
|
137
|
|
138 /** The user's desired nickname. */
|
|
139 char *icq_Nick;
|
|
140
|
|
141 /* UDP stuff */
|
|
142
|
|
143 /** socket used to send and received UDP messages */
|
|
144 int icq_UDPSok;
|
|
145
|
|
146 /** Time, in seconds, that a sent UDP message can go without an ACK from the
|
|
147 * server before being retransmitted. */
|
|
148 int icq_UDPExpireInterval;
|
|
149
|
|
150 /* TCP stuff */
|
|
151
|
|
152 /** TCP listen port, in host byte order. The TCP implementation will listen
|
|
153 * here for new connections from other clients. This is transmitted as
|
|
154 * part of the ICQ login process. */
|
|
155 unsigned short icq_TCPSrvPort;
|
|
156
|
|
157 /** Has TCP been enabled for this connection?
|
|
158 * @see icq_Newicq_Link */
|
|
159 unsigned char icq_UseTCP;
|
|
160
|
|
161 /* SOCKS5 Proxy stuff */
|
|
162
|
|
163 /** Should all network traffic be redirected through a proxy?
|
|
164 * @see icq_SetProxy */
|
|
165 unsigned char icq_UseProxy;
|
|
166
|
|
167 /** Hostname of the SOCKS5 proxy to use. */
|
|
168 char *icq_ProxyHost;
|
|
169
|
|
170 /** IP Address of the SOCKS5 proxy after DNS resolution, in host byteorder. */
|
|
171 unsigned long icq_ProxyIP;
|
|
172
|
|
173 /** Port of the SOCKS5 proxy to use, in host byteorder. */
|
|
174 unsigned short icq_ProxyPort;
|
|
175
|
|
176 /** What's this? :) */
|
|
177 int icq_ProxyAuth;
|
|
178
|
|
179 /** Username used when logging into the proxy. */
|
|
180 char *icq_ProxyName;
|
|
181
|
|
182 /** Password used when logging into the proxy. */
|
|
183 char *icq_ProxyPass;
|
|
184
|
|
185 /** TCP socket used to communicate with the proxy. */
|
|
186 int icq_ProxySok;
|
|
187
|
|
188 unsigned short icq_ProxyOurPort; /* HOST byteorder */
|
|
189 unsigned long icq_ProxyDestIP; /* HOST byteorder */
|
|
190 unsigned short icq_ProxyDestPort; /* HOST byteorder */
|
|
191
|
|
192 /* Begin Callbacks */
|
|
193 void (*icq_Logged)(icq_Link *icqlink);
|
|
194 void (*icq_Disconnected)(icq_Link *icqlink);
|
|
195 void (*icq_RecvMessage)(icq_Link *icqlink, unsigned long uin,
|
|
196 unsigned char hour, unsigned char minute, unsigned char day,
|
|
197 unsigned char month, unsigned short year, const char *msg);
|
|
198 void (*icq_RecvURL)(icq_Link *icqlink, unsigned long uin,
|
|
199 unsigned char hour, unsigned char minute, unsigned char day,
|
|
200 unsigned char month, unsigned short year, const char *url,
|
|
201 const char *descr);
|
|
202 void (*icq_RecvContactList)(icq_Link *icqlink, unsigned long uin,
|
|
203 unsigned char hour, unsigned char minute, unsigned char day,
|
|
204 unsigned char month, unsigned short year, int nr,
|
|
205 const char **contact_uin, const char **contact_nick);
|
|
206 void (*icq_RecvWebPager)(icq_Link *icqlink,unsigned char hour,
|
|
207 unsigned char minute, unsigned char day, unsigned char month,
|
|
208 unsigned short year, const char *nick, const char *email,
|
|
209 const char *msg);
|
|
210 void (*icq_RecvMailExpress)(icq_Link *icqlink,unsigned char hour,
|
|
211 unsigned char minute, unsigned char day, unsigned char month,
|
|
212 unsigned short year, const char *nick, const char *email,
|
|
213 const char *msg);
|
|
214 void (*icq_RecvChatReq)(icq_Link *icqlink, unsigned long uin,
|
|
215 unsigned char hour, unsigned char minute, unsigned char day,
|
|
216 unsigned char month, unsigned short year, const char *descr,
|
|
217 unsigned long seq);
|
|
218 void (*icq_RecvFileReq)(icq_Link *icqlink, unsigned long uin,
|
|
219 unsigned char hour, unsigned char minute, unsigned char day,
|
|
220 unsigned char month, unsigned short year, const char *descr,
|
|
221 const char *filename, unsigned long filesize, unsigned long seq);
|
|
222 void (*icq_RecvAdded)(icq_Link *icqlink, unsigned long uin,
|
|
223 unsigned char hour, unsigned char minute, unsigned char day,
|
|
224 unsigned char month, unsigned short year, const char *nick,
|
|
225 const char *first, const char *last, const char *email);
|
|
226 void (*icq_RecvAuthReq)(icq_Link *icqlink, unsigned long uin,
|
|
227 unsigned char hour, unsigned char minute, unsigned char day,
|
|
228 unsigned char month, unsigned short year, const char *nick,
|
|
229 const char *first, const char *last, const char *email,
|
|
230 const char *reason);
|
|
231 void (*icq_UserFound)(icq_Link *icqlink, unsigned long uin,
|
|
232 const char *nick, const char *first, const char *last,
|
|
233 const char *email, char auth);
|
|
234 void (*icq_SearchDone)(icq_Link *icqlink);
|
|
235 void (*icq_UpdateSuccess)(icq_Link *icqlink);
|
|
236 void (*icq_UpdateFailure)(icq_Link *icqlink);
|
|
237 void (*icq_UserOnline)(icq_Link *icqlink, unsigned long uin,
|
|
238 unsigned long status, unsigned long ip, unsigned short port,
|
|
239 unsigned long real_ip, unsigned char tcp_flag );
|
|
240 void (*icq_UserOffline)(icq_Link *icqlink, unsigned long uin);
|
|
241 void (*icq_UserStatusUpdate)(icq_Link *icqlink, unsigned long uin,
|
|
242 unsigned long status);
|
|
243 void (*icq_RecvAwayMsg)(icq_Link *icqlink, unsigned long id,
|
|
244 const char *msg);
|
|
245 void (*icq_InfoReply)(icq_Link *icqlink, unsigned long uin,
|
|
246 const char *nick, const char *first, const char *last,
|
|
247 const char *email, char auth);
|
|
248 void (*icq_ExtInfoReply)(icq_Link *icqlink, unsigned long uin,
|
|
249 const char *city, unsigned short country_code, char country_stat,
|
|
250 const char *state, unsigned short age, char gender,
|
|
251 const char *phone, const char *hp, const char *about);
|
|
252 void (*icq_WrongPassword)(icq_Link *icqlink);
|
|
253 void (*icq_InvalidUIN)(icq_Link *icqlink);
|
|
254 void (*icq_Log)(icq_Link *icqlink, time_t log_time, unsigned char level,
|
|
255 const char *str);
|
|
256 void (*icq_SrvAck)(icq_Link *icqlink, unsigned short seq);
|
|
257 void (*icq_RequestNotify)(icq_Link *icqlink, unsigned long id,
|
|
258 int type, int arg, void *data);
|
|
259 void (*icq_FileNotify)(icq_FileSession *session, int type, int arg,
|
|
260 void *data);
|
|
261 void (*icq_ChatNotify)(icq_ChatSession *session, int type, int arg,
|
|
262 void *data);
|
|
263 void (*icq_NewUIN)(icq_Link *icqlink, unsigned long uin);
|
|
264 void (*icq_MetaUserFound)(icq_Link *icqlink, unsigned short seq2,
|
|
265 unsigned long uin, const char *nick, const char *first,
|
|
266 const char *last, const char *email, char auth);
|
|
267 void (*icq_MetaUserInfo)(icq_Link *icqlink, unsigned short seq2,
|
|
268 const char *nick, const char *first, const char *last,
|
|
269 const char *pri_eml, const char *sec_eml, const char *old_eml,
|
|
270 const char *city, const char *state, const char *phone, const char *fax,
|
|
271 const char *street, const char *cellular, unsigned long zip,
|
|
272 unsigned short country, unsigned char timezone, unsigned char auth,
|
|
273 unsigned char webaware, unsigned char hideip);
|
|
274 void (*icq_MetaUserWork)(icq_Link *icqlink, unsigned short seq2,
|
|
275 const char *wcity, const char *wstate, const char *wphone,
|
|
276 const char *wfax, const char *waddress, unsigned long wzip,
|
|
277 unsigned short wcountry, const char *company, const char *department,
|
|
278 const char *job, unsigned short occupation, const char *whomepage);
|
|
279 void (*icq_MetaUserMore)(icq_Link *icqlink, unsigned short seq2,
|
|
280 unsigned short age, unsigned char gender, const char *homepage,
|
|
281 unsigned char byear, unsigned char bmonth, unsigned char bday,
|
|
282 unsigned char lang1, unsigned char lang2, unsigned char lang3);
|
|
283 void (*icq_MetaUserAbout)(icq_Link *icqlink, unsigned short seq2,
|
|
284 const char *about);
|
|
285 void (*icq_MetaUserInterests)(icq_Link *icqlink, unsigned short seq2,
|
|
286 unsigned char num, unsigned short icat1, const char *int1,
|
|
287 unsigned short icat2, const char *int2, unsigned short icat3,
|
|
288 const char *int3, unsigned short icat4, const char *int4);
|
|
289 void (*icq_MetaUserAffiliations)(icq_Link *icqlink, unsigned short seq2,
|
|
290 unsigned char anum, unsigned short acat1, const char *aff1,
|
|
291 unsigned short acat2, const char *aff2, unsigned short acat3,
|
|
292 const char *aff3, unsigned short acat4, const char *aff4,
|
|
293 unsigned char bnum, unsigned short bcat1, const char *back1,
|
|
294 unsigned short bcat2, const char *back2, unsigned short bcat3,
|
|
295 const char *back3, unsigned short bcat4, const char *back4);
|
|
296 void (*icq_MetaUserHomePageCategory)(icq_Link *icqlink,
|
|
297 unsigned short seq2, unsigned char num, unsigned short hcat1,
|
|
298 const char *htext1);
|
|
299 /* End Callbacks */
|
|
300
|
|
301 /** Private data pointer. */
|
|
302 icq_LinkPrivate *d;
|
|
303
|
|
304 /** Space for user data */
|
|
305 void *icq_UserData;
|
|
306 };
|
|
307
|
|
308 extern int icq_Russian;
|
|
309 extern unsigned char icq_LogLevel;
|
|
310 extern icq_ArrayType icq_Countries[];
|
|
311 extern icq_ArrayType icq_Genders[];
|
|
312
|
|
313 icq_Link *icq_LinkNew(unsigned long uin, const char *password,
|
|
314 const char *nick, unsigned char useTCP);
|
|
315 void icq_LinkInit(icq_Link *icqlink, unsigned long uin, const char *password,
|
|
316 const char *nick, unsigned char useTCP);
|
|
317 void icq_LinkDestroy(icq_Link *icqlink);
|
|
318 void icq_LinkDelete(icq_Link *icqlink);
|
|
319
|
|
320 void icq_Main(void);
|
|
321 const char *icq_GetCountryName(unsigned short code);
|
|
322 const char *icq_GetMetaOccupationName(unsigned short code);
|
|
323 const char *icq_GetMetaBackgroundName(unsigned short code);
|
|
324 const char *icq_GetMetaAffiliationName(unsigned short code);
|
|
325 const char *icq_GetMetaLanguageName(unsigned short code);
|
|
326
|
|
327 /* Begin icq_Link methods */
|
|
328 void icq_SetProxy(icq_Link *icqlink, const char *phost, unsigned short pport,
|
|
329 int pauth, const char *pname, const char *ppass);
|
|
330 void icq_UnsetProxy(icq_Link *icqlink);
|
|
331
|
|
332 int icq_Connect(icq_Link *icqlink, const char *hostname, int port);
|
|
333 void icq_Disconnect(icq_Link *icqlink);
|
|
334 int icq_GetSok(icq_Link *icqlink);
|
|
335 int icq_GetProxySok(icq_Link *icqlink);
|
|
336 void icq_HandleServerResponse(icq_Link *icqlink);
|
|
337 void icq_HandleProxyResponse(icq_Link *icqlink);
|
|
338 unsigned short icq_KeepAlive(icq_Link *icqlink);
|
|
339 void icq_Login(icq_Link *icqlink, unsigned long status);
|
|
340 void icq_Logout(icq_Link *icqlink);
|
|
341 void icq_SendContactList(icq_Link *icqlink);
|
|
342 void icq_SendVisibleList(icq_Link *icqlink);
|
|
343 void icq_SendInvisibleList(icq_Link *icqlink);
|
|
344 void icq_SendNewUser(icq_Link *icqlink, unsigned long uin);
|
|
345 unsigned long icq_SendMessage(icq_Link *icqlink, unsigned long uin,
|
|
346 const char *text, unsigned char thruSrv);
|
|
347 unsigned long icq_SendURL(icq_Link *icqlink, unsigned long uin, const char *url,
|
|
348 const char *descr, unsigned char thruSrv);
|
|
349 void icq_ChangeStatus(icq_Link *icqlink, unsigned long status);
|
|
350 unsigned short icq_SendInfoReq(icq_Link *icqlink, unsigned long uin);
|
|
351 unsigned short icq_SendExtInfoReq(icq_Link *icqlink, unsigned long uin);
|
|
352 unsigned short icq_SendAuthMsg(icq_Link *icqlink, unsigned long uin);
|
|
353 void icq_SendSearchReq(icq_Link *icqlink, const char *email, const char *nick,
|
|
354 const char* first, const char* last);
|
|
355 void icq_SendSearchUINReq(icq_Link *icqlink, unsigned long uin);
|
|
356
|
|
357 void icq_RegNewUser(icq_Link *icqlink, const char *pass);
|
|
358 unsigned short icq_UpdateUserInfo(icq_Link *icqlink, const char *nick,
|
|
359 const char *first, const char *last, const char *email);
|
|
360 unsigned short icq_UpdateAuthInfo(icq_Link *icqlink, unsigned long auth);
|
|
361 unsigned short icq_UpdateMetaInfoSet(icq_Link *icqlink, const char *nick,
|
|
362 const char *first, const char *last, const char *email,
|
|
363 const char *email2, const char *email3, const char *city,
|
|
364 const char *state, const char *phone, const char *fax, const char *street,
|
|
365 const char *cellular, unsigned long zip, unsigned short cnt_code,
|
|
366 unsigned char cnt_stat, unsigned char emailhide);
|
|
367 unsigned short icq_UpdateMetaInfoHomepage(icq_Link *icqlink, unsigned char age,
|
|
368 const char *homepage, unsigned char year, unsigned char month,
|
|
369 unsigned char day, unsigned char lang1, unsigned char lang2,
|
|
370 unsigned char lang3);
|
|
371 unsigned short icq_UpdateMetaInfoAbout(icq_Link *icqlink, const char *about);
|
|
372 unsigned short icq_UpdateMetaInfoSecurity(icq_Link *icqlink, unsigned char reqauth,
|
|
373 unsigned char webpresence, unsigned char pubip);
|
|
374 unsigned short icq_UpdateNewUserInfo(icq_Link *icqlink, const char *nick,
|
|
375 const char *first, const char *last, const char *email);
|
|
376 unsigned short icq_SendMetaInfoReq(icq_Link *icqlink, unsigned long uin);
|
|
377
|
|
378 void icq_FmtLog(icq_Link *icqlink, int level, const char *fmt, ...);
|
|
379
|
|
380 void icq_ContactAdd(icq_Link *icqlink, unsigned long cuin);
|
|
381 void icq_ContactRemove(icq_Link *icqlink, unsigned long cuin);
|
|
382 void icq_ContactClear(icq_Link *icqlink );
|
|
383 void icq_ContactSetVis(icq_Link *icqlink, unsigned long cuin, unsigned char on);
|
|
384 void icq_ContactSetInvis(icq_Link *icqlink, unsigned long cuin, unsigned char on);
|
|
385
|
|
386 /*** TCP ***/
|
|
387 void icq_TCPMain(icq_Link *icqlink);
|
|
388
|
|
389 void icq_TCPProcessReceived(icq_Link *icqlink);
|
|
390
|
|
391 unsigned long icq_TCPSendMessage(icq_Link *icqlink, unsigned long uin,
|
|
392 const char *message);
|
|
393 unsigned long icq_TCPSendURL(icq_Link *icqlink, unsigned long uin,
|
|
394 const char *message, const char *url);
|
|
395 unsigned long icq_TCPSendAwayMessageReq(icq_Link *icqlink, unsigned long
|
|
396 uin, int status);
|
|
397 unsigned long icq_SendChatRequest(icq_Link *icqlink, unsigned long uin,
|
|
398 const char *message);
|
|
399 void icq_AcceptChatRequest(icq_Link *icqlink, unsigned long uin, unsigned long seq);
|
|
400
|
|
401 void icq_CancelChatRequest(icq_Link *icqlink, unsigned long uin,
|
|
402 unsigned long sequence);
|
|
403 void icq_RefuseChatRequest(icq_Link *icqlink, unsigned long uin,
|
|
404 unsigned long sequence, const char *reason);
|
|
405
|
|
406 /* End icq_Link Methods */
|
|
407
|
|
408 /*** TCP ***/
|
|
409
|
|
410 /** \defgroup ChatSession Chat Session Documentation
|
|
411 * icqlib's 'Chat Session' abstraction represents ICQ's 'chat' function
|
|
412 * between two participants. Multi-party chat is not yet supported.
|
|
413 *
|
|
414 * An icq_ChatSession is instantiated when a 'Chat Request' event is
|
|
415 * accepted. Upon receipt of a 'Chat Accept' event or a call to
|
|
416 * icq_AcceptChatRequest, icqlib will create a new chat session and pass the
|
|
417 * new chat session pointer back to the library client through the
|
|
418 * icq_RequestNotify / ICQ_NOTIFY_CHATSESSION callback. This pointer should
|
|
419 * be stored by the library client, as multiple chat sessions may be in
|
|
420 * progress at any given time. The icq_ChatSession pointer is used as a key
|
|
421 * for all future communication between the library and the library client to
|
|
422 * indicate which icq_ChatSession is currently being dealt with.
|
|
423 *
|
|
424 * icqlib communicates chat session events through use of the icq_ChatNotify
|
|
425 * callback, such as the CHAT_NOTIFY_DATA event. The library client
|
|
426 * can perform operations on a chat session by use of the icq_ChatSession*
|
|
427 * functions, such as sending data to the remote uin by using the
|
|
428 * icq_ChatSessionSendData function.
|
|
429 *
|
|
430 * A new chat session must first undergo an initialization sequence before is
|
|
431 * ready to transmit and receive data. As this initialization is in progress
|
|
432 * the chat session will transition through various statuses depending on
|
|
433 * whether icqlib sent the accept event or it received the accept event.
|
|
434 * Each change in chat session status will be reported to the library
|
|
435 * client through use of the icq_ChatNotify callback, with a @type parameter
|
|
436 * of CHAT_NOTIFY_STATUS and an @a arg parameter of the status value.
|
|
437 *
|
|
438 * Once the chat session initialization is complete, both sides will enter
|
|
439 * the CHAT_STATUS_READY state, indicating that the chat session is
|
|
440 * ready to send and receive data. Received data is reported through the
|
|
441 * icq_ChatNotify callback, with a @type of CHAT_NOTIFY_DATA. The library
|
|
442 * client can send data using icq_ChatSessionSendData or
|
|
443 * icq_ChatSessionSendData_n.
|
|
444 *
|
|
445 * Chat sessions may be terminated at any time, by either side. The library
|
|
446 * client may terminate a chat session by using icq_ChatSessionClose, or
|
|
447 * the remote uin may terminate a chat session. In either instance, a
|
|
448 * CHAT_STATUS_CLOSE event will be reported through the icq_ChatNotify
|
|
449 * callback. Once this callback is complete (e.g. your application's
|
|
450 * callback handler returns), the icq_ChatSession will be deleted by icqlib
|
|
451 * and the session pointer becomes invalid.
|
|
452 */
|
|
453
|
|
454 /** @name Type Constants
|
|
455 * @ingroup ChatSession
|
|
456 * These values are used as the @a type parameter in the icq_ChatNotify
|
|
457 * callback to indicate the type of chat session event that has occured.
|
|
458 * The remaining @a arg and @a data parameters passed by the callback
|
|
459 * are specific to each event; see the documentation for each type
|
|
460 * constant.
|
|
461 */
|
|
462
|
|
463 /*@{*/
|
|
464
|
|
465 /** Status has changed.
|
|
466 * @param arg new session status - one of the CHAT_STATUS_* defines
|
|
467 * @param data unused.
|
|
468 * @ingroup ChatSession
|
|
469 */
|
|
470 #define CHAT_NOTIFY_STATUS 1
|
|
471
|
|
472 /** Data has been received from a chat participant.
|
|
473 * @param arg length of data received
|
|
474 * @param data pointer to buffer containing received data
|
|
475 * @ingroup ChatSession
|
|
476 */
|
|
477 #define CHAT_NOTIFY_DATA 2
|
|
478
|
|
479 /** Session has been closed, either automatically by icqlib or
|
|
480 * explicitly by a call to icq_ChatSessionClose.
|
|
481 * @param arg unused
|
|
482 * @param data unused
|
|
483 * @ingroup ChatSession
|
|
484 */
|
|
485 #define CHAT_NOTIFY_CLOSE 3
|
|
486
|
|
487 /*@}*/
|
|
488
|
|
489 /** @name Status Constants
|
|
490 * @ingroup ChatSession
|
|
491 * These constants are used as the @a arg parameter during in the
|
|
492 * icq_ChatNotify/CHAT_NOTIFY_STATUS callback to indicate the
|
|
493 * new status of the chat session.
|
|
494 */
|
|
495
|
|
496 /*@{*/
|
|
497
|
|
498 /** icqlib is listening for a chat connection from the remote uin.
|
|
499 * @ingroup ChatSession
|
|
500 */
|
|
501 #define CHAT_STATUS_LISTENING 1
|
|
502
|
|
503 /** A connection has been established with the remote uin.
|
|
504 * @ingroup ChatSession
|
|
505 */
|
|
506 #define CHAT_STATUS_CONNECTED 3
|
|
507
|
|
508 /** icqlib is currently waiting for the remote uin to send the chat
|
|
509 * initialization packet which contains the remote uin's chat handle.
|
|
510 * @ingroup ChatSession
|
|
511 */
|
|
512 #define CHAT_STATUS_WAIT_NAME 4
|
|
513
|
|
514 /** icqlib is currently waiting for the remote uin to send the chat
|
|
515 * initialization packet which contains the remote uin's font information.
|
|
516 * @ingroup ChatSession
|
|
517 */
|
|
518 #define CHAT_STATUS_WAIT_FONT 6
|
|
519
|
|
520 /** A connection to the chat session port of the remote uin is in
|
|
521 * progress.
|
|
522 * @ingroup ChatSession
|
|
523 */
|
|
524 /* chat session statuses - request sender */
|
|
525 #define CHAT_STATUS_CONNECTING 2
|
|
526
|
|
527 /** icqlib is currently waiting for the remote uin to send the chat
|
|
528 * initialization packet which contains the remote uin's chat handle
|
|
529 * and font information.
|
|
530 * @ingroup ChatSession
|
|
531 */
|
|
532 #define CHAT_STATUS_WAIT_ALLINFO 5
|
|
533
|
|
534 /** Chat session initialization has completed successfully. The session
|
|
535 * is now fully established - both sides can begin to send data and
|
|
536 * should be prepared to accept data.
|
|
537 * @ingroup ChatSession
|
|
538 */
|
|
539 #define CHAT_STATUS_READY 7
|
|
540
|
|
541 /*@}*/
|
|
542
|
|
543 /** Chat Session state structure. This structure is used internally by
|
|
544 * icqlib to maintain state information about each chat session. All
|
|
545 * members should be considered read-only! Use the appropriate
|
|
546 * icq_ChatSession* function to change the state of a chat session,
|
|
547 * results are undefined if your application attempts to manipulate this
|
|
548 * structure itself.
|
|
549 */
|
|
550 struct icq_ChatSession_s {
|
|
551
|
|
552 /** For internal icqlib use only. */
|
|
553 unsigned long id;
|
|
554
|
|
555 /** Current status of the chat session. See 'Status Constants' group. */
|
|
556 int status;
|
|
557
|
|
558 /** ICQLINK that spawned this chat session. */
|
|
559 icq_Link *icqlink;
|
|
560
|
|
561 /** For internal icqlib use only. */
|
|
562 icq_TCPLink *tcplink;
|
|
563
|
|
564 /** Remote uin number. */
|
|
565 unsigned long remote_uin;
|
|
566
|
|
567 /** Remote uin's chat handle. */
|
|
568 char remote_handle[64];
|
|
569
|
|
570 /** Space for user data */
|
|
571 void *user_data;
|
|
572 };
|
|
573
|
|
574 void icq_ChatSessionClose(icq_ChatSession *session);
|
|
575 void icq_ChatSessionSendData(icq_ChatSession *session, const char *data);
|
|
576 void icq_ChatSessionSendData_n(icq_ChatSession *session, const char *data,
|
|
577 int length);
|
|
578
|
|
579
|
|
580 /* FileNotify constants */
|
|
581 #define FILE_NOTIFY_DATAPACKET 1
|
|
582 #define FILE_NOTIFY_STATUS 2
|
|
583 #define FILE_NOTIFY_CLOSE 3
|
|
584 #define FILE_NOTIFY_NEW_SPEED 4
|
|
585 #define FILE_NOTIFY_STOP_FILE 5
|
|
586
|
|
587 /* file session statuses- request receiver */
|
|
588 #define FILE_STATUS_LISTENING 1
|
|
589 #define FILE_STATUS_CONNECTED 3
|
|
590
|
|
591 /* file session statuses- request sender */
|
|
592 #define FILE_STATUS_CONNECTING 2
|
|
593
|
|
594 #define FILE_STATUS_INITIALIZING 4
|
|
595
|
|
596 #define FILE_STATUS_NEXT_FILE 5
|
|
597
|
|
598 /* once negotiation is complete, file session enters proper state */
|
|
599 #define FILE_STATUS_SENDING 6
|
|
600 #define FILE_STATUS_RECEIVING 7
|
|
601
|
|
602 struct icq_FileSession_s {
|
|
603
|
|
604 unsigned long id;
|
|
605 int status;
|
|
606 icq_Link *icqlink;
|
|
607 icq_TCPLink *tcplink;
|
|
608
|
|
609 int direction;
|
|
610
|
|
611 unsigned long remote_uin;
|
|
612 char remote_handle[64];
|
|
613
|
|
614 char **files;
|
|
615 int total_files;
|
|
616 int current_file_num;
|
|
617 unsigned long total_bytes;
|
|
618 unsigned long total_transferred_bytes;
|
|
619
|
|
620 char working_dir[512];
|
|
621 char current_file[64];
|
|
622 int current_fd;
|
|
623 unsigned long current_file_size;
|
|
624 unsigned long current_file_progress;
|
|
625
|
|
626 int current_speed;
|
|
627
|
|
628 /** Space for user data */
|
|
629 void *user_data;
|
|
630 };
|
|
631
|
|
632 icq_FileSession *icq_AcceptFileRequest(icq_Link *icqlink, unsigned long uin,
|
|
633 unsigned long sequence);
|
|
634 unsigned long icq_SendFileRequest(icq_Link *icqlink, unsigned long uin,
|
|
635 const char *message, char **files);
|
|
636 void icq_CancelFileRequest(icq_Link *icqlink, unsigned long uin,
|
|
637 unsigned long sequence);
|
|
638 void icq_RefuseFileRequest(icq_Link *icqlink, unsigned long uin,
|
|
639 unsigned long sequence, const char *reason);
|
|
640
|
|
641 void icq_FileSessionSetSpeed(icq_FileSession *p, int speed);
|
|
642 void icq_FileSessionClose(icq_FileSession *p);
|
|
643 void icq_FileSessionSetWorkingDir(icq_FileSession *p, const char *dir);
|
|
644 void icq_FileSessionSetFiles(icq_FileSession *p, char **files);
|
|
645
|
|
646 /* Socket Manager */
|
|
647
|
|
648 #define ICQ_SOCKET_READ 0
|
|
649 #define ICQ_SOCKET_WRITE 1
|
|
650 #define ICQ_SOCKET_MAX 2
|
|
651
|
|
652 extern void (*icq_SocketNotify)(int socket_fd, int type, int status);
|
|
653
|
|
654 void icq_HandleReadySocket(int socket_fd, int type);
|
|
655
|
|
656 /* Timeout Manager */
|
|
657
|
|
658 extern void (*icq_SetTimeout)(long interval);
|
|
659
|
|
660 void icq_HandleTimeout(void);
|
|
661
|
|
662 #ifdef __cplusplus
|
|
663 }
|
|
664 #endif /* __cplusplus */
|
|
665
|
|
666 #endif /* _ICQ_H_ */
|