1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
4 * $Id: icq.h 2096 2001-07-31 01:00:39Z warmenhoven $
6 * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
7 * Bill Soudan <soudan@kde.org>
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.
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.
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.
34 #include <sys/types.h>
46 /* ICQLIB version defines */
47 #define ICQLIBVER 0x010200
54 #define ICQ_LOG_FATAL 1
55 #define ICQ_LOG_ERROR 2
56 #define ICQ_LOG_WARNING 3
57 #define ICQ_LOG_MESSAGE 4
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
68 #define ICQ_SEND_THRUSERVER 0
69 #define ICQ_SEND_DIRECT 1
70 #define ICQ_SEND_BESTWAY 2
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
79 #define ICQ_NOTIFY_CHATSESSION 7
80 #define ICQ_NOTIFY_FILESESSION 8
82 #define ICQ_MAX_MESSAGE_SIZE 1024
83 #define ICQ_MAX_UDP_MESSAGE_SIZE 480
87 #endif /* __cplusplus */
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
;
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
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.
112 * This structure should be considered read-only. Modifying it will cause
117 /* General parameters */
119 /** User Identification Number. This is your ICQ 'account' number. */
120 unsigned long icq_Uin
;
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
;
128 /** The UDP port used to connect to the ICQ server, in host byteorder. */
129 unsigned short icq_OurPort
;
131 /** Our current ICQ status: one of the STATUS_* defines.
132 * @see icq_StatusUpdate */
133 unsigned long icq_Status
;
135 /** The password used to log into the ICQ server. */
138 /** The user's desired nickname. */
143 /** socket used to send and received UDP messages */
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
;
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
;
157 /** Has TCP been enabled for this connection?
158 * @see icq_Newicq_Link */
159 unsigned char icq_UseTCP
;
161 /* SOCKS5 Proxy stuff */
163 /** Should all network traffic be redirected through a proxy?
164 * @see icq_SetProxy */
165 unsigned char icq_UseProxy
;
167 /** Hostname of the SOCKS5 proxy to use. */
170 /** IP Address of the SOCKS5 proxy after DNS resolution, in host byteorder. */
171 unsigned long icq_ProxyIP
;
173 /** Port of the SOCKS5 proxy to use, in host byteorder. */
174 unsigned short icq_ProxyPort
;
176 /** What's this? :) */
179 /** Username used when logging into the proxy. */
182 /** Password used when logging into the proxy. */
185 /** TCP socket used to communicate with the proxy. */
188 unsigned short icq_ProxyOurPort
; /* HOST byteorder */
189 unsigned long icq_ProxyDestIP
; /* HOST byteorder */
190 unsigned short icq_ProxyDestPort
; /* HOST byteorder */
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
,
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
,
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
,
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
,
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
,
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
,
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
,
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
,
261 void (*icq_ChatNotify
)(icq_ChatSession
*session
, int type
, int arg
,
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
,
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
,
301 /** Private data pointer. */
304 /** Space for user data */
308 extern int icq_Russian
;
309 extern unsigned char icq_LogLevel
;
310 extern icq_ArrayType icq_Countries
[];
311 extern icq_ArrayType icq_Genders
[];
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
);
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
);
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
);
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
);
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
);
378 void icq_FmtLog(icq_Link
*icqlink
, int level
, const char *fmt
, ...);
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
);
387 void icq_TCPMain(icq_Link
*icqlink
);
389 void icq_TCPProcessReceived(icq_Link
*icqlink
);
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
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
);
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
);
406 /* End icq_Link Methods */
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.
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.
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.
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.
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.
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.
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
465 /** Status has changed.
466 * @param arg new session status - one of the CHAT_STATUS_* defines
467 * @param data unused.
468 * @ingroup ChatSession
470 #define CHAT_NOTIFY_STATUS 1
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
477 #define CHAT_NOTIFY_DATA 2
479 /** Session has been closed, either automatically by icqlib or
480 * explicitly by a call to icq_ChatSessionClose.
483 * @ingroup ChatSession
485 #define CHAT_NOTIFY_CLOSE 3
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.
498 /** icqlib is listening for a chat connection from the remote uin.
499 * @ingroup ChatSession
501 #define CHAT_STATUS_LISTENING 1
503 /** A connection has been established with the remote uin.
504 * @ingroup ChatSession
506 #define CHAT_STATUS_CONNECTED 3
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
512 #define CHAT_STATUS_WAIT_NAME 4
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
518 #define CHAT_STATUS_WAIT_FONT 6
520 /** A connection to the chat session port of the remote uin is in
522 * @ingroup ChatSession
524 /* chat session statuses - request sender */
525 #define CHAT_STATUS_CONNECTING 2
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
532 #define CHAT_STATUS_WAIT_ALLINFO 5
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
539 #define CHAT_STATUS_READY 7
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
550 struct icq_ChatSession_s
{
552 /** For internal icqlib use only. */
555 /** Current status of the chat session. See 'Status Constants' group. */
558 /** ICQLINK that spawned this chat session. */
561 /** For internal icqlib use only. */
562 icq_TCPLink
*tcplink
;
564 /** Remote uin number. */
565 unsigned long remote_uin
;
567 /** Remote uin's chat handle. */
568 char remote_handle
[64];
570 /** Space for user data */
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
,
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
587 /* file session statuses- request receiver */
588 #define FILE_STATUS_LISTENING 1
589 #define FILE_STATUS_CONNECTED 3
591 /* file session statuses- request sender */
592 #define FILE_STATUS_CONNECTING 2
594 #define FILE_STATUS_INITIALIZING 4
596 #define FILE_STATUS_NEXT_FILE 5
598 /* once negotiation is complete, file session enters proper state */
599 #define FILE_STATUS_SENDING 6
600 #define FILE_STATUS_RECEIVING 7
602 struct icq_FileSession_s
{
607 icq_TCPLink
*tcplink
;
611 unsigned long remote_uin
;
612 char remote_handle
[64];
616 int current_file_num
;
617 unsigned long total_bytes
;
618 unsigned long total_transferred_bytes
;
620 char working_dir
[512];
621 char current_file
[64];
623 unsigned long current_file_size
;
624 unsigned long current_file_progress
;
628 /** Space for user data */
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
);
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
);
648 #define ICQ_SOCKET_READ 0
649 #define ICQ_SOCKET_WRITE 1
650 #define ICQ_SOCKET_MAX 2
652 extern void (*icq_SocketNotify
)(int socket_fd
, int type
, int status
);
654 void icq_HandleReadySocket(int socket_fd
, int type
);
656 /* Timeout Manager */
658 extern void (*icq_SetTimeout
)(long interval
);
660 void icq_HandleTimeout(void);
664 #endif /* __cplusplus */