Updated Changelog
[centerim/davrieb.git] / libgadu / libgadu.h
blob416c55298b82d3ae58dd1a50c9fff5d39dabd736
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 #ifdef HAVE_OPENSSL
42 #ifndef OPENSSL_NO_KRB5
43 #define OPENSSL_NO_KRB5 1
44 #endif
46 #include <openssl/ssl.h>
48 #elif HAVE_GNUTLS
49 #include <gnutls/openssl.h>
50 #endif
53 * typedef uin_t
55 * typ reprezentuj±cy numer osoby.
57 typedef uint32_t uin_t;
60 * ogólna struktura opisuj±ca ró¿ne sesje. przydatna w klientach.
62 #define gg_common_head(x) \
63 int fd; /* podgl±dany deskryptor */ \
64 int check; /* sprawdzamy zapis czy odczyt */ \
65 int state; /* aktualny stan maszynki */ \
66 int error; /* kod b³êdu dla GG_STATE_ERROR */ \
67 int type; /* rodzaj sesji */ \
68 int id; /* identyfikator */ \
69 int timeout; /* sugerowany timeout w sekundach */ \
70 int (*callback)(x*); /* callback przy zmianach */ \
71 void (*destroy)(x*); /* funkcja niszczenia */
73 struct gg_common {
74 gg_common_head(struct gg_common)
77 struct gg_image_queue;
80 * struct gg_session
82 * struktura opisuj±ca dan± sesjê. tworzona przez gg_login(), zwalniana
83 * przez gg_free_session().
85 struct gg_session {
86 gg_common_head(struct gg_session)
88 int async; /* czy po³±czenie jest asynchroniczne */
89 int pid; /* pid procesu resolvera */
90 int port; /* port, z którym siê ³±czymy */
91 int seq; /* numer sekwencyjny ostatniej wiadomo¶ci */
92 int last_pong; /* czas otrzymania ostatniego ping/pong */
93 int last_event; /* czas otrzymania ostatniego pakietu */
95 struct gg_event *event; /* zdarzenie po ->callback() */
97 uint32_t proxy_addr; /* adres proxy, keszowany */
98 uint16_t proxy_port; /* port proxy */
100 uint32_t hub_addr; /* adres huba po resolvniêciu */
101 uint32_t server_addr; /* adres serwera, od huba */
103 uint32_t client_addr; /* adres klienta */
104 uint16_t client_port; /* port, na którym klient s³ucha */
106 uint32_t external_addr; /* adres zewnetrzny klienta */
107 uint16_t external_port; /* port zewnetrzny klienta */
109 uin_t uin; /* numerek klienta */
110 char *password; /* i jego has³o. zwalniane automagicznie */
112 int initial_status; /* pocz±tkowy stan klienta */
113 int status; /* aktualny stan klienta */
115 char *recv_buf; /* bufor na otrzymywane pakiety */
116 int recv_done; /* ile ju¿ wczytano do bufora */
117 int recv_left; /* i ile jeszcze trzeba wczytaæ */
119 int protocol_version; /* wersja u¿ywanego protoko³u */
120 char *client_version; /* wersja u¿ywanego klienta */
121 int last_sysmsg; /* ostatnia wiadomo¶æ systemowa */
123 char *initial_descr; /* pocz±tkowy opis stanu klienta */
125 void *resolver; /* wska¼nik na informacje resolvera */
127 char *header_buf; /* bufor na pocz±tek nag³ówka */
128 unsigned int header_done;/* ile ju¿ mamy */
130 #ifdef HAVE_OPENSSL
131 SSL *ssl; /* sesja TLS */
132 SSL_CTX *ssl_ctx; /* kontekst sesji? */
133 #elif HAVE_GNUTLS
134 gnutls_session_t session; /* TLS session */
135 gnutls_certificate_credentials_t xcred; /*Credentials*/
136 #endif
138 int image_size; /* maksymalny rozmiar obrazków w KiB */
140 char *userlist_reply; /* fragment odpowiedzi listy kontaktów */
142 int userlist_blocks; /* na ile kawa³ków podzielono listê kontaktów */
144 struct gg_image_queue *images; /* aktualnie wczytywane obrazki */
148 * struct gg_http
150 * ogólna struktura opisuj±ca stan wszystkich operacji HTTP. tworzona
151 * przez gg_http_connect(), zwalniana przez gg_http_free().
153 struct gg_http {
154 gg_common_head(struct gg_http)
156 int async; /* czy po³±czenie asynchroniczne */
157 int pid; /* pid procesu resolvera */
158 int port; /* port, z którym siê ³±czymy */
160 char *query; /* bufor zapytania http */
161 char *header; /* bufor nag³ówka */
162 int header_size; /* rozmiar wczytanego nag³ówka */
163 char *body; /* bufor otrzymanych informacji */
164 unsigned int body_size; /* oczekiwana ilo¶æ informacji */
166 void *data; /* dane danej operacji http */
168 char *user_data; /* dane u¿ytkownika, nie s± zwalniane przez gg_http_free() */
170 void *resolver; /* wska¼nik na informacje resolvera */
172 unsigned int body_done; /* ile ju¿ tre¶ci odebrano? */
175 #ifdef __GNUC__
176 #define GG_PACKED __attribute__ ((packed))
177 #else
178 #define GG_PACKED
179 #endif
181 #define GG_MAX_PATH 276
184 * struct gg_file_info
186 * odpowiednik windowsowej struktury WIN32_FIND_DATA niezbêdnej przy
187 * wysy³aniu plików.
189 struct gg_file_info {
190 uint32_t mode; /* dwFileAttributes */
191 uint32_t ctime[2]; /* ftCreationTime */
192 uint32_t atime[2]; /* ftLastAccessTime */
193 uint32_t mtime[2]; /* ftLastWriteTime */
194 uint32_t size_hi; /* nFileSizeHigh */
195 uint32_t size; /* nFileSizeLow */
196 uint32_t reserved0; /* dwReserved0 */
197 uint32_t reserved1; /* dwReserved1 */
198 unsigned char filename[GG_MAX_PATH - 14]; /* cFileName */
199 unsigned char short_filename[14]; /* cAlternateFileName */
200 } GG_PACKED;
203 * struct gg_dcc
205 * struktura opisuj±ca nas³uchuj±ce gniazdo po³±czeñ miêdzy klientami.
206 * tworzona przez gg_dcc_socket_create(), zwalniana przez gg_dcc_free().
208 struct gg_dcc {
209 gg_common_head(struct gg_dcc)
211 struct gg_event *event; /* opis zdarzenia */
213 int active; /* czy to my siê ³±czymy? */
214 int port; /* port, na którym siedzi */
215 uin_t uin; /* uin klienta */
216 uin_t peer_uin; /* uin drugiej strony */
217 int file_fd; /* deskryptor pliku */
218 unsigned int offset; /* offset w pliku */
219 unsigned int chunk_size;/* rozmiar kawa³ka */
220 unsigned int chunk_offset;/* offset w aktualnym kawa³ku */
221 struct gg_file_info file_info;
222 /* informacje o pliku */
223 int established; /* po³±czenie ustanowione */
224 char *voice_buf; /* bufor na pakiet po³±czenia g³osowego */
225 int incoming; /* po³±czenie przychodz±ce */
226 char *chunk_buf; /* bufor na kawa³ek danych */
227 uint32_t remote_addr; /* adres drugiej strony */
228 uint16_t remote_port; /* port drugiej strony */
232 * enum gg_session_t
234 * rodzaje sesji.
236 enum gg_session_t {
237 GG_SESSION_GG = 1, /* po³±czenie z serwerem gg */
238 GG_SESSION_HTTP, /* ogólna sesja http */
239 GG_SESSION_SEARCH, /* szukanie */
240 GG_SESSION_REGISTER, /* rejestrowanie */
241 GG_SESSION_REMIND, /* przypominanie has³a */
242 GG_SESSION_PASSWD, /* zmiana has³a */
243 GG_SESSION_CHANGE, /* zmiana informacji o sobie */
244 GG_SESSION_DCC, /* ogólne po³±czenie DCC */
245 GG_SESSION_DCC_SOCKET, /* nas³uchuj±cy socket */
246 GG_SESSION_DCC_SEND, /* wysy³anie pliku */
247 GG_SESSION_DCC_GET, /* odbieranie pliku */
248 GG_SESSION_DCC_VOICE, /* rozmowa g³osowa */
249 GG_SESSION_USERLIST_GET, /* pobieranie userlisty */
250 GG_SESSION_USERLIST_PUT, /* wysy³anie userlisty */
251 GG_SESSION_UNREGISTER, /* usuwanie konta */
252 GG_SESSION_USERLIST_REMOVE, /* usuwanie userlisty */
253 GG_SESSION_TOKEN, /* pobieranie tokenu */
255 GG_SESSION_USER0 = 256, /* zdefiniowana dla u¿ytkownika */
256 GG_SESSION_USER1, /* j.w. */
257 GG_SESSION_USER2, /* j.w. */
258 GG_SESSION_USER3, /* j.w. */
259 GG_SESSION_USER4, /* j.w. */
260 GG_SESSION_USER5, /* j.w. */
261 GG_SESSION_USER6, /* j.w. */
262 GG_SESSION_USER7 /* j.w. */
266 * enum gg_state_t
268 * opisuje stan asynchronicznej maszyny.
270 enum gg_state_t {
271 /* wspólne */
272 GG_STATE_IDLE = 0, /* nie powinno wyst±piæ. */
273 GG_STATE_RESOLVING, /* wywo³a³ gethostbyname() */
274 GG_STATE_CONNECTING, /* wywo³a³ connect() */
275 GG_STATE_READING_DATA, /* czeka na dane http */
276 GG_STATE_ERROR, /* wyst±pi³ b³±d. kod w x->error */
278 /* gg_session */
279 GG_STATE_CONNECTING_HUB, /* wywo³a³ connect() na huba */
280 GG_STATE_CONNECTING_GG, /* wywo³a³ connect() na serwer */
281 GG_STATE_READING_KEY, /* czeka na klucz */
282 GG_STATE_READING_REPLY, /* czeka na odpowied¼ */
283 GG_STATE_CONNECTED, /* po³±czy³ siê */
285 /* gg_http */
286 GG_STATE_SENDING_QUERY, /* wysy³a zapytanie http */
287 GG_STATE_READING_HEADER, /* czeka na nag³ówek http */
288 GG_STATE_PARSING, /* przetwarza dane */
289 GG_STATE_DONE, /* skoñczy³ */
291 /* gg_dcc */
292 GG_STATE_LISTENING, /* czeka na po³±czenia */
293 GG_STATE_READING_UIN_1, /* czeka na uin peera */
294 GG_STATE_READING_UIN_2, /* czeka na swój uin */
295 GG_STATE_SENDING_ACK, /* wysy³a potwierdzenie dcc */
296 GG_STATE_READING_ACK, /* czeka na potwierdzenie dcc */
297 GG_STATE_READING_REQUEST, /* czeka na komendê */
298 GG_STATE_SENDING_REQUEST, /* wysy³a komendê */
299 GG_STATE_SENDING_FILE_INFO, /* wysy³a informacje o pliku */
300 GG_STATE_READING_PRE_FILE_INFO, /* czeka na pakiet przed file_info */
301 GG_STATE_READING_FILE_INFO, /* czeka na informacje o pliku */
302 GG_STATE_SENDING_FILE_ACK, /* wysy³a potwierdzenie pliku */
303 GG_STATE_READING_FILE_ACK, /* czeka na potwierdzenie pliku */
304 GG_STATE_SENDING_FILE_HEADER, /* wysy³a nag³ówek pliku */
305 GG_STATE_READING_FILE_HEADER, /* czeka na nag³ówek */
306 GG_STATE_GETTING_FILE, /* odbiera plik */
307 GG_STATE_SENDING_FILE, /* wysy³a plik */
308 GG_STATE_READING_VOICE_ACK, /* czeka na potwierdzenie voip */
309 GG_STATE_READING_VOICE_HEADER, /* czeka na rodzaj bloku voip */
310 GG_STATE_READING_VOICE_SIZE, /* czeka na rozmiar bloku voip */
311 GG_STATE_READING_VOICE_DATA, /* czeka na dane voip */
312 GG_STATE_SENDING_VOICE_ACK, /* wysy³a potwierdzenie voip */
313 GG_STATE_SENDING_VOICE_REQUEST, /* wysy³a ¿±danie voip */
314 GG_STATE_READING_TYPE, /* czeka na typ po³±czenia */
316 /* nowe. bez sensu jest to API. */
317 GG_STATE_TLS_NEGOTIATION /* negocjuje po³±czenie TLS */
321 * enum gg_check_t
323 * informuje, co proces klienta powinien sprawdziæ na deskryptorze danego
324 * po³±czenia.
326 enum gg_check_t {
327 GG_CHECK_NONE = 0, /* nic. nie powinno wyst±piæ */
328 GG_CHECK_WRITE = 1, /* sprawdzamy mo¿liwo¶æ zapisu */
329 GG_CHECK_READ = 2 /* sprawdzamy mo¿liwo¶æ odczytu */
333 * struct gg_login_params
335 * parametry gg_login(). przeniesiono do struktury, ¿eby unikn±æ problemów
336 * z ci±g³ymi zmianami API, gdy dodano co¶ nowego do protoko³u.
338 struct gg_login_params {
339 uin_t uin; /* numerek */
340 char *password; /* has³o */
341 int async; /* asynchroniczne sockety? */
342 int status; /* pocz±tkowy status klienta */
343 char *status_descr; /* opis statusu */
344 uint32_t server_addr; /* adres serwera gg */
345 uint16_t server_port; /* port serwera gg */
346 uint32_t client_addr; /* adres dcc klienta */
347 uint16_t client_port; /* port dcc klienta */
348 int protocol_version; /* wersja protoko³u */
349 char *client_version; /* wersja klienta */
350 int has_audio; /* czy ma d¼wiêk? */
351 int last_sysmsg; /* ostatnia wiadomo¶æ systemowa */
352 uint32_t external_addr; /* adres widziany na zewnatrz */
353 uint16_t external_port; /* port widziany na zewnatrz */
354 int tls; /* czy ³±czymy po TLS? */
355 int image_size; /* maksymalny rozmiar obrazka w KiB */
357 char dummy[6 * sizeof(int)]; /* miejsce na kolejnych 8 zmiennych,
358 * ¿eby z dodaniem parametru nie
359 * zmienia³ siê rozmiar struktury */
362 struct gg_session *gg_login(const struct gg_login_params *p);
363 void gg_free_session(struct gg_session *sess);
364 void gg_logoff(struct gg_session *sess);
365 int gg_change_status(struct gg_session *sess, int status);
366 int gg_change_status_descr(struct gg_session *sess, int status, const char *descr);
367 int gg_change_status_descr_time(struct gg_session *sess, int status, const char *descr, int time);
368 int gg_send_message(struct gg_session *sess, int msgclass, uin_t recipient, const unsigned char *message);
369 int gg_send_message_richtext(struct gg_session *sess, int msgclass, uin_t recipient, const unsigned char *message, const unsigned char *format, int formatlen);
370 int gg_send_message_confer(struct gg_session *sess, int msgclass, int recipients_count, uin_t *recipients, const unsigned char *message);
371 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);
372 int gg_send_message_ctcp(struct gg_session *sess, int msgclass, uin_t recipient, const unsigned char *message, int message_len);
373 int gg_ping(struct gg_session *sess);
374 int gg_userlist_request(struct gg_session *sess, char type, const char *request);
375 int gg_image_request(struct gg_session *sess, uin_t recipient, int size, uint32_t crc32);
376 int gg_image_reply(struct gg_session *sess, uin_t recipient, const char *filename, const char *image, int size);
378 uint32_t gg_crc32(uint32_t crc, const unsigned char *buf, int len);
380 struct gg_image_queue {
381 uin_t sender; /* nadawca obrazka */
382 uint32_t size; /* rozmiar */
383 uint32_t crc32; /* suma kontrolna */
384 char *filename; /* nazwa pliku */
385 char *image; /* bufor z obrazem */
386 uint32_t done; /* ile ju¿ wczytano */
388 struct gg_image_queue *next; /* nastêpny na li¶cie */
392 * enum gg_event_t
394 * rodzaje zdarzeñ.
396 enum gg_event_t {
397 GG_EVENT_NONE = 0, /* nic siê nie wydarzy³o */
398 GG_EVENT_MSG, /* otrzymano wiadomo¶æ */
399 GG_EVENT_NOTIFY, /* kto¶ siê pojawi³ */
400 GG_EVENT_NOTIFY_DESCR, /* kto¶ siê pojawi³ z opisem */
401 GG_EVENT_STATUS, /* kto¶ zmieni³ stan */
402 GG_EVENT_ACK, /* potwierdzenie wys³ania wiadomo¶ci */
403 GG_EVENT_PONG, /* pakiet pong */
404 GG_EVENT_CONN_FAILED, /* po³±czenie siê nie uda³o */
405 GG_EVENT_CONN_SUCCESS, /* po³±czenie siê powiod³o */
406 GG_EVENT_DISCONNECT, /* serwer zrywa po³±czenie */
408 GG_EVENT_DCC_NEW, /* nowe po³±czenie miêdzy klientami */
409 GG_EVENT_DCC_ERROR, /* b³±d po³±czenia miêdzy klientami */
410 GG_EVENT_DCC_DONE, /* zakoñczono po³±czenie */
411 GG_EVENT_DCC_CLIENT_ACCEPT, /* moment akceptacji klienta */
412 GG_EVENT_DCC_CALLBACK, /* klient siê po³±czy³ na ¿±danie */
413 GG_EVENT_DCC_NEED_FILE_INFO, /* nale¿y wype³niæ file_info */
414 GG_EVENT_DCC_NEED_FILE_ACK, /* czeka na potwierdzenie pliku */
415 GG_EVENT_DCC_NEED_VOICE_ACK, /* czeka na potwierdzenie rozmowy */
416 GG_EVENT_DCC_VOICE_DATA, /* ramka danych rozmowy g³osowej */
418 GG_EVENT_PUBDIR50_SEARCH_REPLY, /* odpowiedz wyszukiwania */
419 GG_EVENT_PUBDIR50_READ, /* odczytano w³asne dane z katalogu */
420 GG_EVENT_PUBDIR50_WRITE, /* wpisano w³asne dane do katalogu */
422 GG_EVENT_STATUS60, /* kto¶ zmieni³ stan w GG 6.0 */
423 GG_EVENT_NOTIFY60, /* kto¶ siê pojawi³ w GG 6.0 */
424 GG_EVENT_USERLIST, /* odpowied¼ listy kontaktów w GG 6.0 */
425 GG_EVENT_IMAGE_REQUEST, /* pro¶ba o wys³anie obrazka GG 6.0 */
426 GG_EVENT_IMAGE_REPLY, /* podes³any obrazek GG 6.0 */
427 GG_EVENT_DCC_ACK /* potwierdzenie transmisji */
430 #define GG_EVENT_SEARCH50_REPLY GG_EVENT_PUBDIR50_SEARCH_REPLY
433 * enum gg_failure_t
435 * okre¶la powód nieudanego po³±czenia.
437 enum gg_failure_t {
438 GG_FAILURE_RESOLVING = 1, /* nie znaleziono serwera */
439 GG_FAILURE_CONNECTING, /* nie mo¿na siê po³±czyæ */
440 GG_FAILURE_INVALID, /* serwer zwróci³ nieprawid³owe dane */
441 GG_FAILURE_READING, /* zerwano po³±czenie podczas odczytu */
442 GG_FAILURE_WRITING, /* zerwano po³±czenie podczas zapisu */
443 GG_FAILURE_PASSWORD, /* nieprawid³owe has³o */
444 GG_FAILURE_404, /* XXX nieu¿ywane */
445 GG_FAILURE_TLS, /* b³±d negocjacji TLS */
446 GG_FAILURE_NEED_EMAIL /* serwer roz³±czy³ nas z pro¶b± o zmianê emaila */
450 * enum gg_error_t
452 * okre¶la rodzaj b³êdu wywo³anego przez dan± operacjê. nie zawiera
453 * przesadnie szczegó³owych informacji o powodzie b³êdu, by nie komplikowaæ
454 * obs³ugi b³êdów. je¶li wymagana jest wiêksza dok³adno¶æ, nale¿y sprawdziæ
455 * zawarto¶æ zmiennej errno.
457 enum gg_error_t {
458 GG_ERROR_RESOLVING = 1, /* b³±d znajdowania hosta */
459 GG_ERROR_CONNECTING, /* b³±d ³aczenia siê */
460 GG_ERROR_READING, /* b³±d odczytu */
461 GG_ERROR_WRITING, /* b³±d wysy³ania */
463 GG_ERROR_DCC_HANDSHAKE, /* b³±d negocjacji */
464 GG_ERROR_DCC_FILE, /* b³±d odczytu/zapisu pliku */
465 GG_ERROR_DCC_EOF, /* plik siê skoñczy³? */
466 GG_ERROR_DCC_NET, /* b³±d wysy³ania/odbierania */
467 GG_ERROR_DCC_REFUSED /* po³±czenie odrzucone przez usera */
471 * struktury dotycz±ce wyszukiwania w GG 5.0. NIE NALE¯Y SIÊ DO NICH
472 * ODWO£YWAÆ BEZPO¦REDNIO! do dostêpu do nich s³u¿± funkcje gg_pubdir50_*()
474 struct gg_pubdir50_entry {
475 int num;
476 char *field;
477 char *value;
480 struct gg_pubdir50_s {
481 int count;
482 uin_t next;
483 int type;
484 uint32_t seq;
485 struct gg_pubdir50_entry *entries;
486 int entries_count;
490 * typedef gg_pubdir_50_t
492 * typ opisuj±cy zapytanie lub wynik zapytania katalogu publicznego
493 * z protoko³u GG 5.0. nie nale¿y siê odwo³ywaæ bezpo¶rednio do jego
494 * pól -- s³u¿± do tego funkcje gg_pubdir50_*()
496 typedef struct gg_pubdir50_s *gg_pubdir50_t;
499 * struct gg_event
501 * struktura opisuj±ca rodzaj zdarzenia. wychodzi z gg_watch_fd() lub
502 * z gg_dcc_watch_fd()
504 struct gg_event {
505 int type; /* rodzaj zdarzenia -- gg_event_t */
506 union { /* @event */
507 struct gg_notify_reply *notify; /* informacje o li¶cie kontaktów -- GG_EVENT_NOTIFY */
509 enum gg_failure_t failure; /* b³±d po³±czenia -- GG_EVENT_FAILURE */
511 struct gg_dcc *dcc_new; /* nowe po³±czenie bezpo¶rednie -- GG_EVENT_DCC_NEW */
513 int dcc_error; /* b³±d po³±czenia bezpo¶redniego -- GG_EVENT_DCC_ERROR */
515 gg_pubdir50_t pubdir50; /* wynik operacji zwi±zanej z katalogiem publicznym -- GG_EVENT_PUBDIR50_* */
517 struct { /* @msg odebrano wiadomo¶æ -- GG_EVENT_MSG */
518 uin_t sender; /* numer nadawcy */
519 int msgclass; /* klasa wiadomo¶ci */
520 time_t time; /* czas nadania */
521 unsigned char *message; /* tre¶æ wiadomo¶ci */
523 int recipients_count; /* ilo¶æ odbiorców konferencji */
524 uin_t *recipients; /* odbiorcy konferencji */
526 int formats_length; /* d³ugo¶æ informacji o formatowaniu tekstu */
527 void *formats; /* informacje o formatowaniu tekstu */
528 } msg;
530 struct { /* @notify_descr informacje o li¶cie kontaktów z opisami stanu -- GG_EVENT_NOTIFY_DESCR */
531 struct gg_notify_reply *notify; /* informacje o li¶cie kontaktów */
532 char *descr; /* opis stanu */
533 } notify_descr;
535 struct { /* @status zmiana stanu -- GG_EVENT_STATUS */
536 uin_t uin; /* numer */
537 uint32_t status; /* nowy stan */
538 char *descr; /* opis stanu */
539 } status;
541 struct { /* @status60 zmiana stanu -- GG_EVENT_STATUS60 */
542 uin_t uin; /* numer */
543 int status; /* nowy stan */
544 uint32_t remote_ip; /* adres ip */
545 uint16_t remote_port; /* port */
546 int version; /* wersja klienta */
547 int image_size; /* maksymalny rozmiar grafiki w KiB */
548 char *descr; /* opis stanu */
549 time_t time; /* czas powrotu */
550 } status60;
552 struct { /* @notify60 informacja o li¶cie kontaktów -- GG_EVENT_NOTIFY60 */
553 uin_t uin; /* numer */
554 int status; /* stan */
555 uint32_t remote_ip; /* adres ip */
556 uint16_t remote_port; /* port */
557 int version; /* wersja klienta */
558 int image_size; /* maksymalny rozmiar grafiki w KiB */
559 char *descr; /* opis stanu */
560 time_t time; /* czas powrotu */
561 } *notify60;
563 struct { /* @ack potwierdzenie wiadomo¶ci -- GG_EVENT_ACK */
564 uin_t recipient; /* numer odbiorcy */
565 int status; /* stan dorêczenia wiadomo¶ci */
566 int seq; /* numer sekwencyjny wiadomo¶ci */
567 } ack;
569 struct { /* @dcc_voice_data otrzymano dane d¼wiêkowe -- GG_EVENT_DCC_VOICE_DATA */
570 uint8_t *data; /* dane d¼wiêkowe */
571 int length; /* ilo¶æ danych d¼wiêkowych */
572 } dcc_voice_data;
574 struct { /* @userlist odpowied¼ listy kontaktów serwera */
575 char type; /* rodzaj odpowiedzi */
576 char *reply; /* tre¶æ odpowiedzi */
577 } userlist;
579 struct { /* @image_request pro¶ba o obrazek */
580 uin_t sender; /* nadawca pro¶by */
581 uint32_t size; /* rozmiar obrazka */
582 uint32_t crc32; /* suma kontrolna */
583 } image_request;
585 struct { /* @image_reply odpowied¼ z obrazkiem */
586 uin_t sender; /* nadawca odpowiedzi */
587 uint32_t size; /* rozmiar obrazka */
588 uint32_t crc32; /* suma kontrolna */
589 char *filename; /* nazwa pliku */
590 char *image; /* bufor z obrazkiem */
591 } image_reply;
592 } event;
595 struct gg_event *gg_watch_fd(struct gg_session *sess);
596 void gg_event_free(struct gg_event *e);
597 #define gg_free_event gg_event_free
600 * funkcje obs³ugi listy kontaktów.
602 int gg_notify_ex(struct gg_session *sess, uin_t *userlist, char *types, int count);
603 int gg_notify(struct gg_session *sess, uin_t *userlist, int count);
604 int gg_add_notify_ex(struct gg_session *sess, uin_t uin, char type);
605 int gg_add_notify(struct gg_session *sess, uin_t uin);
606 int gg_remove_notify_ex(struct gg_session *sess, uin_t uin, char type);
607 int gg_remove_notify(struct gg_session *sess, uin_t uin);
610 * funkcje obs³ugi http.
612 struct gg_http *gg_http_connect(const char *hostname, int port, int async, const char *method, const char *path, const char *header);
613 int gg_http_watch_fd(struct gg_http *h);
614 void gg_http_stop(struct gg_http *h);
615 void gg_http_free(struct gg_http *h);
616 void gg_http_free_fields(struct gg_http *h);
617 #define gg_free_http gg_http_free
620 * struktury opisuj±ca kryteria wyszukiwania dla gg_search(). nieaktualne,
621 * zast±pione przez gg_pubdir50_t. pozostawiono je dla zachowania ABI.
623 struct gg_search_request {
624 int active;
625 unsigned int start;
626 char *nickname;
627 char *first_name;
628 char *last_name;
629 char *city;
630 int gender;
631 int min_birth;
632 int max_birth;
633 char *email;
634 char *phone;
635 uin_t uin;
638 struct gg_search {
639 int count;
640 struct gg_search_result *results;
643 struct gg_search_result {
644 uin_t uin;
645 char *first_name;
646 char *last_name;
647 char *nickname;
648 int born;
649 int gender;
650 char *city;
651 int active;
654 #define GG_GENDER_NONE 0
655 #define GG_GENDER_FEMALE 1
656 #define GG_GENDER_MALE 2
659 * funkcje wyszukiwania.
661 struct gg_http *gg_search(const struct gg_search_request *r, int async);
662 int gg_search_watch_fd(struct gg_http *f);
663 void gg_free_search(struct gg_http *f);
664 #define gg_search_free gg_free_search
666 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);
667 const struct gg_search_request *gg_search_request_mode_1(char *email, int active, int start);
668 const struct gg_search_request *gg_search_request_mode_2(char *phone, int active, int start);
669 const struct gg_search_request *gg_search_request_mode_3(uin_t uin, int active, int start);
670 void gg_search_request_free(struct gg_search_request *r);
673 * funkcje obs³ugi katalogu publicznego zgodne z GG 5.0. tym razem funkcje
674 * zachowuj± pewien poziom abstrakcji, ¿eby unikn±æ zmian ABI przy zmianach
675 * w protokole.
677 * NIE NALE¯Y SIÊ ODWO£YWAÆ DO PÓL gg_pubdir50_t BEZPO¦REDNIO!
679 uint32_t gg_pubdir50(struct gg_session *sess, gg_pubdir50_t req);
680 gg_pubdir50_t gg_pubdir50_new(int type);
681 int gg_pubdir50_add(gg_pubdir50_t req, const char *field, const char *value);
682 int gg_pubdir50_seq_set(gg_pubdir50_t req, uint32_t seq);
683 const char *gg_pubdir50_get(gg_pubdir50_t res, int num, const char *field);
684 int gg_pubdir50_type(gg_pubdir50_t res);
685 int gg_pubdir50_count(gg_pubdir50_t res);
686 uin_t gg_pubdir50_next(gg_pubdir50_t res);
687 uint32_t gg_pubdir50_seq(gg_pubdir50_t res);
688 void gg_pubdir50_free(gg_pubdir50_t res);
690 #define GG_PUBDIR50_UIN "FmNumber"
691 #define GG_PUBDIR50_STATUS "FmStatus"
692 #define GG_PUBDIR50_FIRSTNAME "firstname"
693 #define GG_PUBDIR50_LASTNAME "lastname"
694 #define GG_PUBDIR50_NICKNAME "nickname"
695 #define GG_PUBDIR50_BIRTHYEAR "birthyear"
696 #define GG_PUBDIR50_CITY "city"
697 #define GG_PUBDIR50_GENDER "gender"
698 #define GG_PUBDIR50_GENDER_FEMALE "1"
699 #define GG_PUBDIR50_GENDER_MALE "2"
700 #define GG_PUBDIR50_GENDER_SET_FEMALE "2"
701 #define GG_PUBDIR50_GENDER_SET_MALE "1"
702 #define GG_PUBDIR50_ACTIVE "ActiveOnly"
703 #define GG_PUBDIR50_ACTIVE_TRUE "1"
704 #define GG_PUBDIR50_START "fmstart"
705 #define GG_PUBDIR50_FAMILYNAME "familyname"
706 #define GG_PUBDIR50_FAMILYCITY "familycity"
708 int gg_pubdir50_handle_reply(struct gg_event *e, const char *packet, int length);
711 * struct gg_pubdir
713 * operacje na katalogu publicznym.
715 struct gg_pubdir {
716 int success; /* czy siê uda³o */
717 uin_t uin; /* otrzymany numerek. 0 je¶li b³±d */
720 /* ogólne funkcje, nie powinny byæ u¿ywane */
721 int gg_pubdir_watch_fd(struct gg_http *f);
722 void gg_pubdir_free(struct gg_http *f);
723 #define gg_free_pubdir gg_pubdir_free
725 struct gg_token {
726 int width; /* szeroko¶æ obrazka */
727 int height; /* wysoko¶æ obrazka */
728 int length; /* ilo¶æ znaków w tokenie */
729 char *tokenid; /* id tokenu */
732 /* funkcje dotycz±ce tokenów */
733 struct gg_http *gg_token(int async);
734 int gg_token_watch_fd(struct gg_http *h);
735 void gg_token_free(struct gg_http *h);
737 /* rejestracja nowego numerka */
738 struct gg_http *gg_register(const char *email, const char *password, int async);
739 struct gg_http *gg_register2(const char *email, const char *password, const char *qa, int async);
740 struct gg_http *gg_register3(const char *email, const char *password, const char *tokenid, const char *tokenval, int async);
741 #define gg_register_watch_fd gg_pubdir_watch_fd
742 #define gg_register_free gg_pubdir_free
743 #define gg_free_register gg_pubdir_free
745 struct gg_http *gg_unregister(uin_t uin, const char *password, const char *email, int async);
746 struct gg_http *gg_unregister2(uin_t uin, const char *password, const char *qa, int async);
747 struct gg_http *gg_unregister3(uin_t uin, const char *password, const char *tokenid, const char *tokenval, int async);
748 #define gg_unregister_watch_fd gg_pubdir_watch_fd
749 #define gg_unregister_free gg_pubdir_free
751 /* przypomnienie has³a e-mailem */
752 struct gg_http *gg_remind_passwd(uin_t uin, int async);
753 struct gg_http *gg_remind_passwd2(uin_t uin, const char *tokenid, const char *tokenval, int async);
754 #define gg_remind_passwd_watch_fd gg_pubdir_watch_fd
755 #define gg_remind_passwd_free gg_pubdir_free
756 #define gg_free_remind_passwd gg_pubdir_free
758 /* zmiana has³a */
759 struct gg_http *gg_change_passwd(uin_t uin, const char *passwd, const char *newpasswd, const char *newemail, int async);
760 struct gg_http *gg_change_passwd2(uin_t uin, const char *passwd, const char *newpasswd, const char *email, const char *newemail, int async);
761 struct gg_http *gg_change_passwd3(uin_t uin, const char *passwd, const char *newpasswd, const char *qa, int async);
762 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);
763 #define gg_change_passwd_free gg_pubdir_free
764 #define gg_free_change_passwd gg_pubdir_free
767 * struct gg_change_info_request
769 * opis ¿±dania zmiany informacji w katalogu publicznym.
771 struct gg_change_info_request {
772 char *first_name; /* imiê */
773 char *last_name; /* nazwisko */
774 char *nickname; /* pseudonim */
775 char *email; /* email */
776 int born; /* rok urodzenia */
777 int gender; /* p³eæ */
778 char *city; /* miasto */
781 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);
782 void gg_change_info_request_free(struct gg_change_info_request *r);
784 struct gg_http *gg_change_info(uin_t uin, const char *passwd, const struct gg_change_info_request *request, int async);
785 #define gg_change_pubdir_watch_fd gg_pubdir_watch_fd
786 #define gg_change_pubdir_free gg_pubdir_free
787 #define gg_free_change_pubdir gg_pubdir_free
790 * funkcje dotycz±ce listy kontaktów na serwerze.
792 struct gg_http *gg_userlist_get(uin_t uin, const char *password, int async);
793 int gg_userlist_get_watch_fd(struct gg_http *f);
794 void gg_userlist_get_free(struct gg_http *f);
796 struct gg_http *gg_userlist_put(uin_t uin, const char *password, const char *contacts, int async);
797 int gg_userlist_put_watch_fd(struct gg_http *f);
798 void gg_userlist_put_free(struct gg_http *f);
800 struct gg_http *gg_userlist_remove(uin_t uin, const char *password, int async);
801 int gg_userlist_remove_watch_fd(struct gg_http *f);
802 void gg_userlist_remove_free(struct gg_http *f);
807 * funkcje dotycz±ce komunikacji miêdzy klientami.
809 extern int gg_dcc_port; /* port, na którym nas³uchuje klient */
810 extern unsigned long gg_dcc_ip; /* adres, na którym nas³uchuje klient */
812 int gg_dcc_request(struct gg_session *sess, uin_t uin);
814 struct gg_dcc *gg_dcc_send_file(uint32_t ip, uint16_t port, uin_t my_uin, uin_t peer_uin);
815 struct gg_dcc *gg_dcc_get_file(uint32_t ip, uint16_t port, uin_t my_uin, uin_t peer_uin);
816 struct gg_dcc *gg_dcc_voice_chat(uint32_t ip, uint16_t port, uin_t my_uin, uin_t peer_uin);
817 void gg_dcc_set_type(struct gg_dcc *d, int type);
818 int gg_dcc_fill_file_info(struct gg_dcc *d, const char *filename);
819 int gg_dcc_voice_send(struct gg_dcc *d, char *buf, int length);
821 #define GG_DCC_VOICE_FRAME_LENGTH 195
822 #define GG_DCC_VOICE_FRAME_LENGTH_505 326
824 struct gg_dcc *gg_dcc_socket_create(uin_t uin, uint16_t port);
825 #define gg_dcc_socket_free gg_free_dcc
826 #define gg_dcc_socket_watch_fd gg_dcc_watch_fd
828 struct gg_event *gg_dcc_watch_fd(struct gg_dcc *d);
830 void gg_dcc_free(struct gg_dcc *c);
831 #define gg_free_dcc gg_dcc_free
834 * je¶li chcemy sobie podebugowaæ, wystarczy ustawiæ `gg_debug_level'.
835 * niestety w miarê przybywania wpisów `gg_debug(...)' nie chcia³o mi
836 * siê ustawiaæ odpowiednich leveli, wiêc wiêkszo¶æ sz³a do _MISC.
838 extern int gg_debug_level; /* poziom debugowania. mapa bitowa sta³ych GG_DEBUG_* */
841 * mo¿na podaæ wska¼nik do funkcji obs³uguj±cej wywo³ania gg_debug().
842 * nieoficjalne, nieudokumentowane, mo¿e siê zmieniæ. je¶li kto¶ jest
843 * zainteresowany, niech da znaæ na ekg-devel.
845 extern void (*gg_debug_handler)(int level, const char *format, va_list ap);
848 * mo¿na podaæ plik, do którego bêd± zapisywane teksty z gg_debug().
850 extern FILE *gg_debug_file;
852 #define GG_DEBUG_NET 1
853 #define GG_DEBUG_TRAFFIC 2
854 #define GG_DEBUG_DUMP 4
855 #define GG_DEBUG_FUNCTION 8
856 #define GG_DEBUG_MISC 16
858 #ifdef GG_DEBUG_DISABLE
859 #define gg_debug(x, y...) do { } while(0)
860 #else
861 void gg_debug(int level, const char *format, ...);
862 #endif
864 const char *gg_libgadu_version(void);
867 * konfiguracja http proxy.
869 extern int gg_proxy_enabled; /* w³±cza obs³ugê proxy */
870 extern char *gg_proxy_host; /* okre¶la adres serwera proxy */
871 extern int gg_proxy_port; /* okre¶la port serwera proxy */
872 extern char *gg_proxy_username; /* okre¶la nazwê u¿ytkownika przy autoryzacji serwera proxy */
873 extern char *gg_proxy_password; /* okre¶la has³o u¿ytkownika przy autoryzacji serwera proxy */
874 extern int gg_proxy_http_only; /* w³±cza obs³ugê proxy wy³±cznie dla us³ug HTTP */
877 * -------------------------------------------------------------------------
878 * poni¿ej znajduj± siê wewnêtrzne sprawy biblioteki. zwyk³y klient nie
879 * powinien ich w ogóle ruszaæ, bo i nie ma po co. wszystko mo¿na za³atwiæ
880 * procedurami wy¿szego poziomu, których definicje znajduj± siê na pocz±tku
881 * tego pliku.
882 * -------------------------------------------------------------------------
885 #ifdef __GG_LIBGADU_HAVE_PTHREAD
886 int gg_resolve_pthread(int *fd, void **resolver, const char *hostname);
887 #endif
889 #ifdef _WIN32
890 int gg_thread_socket(int thread_id, int socket);
891 #endif
893 int gg_resolve(int *fd, int *pid, const char *hostname);
895 #ifdef __GNUC__
896 char *gg_saprintf(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
897 #else
898 char *gg_saprintf(const char *format, ...);
899 #endif
901 char *gg_vsaprintf(const char *format, va_list ap);
903 #define gg_alloc_sprintf gg_saprintf
905 char *gg_get_line(char **ptr);
907 int gg_connect(void *addr, int port, int async);
908 struct hostent *gg_gethostbyname(const char *hostname);
909 char *gg_read_line(int sock, char *buf, int length);
910 void gg_chomp(char *line);
911 char *gg_urlencode(const char *str);
912 int gg_http_hash(const char *format, ...);
913 int gg_read(struct gg_session *sess, char *buf, int length);
914 int gg_write(struct gg_session *sess, const char *buf, int length);
915 void *gg_recv_packet(struct gg_session *sess);
916 int gg_send_packet(struct gg_session *sess, int type, ...);
917 unsigned int gg_login_hash(const unsigned char *password, unsigned int seed);
918 uint32_t gg_fix32(uint32_t x);
919 uint16_t gg_fix16(uint16_t x);
920 #define fix16 gg_fix16
921 #define fix32 gg_fix32
922 char *gg_proxy_auth(void);
923 char *gg_base64_encode(const char *buf);
924 char *gg_base64_decode(const char *buf);
925 int gg_image_queue_remove(struct gg_session *s, struct gg_image_queue *q, int freeq);
927 #define GG_APPMSG_HOST "appmsg.gadu-gadu.pl"
928 #define GG_APPMSG_PORT 80
929 #define GG_PUBDIR_HOST "pubdir.gadu-gadu.pl"
930 #define GG_PUBDIR_PORT 80
931 #define GG_REGISTER_HOST "register.gadu-gadu.pl"
932 #define GG_REGISTER_PORT 80
933 #define GG_REMIND_HOST "retr.gadu-gadu.pl"
934 #define GG_REMIND_PORT 80
936 #define GG_DEFAULT_PORT 8074
937 #define GG_HTTPS_PORT 443
938 #define GG_HTTP_USERAGENT "Mozilla/4.7 [en] (Win98; I)"
940 #define GG_DEFAULT_CLIENT_VERSION "6, 0, 0, 132"
941 #define GG_DEFAULT_PROTOCOL_VERSION 0x20
942 #define GG_DEFAULT_TIMEOUT 30
943 #define GG_HAS_AUDIO_MASK 0x40000000
944 #define GG_LIBGADU_VERSION "20040117"
946 #define GG_DEFAULT_DCC_PORT 1550
948 struct gg_header {
949 uint32_t type; /* typ pakietu */
950 uint32_t length; /* d³ugo¶æ reszty pakietu */
951 } GG_PACKED;
953 #define GG_WELCOME 0x0001
954 #define GG_NEED_EMAIL 0x0014
956 struct gg_welcome {
957 uint32_t key; /* klucz szyfrowania has³a */
958 } GG_PACKED;
960 #define GG_LOGIN 0x000c
962 struct gg_login {
963 uint32_t uin; /* mój numerek */
964 uint32_t hash; /* hash has³a */
965 uint32_t status; /* status na dzieñ dobry */
966 uint32_t version; /* moja wersja klienta */
967 uint32_t local_ip; /* mój adres ip */
968 uint16_t local_port; /* port, na którym s³ucham */
969 } GG_PACKED;
971 #define GG_LOGIN_EXT 0x0013
973 struct gg_login_ext {
974 uint32_t uin; /* mój numerek */
975 uint32_t hash; /* hash has³a */
976 uint32_t status; /* status na dzieñ dobry */
977 uint32_t version; /* moja wersja klienta */
978 uint32_t local_ip; /* mój adres ip */
979 uint16_t local_port; /* port, na którym s³ucham */
980 uint32_t external_ip; /* zewnêtrzny adres ip */
981 uint16_t external_port; /* zewnêtrzny port */
982 } GG_PACKED;
984 #define GG_LOGIN60 0x0015
986 struct gg_login60 {
987 uint32_t uin; /* mój numerek */
988 uint32_t hash; /* hash has³a */
989 uint32_t status; /* status na dzieñ dobry */
990 uint32_t version; /* moja wersja klienta */
991 uint8_t dunno1; /* 0x00 */
992 uint32_t local_ip; /* mój adres ip */
993 uint16_t local_port; /* port, na którym s³ucham */
994 uint32_t external_ip; /* zewnêtrzny adres ip */
995 uint16_t external_port; /* zewnêtrzny port */
996 uint8_t image_size; /* maksymalny rozmiar grafiki w KiB */
997 uint8_t dunno2; /* 0xbe */
998 } GG_PACKED;
1000 #define GG_LOGIN_OK 0x0003
1002 #define GG_LOGIN_FAILED 0x0009
1004 #define GG_PUBDIR50_REQUEST 0x0014
1006 #define GG_PUBDIR50_WRITE 0x01
1007 #define GG_PUBDIR50_READ 0x02
1008 #define GG_PUBDIR50_SEARCH 0x03
1009 #define GG_PUBDIR50_SEARCH_REQUEST GG_PUBDIR50_SEARCH
1010 #define GG_PUBDIR50_SEARCH_REPLY 0x05
1012 struct gg_pubdir50_request {
1013 uint8_t type; /* GG_PUBDIR50_* */
1014 uint32_t seq; /* czas wys³ania zapytania */
1015 } GG_PACKED;
1017 #define GG_PUBDIR50_REPLY 0x000e
1019 struct gg_pubdir50_reply {
1020 uint8_t type; /* GG_PUBDIR50_* */
1021 uint32_t seq; /* czas wys³ania zapytania */
1022 } GG_PACKED;
1024 #define GG_NEW_STATUS 0x0002
1026 #define GG_STATUS_NOT_AVAIL 0x0001 /* niedostêpny */
1027 #define GG_STATUS_NOT_AVAIL_DESCR 0x0015 /* niedostêpny z opisem (4.8) */
1028 #define GG_STATUS_AVAIL 0x0002 /* dostêpny */
1029 #define GG_STATUS_AVAIL_DESCR 0x0004 /* dostêpny z opisem (4.9) */
1030 #define GG_STATUS_BUSY 0x0003 /* zajêty */
1031 #define GG_STATUS_BUSY_DESCR 0x0005 /* zajêty z opisem (4.8) */
1032 #define GG_STATUS_INVISIBLE 0x0014 /* niewidoczny (4.6) */
1033 #define GG_STATUS_INVISIBLE_DESCR 0x0016 /* niewidoczny z opisem (4.9) */
1034 #define GG_STATUS_BLOCKED 0x0006 /* zablokowany */
1036 #define GG_STATUS_FRIENDS_MASK 0x8000 /* tylko dla znajomych (4.6) */
1038 #define GG_STATUS_DESCR_MAXSIZE 70
1041 * makra do ³atwego i szybkiego sprawdzania stanu.
1044 /* GG_S_F() tryb tylko dla znajomych */
1045 #define GG_S_F(x) (((x) & GG_STATUS_FRIENDS_MASK) != 0)
1047 /* GG_S() stan bez uwzglêdnienia trybu tylko dla znajomych */
1048 #define GG_S(x) ((x) & ~GG_STATUS_FRIENDS_MASK)
1050 /* GG_S_A() dostêpny */
1051 #define GG_S_A(x) (GG_S(x) == GG_STATUS_AVAIL || GG_S(x) == GG_STATUS_AVAIL_DESCR)
1053 /* GG_S_NA() niedostêpny */
1054 #define GG_S_NA(x) (GG_S(x) == GG_STATUS_NOT_AVAIL || GG_S(x) == GG_STATUS_NOT_AVAIL_DESCR)
1056 /* GG_S_B() zajêty */
1057 #define GG_S_B(x) (GG_S(x) == GG_STATUS_BUSY || GG_S(x) == GG_STATUS_BUSY_DESCR)
1059 /* GG_S_I() niewidoczny */
1060 #define GG_S_I(x) (GG_S(x) == GG_STATUS_INVISIBLE || GG_S(x) == GG_STATUS_INVISIBLE_DESCR)
1062 /* GG_S_D() stan opisowy */
1063 #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)
1065 /* GG_S_BL() blokowany lub blokuj±cy */
1066 #define GG_S_BL(x) (GG_S(x) == GG_STATUS_BLOCKED)
1068 struct gg_new_status {
1069 uint32_t status; /* na jaki zmieniæ? */
1070 } GG_PACKED;
1072 #define GG_NOTIFY 0x0010
1074 struct gg_notify {
1075 uint32_t uin; /* numerek danej osoby */
1076 uint8_t dunno1; /* rodzaj wpisu w li¶cie */
1077 } GG_PACKED;
1079 #define GG_USER_OFFLINE 0x01 /* bêdziemy niewidoczni dla u¿ytkownika */
1080 #define GG_USER_NORMAL 0x03 /* zwyk³y u¿ytkownik */
1081 #define GG_USER_BLOCKED 0x04 /* zablokowany u¿ytkownik */
1083 #define GG_LIST_EMPTY 0x0012
1085 #define GG_NOTIFY_REPLY 0x000c /* tak, to samo co GG_LOGIN */
1087 struct gg_notify_reply {
1088 uint32_t uin; /* numerek */
1089 uint32_t status; /* status danej osoby */
1090 uint32_t remote_ip; /* adres ip delikwenta */
1091 uint16_t remote_port; /* port, na którym s³ucha klient */
1092 uint32_t version; /* wersja klienta */
1093 uint16_t dunno2; /* znowu port? */
1094 } GG_PACKED;
1096 #define GG_NOTIFY_REPLY60 0x0011
1098 struct gg_notify_reply60 {
1099 uint32_t uin; /* numerek plus flagi w MSB */
1100 uint8_t status; /* status danej osoby */
1101 uint32_t remote_ip; /* adres ip delikwenta */
1102 uint16_t remote_port; /* port, na którym s³ucha klient */
1103 uint8_t version; /* wersja klienta */
1104 uint8_t image_size; /* maksymalny rozmiar grafiki w KiB */
1105 uint8_t dunno1; /* 0x00 */
1106 } GG_PACKED;
1108 #define GG_STATUS60 0x000f
1110 struct gg_status60 {
1111 uint32_t uin; /* numerek plus flagi w MSB */
1112 uint8_t status; /* status danej osoby */
1113 uint32_t remote_ip; /* adres ip delikwenta */
1114 uint16_t remote_port; /* port, na którym s³ucha klient */
1115 uint8_t version; /* wersja klienta */
1116 uint8_t image_size; /* maksymalny rozmiar grafiki w KiB */
1117 uint8_t dunno1; /* 0x00 */
1118 } GG_PACKED;
1120 #define GG_ADD_NOTIFY 0x000d
1121 #define GG_REMOVE_NOTIFY 0x000e
1123 struct gg_add_remove {
1124 uint32_t uin; /* numerek */
1125 uint8_t dunno1; /* bitmapa */
1126 } GG_PACKED;
1128 #define GG_STATUS 0x0002
1130 struct gg_status {
1131 uint32_t uin; /* numerek */
1132 uint32_t status; /* nowy stan */
1133 } GG_PACKED;
1135 #define GG_SEND_MSG 0x000b
1137 #define GG_CLASS_QUEUED 0x0001
1138 #define GG_CLASS_OFFLINE GG_CLASS_QUEUED
1139 #define GG_CLASS_MSG 0x0004
1140 #define GG_CLASS_CHAT 0x0008
1141 #define GG_CLASS_CTCP 0x0010
1142 #define GG_CLASS_ACK 0x0020
1143 #define GG_CLASS_EXT GG_CLASS_ACK /* kompatybilno¶æ wstecz */
1145 #define GG_MSG_MAXSIZE 2000
1147 struct gg_send_msg {
1148 uint32_t recipient;
1149 uint32_t seq;
1150 uint32_t msgclass;
1151 } GG_PACKED;
1153 struct gg_msg_richtext {
1154 uint8_t flag;
1155 uint16_t length;
1156 } GG_PACKED;
1158 struct gg_msg_richtext_format {
1159 uint16_t position;
1160 uint8_t font;
1161 } GG_PACKED;
1163 struct gg_msg_richtext_image {
1164 uint16_t unknown1;
1165 uint32_t size;
1166 uint32_t crc32;
1167 } GG_PACKED;
1169 #define GG_FONT_BOLD 0x01
1170 #define GG_FONT_ITALIC 0x02
1171 #define GG_FONT_UNDERLINE 0x04
1172 #define GG_FONT_COLOR 0x08
1173 #define GG_FONT_IMAGE 0x80
1175 struct gg_msg_richtext_color {
1176 uint8_t red;
1177 uint8_t green;
1178 uint8_t blue;
1179 } GG_PACKED;
1181 struct gg_msg_recipients {
1182 uint8_t flag;
1183 uint32_t count;
1184 } GG_PACKED;
1186 struct gg_msg_image_request {
1187 uint8_t flag;
1188 uint32_t size;
1189 uint32_t crc32;
1190 } GG_PACKED;
1192 struct gg_msg_image_reply {
1193 uint8_t flag;
1194 uint32_t size;
1195 uint32_t crc32;
1196 /* char filename[]; */
1197 /* char image[]; */
1198 } GG_PACKED;
1200 #define GG_SEND_MSG_ACK 0x0005
1202 #define GG_ACK_DELIVERED 0x0002
1203 #define GG_ACK_QUEUED 0x0003
1204 #define GG_ACK_NOT_DELIVERED 0x0006
1206 struct gg_send_msg_ack {
1207 uint32_t status;
1208 uint32_t recipient;
1209 uint32_t seq;
1210 } GG_PACKED;
1212 #define GG_RECV_MSG 0x000a
1214 struct gg_recv_msg {
1215 uint32_t sender;
1216 uint32_t seq;
1217 uint32_t time;
1218 uint32_t msgclass;
1219 } GG_PACKED;
1221 #define GG_PING 0x0008
1223 #define GG_PONG 0x0007
1225 #define GG_DISCONNECTING 0x000b
1227 #define GG_USERLIST_REQUEST 0x0016
1229 #define GG_USERLIST_PUT 0x00
1230 #define GG_USERLIST_PUT_MORE 0x01
1231 #define GG_USERLIST_GET 0x02
1233 struct gg_userlist_request {
1234 uint8_t type;
1235 } GG_PACKED;
1237 #define GG_USERLIST_REPLY 0x0010
1239 #define GG_USERLIST_PUT_REPLY 0x00
1240 #define GG_USERLIST_PUT_MORE_REPLY 0x02
1241 #define GG_USERLIST_GET_REPLY 0x06
1242 #define GG_USERLIST_GET_MORE_REPLY 0x04
1244 struct gg_userlist_reply {
1245 uint8_t type;
1246 } GG_PACKED;
1249 * pakiety, sta³e, struktury dla DCC
1252 struct gg_dcc_tiny_packet {
1253 uint8_t type; /* rodzaj pakietu */
1254 } GG_PACKED;
1256 struct gg_dcc_small_packet {
1257 uint32_t type; /* rodzaj pakietu */
1258 } GG_PACKED;
1260 struct gg_dcc_big_packet {
1261 uint32_t type; /* rodzaj pakietu */
1262 uint32_t dunno1; /* niewiadoma */
1263 uint32_t dunno2; /* niewiadoma */
1264 } GG_PACKED;
1267 * póki co, nie znamy dok³adnie protoko³u. nie wiemy, co czemu odpowiada.
1268 * nazwy s± niepowa¿ne i tymczasowe.
1270 #define GG_DCC_WANT_FILE 0x0003 /* peer chce plik */
1271 #define GG_DCC_HAVE_FILE 0x0001 /* wiêc mu damy */
1272 #define GG_DCC_HAVE_FILEINFO 0x0003 /* niech ma informacje o pliku */
1273 #define GG_DCC_GIMME_FILE 0x0006 /* peer jest pewny */
1274 #define GG_DCC_CATCH_FILE 0x0002 /* wysy³amy plik */
1276 #define GG_DCC_FILEATTR_READONLY 0x0020
1278 #define GG_DCC_TIMEOUT_SEND 1800 /* 30 minut */
1279 #define GG_DCC_TIMEOUT_GET 1800 /* 30 minut */
1280 #define GG_DCC_TIMEOUT_FILE_ACK 300 /* 5 minut */
1281 #define GG_DCC_TIMEOUT_VOICE_ACK 300 /* 5 minut */
1283 #ifdef __cplusplus
1285 #ifdef _WIN32
1286 #pragma pack(pop)
1287 #endif
1288 #endif
1290 #endif /* __GG_LIBGADU_H */
1293 * Local variables:
1294 * c-indentation-style: k&r
1295 * c-basic-offset: 8
1296 * indent-tabs-mode: notnil
1297 * End:
1299 * vim: shiftwidth=8: