connwrap - initialize gnutls session in cw_connect
[centerim.git] / libgadu / libgadu.h
blobabb36e18ae0546e45828b95c86f8e19a90d3bde7
1 /* $Id: libgadu.h,v 1.3 2004/06/10 19:20:08 konst Exp $ */
3 /*
4 * (C) Copyright 2001-2003 Wojtek Kaniewski <wojtekka@irc.pl>
5 * Robert J. Wo¼ny <speedy@ziew.org>
6 * Arkadiusz Mi¶kiewicz <misiek@pld.org.pl>
7 * Tomasz Chiliñski <chilek@chilan.com>
8 * Piotr Wysocki <wysek@linux.bydg.org>
9 * Dawid Jarosz <dawjar@poczta.onet.pl>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License Version
13 * 2.1 as published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #ifndef __GG_LIBGADU_H
26 #define __GG_LIBGADU_H
28 #ifdef __cplusplus
29 #ifdef _WIN32
30 #pragma pack(push, 1)
31 #endif
32 extern "C" {
33 #endif
35 #include <libgadu-config.h>
36 #include <sys/types.h>
37 #include <stdio.h>
38 #include <stdarg.h>
40 #if defined(HAVE_OPENSSL)
42 #ifndef OPENSSL_NO_KRB5
43 #define OPENSSL_NO_KRB5 1
44 #endif
46 #include <openssl/ssl.h>
48 #elif defined(HAVE_NSS_COMPAT)
50 #include <nss_compat_ossl/nss_compat_ossl.h>
52 #elif HAVE_GNUTLS
53 #include <gnutls/openssl.h>
54 #endif
57 * typedef uin_t
59 * typ reprezentuj±cy numer osoby.
61 typedef uint32_t uin_t;
64 * ogólna struktura opisuj±ca ró¿ne sesje. przydatna w klientach.
66 #define gg_common_head(x) \
67 int fd; /* podgl±dany deskryptor */ \
68 int check; /* sprawdzamy zapis czy odczyt */ \
69 int state; /* aktualny stan maszynki */ \
70 int error; /* kod b³êdu dla GG_STATE_ERROR */ \
71 int type; /* rodzaj sesji */ \
72 int id; /* identyfikator */ \
73 int timeout; /* sugerowany timeout w sekundach */ \
74 int (*callback)(x*); /* callback przy zmianach */ \
75 void (*destroy)(x*); /* funkcja niszczenia */
77 struct gg_common {
78 gg_common_head(struct gg_common)
81 struct gg_image_queue;
84 * struct gg_session
86 * struktura opisuj±ca dan± sesjê. tworzona przez gg_login(), zwalniana
87 * przez gg_free_session().
89 struct gg_session {
90 gg_common_head(struct gg_session)
92 int async; /* czy po³±czenie jest asynchroniczne */
93 int pid; /* pid procesu resolvera */
94 int port; /* port, z którym siê ³±czymy */
95 int seq; /* numer sekwencyjny ostatniej wiadomo¶ci */
96 int last_pong; /* czas otrzymania ostatniego ping/pong */
97 int last_event; /* czas otrzymania ostatniego pakietu */
99 struct gg_event *event; /* zdarzenie po ->callback() */
101 uint32_t proxy_addr; /* adres proxy, keszowany */
102 uint16_t proxy_port; /* port proxy */
104 uint32_t hub_addr; /* adres huba po resolvniêciu */
105 uint32_t server_addr; /* adres serwera, od huba */
107 uint32_t client_addr; /* adres klienta */
108 uint16_t client_port; /* port, na którym klient s³ucha */
110 uint32_t external_addr; /* adres zewnetrzny klienta */
111 uint16_t external_port; /* port zewnetrzny klienta */
113 uin_t uin; /* numerek klienta */
114 char *password; /* i jego has³o. zwalniane automagicznie */
116 int initial_status; /* pocz±tkowy stan klienta */
117 int status; /* aktualny stan klienta */
119 char *recv_buf; /* bufor na otrzymywane pakiety */
120 int recv_done; /* ile ju¿ wczytano do bufora */
121 int recv_left; /* i ile jeszcze trzeba wczytaæ */
123 int protocol_version; /* wersja u¿ywanego protoko³u */
124 char *client_version; /* wersja u¿ywanego klienta */
125 int last_sysmsg; /* ostatnia wiadomo¶æ systemowa */
127 char *initial_descr; /* pocz±tkowy opis stanu klienta */
129 void *resolver; /* wska¼nik na informacje resolvera */
131 char *header_buf; /* bufor na pocz±tek nag³ówka */
132 unsigned int header_done;/* ile ju¿ mamy */
134 #if defined(HAVE_OPENSSL) || defined(HAVE_NSS_COMPAT)
135 SSL *ssl; /* sesja TLS */
136 SSL_CTX *ssl_ctx; /* kontekst sesji? */
137 #elif HAVE_GNUTLS
138 gnutls_session_t session; /* TLS session */
139 gnutls_certificate_credentials_t xcred; /*Credentials*/
140 #endif
142 int image_size; /* maksymalny rozmiar obrazków w KiB */
144 char *userlist_reply; /* fragment odpowiedzi listy kontaktów */
146 int userlist_blocks; /* na ile kawa³ków podzielono listê kontaktów */
148 struct gg_image_queue *images; /* aktualnie wczytywane obrazki */
152 * struct gg_http
154 * ogólna struktura opisuj±ca stan wszystkich operacji HTTP. tworzona
155 * przez gg_http_connect(), zwalniana przez gg_http_free().
157 struct gg_http {
158 gg_common_head(struct gg_http)
160 int async; /* czy po³±czenie asynchroniczne */
161 int pid; /* pid procesu resolvera */
162 int port; /* port, z którym siê ³±czymy */
164 char *query; /* bufor zapytania http */
165 char *header; /* bufor nag³ówka */
166 int header_size; /* rozmiar wczytanego nag³ówka */
167 char *body; /* bufor otrzymanych informacji */
168 unsigned int body_size; /* oczekiwana ilo¶æ informacji */
170 void *data; /* dane danej operacji http */
172 char *user_data; /* dane u¿ytkownika, nie s± zwalniane przez gg_http_free() */
174 void *resolver; /* wska¼nik na informacje resolvera */
176 unsigned int body_done; /* ile ju¿ tre¶ci odebrano? */
179 #ifdef __GNUC__
180 #define GG_PACKED __attribute__ ((packed))
181 #else
182 #define GG_PACKED
183 #endif
185 #define GG_MAX_PATH 276
188 * struct gg_file_info
190 * odpowiednik windowsowej struktury WIN32_FIND_DATA niezbêdnej przy
191 * wysy³aniu plików.
193 struct gg_file_info {
194 uint32_t mode; /* dwFileAttributes */
195 uint32_t ctime[2]; /* ftCreationTime */
196 uint32_t atime[2]; /* ftLastAccessTime */
197 uint32_t mtime[2]; /* ftLastWriteTime */
198 uint32_t size_hi; /* nFileSizeHigh */
199 uint32_t size; /* nFileSizeLow */
200 uint32_t reserved0; /* dwReserved0 */
201 uint32_t reserved1; /* dwReserved1 */
202 unsigned char filename[GG_MAX_PATH - 14]; /* cFileName */
203 unsigned char short_filename[14]; /* cAlternateFileName */
204 } GG_PACKED;
207 * struct gg_dcc
209 * struktura opisuj±ca nas³uchuj±ce gniazdo po³±czeñ miêdzy klientami.
210 * tworzona przez gg_dcc_socket_create(), zwalniana przez gg_dcc_free().
212 struct gg_dcc {
213 gg_common_head(struct gg_dcc)
215 struct gg_event *event; /* opis zdarzenia */
217 int active; /* czy to my siê ³±czymy? */
218 int port; /* port, na którym siedzi */
219 uin_t uin; /* uin klienta */
220 uin_t peer_uin; /* uin drugiej strony */
221 int file_fd; /* deskryptor pliku */
222 unsigned int offset; /* offset w pliku */
223 unsigned int chunk_size;/* rozmiar kawa³ka */
224 unsigned int chunk_offset;/* offset w aktualnym kawa³ku */
225 struct gg_file_info file_info;
226 /* informacje o pliku */
227 int established; /* po³±czenie ustanowione */
228 char *voice_buf; /* bufor na pakiet po³±czenia g³osowego */
229 int incoming; /* po³±czenie przychodz±ce */
230 char *chunk_buf; /* bufor na kawa³ek danych */
231 uint32_t remote_addr; /* adres drugiej strony */
232 uint16_t remote_port; /* port drugiej strony */
236 * enum gg_session_t
238 * rodzaje sesji.
240 enum gg_session_t {
241 GG_SESSION_GG = 1, /* po³±czenie z serwerem gg */
242 GG_SESSION_HTTP, /* ogólna sesja http */
243 GG_SESSION_SEARCH, /* szukanie */
244 GG_SESSION_REGISTER, /* rejestrowanie */
245 GG_SESSION_REMIND, /* przypominanie has³a */
246 GG_SESSION_PASSWD, /* zmiana has³a */
247 GG_SESSION_CHANGE, /* zmiana informacji o sobie */
248 GG_SESSION_DCC, /* ogólne po³±czenie DCC */
249 GG_SESSION_DCC_SOCKET, /* nas³uchuj±cy socket */
250 GG_SESSION_DCC_SEND, /* wysy³anie pliku */
251 GG_SESSION_DCC_GET, /* odbieranie pliku */
252 GG_SESSION_DCC_VOICE, /* rozmowa g³osowa */
253 GG_SESSION_USERLIST_GET, /* pobieranie userlisty */
254 GG_SESSION_USERLIST_PUT, /* wysy³anie userlisty */
255 GG_SESSION_UNREGISTER, /* usuwanie konta */
256 GG_SESSION_USERLIST_REMOVE, /* usuwanie userlisty */
257 GG_SESSION_TOKEN, /* pobieranie tokenu */
259 GG_SESSION_USER0 = 256, /* zdefiniowana dla u¿ytkownika */
260 GG_SESSION_USER1, /* j.w. */
261 GG_SESSION_USER2, /* j.w. */
262 GG_SESSION_USER3, /* j.w. */
263 GG_SESSION_USER4, /* j.w. */
264 GG_SESSION_USER5, /* j.w. */
265 GG_SESSION_USER6, /* j.w. */
266 GG_SESSION_USER7 /* j.w. */
270 * enum gg_state_t
272 * opisuje stan asynchronicznej maszyny.
274 enum gg_state_t {
275 /* wspólne */
276 GG_STATE_IDLE = 0, /* nie powinno wyst±piæ. */
277 GG_STATE_RESOLVING, /* wywo³a³ gethostbyname() */
278 GG_STATE_CONNECTING, /* wywo³a³ connect() */
279 GG_STATE_READING_DATA, /* czeka na dane http */
280 GG_STATE_ERROR, /* wyst±pi³ b³±d. kod w x->error */
282 /* gg_session */
283 GG_STATE_CONNECTING_HUB, /* wywo³a³ connect() na huba */
284 GG_STATE_CONNECTING_GG, /* wywo³a³ connect() na serwer */
285 GG_STATE_READING_KEY, /* czeka na klucz */
286 GG_STATE_READING_REPLY, /* czeka na odpowied¼ */
287 GG_STATE_CONNECTED, /* po³±czy³ siê */
289 /* gg_http */
290 GG_STATE_SENDING_QUERY, /* wysy³a zapytanie http */
291 GG_STATE_READING_HEADER, /* czeka na nag³ówek http */
292 GG_STATE_PARSING, /* przetwarza dane */
293 GG_STATE_DONE, /* skoñczy³ */
295 /* gg_dcc */
296 GG_STATE_LISTENING, /* czeka na po³±czenia */
297 GG_STATE_READING_UIN_1, /* czeka na uin peera */
298 GG_STATE_READING_UIN_2, /* czeka na swój uin */
299 GG_STATE_SENDING_ACK, /* wysy³a potwierdzenie dcc */
300 GG_STATE_READING_ACK, /* czeka na potwierdzenie dcc */
301 GG_STATE_READING_REQUEST, /* czeka na komendê */
302 GG_STATE_SENDING_REQUEST, /* wysy³a komendê */
303 GG_STATE_SENDING_FILE_INFO, /* wysy³a informacje o pliku */
304 GG_STATE_READING_PRE_FILE_INFO, /* czeka na pakiet przed file_info */
305 GG_STATE_READING_FILE_INFO, /* czeka na informacje o pliku */
306 GG_STATE_SENDING_FILE_ACK, /* wysy³a potwierdzenie pliku */
307 GG_STATE_READING_FILE_ACK, /* czeka na potwierdzenie pliku */
308 GG_STATE_SENDING_FILE_HEADER, /* wysy³a nag³ówek pliku */
309 GG_STATE_READING_FILE_HEADER, /* czeka na nag³ówek */
310 GG_STATE_GETTING_FILE, /* odbiera plik */
311 GG_STATE_SENDING_FILE, /* wysy³a plik */
312 GG_STATE_READING_VOICE_ACK, /* czeka na potwierdzenie voip */
313 GG_STATE_READING_VOICE_HEADER, /* czeka na rodzaj bloku voip */
314 GG_STATE_READING_VOICE_SIZE, /* czeka na rozmiar bloku voip */
315 GG_STATE_READING_VOICE_DATA, /* czeka na dane voip */
316 GG_STATE_SENDING_VOICE_ACK, /* wysy³a potwierdzenie voip */
317 GG_STATE_SENDING_VOICE_REQUEST, /* wysy³a ¿±danie voip */
318 GG_STATE_READING_TYPE, /* czeka na typ po³±czenia */
320 /* nowe. bez sensu jest to API. */
321 GG_STATE_TLS_NEGOTIATION /* negocjuje po³±czenie TLS */
325 * enum gg_check_t
327 * informuje, co proces klienta powinien sprawdziæ na deskryptorze danego
328 * po³±czenia.
330 enum gg_check_t {
331 GG_CHECK_NONE = 0, /* nic. nie powinno wyst±piæ */
332 GG_CHECK_WRITE = 1, /* sprawdzamy mo¿liwo¶æ zapisu */
333 GG_CHECK_READ = 2 /* sprawdzamy mo¿liwo¶æ odczytu */
337 * struct gg_login_params
339 * parametry gg_login(). przeniesiono do struktury, ¿eby unikn±æ problemów
340 * z ci±g³ymi zmianami API, gdy dodano co¶ nowego do protoko³u.
342 struct gg_login_params {
343 uin_t uin; /* numerek */
344 char *password; /* has³o */
345 int async; /* asynchroniczne sockety? */
346 int status; /* pocz±tkowy status klienta */
347 char *status_descr; /* opis statusu */
348 uint32_t server_addr; /* adres serwera gg */
349 uint16_t server_port; /* port serwera gg */
350 uint32_t client_addr; /* adres dcc klienta */
351 uint16_t client_port; /* port dcc klienta */
352 int protocol_version; /* wersja protoko³u */
353 char *client_version; /* wersja klienta */
354 int has_audio; /* czy ma d¼wiêk? */
355 int last_sysmsg; /* ostatnia wiadomo¶æ systemowa */
356 uint32_t external_addr; /* adres widziany na zewnatrz */
357 uint16_t external_port; /* port widziany na zewnatrz */
358 int tls; /* czy ³±czymy po TLS? */
359 int image_size; /* maksymalny rozmiar obrazka w KiB */
361 char dummy[6 * sizeof(int)]; /* miejsce na kolejnych 8 zmiennych,
362 * ¿eby z dodaniem parametru nie
363 * zmienia³ siê rozmiar struktury */
366 struct gg_session *gg_login(const struct gg_login_params *p);
367 void gg_free_session(struct gg_session *sess);
368 void gg_logoff(struct gg_session *sess);
369 int gg_change_status(struct gg_session *sess, int status);
370 int gg_change_status_descr(struct gg_session *sess, int status, const char *descr);
371 int gg_change_status_descr_time(struct gg_session *sess, int status, const char *descr, int time);
372 int gg_send_message(struct gg_session *sess, int msgclass, uin_t recipient, const unsigned char *message);
373 int gg_send_message_richtext(struct gg_session *sess, int msgclass, uin_t recipient, const unsigned char *message, const unsigned char *format, int formatlen);
374 int gg_send_message_confer(struct gg_session *sess, int msgclass, int recipients_count, uin_t *recipients, const unsigned char *message);
375 int gg_send_message_confer_richtext(struct gg_session *sess, int msgclass, int recipients_count, uin_t *recipients, const unsigned char *message, const unsigned char *format, int formatlen);
376 int gg_send_message_ctcp(struct gg_session *sess, int msgclass, uin_t recipient, const unsigned char *message, int message_len);
377 int gg_ping(struct gg_session *sess);
378 int gg_userlist_request(struct gg_session *sess, char type, const char *request);
379 int gg_image_request(struct gg_session *sess, uin_t recipient, int size, uint32_t crc32);
380 int gg_image_reply(struct gg_session *sess, uin_t recipient, const char *filename, const char *image, int size);
382 uint32_t gg_crc32(uint32_t crc, const unsigned char *buf, int len);
384 struct gg_image_queue {
385 uin_t sender; /* nadawca obrazka */
386 uint32_t size; /* rozmiar */
387 uint32_t crc32; /* suma kontrolna */
388 char *filename; /* nazwa pliku */
389 char *image; /* bufor z obrazem */
390 uint32_t done; /* ile ju¿ wczytano */
392 struct gg_image_queue *next; /* nastêpny na li¶cie */
396 * enum gg_event_t
398 * rodzaje zdarzeñ.
400 enum gg_event_t {
401 GG_EVENT_NONE = 0, /* nic siê nie wydarzy³o */
402 GG_EVENT_MSG, /* otrzymano wiadomo¶æ */
403 GG_EVENT_NOTIFY, /* kto¶ siê pojawi³ */
404 GG_EVENT_NOTIFY_DESCR, /* kto¶ siê pojawi³ z opisem */
405 GG_EVENT_STATUS, /* kto¶ zmieni³ stan */
406 GG_EVENT_ACK, /* potwierdzenie wys³ania wiadomo¶ci */
407 GG_EVENT_PONG, /* pakiet pong */
408 GG_EVENT_CONN_FAILED, /* po³±czenie siê nie uda³o */
409 GG_EVENT_CONN_SUCCESS, /* po³±czenie siê powiod³o */
410 GG_EVENT_DISCONNECT, /* serwer zrywa po³±czenie */
412 GG_EVENT_DCC_NEW, /* nowe po³±czenie miêdzy klientami */
413 GG_EVENT_DCC_ERROR, /* b³±d po³±czenia miêdzy klientami */
414 GG_EVENT_DCC_DONE, /* zakoñczono po³±czenie */
415 GG_EVENT_DCC_CLIENT_ACCEPT, /* moment akceptacji klienta */
416 GG_EVENT_DCC_CALLBACK, /* klient siê po³±czy³ na ¿±danie */
417 GG_EVENT_DCC_NEED_FILE_INFO, /* nale¿y wype³niæ file_info */
418 GG_EVENT_DCC_NEED_FILE_ACK, /* czeka na potwierdzenie pliku */
419 GG_EVENT_DCC_NEED_VOICE_ACK, /* czeka na potwierdzenie rozmowy */
420 GG_EVENT_DCC_VOICE_DATA, /* ramka danych rozmowy g³osowej */
422 GG_EVENT_PUBDIR50_SEARCH_REPLY, /* odpowiedz wyszukiwania */
423 GG_EVENT_PUBDIR50_READ, /* odczytano w³asne dane z katalogu */
424 GG_EVENT_PUBDIR50_WRITE, /* wpisano w³asne dane do katalogu */
426 GG_EVENT_STATUS60, /* kto¶ zmieni³ stan w GG 6.0 */
427 GG_EVENT_NOTIFY60, /* kto¶ siê pojawi³ w GG 6.0 */
428 GG_EVENT_USERLIST, /* odpowied¼ listy kontaktów w GG 6.0 */
429 GG_EVENT_IMAGE_REQUEST, /* pro¶ba o wys³anie obrazka GG 6.0 */
430 GG_EVENT_IMAGE_REPLY, /* podes³any obrazek GG 6.0 */
431 GG_EVENT_DCC_ACK /* potwierdzenie transmisji */
434 #define GG_EVENT_SEARCH50_REPLY GG_EVENT_PUBDIR50_SEARCH_REPLY
437 * enum gg_failure_t
439 * okre¶la powód nieudanego po³±czenia.
441 enum gg_failure_t {
442 GG_FAILURE_RESOLVING = 1, /* nie znaleziono serwera */
443 GG_FAILURE_CONNECTING, /* nie mo¿na siê po³±czyæ */
444 GG_FAILURE_INVALID, /* serwer zwróci³ nieprawid³owe dane */
445 GG_FAILURE_READING, /* zerwano po³±czenie podczas odczytu */
446 GG_FAILURE_WRITING, /* zerwano po³±czenie podczas zapisu */
447 GG_FAILURE_PASSWORD, /* nieprawid³owe has³o */
448 GG_FAILURE_404, /* XXX nieu¿ywane */
449 GG_FAILURE_TLS, /* b³±d negocjacji TLS */
450 GG_FAILURE_NEED_EMAIL /* serwer roz³±czy³ nas z pro¶b± o zmianê emaila */
454 * enum gg_error_t
456 * okre¶la rodzaj b³êdu wywo³anego przez dan± operacjê. nie zawiera
457 * przesadnie szczegó³owych informacji o powodzie b³êdu, by nie komplikowaæ
458 * obs³ugi b³êdów. je¶li wymagana jest wiêksza dok³adno¶æ, nale¿y sprawdziæ
459 * zawarto¶æ zmiennej errno.
461 enum gg_error_t {
462 GG_ERROR_RESOLVING = 1, /* b³±d znajdowania hosta */
463 GG_ERROR_CONNECTING, /* b³±d ³aczenia siê */
464 GG_ERROR_READING, /* b³±d odczytu */
465 GG_ERROR_WRITING, /* b³±d wysy³ania */
467 GG_ERROR_DCC_HANDSHAKE, /* b³±d negocjacji */
468 GG_ERROR_DCC_FILE, /* b³±d odczytu/zapisu pliku */
469 GG_ERROR_DCC_EOF, /* plik siê skoñczy³? */
470 GG_ERROR_DCC_NET, /* b³±d wysy³ania/odbierania */
471 GG_ERROR_DCC_REFUSED /* po³±czenie odrzucone przez usera */
475 * struktury dotycz±ce wyszukiwania w GG 5.0. NIE NALE¯Y SIÊ DO NICH
476 * ODWO£YWAÆ BEZPO¦REDNIO! do dostêpu do nich s³u¿± funkcje gg_pubdir50_*()
478 struct gg_pubdir50_entry {
479 int num;
480 char *field;
481 char *value;
484 struct gg_pubdir50_s {
485 int count;
486 uin_t next;
487 int type;
488 uint32_t seq;
489 struct gg_pubdir50_entry *entries;
490 int entries_count;
494 * typedef gg_pubdir_50_t
496 * typ opisuj±cy zapytanie lub wynik zapytania katalogu publicznego
497 * z protoko³u GG 5.0. nie nale¿y siê odwo³ywaæ bezpo¶rednio do jego
498 * pól -- s³u¿± do tego funkcje gg_pubdir50_*()
500 typedef struct gg_pubdir50_s *gg_pubdir50_t;
503 * struct gg_event
505 * struktura opisuj±ca rodzaj zdarzenia. wychodzi z gg_watch_fd() lub
506 * z gg_dcc_watch_fd()
508 struct gg_event {
509 int type; /* rodzaj zdarzenia -- gg_event_t */
510 union { /* @event */
511 struct gg_notify_reply *notify; /* informacje o li¶cie kontaktów -- GG_EVENT_NOTIFY */
513 enum gg_failure_t failure; /* b³±d po³±czenia -- GG_EVENT_FAILURE */
515 struct gg_dcc *dcc_new; /* nowe po³±czenie bezpo¶rednie -- GG_EVENT_DCC_NEW */
517 int dcc_error; /* b³±d po³±czenia bezpo¶redniego -- GG_EVENT_DCC_ERROR */
519 gg_pubdir50_t pubdir50; /* wynik operacji zwi±zanej z katalogiem publicznym -- GG_EVENT_PUBDIR50_* */
521 struct { /* @msg odebrano wiadomo¶æ -- GG_EVENT_MSG */
522 uin_t sender; /* numer nadawcy */
523 int msgclass; /* klasa wiadomo¶ci */
524 time_t time; /* czas nadania */
525 unsigned char *message; /* tre¶æ wiadomo¶ci */
527 int recipients_count; /* ilo¶æ odbiorców konferencji */
528 uin_t *recipients; /* odbiorcy konferencji */
530 int formats_length; /* d³ugo¶æ informacji o formatowaniu tekstu */
531 void *formats; /* informacje o formatowaniu tekstu */
532 } msg;
534 struct { /* @notify_descr informacje o li¶cie kontaktów z opisami stanu -- GG_EVENT_NOTIFY_DESCR */
535 struct gg_notify_reply *notify; /* informacje o li¶cie kontaktów */
536 char *descr; /* opis stanu */
537 } notify_descr;
539 struct { /* @status zmiana stanu -- GG_EVENT_STATUS */
540 uin_t uin; /* numer */
541 uint32_t status; /* nowy stan */
542 char *descr; /* opis stanu */
543 } status;
545 struct { /* @status60 zmiana stanu -- GG_EVENT_STATUS60 */
546 uin_t uin; /* numer */
547 int status; /* nowy stan */
548 uint32_t remote_ip; /* adres ip */
549 uint16_t remote_port; /* port */
550 int version; /* wersja klienta */
551 int image_size; /* maksymalny rozmiar grafiki w KiB */
552 char *descr; /* opis stanu */
553 time_t time; /* czas powrotu */
554 } status60;
556 struct { /* @notify60 informacja o li¶cie kontaktów -- GG_EVENT_NOTIFY60 */
557 uin_t uin; /* numer */
558 int status; /* stan */
559 uint32_t remote_ip; /* adres ip */
560 uint16_t remote_port; /* port */
561 int version; /* wersja klienta */
562 int image_size; /* maksymalny rozmiar grafiki w KiB */
563 char *descr; /* opis stanu */
564 time_t time; /* czas powrotu */
565 } *notify60;
567 struct { /* @ack potwierdzenie wiadomo¶ci -- GG_EVENT_ACK */
568 uin_t recipient; /* numer odbiorcy */
569 int status; /* stan dorêczenia wiadomo¶ci */
570 int seq; /* numer sekwencyjny wiadomo¶ci */
571 } ack;
573 struct { /* @dcc_voice_data otrzymano dane d¼wiêkowe -- GG_EVENT_DCC_VOICE_DATA */
574 uint8_t *data; /* dane d¼wiêkowe */
575 int length; /* ilo¶æ danych d¼wiêkowych */
576 } dcc_voice_data;
578 struct { /* @userlist odpowied¼ listy kontaktów serwera */
579 char type; /* rodzaj odpowiedzi */
580 char *reply; /* tre¶æ odpowiedzi */
581 } userlist;
583 struct { /* @image_request pro¶ba o obrazek */
584 uin_t sender; /* nadawca pro¶by */
585 uint32_t size; /* rozmiar obrazka */
586 uint32_t crc32; /* suma kontrolna */
587 } image_request;
589 struct { /* @image_reply odpowied¼ z obrazkiem */
590 uin_t sender; /* nadawca odpowiedzi */
591 uint32_t size; /* rozmiar obrazka */
592 uint32_t crc32; /* suma kontrolna */
593 char *filename; /* nazwa pliku */
594 char *image; /* bufor z obrazkiem */
595 } image_reply;
596 } event;
599 struct gg_event *gg_watch_fd(struct gg_session *sess);
600 void gg_event_free(struct gg_event *e);
601 #define gg_free_event gg_event_free
604 * funkcje obs³ugi listy kontaktów.
606 int gg_notify_ex(struct gg_session *sess, uin_t *userlist, char *types, int count);
607 int gg_notify(struct gg_session *sess, uin_t *userlist, int count);
608 int gg_add_notify_ex(struct gg_session *sess, uin_t uin, char type);
609 int gg_add_notify(struct gg_session *sess, uin_t uin);
610 int gg_remove_notify_ex(struct gg_session *sess, uin_t uin, char type);
611 int gg_remove_notify(struct gg_session *sess, uin_t uin);
614 * funkcje obs³ugi http.
616 struct gg_http *gg_http_connect(const char *hostname, int port, int async, const char *method, const char *path, const char *header);
617 int gg_http_watch_fd(struct gg_http *h);
618 void gg_http_stop(struct gg_http *h);
619 void gg_http_free(struct gg_http *h);
620 void gg_http_free_fields(struct gg_http *h);
621 #define gg_free_http gg_http_free
624 * struktury opisuj±ca kryteria wyszukiwania dla gg_search(). nieaktualne,
625 * zast±pione przez gg_pubdir50_t. pozostawiono je dla zachowania ABI.
627 struct gg_search_request {
628 int active;
629 unsigned int start;
630 char *nickname;
631 char *first_name;
632 char *last_name;
633 char *city;
634 int gender;
635 int min_birth;
636 int max_birth;
637 char *email;
638 char *phone;
639 uin_t uin;
642 struct gg_search {
643 int count;
644 struct gg_search_result *results;
647 struct gg_search_result {
648 uin_t uin;
649 char *first_name;
650 char *last_name;
651 char *nickname;
652 int born;
653 int gender;
654 char *city;
655 int active;
658 #define GG_GENDER_NONE 0
659 #define GG_GENDER_FEMALE 1
660 #define GG_GENDER_MALE 2
663 * funkcje wyszukiwania.
665 struct gg_http *gg_search(const struct gg_search_request *r, int async);
666 int gg_search_watch_fd(struct gg_http *f);
667 void gg_free_search(struct gg_http *f);
668 #define gg_search_free gg_free_search
670 const struct gg_search_request *gg_search_request_mode_0(char *nickname, char *first_name, char *last_name, char *city, int gender, int min_birth, int max_birth, int active, int start);
671 const struct gg_search_request *gg_search_request_mode_1(char *email, int active, int start);
672 const struct gg_search_request *gg_search_request_mode_2(char *phone, int active, int start);
673 const struct gg_search_request *gg_search_request_mode_3(uin_t uin, int active, int start);
674 void gg_search_request_free(struct gg_search_request *r);
677 * funkcje obs³ugi katalogu publicznego zgodne z GG 5.0. tym razem funkcje
678 * zachowuj± pewien poziom abstrakcji, ¿eby unikn±æ zmian ABI przy zmianach
679 * w protokole.
681 * NIE NALE¯Y SIÊ ODWO£YWAÆ DO PÓL gg_pubdir50_t BEZPO¦REDNIO!
683 uint32_t gg_pubdir50(struct gg_session *sess, gg_pubdir50_t req);
684 gg_pubdir50_t gg_pubdir50_new(int type);
685 int gg_pubdir50_add(gg_pubdir50_t req, const char *field, const char *value);
686 int gg_pubdir50_seq_set(gg_pubdir50_t req, uint32_t seq);
687 const char *gg_pubdir50_get(gg_pubdir50_t res, int num, const char *field);
688 int gg_pubdir50_type(gg_pubdir50_t res);
689 int gg_pubdir50_count(gg_pubdir50_t res);
690 uin_t gg_pubdir50_next(gg_pubdir50_t res);
691 uint32_t gg_pubdir50_seq(gg_pubdir50_t res);
692 void gg_pubdir50_free(gg_pubdir50_t res);
694 #define GG_PUBDIR50_UIN "FmNumber"
695 #define GG_PUBDIR50_STATUS "FmStatus"
696 #define GG_PUBDIR50_FIRSTNAME "firstname"
697 #define GG_PUBDIR50_LASTNAME "lastname"
698 #define GG_PUBDIR50_NICKNAME "nickname"
699 #define GG_PUBDIR50_BIRTHYEAR "birthyear"
700 #define GG_PUBDIR50_CITY "city"
701 #define GG_PUBDIR50_GENDER "gender"
702 #define GG_PUBDIR50_GENDER_FEMALE "1"
703 #define GG_PUBDIR50_GENDER_MALE "2"
704 #define GG_PUBDIR50_GENDER_SET_FEMALE "2"
705 #define GG_PUBDIR50_GENDER_SET_MALE "1"
706 #define GG_PUBDIR50_ACTIVE "ActiveOnly"
707 #define GG_PUBDIR50_ACTIVE_TRUE "1"
708 #define GG_PUBDIR50_START "fmstart"
709 #define GG_PUBDIR50_FAMILYNAME "familyname"
710 #define GG_PUBDIR50_FAMILYCITY "familycity"
712 int gg_pubdir50_handle_reply(struct gg_event *e, const char *packet, int length);
715 * struct gg_pubdir
717 * operacje na katalogu publicznym.
719 struct gg_pubdir {
720 int success; /* czy siê uda³o */
721 uin_t uin; /* otrzymany numerek. 0 je¶li b³±d */
724 /* ogólne funkcje, nie powinny byæ u¿ywane */
725 int gg_pubdir_watch_fd(struct gg_http *f);
726 void gg_pubdir_free(struct gg_http *f);
727 #define gg_free_pubdir gg_pubdir_free
729 struct gg_token {
730 int width; /* szeroko¶æ obrazka */
731 int height; /* wysoko¶æ obrazka */
732 int length; /* ilo¶æ znaków w tokenie */
733 char *tokenid; /* id tokenu */
736 /* funkcje dotycz±ce tokenów */
737 struct gg_http *gg_token(int async);
738 int gg_token_watch_fd(struct gg_http *h);
739 void gg_token_free(struct gg_http *h);
741 /* rejestracja nowego numerka */
742 struct gg_http *gg_register(const char *email, const char *password, int async);
743 struct gg_http *gg_register2(const char *email, const char *password, const char *qa, int async);
744 struct gg_http *gg_register3(const char *email, const char *password, const char *tokenid, const char *tokenval, int async);
745 #define gg_register_watch_fd gg_pubdir_watch_fd
746 #define gg_register_free gg_pubdir_free
747 #define gg_free_register gg_pubdir_free
749 struct gg_http *gg_unregister(uin_t uin, const char *password, const char *email, int async);
750 struct gg_http *gg_unregister2(uin_t uin, const char *password, const char *qa, int async);
751 struct gg_http *gg_unregister3(uin_t uin, const char *password, const char *tokenid, const char *tokenval, int async);
752 #define gg_unregister_watch_fd gg_pubdir_watch_fd
753 #define gg_unregister_free gg_pubdir_free
755 /* przypomnienie has³a e-mailem */
756 struct gg_http *gg_remind_passwd(uin_t uin, int async);
757 struct gg_http *gg_remind_passwd2(uin_t uin, const char *tokenid, const char *tokenval, int async);
758 #define gg_remind_passwd_watch_fd gg_pubdir_watch_fd
759 #define gg_remind_passwd_free gg_pubdir_free
760 #define gg_free_remind_passwd gg_pubdir_free
762 /* zmiana has³a */
763 struct gg_http *gg_change_passwd(uin_t uin, const char *passwd, const char *newpasswd, const char *newemail, int async);
764 struct gg_http *gg_change_passwd2(uin_t uin, const char *passwd, const char *newpasswd, const char *email, const char *newemail, int async);
765 struct gg_http *gg_change_passwd3(uin_t uin, const char *passwd, const char *newpasswd, const char *qa, int async);
766 struct gg_http *gg_change_passwd4(uin_t uin, const char *email, const char *passwd, const char *newpasswd, const char *tokenid, const char *tokenval, int async);
767 #define gg_change_passwd_free gg_pubdir_free
768 #define gg_free_change_passwd gg_pubdir_free
771 * struct gg_change_info_request
773 * opis ¿±dania zmiany informacji w katalogu publicznym.
775 struct gg_change_info_request {
776 char *first_name; /* imiê */
777 char *last_name; /* nazwisko */
778 char *nickname; /* pseudonim */
779 char *email; /* email */
780 int born; /* rok urodzenia */
781 int gender; /* p³eæ */
782 char *city; /* miasto */
785 struct gg_change_info_request *gg_change_info_request_new(const char *first_name, const char *last_name, const char *nickname, const char *email, int born, int gender, const char *city);
786 void gg_change_info_request_free(struct gg_change_info_request *r);
788 struct gg_http *gg_change_info(uin_t uin, const char *passwd, const struct gg_change_info_request *request, int async);
789 #define gg_change_pubdir_watch_fd gg_pubdir_watch_fd
790 #define gg_change_pubdir_free gg_pubdir_free
791 #define gg_free_change_pubdir gg_pubdir_free
794 * funkcje dotycz±ce listy kontaktów na serwerze.
796 struct gg_http *gg_userlist_get(uin_t uin, const char *password, int async);
797 int gg_userlist_get_watch_fd(struct gg_http *f);
798 void gg_userlist_get_free(struct gg_http *f);
800 struct gg_http *gg_userlist_put(uin_t uin, const char *password, const char *contacts, int async);
801 int gg_userlist_put_watch_fd(struct gg_http *f);
802 void gg_userlist_put_free(struct gg_http *f);
804 struct gg_http *gg_userlist_remove(uin_t uin, const char *password, int async);
805 int gg_userlist_remove_watch_fd(struct gg_http *f);
806 void gg_userlist_remove_free(struct gg_http *f);
811 * funkcje dotycz±ce komunikacji miêdzy klientami.
813 extern int gg_dcc_port; /* port, na którym nas³uchuje klient */
814 extern unsigned long gg_dcc_ip; /* adres, na którym nas³uchuje klient */
816 int gg_dcc_request(struct gg_session *sess, uin_t uin);
818 struct gg_dcc *gg_dcc_send_file(uint32_t ip, uint16_t port, uin_t my_uin, uin_t peer_uin);
819 struct gg_dcc *gg_dcc_get_file(uint32_t ip, uint16_t port, uin_t my_uin, uin_t peer_uin);
820 struct gg_dcc *gg_dcc_voice_chat(uint32_t ip, uint16_t port, uin_t my_uin, uin_t peer_uin);
821 void gg_dcc_set_type(struct gg_dcc *d, int type);
822 int gg_dcc_fill_file_info(struct gg_dcc *d, const char *filename);
823 int gg_dcc_voice_send(struct gg_dcc *d, char *buf, int length);
825 #define GG_DCC_VOICE_FRAME_LENGTH 195
826 #define GG_DCC_VOICE_FRAME_LENGTH_505 326
828 struct gg_dcc *gg_dcc_socket_create(uin_t uin, uint16_t port);
829 #define gg_dcc_socket_free gg_free_dcc
830 #define gg_dcc_socket_watch_fd gg_dcc_watch_fd
832 struct gg_event *gg_dcc_watch_fd(struct gg_dcc *d);
834 void gg_dcc_free(struct gg_dcc *c);
835 #define gg_free_dcc gg_dcc_free
838 * je¶li chcemy sobie podebugowaæ, wystarczy ustawiæ `gg_debug_level'.
839 * niestety w miarê przybywania wpisów `gg_debug(...)' nie chcia³o mi
840 * siê ustawiaæ odpowiednich leveli, wiêc wiêkszo¶æ sz³a do _MISC.
842 extern int gg_debug_level; /* poziom debugowania. mapa bitowa sta³ych GG_DEBUG_* */
845 * mo¿na podaæ wska¼nik do funkcji obs³uguj±cej wywo³ania gg_debug().
846 * nieoficjalne, nieudokumentowane, mo¿e siê zmieniæ. je¶li kto¶ jest
847 * zainteresowany, niech da znaæ na ekg-devel.
849 extern void (*gg_debug_handler)(int level, const char *format, va_list ap);
852 * mo¿na podaæ plik, do którego bêd± zapisywane teksty z gg_debug().
854 extern FILE *gg_debug_file;
856 #define GG_DEBUG_NET 1
857 #define GG_DEBUG_TRAFFIC 2
858 #define GG_DEBUG_DUMP 4
859 #define GG_DEBUG_FUNCTION 8
860 #define GG_DEBUG_MISC 16
862 #ifdef GG_DEBUG_DISABLE
863 #define gg_debug(x, y...) do { } while(0)
864 #else
865 void gg_debug(int level, const char *format, ...);
866 #endif
868 const char *gg_libgadu_version(void);
871 * konfiguracja http proxy.
873 extern int gg_proxy_enabled; /* w³±cza obs³ugê proxy */
874 extern char *gg_proxy_host; /* okre¶la adres serwera proxy */
875 extern int gg_proxy_port; /* okre¶la port serwera proxy */
876 extern char *gg_proxy_username; /* okre¶la nazwê u¿ytkownika przy autoryzacji serwera proxy */
877 extern char *gg_proxy_password; /* okre¶la has³o u¿ytkownika przy autoryzacji serwera proxy */
878 extern int gg_proxy_http_only; /* w³±cza obs³ugê proxy wy³±cznie dla us³ug HTTP */
881 * -------------------------------------------------------------------------
882 * poni¿ej znajduj± siê wewnêtrzne sprawy biblioteki. zwyk³y klient nie
883 * powinien ich w ogóle ruszaæ, bo i nie ma po co. wszystko mo¿na za³atwiæ
884 * procedurami wy¿szego poziomu, których definicje znajduj± siê na pocz±tku
885 * tego pliku.
886 * -------------------------------------------------------------------------
889 #ifdef __GG_LIBGADU_HAVE_PTHREAD
890 int gg_resolve_pthread(int *fd, void **resolver, const char *hostname);
891 #endif
893 #ifdef _WIN32
894 int gg_thread_socket(int thread_id, int socket);
895 #endif
897 int gg_resolve(int *fd, int *pid, const char *hostname);
899 #ifdef __GNUC__
900 char *gg_saprintf(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
901 #else
902 char *gg_saprintf(const char *format, ...);
903 #endif
905 char *gg_vsaprintf(const char *format, va_list ap);
907 #define gg_alloc_sprintf gg_saprintf
909 char *gg_get_line(char **ptr);
911 int gg_connect(void *addr, int port, int async);
912 struct hostent *gg_gethostbyname(const char *hostname);
913 char *gg_read_line(int sock, char *buf, int length);
914 void gg_chomp(char *line);
915 char *gg_urlencode(const char *str);
916 int gg_http_hash(const char *format, ...);
917 int gg_read(struct gg_session *sess, char *buf, int length);
918 int gg_write(struct gg_session *sess, const char *buf, int length);
919 void *gg_recv_packet(struct gg_session *sess);
920 int gg_send_packet(struct gg_session *sess, int type, ...);
921 unsigned int gg_login_hash(const unsigned char *password, unsigned int seed);
922 uint32_t gg_fix32(uint32_t x);
923 uint16_t gg_fix16(uint16_t x);
924 #define fix16 gg_fix16
925 #define fix32 gg_fix32
926 char *gg_proxy_auth(void);
927 char *gg_base64_encode(const char *buf);
928 char *gg_base64_decode(const char *buf);
929 int gg_image_queue_remove(struct gg_session *s, struct gg_image_queue *q, int freeq);
931 #define GG_APPMSG_HOST "appmsg.gadu-gadu.pl"
932 #define GG_APPMSG_PORT 80
933 #define GG_PUBDIR_HOST "pubdir.gadu-gadu.pl"
934 #define GG_PUBDIR_PORT 80
935 #define GG_REGISTER_HOST "register.gadu-gadu.pl"
936 #define GG_REGISTER_PORT 80
937 #define GG_REMIND_HOST "retr.gadu-gadu.pl"
938 #define GG_REMIND_PORT 80
940 #define GG_DEFAULT_PORT 8074
941 #define GG_HTTPS_PORT 443
942 #define GG_HTTP_USERAGENT "Mozilla/4.7 [en] (Win98; I)"
944 #define GG_DEFAULT_CLIENT_VERSION "6, 0, 0, 132"
945 #define GG_DEFAULT_PROTOCOL_VERSION 0x20
946 #define GG_DEFAULT_TIMEOUT 30
947 #define GG_HAS_AUDIO_MASK 0x40000000
948 #define GG_LIBGADU_VERSION "20040117"
950 #define GG_DEFAULT_DCC_PORT 1550
952 struct gg_header {
953 uint32_t type; /* typ pakietu */
954 uint32_t length; /* d³ugo¶æ reszty pakietu */
955 } GG_PACKED;
957 #define GG_WELCOME 0x0001
958 #define GG_NEED_EMAIL 0x0014
960 struct gg_welcome {
961 uint32_t key; /* klucz szyfrowania has³a */
962 } GG_PACKED;
964 #define GG_LOGIN 0x000c
966 struct gg_login {
967 uint32_t uin; /* mój numerek */
968 uint32_t hash; /* hash has³a */
969 uint32_t status; /* status na dzieñ dobry */
970 uint32_t version; /* moja wersja klienta */
971 uint32_t local_ip; /* mój adres ip */
972 uint16_t local_port; /* port, na którym s³ucham */
973 } GG_PACKED;
975 #define GG_LOGIN_EXT 0x0013
977 struct gg_login_ext {
978 uint32_t uin; /* mój numerek */
979 uint32_t hash; /* hash has³a */
980 uint32_t status; /* status na dzieñ dobry */
981 uint32_t version; /* moja wersja klienta */
982 uint32_t local_ip; /* mój adres ip */
983 uint16_t local_port; /* port, na którym s³ucham */
984 uint32_t external_ip; /* zewnêtrzny adres ip */
985 uint16_t external_port; /* zewnêtrzny port */
986 } GG_PACKED;
988 #define GG_LOGIN60 0x0015
990 struct gg_login60 {
991 uint32_t uin; /* mój numerek */
992 uint32_t hash; /* hash has³a */
993 uint32_t status; /* status na dzieñ dobry */
994 uint32_t version; /* moja wersja klienta */
995 uint8_t dunno1; /* 0x00 */
996 uint32_t local_ip; /* mój adres ip */
997 uint16_t local_port; /* port, na którym s³ucham */
998 uint32_t external_ip; /* zewnêtrzny adres ip */
999 uint16_t external_port; /* zewnêtrzny port */
1000 uint8_t image_size; /* maksymalny rozmiar grafiki w KiB */
1001 uint8_t dunno2; /* 0xbe */
1002 } GG_PACKED;
1004 #define GG_LOGIN_OK 0x0003
1006 #define GG_LOGIN_FAILED 0x0009
1008 #define GG_PUBDIR50_REQUEST 0x0014
1010 #define GG_PUBDIR50_WRITE 0x01
1011 #define GG_PUBDIR50_READ 0x02
1012 #define GG_PUBDIR50_SEARCH 0x03
1013 #define GG_PUBDIR50_SEARCH_REQUEST GG_PUBDIR50_SEARCH
1014 #define GG_PUBDIR50_SEARCH_REPLY 0x05
1016 struct gg_pubdir50_request {
1017 uint8_t type; /* GG_PUBDIR50_* */
1018 uint32_t seq; /* czas wys³ania zapytania */
1019 } GG_PACKED;
1021 #define GG_PUBDIR50_REPLY 0x000e
1023 struct gg_pubdir50_reply {
1024 uint8_t type; /* GG_PUBDIR50_* */
1025 uint32_t seq; /* czas wys³ania zapytania */
1026 } GG_PACKED;
1028 #define GG_NEW_STATUS 0x0002
1030 #define GG_STATUS_NOT_AVAIL 0x0001 /* niedostêpny */
1031 #define GG_STATUS_NOT_AVAIL_DESCR 0x0015 /* niedostêpny z opisem (4.8) */
1032 #define GG_STATUS_AVAIL 0x0002 /* dostêpny */
1033 #define GG_STATUS_AVAIL_DESCR 0x0004 /* dostêpny z opisem (4.9) */
1034 #define GG_STATUS_BUSY 0x0003 /* zajêty */
1035 #define GG_STATUS_BUSY_DESCR 0x0005 /* zajêty z opisem (4.8) */
1036 #define GG_STATUS_INVISIBLE 0x0014 /* niewidoczny (4.6) */
1037 #define GG_STATUS_INVISIBLE_DESCR 0x0016 /* niewidoczny z opisem (4.9) */
1038 #define GG_STATUS_BLOCKED 0x0006 /* zablokowany */
1040 #define GG_STATUS_FRIENDS_MASK 0x8000 /* tylko dla znajomych (4.6) */
1042 #define GG_STATUS_DESCR_MAXSIZE 70
1045 * makra do ³atwego i szybkiego sprawdzania stanu.
1048 /* GG_S_F() tryb tylko dla znajomych */
1049 #define GG_S_F(x) (((x) & GG_STATUS_FRIENDS_MASK) != 0)
1051 /* GG_S() stan bez uwzglêdnienia trybu tylko dla znajomych */
1052 #define GG_S(x) ((x) & ~GG_STATUS_FRIENDS_MASK)
1054 /* GG_S_A() dostêpny */
1055 #define GG_S_A(x) (GG_S(x) == GG_STATUS_AVAIL || GG_S(x) == GG_STATUS_AVAIL_DESCR)
1057 /* GG_S_NA() niedostêpny */
1058 #define GG_S_NA(x) (GG_S(x) == GG_STATUS_NOT_AVAIL || GG_S(x) == GG_STATUS_NOT_AVAIL_DESCR)
1060 /* GG_S_B() zajêty */
1061 #define GG_S_B(x) (GG_S(x) == GG_STATUS_BUSY || GG_S(x) == GG_STATUS_BUSY_DESCR)
1063 /* GG_S_I() niewidoczny */
1064 #define GG_S_I(x) (GG_S(x) == GG_STATUS_INVISIBLE || GG_S(x) == GG_STATUS_INVISIBLE_DESCR)
1066 /* GG_S_D() stan opisowy */
1067 #define GG_S_D(x) (GG_S(x) == GG_STATUS_NOT_AVAIL_DESCR || GG_S(x) == GG_STATUS_AVAIL_DESCR || GG_S(x) == GG_STATUS_BUSY_DESCR || GG_S(x) == GG_STATUS_INVISIBLE_DESCR)
1069 /* GG_S_BL() blokowany lub blokuj±cy */
1070 #define GG_S_BL(x) (GG_S(x) == GG_STATUS_BLOCKED)
1072 struct gg_new_status {
1073 uint32_t status; /* na jaki zmieniæ? */
1074 } GG_PACKED;
1076 #define GG_NOTIFY 0x0010
1078 struct gg_notify {
1079 uint32_t uin; /* numerek danej osoby */
1080 uint8_t dunno1; /* rodzaj wpisu w li¶cie */
1081 } GG_PACKED;
1083 #define GG_USER_OFFLINE 0x01 /* bêdziemy niewidoczni dla u¿ytkownika */
1084 #define GG_USER_NORMAL 0x03 /* zwyk³y u¿ytkownik */
1085 #define GG_USER_BLOCKED 0x04 /* zablokowany u¿ytkownik */
1087 #define GG_LIST_EMPTY 0x0012
1089 #define GG_NOTIFY_REPLY 0x000c /* tak, to samo co GG_LOGIN */
1091 struct gg_notify_reply {
1092 uint32_t uin; /* numerek */
1093 uint32_t status; /* status danej osoby */
1094 uint32_t remote_ip; /* adres ip delikwenta */
1095 uint16_t remote_port; /* port, na którym s³ucha klient */
1096 uint32_t version; /* wersja klienta */
1097 uint16_t dunno2; /* znowu port? */
1098 } GG_PACKED;
1100 #define GG_NOTIFY_REPLY60 0x0011
1102 struct gg_notify_reply60 {
1103 uint32_t uin; /* numerek plus flagi w MSB */
1104 uint8_t status; /* status danej osoby */
1105 uint32_t remote_ip; /* adres ip delikwenta */
1106 uint16_t remote_port; /* port, na którym s³ucha klient */
1107 uint8_t version; /* wersja klienta */
1108 uint8_t image_size; /* maksymalny rozmiar grafiki w KiB */
1109 uint8_t dunno1; /* 0x00 */
1110 } GG_PACKED;
1112 #define GG_STATUS60 0x000f
1114 struct gg_status60 {
1115 uint32_t uin; /* numerek plus flagi w MSB */
1116 uint8_t status; /* status danej osoby */
1117 uint32_t remote_ip; /* adres ip delikwenta */
1118 uint16_t remote_port; /* port, na którym s³ucha klient */
1119 uint8_t version; /* wersja klienta */
1120 uint8_t image_size; /* maksymalny rozmiar grafiki w KiB */
1121 uint8_t dunno1; /* 0x00 */
1122 } GG_PACKED;
1124 #define GG_ADD_NOTIFY 0x000d
1125 #define GG_REMOVE_NOTIFY 0x000e
1127 struct gg_add_remove {
1128 uint32_t uin; /* numerek */
1129 uint8_t dunno1; /* bitmapa */
1130 } GG_PACKED;
1132 #define GG_STATUS 0x0002
1134 struct gg_status {
1135 uint32_t uin; /* numerek */
1136 uint32_t status; /* nowy stan */
1137 } GG_PACKED;
1139 #define GG_SEND_MSG 0x000b
1141 #define GG_CLASS_QUEUED 0x0001
1142 #define GG_CLASS_OFFLINE GG_CLASS_QUEUED
1143 #define GG_CLASS_MSG 0x0004
1144 #define GG_CLASS_CHAT 0x0008
1145 #define GG_CLASS_CTCP 0x0010
1146 #define GG_CLASS_ACK 0x0020
1147 #define GG_CLASS_EXT GG_CLASS_ACK /* kompatybilno¶æ wstecz */
1149 #define GG_MSG_MAXSIZE 2000
1151 struct gg_send_msg {
1152 uint32_t recipient;
1153 uint32_t seq;
1154 uint32_t msgclass;
1155 } GG_PACKED;
1157 struct gg_msg_richtext {
1158 uint8_t flag;
1159 uint16_t length;
1160 } GG_PACKED;
1162 struct gg_msg_richtext_format {
1163 uint16_t position;
1164 uint8_t font;
1165 } GG_PACKED;
1167 struct gg_msg_richtext_image {
1168 uint16_t unknown1;
1169 uint32_t size;
1170 uint32_t crc32;
1171 } GG_PACKED;
1173 #define GG_FONT_BOLD 0x01
1174 #define GG_FONT_ITALIC 0x02
1175 #define GG_FONT_UNDERLINE 0x04
1176 #define GG_FONT_COLOR 0x08
1177 #define GG_FONT_IMAGE 0x80
1179 struct gg_msg_richtext_color {
1180 uint8_t red;
1181 uint8_t green;
1182 uint8_t blue;
1183 } GG_PACKED;
1185 struct gg_msg_recipients {
1186 uint8_t flag;
1187 uint32_t count;
1188 } GG_PACKED;
1190 struct gg_msg_image_request {
1191 uint8_t flag;
1192 uint32_t size;
1193 uint32_t crc32;
1194 } GG_PACKED;
1196 struct gg_msg_image_reply {
1197 uint8_t flag;
1198 uint32_t size;
1199 uint32_t crc32;
1200 /* char filename[]; */
1201 /* char image[]; */
1202 } GG_PACKED;
1204 #define GG_SEND_MSG_ACK 0x0005
1206 #define GG_ACK_DELIVERED 0x0002
1207 #define GG_ACK_QUEUED 0x0003
1208 #define GG_ACK_NOT_DELIVERED 0x0006
1210 struct gg_send_msg_ack {
1211 uint32_t status;
1212 uint32_t recipient;
1213 uint32_t seq;
1214 } GG_PACKED;
1216 #define GG_RECV_MSG 0x000a
1218 struct gg_recv_msg {
1219 uint32_t sender;
1220 uint32_t seq;
1221 uint32_t time;
1222 uint32_t msgclass;
1223 } GG_PACKED;
1225 #define GG_PING 0x0008
1227 #define GG_PONG 0x0007
1229 #define GG_DISCONNECTING 0x000b
1231 #define GG_USERLIST_REQUEST 0x0016
1233 #define GG_USERLIST_PUT 0x00
1234 #define GG_USERLIST_PUT_MORE 0x01
1235 #define GG_USERLIST_GET 0x02
1237 struct gg_userlist_request {
1238 uint8_t type;
1239 } GG_PACKED;
1241 #define GG_USERLIST_REPLY 0x0010
1243 #define GG_USERLIST_PUT_REPLY 0x00
1244 #define GG_USERLIST_PUT_MORE_REPLY 0x02
1245 #define GG_USERLIST_GET_REPLY 0x06
1246 #define GG_USERLIST_GET_MORE_REPLY 0x04
1248 struct gg_userlist_reply {
1249 uint8_t type;
1250 } GG_PACKED;
1253 * pakiety, sta³e, struktury dla DCC
1256 struct gg_dcc_tiny_packet {
1257 uint8_t type; /* rodzaj pakietu */
1258 } GG_PACKED;
1260 struct gg_dcc_small_packet {
1261 uint32_t type; /* rodzaj pakietu */
1262 } GG_PACKED;
1264 struct gg_dcc_big_packet {
1265 uint32_t type; /* rodzaj pakietu */
1266 uint32_t dunno1; /* niewiadoma */
1267 uint32_t dunno2; /* niewiadoma */
1268 } GG_PACKED;
1271 * póki co, nie znamy dok³adnie protoko³u. nie wiemy, co czemu odpowiada.
1272 * nazwy s± niepowa¿ne i tymczasowe.
1274 #define GG_DCC_WANT_FILE 0x0003 /* peer chce plik */
1275 #define GG_DCC_HAVE_FILE 0x0001 /* wiêc mu damy */
1276 #define GG_DCC_HAVE_FILEINFO 0x0003 /* niech ma informacje o pliku */
1277 #define GG_DCC_GIMME_FILE 0x0006 /* peer jest pewny */
1278 #define GG_DCC_CATCH_FILE 0x0002 /* wysy³amy plik */
1280 #define GG_DCC_FILEATTR_READONLY 0x0020
1282 #define GG_DCC_TIMEOUT_SEND 1800 /* 30 minut */
1283 #define GG_DCC_TIMEOUT_GET 1800 /* 30 minut */
1284 #define GG_DCC_TIMEOUT_FILE_ACK 300 /* 5 minut */
1285 #define GG_DCC_TIMEOUT_VOICE_ACK 300 /* 5 minut */
1287 #ifdef __cplusplus
1289 #ifdef _WIN32
1290 #pragma pack(pop)
1291 #endif
1292 #endif
1294 #endif /* __GG_LIBGADU_H */
1297 * Local variables:
1298 * c-indentation-style: k&r
1299 * c-basic-offset: 8
1300 * indent-tabs-mode: notnil
1301 * End:
1303 * vim: shiftwidth=8: