From libgadu-commit at lists.ziew.org Tue Mar 9 00:53:08 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Tue, 9 Mar 2010 00:53:08 +0100 Subject: [libgadu-commit] r914 - branches/new-api/examples Message-ID: <20100308235308.D0C9717B69@toxygen.net> Author: wojtekka Date: 2010-03-09 00:53:08 +0100 (Tue, 09 Mar 2010) New Revision: 914 Added: branches/new-api/examples/token.c Log: Dodanie przyk?adu pobierania tokena. Added: branches/new-api/examples/token.c =================================================================== --- branches/new-api/examples/token.c (rev 0) +++ branches/new-api/examples/token.c 2010-03-08 23:53:08 UTC (rev 914) @@ -0,0 +1,120 @@ +#include +#include +#include +#include "libgadu.h" + +#ifdef ASYNC + +#include +#include +#include +#include + +void sigchld(int sig) +{ + wait(NULL); + signal(SIGCHLD, sigchld); +} + +#endif + +int main(void) +{ + struct gg_http *h; + struct gg_token *t; + char path[] = "token.XXXXXX"; + FILE *f; + + gg_debug_level = 255; + +#ifndef ASYNC + + if (!(h = gg_token(0))) { + printf("B??d pobierania tokenu.\n"); + return 1; + } + +#else + + signal(SIGCHLD, sigchld); + + if (!(h = gg_token(1))) + return 1; + + while (1) { + fd_set rd, wr, ex; + + FD_ZERO(&rd); + FD_ZERO(&wr); + FD_ZERO(&ex); + + if ((h->check & GG_CHECK_READ)) + FD_SET(h->fd, &rd); + if ((h->check & GG_CHECK_WRITE)) + FD_SET(h->fd, &wr); + FD_SET(h->fd, &ex); + + if (select(h->fd + 1, &rd, &wr, &ex, NULL) == -1 || FD_ISSET(h->fd, &ex)) { + if (errno == EINTR) + continue; + gg_token_free(h); + perror("select"); + return 1; + } + + if (FD_ISSET(h->fd, &rd) || FD_ISSET(h->fd, &wr)) { + if (gg_token_watch_fd(h) == -1) { + gg_token_free(h); + fprintf(stderr, "B??d po??czenia.\n"); + return 1; + } + if (h->state == GG_STATE_ERROR) { + gg_token_free(h); + fprintf(stderr, "B??d pobierania tokenu.\n"); + return 1; + } + if (h->state == GG_STATE_DONE) + break; + + } + } + +#endif + + t = h->data; + +#if defined(_BSD_SOURCE) || defined(_SVID_SOURCE) || _XOPEN_SOURCE >= 500 + if (mkstemp(path) == -1) { +#else + if (strcmp(mktemp(path), "") == 0) { +#endif + printf("B??d tworzenia pliku tymczasowego.\n"); + gg_token_free(h); + return 1; + } + + f = fopen(path, "w"); + + if (f == NULL) { + printf("B??d otwierania pliku tymczasowego %s.\n", path); + gg_token_free(h); + return 1; + } + + if (fwrite(h->body, h->body_size, 1, f) != 1) { + printf("B??d zapisu do pliku tymczasowego %s.\n", path); + gg_token_free(h); + fclose(f); + unlink(path); + return 1; + } + + fclose(f); + + printf("id=%s\nwidth=%d\nheight=%d\nlength=%d\npath=%s\n", t->tokenid, t->width, t->height, t->length, path); + + gg_token_free(h); + + return 0; +} + From libgadu-commit at lists.ziew.org Tue Mar 9 00:54:27 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Tue, 9 Mar 2010 00:54:27 +0100 Subject: [libgadu-commit] r915 - branches/new-api/src Message-ID: <20100308235428.0B2FC17B69@toxygen.net> Author: wojtekka Date: 2010-03-09 00:54:27 +0100 (Tue, 09 Mar 2010) New Revision: 915 Modified: branches/new-api/src/buffer.c Log: Poprawka komentarza. Modified: branches/new-api/src/buffer.c =================================================================== --- branches/new-api/src/buffer.c 2010-03-08 23:53:08 UTC (rev 914) +++ branches/new-api/src/buffer.c 2010-03-08 23:54:27 UTC (rev 915) @@ -272,8 +272,9 @@ return -1; } -// XXX zrobi? z tego funkcj? inline? sprawdzi?, czy na x86 gcc zoptymalizuje -// do zwyk?ego odczytu. je?li nie, ifdefowa?. +// XXX zrobi? z tego funkcj? inline? gcc 4.4.1 nie zoptymalizuje tego do +// zwyk?ego odczytu, wi?c fajnie by by?o to ifdefowa? prostym kodem dla +// maszyn little-endian z niewyr?wnanym dost?pem do pami?ci (__i386__?) // uint32_t gg_buffer_get_uint32(const char *ptr) { From libgadu-commit at lists.ziew.org Tue Mar 9 00:54:48 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Tue, 9 Mar 2010 00:54:48 +0100 Subject: [libgadu-commit] r916 - branches/new-api/src Message-ID: <20100308235448.4BC8217B69@toxygen.net> Author: wojtekka Date: 2010-03-09 00:54:47 +0100 (Tue, 09 Mar 2010) New Revision: 916 Modified: branches/new-api/src/debug.c Log: Styl kodowania. Modified: branches/new-api/src/debug.c =================================================================== --- branches/new-api/src/debug.c 2010-03-08 23:54:27 UTC (rev 915) +++ branches/new-api/src/debug.c 2010-03-08 23:54:47 UTC (rev 916) @@ -101,11 +101,11 @@ */ void gg_debug_common(struct gg_session *sess, int level, const char *format, va_list ap) { - if (gg_debug_handler_session) + if (gg_debug_handler_session != NULL) (*gg_debug_handler_session)(sess, level, format, ap); - else if (gg_debug_handler) + else if (gg_debug_handler != NULL) (*gg_debug_handler)(level, format, ap); - else if (gg_debug_level & level) + else if ((gg_debug_level & level) != 0) vfprintf((gg_debug_file) ? gg_debug_file : stderr, format, ap); } @@ -122,6 +122,7 @@ { va_list ap; int old_errno = errno; + va_start(ap, format); gg_debug_common(NULL, level, format, ap); va_end(ap); @@ -141,6 +142,7 @@ { va_list ap; int old_errno = errno; + va_start(ap, format); gg_debug_common(gs, level, format, ap); va_end(ap); From libgadu-commit at lists.ziew.org Tue Mar 9 00:56:01 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Tue, 9 Mar 2010 00:56:01 +0100 Subject: [libgadu-commit] r917 - branches/new-api/src Message-ID: <20100308235601.7C84B17B69@toxygen.net> Author: wojtekka Date: 2010-03-09 00:56:00 +0100 (Tue, 09 Mar 2010) New Revision: 917 Modified: branches/new-api/src/common.c Log: Usuni?cie antycznego kodu dla Win32. Tablica heksadecymalna jest teraz "const". Modified: branches/new-api/src/common.c =================================================================== --- branches/new-api/src/common.c 2010-03-08 23:54:47 UTC (rev 916) +++ branches/new-api/src/common.c 2010-03-08 23:56:00 UTC (rev 917) @@ -261,10 +261,6 @@ return -1; } -#ifdef ASSIGN_SOCKETS_TO_THREADS - gg_win32_thread_socket(0, sock); -#endif - if (async) { #ifdef FIONBIO if (ioctl(sock, FIONBIO, &one) == -1) { @@ -336,7 +332,8 @@ */ char *gg_urlencode(const char *str) { - char *q, *buf, hex[] = "0123456789abcdef"; + char *q, *buf; + const char hex[] = "0123456789abcdef"; const char *p; unsigned int size = 0; @@ -415,81 +412,7 @@ return (b < 0 ? -b : b); } -#ifdef ASSIGN_SOCKETS_TO_THREADS - -typedef struct gg_win32_thread { - int id; - int socket; - struct gg_win32_thread *next; -} gg_win32_thread; - -struct gg_win32_thread *gg_win32_threads = 0; - /** - * \internal Zwraca deskryptor gniazda, kt?re by?o ostatnio tworzone dla w?tku. - * - * Je?li na win32 przy po??czeniach synchronicznych zapami?tamy w jakim - * w?tku uruchomili?my funkcj?, kt?ra si? z czymkolwiek ??czy, to z osobnego - * w?tku mo?emy anulowa? po??czenie poprzez \c gg_win32_thread_socket(watek,-1) - * - * \param thread_id Identyfikator w?tku (je?li jest r?wne 0, brany jest - * aktualny w?tek, je?li r?wne -1, usuwa wpis dotycz?cy - * danego gniazda sockecie) - * \param socket Deskryptor gniazda (je?li r?wne 0, zwraca deskryptor gniazda - * dla podanego w?tku, je?li r?wne -1, usuwa wpis, je?li co? - * innego, ustawia dla podanego w?tku dany numer deskryptora) - * - * \return Je?li socket jest r?wne 0, zwraca deskryptor gniazda dla podanego - * w?tku. - */ -int gg_win32_thread_socket(int thread_id, int socket) -{ - char close = (thread_id == -1) || socket == -1; - gg_win32_thread *wsk = gg_win32_threads; - gg_win32_thread **p_wsk = &gg_win32_threads; - - if (!thread_id) - thread_id = GetCurrentThreadId(); - - while (wsk) { - if ((thread_id == -1 && wsk->socket == socket) || wsk->id == thread_id) { - if (close) { - /* socket zostaje usuniety */ - closesocket(wsk->socket); - *p_wsk = wsk->next; - free(wsk); - return 1; - } else if (!socket) { - /* socket zostaje zwrocony */ - return wsk->socket; - } else { - /* socket zostaje ustawiony */ - wsk->socket = socket; - return socket; - } - } - p_wsk = &(wsk->next); - wsk = wsk->next; - } - - if (close && socket != -1) - closesocket(socket); - if (close || !socket) - return 0; - - /* Dodaje nowy element */ - wsk = malloc(sizeof(gg_win32_thread)); - wsk->id = thread_id; - wsk->socket = socket; - wsk->next = 0; - *p_wsk = wsk; - - return socket; -} - -#endif /* ASSIGN_SOCKETS_TO_THREADS */ - -/** * \internal Zestaw znak?w kodowania base64. */ static char gg_base64_charset[] = From libgadu-commit at lists.ziew.org Tue Mar 9 00:56:42 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Tue, 9 Mar 2010 00:56:42 +0100 Subject: [libgadu-commit] r918 - branches/new-api/test/automatic Message-ID: <20100308235642.B7AF617B69@toxygen.net> Author: wojtekka Date: 2010-03-09 00:56:42 +0100 (Tue, 09 Mar 2010) New Revision: 918 Modified: branches/new-api/test/automatic/message2.c Log: Kolejne testy chorych sytuacji przy konwersji wiadomo?ci. Modified: branches/new-api/test/automatic/message2.c =================================================================== --- branches/new-api/test/automatic/message2.c 2010-03-08 23:56:00 UTC (rev 917) +++ branches/new-api/test/automatic/message2.c 2010-03-08 23:56:42 UTC (rev 918) @@ -33,6 +33,15 @@ /* Obrazek poza tekstem */ { "test", SPAN("test"), "\x05\x00\x80\x09\x01\x11\x22\x33\x44\x55\x66\x77\x88", 13 }, + /* Bez tekstu, tylko obrazek -- bez */ + { "", "", "\x00\x00\x80\x09\x01\x11\x22\x33\x44\x55\x66\x77\x88", 13 }, + + /* Bez tekstu, dwa obrazki -- nadal bez */ + { "", "", "\x00\x00\x80\x09\x01\x11\x22\x33\x44\x55\x66\x77\x88\x00\x00\x80\x09\x01\x88\x77\x66\x55\x44\x33\x22\x11", 26 }, + + /* Bez tekstu, dwa obrazki, w tym jeden poza */ + { "", "", "\x00\x00\x80\x09\x01\x11\x22\x33\x44\x55\x66\x77\x88\x01\x00\x80\x09\x01\x88\x77\x66\x55\x44\x33\x22\x11", 26 }, + /* Atrybuty na pocz?tku, w ?rodku i na ko?cu tekstu */ { "foobarbaz", SPAN("foo") SPAN("bar") SPAN("baz"), "\x00\x00\x01\x03\x00\x02\x06\x00\x04", 9 }, @@ -75,8 +84,13 @@ /* Niekompletny atrybut obrazka */ { "test", SPAN("test"), "\x04\x00\x80\x09\x01\x11\x22\x33\x44\x55\x66\x77", 12 }, - /* Pusty tekst */ - { "", SPAN("") }, + /* Atrybut w ?rodku znaku unikodowego */ + { "????", SPAN("?") SPAN("???"), "\x00\x00\x01\x01\x00\x02", 6 }, + + /* Pusty tekst. Oryginalny klient co prawda nie wysy?a pustego tekstu, + * ale przy wiadomo?ci zawieraj?cej jedynie obrazek, nie dokleja tag?w + * , wi?c improwizujemy. */ + { "", "" }, }; const struct test_data html_to_text[] = From libgadu-commit at lists.ziew.org Tue Mar 9 00:40:41 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Tue, 9 Mar 2010 00:40:41 +0100 Subject: [libgadu-commit] r907 - branches/new-api/src Message-ID: <20100308234041.E5E6417B5B@toxygen.net> Author: wojtekka Date: 2010-03-09 00:40:41 +0100 (Tue, 09 Mar 2010) New Revision: 907 Modified: branches/new-api/src/events.c Log: Poprawka poziomu logowania wyniku resolvera. Modified: branches/new-api/src/events.c =================================================================== --- branches/new-api/src/events.c 2010-03-08 23:40:14 UTC (rev 906) +++ branches/new-api/src/events.c 2010-03-08 23:40:41 UTC (rev 907) @@ -441,7 +441,7 @@ strcat(list, inet_ntoa(((struct in_addr*) sess->recv_buf)[i])); } - gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() resolved: %s\n", list); + gg_debug_session(sess, GG_DEBUG_DUMP, "// gg_watch_fd() resolved: %s\n", list); free(list); } From libgadu-commit at lists.ziew.org Tue Mar 9 00:38:52 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Tue, 9 Mar 2010 00:38:52 +0100 Subject: [libgadu-commit] r905 - in branches/new-api: examples test/automatic test/manual Message-ID: <20100308233852.E222C17B53@toxygen.net> Author: wojtekka Date: 2010-03-09 00:38:52 +0100 (Tue, 09 Mar 2010) New Revision: 905 Modified: branches/new-api/examples/Makefile.am branches/new-api/test/automatic/Makefile.am branches/new-api/test/manual/Makefile.am Log: Poprawki kompilacji. Modified: branches/new-api/examples/Makefile.am =================================================================== --- branches/new-api/examples/Makefile.am 2010-03-08 23:38:24 UTC (rev 904) +++ branches/new-api/examples/Makefile.am 2010-03-08 23:38:52 UTC (rev 905) @@ -1,7 +1,7 @@ noinst_PROGRAMS = send httphash conn-async register-sync register-async remind-sync remind-async status status2 token-sync token-async LDADD = ../src/libgadu.la -httphash_CFLAGS = -DGG_IGNORE_DEPRECATED +CFLAGS = -DGG_IGNORE_DEPRECATED register_sync_SOURCES = register.c Modified: branches/new-api/test/automatic/Makefile.am =================================================================== --- branches/new-api/test/automatic/Makefile.am 2010-03-08 23:38:24 UTC (rev 904) +++ branches/new-api/test/automatic/Makefile.am 2010-03-08 23:38:52 UTC (rev 905) @@ -1,21 +1,28 @@ -noinst_PROGRAMS = protocol convert message2 message1 $(OPTIONAL_TESTS) -EXTRA_PROGRAMS = protocol convert message2 message1 connect packet resolver +noinst_PROGRAMS = convert message2 message1 $(OPTIONAL_TESTS_GLIBC) $(OPTIONAL_TESTS_PERL) +EXTRA_PROGRAMS = convert message2 message1 connect packet resolver protocol -CFLAGS = -Wall -ggdb +CFLAGS = -Wall -ggdb -DGG_IGNORE_DEPRECATED + +protocol_SOURCES = protocol.c script/script.c +protocol_CFLAGS = -Iscript protocol_LDADD = $(top_builddir)/src/libgadu.la -convert_LDADD = $(top_builddir)/src/libgadu.la + +convert_SOURCES = convert.c $(top_builddir)/src/encoding.c + message1_SOURCES = message1.c + message2_SOURCES = message2.c $(top_builddir)/src/message.c message2_LDADD = @LIBXML2_LIBS@ message2_CFLAGS = @LIBXML2_CFLAGS@ + connect_LDADD = $(top_builddir)/src/libgadu.la + packet_LDADD = $(top_builddir)/src/libgadu.la + resolver_LDADD = $(top_builddir)/src/libgadu.la + EXTRA_DIST = protocol.txt connect.txt -protocol_SOURCES = protocol.c script/script.c -protocol_CFLAGS = -Iscript - SUBDIRS = script script/script.c: $(wildcard script/*.scr) script/compile Modified: branches/new-api/test/manual/Makefile.am =================================================================== --- branches/new-api/test/manual/Makefile.am 2010-03-08 23:38:24 UTC (rev 904) +++ branches/new-api/test/manual/Makefile.am 2010-03-08 23:38:52 UTC (rev 905) @@ -1,6 +1,8 @@ noinst_PROGRAMS = client dcc7 $(OPTIONAL_TESTS_SEARCH) $(OPTIONAL_TESTS_VOICE7) EXTRA_PROGRAMS = client dcc7 search voice7 +CFLAGS = -DGG_IGNORE_DEPRECATED + dcc7_CFLAGS = -Wall dcc7_LDADD = $(top_builddir)/src/libgadu.la dcc7_SOURCES = dcc7.c userconfig.c userconfig.h From libgadu-commit at lists.ziew.org Tue Mar 9 00:38:25 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Tue, 9 Mar 2010 00:38:25 +0100 Subject: [libgadu-commit] r904 - branches/new-api/test/automatic Message-ID: <20100308233825.35FF217B4E@toxygen.net> Author: wojtekka Date: 2010-03-09 00:38:24 +0100 (Tue, 09 Mar 2010) New Revision: 904 Modified: branches/new-api/test/automatic/convert.c Log: Wy?wietlanie numeru linii, w kt?rej wyst?pi? b??d. Modified: branches/new-api/test/automatic/convert.c =================================================================== --- branches/new-api/test/automatic/convert.c 2010-03-08 23:37:46 UTC (rev 903) +++ branches/new-api/test/automatic/convert.c 2010-03-08 23:38:24 UTC (rev 904) @@ -13,14 +13,15 @@ struct test_data { + int line; const char *src; const char *dst; ssize_t src_len; ssize_t dst_len; }; -#define TEST(src,dst) { src, dst, -1, -1 } -#define TEST_SIZE(src,dst,src_len,dst_len) { src, dst, src_len, dst_len } +#define TEST(src,dst) { __LINE__, src, dst, -1, -1 } +#define TEST_SIZE(src,dst,src_len,dst_len) { __LINE__, src, dst, src_len, dst_len } const struct test_data utf8_to_cp1250[] = { @@ -117,32 +118,32 @@ TEST("za\xbf\xf3\xb3\xe6 g\xea\x9cl\xb9 ja\x9f\xf1", "za???? g??l? ja??"), }; -void test_utf8(const char *input, const char *match, int src_len, int dst_len) +void test_utf8_to_cp1250(const struct test_data *t) { - char *output; + char *res; - output = gg_encoding_convert(input, GG_ENCODING_UTF8, GG_ENCODING_CP1250, src_len, dst_len); + res = gg_encoding_convert(t->src, GG_ENCODING_UTF8, GG_ENCODING_CP1250, t->src_len, t->dst_len); - if (strcmp(output, match) != 0) { - printf("utf8->cp1250: input=\"%s\", output=\"%s\", match=\"%s\", src_len=%d, dst_len=%d\n", input, output, match, src_len, dst_len); + if (strcmp(res, t->dst) != 0) { + printf("utf8->cp1250: line %d, input=\"%s\", output=\"%s\", match=\"%s\", src_len=%d, dst_len=%d\n", t->line, t->src, res, t->dst, t->src_len, t->dst_len); exit(1); } - free(output); + free(res); } -void test_cp1250(const char *input, const char *match, int src_len, int dst_len) +void test_cp1250_to_utf8(const struct test_data *t) { - char *output; + char *res; - output = gg_encoding_convert(input, GG_ENCODING_CP1250, GG_ENCODING_UTF8, src_len, dst_len); + res = gg_encoding_convert(t->src, GG_ENCODING_CP1250, GG_ENCODING_UTF8, t->src_len, t->dst_len); - if (strcmp(output, match) != 0) { - printf("cp1250->utf8: input=\"%s\", output=\"%s\", match=\"%s\", src_len=%d, dst_len=%d\n", input, output, match, src_len, dst_len); + if (strcmp(res, t->dst) != 0) { + printf("cp1250->utf8: line %d, input=\"%s\", output=\"%s\", match=\"%s\", src_len=%d, dst_len=%d\n", t->line, t->src, res, t->dst, t->src_len, t->dst_len); exit(1); } - free(output); + free(res); } int main(void) @@ -150,10 +151,10 @@ int i; for (i = 0; i < sizeof(cp1250_to_utf8) / sizeof(cp1250_to_utf8[0]); i++) - test_cp1250(cp1250_to_utf8[i].src, cp1250_to_utf8[i].dst, cp1250_to_utf8[i].src_len, cp1250_to_utf8[i].dst_len); + test_cp1250_to_utf8(&cp1250_to_utf8[i]); for (i = 0; i < sizeof(utf8_to_cp1250) / sizeof(utf8_to_cp1250[0]); i++) - test_cp1250(utf8_to_cp1250[i].src, utf8_to_cp1250[i].dst, utf8_to_cp1250[i].src_len, utf8_to_cp1250[i].dst_len); + test_utf8_to_cp1250(&utf8_to_cp1250[i]); printf("okay\n"); From libgadu-commit at lists.ziew.org Tue Mar 9 00:37:47 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Tue, 9 Mar 2010 00:37:47 +0100 Subject: [libgadu-commit] r903 - branches/new-api Message-ID: <20100308233747.7F1FD17B44@toxygen.net> Author: wojtekka Date: 2010-03-09 00:37:46 +0100 (Tue, 09 Mar 2010) New Revision: 903 Modified: branches/new-api/configure.ac Log: Komentarz do --disable-debug. Wykrywanie Perla dla test?w automatycznych. Mo?liwo?? podania w?asnego Doxygena. Modified: branches/new-api/configure.ac =================================================================== --- branches/new-api/configure.ac 2010-02-17 11:40:06 UTC (rev 902) +++ branches/new-api/configure.ac 2010-03-08 23:37:46 UTC (rev 903) @@ -141,7 +141,7 @@ ]) AC_ARG_ENABLE(debug, - [ --disable-debug compile without debugging support]) + [ --disable-debug compile without debugging support (recommended only on embedded systems)]) if test "x$enable_debug" = "xno"; then AC_MSG_WARN([--disable-debug is obsolete.]) @@ -238,6 +238,15 @@ fi fi +AC_SUBST([OPTIONAL_TESTS_PERL]) + +AC_CHECK_PROG([PERL], [perl], [perl], [:]) +if test "x$PERL" != "x:"; then + OPTIONAL_TESTS_PERL="protocol" +else + OPTIONAL_TESTS_PERL="" +fi + dnl dnl Sprawd?, czy mamy libxml2 do test?w automatycznych dnl @@ -262,7 +271,7 @@ AC_CHECK_PROG([DOXYGEN], [doxygen], [doxygen], [:]) AC_SUBST([SUBDIRS_DOXYGEN]) -if test "x$DOXYGEN" = "xdoxygen"; then +if test "x$DOXYGEN" != "x:"; then SUBDIRS_DOXYGEN="docs" else SUBDIRS_DOXYGEN="" From libgadu-commit at lists.ziew.org Tue Mar 9 00:47:37 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Tue, 9 Mar 2010 00:47:37 +0100 Subject: [libgadu-commit] r913 - branches/new-api/test/automatic Message-ID: <20100308234737.8FAD117B67@toxygen.net> Author: wojtekka Date: 2010-03-09 00:47:37 +0100 (Tue, 09 Mar 2010) New Revision: 913 Modified: branches/new-api/test/automatic/ Log: Ignorowanie binarek. Property changes on: branches/new-api/test/automatic ___________________________________________________________________ Modified: svn:ignore - .deps Makefile Makefile.in connect convert message packet protocol resolver *.html *.log *-valgrind + .deps Makefile Makefile.in connect convert message1 message2 packet protocol resolver *.html *.log *-valgrind From libgadu-commit at lists.ziew.org Tue Mar 9 00:40:14 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Tue, 9 Mar 2010 00:40:14 +0100 Subject: [libgadu-commit] r906 - branches/new-api/include Message-ID: <20100308234014.DDE3C17B59@toxygen.net> Author: wojtekka Date: 2010-03-09 00:40:14 +0100 (Tue, 09 Mar 2010) New Revision: 906 Modified: branches/new-api/include/libgadu.h.in branches/new-api/include/protocol.h Log: Stare API odchodzi do lamusa. Dodanie makra GG_FORMAT robi?cego za __attribute__((format)) Modified: branches/new-api/include/libgadu.h.in =================================================================== --- branches/new-api/include/libgadu.h.in 2010-03-08 23:38:52 UTC (rev 905) +++ branches/new-api/include/libgadu.h.in 2010-03-08 23:40:14 UTC (rev 906) @@ -1,5 +1,5 @@ /* - * (C) Copyright 2001-2003 Wojtek Kaniewski + * (C) Copyright 2001-2009 Wojtek Kaniewski * Robert J. Wo?ny * Arkadiusz Mi?kiewicz * Tomasz Chili?ski @@ -357,15 +357,17 @@ #ifdef __GNUC__ #define GG_PACKED __attribute__ ((packed)) +#define GG_FORMAT(x,y,z) __attribute__ ((format(x,y,z))) #ifndef GG_IGNORE_DEPRECATED #define GG_DEPRECATED __attribute__ ((deprecated)) #else #define GG_DEPRECATED #endif -#else +#else /* __GNUC__ */ #define GG_PACKED +#define GG_FORMAT(x,y,z) #define GG_DEPRECATED -#endif +#endif /* __GNUC__ */ /** \endcond */ @@ -601,7 +603,7 @@ GG_CHECK_NONE = 0, /**< Nie sprawdzaj niczego */ GG_CHECK_WRITE = 1, /**< Sprawd? mo?liwo?? zapisu */ GG_CHECK_READ = 2 /**< Sprawd? mo?liwo?? odczytu */ -}; +} GG_DEPRECATED; /** * Parametry po??czenia z serwerem Gadu-Gadu. Parametry zosta?y przeniesione @@ -647,7 +649,7 @@ parametr?w nie zmienia? si? rozmiar struktury */ #endif -}; +} GG_DEPRECATED; /** * Flagi sesji. @@ -690,6 +692,8 @@ uint32_t gg_session_get_bind_address(struct gg_session *gs); int gg_session_set_protocol_version(struct gg_session *gs, int protocol); int gg_session_get_protocol_version(struct gg_session *gs); +int gg_session_set_protocol_features(struct gg_session *gs, int features); +int gg_session_get_protocol_features(struct gg_session *gs); int gg_session_set_client_version(struct gg_session *gs, const char *version); const char *gg_session_get_client_version(struct gg_session *gs); int gg_session_set_image_size(struct gg_session *gs, int image_size); @@ -745,23 +749,23 @@ int gg_message_set_attributes(gg_message_t *gm, const char *attributes, size_t length); int gg_message_get_attributes(gg_message_t *gm, const char **attributes, size_t *attributes_length); -struct gg_session *gg_login(const struct gg_login_params *p); -void gg_free_session(struct gg_session *sess); -void gg_logoff(struct gg_session *sess); -int gg_change_status(struct gg_session *sess, int status); -int gg_change_status_descr(struct gg_session *sess, int status, const char *descr); -int gg_change_status_descr_time(struct gg_session *sess, int status, const char *descr, int time); -int gg_send_message(struct gg_session *sess, int msgclass, uin_t recipient, const unsigned char *message); -int gg_send_message_richtext(struct gg_session *sess, int msgclass, uin_t recipient, const unsigned char *message, const unsigned char *format, int formatlen); -int gg_send_message_confer(struct gg_session *sess, int msgclass, int recipients_count, uin_t *recipients, const unsigned char *message); -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); -int gg_send_message_ctcp(struct gg_session *sess, int msgclass, uin_t recipient, const unsigned char *message, int message_len); -int gg_ping(struct gg_session *sess); -int gg_userlist_request(struct gg_session *sess, char type, const char *request); -int gg_image_request(struct gg_session *sess, uin_t recipient, int size, uint32_t crc32); -int gg_image_reply(struct gg_session *sess, uin_t recipient, const char *filename, const char *image, int size); +struct gg_session *gg_login(const struct gg_login_params *p) GG_DEPRECATED; +void gg_free_session(struct gg_session *sess) GG_DEPRECATED; +void gg_logoff(struct gg_session *sess) GG_DEPRECATED; +int gg_change_status(struct gg_session *sess, int status) GG_DEPRECATED; +int gg_change_status_descr(struct gg_session *sess, int status, const char *descr) GG_DEPRECATED; +int gg_change_status_descr_time(struct gg_session *sess, int status, const char *descr, int time) GG_DEPRECATED; +int gg_send_message(struct gg_session *sess, int msgclass, uin_t recipient, const unsigned char *message) GG_DEPRECATED; +int gg_send_message_richtext(struct gg_session *sess, int msgclass, uin_t recipient, const unsigned char *message, const unsigned char *format, int formatlen) GG_DEPRECATED; +int gg_send_message_confer(struct gg_session *sess, int msgclass, int recipients_count, uin_t *recipients, const unsigned char *message) GG_DEPRECATED; +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) GG_DEPRECATED; +int gg_send_message_ctcp(struct gg_session *sess, int msgclass, uin_t recipient, const unsigned char *message, int message_len) GG_DEPRECATED; +int gg_ping(struct gg_session *sess) GG_DEPRECATED; +int gg_userlist_request(struct gg_session *sess, char type, const char *request) GG_DEPRECATED; +int gg_image_request(struct gg_session *sess, uin_t recipient, int size, uint32_t crc32) GG_DEPRECATED; +int gg_image_reply(struct gg_session *sess, uin_t recipient, const char *filename, const char *image, int size) GG_DEPRECATED; -uint32_t gg_crc32(uint32_t crc, const unsigned char *buf, int len); +uint32_t gg_crc32(uint32_t crc, const unsigned char *buf, int len) GG_DEPRECATED; int gg_session_set_resolver(struct gg_session *gs, gg_resolver_t type); gg_resolver_t gg_session_get_resolver(struct gg_session *gs); @@ -878,7 +882,7 @@ int num; /**< Numer wyniku */ char *field; /**< Nazwa pola */ char *value; /**< Warto?? pola */ -} /* GG_DEPRECATED */; +} GG_DEPRECATED; /** * Zapytanie lub odpowied? katalogu publicznego. @@ -892,7 +896,7 @@ uint32_t seq; /**< Numer sekwencyjny */ struct gg_pubdir50_entry *entries; /**< Pola zapytania lub odpowiedzi */ int entries_count; /**< Liczba p?l */ -} /* GG_DEPRECATED */; +} GG_DEPRECATED; /** * Zapytanie lub odpowied? katalogu publicznego. @@ -1110,20 +1114,20 @@ struct gg_event *next; /**< Kolejne zdarzenie w kolejce */ }; -struct gg_event *gg_watch_fd(struct gg_session *sess); -void gg_event_free(struct gg_event *e); +struct gg_event *gg_watch_fd(struct gg_session *sess) GG_DEPRECATED; +void gg_event_free(struct gg_event *e) GG_DEPRECATED; -int gg_notify_ex(struct gg_session *sess, uin_t *userlist, char *types, int count); -int gg_notify(struct gg_session *sess, uin_t *userlist, int count); -int gg_add_notify_ex(struct gg_session *sess, uin_t uin, char type); -int gg_add_notify(struct gg_session *sess, uin_t uin); -int gg_remove_notify_ex(struct gg_session *sess, uin_t uin, char type); -int gg_remove_notify(struct gg_session *sess, uin_t uin); +int gg_notify_ex(struct gg_session *sess, uin_t *userlist, char *types, int count) GG_DEPRECATED; +int gg_notify(struct gg_session *sess, uin_t *userlist, int count) GG_DEPRECATED; +int gg_add_notify_ex(struct gg_session *sess, uin_t uin, char type) GG_DEPRECATED; +int gg_add_notify(struct gg_session *sess, uin_t uin) GG_DEPRECATED; +int gg_remove_notify_ex(struct gg_session *sess, uin_t uin, char type) GG_DEPRECATED; +int gg_remove_notify(struct gg_session *sess, uin_t uin) GG_DEPRECATED; -struct gg_http *gg_http_connect(const char *hostname, int port, int async, const char *method, const char *path, const char *header); -int gg_http_watch_fd(struct gg_http *h); -void gg_http_stop(struct gg_http *h); -void gg_http_free(struct gg_http *h); +struct gg_http *gg_http_connect(const char *hostname, int port, int async, const char *method, const char *path, const char *header) GG_DEPRECATED; +int gg_http_watch_fd(struct gg_http *h) GG_DEPRECATED; +void gg_http_stop(struct gg_http *h) GG_DEPRECATED; +void gg_http_free(struct gg_http *h) GG_DEPRECATED; uint32_t gg_pubdir50(struct gg_session *sess, gg_pubdir50_t req); gg_pubdir50_t gg_pubdir50_new(int type); @@ -1278,7 +1282,7 @@ #define GG_DCC_VOICE_FRAME_LENGTH 195 /**< Rozmiar pakietu g?osowego przed wersj? Gadu-Gadu 5.0.5 */ #define GG_DCC_VOICE_FRAME_LENGTH_505 326 /**< Rozmiar pakietu g?osowego od wersji Gadu-Gadu 5.0.5 */ -struct gg_dcc *gg_dcc_socket_create(uin_t uin, uint16_t port); +struct gg_dcc *gg_dcc_socket_create(uin_t uin, uint16_t port) GG_DEPRECATED; #ifndef DOXYGEN #define gg_dcc_socket_free gg_dcc_free #define gg_dcc_socket_watch_fd gg_dcc_watch_fd @@ -1381,7 +1385,7 @@ char *email; char *phone; uin_t uin; -} /* GG_DEPRECATED */; +} GG_DEPRECATED; struct gg_search { int count; @@ -1435,7 +1439,7 @@ int born; int gender; char *city; -} /* GG_DEPRECATED */; +} GG_DEPRECATED; 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) GG_DEPRECATED; void gg_change_info_request_free(struct gg_change_info_request *r) GG_DEPRECATED; @@ -1461,12 +1465,11 @@ int gg_file_hash_sha1(int fd, uint8_t *result) GG_DEPRECATED; -#ifdef __GNUC__ -char *gg_saprintf(const char *format, ...) __attribute__ ((format (printf, 1, 2))) GG_DEPRECATED; -#else -char *gg_saprintf(const char *format, ...) GG_DEPRECATED; +#ifdef _WIN32 +int gg_win32_thread_socket(int thread_id, int socket) GG_DEPRECATED; #endif +char *gg_saprintf(const char *format, ...) GG_FORMAT(printf, 1, 2) GG_DEPRECATED; char *gg_vsaprintf(const char *format, va_list ap) GG_DEPRECATED; #define gg_alloc_sprintf gg_saprintf @@ -1546,7 +1549,7 @@ /* Poni?sze makra zosta?y zachowane dla zgodno?ci API */ #define GG_FEATURE_MSG80 0 #define GG_FEATURE_STATUS80 0 -#define GG_FEATURE_STATUS80BETA 0 +#define GG_FEATURE_STATUS80BETA 0 #define GG_FEATURE_ALL (GG_FEATURE_DND_FFC | GG_FEATURE_IMAGE_DESCR) #else @@ -1570,14 +1573,14 @@ struct gg_header { uint32_t type; /* typ pakietu */ uint32_t length; /* d?ugo?? reszty pakietu */ -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; #define GG_WELCOME 0x0001 #define GG_NEED_EMAIL 0x0014 struct gg_welcome { uint32_t key; /* klucz szyfrowania has?a */ -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; #define GG_LOGIN 0x000c @@ -1588,7 +1591,7 @@ uint32_t version; /* moja wersja klienta */ uint32_t local_ip; /* m?j adres ip */ uint16_t local_port; /* port, na kt?rym s?ucham */ -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; #define GG_LOGIN_EXT 0x0013 @@ -1601,7 +1604,7 @@ uint16_t local_port; /* port, na kt?rym s?ucham */ uint32_t external_ip; /* zewn?trzny adres ip */ uint16_t external_port; /* zewn?trzny port */ -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; #define GG_LOGIN60 0x0015 @@ -1617,7 +1620,7 @@ uint16_t external_port; /* zewn?trzny port */ uint8_t image_size; /* maksymalny rozmiar grafiki w KiB */ uint8_t dunno2; /* 0xbe */ -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; #define GG_LOGIN70 0x0019 @@ -1634,7 +1637,7 @@ uint16_t external_port; /* zewn?trzny port (???) */ uint8_t image_size; /* maksymalny rozmiar grafiki w KiB */ uint8_t dunno2; /* 0xbe */ -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; #define GG_LOGIN_OK 0x0003 @@ -1645,14 +1648,14 @@ struct gg_pubdir50_request { uint8_t type; /* GG_PUBDIR50_* */ uint32_t seq; /* czas wys?ania zapytania */ -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; #define GG_PUBDIR50_REPLY 0x000e struct gg_pubdir50_reply { uint8_t type; /* GG_PUBDIR50_* */ uint32_t seq; /* czas wys?ania zapytania */ -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; #define GG_NEW_STATUS 0x0002 @@ -1771,7 +1774,7 @@ */ struct gg_new_status { uint32_t status; /**< Nowy status */ -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; #define GG_NOTIFY_FIRST 0x000f #define GG_NOTIFY_LAST 0x0010 @@ -1781,7 +1784,7 @@ struct gg_notify { uint32_t uin; /* numerek danej osoby */ uint8_t dunno1; /* rodzaj wpisu w li?cie */ -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; #ifndef DOXYGEN @@ -1815,7 +1818,7 @@ uint16_t remote_port; /* port, na kt?rym s?ucha klient */ uint32_t version; /* wersja klienta */ uint16_t dunno2; /* znowu port? */ -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; #define GG_NOTIFY_REPLY60 0x0011 @@ -1827,7 +1830,7 @@ uint8_t version; /* wersja klienta */ uint8_t image_size; /* maksymalny rozmiar grafiki w KiB */ uint8_t dunno1; /* 0x00 */ -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; #define GG_STATUS60 0x000f @@ -1839,7 +1842,7 @@ uint8_t version; /* wersja klienta */ uint8_t image_size; /* maksymalny rozmiar grafiki w KiB */ uint8_t dunno1; /* 0x00 */ -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; #define GG_NOTIFY_REPLY77 0x0018 @@ -1852,7 +1855,7 @@ uint8_t image_size; /* maksymalny rozmiar grafiki w KiB */ uint8_t dunno1; /* 0x00 */ uint32_t dunno2; /* ? */ -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; #define GG_STATUS77 0x0017 @@ -1865,7 +1868,7 @@ uint8_t image_size; /* maksymalny rozmiar grafiki w KiB */ uint8_t dunno1; /* 0x00 */ uint32_t dunno2; /* ? */ -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; #define GG_ADD_NOTIFY 0x000d #define GG_REMOVE_NOTIFY 0x000e @@ -1873,14 +1876,14 @@ struct gg_add_remove { uint32_t uin; /* numerek */ uint8_t dunno1; /* bitmapa */ -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; #define GG_STATUS 0x0002 struct gg_status { uint32_t uin; /* numerek */ uint32_t status; /* nowy stan */ -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; #define GG_SEND_MSG 0x000b @@ -1924,12 +1927,12 @@ uint32_t recipient; uint32_t seq; uint32_t msgclass; -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; struct gg_msg_richtext { uint8_t flag; uint16_t length; -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; /** * Struktura opisuj?ca formatowanie tekstu. W zale?no?ci od warto?ci pola @@ -1941,7 +1944,7 @@ struct gg_msg_richtext_format { uint16_t position; /**< Pocz?tkowy znak formatowania (liczony od 0) */ uint8_t font; /**< Atrybuty formatowania */ -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; #ifndef DOXYGEN @@ -1977,7 +1980,7 @@ uint8_t red; /**< Sk?adowa czerwona koloru */ uint8_t green; /**< Sk?adowa zielona koloru */ uint8_t blue; /**< Sk?adowa niebieska koloru */ -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; /** * Strukturya opisuj?ca obrazek wstawiony do wiadomo?ci dla atrubutu @@ -1989,18 +1992,18 @@ uint16_t unknown1; /**< Nieznane pole o warto?ci 0x0109 */ uint32_t size; /**< Rozmiar obrazka */ uint32_t crc32; /**< Suma kontrolna CRC32 obrazka */ -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; struct gg_msg_recipients { uint8_t flag; uint32_t count; -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; struct gg_msg_image_request { uint8_t flag; uint32_t size; uint32_t crc32; -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; struct gg_msg_image_reply { uint8_t flag; @@ -2008,7 +2011,7 @@ uint32_t crc32; /* char filename[]; */ /* char image[]; */ -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; #define GG_SEND_MSG_ACK 0x0005 @@ -2042,7 +2045,7 @@ uint32_t status; uint32_t recipient; uint32_t seq; -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; #define GG_RECV_MSG 0x000a @@ -2051,7 +2054,7 @@ uint32_t seq; uint32_t time; uint32_t msgclass; -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; #define GG_PING 0x0008 @@ -2085,7 +2088,7 @@ struct gg_userlist_request { uint8_t type; -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; #define GG_USERLIST_REPLY 0x0010 @@ -2112,21 +2115,21 @@ struct gg_userlist_reply { uint8_t type; -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; struct gg_dcc_tiny_packet { uint8_t type; /* rodzaj pakietu */ -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; struct gg_dcc_small_packet { uint32_t type; /* rodzaj pakietu */ -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; struct gg_dcc_big_packet { uint32_t type; /* rodzaj pakietu */ uint32_t dunno1; /* niewiadoma */ uint32_t dunno2; /* niewiadoma */ -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; /* * p?ki co, nie znamy dok?adnie protoko?u. nie wiemy, co czemu odpowiada. @@ -2152,7 +2155,7 @@ uint32_t type; /* spos?b po??czenia */ gg_dcc7_id_t id; /* identyfikator po??czenia */ char info[GG_DCC7_INFO_LEN]; /* informacje o po??czeniu "ip port" */ -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; #define GG_DCC7_NEW 0x20 @@ -2165,7 +2168,7 @@ uint32_t size; /* rozmiar pliku */ uint32_t size_hi; /* rozmiar pliku (starsze bajty) */ unsigned char hash[GG_DCC7_HASH_LEN]; /* hash SHA1 */ -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; #define GG_DCC7_ACCEPT 0x21 @@ -2174,7 +2177,7 @@ gg_dcc7_id_t id; /* identyfikator po??czenia */ uint32_t offset; /* offset przy wznawianiu transmisji */ uint32_t dunno1; /* 0x00000000 */ -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; // XXX API #define GG_DCC7_TYPE_P2P 0x00000001 /**< Po??czenie bezpo?rednie */ @@ -2186,7 +2189,7 @@ uint32_t uin; /**< Numer odrzucaj?cego po??czenie */ gg_dcc7_id_t id; /**< Identyfikator po??czenia */ uint32_t reason; /**< Pow?d roz??czenia */ -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; // XXX API #define GG_DCC7_REJECT_BUSY 0x00000001 /**< Po??czenie bezpo?rednie ju? trwa, nie umiem obs?u?y? wi?cej */ @@ -2197,7 +2200,7 @@ struct gg_dcc7_id_request { uint32_t type; /**< Rodzaj tranmisji */ -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; // XXX API #define GG_DCC7_TYPE_VOICE 0x00000001 /**< Transmisja g?osu */ @@ -2208,13 +2211,13 @@ struct gg_dcc7_id_reply { uint32_t type; /** Rodzaj transmisji */ gg_dcc7_id_t id; /** Przyznany identyfikator */ -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; #define GG_DCC7_DUNNO1 0x24 struct gg_dcc7_dunno1 { // XXX -} GG_PACKED; +} GG_PACKED GG_DEPRECATED; #define GG_DCC7_TIMEOUT_CONNECT 10 /* 10 sekund */ #define GG_DCC7_TIMEOUT_SEND 1800 /* 30 minut */ Modified: branches/new-api/include/protocol.h =================================================================== --- branches/new-api/include/protocol.h 2010-03-08 23:38:52 UTC (rev 905) +++ branches/new-api/include/protocol.h 2010-03-08 23:40:14 UTC (rev 906) @@ -30,12 +30,9 @@ #define GG_LOGIN80 0x0031 -#undef GG_FEATURE_STATUS80BETA -#undef GG_FEATURE_MSG80 -#undef GG_FEATURE_STATUS80 -#define GG_FEATURE_STATUS80BETA 0x01 -#define GG_FEATURE_MSG80 0x02 -#define GG_FEATURE_STATUS80 0x05 +#define GG_PROTOCOL_FEATURE_STATUS80BETA 0x01 +#define GG_PROTOCOL_FEATURE_MSG80 0x02 +#define GG_PROTOCOL_FEATURE_STATUS80 0x05 #define GG8_LANG "pl" #define GG8_VERSION "Gadu-Gadu Client Build 8.0.0.8731" From libgadu-commit at lists.ziew.org Tue Mar 9 00:57:29 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Tue, 9 Mar 2010 00:57:29 +0100 Subject: [libgadu-commit] r919 - branches/new-api/src Message-ID: <20100308235729.B79ED17B44@toxygen.net> Author: wojtekka Date: 2010-03-09 00:57:29 +0100 (Tue, 09 Mar 2010) New Revision: 919 Modified: branches/new-api/src/message.c Log: Poprawki konwersji wiadomo?ci. Modified: branches/new-api/src/message.c =================================================================== --- branches/new-api/src/message.c 2010-03-08 23:56:42 UTC (rev 918) +++ branches/new-api/src/message.c 2010-03-08 23:57:29 UTC (rev 919) @@ -340,8 +340,8 @@ * \internal Zamienia tekst z formatowaniem Gadu-Gadu na HTML. * * \param dst Bufor wynikowy (mo?e by? \c NULL) - * \param utf_msg Tekst ?r?d?owy - * \param format_ Atrybuty tekstu ?r?d?owego + * \param src Tekst ?r?d?owy w UTF-8 + * \param format Atrybuty tekstu ?r?d?owego * \param format_len D?ugo?? bloku atrybut?w tekstu ?r?d?owego * * \note Wynikowy tekst nie jest idealnym kodem HTML, poniewa? ma jak @@ -351,7 +351,7 @@ * * \return D?ugo?? tekstu wynikowego bez \c \\0 (nawet je?li \c dst to \c NULL). */ -size_t gg_message_text_to_html(char *dst, const char *utf_msg, const char *format_, size_t format_len) +size_t gg_message_text_to_html(char *dst, const char *src, const char *format, size_t format_len) { const char span_fmt[] = ""; const int span_len = 75; @@ -362,31 +362,44 @@ unsigned char old_attr = 0; const unsigned char *color = (const unsigned char*) "\x00\x00\x00"; int len, i; - const unsigned char *format = (const unsigned char*) format_; + const unsigned char *format_ = (const unsigned char*) format; len = 0; + /* Nie mamy atrybut?w dla pierwsze znaku, a tekst nie jest pusty, wi?c + * tak czy inaczej trzeba otworzy? . */ + + if (src[0] != 0 && (format_idx + 3 > format_len || (format_[format_idx] | (format_[format_idx + 1] << 8)) != 0)) { + if (dst != NULL) + sprintf(&dst[len], span_fmt, 0, 0, 0); + + len += span_len; + } + /* P?tla przechodzi te? przez ko?cz?ce \0, ?eby m?c doklei? obrazek * na ko?cu tekstu. */ for (i = 0; ; i++) { - unsigned char attr; - int attr_pos; + /* Analizuj atrybuty tak d?ugo jak dotycz? aktualnego znaku. */ + for (;;) { + unsigned char attr; + int attr_pos; - if (format_idx + 3 <= format_len) { - attr_pos = format[format_idx] | (format[format_idx + 1] << 8); - attr = (unsigned char) format[format_idx + 2]; - } else { - attr_pos = -1; - attr = 0; - } + if (format_idx + 3 > format_len) + break; - /* Nie doklejaj atrybut?w na ko?cu, co najwy?ej obrazki. */ + attr_pos = format_[format_idx] | (format_[format_idx + 1] << 8); - if (utf_msg[i] == 0) - attr &= ~(GG_FONT_BOLD | GG_FONT_ITALIC | GG_FONT_UNDERLINE | GG_FONT_COLOR); + if (attr_pos != char_pos) + break; - if (attr_pos == char_pos) { + attr = format_[format_idx + 2]; + + /* Nie doklejaj atrybut?w na ko?cu, co najwy?ej obrazki. */ + + if (src[i] == 0) + attr &= ~(GG_FONT_BOLD | GG_FONT_ITALIC | GG_FONT_UNDERLINE | GG_FONT_COLOR); + format_idx += 3; if ((attr & (GG_FONT_BOLD | GG_FONT_ITALIC | GG_FONT_UNDERLINE | GG_FONT_COLOR)) != 0) { @@ -404,7 +417,7 @@ } if (((attr & GG_FONT_COLOR) != 0) && (format_idx + 3 <= format_len)) { - color = (unsigned char *) &format[format_idx]; + color = &format_[format_idx]; format_idx += 3; } else { color = (unsigned char*) "\x00\x00\x00"; @@ -413,7 +426,7 @@ if (dst != NULL) sprintf(&dst[len], span_fmt, color[0], color[1], color[2]); len += span_len; - } else if (char_pos == 0) { + } else if (char_pos == 0 && src[0] != 0) { if (dst != NULL) sprintf(&dst[len], span_fmt, 0, 0, 0); len += span_len; @@ -431,14 +444,14 @@ if (((attr & GG_FONT_IMAGE) != 0) && (format_idx + 10 <= format_len)) { if (dst != NULL) { sprintf(&dst[len], img_fmt, - format[format_idx + 9], - format[format_idx + 8], - format[format_idx + 7], - format[format_idx + 6], - format[format_idx + 5], - format[format_idx + 4], - format[format_idx + 3], - format[format_idx + 2]); + format_[format_idx + 9], + format_[format_idx + 8], + format_[format_idx + 7], + format_[format_idx + 6], + format_[format_idx + 5], + format_[format_idx + 4], + format_[format_idx + 3], + format_[format_idx + 2]); } len += img_len; @@ -446,14 +459,11 @@ } old_attr = attr; - } else if (i == 0) { - if (dst != NULL) - sprintf(&dst[len], span_fmt, 0, 0, 0); - - len += span_len; } - switch (utf_msg[i]) { + /* Doklej znak zachowuj?c htmlowe escapowanie. */ + + switch (src[i]) { case '&': gg_append(dst, &len, "&", 5); break; @@ -477,16 +487,16 @@ break; default: if (dst != NULL) - dst[len] = utf_msg[i]; + dst[len] = src[i]; len++; } /* Sprawd?, czy bajt nie jest kontynuacj? znaku unikodowego. */ - if ((utf_msg[i] & 0xc0) != 0xc0) + if ((src[i] & 0xc0) != 0xc0) char_pos++; - if (utf_msg[i] == 0) + if (src[i] == 0) break; } @@ -501,7 +511,8 @@ if ((old_attr & GG_FONT_BOLD) != 0) gg_append(dst, &len, "", 4); - gg_append(dst, &len, "", 7); + if (src[0] != 0) + gg_append(dst, &len, "", 7); if (dst != NULL) dst[len] = 0; From libgadu-commit at lists.ziew.org Tue Mar 9 01:00:09 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Tue, 9 Mar 2010 01:00:09 +0100 Subject: [libgadu-commit] r920 - branches/1.9/src Message-ID: <20100309000009.86B0B17B44@toxygen.net> Author: wojtekka Date: 2010-03-09 01:00:08 +0100 (Tue, 09 Mar 2010) New Revision: 920 Modified: branches/1.9/src/libgadu.c Log: Poprawki konwersji wiadomo?ci przeniesione z /branches/new-api. Ujednolicenie kodu. Modified: branches/1.9/src/libgadu.c =================================================================== --- branches/1.9/src/libgadu.c 2010-03-08 23:57:29 UTC (rev 919) +++ branches/1.9/src/libgadu.c 2010-03-09 00:00:08 UTC (rev 920) @@ -1300,41 +1300,66 @@ * \internal Zamienia tekst z formatowaniem Gadu-Gadu na HTML. * * \param dst Bufor wynikowy (mo?e by? \c NULL) - * \param utf_msg Tekst ?r?d?owy + * \param src Tekst ?r?d?owy w UTF-8 * \param format Atrybuty tekstu ?r?d?owego * \param format_len D?ugo?? bloku atrybut?w tekstu ?r?d?owego * + * \note Wynikowy tekst nie jest idealnym kodem HTML, poniewa? ma jak + * dok?adniej odzwierciedla? to, co wygenerowa?by oryginalny klient. + * * \note Dokleja \c \\0 na ko?cu bufora wynikowego. * * \return D?ugo?? tekstu wynikowego bez \c \\0 (nawet je?li \c dst to \c NULL). */ -static int gg_convert_to_html(char *dst, const char *utf_msg, const unsigned char *format, int format_len) +static int gg_convert_to_html(char *dst, const char *src, const unsigned char *format, int format_len) { const char span_fmt[] = ""; const int span_len = 75; const char img_fmt[] = ""; const int img_len = 29; int char_pos = 0; - int format_idx = 3; + int format_idx = 0; unsigned char old_attr = 0; const unsigned char *color = (const unsigned char*) "\x00\x00\x00"; int len, i; + const unsigned char *format_ = (const unsigned char*) format; len = 0; - for (i = 0; utf_msg[i] != 0; i++) { - unsigned char attr; - int attr_pos; + /* Nie mamy atrybut?w dla pierwsze znaku, a tekst nie jest pusty, wi?c + * tak czy inaczej trzeba otworzy? . */ - if (format_idx + 3 <= format_len) { - attr_pos = format[format_idx] | (format[format_idx + 1] << 8); - attr = format[format_idx + 2]; - } else { - attr_pos = -1; - attr = 0; - } + if (src[0] != 0 && (format_idx + 3 > format_len || (format_[format_idx] | (format_[format_idx + 1] << 8)) != 0)) { + if (dst != NULL) + sprintf(&dst[len], span_fmt, 0, 0, 0); - if (attr_pos == char_pos) { + len += span_len; + } + + /* P?tla przechodzi te? przez ko?cz?ce \0, ?eby m?c doklei? obrazek + * na ko?cu tekstu. */ + + for (i = 0; ; i++) { + /* Analizuj atrybuty tak d?ugo jak dotycz? aktualnego znaku. */ + for (;;) { + unsigned char attr; + int attr_pos; + + if (format_idx + 3 > format_len) + break; + + attr_pos = format_[format_idx] | (format_[format_idx + 1] << 8); + + if (attr_pos != char_pos) + break; + + attr = format_[format_idx + 2]; + + /* Nie doklejaj atrybut?w na ko?cu, co najwy?ej obrazki. */ + + if (src[i] == 0) + attr &= ~(GG_FONT_BOLD | GG_FONT_ITALIC | GG_FONT_UNDERLINE | GG_FONT_COLOR); + format_idx += 3; if ((attr & (GG_FONT_BOLD | GG_FONT_ITALIC | GG_FONT_UNDERLINE | GG_FONT_COLOR)) != 0) { @@ -1352,16 +1377,16 @@ } if (((attr & GG_FONT_COLOR) != 0) && (format_idx + 3 <= format_len)) { - color = &format[format_idx]; + color = &format_[format_idx]; format_idx += 3; } else { - color = (const unsigned char*) "\x00\x00\x00"; + color = (unsigned char*) "\x00\x00\x00"; } if (dst != NULL) sprintf(&dst[len], span_fmt, color[0], color[1], color[2]); len += span_len; - } else if (char_pos == 0) { + } else if (char_pos == 0 && src[0] != 0) { if (dst != NULL) sprintf(&dst[len], span_fmt, 0, 0, 0); len += span_len; @@ -1379,14 +1404,14 @@ if (((attr & GG_FONT_IMAGE) != 0) && (format_idx + 10 <= format_len)) { if (dst != NULL) { sprintf(&dst[len], img_fmt, - format[format_idx + 9], - format[format_idx + 8], - format[format_idx + 7], - format[format_idx + 6], - format[format_idx + 5], - format[format_idx + 4], - format[format_idx + 3], - format[format_idx + 2]); + format_[format_idx + 9], + format_[format_idx + 8], + format_[format_idx + 7], + format_[format_idx + 6], + format_[format_idx + 5], + format_[format_idx + 4], + format_[format_idx + 3], + format_[format_idx + 2]); } len += img_len; @@ -1394,14 +1419,11 @@ } old_attr = attr; - } else if (i == 0) { - if (dst != NULL) - sprintf(&dst[len], span_fmt, 0, 0, 0); - - len += span_len; } - switch (utf_msg[i]) { + /* Doklej znak zachowuj?c htmlowe escapowanie. */ + + switch (src[i]) { case '&': gg_append(dst, &len, "&", 5); break; @@ -1421,19 +1443,25 @@ gg_append(dst, &len, "
", 4); break; case '\r': + case 0: break; default: if (dst != NULL) - dst[len] = utf_msg[i]; + dst[len] = src[i]; len++; } /* Sprawd?, czy bajt nie jest kontynuacj? znaku unikodowego. */ - if ((utf_msg[i] & 0xc0) != 0xc0) + if ((src[i] & 0xc0) != 0xc0) char_pos++; + + if (src[i] == 0) + break; } + /* Zamknij tagi. */ + if ((old_attr & GG_FONT_UNDERLINE) != 0) gg_append(dst, &len, "", 4); @@ -1443,17 +1471,9 @@ if ((old_attr & GG_FONT_BOLD) != 0) gg_append(dst, &len, "", 4); - /* Dla pustych tekst?w dodaj pusty . */ + if (src[0] != 0) + gg_append(dst, &len, "", 7); - if (i == 0) { - if (dst != NULL) - sprintf(&dst[len], span_fmt, 0, 0, 0); - - len += span_len; - } - - gg_append(dst, &len, "
", 7); - if (dst != NULL) dst[len] = 0; @@ -1548,7 +1568,7 @@ formatlen = 9; } - len = gg_convert_to_html(NULL, utf_msg, format, formatlen); + len = gg_convert_to_html(NULL, utf_msg, format + 3, formatlen - 3); html_msg = malloc(len + 1); @@ -1557,7 +1577,7 @@ goto cleanup; } - gg_convert_to_html(html_msg, utf_msg, format, formatlen); + gg_convert_to_html(html_msg, utf_msg, format + 3, formatlen - 3); s80.seq = gg_fix32(seq_no); s80.msgclass = gg_fix32(msgclass); From libgadu-commit at lists.ziew.org Tue Mar 9 00:45:05 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Tue, 9 Mar 2010 00:45:05 +0100 Subject: [libgadu-commit] r911 - branches/new-api/docs Message-ID: <20100308234505.8DC5617B63@toxygen.net> Author: wojtekka Date: 2010-03-09 00:45:05 +0100 (Tue, 09 Mar 2010) New Revision: 911 Modified: branches/new-api/docs/ Log: Ignorowanie timestampu dla dokumentacji HTML. Property changes on: branches/new-api/docs ___________________________________________________________________ Modified: svn:ignore - html Makefile Makefile.in Doxyfile + html html-stamp Makefile Makefile.in Doxyfile From libgadu-commit at lists.ziew.org Tue Mar 9 00:44:27 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Tue, 9 Mar 2010 00:44:27 +0100 Subject: [libgadu-commit] r910 - branches/new-api/src Message-ID: <20100308234427.8572917B61@toxygen.net> Author: wojtekka Date: 2010-03-09 00:44:26 +0100 (Tue, 09 Mar 2010) New Revision: 910 Added: branches/new-api/src/libgadu.sym Log: Lista eksportowanych symboli. Added: branches/new-api/src/libgadu.sym =================================================================== --- branches/new-api/src/libgadu.sym (rev 0) +++ branches/new-api/src/libgadu.sym 2010-03-08 23:44:26 UTC (rev 910) @@ -0,0 +1,232 @@ +gg_add_notify +gg_add_notify_ex +gg_base64_decode +gg_base64_encode +gg_change_info +gg_change_info_request_free +gg_change_info_request_new +gg_change_passwd +gg_change_passwd2 +gg_change_passwd3 +gg_change_passwd4 +gg_change_status +gg_change_status_descr +gg_change_status_descr_time +gg_chomp +gg_connect +gg_crc32 +gg_dcc_ip +gg_dcc_port +gg_dcc7_accept +gg_dcc7_free +gg_dcc7_handle_accept +gg_dcc7_handle_id +gg_dcc7_handle_info +gg_dcc7_handle_new +gg_dcc7_handle_reject +gg_dcc7_reject +gg_dcc7_send_file +gg_dcc7_send_file_fd +gg_dcc7_watch_fd +gg_dcc_fill_file_info +gg_dcc_fill_file_info2 +gg_dcc_free +gg_dcc_get_file +gg_dcc_request +gg_dcc_send_file +gg_dcc_set_type +gg_dcc_socket_create +gg_dcc_voice_chat +gg_dcc_voice_send +gg_dcc_watch_fd +gg_debug +gg_debug_common +gg_debug_file +gg_debug_handler +gg_debug_handler_session +gg_debug_level +gg_debug_session +gg_event_free +gg_file_hash_sha1 +gg_fix16 +gg_fix32 +gg_free_search +gg_free_session +gg_gethostbyname +gg_get_line +gg_global_get_resolver +gg_global_set_custom_resolver +gg_global_set_resolver +gg_http_connect +gg_http_free +gg_http_free_fields +gg_http_get_resolver +gg_http_hash +gg_http_set_custom_resolver +gg_http_set_resolver +gg_http_stop +gg_http_watch_fd +gg_image_queue_remove +gg_image_reply +gg_image_request +gg_libgadu_version +gg_local_ip +gg_login +gg_login_hash +gg_login_hash_sha1 +gg_logoff +gg_message_free +gg_message_get_attributes +gg_message_get_auto_convert +gg_message_get_class +gg_message_get_html +gg_message_get_recipients +gg_message_get_seq +gg_message_get_text +gg_message_html_to_text +gg_message_init +gg_message_new +gg_message_recipient +gg_message_set_attributes +gg_message_set_auto_convert +gg_message_set_class +gg_message_set_html +gg_message_set_recipient +gg_message_set_recipients +gg_message_set_seq +gg_message_set_text +gg_message_text_to_html +gg_notify +gg_notify_ex +gg_ping +gg_proxy_auth +gg_proxy_enabled +gg_proxy_host +gg_proxy_http_only +gg_proxy_password +gg_proxy_port +gg_proxy_username +gg_pubdir50 +gg_pubdir50_add +gg_pubdir50_count +gg_pubdir50_free +gg_pubdir50_get +gg_pubdir50_handle_reply +gg_pubdir50_new +gg_pubdir50_next +gg_pubdir50_seq +gg_pubdir50_seq_set +gg_pubdir50_type +gg_pubdir_free +gg_pubdir_watch_fd +gg_read +gg_read_line +gg_recv_packet +gg_register +gg_register2 +gg_register3 +gg_remind_passwd +gg_remind_passwd2 +gg_remind_passwd3 +gg_remove_notify +gg_remove_notify_ex +gg_resolve +gg_resolve_pthread +gg_resolve_pthread_cleanup +gg_saprintf +gg_search +gg_search_request_free +gg_search_request_mode_0 +gg_search_request_mode_1 +gg_search_request_mode_2 +gg_search_request_mode_3 +gg_search_watch_fd +gg_send_message +gg_send_message_confer +gg_send_message_confer_richtext +gg_send_message_ctcp +gg_send_message_richtext +gg_send_packet +gg_session_add_contact +gg_session_connect +gg_session_contacts_request +gg_session_disconnect +gg_session_export_contacts +gg_session_free +gg_session_get_async +gg_session_get_bind_address +gg_session_get_check +gg_session_get_client_version +gg_session_get_data +gg_session_get_encoding +gg_session_get_event +gg_session_get_external_address +gg_session_get_fd +gg_session_get_flag +gg_session_get_hash_type +gg_session_get_image_size +gg_session_get_last_message +gg_session_get_password +gg_session_get_ping_period +gg_session_get_protocol_features +gg_session_get_protocol_version +gg_session_get_resolver +gg_session_get_server +gg_session_get_status +gg_session_get_timeout +gg_session_get_uin +gg_session_handle_data +gg_session_handle_io +gg_session_handle_packet +gg_session_handle_timeout +gg_session_image_reply +gg_session_image_request +gg_session_import_contacts +gg_session_is_connected +gg_session_is_connecting +gg_session_is_idle +gg_session_new +gg_session_peek_event +gg_session_ping +gg_session_remove_contact +gg_session_send_contacts +gg_session_send_message +gg_session_set_async +gg_session_set_bind_address +gg_session_set_client_version +gg_session_set_custom_resolver +gg_session_set_data +gg_session_set_encoding +gg_session_set_external_address +gg_session_set_flag +gg_session_set_hash_type +gg_session_set_image_size +gg_session_set_last_message +gg_session_set_password +gg_session_set_protocol_features +gg_session_set_protocol_version +gg_session_set_resolver +gg_session_set_server +gg_session_set_status +gg_session_set_uin +gg_session_shutdown +gg_token +gg_token_free +gg_token_watch_fd +gg_unregister +gg_unregister2 +gg_unregister3 +gg_urlencode +gg_userlist_get +gg_userlist_get_free +gg_userlist_get_watch_fd +gg_userlist_put +gg_userlist_put_free +gg_userlist_put_watch_fd +gg_userlist_remove +gg_userlist_remove_free +gg_userlist_remove_watch_fd +gg_userlist_request +gg_vsaprintf +gg_watch_fd +gg_write From libgadu-commit at lists.ziew.org Tue Mar 9 00:43:31 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Tue, 9 Mar 2010 00:43:31 +0100 Subject: [libgadu-commit] r909 - branches/new-api/src Message-ID: <20100308234331.C79B417B5F@toxygen.net> Author: wojtekka Date: 2010-03-09 00:43:31 +0100 (Tue, 09 Mar 2010) New Revision: 909 Modified: branches/new-api/src/libgadu.c branches/new-api/src/session.c Log: Poprawki ?onglowania numerami sekwencyjnymi. Mo?liwo?? ustawiania gg_session.protocol_features tak jak w 1.9. Modified: branches/new-api/src/libgadu.c =================================================================== --- branches/new-api/src/libgadu.c 2010-03-08 23:42:12 UTC (rev 908) +++ branches/new-api/src/libgadu.c 2010-03-08 23:43:31 UTC (rev 909) @@ -39,6 +39,7 @@ #include "resolver.h" #include "message.h" #include "session.h" +#include "protocol.h" #include #include @@ -1115,6 +1116,7 @@ struct gg_session *gg_login(const struct gg_login_params *p) { struct gg_session *gs = NULL; + int features; if (p == NULL) { gg_debug(GG_DEBUG_FUNCTION, "** gg_login(%p);\n", p); @@ -1159,6 +1161,16 @@ if (p->protocol_version != 0) gg_session_set_protocol_version(gs, p->protocol_version); + features = (p->protocol_features & ~(GG_FEATURE_STATUS77 | GG_FEATURE_MSG77)); + + if (!(p->protocol_features & GG_FEATURE_STATUS77)) + features |= GG_PROTOCOL_FEATURE_STATUS80; + + if (!(p->protocol_features & GG_FEATURE_MSG77)) + features |= GG_PROTOCOL_FEATURE_MSG80; + + gg_session_set_protocol_features(gs, features); + if (p->client_version != NULL) gg_session_set_client_version(gs, p->client_version); Modified: branches/new-api/src/session.c =================================================================== --- branches/new-api/src/session.c 2010-03-08 23:42:12 UTC (rev 908) +++ branches/new-api/src/session.c 2010-03-08 23:43:31 UTC (rev 909) @@ -75,7 +75,7 @@ gs->pid = -1; gs->encoding = GG_ENCODING_UTF8; gs->hash_type = GG_LOGIN_HASH_SHA1; - gs->protocol_features = GG_FEATURE_MSG80 | GG_FEATURE_STATUS80; // XXX trzeba jako? to zmienia? + gs->protocol_features = GG_PROTOCOL_FEATURE_MSG80 | GG_PROTOCOL_FEATURE_STATUS80; gg_session_set_protocol_version(gs, GG_DEFAULT_PROTOCOL_VERSION); @@ -286,6 +286,22 @@ return gs->protocol_version; } +int gg_session_set_protocol_features(struct gg_session *gs, int features) +{ + GG_SESSION_CHECK(gs, -1); + + gs->protocol_features = features; + + return 0; +} + +int gg_session_get_protocol_features(struct gg_session *gs) +{ + GG_SESSION_CHECK(gs, -1); + + return gs->protocol_features; +} + int gg_session_set_client_version(struct gg_session *gs, const char *version) { char *tmp = NULL; @@ -809,6 +825,7 @@ struct gg_send_msg s; unsigned char *attr_header = NULL, attr_buf[3]; char *text = NULL; + uint32_t seq; if (gm->text != NULL) { if (gs->encoding != GG_ENCODING_CP1250) { @@ -847,11 +864,12 @@ goto failure; } - if (gm->seq != (uint32_t) -1) - s.seq = gg_fix32(gm->seq); - else - s.seq = gg_fix32(rand()); + seq = gm->seq; + if (seq == (uint32_t) -1) + seq = rand(); + + s.seq = gg_fix32(seq); s.msgclass = gg_fix32(gm->msgclass); if ((gm->attributes != NULL) && (gm->attributes_length > 0)) { @@ -903,7 +921,7 @@ if (text != gm->text) free(text); - return gg_fix32(s.seq); + return seq; failure: if (text != gm->text) @@ -919,7 +937,7 @@ const char *attr; int attr_len; char *text = NULL, *html = NULL; - time_t now; + uint32_t seq; if (gm->html != NULL) { if (gs->encoding != GG_ENCODING_UTF8) { @@ -996,17 +1014,21 @@ // w ci?gu jednej sekundy, zwi?kszamy poprzedni? warto??, ?eby ka?da // wiadomo?? mia?a unikalny numer. - now = time(NULL); + seq = gm->seq; - if (now > gm->seq) - gm->seq = now; - else - gm->seq++; + if (seq == (uint32_t) -1) { + seq = time(NULL); - s.seq = gg_fix32(gm->seq); + if (seq <= gm->seq) + seq = gm->seq + 1; + + gs->seq = seq; + } + + s.seq = gg_fix32(seq); s.msgclass = gg_fix32(gm->msgclass); s.offset_plain = gg_fix32(sizeof(s) + strlen(html) + 1); - s.offset_attr = gg_fix32(s.offset_plain + strlen(text) + 1); + s.offset_attr = gg_fix32(sizeof(s) + strlen(html) + 1 + strlen(text) + 1); if ((gm->attributes != NULL) && (gm->attributes_length > 0)) { attr = gm->attributes; @@ -1065,7 +1087,7 @@ if (text != gm->text) free(text); - return gg_fix32(s.seq); + return seq; failure: if (html != gm->html) From libgadu-commit at lists.ziew.org Tue Mar 9 00:46:49 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Tue, 9 Mar 2010 00:46:49 +0100 Subject: [libgadu-commit] r912 - branches/new-api/examples Message-ID: <20100308234649.836CF17B65@toxygen.net> Author: wojtekka Date: 2010-03-09 00:46:49 +0100 (Tue, 09 Mar 2010) New Revision: 912 Modified: branches/new-api/examples/ Log: Ignorowanie binarek. Property changes on: branches/new-api/examples ___________________________________________________________________ Modified: svn:ignore - Makefile Makefile.in conn-async httphash register-async register-sync remind-async remind-sync send status status2 .deps .libs + Makefile Makefile.in conn-async httphash register-async register-sync remind-async remind-sync send status status2 token-sync token-async .deps .libs From libgadu-commit at lists.ziew.org Tue Mar 9 00:42:12 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Tue, 9 Mar 2010 00:42:12 +0100 Subject: [libgadu-commit] r908 - branches/new-api/src Message-ID: <20100308234212.CCCD917B5D@toxygen.net> Author: wojtekka Date: 2010-03-09 00:42:12 +0100 (Tue, 09 Mar 2010) New Revision: 908 Modified: branches/new-api/src/buffer.c branches/new-api/src/encoding.c Log: Nie includujemy Modified: branches/new-api/src/buffer.c =================================================================== --- branches/new-api/src/buffer.c 2010-03-08 23:40:41 UTC (rev 907) +++ branches/new-api/src/buffer.c 2010-03-08 23:42:12 UTC (rev 908) @@ -1,8 +1,9 @@ #include #include -#include #include +#include "libgadu.h" + typedef struct gg_buffer gg_buffer_t; struct gg_buffer { Modified: branches/new-api/src/encoding.c =================================================================== --- branches/new-api/src/encoding.c 2010-03-08 23:40:41 UTC (rev 907) +++ branches/new-api/src/encoding.c 2010-03-08 23:42:12 UTC (rev 908) @@ -18,7 +18,6 @@ */ #include -#include #include #include From libgadu-commit at lists.ziew.org Tue Mar 9 01:34:23 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Tue, 9 Mar 2010 01:34:23 +0100 Subject: [libgadu-commit] r921 - in branches/1.9: . test test/protocol Message-ID: <20100309003423.69AAA17B44@toxygen.net> Author: wojtekka Date: 2010-03-09 01:34:22 +0100 (Tue, 09 Mar 2010) New Revision: 921 Modified: branches/1.9/configure.ac branches/1.9/test/Makefile.am branches/1.9/test/protocol/Makefile.am Log: Kompilujemy tests/protocol tylko je?li mamy Perla (Marcin Wi?nicki) Modified: branches/1.9/configure.ac =================================================================== --- branches/1.9/configure.ac 2010-03-09 00:00:08 UTC (rev 920) +++ branches/1.9/configure.ac 2010-03-09 00:34:22 UTC (rev 921) @@ -199,14 +199,22 @@ dnl AC_SUBST([OPTIONAL_TESTS]) +OPTIONAL_TESTS="" + AC_CHECK_LIB(c, __connect, [ - OPTIONAL_TESTS="dcc7 connect resolver" -], -[ - OPTIONAL_TESTS="" + OPTIONAL_TESTS="$OPTIONAL_TESTS dcc7 connect resolver" ]) dnl +dnl Sprawd?, czy mamy Perla +dnl + +AC_CHECK_PROG(PERL, [perl], [perl]) +if test "x$PERL" != "x"; then + OPTIONAL_TESTS="$OPTIONAL_TESTS protocol" +fi + +dnl dnl Sprawd?, czy mamy czym generowa? dokumentacj? dnl Modified: branches/1.9/test/Makefile.am =================================================================== --- branches/1.9/test/Makefile.am 2010-03-09 00:00:08 UTC (rev 920) +++ branches/1.9/test/Makefile.am 2010-03-09 00:34:22 UTC (rev 921) @@ -1,3 +1,3 @@ -SUBDIRS = protocol $(OPTIONAL_TESTS) +SUBDIRS = $(OPTIONAL_TESTS) DIST_SUBDIRS = protocol gg8oauth dcc7 resolver connect EXTRA_DIST = config.sample Modified: branches/1.9/test/protocol/Makefile.am =================================================================== --- branches/1.9/test/protocol/Makefile.am 2010-03-09 00:00:08 UTC (rev 920) +++ branches/1.9/test/protocol/Makefile.am 2010-03-09 00:34:22 UTC (rev 921) @@ -7,7 +7,7 @@ SUBDIRS = tests script.c: $(wildcard tests/*.scr) compile - ./compile tests/*.scr > script.c + $(PERL) compile tests/*.scr > script.c clean-local: rm -f *.log script.c From libgadu-commit at lists.ziew.org Tue Mar 9 01:37:51 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Tue, 9 Mar 2010 01:37:51 +0100 Subject: [libgadu-commit] r922 - in branches/new-api/test/automatic: . script Message-ID: <20100309003752.1E7F117B44@toxygen.net> Author: wojtekka Date: 2010-03-09 01:37:51 +0100 (Tue, 09 Mar 2010) New Revision: 922 Modified: branches/new-api/test/automatic/Makefile.am branches/new-api/test/automatic/script/Makefile.am Log: Korzystamy ze znalezionego Perla. Modified: branches/new-api/test/automatic/Makefile.am =================================================================== --- branches/new-api/test/automatic/Makefile.am 2010-03-09 00:34:22 UTC (rev 921) +++ branches/new-api/test/automatic/Makefile.am 2010-03-09 00:37:51 UTC (rev 922) @@ -26,7 +26,7 @@ SUBDIRS = script script/script.c: $(wildcard script/*.scr) script/compile - script/compile script/*.scr > script/script.c + $(PERL) script/compile script/*.scr > script/script.c clean-local: rm -f *.html *.log *-valgrind Modified: branches/new-api/test/automatic/script/Makefile.am =================================================================== --- branches/new-api/test/automatic/script/Makefile.am 2010-03-09 00:34:22 UTC (rev 921) +++ branches/new-api/test/automatic/script/Makefile.am 2010-03-09 00:37:51 UTC (rev 922) @@ -3,7 +3,7 @@ EXTRA_DIST = *.scr script.c: $(wildcard *.scr) compile - ./compile *.scr > script.c + $(PERL) compile *.scr > script.c clean-local: rm -f script.c From libgadu-commit at lists.ziew.org Tue Mar 9 21:03:30 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Tue, 9 Mar 2010 21:03:30 +0100 Subject: [libgadu-commit] r923 - in branches/1.9: . src Message-ID: <20100309200330.AA4F817B44@toxygen.net> Author: wojtekka Date: 2010-03-09 21:03:29 +0100 (Tue, 09 Mar 2010) New Revision: 923 Modified: branches/1.9/README branches/1.9/configure.ac branches/1.9/src/libgadu.c Log: Podbicie wersji do 1.9.0-rc3, podbicie roku w copyrightach. Modified: branches/1.9/README =================================================================== --- branches/1.9/README 2010-03-09 00:37:51 UTC (rev 922) +++ branches/1.9/README 2010-03-09 20:03:29 UTC (rev 923) @@ -1,5 +1,5 @@ -libgadu 1.9.0-rc2 -(C) Copyright 2001-2009 Autorzy (pe?na lista w pliku AUTHORS) +libgadu 1.9.0-rc3 +(C) Copyright 2001-2010 Autorzy (pe?na lista w pliku AUTHORS) libgadu jest bibliotek? przeznaczon? do obs?ugi protoko?u komunikatora Gadu-Gadu. Przez d?u?szy czas by?a integraln? cz??ci? Eksperymentalnego Modified: branches/1.9/configure.ac =================================================================== --- branches/1.9/configure.ac 2010-03-09 00:37:51 UTC (rev 922) +++ branches/1.9/configure.ac 2010-03-09 20:03:29 UTC (rev 923) @@ -1,7 +1,7 @@ dnl $Id$ AC_INIT(src/libgadu.c) -AM_INIT_AUTOMAKE(libgadu, 1.9.0-rc2) +AM_INIT_AUTOMAKE(libgadu, 1.9.0-rc3) AC_PREREQ(2.50) AC_CANONICAL_HOST Modified: branches/1.9/src/libgadu.c =================================================================== --- branches/1.9/src/libgadu.c 2010-03-09 00:37:51 UTC (rev 922) +++ branches/1.9/src/libgadu.c 2010-03-09 20:03:29 UTC (rev 923) @@ -1,7 +1,7 @@ /* $Id$ */ /* - * (C) Copyright 2001-2009 Wojtek Kaniewski + * (C) Copyright 2001-2010 Wojtek Kaniewski * Robert J. Wo?ny * Arkadiusz Mi?kiewicz * Tomasz Chili?ski From libgadu-commit at lists.ziew.org Tue Mar 9 22:14:07 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Tue, 9 Mar 2010 22:14:07 +0100 Subject: [libgadu-commit] r924 - branches/new-api Message-ID: <20100309211408.04CCF17B44@toxygen.net> Author: wojtekka Date: 2010-03-09 22:14:07 +0100 (Tue, 09 Mar 2010) New Revision: 924 Modified: branches/new-api/configure.ac Log: Ale o co mi chodzi?o? Modified: branches/new-api/configure.ac =================================================================== --- branches/new-api/configure.ac 2010-03-09 20:03:29 UTC (rev 923) +++ branches/new-api/configure.ac 2010-03-09 21:14:07 UTC (rev 924) @@ -141,7 +141,7 @@ ]) AC_ARG_ENABLE(debug, - [ --disable-debug compile without debugging support (recommended only on embedded systems)]) + [ --disable-debug compile without debugging support]) if test "x$enable_debug" = "xno"; then AC_MSG_WARN([--disable-debug is obsolete.]) From libgadu-commit at lists.ziew.org Tue Mar 9 22:30:36 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Tue, 9 Mar 2010 22:30:36 +0100 Subject: [libgadu-commit] r925 - branches/1.9 Message-ID: <20100309213036.83DE617B44@toxygen.net> Author: wojtekka Date: 2010-03-09 22:30:35 +0100 (Tue, 09 Mar 2010) New Revision: 925 Modified: branches/1.9/configure.ac Log: Mo?liwo?? wy??czenia test?w (Marcin Wi?nicki) Modified: branches/1.9/configure.ac =================================================================== --- branches/1.9/configure.ac 2010-03-09 21:14:07 UTC (rev 924) +++ branches/1.9/configure.ac 2010-03-09 21:30:35 UTC (rev 925) @@ -195,23 +195,21 @@ fi dnl -dnl Sprawd?, czy mo?na korzysta? z __funkcji w libc. +dnl Sprawd?, czy mo?emy kompilowa? testy. dnl AC_SUBST([OPTIONAL_TESTS]) OPTIONAL_TESTS="" -AC_CHECK_LIB(c, __connect, [ - OPTIONAL_TESTS="$OPTIONAL_TESTS dcc7 connect resolver" -]) +AC_ARG_ENABLE(tests, + [ --disable-tests do not compile tests]) -dnl -dnl Sprawd?, czy mamy Perla -dnl - -AC_CHECK_PROG(PERL, [perl], [perl]) -if test "x$PERL" != "x"; then - OPTIONAL_TESTS="$OPTIONAL_TESTS protocol" +if test "x$enable_tests" != "xno"; then + AC_CHECK_LIB(c, __connect, [OPTIONAL_TESTS="$OPTIONAL_TESTS dcc7 connect resolver"]) + AC_CHECK_PROG(PERL, [perl], [perl]) + if test "x$PERL" != "x"; then + OPTIONAL_TESTS="$OPTIONAL_TESTS protocol" + fi fi dnl From libgadu-commit at lists.ziew.org Tue Mar 9 23:21:16 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Tue, 9 Mar 2010 23:21:16 +0100 Subject: [libgadu-commit] r926 - tags Message-ID: <20100309222116.9907D17B4E@toxygen.net> Author: wojtekka Date: 2010-03-09 23:21:16 +0100 (Tue, 09 Mar 2010) New Revision: 926 Added: tags/1.9.0-rc3/ Log: 1.9.0-rc3 From libgadu-commit at lists.ziew.org Tue Mar 9 23:24:52 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Tue, 9 Mar 2010 23:24:52 +0100 Subject: [libgadu-commit] r927 - in trunk: . docs examples include src test test/connect test/dcc7 test/protocol test/protocol/tests Message-ID: <20100309222452.B05DF17B44@toxygen.net> Author: wojtekka Date: 2010-03-09 23:24:51 +0100 (Tue, 09 Mar 2010) New Revision: 927 Added: trunk/examples/token.c trunk/src/libgadu.sym Modified: trunk/ trunk/Makefile.am trunk/README trunk/autoclean.sh trunk/autogen.sh trunk/configure.ac trunk/docs/ trunk/docs/Doxyfile.in trunk/docs/Makefile.am trunk/docs/changelog.dox trunk/docs/events.dox trunk/docs/login.dox trunk/docs/messages.dox trunk/docs/pubdir50.dox trunk/docs/status.dox trunk/examples/ trunk/examples/Makefile.am trunk/examples/register.c trunk/examples/remind.c trunk/include/internal.h trunk/include/libgadu.h.in trunk/include/protocol.h trunk/include/resolver.h trunk/src/Makefile.am trunk/src/common.c trunk/src/dcc7.c trunk/src/events.c trunk/src/http.c trunk/src/libgadu.c trunk/src/obsolete.c trunk/src/pubdir50.c trunk/src/resolver.c trunk/test/Makefile.am trunk/test/connect/connect.c trunk/test/dcc7/dcc7.c trunk/test/protocol/Makefile.am trunk/test/protocol/protocol.c trunk/test/protocol/tests/00-login.scr trunk/test/protocol/tests/10-contacts.scr trunk/test/protocol/tests/20-messages.scr trunk/test/protocol/tests/30-status.scr Log: Merge z /branches/1.9. Property changes on: trunk ___________________________________________________________________ Added: svn:mergeinfo + /branches/1.9:786-926 Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/Makefile.am 2010-03-09 22:24:51 UTC (rev 927) @@ -1,7 +1,9 @@ -SUBDIRS = include src pkgconfig docs test examples +SUBDIRS = include src pkgconfig test examples @SUBDIRS_DOXYGEN@ +DIST_SUBDIRS = include src pkgconfig test examples docs -LIBTOOL_DEPS = @LIBTOOL_DEPS@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ + libtool: $(LIBTOOL_DEPS) - $(SHELL) ./config.status --recheck + $(SHELL) ./config.status --recheck ACLOCAL_AMFLAGS = -I m4 Modified: trunk/README =================================================================== --- trunk/README 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/README 2010-03-09 22:24:51 UTC (rev 927) @@ -1,5 +1,5 @@ -libgadu 1.8.0 -(C) Copyright 2001-2008 Autorzy (pe?na lista w pliku AUTHORS) +libgadu 1.10.0-pre +(C) Copyright 2001-2010 Autorzy (pe?na lista w pliku AUTHORS) libgadu jest bibliotek? przeznaczon? do obs?ugi protoko?u komunikatora Gadu-Gadu. Przez d?u?szy czas by?a integraln? cz??ci? Eksperymentalnego Modified: trunk/autoclean.sh =================================================================== --- trunk/autoclean.sh 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/autoclean.sh 2010-03-09 22:24:51 UTC (rev 927) @@ -31,6 +31,11 @@ include/Makefile.in \ include/libgadu.h \ include/stamp* \ + docs/Makefile.in \ + examples/Makefile.in \ + test/Makefile.in \ + test/*/Makefile.in \ + test/protocol/tests/Makefile.in \ pkgconfig/Makefile \ pkgconfig/Makefile.in \ pkgconfig/libgadu.pc \ Modified: trunk/autogen.sh =================================================================== --- trunk/autogen.sh 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/autogen.sh 2010-03-09 22:24:51 UTC (rev 927) @@ -7,5 +7,8 @@ echo automake && automake --add-missing --copy --force --foreign || exit 1 echo autoconf && autoconf || exit 1 -test x$NOCONFIGURE = x && echo configure && ./configure $* +if test x$NOCONFIGURE = x ; then + echo configure + ./configure $* +fi Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/configure.ac 2010-03-09 22:24:51 UTC (rev 927) @@ -1,7 +1,7 @@ dnl $Id$ AC_INIT(src/libgadu.c) -AM_INIT_AUTOMAKE(libgadu, 1.9.0-rc1) +AM_INIT_AUTOMAKE(libgadu, 1.10.0-pre) AC_PREREQ(2.50) AC_CANONICAL_HOST @@ -13,6 +13,7 @@ AC_PROG_LN_S AC_C_CONST AC_PROG_LIBTOOL +AC_SUBST(LIBTOOL_DEPS) AC_SUBST(REQUIRES) AC_SUBST(INCLUDES) @@ -194,17 +195,36 @@ fi dnl -dnl Sprawd?, czy mo?na korzysta? z __funkcji w libc. +dnl Sprawd?, czy mo?emy kompilowa? testy. dnl AC_SUBST([OPTIONAL_TESTS]) -AC_CHECK_LIB(c, __connect, [ - OPTIONAL_TESTS="dcc7 connect resolver" -], -[ - OPTIONAL_TESTS="" -]) +OPTIONAL_TESTS="" +AC_ARG_ENABLE(tests, + [ --disable-tests do not compile tests]) + +if test "x$enable_tests" != "xno"; then + AC_CHECK_LIB(c, __connect, [OPTIONAL_TESTS="$OPTIONAL_TESTS dcc7 connect resolver"]) + AC_CHECK_PROG(PERL, [perl], [perl]) + if test "x$PERL" != "x"; then + OPTIONAL_TESTS="$OPTIONAL_TESTS protocol" + fi +fi + +dnl +dnl Sprawd?, czy mamy czym generowa? dokumentacj? +dnl + +AC_CHECK_PROG([DOXYGEN], [doxygen], [doxygen], [:]) + +AC_SUBST([SUBDIRS_DOXYGEN]) +if test "x$DOXYGEN" = "xdoxygen"; then + SUBDIRS_DOXYGEN="docs" +else + SUBDIRS_DOXYGEN="" +fi + AC_CONFIG_FILES([Makefile src/Makefile include/Makefile pkgconfig/Makefile pkgconfig/libgadu.pc docs/Makefile docs/Doxyfile examples/Makefile test/Makefile test/protocol/Makefile test/protocol/tests/Makefile test/dcc7/Makefile test/connect/Makefile test/gg8oauth/Makefile test/resolver/Makefile]) AC_OUTPUT Property changes on: trunk/docs ___________________________________________________________________ Modified: svn:ignore - html Makefile Makefile.in Doxyfile + html html-stamp Makefile Makefile.in Doxyfile Modified: trunk/docs/Doxyfile.in =================================================================== --- trunk/docs/Doxyfile.in 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/docs/Doxyfile.in 2010-03-09 22:24:51 UTC (rev 927) @@ -41,7 +41,7 @@ OPTIMIZE_OUTPUT_FOR_C = YES OPTIMIZE_OUTPUT_JAVA = NO SHOW_USED_FILES = YES -DETAILS_AT_TOP = YES +#DETAILS_AT_TOP = YES #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- Modified: trunk/docs/Makefile.am =================================================================== --- trunk/docs/Makefile.am 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/docs/Makefile.am 2010-03-09 22:24:51 UTC (rev 927) @@ -1,10 +1,11 @@ EXTRA_DIST = Doxyfile protocol.html *.dox -all-local: html +all-local: html-stamp -html: ../include/libgadu.h - test -d html || doxygen || true +html-stamp: ../include/libgadu.h $(wildcard ../src/*.c) $(wildcard *.dox) + $(DOXYGEN) + touch html-stamp clean-local: - rm -rf html + rm -rf html html-stamp Modified: trunk/docs/changelog.dox =================================================================== --- trunk/docs/changelog.dox 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/docs/changelog.dox 2010-03-09 22:24:51 UTC (rev 927) @@ -11,11 +11,11 @@ \section changelog-1_9_0 libgadu 1.9.0 -- Podstawowa obs?uga protoko?u Nowego Gadu-Gadu, a co za tym idzie, wiadomo?ci i opisy kodowane w UTF-8. Domy?lnie biblioteka nadal przekazuje do aplikacji i spodziewa si? od niej tekst?w w CP1250, ale pole \c encoding struktury \c gg_login_params pozwala zmieni? kodowanie na UTF-8. Uwaga! Kodowanie danych innych ni? wiadomo?ci i opisy pozostaje w CP1250. \ref gg_login_params "Szczeg??y." +- Podstawowa obs?uga protoko?u Nowego Gadu-Gadu, a co za tym idzie, wiadomo?ci i opisy kodowane w UTF-8. Domy?lnie biblioteka nadal przekazuje do aplikacji i spodziewa si? od niej tekst?w w CP1250, ale pole \c encoding struktury \c gg_login_params pozwala zmieni? kodowanie na UTF-8. Mimo ?e katalog publiczny ze strony serwera jest obs?ugiwany w CP1250, biblioteka dokonuje konwersji. \ref gg_login_params "Szczeg??y." - Poniewa? nowy klient przekazuje wiadomo?ci w dw?ch formatach — czysty tekst plus atrybuty i HTML, dodano pole \c xhtml_message do struktury \c gg_event_msg. Niestety, nie mo?na jeszcze wysy?a? wiadomo?ci w tym formacie. \ref gg_event_msg "Szczeg??y." -- Razem z nowym protoko?em przysz?y nowe statusy: \c GG_STATUS_FFC, \c GG_STATUS_FFC_DESCR, \c GG_STATUS_DND i \c GG_STATUS_DND_DESCR. \ref status "Szczeg??y." +- Razem z nowym protoko?em przysz?y nowe statusy: \c GG_STATUS_FFC, \c GG_STATUS_FFC_DESCR, \c GG_STATUS_DND i \c GG_STATUS_DND_DESCR. Uwaga! Je?li pole \c protocol_features struktury \c gg_login_params zawiera \c GG_FEATURE_IMAGE_DESCR, statusy z opisami s? przekazywane w inny spos?b. \ref status "Szczeg??y." - Aplikacja mo?e sama wybra? spos?b rozwi?zywania nazw serwer?w — przy u?yciu procesu, w?tku lub we w?asny spos?b. Mo?na to zrobi? za pomoc? pola \c resolver_type struktury \c gg_login_params dla proces?w i w?tk?w, lub globalnie za pomoc? funkcji \ref gg_global_set_resolver czy \ref gg_global_set_custom_resolver. \ref build-resolver "Szczeg??y." Modified: trunk/docs/events.dox =================================================================== --- trunk/docs/events.dox 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/docs/events.dox 2010-03-09 22:24:51 UTC (rev 927) @@ -255,7 +255,7 @@ \c GG_EVENT_NOTIFY -\c event.notify\c[\c] +\c event.notify[] \c gg_notify_reply \copydoc gg_event_t::GG_EVENT_NOTIFY @@ -273,7 +273,7 @@ \c GG_EVENT_NOTIFY60 -\c event.notify60\c[\c] +\c event.notify60[] \c gg_event_notify60 \copydoc gg_event_t::GG_EVENT_NOTIFY60 Modified: trunk/docs/login.dox =================================================================== --- trunk/docs/login.dox 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/docs/login.dox 2010-03-09 22:24:51 UTC (rev 927) @@ -38,6 +38,17 @@ Dok?adny opis dalszej obs?ugi po??czenia znajduje si? w sekcji po?wi?conej \ref events "obs?udze zdarze?". +Nowe statusy (nie przeszkadza?, poGGadaj ze mn?), opisy graficzne i wiadomo?ci +kodowane UTF-8 b?d? dost?pne dopiero po ustawieniu odpowiednich parametr?w +po??czenia. Jest to niezb?dne, poniewa? starsze klienty mog?yby nie dzia?a? +prawid?owo, gdyby przy domy?lnych parametrach po??czenia zmieni?oby si? +zachowanie biblioteki. + +\code +parametry.encoding = GG_ENCODING_UTF8; +parametry.protocol_features = GG_FEATURE_DND_FFC | GG_FEATURE_IMAGE_DESCR; +\endcode + Aby ??czy? si? z u?yciem serwera po?rednicz?cego (ang. \e proxy), nale?y przed po??czeniem ustawi? zmienne globalne \ref proxy "\c gg_proxy_enabled" , \ref proxy "\c gg_proxy_host" Modified: trunk/docs/messages.dox =================================================================== --- trunk/docs/messages.dox 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/docs/messages.dox 2010-03-09 22:24:51 UTC (rev 927) @@ -66,11 +66,12 @@ opisuj?ca kolor za pomoc? sk?adowych RGB. Je?li wyst?puje atrybut \c GG_FONT_IMAGE, za struktur? znajduje si? -struktura \c gg_msg_richtext_image. Pole \c unknown1 jest nieznane, ale -powinno zawiera? warto?? \c 0x0109. Pola \c size i \c crc32 identyfikuj? -obrazek, kt?ry mo?na pobra? od nadawcy lub z dysku lokalnego, je?li by? ju? -wcze?niej pobierany (np. cz?sto u?ywana ikonka). Opis pobierania obrazk?w -od nadawcy znajduje si? \ref messages-images "poni?ej". +struktura \c gg_msg_richtext_image. Pole \c unknown1 zawiera rozmiar (0x09) +oraz rodzaj struktury (0x01), ale ze wzgl?d?w historycznych jest liczb? +16-bitow? i nale?y przypisa? mu warto?? \c 0x0109. Pola \c size i \c crc32 +identyfikuj? obrazek, kt?ry mo?na pobra? od nadawcy lub z dysku lokalnego, +je?li by? ju? wcze?niej pobierany (np. cz?sto u?ywana ikonka). Opis pobierania +obrazk?w od nadawcy znajduje si? \ref messages-images "poni?ej". \note Biblioteka nie ingeruje w zawarto?? bloku formatowania, wi?c kolejno?? bajt?w mo?e si? r??ni? od u?ywanej na danej architekturze. By pobra? lub Modified: trunk/docs/pubdir50.dox =================================================================== --- trunk/docs/pubdir50.dox 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/docs/pubdir50.dox 2010-03-09 22:24:51 UTC (rev 927) @@ -48,8 +48,8 @@ \c gg_pubdir50_add() dodaje kolejne pola zapytania. Pole zapytania jest w rzeczywi?ci sta?? tekstow?, np. \c GG_PUBDIR50_UIN to \c "FmNumber". Nale?y pami?ta?, ?e wszystkie argumenty s? tekstami, ale nie trzeba si? przejmowa? -alokacj? pami?ci — biblioteka zapami?ta to, co jest potrzebne. Teksty -musz? by? oczywi?cie kodowane w CP1250. Na ko?cu wywo?ujemy funkcj? +alokacj? pami?ci — biblioteka zapami?ta to, co jest potrzebne. Kodowanie +tekst?w jest zgodne z ustawieniem sesji. Na ko?cu wywo?ujemy funkcj? \c gg_pubdir50(), kt?ra zwr?ci numer sekwencyjny wyszukiwania (mo?na zachowa? dla p??niejszego rozr??nienia wynik?w). Modified: trunk/docs/status.dox =================================================================== --- trunk/docs/status.dox 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/docs/status.dox 2010-03-09 22:24:51 UTC (rev 927) @@ -22,7 +22,12 @@ \ref contacts "doda? do listy konktakt?w" ich identyfikatory, a nast?pnie obs?ugiwa? \ref events-list "zdarzenia" zwi?zane ze zmianami statusu. -\bug Nie ma mo?liwo?ci ustawiania i poprawnego odbierania status?w -zawieraj?cych czas powrotu. +Je?li pole \c protocol_features struktury \c gg_login_params zawiera +\c GG_FEATURE_IMAGE_DESCR, informacja o tym, ?e status zawiera opis jest +dodatkowo przekazywana za pomoc? flagi \c GG_STATUS_DESCR_MASK. To samo +dotyczy zmiany status?w os?b z listy kontakt?w. +\bug Nie ma mo?liwo?ci poprawnego odbierania status?w zawieraj?cych czas +powrotu. + */ Property changes on: trunk/examples ___________________________________________________________________ Modified: svn:ignore - Makefile Makefile.in conn-async httphash register-async register-sync remind-async remind-sync send status .deps .libs + Makefile Makefile.in conn-async httphash register-async register-sync remind-async remind-sync token-async token-sync send status .deps .libs Modified: trunk/examples/Makefile.am =================================================================== --- trunk/examples/Makefile.am 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/examples/Makefile.am 2010-03-09 22:24:51 UTC (rev 927) @@ -1,13 +1,20 @@ -noinst_PROGRAMS = send httphash conn-async register-sync register-async remind-sync remind-async status +noinst_PROGRAMS = send httphash conn-async register-sync register-async remind-sync remind-async status token-sync token-async LDADD = ../src/libgadu.la +httphash_CFLAGS = -DGG_IGNORE_DEPRECATED + register_sync_SOURCES = register.c register_async_SOURCES = register.c register_async_CFLAGS = -DASYNC -remind_sync_SOURCES = register.c +remind_sync_SOURCES = remind.c -remind_async_SOURCES = register.c +remind_async_SOURCES = remind.c remind_async_CFLAGS = -DASYNC +token_sync_SOURCES = token.c + +token_async_SOURCES = token.c +token_async_CFLAGS = -DASYNC + Modified: trunk/examples/register.c =================================================================== --- trunk/examples/register.c 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/examples/register.c 2010-03-09 22:24:51 UTC (rev 927) @@ -19,40 +19,38 @@ #endif -int main(void) +int main(int argc, char **argv) { struct gg_http *h; struct gg_pubdir *p; - char email[100], password[100]; + const char *email; + const char *password; + const char *tokenid; + const char *tokenval; - gg_debug_level = 255; - - printf("e-mail: "); - if (fgets(email, 99, stdin) == NULL) + if (argc < 5) { + printf("U?ycie: %s \n", argv[0]); return 1; - if (email[strlen(email)-1] == '\n') - email[strlen(email)-1] = 0; - printf("password: "); - if (fgets(password, 99, stdin) == NULL) - return 1; - if (password[strlen(password)-1] == '\n') - password[strlen(password)-1] = 0; + } -#ifndef ASYNC + email = argv[1]; + password = argv[2]; + tokenid = argv[3]; + tokenval = argv[4]; - if (!(h = gg_register(email, password, 0))) { + gg_debug_level = 255; + +#ifndef ASYNC + if (!(h = gg_register3(email, password, tokenid, tokenval, 0))) { printf("B??d rejestracji.\n"); return 1; } - p = h->data; - printf("success=%d, uin=%d\n", p->success, p->uin); - gg_free_register(h); #else signal(SIGCHLD, sigchld); - if (!(h = gg_register(email, password, 1))) + if (!(h = gg_register3(email, password, tokenid, tokenval, 1))) return 1; while (1) { @@ -87,17 +85,16 @@ fprintf(stderr, "B??d rejestracji.\n"); return 1; } - if (h->state == GG_STATE_DONE) { - p = h->data; - printf("success=%d, uin=%d\n", p->success, p->uin); - gg_free_register(h); + if (h->state == GG_STATE_DONE) break; - } } } - #endif + p = h->data; + printf("success=%d\nuin=%d\n", p->success, p->uin); + gg_free_register(h); + return 0; } Modified: trunk/examples/remind.c =================================================================== --- trunk/examples/remind.c 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/examples/remind.c 2010-03-09 22:24:51 UTC (rev 927) @@ -18,32 +18,36 @@ #endif -int main() +int main(int argc, char **argv) { struct gg_http *h; struct gg_pubdir *p; uin_t uin; + const char *email; + const char *tokenid; + const char *tokenval; + if (argc < 5) { + printf("U?ycie: %s \n", argv[0]); + return 1; + } + + uin = atoi(argv[1]); + email = argv[2]; + tokenid = argv[3]; + tokenval = argv[4]; + gg_debug_level = 255; - - printf("uin: "); - scanf("%d", &uin); #ifndef ASYNC - - if (!(h = gg_remind_passwd(uin, 0))) { + if (!(h = gg_remind_passwd3(uin, email, tokenid, tokenval, 0))) { printf("B??d przypominania has?a.\n"); return 1; } - p = h->data; - printf("success=%d\n", p->success); - gg_free_remind_passwd(h); - #else - signal(SIGCHLD, sigchld); - if (!(h = gg_remind_passwd(uin, 1))) + if (!(h = gg_remind_passwd3(uin, email, tokenid, tokenval, 1))) return 1; while (1) { @@ -78,17 +82,16 @@ fprintf(stderr, "B??d przypominania has?a.\n"); return 1; } - if (h->state == GG_STATE_DONE) { - p = h->data; - printf("success=%d\n", p->success); - gg_free_remind_passwd(h); + if (h->state == GG_STATE_DONE) break; - } } } - #endif + p = h->data; + printf("success=%d\n", p->success); + gg_free_remind_passwd(h); + return 0; } Copied: trunk/examples/token.c (from rev 884, branches/1.9/examples/token.c) =================================================================== --- trunk/examples/token.c (rev 0) +++ trunk/examples/token.c 2010-03-09 22:24:51 UTC (rev 927) @@ -0,0 +1,120 @@ +#include +#include +#include +#include "libgadu.h" + +#ifdef ASYNC + +#include +#include +#include +#include + +void sigchld(int sig) +{ + wait(NULL); + signal(SIGCHLD, sigchld); +} + +#endif + +int main(void) +{ + struct gg_http *h; + struct gg_token *t; + char path[] = "token.XXXXXX"; + FILE *f; + + gg_debug_level = 255; + +#ifndef ASYNC + + if (!(h = gg_token(0))) { + printf("B??d pobierania tokenu.\n"); + return 1; + } + +#else + + signal(SIGCHLD, sigchld); + + if (!(h = gg_token(1))) + return 1; + + while (1) { + fd_set rd, wr, ex; + + FD_ZERO(&rd); + FD_ZERO(&wr); + FD_ZERO(&ex); + + if ((h->check & GG_CHECK_READ)) + FD_SET(h->fd, &rd); + if ((h->check & GG_CHECK_WRITE)) + FD_SET(h->fd, &wr); + FD_SET(h->fd, &ex); + + if (select(h->fd + 1, &rd, &wr, &ex, NULL) == -1 || FD_ISSET(h->fd, &ex)) { + if (errno == EINTR) + continue; + gg_token_free(h); + perror("select"); + return 1; + } + + if (FD_ISSET(h->fd, &rd) || FD_ISSET(h->fd, &wr)) { + if (gg_token_watch_fd(h) == -1) { + gg_token_free(h); + fprintf(stderr, "B??d po??czenia.\n"); + return 1; + } + if (h->state == GG_STATE_ERROR) { + gg_token_free(h); + fprintf(stderr, "B??d pobierania tokenu.\n"); + return 1; + } + if (h->state == GG_STATE_DONE) + break; + + } + } + +#endif + + t = h->data; + +#if defined(_BSD_SOURCE) || defined(_SVID_SOURCE) || _XOPEN_SOURCE >= 500 + if (mkstemp(path) == -1) { +#else + if (strcmp(mktemp(path), "") == 0) { +#endif + printf("B??d tworzenia pliku tymczasowego.\n"); + gg_token_free(h); + return 1; + } + + f = fopen(path, "w"); + + if (f == NULL) { + printf("B??d otwierania pliku tymczasowego %s.\n", path); + gg_token_free(h); + return 1; + } + + if (fwrite(h->body, h->body_size, 1, f) != 1) { + printf("B??d zapisu do pliku tymczasowego %s.\n", path); + gg_token_free(h); + fclose(f); + unlink(path); + return 1; + } + + fclose(f); + + printf("id=%s\nwidth=%d\nheight=%d\nlength=%d\npath=%s\n", t->tokenid, t->width, t->height, t->length, path); + + gg_token_free(h); + + return 0; +} + Modified: trunk/include/internal.h =================================================================== --- trunk/include/internal.h 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/include/internal.h 2010-03-09 22:24:51 UTC (rev 927) @@ -21,7 +21,10 @@ #ifndef LIBGADU_INTERNAL_H #define LIBGADU_INTERNAL_H +#include "libgadu.h" + char *gg_cp_to_utf8(const char *b); char *gg_utf8_to_cp(const char *b); +int gg_pubdir50_handle_reply_sess(struct gg_session *sess, struct gg_event *e, const char *packet, int length); #endif /* LIBGADU_INTERNAL_H */ Modified: trunk/include/libgadu.h.in =================================================================== --- trunk/include/libgadu.h.in 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/include/libgadu.h.in 2010-03-09 22:24:51 UTC (rev 927) @@ -317,8 +317,14 @@ #ifdef __GNUC__ #define GG_PACKED __attribute__ ((packed)) +#ifndef GG_IGNORE_DEPRECATED +#define GG_DEPRECATED __attribute__ ((deprecated)) #else +#define GG_DEPRECATED +#endif +#else #define GG_PACKED +#define GG_DEPRECATED #endif /** \endcond */ @@ -567,7 +573,7 @@ int hash_type; /**< Rodzaj skr?tu has?a (\c GG_LOGIN_HASH_GG32 lub \c GG_LOGIN_HASH_SHA1, domy?lnie SHA1) */ gg_encoding_t encoding; /**< Rodzaj kodowania u?ywanego w sesji (domy?lnie CP1250) */ gg_resolver_t resolver; /**< Spos?b rozwi?zywania nazw (patrz \ref build-resolver) */ - int protocol_features; /**< Opcje protoko?u (flagi GG_FEATURE_*) */ + int protocol_features; /**< Opcje protoko?u (flagi GG_FEATURE_*). */ #ifndef DOXYGEN char dummy[2 * sizeof(int)]; /**< \internal Miejsce na kilka kolejnych @@ -709,7 +715,7 @@ int num; /**< Numer wyniku */ char *field; /**< Nazwa pola */ char *value; /**< Warto?? pola */ -}; +} /* GG_DEPRECATED */; /** * Zapytanie lub odpowied? katalogu publicznego. @@ -723,7 +729,7 @@ uint32_t seq; /**< Numer sekwencyjny */ struct gg_pubdir50_entry *entries; /**< Pola zapytania lub odpowiedzi */ int entries_count; /**< Liczba p?l */ -}; +} /* GG_DEPRECATED */; /** * Zapytanie lub odpowied? katalogu publicznego. @@ -858,6 +864,13 @@ }; /** + * Opis zdarzenia \c GG_EVENT_DCC7_PENDING. + */ +struct gg_event_dcc7_pending { + struct gg_dcc7 *dcc7; /**< Struktura po??czenia */ +}; + +/** * Opis zdarzenia \c GG_EVENT_DCC7_REJECT. */ struct gg_event_dcc7_reject { @@ -901,6 +914,7 @@ struct gg_dcc7 *dcc7_new; /**< Nowe po??czenie bezpo?rednie (\c GG_EVENT_DCC7_NEW) */ enum gg_error_t dcc7_error; /**< B??d po??czenia bezpo?redniego (\c GG_EVENT_DCC7_ERROR) */ struct gg_event_dcc7_connected dcc7_connected; /**< Informacja o zestawieniu po??czenia bezpo?redniego (\c GG_EVENT_DCC7_CONNECTED) */ + struct gg_event_dcc7_pending dcc7_pending; /**< Trwa pr?ba po??czenia bezpo?redniego (\c GG_EVENT_DCC7_PENDING) */ struct gg_event_dcc7_reject dcc7_reject; /**< Odrzucono po??czenia bezpo?redniego (\c GG_EVENT_DCC7_REJECT) */ struct gg_event_dcc7_accept dcc7_accept; /**< Zaakceptowano po??czenie bezpo?rednie (\c GG_EVENT_DCC7_ACCEPT) */ }; @@ -1191,12 +1205,12 @@ char *email; char *phone; uin_t uin; -}; +} /* GG_DEPRECATED */; struct gg_search { int count; struct gg_search_result *results; -}; +} GG_DEPRECATED; struct gg_search_result { uin_t uin; @@ -1207,35 +1221,35 @@ int gender; char *city; int active; -}; +} GG_DEPRECATED; #define GG_GENDER_NONE 0 #define GG_GENDER_FEMALE 1 #define GG_GENDER_MALE 2 -struct gg_http *gg_search(const struct gg_search_request *r, int async); -int gg_search_watch_fd(struct gg_http *f); -void gg_free_search(struct gg_http *f); +struct gg_http *gg_search(const struct gg_search_request *r, int async) GG_DEPRECATED; +int gg_search_watch_fd(struct gg_http *f) GG_DEPRECATED; +void gg_free_search(struct gg_http *f) GG_DEPRECATED; #define gg_search_free gg_free_search -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); -const struct gg_search_request *gg_search_request_mode_1(char *email, int active, int start); -const struct gg_search_request *gg_search_request_mode_2(char *phone, int active, int start); -const struct gg_search_request *gg_search_request_mode_3(uin_t uin, int active, int start); -void gg_search_request_free(struct gg_search_request *r); +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) GG_DEPRECATED; +const struct gg_search_request *gg_search_request_mode_1(char *email, int active, int start) GG_DEPRECATED; +const struct gg_search_request *gg_search_request_mode_2(char *phone, int active, int start) GG_DEPRECATED; +const struct gg_search_request *gg_search_request_mode_3(uin_t uin, int active, int start) GG_DEPRECATED; +void gg_search_request_free(struct gg_search_request *r) GG_DEPRECATED; -struct gg_http *gg_register(const char *email, const char *password, int async); -struct gg_http *gg_register2(const char *email, const char *password, const char *qa, int async); +struct gg_http *gg_register(const char *email, const char *password, int async) GG_DEPRECATED; +struct gg_http *gg_register2(const char *email, const char *password, const char *qa, int async) GG_DEPRECATED; -struct gg_http *gg_unregister(uin_t uin, const char *password, const char *email, int async); -struct gg_http *gg_unregister2(uin_t uin, const char *password, const char *qa, int async); +struct gg_http *gg_unregister(uin_t uin, const char *password, const char *email, int async) GG_DEPRECATED; +struct gg_http *gg_unregister2(uin_t uin, const char *password, const char *qa, int async) GG_DEPRECATED; -struct gg_http *gg_remind_passwd(uin_t uin, int async); -struct gg_http *gg_remind_passwd2(uin_t uin, const char *tokenid, const char *tokenval, int async); +struct gg_http *gg_remind_passwd(uin_t uin, int async) GG_DEPRECATED; +struct gg_http *gg_remind_passwd2(uin_t uin, const char *tokenid, const char *tokenval, int async) GG_DEPRECATED; -struct gg_http *gg_change_passwd(uin_t uin, const char *passwd, const char *newpasswd, const char *newemail, int async); -struct gg_http *gg_change_passwd2(uin_t uin, const char *passwd, const char *newpasswd, const char *email, const char *newemail, int async); -struct gg_http *gg_change_passwd3(uin_t uin, const char *passwd, const char *newpasswd, const char *qa, int async); +struct gg_http *gg_change_passwd(uin_t uin, const char *passwd, const char *newpasswd, const char *newemail, int async) GG_DEPRECATED; +struct gg_http *gg_change_passwd2(uin_t uin, const char *passwd, const char *newpasswd, const char *email, const char *newemail, int async) GG_DEPRECATED; +struct gg_http *gg_change_passwd3(uin_t uin, const char *passwd, const char *newpasswd, const char *qa, int async) GG_DEPRECATED; struct gg_change_info_request { char *first_name; @@ -1245,70 +1259,67 @@ int born; int gender; char *city; -}; +} /* GG_DEPRECATED */; -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); -void gg_change_info_request_free(struct gg_change_info_request *r); +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) GG_DEPRECATED; +void gg_change_info_request_free(struct gg_change_info_request *r) GG_DEPRECATED; -struct gg_http *gg_change_info(uin_t uin, const char *passwd, const struct gg_change_info_request *request, int async); +struct gg_http *gg_change_info(uin_t uin, const char *passwd, const struct gg_change_info_request *request, int async) GG_DEPRECATED; #define gg_change_pubdir_watch_fd gg_pubdir_watch_fd #define gg_change_pubdir_free gg_pubdir_free #define gg_free_change_pubdir gg_pubdir_free -struct gg_http *gg_userlist_get(uin_t uin, const char *password, int async); -int gg_userlist_get_watch_fd(struct gg_http *f); -void gg_userlist_get_free(struct gg_http *f); +struct gg_http *gg_userlist_get(uin_t uin, const char *password, int async) GG_DEPRECATED; +int gg_userlist_get_watch_fd(struct gg_http *f) GG_DEPRECATED; +void gg_userlist_get_free(struct gg_http *f) GG_DEPRECATED; -struct gg_http *gg_userlist_put(uin_t uin, const char *password, const char *contacts, int async); -int gg_userlist_put_watch_fd(struct gg_http *f); -void gg_userlist_put_free(struct gg_http *f); +struct gg_http *gg_userlist_put(uin_t uin, const char *password, const char *contacts, int async) GG_DEPRECATED; +int gg_userlist_put_watch_fd(struct gg_http *f) GG_DEPRECATED; +void gg_userlist_put_free(struct gg_http *f) GG_DEPRECATED; -struct gg_http *gg_userlist_remove(uin_t uin, const char *password, int async); -int gg_userlist_remove_watch_fd(struct gg_http *f); -void gg_userlist_remove_free(struct gg_http *f); +struct gg_http *gg_userlist_remove(uin_t uin, const char *password, int async) GG_DEPRECATED; +int gg_userlist_remove_watch_fd(struct gg_http *f) GG_DEPRECATED; +void gg_userlist_remove_free(struct gg_http *f) GG_DEPRECATED; +int gg_pubdir50_handle_reply(struct gg_event *e, const char *packet, int length) GG_DEPRECATED; + /** \endcond */ -int gg_pubdir50_handle_reply(struct gg_event *e, const char *packet, int length); +int gg_file_hash_sha1(int fd, uint8_t *result) GG_DEPRECATED; -int gg_file_hash_sha1(int fd, uint8_t *result); - -#ifdef _WIN32 -int gg_thread_socket(int thread_id, int socket); -#endif - #ifdef __GNUC__ -char *gg_saprintf(const char *format, ...) __attribute__ ((format (printf, 1, 2))); +char *gg_saprintf(const char *format, ...) __attribute__ ((format (printf, 1, 2))) GG_DEPRECATED; #else -char *gg_saprintf(const char *format, ...); +char *gg_saprintf(const char *format, ...) GG_DEPRECATED; #endif -char *gg_vsaprintf(const char *format, va_list ap); +char *gg_vsaprintf(const char *format, va_list ap) GG_DEPRECATED; #define gg_alloc_sprintf gg_saprintf -char *gg_get_line(char **ptr); +char *gg_get_line(char **ptr) GG_DEPRECATED; -int gg_connect(void *addr, int port, int async); -char *gg_read_line(int sock, char *buf, int length); -void gg_chomp(char *line); -char *gg_urlencode(const char *str); -int gg_http_hash(const char *format, ...); -void gg_http_free_fields(struct gg_http *h); -int gg_read(struct gg_session *sess, char *buf, int length); -int gg_write(struct gg_session *sess, const char *buf, int length); -void *gg_recv_packet(struct gg_session *sess); -int gg_send_packet(struct gg_session *sess, int type, ...); -unsigned int gg_login_hash(const unsigned char *password, unsigned int seed); -void gg_login_hash_sha1(const char *password, uint32_t seed, uint8_t *result); +int gg_connect(void *addr, int port, int async) GG_DEPRECATED; +struct in_addr *gg_gethostbyname(const char *hostname) GG_DEPRECATED; +char *gg_read_line(int sock, char *buf, int length) GG_DEPRECATED; +void gg_chomp(char *line) GG_DEPRECATED; +char *gg_urlencode(const char *str) GG_DEPRECATED; +int gg_http_hash(const char *format, ...) GG_DEPRECATED; +void gg_http_free_fields(struct gg_http *h) GG_DEPRECATED; +int gg_read(struct gg_session *sess, char *buf, int length) GG_DEPRECATED; +int gg_write(struct gg_session *sess, const char *buf, int length) GG_DEPRECATED; +void *gg_recv_packet(struct gg_session *sess) GG_DEPRECATED; +int gg_send_packet(struct gg_session *sess, int type, ...) GG_DEPRECATED; +unsigned int gg_login_hash(const unsigned char *password, unsigned int seed) GG_DEPRECATED; +void gg_login_hash_sha1(const char *password, uint32_t seed, uint8_t *result) GG_DEPRECATED; uint32_t gg_fix32(uint32_t x); uint16_t gg_fix16(uint16_t x); #define fix16 gg_fix16 #define fix32 gg_fix32 -char *gg_proxy_auth(void); -char *gg_base64_encode(const char *buf); -char *gg_base64_decode(const char *buf); -int gg_image_queue_remove(struct gg_session *s, struct gg_image_queue *q, int freeq); +char *gg_proxy_auth(void) GG_DEPRECATED; +char *gg_base64_encode(const char *buf) GG_DEPRECATED; +char *gg_base64_decode(const char *buf) GG_DEPRECATED; +int gg_image_queue_remove(struct gg_session *s, struct gg_image_queue *q, int freeq) GG_DEPRECATED; /** * Kolejka odbieranych obrazk?w. @@ -1322,13 +1333,13 @@ uint32_t done; /**< Rozmiar odebranych danych */ struct gg_image_queue *next; /**< Kolejny element listy */ -}; +} GG_DEPRECATED; -int gg_dcc7_handle_id(struct gg_session *sess, struct gg_event *e, void *payload, int len); -int gg_dcc7_handle_new(struct gg_session *sess, struct gg_event *e, void *payload, int len); -int gg_dcc7_handle_info(struct gg_session *sess, struct gg_event *e, void *payload, int len); -int gg_dcc7_handle_accept(struct gg_session *sess, struct gg_event *e, void *payload, int len); -int gg_dcc7_handle_reject(struct gg_session *sess, struct gg_event *e, void *payload, int len); +int gg_dcc7_handle_id(struct gg_session *sess, struct gg_event *e, void *payload, int len) GG_DEPRECATED; +int gg_dcc7_handle_new(struct gg_session *sess, struct gg_event *e, void *payload, int len) GG_DEPRECATED; +int gg_dcc7_handle_info(struct gg_session *sess, struct gg_event *e, void *payload, int len) GG_DEPRECATED; +int gg_dcc7_handle_accept(struct gg_session *sess, struct gg_event *e, void *payload, int len) GG_DEPRECATED; +int gg_dcc7_handle_reject(struct gg_session *sess, struct gg_event *e, void *payload, int len) GG_DEPRECATED; #define GG_APPMSG_HOST "appmsg.gadu-gadu.pl" #define GG_APPMSG_PORT 80 @@ -1351,13 +1362,36 @@ #define GG_ERA_OMNIX_MASK 0x04000000 #undef GG_LIBGADU_VERSION -#define GG_FEATURE_STATUS80BETA 0x01 -#define GG_FEATURE_MSG80 0x02 -#define GG_FEATURE_STATUS80 (0x04|GG_FEATURE_STATUS80BETA) -#define GG_FEATURE_DND_FFC 0x30 +#ifndef DOXYGEN -#define GG_FEATURE_ALL (GG_FEATURE_STATUS80BETA|GG_FEATURE_MSG80|GG_FEATURE_STATUS80|GG_FEATURE_DND_FFC) +#define GG_FEATURE_MSG77 0x01 +#define GG_FEATURE_STATUS77 0x02 +#define GG_FEATURE_DND_FFC 0x10 +#define GG_FEATURE_IMAGE_DESCR 0x20 +/* Poni?sze makra zosta?y zachowane dla zgodno?ci API */ +#define GG_FEATURE_MSG80 0 +#define GG_FEATURE_STATUS80 0 +#define GG_FEATURE_STATUS80BETA 0 +#define GG_FEATURE_ALL (GG_FEATURE_DND_FFC | GG_FEATURE_IMAGE_DESCR) + +#else + +/** + * \ingroup login + * + * Flagi opcji protoko?u. + */ +enum { + GG_FEATURE_MSG77, /**< Klient ?yczy sobie otrzymywa? wiadomo?ci zgodnie z protoko?em 7.7 */ + GG_FEATURE_STATUS77, /**< Klient ?yczy sobie otrzymywa? zmiany stanu zgodnie z protoko?em 7.7 */ + GG_FEATURE_DND_FFC, /**< Klient obs?uguje statusy "nie przeszkadza?" i "poGGadaj ze mn?" */ + GG_FEATURE_IMAGE_DESCR, /**< Klient obs?uguje opisy graficzne oraz flag? \c GG_STATUS80_DESCR_MASK */ +}; + + +#endif + #define GG_DEFAULT_DCC_PORT 1550 struct gg_header { @@ -1465,6 +1499,8 @@ #define GG_STATUS_INVISIBLE_DESCR 0x0016 #define GG_STATUS_BLOCKED 0x0006 +#define GG_STATUS_IMAGE_MASK 0x0100 +#define GG_STATUS_DESCR_MASK 0x4000 #define GG_STATUS_FRIENDS_MASK 0x8000 #else @@ -1488,6 +1524,8 @@ GG_STATUS_INVISIBLE, /**< Niewidoczny (tylko w?asny status) */ GG_STATUS_INVISIBLE_DESCR, /**< Niewidoczny z opisem (tylko w?asny status) */ GG_STATUS_BLOCKED, /**< Zablokowany (tylko status innych) */ + GG_STATUS_IMAGE_MASK, /**< Flaga bitowa oznaczaj?ca opis graficzny (tylko je?li wybrano \c GG_FEATURE_IMAGE_DESCR) */ + GG_STATUS_DESCR_MASK, /**< Flaga bitowa oznaczaj?ca status z opisem (tylko je?li wybrano \c GG_FEATURE_IMAGE_DESCR) */ GG_STATUS_FRIENDS_MASK, /**< Flaga bitowa dost?pno?ci tylko dla znajomych */ }; Modified: trunk/include/protocol.h =================================================================== --- trunk/include/protocol.h 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/include/protocol.h 2010-03-09 22:24:51 UTC (rev 927) @@ -31,6 +31,13 @@ #define GG_LOGIN80 0x0031 +#undef GG_FEATURE_STATUS80BETA +#undef GG_FEATURE_MSG80 +#undef GG_FEATURE_STATUS80 +#define GG_FEATURE_STATUS80BETA 0x01 +#define GG_FEATURE_MSG80 0x02 +#define GG_FEATURE_STATUS80 0x05 + #define GG8_LANG "pl" #define GG8_VERSION "Gadu-Gadu Client Build 8.0.0.8731" Modified: trunk/include/resolver.h =================================================================== --- trunk/include/resolver.h 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/include/resolver.h 2010-03-09 22:24:51 UTC (rev 927) @@ -23,6 +23,6 @@ #include -int gg_gethostbyname(const char *hostname, struct in_addr *result, int pthread); +int gg_gethostbyname_real(const char *hostname, struct in_addr *result, int pthread); #endif /* LIBGADU_RESOLVER_H */ Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/src/Makefile.am 2010-03-09 22:24:51 UTC (rev 927) @@ -1,4 +1,5 @@ lib_LTLIBRARIES = libgadu.la libgadu_la_SOURCES = common.c dcc.c dcc7.c events.c http.c obsolete.c pubdir.c pubdir50.c libgadu.c sha1.c resolver.c -libgadu_la_CFLAGS = -I$(top_srcdir) -I$(top_srcdir)/include -libgadu_la_LDFLAGS = -version-number 3:10 +libgadu_la_CFLAGS = -I$(top_srcdir) -I$(top_srcdir)/include -DGG_IGNORE_DEPRECATED +libgadu_la_LDFLAGS = -version-number 3:10 -export-symbols libgadu.sym +EXTRA_DIST = libgadu.sym Modified: trunk/src/common.c =================================================================== --- trunk/src/common.c 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/src/common.c 2010-03-09 22:24:51 UTC (rev 927) @@ -105,7 +105,7 @@ /** - * Przekazuje informacj? odpluskawiania. + * \internal Przekazuje informacj? odpluskawiania. * * \param level Poziom wiadomo?ci * \param format Format wiadomo?ci (zgodny z \c printf) @@ -123,7 +123,7 @@ } /** - * Przekazuje informacj? odpluskwiania zwi?zan? z sesj?. + * \internal Przekazuje informacj? odpluskwiania zwi?zan? z sesj?. * * \param sess Struktura sesji * \param level Poziom wiadomo?ci @@ -144,7 +144,7 @@ #endif /** - * Odpowiednik funkcji \c vsprintf alokuj?cy miejsce na wynik. + * \internal Odpowiednik funkcji \c vsprintf alokuj?cy miejsce na wynik. * * Funkcja korzysta z funkcji \c vsnprintf, sprawdzaj?c czy dost?pna funkcja * systemowa jest zgodna ze standardem C99 czy wcze?niejszymi. @@ -222,7 +222,7 @@ } /** - * Odpowiednik funkcji \c sprintf alokuj?cy miejsce na wynik. + * \internal Odpowiednik funkcji \c sprintf alokuj?cy miejsce na wynik. * * Funkcja korzysta z funkcji \c vsnprintf, sprawdzaj?c czy dost?pna funkcja * systemowa jest zgodna ze standardem C99 czy wcze?niejszymi. @@ -325,7 +325,7 @@ } /** - * Nawi?zuje po??czenie TCP. + * \internal Nawi?zuje po??czenie TCP. * * \param addr Wska?nik na struktur? \c in_addr z adresem serwera * \param port Port serwera @@ -399,7 +399,7 @@ } /** - * Usuwa znaki ko?ca linii. + * \internal Usuwa znaki ko?ca linii. * * Funkcja dzia?a bezpo?rednio na buforze. * @@ -423,7 +423,7 @@ } /** - * Koduje ci?g znak?w do postacji adresu HTTP. + * \internal Koduje ci?g znak?w do postacji adresu HTTP. * * Zamienia znaki niedrukowalne, spoza ASCII i maj?ce specjalne znaczenie * dla protoko?u HTTP na encje postaci \c %XX, gdzie \c XX jest szesnastkow? @@ -597,7 +597,7 @@ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; /** - * Koduje ci?g znak?w do base64. + * \internal Koduje ci?g znak?w do base64. * * Wynik funkcji nale?y zwolni? za pomoc? \c free. * @@ -656,7 +656,7 @@ } /** - * Dekoduje ci?g znak?w zapisany w base64. + * \internal Dekoduje ci?g znak?w zapisany w base64. * * Wynik funkcji nale?y zwolni? za pomoc? \c free. * Modified: trunk/src/dcc7.c =================================================================== --- trunk/src/dcc7.c 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/src/dcc7.c 2010-03-09 22:24:51 UTC (rev 927) @@ -726,6 +726,7 @@ e->event.dcc7_accept.remote_port = dcc->remote_port; } else { e->type = GG_EVENT_DCC7_PENDING; + e->event.dcc7_pending.dcc7 = dcc; } if (gg_dcc7_connect(sess, dcc) == -1) { @@ -999,6 +1000,7 @@ if (gg_dcc7_reverse_connect(dcc) != -1) { e->type = GG_EVENT_DCC7_PENDING; + e->event.dcc7_pending.dcc7 = dcc; } else { e->type = GG_EVENT_DCC7_ERROR; e->event.dcc_error = GG_ERROR_DCC7_NET; Modified: trunk/src/events.c =================================================================== --- trunk/src/events.c 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/src/events.c 2010-03-09 22:24:51 UTC (rev 927) @@ -44,6 +44,7 @@ #include #include #include +#include #ifdef GG_CONFIG_HAVE_OPENSSL # include # include @@ -482,6 +483,91 @@ } /** + * \internal Zamienia tekst w formacie HTML na czysty tekst. + * + * \param dst Bufor wynikowy (mo?e by? \c NULL) + * \param html Tekst ?r?d?owy + * + * \note Dokleja \c \\0 na ko?cu bufora wynikowego. + * + * \return D?ugo?? tekstu wynikowego bez \c \\0 (nawet je?li \c dst to \c NULL). + */ +static int gg_convert_from_html(char *dst, const char *html) +{ + const char *src, *entity, *tag; + int len, in_tag, in_entity; + + len = 0; + in_tag = 0; + tag = NULL; + in_entity = 0; + entity = NULL; + + for (src = html; *src != 0; src++) { + if (*src == '<') { + tag = src; + in_tag = 1; + continue; + } + + if (in_tag && (*src == '>')) { + if (strncmp(tag, "event.msg.time = gg_fix32(r->time); e->event.msg.seq = gg_fix32(r->seq); - if (sess->encoding == GG_ENCODING_CP1250) + if (sess->encoding == GG_ENCODING_CP1250) { e->event.msg.message = (unsigned char*) strdup(packet + offset_plain); - else - e->event.msg.message = (unsigned char*) gg_cp_to_utf8(packet + offset_plain); + } else { + if (offset_plain > sizeof(struct gg_recv_msg80)) { + int len; + len = gg_convert_from_html(NULL, packet + sizeof(struct gg_recv_msg80)); + + e->event.msg.message = malloc(len + 1); + + if (e->event.msg.message == NULL) + goto fail; + + gg_convert_from_html((char*) e->event.msg.message, packet + sizeof(struct gg_recv_msg80)); + } else { + e->event.msg.message = (unsigned char*) gg_cp_to_utf8(packet + offset_plain); + } + } + if (offset_plain > sizeof(struct gg_recv_msg80)) { if (sess->encoding == GG_ENCODING_UTF8) e->event.msg.xhtml_message = strdup(packet + sizeof(struct gg_recv_msg80)); else e->event.msg.xhtml_message = gg_utf8_to_cp(packet + sizeof(struct gg_recv_msg80)); - } else + } else { e->event.msg.xhtml_message = NULL; + } if (offset_attr != 0) { switch (gg_handle_recv_msg_options(sess, e, gg_fix32(r->sender), packet + offset_attr, packet + h->length)) { @@ -1016,7 +1117,7 @@ descr_len = gg_fix32(s->descr_len); - if (h->length-sizeof(*s) >= descr_len) { + if (descr_len > 0 && h->length-sizeof(*s) >= descr_len) { char *buf = malloc(descr_len + 1); if (buf) { @@ -1172,7 +1273,7 @@ case GG_PUBDIR50_REPLY: { gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd_connected() received pubdir/search reply\n"); - if (gg_pubdir50_handle_reply(e, p, h->length) == -1) + if (gg_pubdir50_handle_reply_sess(sess, e, p, h->length) == -1) goto fail; break; } @@ -1856,17 +1957,11 @@ struct gg_welcome *w; unsigned char *password = (unsigned char*) sess->password; int ret; - - int login_dunno2; uint8_t login_hash[64]; gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() GG_STATE_READING_KEY\n"); memset(login_hash, 0, sizeof(login_hash)); - if (sess->protocol_version >= 0x2d) - login_dunno2 = 0x64; - else - login_dunno2 = 0xbe; /* XXX bardzo, bardzo, bardzo g?upi pomys? na pozbycie * si? tekstu wrzucanego przez proxy. */ @@ -1985,14 +2080,10 @@ l.hash_type = sess->hash_type; memcpy(l.hash, login_hash, sizeof(login_hash)); l.status = gg_fix32(sess->initial_status ? sess->initial_status : GG_STATUS_AVAIL); - l.flags = gg_fix32(0x01); + l.flags = gg_fix32(0x00800001); l.features = gg_fix32(sess->protocol_features); - /* - l.local_ip = (sess->external_addr) ? sess->external_addr : sess->client_addr; - l.local_port = gg_fix16((sess->external_port > 1023) ? sess->external_port : gg_dcc_port); - */ l.image_size = sess->image_size; - l.dunno2 = login_dunno2; + l.dunno2 = 0x64; gg_debug_session(sess, GG_DEBUG_TRAFFIC, "// gg_watch_fd() sending GG_LOGIN80 packet\n"); ret = gg_send_packet(sess, GG_LOGIN80, @@ -2011,7 +2102,7 @@ l.hash_type = sess->hash_type; memcpy(l.hash, login_hash, sizeof(login_hash)); l.image_size = sess->image_size; - l.dunno2 = login_dunno2; + l.dunno2 = 0x64; l.status = gg_fix32(sess->initial_status ? sess->initial_status : GG_STATUS_AVAIL); l.version = gg_fix32(sess->protocol_version | sess->protocol_flags); @@ -2031,7 +2122,7 @@ l.hash_type = sess->hash_type; memcpy(l.hash, login_hash, sizeof(login_hash)); l.image_size = sess->image_size; - l.dunno2 = login_dunno2; + l.dunno2 = 0xbe; l.status = gg_fix32(sess->initial_status ? sess->initial_status : GG_STATUS_AVAIL); l.version = gg_fix32(sess->protocol_version | sess->protocol_flags); Modified: trunk/src/http.c =================================================================== --- trunk/src/http.c 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/src/http.c 2010-03-09 22:24:51 UTC (rev 927) @@ -130,7 +130,7 @@ } else { struct in_addr addr; - if (gg_gethostbyname(hostname, &addr, 0) == -1) { + if (gg_gethostbyname_real(hostname, &addr, 0) == -1) { gg_debug(GG_DEBUG_MISC, "// gg_http_connect() host not found\n"); gg_http_free(h); errno = ENOENT; Modified: trunk/src/libgadu.c =================================================================== --- trunk/src/libgadu.c 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/src/libgadu.c 2010-03-09 22:24:51 UTC (rev 927) @@ -1,7 +1,7 @@ /* $Id$ */ /* - * (C) Copyright 2001-2006 Wojtek Kaniewski + * (C) Copyright 2001-2010 Wojtek Kaniewski * Robert J. Wo?ny * Arkadiusz Mi?kiewicz * Tomasz Chili?ski @@ -182,7 +182,7 @@ } /** - * Zamienia kolejno?? bajt?w w 32-bitowym s?owie. + * \internal Zamienia kolejno?? bajt?w w 32-bitowym s?owie. * * Ze wzgl?du na little-endianowo?? protoko?u Gadu-Gadu, na maszynach * big-endianowych odwraca kolejno?? bajt?w w s?owie. @@ -207,7 +207,7 @@ } /** - * Zamienia kolejno?? bajt?w w 16-bitowym s?owie. + * \internal Zamienia kolejno?? bajt?w w 16-bitowym s?owie. * * Ze wzgl?du na little-endianowo?? protoko?u Gadu-Gadu, na maszynach * big-endianowych zamienia kolejno?? bajt?w w s?owie. @@ -723,7 +723,15 @@ sess->server_addr = p->server_addr; sess->external_port = p->external_port; sess->external_addr = p->external_addr; - sess->protocol_features = p->protocol_features; + + sess->protocol_features = (p->protocol_features & ~(GG_FEATURE_STATUS77 | GG_FEATURE_MSG77)); + + if (!(p->protocol_features & GG_FEATURE_STATUS77)) + sess->protocol_features |= GG_FEATURE_STATUS80; + + if (!(p->protocol_features & GG_FEATURE_MSG77)) + sess->protocol_features |= GG_FEATURE_MSG80; + sess->protocol_version = (p->protocol_version) ? p->protocol_version : GG_DEFAULT_PROTOCOL_VERSION; if (p->era_omnix) @@ -826,7 +834,7 @@ if (!sess->server_addr) { if ((addr.s_addr = inet_addr(hostname)) == INADDR_NONE) { - if (gg_gethostbyname(hostname, &addr, 0) == -1) { + if (gg_gethostbyname_real(hostname, &addr, 0) == -1) { gg_debug(GG_DEBUG_MISC, "// gg_login() host \"%s\" not found\n", hostname); goto fail; } @@ -1035,6 +1043,8 @@ free(sess); } +#ifndef DOXYGEN + /** * \internal Funkcja wysy?aj?ca pakiet zmiany statusu u?ytkownika. * @@ -1114,7 +1124,7 @@ struct gg_new_status80 p; p.status = gg_fix32(status); - p.flags = gg_fix32(0x01); + p.flags = gg_fix32(0x00800001); p.description_size = gg_fix32(descr_len); res = gg_send_packet(sess, packet_type, @@ -1145,6 +1155,8 @@ return res; } +#endif /* DOXYGEN */ + /** * Zmienia status u?ytkownika. * @@ -1218,7 +1230,7 @@ { gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_send_message(%p, %d, %u, %p)\n", sess, msgclass, recipient, message); - return gg_send_message_richtext(sess, msgclass, recipient, message, NULL, 0); + return gg_send_message_confer_richtext(sess, msgclass, 1, &recipient, message, NULL, 0); } /** @@ -1240,48 +1252,9 @@ */ int gg_send_message_richtext(struct gg_session *sess, int msgclass, uin_t recipient, const unsigned char *message, const unsigned char *format, int formatlen) { - struct gg_send_msg s; - char *cp_msg = NULL; - int seq_no; - gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_send_message_richtext(%p, %d, %u, %p, %p, %d);\n", sess, msgclass, recipient, message, format, formatlen); - if (!sess) { - errno = EFAULT; - return -1; - } - - if (sess->state != GG_STATE_CONNECTED) { - errno = ENOTCONN; - return -1; - } - - if (!message) { - errno = EFAULT; - return -1; - } - - if (sess->encoding == GG_ENCODING_UTF8) { - if (!(cp_msg = gg_utf8_to_cp((const char *) message))) - return -1; - - message = (unsigned char *) cp_msg; - } - - if (!sess->seq) - sess->seq = 0x01740000 | (rand() & 0xffff); - seq_no = sess->seq; - sess->seq += (rand() % 0x300) + 0x300; - - s.msgclass = gg_fix32(msgclass); - s.recipient = gg_fix32(recipient); - s.seq = gg_fix32(seq_no); - - if (gg_send_packet(sess, GG_SEND_MSG, &s, sizeof(s), message, strlen((char*) message) + 1, format, formatlen, NULL) == -1) - seq_no = -1; - - free(cp_msg); - return seq_no; + return gg_send_message_confer_richtext(sess, msgclass, 1, &recipient, message, format, formatlen); } /** @@ -1308,6 +1281,206 @@ } /** + * \internal Dodaje tekst na koniec bufora. + * + * \param dst Wska?nik na bufor roboczy + * \param pos Wska?nik na aktualne po?o?enie w buforze roboczym + * \param src Dodawany tekst + * \param len D?ugo?? dodawanego tekstu + */ +static void gg_append(char *dst, int *pos, const void *src, int len) +{ + if (dst != NULL) + memcpy(&dst[*pos], src, len); + + *pos += len; +} + +/** + * \internal Zamienia tekst z formatowaniem Gadu-Gadu na HTML. + * + * \param dst Bufor wynikowy (mo?e by? \c NULL) + * \param src Tekst ?r?d?owy w UTF-8 + * \param format Atrybuty tekstu ?r?d?owego + * \param format_len D?ugo?? bloku atrybut?w tekstu ?r?d?owego + * + * \note Wynikowy tekst nie jest idealnym kodem HTML, poniewa? ma jak + * dok?adniej odzwierciedla? to, co wygenerowa?by oryginalny klient. + * + * \note Dokleja \c \\0 na ko?cu bufora wynikowego. + * + * \return D?ugo?? tekstu wynikowego bez \c \\0 (nawet je?li \c dst to \c NULL). + */ +static int gg_convert_to_html(char *dst, const char *src, const unsigned char *format, int format_len) +{ + const char span_fmt[] = ""; + const int span_len = 75; + const char img_fmt[] = ""; + const int img_len = 29; + int char_pos = 0; + int format_idx = 0; + unsigned char old_attr = 0; + const unsigned char *color = (const unsigned char*) "\x00\x00\x00"; + int len, i; + const unsigned char *format_ = (const unsigned char*) format; + + len = 0; + + /* Nie mamy atrybut?w dla pierwsze znaku, a tekst nie jest pusty, wi?c + * tak czy inaczej trzeba otworzy? . */ + + if (src[0] != 0 && (format_idx + 3 > format_len || (format_[format_idx] | (format_[format_idx + 1] << 8)) != 0)) { + if (dst != NULL) + sprintf(&dst[len], span_fmt, 0, 0, 0); + + len += span_len; + } + + /* P?tla przechodzi te? przez ko?cz?ce \0, ?eby m?c doklei? obrazek + * na ko?cu tekstu. */ + + for (i = 0; ; i++) { + /* Analizuj atrybuty tak d?ugo jak dotycz? aktualnego znaku. */ + for (;;) { + unsigned char attr; + int attr_pos; + + if (format_idx + 3 > format_len) + break; + + attr_pos = format_[format_idx] | (format_[format_idx + 1] << 8); + + if (attr_pos != char_pos) + break; + + attr = format_[format_idx + 2]; + + /* Nie doklejaj atrybut?w na ko?cu, co najwy?ej obrazki. */ + + if (src[i] == 0) + attr &= ~(GG_FONT_BOLD | GG_FONT_ITALIC | GG_FONT_UNDERLINE | GG_FONT_COLOR); + + format_idx += 3; + + if ((attr & (GG_FONT_BOLD | GG_FONT_ITALIC | GG_FONT_UNDERLINE | GG_FONT_COLOR)) != 0) { + if (char_pos != 0) { + if ((old_attr & GG_FONT_UNDERLINE) != 0) + gg_append(dst, &len, "", 4); + + if ((old_attr & GG_FONT_ITALIC) != 0) + gg_append(dst, &len, "", 4); + + if ((old_attr & GG_FONT_BOLD) != 0) + gg_append(dst, &len, "", 4); + + gg_append(dst, &len, "", 7); + } + + if (((attr & GG_FONT_COLOR) != 0) && (format_idx + 3 <= format_len)) { + color = &format_[format_idx]; + format_idx += 3; + } else { + color = (unsigned char*) "\x00\x00\x00"; + } + + if (dst != NULL) + sprintf(&dst[len], span_fmt, color[0], color[1], color[2]); + len += span_len; + } else if (char_pos == 0 && src[0] != 0) { + if (dst != NULL) + sprintf(&dst[len], span_fmt, 0, 0, 0); + len += span_len; + } + + if ((attr & GG_FONT_BOLD) != 0) + gg_append(dst, &len, "", 3); + + if ((attr & GG_FONT_ITALIC) != 0) + gg_append(dst, &len, "", 3); + + if ((attr & GG_FONT_UNDERLINE) != 0) + gg_append(dst, &len, "", 3); + + if (((attr & GG_FONT_IMAGE) != 0) && (format_idx + 10 <= format_len)) { + if (dst != NULL) { + sprintf(&dst[len], img_fmt, + format_[format_idx + 9], + format_[format_idx + 8], + format_[format_idx + 7], + format_[format_idx + 6], + format_[format_idx + 5], + format_[format_idx + 4], + format_[format_idx + 3], + format_[format_idx + 2]); + } + + len += img_len; + format_idx += 10; + } + + old_attr = attr; + } + + /* Doklej znak zachowuj?c htmlowe escapowanie. */ + + switch (src[i]) { + case '&': + gg_append(dst, &len, "&", 5); + break; + case '<': + gg_append(dst, &len, "<", 4); + break; + case '>': + gg_append(dst, &len, ">", 4); + break; + case '\'': + gg_append(dst, &len, "'", 6); + break; + case '\"': + gg_append(dst, &len, """, 6); + break; + case '\n': + gg_append(dst, &len, "
", 4); + break; + case '\r': + case 0: + break; + default: + if (dst != NULL) + dst[len] = src[i]; + len++; + } + + /* Sprawd?, czy bajt nie jest kontynuacj? znaku unikodowego. */ + + if ((src[i] & 0xc0) != 0xc0) + char_pos++; + + if (src[i] == 0) + break; + } + + /* Zamknij tagi. */ + + if ((old_attr & GG_FONT_UNDERLINE) != 0) + gg_append(dst, &len, "
", 4); + + if ((old_attr & GG_FONT_ITALIC) != 0) + gg_append(dst, &len, "
", 4); + + if ((old_attr & GG_FONT_BOLD) != 0) + gg_append(dst, &len, "
", 4); + + if (src[0] != 0) + gg_append(dst, &len, "
", 7); + + if (dst != NULL) + dst[len] = 0; + + return len; +} + +/** * Wysy?a wiadomo?? formatowan? w ramach konferencji. * * Zwraca losowy numer sekwencyjny, kt?ry mo?na zignorowa? albo wykorzysta? @@ -1328,8 +1501,12 @@ 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) { struct gg_send_msg s; + struct gg_send_msg80 s80; struct gg_msg_recipients r; char *cp_msg = NULL; + char *utf_msg = NULL; + char *html_msg = NULL; + int seq_no; int i, j, k; uin_t *recps; @@ -1345,7 +1522,7 @@ return -1; } - if (!message || recipients_count <= 0 || recipients_count > 0xffff || !recipients) { + if (message == NULL || recipients_count <= 0 || recipients_count > 0xffff || (recipients_count != 1 && recipients == NULL)) { errno = EINVAL; return -1; } @@ -1354,44 +1531,117 @@ if (!(cp_msg = gg_utf8_to_cp((const char *) message))) return -1; - message = (const unsigned char *) cp_msg; + utf_msg = (char*) message; + } else { + if (sess->protocol_version >= 0x2d) { + if (!(utf_msg = gg_cp_to_utf8((const char *) message))) + return -1; + } + + cp_msg = (char*) message; } - r.flag = 0x01; - r.count = gg_fix32(recipients_count - 1); + if (sess->protocol_version < 0x2d) { + if (!sess->seq) + sess->seq = 0x01740000 | (rand() & 0xffff); + seq_no = sess->seq; + sess->seq += (rand() % 0x300) + 0x300; - if (!sess->seq) - sess->seq = 0x01740000 | (rand() & 0xffff); - s.seq = gg_fix32(sess->seq); - s.msgclass = gg_fix32(msgclass); + s.msgclass = gg_fix32(msgclass); + s.seq = gg_fix32(seq_no); + } else { + int len; + + // Drobne odchylenie od protoko?u. Je?li wysy?amy kilka + // wiadomo?ci w ci?gu jednej sekundy, zwi?kszamy poprzedni? + // warto??, ?eby ka?da wiadomo?? mia?a unikalny numer. - recps = malloc(sizeof(uin_t) * recipients_count); - if (!recps) - return -1; + seq_no = time(NULL); - sess->seq += (rand() % 0x300) + 0x300; + if (seq_no <= sess->seq) + seq_no = sess->seq + 1; - for (i = 0; i < recipients_count; i++) { + sess->seq = seq_no; - s.recipient = gg_fix32(recipients[i]); + if (format == NULL || formatlen < 3) { + format = (unsigned char*) "\x02\x06\x00\x00\x00\x08\x00\x00\x00"; + formatlen = 9; + } - for (j = 0, k = 0; j < recipients_count; j++) - if (recipients[j] != recipients[i]) { - recps[k] = gg_fix32(recipients[j]); - k++; + len = gg_convert_to_html(NULL, utf_msg, format + 3, formatlen - 3); + + html_msg = malloc(len + 1); + + if (html_msg == NULL) { + seq_no = -1; + goto cleanup; + } + + gg_convert_to_html(html_msg, utf_msg, format + 3, formatlen - 3); + + s80.seq = gg_fix32(seq_no); + s80.msgclass = gg_fix32(msgclass); + s80.offset_plain = gg_fix32(sizeof(s80) + strlen(html_msg) + 1); + s80.offset_attr = gg_fix32(sizeof(s80) + strlen(html_msg) + 1 + strlen(cp_msg) + 1); + } + + if (recipients_count > 1) { + r.flag = 0x01; + r.count = gg_fix32(recipients_count - 1); + + recps = malloc(sizeof(uin_t) * recipients_count); + + if (!recps) { + seq_no = -1; + goto cleanup; + } + + for (i = 0; i < recipients_count; i++) { + for (j = 0, k = 0; j < recipients_count; j++) { + if (recipients[j] != recipients[i]) { + recps[k] = gg_fix32(recipients[j]); + k++; + } } - if (gg_send_packet(sess, GG_SEND_MSG, &s, sizeof(s), message, strlen((char*) message) + 1, &r, sizeof(r), recps, (recipients_count - 1) * sizeof(uin_t), format, formatlen, NULL) == -1) { - free(cp_msg); - free(recps); - return -1; + if (sess->protocol_version < 0x2d) { + s.recipient = gg_fix32(recipients[i]); + + if (gg_send_packet(sess, GG_SEND_MSG, &s, sizeof(s), cp_msg, strlen(cp_msg) + 1, &r, sizeof(r), recps, (recipients_count - 1) * sizeof(uin_t), format, formatlen, NULL) == -1) + seq_no = -1; + } else { + s80.recipient = gg_fix32(recipients[i]); + + if (gg_send_packet(sess, GG_SEND_MSG80, &s80, sizeof(s80), html_msg, strlen(html_msg) + 1, cp_msg, strlen(cp_msg) + 1, &r, sizeof(r), recps, (recipients_count - 1) * sizeof(uin_t), format, formatlen, NULL) == -1) + seq_no = -1; + } } + + free(recps); + } else { + if (sess->protocol_version < 0x2d) { + s.recipient = gg_fix32(recipients[0]); + + if (gg_send_packet(sess, GG_SEND_MSG, &s, sizeof(s), cp_msg, strlen(cp_msg) + 1, format, formatlen, NULL) == -1) + seq_no = -1; + } else { + s80.recipient = gg_fix32(recipients[0]); + + if (gg_send_packet(sess, GG_SEND_MSG80, &s80, sizeof(s80), html_msg, strlen(html_msg) + 1, cp_msg, strlen(cp_msg) + 1, format, formatlen, NULL) == -1) + seq_no = -1; + } } - free(cp_msg); - free(recps); +cleanup: + if (cp_msg != (char*) message) + free(cp_msg); - return gg_fix32(s.seq); + if (utf_msg != (char*) message) + free(utf_msg); + + free(html_msg); + + return seq_no; } /** Copied: trunk/src/libgadu.sym (from rev 884, branches/1.9/src/libgadu.sym) =================================================================== --- trunk/src/libgadu.sym (rev 0) +++ trunk/src/libgadu.sym 2010-03-09 22:24:51 UTC (rev 927) @@ -0,0 +1,151 @@ +gg_add_notify +gg_add_notify_ex +gg_base64_decode +gg_base64_encode +gg_change_info +gg_change_info_request_free +gg_change_info_request_new +gg_change_passwd +gg_change_passwd2 +gg_change_passwd3 +gg_change_passwd4 +gg_change_status +gg_change_status_descr +gg_change_status_descr_time +gg_chomp +gg_connect +gg_crc32 +gg_dcc_ip +gg_dcc_port +gg_dcc7_accept +gg_dcc7_free +gg_dcc7_handle_accept +gg_dcc7_handle_id +gg_dcc7_handle_info +gg_dcc7_handle_new +gg_dcc7_handle_reject +gg_dcc7_reject +gg_dcc7_send_file +gg_dcc7_send_file_fd +gg_dcc7_watch_fd +gg_dcc_fill_file_info +gg_dcc_fill_file_info2 +gg_dcc_free +gg_dcc_get_file +gg_dcc_request +gg_dcc_send_file +gg_dcc_set_type +gg_dcc_socket_create +gg_dcc_voice_chat +gg_dcc_voice_send +gg_dcc_watch_fd +gg_debug +gg_debug_common +gg_debug_file +gg_debug_handler +gg_debug_handler_session +gg_debug_level +gg_debug_session +gg_event_free +gg_file_hash_sha1 +gg_fix16 +gg_fix32 +gg_free_search +gg_free_session +gg_gethostbyname +gg_get_line +gg_global_get_resolver +gg_global_set_custom_resolver +gg_global_set_resolver +gg_http_connect +gg_http_free +gg_http_free_fields +gg_http_get_resolver +gg_http_hash +gg_http_set_custom_resolver +gg_http_set_resolver +gg_http_stop +gg_http_watch_fd +gg_image_queue_remove +gg_image_reply +gg_image_request +gg_libgadu_version +gg_local_ip +gg_login +gg_login_hash +gg_login_hash_sha1 +gg_logoff +gg_notify +gg_notify_ex +gg_ping +gg_proxy_auth +gg_proxy_enabled +gg_proxy_host +gg_proxy_http_only +gg_proxy_password +gg_proxy_port +gg_proxy_username +gg_pubdir50 +gg_pubdir50_add +gg_pubdir50_count +gg_pubdir50_free +gg_pubdir50_get +gg_pubdir50_handle_reply +gg_pubdir50_new +gg_pubdir50_next +gg_pubdir50_seq +gg_pubdir50_seq_set +gg_pubdir50_type +gg_pubdir_free +gg_pubdir_watch_fd +gg_read +gg_read_line +gg_recv_packet +gg_register +gg_register2 +gg_register3 +gg_remind_passwd +gg_remind_passwd2 +gg_remind_passwd3 +gg_remove_notify +gg_remove_notify_ex +gg_resolve +gg_resolve_pthread +gg_resolve_pthread_cleanup +gg_saprintf +gg_search +gg_search_request_free +gg_search_request_mode_0 +gg_search_request_mode_1 +gg_search_request_mode_2 +gg_search_request_mode_3 +gg_search_watch_fd +gg_send_message +gg_send_message_confer +gg_send_message_confer_richtext +gg_send_message_ctcp +gg_send_message_richtext +gg_send_packet +gg_session_get_resolver +gg_session_set_custom_resolver +gg_session_set_resolver +gg_token +gg_token_free +gg_token_watch_fd +gg_unregister +gg_unregister2 +gg_unregister3 +gg_urlencode +gg_userlist_get +gg_userlist_get_free +gg_userlist_get_watch_fd +gg_userlist_put +gg_userlist_put_free +gg_userlist_put_watch_fd +gg_userlist_remove +gg_userlist_remove_free +gg_userlist_remove_watch_fd +gg_userlist_request +gg_vsaprintf +gg_watch_fd +gg_write Modified: trunk/src/obsolete.c =================================================================== --- trunk/src/obsolete.c 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/src/obsolete.c 2010-03-09 22:24:51 UTC (rev 927) @@ -228,4 +228,9 @@ return -1; } +int gg_pubdir50_handle_reply(struct gg_event *e, const char *packet, int length) +{ + return -1; +} + /** \endcond */ Modified: trunk/src/pubdir50.c =================================================================== --- trunk/src/pubdir50.c 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/src/pubdir50.c 2010-03-09 22:24:51 UTC (rev 927) @@ -30,6 +30,7 @@ #include #include "libgadu.h" +#include "internal.h" /** * Tworzy nowe zapytanie katalogu publicznego. @@ -217,8 +218,30 @@ if (req->entries[i].num) continue; - size += strlen(req->entries[i].field) + 1; - size += strlen(req->entries[i].value) + 1; + if (sess->encoding == GG_ENCODING_CP1250) { + size += strlen(req->entries[i].field) + 1; + size += strlen(req->entries[i].value) + 1; + } else { + char *tmp; + + tmp = gg_utf8_to_cp(req->entries[i].field); + + if (tmp == NULL) + return -1; + + size += strlen(tmp) + 1; + + free(tmp); + + tmp = gg_utf8_to_cp(req->entries[i].value); + + if (tmp == NULL) + return -1; + + size += strlen(tmp) + 1; + + free(tmp); + } } if (!(buf = malloc(size))) { @@ -239,11 +262,37 @@ if (req->entries[i].num) continue; - strcpy(p, req->entries[i].field); - p += strlen(p) + 1; + if (sess->encoding == GG_ENCODING_CP1250) { + strcpy(p, req->entries[i].field); + p += strlen(p) + 1; - strcpy(p, req->entries[i].value); - p += strlen(p) + 1; + strcpy(p, req->entries[i].value); + p += strlen(p) + 1; + } else { + char *tmp; + + tmp = gg_utf8_to_cp(req->entries[i].field); + + if (tmp == NULL) { + free(buf); + return -1; + } + + strcpy(p, tmp); + p += strlen(tmp) + 1; + free(tmp); + + tmp = gg_utf8_to_cp(req->entries[i].value); + + if (tmp == NULL) { + free(buf); + return -1; + } + + strcpy(p, tmp); + p += strlen(tmp) + 1; + free(tmp); + } } if (gg_send_packet(sess, GG_PUBDIR50_REQUEST, buf, size, NULL, 0) == -1) @@ -258,22 +307,23 @@ * \internal Analizuje przychodz?cy pakiet odpowiedzi i zapisuje wynik * w strukturze \c gg_event. * + * \param sess Struktura sesji * \param e Struktura zdarzenia * \param packet Pakiet odpowiedzi * \param length D?ugo?? pakietu odpowiedzi * * \return 0 je?li si? powiod?o, -1 w przypadku b??du */ -int gg_pubdir50_handle_reply(struct gg_event *e, const char *packet, int length) +int gg_pubdir50_handle_reply_sess(struct gg_session *sess, struct gg_event *e, const char *packet, int length) { const char *end = packet + length, *p; struct gg_pubdir50_reply *r = (struct gg_pubdir50_reply*) packet; gg_pubdir50_t res; int num = 0; - gg_debug(GG_DEBUG_FUNCTION, "** gg_pubdir50_handle_reply(%p, %p, %d);\n", e, packet, length); + gg_debug(GG_DEBUG_FUNCTION, "** gg_pubdir50_handle_reply_sess(%p, %p, %p, %d);\n", sess, e, packet, length); - if (!e || !packet) { + if (!sess || !e || !packet) { gg_debug(GG_DEBUG_MISC, "// gg_pubdir50_handle_reply() invalid arguments\n"); errno = EFAULT; return -1; @@ -360,8 +410,24 @@ res->next = atoi(value); num--; } else { - if (gg_pubdir50_add_n(res, num, field, value) == -1) - goto failure; + if (sess->encoding == GG_ENCODING_CP1250) { + if (gg_pubdir50_add_n(res, num, field, value) == -1) + goto failure; + } else { + char *tmp; + + tmp = gg_cp_to_utf8(value); + + if (tmp == NULL) + goto failure; + + if (gg_pubdir50_add_n(res, num, field, tmp) == -1) { + free(tmp); + goto failure; + } + + free(tmp); + } } } Modified: trunk/src/resolver.c =================================================================== --- trunk/src/resolver.c 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/src/resolver.c 2010-03-09 22:24:51 UTC (rev 927) @@ -85,7 +85,7 @@ * * \return 0 je?li si? powiod?o, -1 w przypadku b??du */ -int gg_gethostbyname(const char *hostname, struct in_addr *addr, int pthread) +int gg_gethostbyname_real(const char *hostname, struct in_addr *addr, int pthread) { #ifdef GG_CONFIG_HAVE_GETHOSTBYNAME_R char *buf = NULL; @@ -182,6 +182,30 @@ } /** + * \internal Odpowiednik \c gethostbyname zapewniaj?cy wsp??bie?no??. + * + * Je?li dany system dostarcza \c gethostbyname_r, u?ywa si? tej wersji, je?li + * nie, to zwyk?ej \c gethostbyname. + * + * \param hostname Nazwa serwera + * + * \return Zaalokowana struktura \c in_addr lub NULL w przypadku b??du. + */ +struct in_addr *gg_gethostbyname(const char *hostname) +{ + struct in_addr *addr; + + if (!(addr = malloc(sizeof(struct in_addr)))) + return NULL; + + if (gg_gethostbyname_real(hostname, addr, 0)) { + free(addr); + return NULL; + } + return addr; +} + +/** * \internal Struktura przekazywana do w?tku rozwi?zuj?cego nazw?. */ struct gg_resolver_fork_data { @@ -243,10 +267,10 @@ close(pipes[0]); if ((addr.s_addr = inet_addr(hostname)) == INADDR_NONE) { - /* W przypadku b??du gg_gethostbyname() zwr?ci -1 + /* W przypadku b??du gg_gethostbyname_real() zwr?ci -1 * i nie zmieni &addr. Tam jest ju? INADDR_NONE, * wi?c nie musimy robi? nic wi?cej. */ - gg_gethostbyname(hostname, &addr, 0); + gg_gethostbyname_real(hostname, &addr, 0); } if (write(pipes[1], &addr, sizeof(addr)) != sizeof(addr)) @@ -363,10 +387,10 @@ pthread_detach(pthread_self()); if ((addr.s_addr = inet_addr(data->hostname)) == INADDR_NONE) { - /* W przypadku b??du gg_gethostbyname() zwr?ci -1 + /* W przypadku b??du gg_gethostbyname_real() zwr?ci -1 * i nie zmieni &addr. Tam jest ju? INADDR_NONE, * wi?c nie musimy robi? nic wi?cej. */ - gg_gethostbyname(data->hostname, &addr, 1); + gg_gethostbyname_real(data->hostname, &addr, 1); } if (write(data->wfd, &addr, sizeof(addr)) == sizeof(addr)) Modified: trunk/test/Makefile.am =================================================================== --- trunk/test/Makefile.am 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/test/Makefile.am 2010-03-09 22:24:51 UTC (rev 927) @@ -1,3 +1,3 @@ -SUBDIRS = protocol $(OPTIONAL_TESTS) +SUBDIRS = $(OPTIONAL_TESTS) DIST_SUBDIRS = protocol gg8oauth dcc7 resolver connect EXTRA_DIST = config.sample Modified: trunk/test/connect/connect.c =================================================================== --- trunk/test/connect/connect.c 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/test/connect/connect.c 2010-03-09 22:24:51 UTC (rev 927) @@ -516,7 +516,7 @@ len += res; if (strstr(buf, "\r\n\r\n")) { - snprintf(buf, sizeof(buf), "HTTP/1.0 200 OK\r\n\r\n0 %s:%d %s\r\n", LOCALHOST, 8074, LOCALHOST); + snprintf(buf, sizeof(buf), "HTTP/1.0 200 OK\r\n\r\n0 0 %s:%d %s\r\n", LOCALHOST, 8074, LOCALHOST); send(cfds[0], buf, strlen(buf), 0); close(cfds[0]); cfds[0] = -1; @@ -631,7 +631,7 @@ int main(int argc, char **argv) { - int i, test_from, test_to, result[TEST_MAX][2] = { { 0, } }; + int i, test_from = 0, test_to = 0, result[TEST_MAX][2] = { { 0, } }; int exit_code = 0; if (argc == 3) { Modified: trunk/test/dcc7/dcc7.c =================================================================== --- trunk/test/dcc7/dcc7.c 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/test/dcc7/dcc7.c 2010-03-09 22:24:51 UTC (rev 927) @@ -335,6 +335,14 @@ debug("Accepted\n"); break; + case GG_EVENT_DCC7_CONNECTED: + debug("Connected\n"); + break; + + case GG_EVENT_DCC7_PENDING: + debug("Pending ...\n"); + break; + case GG_EVENT_DCC7_REJECT: debug("Rejected\n"); exit(1); Modified: trunk/test/protocol/Makefile.am =================================================================== --- trunk/test/protocol/Makefile.am 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/test/protocol/Makefile.am 2010-03-09 22:24:51 UTC (rev 927) @@ -7,7 +7,7 @@ SUBDIRS = tests script.c: $(wildcard tests/*.scr) compile - ./compile tests/*.scr > script.c + $(PERL) compile tests/*.scr > script.c clean-local: rm -f *.log script.c Modified: trunk/test/protocol/protocol.c =================================================================== --- trunk/test/protocol/protocol.c 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/test/protocol/protocol.c 2010-03-09 22:24:51 UTC (rev 927) @@ -199,7 +199,7 @@ for (i = 0; i < script[state].data_len; i++) { if (((unsigned char) inbuf[i] & script[state].data_mask[i]) != script[state].data[i]) { - error(state, "Received invalid data at offset %d: expected %d, received %d\n", i, script[state].data[i], inbuf[i]); + error(state, "Received invalid data at offset %d: expected 0x%02x, received 0x%02x\n", i, (unsigned char) script[state].data[i], (unsigned char) inbuf[i]); exit(1); } } Modified: trunk/test/protocol/tests/00-login.scr =================================================================== --- trunk/test/protocol/tests/00-login.scr 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/test/protocol/tests/00-login.scr 2010-03-09 22:24:51 UTC (rev 927) @@ -4,7 +4,7 @@ login (uin = 1, password = "") expect connect send (01 00 00 00, auto, 12 34 56 78) -expect data (19 00 00 00, auto, xx*92) +expect data (31 00 00 00, auto, xx*138) send (03 00 00 00, auto) expect event GG_EVENT_CONN_SUCCESS logoff @@ -17,7 +17,7 @@ login (uin = 1, password = "") expect connect send (01 00 00 00, auto, 12 34 56 78) -expect data (19 00 00 00, auto, xx*92) +expect data (31 00 00 00, auto, xx*138) send (14 00 00 00, auto) expect event GG_EVENT_CONN_SUCCESS logoff @@ -30,7 +30,7 @@ login (uin = 1, password = "") expect connect send (01 00 00 00, auto, 12 34 56 78) -expect data (19 00 00 00, auto, xx*92) +expect data (31 00 00 00, auto, xx*138) send (09 00 00 00, auto) expect event GG_EVENT_CONN_FAILED logoff @@ -39,23 +39,22 @@ #----------------------------------------------------------------------------- # Login with parameters #----------------------------------------------------------------------------- -login (uin = 0x123456, password = "ABC", status = GG_STATUS_INVISIBLE_DESCR, status_descr = "Test", protocol_version = 0x2b, has_audio = 1, image_size = 255, hash_type = GG_LOGIN_HASH_GG32, external_addr = 127.0.0.1, external_port = 0x1234) +login (uin = 0x123456, password = "ABC", status = GG_STATUS_INVISIBLE_DESCR, status_descr = "Test", has_audio = 1, image_size = 255, hash_type = GG_LOGIN_HASH_GG32, external_addr = 127.0.0.1, external_port = 0x1234) expect connect send (01 00 00 00, auto, 12 34 56 78) -expect data (19 00 00 00, auto, 56 34 12 00, 01, 09 ad 7d 58 00*60, 16 00 00 00, 2b 00 00 40, 00, 7f 00 00 01, 34 12, 00 00 00 00, 00 00, ff, be, "Test") +expect data (31 00 00 00, auto, 56 34 12 00, "pl", 01, 09 ad 7d 58 00*60, 16 00 00 00, 01 00 80 00, 07 00 00 00, 00 00 00 00, 00 00, 00 00 00 00, 00 00, ff, 64, 21 00 00 00, "Gadu-Gadu", 20, "Client", 20, "Build", 20, "8.0.0.8731", 04 00 00 00, "Test") send (03 00 00 00, auto) expect event GG_EVENT_CONN_SUCCESS logoff expect disconnect #----------------------------------------------------------------------------- -# Simple login +# Simple login before further tests #----------------------------------------------------------------------------- -login (uin = 0x123456, password = "") +login (uin = 0x123456, password = "", encoding = GG_ENCODING_UTF8) expect connect send (01 00 00 00, auto, 12 34 56 78) -expect data (19 00 00 00, auto, 56 34 12 00, 02, 9b ce 73 d0 c8 b9 ec a4 f2 41 54 f3 bd 3b 8a a4 73 b1 c3 a9 00*44, 02 00 00 00, 2a 00 00 00, 00, 00 00 00 00, 00 00, 00 00 00 00, 00 00, 00, be) +expect data (31 00 00 00, auto, xx*138) send (03 00 00 00, auto) expect event GG_EVENT_CONN_SUCCESS - Modified: trunk/test/protocol/tests/10-contacts.scr =================================================================== --- trunk/test/protocol/tests/10-contacts.scr 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/test/protocol/tests/10-contacts.scr 2010-03-09 22:24:51 UTC (rev 927) @@ -217,6 +217,58 @@ expect event GG_EVENT_NONE #----------------------------------------------------------------------------- +# Status change (8.0) +#----------------------------------------------------------------------------- +# TODO: GG_HAS_AUDIO_MASK, GG_ERA_OMNIX_MASK +#----------------------------------------------------------------------------- + +send (36 00 00 00, auto, 11 11 11 00, 14 00 00 00, 00 00 00 00, 7f 00 00 01, 34 12, ff, 00, 00 00 00 00, 00 00 00 00) + +expect event GG_EVENT_STATUS60 ( + status60.uin == 0x00111111 + status60.status == GG_STATUS_INVISIBLE + status60.remote_ip == 127.0.0.1 + status60.remote_port == 0x1234 + status60.version == 0 + status60.image_size == 0xff + status60.descr == NULL +) + +#----------------------------------------------------------------------------- + +send (36 00 00 00, auto, 11 11 11 00, 16 00 00 00, 00 00 00 00, 7f 00 00 01, 34 12, ff, 00, 00 00 00 00, 04 00 00 00, "Test") + +expect event GG_EVENT_STATUS60 ( + status60.uin == 0x00111111 + status60.status == GG_STATUS_INVISIBLE_DESCR + status60.remote_ip == 127.0.0.1 + status60.remote_port == 0x1234 + status60.version == 0 + status60.image_size == 0xff + status60.descr == "Test" +) + +#----------------------------------------------------------------------------- + +send (36 00 00 00, auto, 11 11 11 00, 16 00 00 00, 00 00 00 00, 7f 00 00 01, 34 12, ff, 00, 00 00 00 00, 04 00 00 00, "Test" 00) + +expect event GG_EVENT_STATUS60 ( + status60.uin == 0x00111111 + status60.status == GG_STATUS_INVISIBLE_DESCR + status60.remote_ip == 127.0.0.1 + status60.remote_port == 0x1234 + status60.version == 0 + status60.image_size == 0x000000ff + status60.descr == "Test" +) + +#----------------------------------------------------------------------------- + +send (36 00 00 00, auto, 00*27) + +expect event GG_EVENT_NONE + +#----------------------------------------------------------------------------- # Notify reply (pre-6.0) #----------------------------------------------------------------------------- @@ -587,6 +639,123 @@ ) #----------------------------------------------------------------------------- +# Notify reply (8.0) +#----------------------------------------------------------------------------- + +send (37 00 00 00, auto, 11 11 11 00, 02 00 00 00, 00 00 00 00, 7f 00 00 01, 34 12, ff, 00, 00 00 00 00, 00 00 00 00) + +expect event GG_EVENT_NOTIFY60 ( + notify60[0].uin == 0x00111111 + notify60[0].status == GG_STATUS_AVAIL + notify60[0].remote_ip == 127.0.0.1 + notify60[0].remote_port == 0x1234 + notify60[0].version == 0 + notify60[0].image_size == 0xff + + notify60[1].uin == 0 +) + +#----------------------------------------------------------------------------- + +send (37 00 00 00, auto, 11 11 11 00, 02 00 00 00, 00 00 00 00, 7f 00 00 01, 34 12, ff, 00, 00 00 00 00, 04 00 00 00, "Test") + +expect event GG_EVENT_NOTIFY60 ( + notify60[0].uin == 0x00111111 + notify60[0].status == GG_STATUS_AVAIL + notify60[0].remote_ip == 127.0.0.1 + notify60[0].remote_port == 0x1234 + notify60[0].version == 0 + notify60[0].image_size == 0xff + + notify60[1].uin == 0 +) + +#----------------------------------------------------------------------------- + +send (37 00 00 00, auto, 11 11 11 00, 04 00 00 00, 00 00 00 00, 7f 00 00 01, 34 12, ff, 00, 00 00 00 00, 04 00 00 00, "Test", 22 22 22 00, 03 00 00 00, 00 00 00 00, 7f 00 00 02, 78 56, 64, 00, 00 00 00 00, 00 00 00 00) + +expect event GG_EVENT_NOTIFY60 ( + notify60[0].uin == 0x00111111 + notify60[0].status == GG_STATUS_AVAIL_DESCR + notify60[0].remote_ip == 127.0.0.1 + notify60[0].remote_port == 0x1234 + notify60[0].version == 0 + notify60[0].image_size == 0xff + notify60[0].descr == "Test" + + notify60[1].uin == 0x00222222 + notify60[1].status == GG_STATUS_BUSY + notify60[1].remote_ip == 127.0.0.2 + notify60[1].remote_port == 0x5678 + notify60[1].version == 0 + notify60[1].image_size == 0x64 + + notify60[2].uin == 0 +) + +#----------------------------------------------------------------------------- + +send (37 00 00 00, auto, 11 11 11 00, 04 00 00 00, 00 00 00 00, 7f 00 00 01, 34 12, ff, 00, 00 00 00 00, 05 00 00 00, "Test" 00, 22 22 22 00, 05 00 00 00, 00 00 00 00, 7f 00 00 02, 78 56, 64, 00, 00 00 00 00, 04 00 00 00, "Blah", 33 33 33 00, 06 00 00 00, 00 00 00 00, 7f 00 00 03, 21 43, 00, 00, 00 00 00 00, 00 00 00 00) + +expect event GG_EVENT_NOTIFY60 ( + notify60[0].uin == 0x00111111 + notify60[0].status == GG_STATUS_AVAIL_DESCR + notify60[0].remote_ip == 127.0.0.1 + notify60[0].remote_port == 0x1234 + notify60[0].version == 0 + notify60[0].image_size == 0xff + notify60[0].descr == "Test" + + notify60[1].uin == 0x00222222 + notify60[1].status == GG_STATUS_BUSY_DESCR + notify60[1].remote_ip == 127.0.0.2 + notify60[1].remote_port == 0x5678 + notify60[1].version == 0 + notify60[1].image_size == 0x64 + notify60[1].descr == "Blah" + + notify60[2].uin == 0x00333333 + notify60[2].status == GG_STATUS_BLOCKED + notify60[2].remote_ip == 127.0.0.3 + notify60[2].remote_port == 0x4321 + notify60[2].version == 0 + notify60[2].image_size == 0x00 + + notify60[3].uin == 0 +) + +#----------------------------------------------------------------------------- + +send (37 00 00 00, auto, 11 11 11 00, 04 00 00 00, 00 00 00 00, 7f 00 00 01, 34 12, ff, 00, 00 00 00 00, 20 00 00 00, "Description_too_short") + +expect event GG_EVENT_NOTIFY60 ( + notify60[0].uin == 0x00111111 + notify60[0].status == GG_STATUS_AVAIL_DESCR + notify60[0].remote_ip == 127.0.0.1 + notify60[0].remote_port == 0x1234 + notify60[0].version == 0 + notify60[0].image_size == 0xff + notify60[0].descr == NULL + + notify60[1].uin == 0 +) + +#----------------------------------------------------------------------------- + +send (37 00 00 00, auto, 00*27) + +expect event GG_EVENT_NOTIFY60 ( + notify60[0].uin == 0 +# notify60[0].status == 0 +# notify60[0].remote_ip == 0.0.0.0 +# notify60[0].remote_port == 0 +# notify60[0].version == 0 +# notify60[0].image_size == 0 + +# notify60[1].uin == 0 +) + +#----------------------------------------------------------------------------- # Trigger segfault found by Jakub Zawadzki (pre-1.8.2) #----------------------------------------------------------------------------- Modified: trunk/test/protocol/tests/20-messages.scr =================================================================== --- trunk/test/protocol/tests/20-messages.scr 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/test/protocol/tests/20-messages.scr 2010-03-09 22:24:51 UTC (rev 927) @@ -6,7 +6,7 @@ gg_send_message(session, GG_CLASS_CHAT, 0x123456, (unsigned char*) "Test"); } -expect data (0b 00 00 00, auto, 56 34 12 00, xx xx xx xx, 08 00 00 00, "Test" 00) +expect data (2d 00 00 00, auto, 56 34 12 00, xx xx xx xx, 08 00 00 00, 6b 00 00 00, 70 00 00 00, "Test
" 00, "Test" 00, 02 06 00 00 00 08 00 00 00) #----------------------------------------------------------------------------- # Sending rich-text message @@ -25,7 +25,8 @@ gg_send_message_richtext(session, GG_CLASS_CHAT | GG_CLASS_ACK, 0x123456, (unsigned char*) "Test", (unsigned char*) format, sizeof(format)); } -expect data (0b 00 00 00, auto, 56 34 12 00, xx xx xx xx, 28 00 00 00, "Test" 00, 02, 0f 00, 00 00 01, 01 00 02, 02 00 04, 03 00 08 12 34 56) +#expect data (0b 00 00 00, auto, 56 34 12 00, xx xx xx xx, 28 00 00 00, "Test" 00, 02, 0f 00, 00 00 01, 01 00 02, 02 00 04, 03 00 08 12 34 56) +expect data (2d 00 00 00, auto, 56 34 12 00, xx xx xx xx, 28 00 00 00, 76 01 00 00, 7b 01 00 00, "T
e
s
t" 00, "Test" 00, 02, 0f 00, 00 00 01, 01 00 02, 02 00 04, 03 00 08 12 34 56) #----------------------------------------------------------------------------- # Sending conference message @@ -37,22 +38,23 @@ gg_send_message_confer(session, GG_CLASS_CHAT | GG_CLASS_ACK, 3, contacts, (unsigned char*) "Test"); } -expect data (0b 00 00 00, auto, 11 11 11 00, xx xx xx xx, 28 00 00 00, "Test" 00, 01, 02 00 00 00, 22 22 22 00, 33 33 33 00) -expect data (0b 00 00 00, auto, 22 22 22 00, xx xx xx xx, 28 00 00 00, "Test" 00, 01, 02 00 00 00, 11 11 11 00, 33 33 33 00) -expect data (0b 00 00 00, auto, 33 33 33 00, xx xx xx xx, 28 00 00 00, "Test" 00, 01, 02 00 00 00, 11 11 11 00, 22 22 22 00) +expect data (2d 00 00 00, auto, 11 11 11 00, xx xx xx xx, 28 00 00 00, 6b 00 00 00, 70 00 00 00, "Test" 00, "Test" 00, 01, 02 00 00 00, 22 22 22 00, 33 33 33 00, 02 06 00 00 00 08 00 00 00) +expect data (2d 00 00 00, auto, 22 22 22 00, xx xx xx xx, 28 00 00 00, 6b 00 00 00, 70 00 00 00, "Test" 00, "Test" 00, 01, 02 00 00 00, 11 11 11 00, 33 33 33 00, 02 06 00 00 00 08 00 00 00) +expect data (2d 00 00 00, auto, 33 33 33 00, xx xx xx xx, 28 00 00 00, 6b 00 00 00, 70 00 00 00, "Test" 00, "Test" 00, 01, 02 00 00 00, 11 11 11 00, 22 22 22 00, 02 06 00 00 00 08 00 00 00) #----------------------------------------------------------------------------- # Receiving regular message #----------------------------------------------------------------------------- -send (0a 00 00 00, auto, 11 11 11 11, 22 22 22 22, 33 33 33 33, 44 44 44 44, "Test" 00) +send (2e 00 00 00, auto, 11 11 11 11, 22 22 22 22, 33 33 33 33, 44 44 44 44, 26 00 00 00, 2b 00 00 00, "t??t" 00, "t" ea 9c "t" 00) expect event GG_EVENT_MSG ( msg.sender == 0x11111111 msg.seq == 0x22222222 msg.time == 0x33333333 msg.msgclass == 0x44444444 - msg.message == "Test" + msg.message == "t??t" + msg.xhtml_message == "t??t" msg.recipients_count == 0 msg.recipients == NULL @@ -65,14 +67,15 @@ # Receiving rich-text message #----------------------------------------------------------------------------- -send (0a 00 00 00, auto, 11 11 11 00, 22 22 00 22, 33 00 33 33, 00 44 44 44, "Test" 00, 02, 04 00, 12 34 56 78) +send (2e 00 00 00, auto, 11 11 11 00, 22 22 00 22, 33 00 33 33, 00 44 44 44, 26 00 00 00, 2b 00 00 00, "t??t" 00, "t" ea 9c "t" 00, 02, 04 00, 12 34 56 78) expect event GG_EVENT_MSG ( msg.sender == 0x00111111 msg.seq == 0x22002222 msg.time == 0x33330033 msg.msgclass == 0x44444400 - msg.message == "Test" + msg.message == "t??t" + msg.xhtml_message == "t??t" msg.recipients_count == 0 msg.recipients == NULL @@ -88,14 +91,15 @@ # Receiving conference message #----------------------------------------------------------------------------- -send (0a 00 00 00, auto, 11 11 11 00, 22 22 00 22, 33 00 33 33, 00 44 44 44, "Test" 00, 01, 03 00 00 00, 01 00 00 00, 02 00 00 00, 03 00 00 00) +send (2e 00 00 00, auto, 11 11 11 00, 22 22 00 22, 33 00 33 33, 00 44 44 44, 26 00 00 00, 2b 00 00 00, "t??t" 00, "t" ea 9c "t" 00, 01, 03 00 00 00, 01 00 00 00, 02 00 00 00, 03 00 00 00) expect event GG_EVENT_MSG ( msg.sender == 0x00111111 msg.seq == 0x22002222 msg.time == 0x33330033 msg.msgclass == 0x44444400 - msg.message == "Test" + msg.message == "t??t" + msg.xhtml_message == "t??t" msg.recipients_count == 3 msg.recipients[0] == (int) 1 @@ -110,14 +114,15 @@ # Receiving rich-text conference message #----------------------------------------------------------------------------- -send (0a 00 00 00, auto, 11 11 11 00, 22 22 00 22, 33 00 33 33, 00 44 44 44, "Test" 00, 01, 03 00 00 00, 01 00 00 00, 02 00 00 00, 03 00 00 00, 02, 04 00, 12 34 56 78) +send (2e 00 00 00, auto, 11 11 11 00, 22 22 00 22, 33 00 33 33, 00 44 44 44, 26 00 00 00, 2b 00 00 00, "t??t" 00, "t" ea 9c "t" 00, 01, 03 00 00 00, 01 00 00 00, 02 00 00 00, 03 00 00 00, 02, 04 00, 12 34 56 78) expect event GG_EVENT_MSG ( msg.sender == 0x00111111 msg.seq == 0x22002222 msg.time == 0x33330033 msg.msgclass == 0x44444400 - msg.message == "Test" + msg.message == "t??t" + msg.xhtml_message == "t??t" msg.recipients_count == 3 msg.recipients[0] == (int) 1 @@ -145,12 +150,43 @@ # Receiving malformed messages #----------------------------------------------------------------------------- -send (0a 00 00 00, auto, 11 11 11 11, 22 22 22 22, 33 33 33 33, 44 44 44 44, 31 32 33) +send (2e 00 00 00, auto, 11 11 11 00, 22 22 00 22, 33 00 33 33, 00 44 44 44, 00 00 00 00, 2b 00 00 00, "t??t" 00, "t" ea 9c "t" 00, 02, 06 00, 00 00 08 00 00 00) expect event GG_EVENT_NONE #----------------------------------------------------------------------------- -send (0a 00 00 00, auto, 00 00 00 00, 00 00 00 00, 00 00 00 00, 00 00 00 00, 31 32 33 00) +send (2e 00 00 00, auto, 11 11 11 00, 22 22 00 22, 33 00 33 33, 00 44 44 44, 26 00 00 00, 00 00 00 00, "t??t" 00, "t" ea 9c "t" 00, 02, 06 00, 00 00 08 00 00 00) +expect event GG_EVENT_MSG + +#----------------------------------------------------------------------------- + +send (2e 00 00 00, auto, 11 11 11 00, 22 22 00 22, 33 00 33 33, 00 44 44 44, 10 00 00 00, 2b 00 00 00, "t??t" 00, "t" ea 9c "t" 00, 02, 06 00, 00 00 08 00 00 00) + expect event GG_EVENT_NONE + +#----------------------------------------------------------------------------- + +send (2e 00 00 00, auto, 11 11 11 00, 22 22 00 22, 33 00 33 33, 00 44 44 44, 26 00 00 00, 10 00 00 00, "t??t" 00, "t" ea 9c "t" 00, 02, 06 00, 00 00 08 00 00 00) + +expect event GG_EVENT_MSG + +#----------------------------------------------------------------------------- + +send (2e 00 00 00, auto, 11 11 11 00, 22 22 00 22, 33 00 33 33, 00 44 44 44, ff 00 00 00, 2b 00 00 00, "t??t" 00, "t" ea 9c "t" 00, 02, 06 00, 00 00 08 00 00 00) + +expect event GG_EVENT_NONE + +#----------------------------------------------------------------------------- + +send (2e 00 00 00, auto, 11 11 11 00, 22 22 00 22, 33 00 33 33, 00 44 44 44, 26 00 00 00, ff 00 00 00, "t??t" 00, "t" ea 9c "t" 00, 02, 06 00, 00 00 08 00 00 00) + +expect event GG_EVENT_MSG + +#----------------------------------------------------------------------------- + +send (2e 00 00 00, auto, 00 00 00 00, 00 00 00 00, 00 00 00 00, 00 00 00 00, 00 00 00 00, 00 00 00 00, "test" 00) + +expect event GG_EVENT_NONE + Modified: trunk/test/protocol/tests/30-status.scr =================================================================== --- trunk/test/protocol/tests/30-status.scr 2010-03-09 22:21:16 UTC (rev 926) +++ trunk/test/protocol/tests/30-status.scr 2010-03-09 22:24:51 UTC (rev 927) @@ -6,7 +6,7 @@ gg_change_status(session, GG_STATUS_AVAIL); } -expect data (02 00 00 00, auto, 02 00 00 00) +expect data (38 00 00 00, auto, 02 00 00 00, 01 00 80 00, 00 00 00 00) #----------------------------------------------------------------------------- @@ -14,7 +14,7 @@ gg_change_status_descr(session, GG_STATUS_AVAIL_DESCR, "Test"); } -expect data (02 00 00 00, auto, 04 00 00 00, "Test") +expect data (38 00 00 00, auto, 04 00 00 00, 01 00 80 00, 04 00 00 00, "Test") #----------------------------------------------------------------------------- @@ -22,7 +22,7 @@ gg_change_status(session, GG_STATUS_NOT_AVAIL); } -expect data (02 00 00 00, auto, 01 00 00 00) +expect data (38 00 00 00, auto, 01 00 00 00, 01 00 80 00, 00 00 00 00) #----------------------------------------------------------------------------- @@ -30,7 +30,7 @@ gg_change_status_descr(session, GG_STATUS_NOT_AVAIL_DESCR, "Test"); } -expect data (02 00 00 00, auto, 15 00 00 00, "Test") +expect data (38 00 00 00, auto, 15 00 00 00, 01 00 80 00, 04 00 00 00, "Test") #----------------------------------------------------------------------------- @@ -38,7 +38,7 @@ gg_change_status(session, GG_STATUS_BUSY); } -expect data (02 00 00 00, auto, 03 00 00 00) +expect data (38 00 00 00, auto, 03 00 00 00, 01 00 80 00, 00 00 00 00) #----------------------------------------------------------------------------- @@ -46,7 +46,7 @@ gg_change_status_descr(session, GG_STATUS_BUSY_DESCR, "Test"); } -expect data (02 00 00 00, auto, 05 00 00 00, "Test") +expect data (38 00 00 00, auto, 05 00 00 00, 01 00 80 00, 04 00 00 00, "Test") #----------------------------------------------------------------------------- @@ -54,7 +54,7 @@ gg_change_status(session, GG_STATUS_INVISIBLE); } -expect data (02 00 00 00, auto, 14 00 00 00) +expect data (38 00 00 00, auto, 14 00 00 00, 01 00 80 00, 00 00 00 00) #----------------------------------------------------------------------------- @@ -62,7 +62,7 @@ gg_change_status_descr(session, GG_STATUS_INVISIBLE_DESCR, "Test"); } -expect data (02 00 00 00, auto, 16 00 00 00, "Test") +expect data (38 00 00 00, auto, 16 00 00 00, 01 00 80 00, 04 00 00 00, "Test") #----------------------------------------------------------------------------- @@ -70,13 +70,13 @@ gg_change_status(session, GG_STATUS_AVAIL | GG_STATUS_FRIENDS_MASK); } -expect data (02 00 00 00, auto, 02 80 00 00) +expect data (38 00 00 00, auto, 02 80 00 00, 01 00 80 00, 00 00 00 00) #----------------------------------------------------------------------------- call { - gg_change_status_descr_time(session, GG_STATUS_AVAIL, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", 0x12345678); + gg_change_status_descr_time(session, GG_STATUS_AVAIL, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", 0x12345678); } -expect data (02 00 00 00, 4f 00 00 00, 02 00 00 00, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" 00, 78 56 34 12) +expect data (38 00 00 00, 0b 01 00 00, 02 00 00 00, 01 00 80 00, ff 00 00 00, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA") From libgadu-commit at lists.ziew.org Wed Mar 10 22:44:04 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Wed, 10 Mar 2010 22:44:04 +0100 Subject: [libgadu-commit] r928 - trunk/docs Message-ID: <20100310214405.0D71F17B44@toxygen.net> Author: wojtekka Date: 2010-03-10 22:44:04 +0100 (Wed, 10 Mar 2010) New Revision: 928 Modified: trunk/docs/changelog.dox trunk/docs/events.dox Log: Aktualizacja dokumentacji. Modified: trunk/docs/changelog.dox =================================================================== --- trunk/docs/changelog.dox 2010-03-09 22:24:51 UTC (rev 927) +++ trunk/docs/changelog.dox 2010-03-10 21:44:04 UTC (rev 928) @@ -19,6 +19,8 @@ - Aplikacja mo?e sama wybra? spos?b rozwi?zywania nazw serwer?w — przy u?yciu procesu, w?tku lub we w?asny spos?b. Mo?na to zrobi? za pomoc? pola \c resolver_type struktury \c gg_login_params dla proces?w i w?tk?w, lub globalnie za pomoc? funkcji \ref gg_global_set_resolver czy \ref gg_global_set_custom_resolver. \ref build-resolver "Szczeg??y." +- Opisy zdarzenia \c GG_EVENT_DCC7_PENDING i \c GG_EVENT_DCC7_DONE zawiera wska?niki do struktur po??cze?, kt?rych dotycz?. + \section changelog-1_8_0 libgadu 1.8.0 - Po??czenia bezpo?rednie Gadu-Gadu 7.x. \ref dcc7 "Szczeg??y." Modified: trunk/docs/events.dox =================================================================== --- trunk/docs/events.dox 2010-03-09 22:24:51 UTC (rev 927) +++ trunk/docs/events.dox 2010-03-10 21:44:04 UTC (rev 928) @@ -218,6 +218,12 @@ \copydoc gg_event_t::GG_EVENT_DISCONNECT +\c GG_EVENT_DISCONNECT_ACK +- +- +\copydoc gg_event_t::GG_EVENT_DISCONNECT_ACK + + Wiadomo?ci @@ -335,6 +341,24 @@ \copydoc gg_event_t::GG_EVENT_DCC7_REJECT +\c GG_EVENT_DCC7_PENDING +\c event.dcc7_pending +\c gg_event_dcc7_pending +\copydoc gg_event_t::GG_EVENT_DCC7_PENDING + + +\c GG_EVENT_DCC7_CONNECTED +\c event.dcc7_connected +\c gg_event_dcc7_connected +\copydoc gg_event_t::GG_EVENT_DCC7_CONNECTED + + +\c GG_EVENT_DCC7_DONE +\c event.dcc7_connected +\c gg_event_dcc7_connected +\copydoc gg_event_t::GG_EVENT_DCC7_DONE + + \c GG_EVENT_DCC7_ERROR \c event.dcc7_error \ref gg_error_t "\c gg_error_t" From libgadu-commit at lists.ziew.org Wed Mar 10 22:44:31 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Wed, 10 Mar 2010 22:44:31 +0100 Subject: [libgadu-commit] r929 - in trunk: include src Message-ID: <20100310214431.B3C7317B44@toxygen.net> Author: wojtekka Date: 2010-03-10 22:44:31 +0100 (Wed, 10 Mar 2010) New Revision: 929 Modified: trunk/include/libgadu.h.in trunk/src/dcc7.c Log: Przekazywanie struktury po??czenia w GG_EVENT_DCC7_DONE. Modified: trunk/include/libgadu.h.in =================================================================== --- trunk/include/libgadu.h.in 2010-03-10 21:44:04 UTC (rev 928) +++ trunk/include/libgadu.h.in 2010-03-10 21:44:31 UTC (rev 929) @@ -860,7 +860,6 @@ */ struct gg_event_dcc7_connected { struct gg_dcc7 *dcc7; /**< Struktura po??czenia */ - // XXX czy co? si? przyda? }; /** @@ -889,6 +888,13 @@ }; /** + * Opis zdarzenia \c GG_EVENT_DCC7_DONE. + */ +struct gg_event_dcc7_done { + struct gg_dcc7 *dcc7; /**< Struktura po??czenia */ +}; + +/** * Unia wszystkich zdarze? zwracanych przez funkcje \c gg_watch_fd(), * \c gg_dcc_watch_fd() i \c gg_dcc7_watch_fd(). * @@ -917,6 +923,7 @@ struct gg_event_dcc7_pending dcc7_pending; /**< Trwa pr?ba po??czenia bezpo?redniego (\c GG_EVENT_DCC7_PENDING) */ struct gg_event_dcc7_reject dcc7_reject; /**< Odrzucono po??czenia bezpo?redniego (\c GG_EVENT_DCC7_REJECT) */ struct gg_event_dcc7_accept dcc7_accept; /**< Zaakceptowano po??czenie bezpo?rednie (\c GG_EVENT_DCC7_ACCEPT) */ + struct gg_event_dcc7_done dcc7_done; /**< Zako?czono po??czenie bezpo?rednie (\c GG_EVENT_DCC7_DONE) */ }; /** Modified: trunk/src/dcc7.c =================================================================== --- trunk/src/dcc7.c 2010-03-10 21:44:04 UTC (rev 928) +++ trunk/src/dcc7.c 2010-03-10 21:44:31 UTC (rev 929) @@ -1087,6 +1087,7 @@ if (dcc->offset >= dcc->size) { gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() offset >= size, finished\n"); e->type = GG_EVENT_DCC7_DONE; + e->event.dcc7_done.dcc7 = dcc; return e; } @@ -1119,6 +1120,7 @@ if (dcc->offset >= dcc->size) { gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() finished\n"); e->type = GG_EVENT_DCC7_DONE; + e->event.dcc7_done.dcc7 = dcc; return e; } @@ -1139,6 +1141,7 @@ if (dcc->offset >= dcc->size) { gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() finished\n"); e->type = GG_EVENT_DCC7_DONE; + e->event.dcc7_done.dcc7 = dcc; return e; } @@ -1163,6 +1166,7 @@ if (dcc->offset >= dcc->size) { gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() finished\n"); e->type = GG_EVENT_DCC7_DONE; + e->event.dcc7_done.dcc7 = dcc; return e; } From libgadu-commit at lists.ziew.org Wed Mar 10 22:47:53 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Wed, 10 Mar 2010 22:47:53 +0100 Subject: [libgadu-commit] r930 - trunk/src Message-ID: <20100310214753.7AC6017B44@toxygen.net> Author: wojtekka Date: 2010-03-10 22:47:52 +0100 (Wed, 10 Mar 2010) New Revision: 930 Modified: trunk/src/libgadu.c Log: Usuni?cie bezsensownego warunku zmieniaj?cego stan na niedost?pny, gdy jest ustawiony niedost?pny (Rafa? H.) Dodanie informacji o tym jak zapewni? zachowanie opisu. Modified: trunk/src/libgadu.c =================================================================== --- trunk/src/libgadu.c 2010-03-10 21:44:31 UTC (rev 929) +++ trunk/src/libgadu.c 2010-03-10 21:47:52 UTC (rev 930) @@ -960,7 +960,10 @@ * * \note Je?li w buforze nadawczym po??czenia z serwerem znajduj? si? jeszcze * dane (np. z powodu strat pakiet?w na ??czu), prawdopodobnie zostan? one - * utracone przy zrywaniu po??czenia. + * utracone przy zrywaniu po??czenia. Aby mie? pewno??, ?e opis statusu + * zostanie zachowany, nale?y ustawi? stan \c GG_STATUS_NOT_AVAIL_DESCR + * za pomoc? funkcji \c gg_change_status_descr() i poczeka? na zdarzenie + * \c GG_EVENT_DISCONNECT_ACK. * * \param sess Struktura sesji * @@ -973,9 +976,6 @@ gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_logoff(%p);\n", sess); - if (GG_S_NA(sess->status)) - gg_change_status(sess, GG_STATUS_NOT_AVAIL); - #ifdef GG_CONFIG_HAVE_OPENSSL if (sess->ssl) SSL_shutdown(sess->ssl); From libgadu-commit at lists.ziew.org Thu Mar 11 00:34:02 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Thu, 11 Mar 2010 00:34:02 +0100 Subject: [libgadu-commit] r931 - in trunk: include src Message-ID: <20100310233402.9AA2517B44@toxygen.net> Author: wojtekka Date: 2010-03-11 00:34:02 +0100 (Thu, 11 Mar 2010) New Revision: 931 Modified: trunk/include/internal.h trunk/src/common.c trunk/src/libgadu.c Log: Funkcja odpluskwiania zrzucaj?ca zawarto?? bufora (Bart?omiej Zimo?). Modified: trunk/include/internal.h =================================================================== --- trunk/include/internal.h 2010-03-10 21:47:52 UTC (rev 930) +++ trunk/include/internal.h 2010-03-10 23:34:02 UTC (rev 931) @@ -26,5 +26,6 @@ char *gg_cp_to_utf8(const char *b); char *gg_utf8_to_cp(const char *b); int gg_pubdir50_handle_reply_sess(struct gg_session *sess, struct gg_event *e, const char *packet, int length); +void gg_debug_dump_session(struct gg_session *sess, const char *buf, unsigned int buf_length, const char *format, ...); #endif /* LIBGADU_INTERNAL_H */ Modified: trunk/src/common.c =================================================================== --- trunk/src/common.c 2010-03-10 21:47:52 UTC (rev 930) +++ trunk/src/common.c 2010-03-10 23:34:02 UTC (rev 931) @@ -141,6 +141,33 @@ errno = old_errno; } +/** + * \internal Przekazuje informacj? odpluskwiania zwi?zane z zawarto?ci? pami?ci. + * + * \param sess Struktura sesji + * \param buf Adres w pami?ci + * \param buf_length Ilo?? danych do wy?wietlenia + * \param format Format wiadomo?ci (zgodny z \c printf) + * + * \ingroup debug + */ +void gg_debug_dump_session(struct gg_session *sess, const char *buf, unsigned int buf_length, const char *format, ...) +{ + va_list ap; + + if ((gg_debug_level & GG_DEBUG_DUMP)) { + unsigned int i; + unsigned char *p = buf; + + va_start(ap, format); + gg_debug_common(sess, GG_DEBUG_DUMP, format, ap); + for (i = 0; i < buf_length; ++i) + gg_debug_session(sess, GG_DEBUG_DUMP, " %.2x", (unsigned char) *(p++)); + gg_debug_session(sess, GG_DEBUG_DUMP, "\n"); + va_end(ap); + } +} + #endif /** Modified: trunk/src/libgadu.c =================================================================== --- trunk/src/libgadu.c 2010-03-10 21:47:52 UTC (rev 930) +++ trunk/src/libgadu.c 2010-03-10 23:34:02 UTC (rev 931) @@ -518,15 +518,8 @@ sess->recv_left = 0; - if ((gg_debug_level & GG_DEBUG_DUMP)) { - unsigned int i; + gg_debug_dump_session(sess, buf, sizeof(h) + h.length, "// gg_recv_packet(0x%.2x)", h.type); - gg_debug_session(sess, GG_DEBUG_DUMP, "// gg_recv_packet(%.2x)", h.type); - for (i = 0; i < sizeof(h) + h.length; i++) - gg_debug_session(sess, GG_DEBUG_DUMP, " %.2x", (unsigned char) buf[i]); - gg_debug_session(sess, GG_DEBUG_DUMP, "\n"); - } - return buf; } @@ -593,15 +586,8 @@ h->type = gg_fix32(type); h->length = gg_fix32(tmp_length - sizeof(struct gg_header)); - if ((gg_debug_level & GG_DEBUG_DUMP)) { - unsigned int i; + gg_debug_dump_session(sess, tmp, tmp_length, "// gg_send_packet(0x%.2x)", gg_fix32(h->type)); - gg_debug_session(sess, GG_DEBUG_DUMP, "// gg_send_packet(0x%.2x)", gg_fix32(h->type)); - for (i = 0; i < tmp_length; ++i) - gg_debug_session(sess, GG_DEBUG_DUMP, " %.2x", (unsigned char) tmp[i]); - gg_debug_session(sess, GG_DEBUG_DUMP, "\n"); - } - res = gg_write(sess, tmp, tmp_length); free(tmp); @@ -677,6 +663,8 @@ struct gg_session *sess = NULL; char *hostname; int port; + char *relay_hostname; + struct in_addr relay_addr; if (!p) { gg_debug(GG_DEBUG_FUNCTION, "** gg_login(%p);\n", p); @@ -723,6 +711,7 @@ sess->server_addr = p->server_addr; sess->external_port = p->external_port; sess->external_addr = p->external_addr; + sess->client_port = p->client_port; sess->protocol_features = (p->protocol_features & ~(GG_FEATURE_STATUS77 | GG_FEATURE_MSG77)); @@ -824,6 +813,14 @@ port = GG_APPMSG_PORT; } + relay_hostname = GG_RELAY_HOST; + if (gg_gethostbyname_real(relay_hostname, &relay_addr, 0) == -1) { + gg_debug(GG_DEBUG_MISC, "// gg_login() relay host \"%s\" not found\n", relay_hostname); + sess->relay_addr = INADDR_NONE; + } + else + sess->relay_addr = relay_addr.s_addr; + if (p->hash_type) sess->hash_type = p->hash_type; else From libgadu-commit at lists.ziew.org Thu Mar 11 18:57:53 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Thu, 11 Mar 2010 18:57:53 +0100 Subject: [libgadu-commit] r932 - trunk/src Message-ID: <20100311175753.774FA17B44@toxygen.net> Author: wojtekka Date: 2010-03-11 18:57:52 +0100 (Thu, 11 Mar 2010) New Revision: 932 Modified: trunk/src/libgadu.c Log: Cofni?cie nadmiarowych zmian z r931 (Wiechu) Modified: trunk/src/libgadu.c =================================================================== --- trunk/src/libgadu.c 2010-03-10 23:34:02 UTC (rev 931) +++ trunk/src/libgadu.c 2010-03-11 17:57:52 UTC (rev 932) @@ -663,8 +663,6 @@ struct gg_session *sess = NULL; char *hostname; int port; - char *relay_hostname; - struct in_addr relay_addr; if (!p) { gg_debug(GG_DEBUG_FUNCTION, "** gg_login(%p);\n", p); @@ -711,7 +709,6 @@ sess->server_addr = p->server_addr; sess->external_port = p->external_port; sess->external_addr = p->external_addr; - sess->client_port = p->client_port; sess->protocol_features = (p->protocol_features & ~(GG_FEATURE_STATUS77 | GG_FEATURE_MSG77)); @@ -813,14 +810,6 @@ port = GG_APPMSG_PORT; } - relay_hostname = GG_RELAY_HOST; - if (gg_gethostbyname_real(relay_hostname, &relay_addr, 0) == -1) { - gg_debug(GG_DEBUG_MISC, "// gg_login() relay host \"%s\" not found\n", relay_hostname); - sess->relay_addr = INADDR_NONE; - } - else - sess->relay_addr = relay_addr.s_addr; - if (p->hash_type) sess->hash_type = p->hash_type; else From libgadu-commit at lists.ziew.org Thu Mar 11 19:04:17 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Thu, 11 Mar 2010 19:04:17 +0100 Subject: [libgadu-commit] r933 - in branches: . dcc7-relay Message-ID: <20100311180418.21DE917B44@toxygen.net> Author: wojtekka Date: 2010-03-11 19:04:17 +0100 (Thu, 11 Mar 2010) New Revision: 933 Added: branches/dcc7-relay/ Log: Property changes on: branches/dcc7-relay ___________________________________________________________________ Added: svn:ignore + aclocal.m4 autom4te.cache compile confdefs.h config.* configure COPYING depcomp INSTALL install-sh libtool ltconfig ltmain.sh Makefile Makefile.in missing mkinstalldirs stamp* *.tar.gz *.tar.bz2 Added: svn:mergeinfo + /branches/1.9:786-926 From libgadu-commit at lists.ziew.org Thu Mar 11 22:46:38 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Thu, 11 Mar 2010 22:46:38 +0100 Subject: [libgadu-commit] r934 - branches/dcc7-relay/include Message-ID: <20100311214638.D0BD517B44@toxygen.net> Author: wojtekka Date: 2010-03-11 22:46:38 +0100 (Thu, 11 Mar 2010) New Revision: 934 Modified: branches/dcc7-relay/include/protocol.h Log: >From 0e914141883dc7aa01ecb42bca5ef7c093e7e6a0 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zimon Date: Sat, 26 Dec 2009 01:09:20 +0100 Subject: [PATCH] - relay packets defs Signed-off-by: Bartlomiej Zimon --- branches/1.9/include/protocol.h | 41 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 41 insertions(+), 0 deletions(-) Modified: branches/dcc7-relay/include/protocol.h =================================================================== --- branches/dcc7-relay/include/protocol.h 2010-03-11 18:04:17 UTC (rev 933) +++ branches/dcc7-relay/include/protocol.h 2010-03-11 21:46:38 UTC (rev 934) @@ -158,6 +158,47 @@ uint32_t id; /* id tego co potwierdzamy [0x1 - 0x5] */ } GG_PACKED; +#define GG_DCC7_RELAY_TYPE_SERVER 0x01 /** adres serwera, na kt?ry spyta? o proxy **/ +#define GG_DCC7_RELAY_TYPE_PROXY 0x08 /** adresy proxy, na kt?re sie ??czy? **/ + +#define GG_DCC7_RELAY_DUNNO1 0x02 + +#define GG_DCC7_RELAY_REQUEST 0x0a + +struct gg_dcc7_relay_req { + uint32_t magic; /** 0x0a **/ + uint32_t len; /** d?ugo?? ca?ego pakietu **/ + gg_dcc7_id_t id; /** identyfikator po??czenia **/ + uint16_t type; /** typ zapytania **/ + uint16_t dunno1; /** 0x02 **/ +} GG_PACKED; + +#define GG_DCC7_RELAY_REPLY_RCOUNT 0x02 + +#define GG_DCC7_RELAY_REPLY 0x0b + +struct gg_dcc7_relay_reply { + uint32_t magic; /** 0x0b **/ + uint32_t len; /** d?ugo?? ca?ego pakietu **/ + uint32_t rcount; /** ilo?? serwer?w **/ + struct { + uint32_t ip; /** adres ip serwera **/ + uint16_t port; /** port serwera **/ + uint8_t family; /** rodzina adres?w (na ko?cu?!) AF_INET=2 **/ + } proxies[2] GG_PACKED; +} GG_PACKED; + +#define GG_DCC7_WELCOME_SERVER 0xc0debabe + +struct gg_dcc7_welcome_server { + uint32_t magic; /** 0xc0debabe **/ + gg_dcc7_id_t id; /** identyfikator po??czenia **/ +} GG_PACKED; + +struct gg_dcc7_welcome_p2p { + gg_dcc7_id_t id; /** identyfikator po??czenia **/ +} GG_PACKED; + #ifdef _WIN32 #pragma pack(pop) #endif From libgadu-commit at lists.ziew.org Thu Mar 11 22:47:20 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Thu, 11 Mar 2010 22:47:20 +0100 Subject: [libgadu-commit] r935 - branches/dcc7-relay/src Message-ID: <20100311214720.E2B6217B44@toxygen.net> Author: wojtekka Date: 2010-03-11 22:47:20 +0100 (Thu, 11 Mar 2010) New Revision: 935 Modified: branches/dcc7-relay/src/dcc7.c branches/dcc7-relay/src/libgadu.c Log: >From 94581ae322e8ca46e6ffd427de9ee665d29891dd Mon Sep 17 00:00:00 2001 From: Bartlomiej Zimon Date: Sat, 26 Dec 2009 01:13:02 +0100 Subject: [PATCH] - external_addr and external_port used for p2p connection definition client_port is used as local port for p2p this logic needs some rework ASAP Modified: branches/dcc7-relay/src/dcc7.c =================================================================== --- branches/dcc7-relay/src/dcc7.c 2010-03-11 21:46:38 UTC (rev 934) +++ branches/dcc7-relay/src/dcc7.c 2010-03-11 21:47:20 UTC (rev 935) @@ -255,21 +255,36 @@ static int gg_dcc7_listen_and_send_info(struct gg_dcc7 *dcc) { struct gg_dcc7_info pkt; + uint16_t external_port; + uint16_t local_port; gg_debug_dcc(dcc, GG_DEBUG_FUNCTION, "** gg_dcc7_listen_and_send_info(%p)\n", dcc); - // XXX da? mo?liwo?? konfiguracji? - - dcc->local_addr = dcc->sess->client_addr; + if (!dcc->sess->client_port) + local_port = dcc->sess->external_port; + else + local_port = dcc->sess->client_port; - if (gg_dcc7_listen(dcc, 0) == -1) + if (gg_dcc7_listen(dcc, local_port) == -1) return -1; + if (!dcc->sess->external_port) + external_port = dcc->local_port; + else + external_port = dcc->sess->external_port; + + if (!dcc->sess->external_addr) + dcc->local_addr = dcc->sess->client_addr; + else + dcc->local_addr = dcc->sess->external_addr; + + gg_debug_dcc(dcc, GG_DEBUG_MISC, "// dcc7_listen_and_send_info() sending IP address %s and port %d\n", inet_ntoa(*((struct in_addr*) &dcc->local_addr)), external_port); + memset(&pkt, 0, sizeof(pkt)); pkt.uin = gg_fix32(dcc->peer_uin); pkt.type = GG_DCC7_TYPE_P2P; pkt.id = dcc->cid; - snprintf((char*) pkt.info, sizeof(pkt.info), "%s %d", inet_ntoa(*((struct in_addr*) &dcc->local_addr)), dcc->local_port); + snprintf((char*) pkt.info, sizeof(pkt.info), "%s %d", inet_ntoa(*((struct in_addr*) &dcc->local_addr)), external_port); return gg_send_packet(dcc->sess, GG_DCC7_INFO, &pkt, sizeof(pkt), NULL); } Modified: branches/dcc7-relay/src/libgadu.c =================================================================== --- branches/dcc7-relay/src/libgadu.c 2010-03-11 21:46:38 UTC (rev 934) +++ branches/dcc7-relay/src/libgadu.c 2010-03-11 21:47:20 UTC (rev 935) @@ -709,6 +709,7 @@ sess->server_addr = p->server_addr; sess->external_port = p->external_port; sess->external_addr = p->external_addr; + sess->client_port = p->client_port; sess->protocol_features = (p->protocol_features & ~(GG_FEATURE_STATUS77 | GG_FEATURE_MSG77)); From libgadu-commit at lists.ziew.org Thu Mar 11 22:47:50 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Thu, 11 Mar 2010 22:47:50 +0100 Subject: [libgadu-commit] r936 - branches/dcc7-relay/test/dcc7 Message-ID: <20100311214750.D03C217B44@toxygen.net> Author: wojtekka Date: 2010-03-11 22:47:50 +0100 (Thu, 11 Mar 2010) New Revision: 936 Modified: branches/dcc7-relay/test/dcc7/dcc7.c Log: >From 57bb3ca4ce1e9626f12350ab11eaedcfb885d796 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zimon Date: Sat, 26 Dec 2009 01:13:31 +0100 Subject: [PATCH] - updated dcc7 test for use of client_port Signed-off-by: Bartlomiej Zimon --- branches/1.9/test/dcc7/dcc7.c | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-) Modified: branches/dcc7-relay/test/dcc7/dcc7.c =================================================================== --- branches/dcc7-relay/test/dcc7/dcc7.c 2010-03-11 21:47:20 UTC (rev 935) +++ branches/dcc7-relay/test/dcc7/dcc7.c 2010-03-11 21:47:50 UTC (rev 936) @@ -31,7 +31,8 @@ char *config_dir; unsigned int config_size = 1048576; unsigned long config_ip = 0xffffffff; -unsigned int config_port; +unsigned int config_port = 0; +unsigned int config_localport = 0; int test_mode; int connected; @@ -97,6 +98,9 @@ if (!strncmp(buf, "port ", 5)) config_port = atoi(buf + 5); + + if (!strncmp(buf, "localport ", 10)) + config_localport = atoi(buf + 10); } fclose(f); @@ -153,9 +157,10 @@ glp.uin = config_uin; glp.password = config_password; glp.async = 1; -// glp.client_addr = config_ip; -// glp.client_port = config_port; - glp.protocol_version = 0x2a; + glp.external_addr = config_ip; + glp.external_port = config_port; + glp.client_port = config_localport; + glp.protocol_version = 0x2e; gg_dcc_ip = config_ip; From libgadu-commit at lists.ziew.org Thu Mar 11 22:48:14 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Thu, 11 Mar 2010 22:48:14 +0100 Subject: [libgadu-commit] r937 - branches/dcc7-relay/include Message-ID: <20100311214814.9EE2E17B44@toxygen.net> Author: wojtekka Date: 2010-03-11 22:48:14 +0100 (Thu, 11 Mar 2010) New Revision: 937 Modified: branches/dcc7-relay/include/libgadu.h.in Log: >From ffc9ba51e5a3d988702e606c8d86dd168a627974 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zimon Date: Sat, 26 Dec 2009 17:22:11 +0100 Subject: [PATCH] - add relay host definition and relay_addr to gg_session Signed-off-by: Bartlomiej Zimon --- branches/1.9/include/libgadu.h.in | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) Modified: branches/dcc7-relay/include/libgadu.h.in =================================================================== --- branches/dcc7-relay/include/libgadu.h.in 2010-03-11 21:47:50 UTC (rev 936) +++ branches/dcc7-relay/include/libgadu.h.in 2010-03-11 21:48:14 UTC (rev 937) @@ -217,6 +217,8 @@ uint32_t hub_addr; /**< Adres huba po rozwi?zaniu nazwy */ uint32_t server_addr; /**< Adres serwera otrzymany od huba */ + uint32_t relay_addr; /**< Adres relay po rozwi?zaniu nazwy */ + uint32_t client_addr; /**< Adres gniazda dla po??cze? bezpo?rednich do wersji Gadu-Gadu 6.x */ uint16_t client_port; /**< Port gniazda dla po??cze? bezpo?rednich do wersji Gadu-Gadu 6.x */ @@ -1356,6 +1358,8 @@ #define GG_REGISTER_PORT 80 #define GG_REMIND_HOST "retr.gadu-gadu.pl" #define GG_REMIND_PORT 80 +#define GG_RELAY_HOST "relay.gadu-gadu.pl" +#define GG_RELAY_PORT 80 #define GG_DEFAULT_PORT 8074 #define GG_HTTPS_PORT 443 From libgadu-commit at lists.ziew.org Thu Mar 11 22:48:29 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Thu, 11 Mar 2010 22:48:29 +0100 Subject: [libgadu-commit] r938 - branches/dcc7-relay/src Message-ID: <20100311214829.D9F6817B44@toxygen.net> Author: wojtekka Date: 2010-03-11 22:48:29 +0100 (Thu, 11 Mar 2010) New Revision: 938 Modified: branches/dcc7-relay/src/libgadu.c Log: >From b10675abe71ac1c3f8ad82a18a7827845428e47c Mon Sep 17 00:00:00 2001 From: Bartlomiej Zimon Date: Sat, 26 Dec 2009 17:25:11 +0100 Subject: [PATCH] - resolve relay host and set relay_addr with it's IP --- branches/1.9/src/libgadu.c | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-) Modified: branches/dcc7-relay/src/libgadu.c =================================================================== --- branches/dcc7-relay/src/libgadu.c 2010-03-11 21:48:14 UTC (rev 937) +++ branches/dcc7-relay/src/libgadu.c 2010-03-11 21:48:29 UTC (rev 938) @@ -661,7 +661,7 @@ struct gg_session *gg_login(const struct gg_login_params *p) { struct gg_session *sess = NULL; - char *hostname; + char *hostname, relay_hostname; int port; if (!p) { @@ -811,6 +811,15 @@ port = GG_APPMSG_PORT; } + relay_hostname = GG_RELAY_HOST; + struct in_addr relay_addr; + if (gg_gethostbyname_real(relay_hostname, &relay_addr, 0) == -1) { + gg_debug(GG_DEBUG_MISC, "// gg_login() relay host \"%s\" not found\n", relay_hostname); + sess->relay_addr = INADDR_NONE; + } + else + sess->relay_addr = relay_addr.s_addr; + if (p->hash_type) sess->hash_type = p->hash_type; else From libgadu-commit at lists.ziew.org Thu Mar 11 22:48:48 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Thu, 11 Mar 2010 22:48:48 +0100 Subject: [libgadu-commit] r939 - branches/dcc7-relay/include Message-ID: <20100311214848.EAB3B17B44@toxygen.net> Author: wojtekka Date: 2010-03-11 22:48:48 +0100 (Thu, 11 Mar 2010) New Revision: 939 Modified: branches/dcc7-relay/include/libgadu.h.in Log: >From 9cdc242f9805a06423c845c10e0df6affb198f27 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zimon Date: Sun, 27 Dec 2009 00:18:38 +0100 Subject: [PATCH] - move relay_addr at the end of gg_session struct for ABI compa t (thx darkjames) --- branches/1.9/include/libgadu.h.in | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Modified: branches/dcc7-relay/include/libgadu.h.in =================================================================== --- branches/dcc7-relay/include/libgadu.h.in 2010-03-11 21:48:29 UTC (rev 938) +++ branches/dcc7-relay/include/libgadu.h.in 2010-03-11 21:48:48 UTC (rev 939) @@ -217,8 +217,6 @@ uint32_t hub_addr; /**< Adres huba po rozwi?zaniu nazwy */ uint32_t server_addr; /**< Adres serwera otrzymany od huba */ - uint32_t relay_addr; /**< Adres relay po rozwi?zaniu nazwy */ - uint32_t client_addr; /**< Adres gniazda dla po??cze? bezpo?rednich do wersji Gadu-Gadu 6.x */ uint16_t client_port; /**< Port gniazda dla po??cze? bezpo?rednich do wersji Gadu-Gadu 6.x */ @@ -280,6 +278,8 @@ void (*resolver_cleanup)(void **private_data, int force); /**< Funkcja zwalniaj?ca zasoby po rozwi?zaniu nazwy */ int protocol_features; /**< Opcje protoko?u */ + + uint32_t relay_addr; /**< Adres relay po rozwi?zaniu nazwy */ }; /** From libgadu-commit at lists.ziew.org Thu Mar 11 22:49:10 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Thu, 11 Mar 2010 22:49:10 +0100 Subject: [libgadu-commit] r940 - branches/dcc7-relay/include Message-ID: <20100311214910.B497B17B44@toxygen.net> Author: wojtekka Date: 2010-03-11 22:49:10 +0100 (Thu, 11 Mar 2010) New Revision: 940 Modified: branches/dcc7-relay/include/libgadu.h.in Log: >From 50c4f9fda68918cb756fb4cf74d5216c6ddc33f7 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zimon Date: Sun, 27 Dec 2009 00:20:56 +0100 Subject: [PATCH] - add relay session data to gg_dcc7 struct --- branches/1.9/include/libgadu.h.in | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) Modified: branches/dcc7-relay/include/libgadu.h.in =================================================================== --- branches/dcc7-relay/include/libgadu.h.in 2010-03-11 21:48:48 UTC (rev 939) +++ branches/dcc7-relay/include/libgadu.h.in 2010-03-11 21:49:10 UTC (rev 940) @@ -429,6 +429,12 @@ int soft_timeout; /**< Flaga m?wi?ca, ?e po przekroczeniu \c timeout nale?y wywo?a? \c gg_dcc7_watch_fd() */ int seek; /**< Flaga m?wi?ca, ?e mo?na zmienia? po?o?enie w wysy?anym pliku */ + + struct { + uint32_t relay_addr; /**< Adres serwera relay */ + uint16_t relay_port; /**< Port serwera relay */ + uint8_t relay_type; /**< Typ serwera relay */ + } dcc_relays [2]; }; /** From libgadu-commit at lists.ziew.org Thu Mar 11 22:49:58 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Thu, 11 Mar 2010 22:49:58 +0100 Subject: [libgadu-commit] r941 - branches/dcc7-relay/src Message-ID: <20100311214958.C453D17B44@toxygen.net> Author: wojtekka Date: 2010-03-11 22:49:58 +0100 (Thu, 11 Mar 2010) New Revision: 941 Modified: branches/dcc7-relay/src/dcc7.c Log: >From 0c440b07dd7489ba8b4b0f5411546578f265ee84 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zimon Date: Sun, 27 Dec 2009 00:32:20 +0100 Subject: [PATCH] - first implementation of get relay adress - to rewrite and spl it to functions but works nice Signed-off-by: Bartlomiej Zimon --- branches/1.9/src/dcc7.c | 155 +++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 155 insertions(+), 0 deletions(-) Modified: branches/dcc7-relay/src/dcc7.c =================================================================== --- branches/dcc7-relay/src/dcc7.c 2010-03-11 21:49:10 UTC (rev 940) +++ branches/dcc7-relay/src/dcc7.c 2010-03-11 21:49:58 UTC (rev 941) @@ -50,10 +50,14 @@ #include "compat.h" #include "libgadu.h" +#include "protocol.h" +#include "resolver.h" #define gg_debug_dcc(dcc, fmt...) \ gg_debug_session((dcc) ? (dcc)->sess : NULL, fmt) +static int gg_dcc7_get_relay_addr(struct gg_dcc7 *dcc); + /** * \internal Dodaje po??czenie bezpo?rednie do sesji. * @@ -313,7 +317,158 @@ return gg_dcc7_listen_and_send_info(dcc); } +/* +laczymy sie na relay.gadu-gadu.pl:80 z pakietem GG_DCC7_RELAY_REQUEST i typem +ustawionym na GG_DCC7_RELAY_TYPE_SERVER w odpowiedzi dostaniemy adres serwera +na ktory pytac o serwery (dlatego port = 0x0000) pewnie to jest w razie czego. +Nastepnie wysylamy pakiet na ten adres i port 80 z pakietem GG_DCC7_RELAY_REQUEST +oraz typem ustawionym na GG_DCC7_RELAY_TYPE_PROXY dopiero teraz dostajemy faktyczne +adresy na ktore bedziemy sie autoryzowac z pakietem GG_DCC7_WELCOME_SERVER i wysylac plik. +*/ + /** + * \internal Pobiera adres serwera relay + * + * \param dcc Struktura po??czenia + * + * \return 0 je?li si? powiod?o, -1 w przypadku b??du + */ +static int gg_dcc7_get_relay_addr(struct gg_dcc7 *dcc) +{ + struct gg_dcc7_relay_req pkt; + struct gg_dcc7_relay_reply reply_pkt; + struct in_addr relay_addr; + char *relay_hostname; + int fd; + + if (!dcc) { + gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_get_relay() invalid parameters\n"); + return -1; + } + + if (!dcc->sess->relay_addr) { + relay_hostname = GG_RELAY_HOST; + if (gg_gethostbyname_real(relay_hostname, &relay_addr, 0) == -1) { + gg_debug(GG_DEBUG_MISC, "// gg_dcc7_get_relay() relay host \"%s\" not found\n", relay_hostname); + // or set here host 91.197.13.101/102? + return -1; + } + + // update session data + dcc->sess->relay_addr = relay_addr.s_addr; + } + + if ((fd = gg_connect(&dcc->sess->relay_addr, GG_RELAY_PORT, 0)) == -1) { + gg_debug_session(dcc->sess, GG_DEBUG_MISC, "// gg_dcc7_get_relay() connection failed\n"); + return -1; + } + + memset(&pkt, 0, sizeof(pkt)); + pkt.magic = gg_fix32(GG_DCC7_RELAY_REQUEST); + pkt.len = gg_fix32(sizeof(pkt)); + pkt.id = dcc->cid; + pkt.type = gg_fix16(GG_DCC7_RELAY_TYPE_PROXY); + pkt.dunno1 = gg_fix16(GG_DCC7_RELAY_DUNNO1); + + if ((gg_debug_level & GG_DEBUG_DUMP)) { + unsigned int i; + unsigned char *p = &pkt; + + gg_debug_session(dcc->sess, GG_DEBUG_DUMP, "// gg_dcc7_get_relay() send pkt(0x%.2x)", gg_fix32(pkt.magic)); + for (i = 0; i < sizeof(pkt); ++i) + gg_debug_session(dcc->sess, GG_DEBUG_DUMP, " %.2x", (unsigned char) *(p++)); + gg_debug_session(dcc->sess, GG_DEBUG_DUMP, "\n"); + } + + if (write(fd, &pkt, sizeof(pkt)) == -1) + return -1; + + memset(&reply_pkt, 0, sizeof(reply_pkt)); + + int ret = 1; + ret = read(fd, &reply_pkt, sizeof(reply_pkt)); + + close(fd); + + if ((gg_debug_level & GG_DEBUG_DUMP)) { + unsigned int i; + unsigned char *p = &reply_pkt; + + gg_debug_session(dcc->sess, GG_DEBUG_DUMP, "// gg_dcc7_get_relay() read pkt(0x%.2x)", gg_fix32(reply_pkt.magic)); + for (i = 0; i < sizeof(reply_pkt); ++i) + gg_debug_session(dcc->sess, GG_DEBUG_DUMP, " %.2x", (unsigned char) *(p++)); + gg_debug_session(dcc->sess, GG_DEBUG_DUMP, "\n"); + } + + // change query type to relay proxy + pkt.type = gg_fix16(GG_DCC7_RELAY_TYPE_SERVER); + // take first proxy but if server does reply with 0 use this server + if (reply_pkt.magic != 0) + dcc->sess->relay_addr = reply_pkt.ip;//.proxies[0] + + reply_pkt.magic = 0; + int relay_port = GG_RELAY_PORT; + int retries = 6; + while (reply_pkt.magic != gg_fix32(GG_DCC7_RELAY_REPLY) || retries == 0) + { + if ((fd = gg_connect(&dcc->sess->relay_addr, relay_port, 0)) == -1) { + gg_debug_session(dcc->sess, GG_DEBUG_MISC, "// gg_dcc7_get_relay() connection failed\n"); + return -1; + } + + if (relay_port == GG_RELAY_PORT) + relay_port = 443; + else + relay_port = GG_RELAY_PORT; + + if ((gg_debug_level & GG_DEBUG_DUMP)) { + unsigned int i; + unsigned char *p = &pkt; + + gg_debug_session(dcc->sess, GG_DEBUG_DUMP, "// gg_dcc7_get_relay() send pkt(0x%.2x)", gg_fix32(pkt.magic)); + for (i = 0; i < sizeof(pkt); ++i) + gg_debug_session(dcc->sess, GG_DEBUG_DUMP, " %.2x", (unsigned char) *(p++)); + gg_debug_session(dcc->sess, GG_DEBUG_DUMP, "\n"); + } + + if (write(fd, &pkt, sizeof(pkt)) == -1) + return -1; + + memset(&reply_pkt, 0, sizeof(reply_pkt)); + + ret = 1; + ret = read(fd, &reply_pkt, sizeof(reply_pkt)); + + if ((gg_debug_level & GG_DEBUG_DUMP)) { + unsigned int i; + unsigned char *p = &reply_pkt; + + gg_debug_session(dcc->sess, GG_DEBUG_DUMP, "// gg_dcc7_get_relay() read pkt(0x%.2x)", gg_fix32(reply_pkt.magic)); + for (i = 0; i < sizeof(reply_pkt); ++i) + gg_debug_session(dcc->sess, GG_DEBUG_DUMP, " %.2x", (unsigned char) *(p++)); + gg_debug_session(dcc->sess, GG_DEBUG_DUMP, "\n"); + } + close(fd); + retries--; + } + + if (reply_pkt.magic != gg_fix32(GG_DCC7_RELAY_REPLY)) + return -1; + + dcc->dcc_relays[0].relay_addr = reply_pkt.ip; + dcc->dcc_relays[0].relay_port = reply_pkt.port; + dcc->dcc_relays[0].relay_type = reply_pkt.type; + dcc->dcc_relays[1].relay_addr = reply_pkt.ip2; + dcc->dcc_relays[1].relay_port = reply_pkt.port2; + dcc->dcc_relays[1].relay_type = reply_pkt.type2; + + gg_debug_session(dcc->sess, GG_DEBUG_DUMP, "// gg_dcc7_get_relay() found relay proxy: %s:%d,", inet_ntoa(*((struct in_addr*) &dcc->dcc_relays[0].relay_addr)), dcc->dcc_relays[0].relay_port); + gg_debug_session(dcc->sess, GG_DEBUG_DUMP, " %s:%d\n", inet_ntoa(*((struct in_addr*) &dcc->dcc_relays[1].relay_addr)), dcc->dcc_relays[1].relay_port); + + return 0; +} + +/** * \internal Wysy?a do serwera ??danie nadania identyfikatora sesji * * \param sess Struktura sesji From libgadu-commit at lists.ziew.org Thu Mar 11 22:50:20 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Thu, 11 Mar 2010 22:50:20 +0100 Subject: [libgadu-commit] r942 - branches/dcc7-relay/src Message-ID: <20100311215021.153CE17B44@toxygen.net> Author: wojtekka Date: 2010-03-11 22:50:20 +0100 (Thu, 11 Mar 2010) New Revision: 942 Modified: branches/dcc7-relay/src/dcc7.c Log: >From e7837580507a41672056563a38c010f1f620c64a Mon Sep 17 00:00:00 2001 From: Bartlomiej Zimon Date: Mon, 28 Dec 2009 17:15:15 +0100 Subject: [PATCH] - if cant bind on port we want, we send dcc->local_port and ses s->client_addr --- branches/1.9/src/dcc7.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) Modified: branches/dcc7-relay/src/dcc7.c =================================================================== --- branches/dcc7-relay/src/dcc7.c 2010-03-11 21:49:58 UTC (rev 941) +++ branches/dcc7-relay/src/dcc7.c 2010-03-11 21:50:20 UTC (rev 942) @@ -272,12 +272,13 @@ if (gg_dcc7_listen(dcc, local_port) == -1) return -1; - if (!dcc->sess->external_port) + + if (!dcc->sess->external_port || dcc->local_port != local_port) external_port = dcc->local_port; else external_port = dcc->sess->external_port; - if (!dcc->sess->external_addr) + if (!dcc->sess->external_addr || dcc->local_port != local_port) dcc->local_addr = dcc->sess->client_addr; else dcc->local_addr = dcc->sess->external_addr; From libgadu-commit at lists.ziew.org Thu Mar 11 22:50:46 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Thu, 11 Mar 2010 22:50:46 +0100 Subject: [libgadu-commit] r943 - branches/dcc7-relay/include Message-ID: <20100311215046.F2CF617B44@toxygen.net> Author: wojtekka Date: 2010-03-11 22:50:46 +0100 (Thu, 11 Mar 2010) New Revision: 943 Modified: branches/dcc7-relay/include/libgadu.h.in Log: >From c361818cebd78762d5595e465721c73d5fe23296 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zimon Date: Mon, 28 Dec 2009 19:55:41 +0100 Subject: [PATCH] - split info in gg_dcc7_info packet to info and hash strings --- branches/1.9/include/libgadu.h.in | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) Modified: branches/dcc7-relay/include/libgadu.h.in =================================================================== --- branches/dcc7-relay/include/libgadu.h.in 2010-03-11 21:50:20 UTC (rev 942) +++ branches/dcc7-relay/include/libgadu.h.in 2010-03-11 21:50:46 UTC (rev 943) @@ -387,7 +387,8 @@ #define GG_DCC7_HASH_LEN 20 /**< Maksymalny rozmiar skr?tu pliku w po??czeniach bezpo?renich */ #define GG_DCC7_FILENAME_LEN 255 /**< Maksymalny rozmiar nazwy pliku w po??czeniach bezpo?rednich */ -#define GG_DCC7_INFO_LEN 64 /**< Maksymalny rozmiar informacji o po??czeniach bezpo?rednich */ +#define GG_DCC7_INFO_LEN 32 /**< Maksymalny rozmiar informacji o po??czeniach bezpo?rednich */ +#define GG_DCC7_INFO_HASH_LEN 32 /**< Maksymalny rozmiar skr?tu ip informacji o po??czeniach bezpo?rednich */ /** * Po??czenie bezpo?rednie od wersji Gadu-Gadu 7.x. @@ -1996,6 +1997,7 @@ uint32_t type; /* spos?b po??czenia */ gg_dcc7_id_t id; /* identyfikator po??czenia */ char info[GG_DCC7_INFO_LEN]; /* informacje o po??czeniu "ip port" */ + char hash[GG_DCC7_INFO_HASH_LEN];/* skr?t "ip" */ } GG_PACKED; #define GG_DCC7_NEW 0x20 From libgadu-commit at lists.ziew.org Thu Mar 11 22:51:23 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Thu, 11 Mar 2010 22:51:23 +0100 Subject: [libgadu-commit] r944 - branches/dcc7-relay/src Message-ID: <20100311215123.809C717B44@toxygen.net> Author: wojtekka Date: 2010-03-11 22:51:22 +0100 (Thu, 11 Mar 2010) New Revision: 944 Modified: branches/dcc7-relay/src/dcc7.c Log: >From 2370228a8d031257860071c40dff08e19c45e794 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zimon Date: Mon, 28 Dec 2009 19:58:58 +0100 Subject: [PATCH] - fill fake hash in gg_dcc7_info to receive request from server if direct connection is unavailable --- branches/1.9/src/dcc7.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) Modified: branches/dcc7-relay/src/dcc7.c =================================================================== --- branches/dcc7-relay/src/dcc7.c 2010-03-11 21:50:46 UTC (rev 943) +++ branches/dcc7-relay/src/dcc7.c 2010-03-11 21:51:22 UTC (rev 944) @@ -290,6 +290,9 @@ pkt.type = GG_DCC7_TYPE_P2P; pkt.id = dcc->cid; snprintf((char*) pkt.info, sizeof(pkt.info), "%s %d", inet_ntoa(*((struct in_addr*) &dcc->local_addr)), external_port); + // TODO: implement hash count + // we MUST fill hash to recive from server request for server connection + snprintf((char*) pkt.hash, sizeof(pkt.hash), "0"); return gg_send_packet(dcc->sess, GG_DCC7_INFO, &pkt, sizeof(pkt), NULL); } From libgadu-commit at lists.ziew.org Thu Mar 11 22:51:53 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Thu, 11 Mar 2010 22:51:53 +0100 Subject: [libgadu-commit] r945 - branches/dcc7-relay/src Message-ID: <20100311215153.657F617B44@toxygen.net> Author: wojtekka Date: 2010-03-11 22:51:52 +0100 (Thu, 11 Mar 2010) New Revision: 945 Modified: branches/dcc7-relay/src/dcc7.c Log: >From b3b699c7bbed41ebfd640735d686cd690a38f9fa Mon Sep 17 00:00:00 2001 From: Bartlomiej Zimon Date: Mon, 28 Dec 2009 20:04:33 +0100 Subject: [PATCH] - show data from gg_dcc7_info pkt in debug - info (ip and port) and hash --- branches/1.9/src/dcc7.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) Modified: branches/dcc7-relay/src/dcc7.c =================================================================== --- branches/dcc7-relay/src/dcc7.c 2010-03-11 21:51:22 UTC (rev 944) +++ branches/dcc7-relay/src/dcc7.c 2010-03-11 21:51:52 UTC (rev 945) @@ -849,6 +849,7 @@ char *tmp; gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_dcc7_handle_info(%p, %p, %p, %d)\n", sess, e, payload, len); + gg_debug_session(sess, GG_DEBUG_FUNCTION, "// gg_dcc7_handle_info() received adress: %s, hash: %s\n", p->info, p->hash); if (!(dcc = gg_dcc7_session_find(sess, p->id, gg_fix32(p->uin)))) { gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_info() unknown dcc session\n"); From libgadu-commit at lists.ziew.org Thu Mar 11 22:52:20 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Thu, 11 Mar 2010 22:52:20 +0100 Subject: [libgadu-commit] r946 - branches/dcc7-relay/include Message-ID: <20100311215220.74F8317B44@toxygen.net> Author: wojtekka Date: 2010-03-11 22:52:19 +0100 (Thu, 11 Mar 2010) New Revision: 946 Modified: branches/dcc7-relay/include/libgadu.h.in Log: >From 4868a21a4b3256117cdffc4f306f5ce66ae08486 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zimon Date: Tue, 29 Dec 2009 00:48:44 +0100 Subject: [PATCH] - add relay flag to gg_dcc7 struct --- branches/1.9/include/libgadu.h.in | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) Modified: branches/dcc7-relay/include/libgadu.h.in =================================================================== --- branches/dcc7-relay/include/libgadu.h.in 2010-03-11 21:51:52 UTC (rev 945) +++ branches/dcc7-relay/include/libgadu.h.in 2010-03-11 21:52:19 UTC (rev 946) @@ -431,6 +431,8 @@ int soft_timeout; /**< Flaga m?wi?ca, ?e po przekroczeniu \c timeout nale?y wywo?a? \c gg_dcc7_watch_fd() */ int seek; /**< Flaga m?wi?ca, ?e mo?na zmienia? po?o?enie w wysy?anym pliku */ + int relay; /**< Flaga m?wi?ca, ?e laczymy sie przez serwer */ + struct { uint32_t relay_addr; /**< Adres serwera relay */ uint16_t relay_port; /**< Port serwera relay */ From libgadu-commit at lists.ziew.org Thu Mar 11 22:52:45 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Thu, 11 Mar 2010 22:52:45 +0100 Subject: [libgadu-commit] r947 - branches/dcc7-relay/src Message-ID: <20100311215246.1877917B44@toxygen.net> Author: wojtekka Date: 2010-03-11 22:52:45 +0100 (Thu, 11 Mar 2010) New Revision: 947 Modified: branches/dcc7-relay/src/dcc7.c Log: >From 821c4a580ec67ebbea028ab6e19bfa12e440d4eb Mon Sep 17 00:00:00 2001 From: Bartlomiej Zimon Date: Tue, 29 Dec 2009 00:54:50 +0100 Subject: [PATCH] - use packets for auth dcc7 host so this part is more clean now --- branches/1.9/src/dcc7.c | 72 +++++++++++++++++++++++++++++++++++----------- 1 files changed, 55 insertions(+), 17 deletions(-) Modified: branches/dcc7-relay/src/dcc7.c =================================================================== --- branches/dcc7-relay/src/dcc7.c 2010-03-11 21:52:19 UTC (rev 946) +++ branches/dcc7-relay/src/dcc7.c 2010-03-11 21:52:45 UTC (rev 947) @@ -1196,23 +1196,45 @@ case GG_STATE_READING_ID: { - gg_dcc7_id_t id; int res; gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() GG_STATE_READING_ID\n"); - if ((res = read(dcc->fd, &id, sizeof(id))) != sizeof(id)) { - gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() read() failed (%d, %s)\n", res, strerror(errno)); - e->type = GG_EVENT_DCC7_ERROR; - e->event.dcc_error = GG_ERROR_DCC7_HANDSHAKE; - return e; - } + if (!dcc->relay) { + struct gg_dcc7_welcome_p2p welcome, welcome_ok; + welcome_ok.id = dcc->cid; - if (memcmp(&id, &dcc->cid, sizeof(id))) { - gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() invalid id\n"); - e->type = GG_EVENT_DCC7_ERROR; - e->event.dcc_error = GG_ERROR_DCC7_HANDSHAKE; - return e; + if ((res = read(dcc->fd, &welcome, sizeof(welcome))) != sizeof(welcome)) { + gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() read() failed (%d, %s)", res, strerror(errno)); + e->type = GG_EVENT_DCC7_ERROR; + e->event.dcc_error = GG_ERROR_DCC7_HANDSHAKE; + return e; + } + + if (memcmp(&welcome, &welcome_ok, sizeof(welcome))) { + gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() invalid id\n"); + e->type = GG_EVENT_DCC7_ERROR; + e->event.dcc_error = GG_ERROR_DCC7_HANDSHAKE; + return e; + } + } else { + struct gg_dcc7_welcome_server welcome, welcome_ok; + welcome_ok.magic = GG_DCC7_WELCOME_SERVER; + welcome_ok.id = dcc->cid; + + if ((res = read(dcc->fd, &welcome, sizeof(welcome))) != sizeof(welcome)) { + gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() read() failed (%d, %s)", res, strerror(errno)); + e->type = GG_EVENT_DCC7_ERROR; + e->event.dcc_error = GG_ERROR_DCC7_HANDSHAKE; + return e; + } + + if (memcmp(&welcome, &welcome_ok, sizeof(welcome))) { + gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() invalid id\n"); + e->type = GG_EVENT_DCC7_ERROR; + e->event.dcc_error = GG_ERROR_DCC7_HANDSHAKE; + return e; + } } if (dcc->incoming) { @@ -1233,11 +1255,27 @@ gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() GG_SENDING_ID\n"); - if ((res = write(dcc->fd, &dcc->cid, sizeof(dcc->cid))) != sizeof(dcc->cid)) { - gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() write() failed (%d, %s)", res, strerror(errno)); - e->type = GG_EVENT_DCC7_ERROR; - e->event.dcc_error = GG_ERROR_DCC7_HANDSHAKE; - return e; + if (!dcc->relay) { + struct gg_dcc7_welcome_p2p welcome; + welcome.id = dcc->cid; + + if ((res = write(dcc->fd, &welcome, sizeof(welcome))) != sizeof(welcome)) { + gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() write() failed (%d, %s)", res, strerror(errno)); + e->type = GG_EVENT_DCC7_ERROR; + e->event.dcc_error = GG_ERROR_DCC7_HANDSHAKE; + return e; + } + } else { + struct gg_dcc7_welcome_server welcome; + welcome.magic = GG_DCC7_WELCOME_SERVER; + welcome.id = dcc->cid; + + if ((res = write(dcc->fd, &welcome, sizeof(welcome))) != sizeof(welcome)) { + gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() write() failed (%d, %s)", res, strerror(errno)); + e->type = GG_EVENT_DCC7_ERROR; + e->event.dcc_error = GG_ERROR_DCC7_HANDSHAKE; + return e; + } } if (dcc->incoming) { From libgadu-commit at lists.ziew.org Thu Mar 11 22:53:16 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Thu, 11 Mar 2010 22:53:16 +0100 Subject: [libgadu-commit] r948 - branches/dcc7-relay/src Message-ID: <20100311215316.6462417B44@toxygen.net> Author: wojtekka Date: 2010-03-11 22:53:15 +0100 (Thu, 11 Mar 2010) New Revision: 948 Modified: branches/dcc7-relay/src/dcc7.c Log: >From f31eadf464dbbaa8eeb5b2e427816552a10d50c1 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zimon Date: Tue, 29 Dec 2009 00:56:41 +0100 Subject: [PATCH] - get relay adresses on accept pkt - but on gg_dcc7_accept after sending info --- branches/1.9/src/dcc7.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) Modified: branches/dcc7-relay/src/dcc7.c =================================================================== --- branches/dcc7-relay/src/dcc7.c 2010-03-11 21:52:45 UTC (rev 947) +++ branches/dcc7-relay/src/dcc7.c 2010-03-11 21:53:15 UTC (rev 948) @@ -709,7 +709,10 @@ dcc->offset = offset; - return gg_dcc7_listen_and_send_info(dcc); + int ret = gg_dcc7_listen_and_send_info(dcc); + gg_dcc7_get_relay_addr(dcc); + + return ret; } /** @@ -817,6 +820,8 @@ return 0; } + gg_dcc7_get_relay_addr(dcc); + if (dcc->state != GG_STATE_WAITING_FOR_ACCEPT) { gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_accept() invalid state\n"); e->type = GG_EVENT_DCC7_ERROR; From libgadu-commit at lists.ziew.org Thu Mar 11 22:53:46 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Thu, 11 Mar 2010 22:53:46 +0100 Subject: [libgadu-commit] r949 - branches/dcc7-relay/src Message-ID: <20100311215346.D91AD17B44@toxygen.net> Author: wojtekka Date: 2010-03-11 22:53:46 +0100 (Thu, 11 Mar 2010) New Revision: 949 Modified: branches/dcc7-relay/src/dcc7.c Log: >From c0d08d7a3fdc69536946fbed7f517600c8ce6464 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zimon Date: Tue, 29 Dec 2009 01:00:05 +0100 Subject: [PATCH] - handle relay connection (dcc by server) works realy nice :) --- branches/1.9/src/dcc7.c | 77 +++++++++++++++++++++++++++++++++++++---------- 1 files changed, 61 insertions(+), 16 deletions(-) Modified: branches/dcc7-relay/src/dcc7.c =================================================================== --- branches/dcc7-relay/src/dcc7.c 2010-03-11 21:53:15 UTC (rev 948) +++ branches/dcc7-relay/src/dcc7.c 2010-03-11 21:53:46 UTC (rev 949) @@ -861,36 +861,81 @@ return 0; } - if (p->type != GG_DCC7_TYPE_P2P) { + if (p->type != GG_DCC7_TYPE_P2P && p->type != GG_DCC7_TYPE_SERVER) { gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_info() unhandled transfer type (%d)\n", p->type); e->type = GG_EVENT_DCC7_ERROR; e->event.dcc7_error = GG_ERROR_DCC7_HANDSHAKE; return 0; } - if ((dcc->remote_addr = inet_addr(p->info)) == INADDR_NONE) { - gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_info() invalid IP address\n"); - e->type = GG_EVENT_DCC7_ERROR; - e->event.dcc7_error = GG_ERROR_DCC7_HANDSHAKE; + if (dcc->state == GG_STATE_CONNECTED) { + gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_info() state is already connected\n"); return 0; } - if (!(tmp = strchr(p->info, ' ')) || !(dcc->remote_port = atoi(tmp + 1))) { - gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_info() invalid IP port\n"); - e->type = GG_EVENT_DCC7_ERROR; - e->event.dcc7_error = GG_ERROR_DCC7_HANDSHAKE; - return 0; + if (p->type == GG_DCC7_TYPE_P2P) { + if ((dcc->remote_addr = inet_addr(p->info)) == INADDR_NONE) { + gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_info() invalid IP address\n"); + e->type = GG_EVENT_DCC7_ERROR; + e->event.dcc7_error = GG_ERROR_DCC7_HANDSHAKE; + return 0; + } + + if (!(tmp = strchr(p->info, ' ')) || !(dcc->remote_port = atoi(tmp + 1))) { + gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_info() invalid IP port\n"); + e->type = GG_EVENT_DCC7_ERROR; + e->event.dcc7_error = GG_ERROR_DCC7_HANDSHAKE; + return 0; + } + + if (dcc->state == GG_STATE_WAITING_FOR_INFO) { + gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_info() wainting for info so send one\n"); + gg_dcc7_listen_and_send_info(dcc); + return 0; + } } + if (p->type == GG_DCC7_TYPE_SERVER) { + if (!(tmp = strchr(p->info, 'GG'))) { + gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_info() unknown info packet\n"); + e->type = GG_EVENT_DCC7_ERROR; + e->event.dcc7_error = GG_ERROR_DCC7_HANDSHAKE; + return 0; + } + + /*if (dcc->cid != (gg_dcc7_)atoi(tmp + 1)) { + gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_info() invalid session id\n"); + e->type = GG_EVENT_DCC7_ERROR; + e->event.dcc7_error = GG_ERROR_DCC7_HANDSHAKE; + return 0; + }*/ + + if (!dcc->dcc_relays[0].relay_addr) { + gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_info() have no relay servers\n"); + e->type = GG_EVENT_DCC7_ERROR; + e->event.dcc7_error = GG_ERROR_DCC7_HANDSHAKE; + return 0; + } + + gg_send_packet(dcc->sess, 0x1f, payload, len, NULL); + dcc->relay = 1; + dcc->remote_addr = dcc->dcc_relays[0].relay_addr; + dcc->remote_port = dcc->dcc_relays[0].relay_port; + + if (gg_dcc7_connect(sess, dcc) != -1) + return 0; + + } + // je?li nadal czekamy na po??czenie przychodz?ce, a druga strona nie // daje rady i oferuje namiary na siebie, bierzemy co daj?. - if (dcc->state != GG_STATE_WAITING_FOR_INFO && (dcc->state != GG_STATE_LISTENING || dcc->reverse)) { - gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_info() invalid state\n"); - e->type = GG_EVENT_DCC7_ERROR; - e->event.dcc7_error = GG_ERROR_DCC7_HANDSHAKE; - return 0; - } +// if (dcc->state != GG_STATE_WAITING_FOR_INFO && (dcc->state != GG_STATE_LISTENING || dcc->reverse)) { +// gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_info() invalid state\n"); +// e->type = GG_EVENT_DCC7_ERROR; +// e->event.dcc7_error = GG_ERROR_DCC7_HANDSHAKE; +// return 0; +// } if (dcc->state == GG_STATE_LISTENING) { close(dcc->fd); From libgadu-commit at lists.ziew.org Thu Mar 11 23:00:53 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Thu, 11 Mar 2010 23:00:53 +0100 Subject: [libgadu-commit] r950 - branches/dcc7-relay/src Message-ID: <20100311220053.6C93217B44@toxygen.net> Author: wojtekka Date: 2010-03-11 23:00:52 +0100 (Thu, 11 Mar 2010) New Revision: 950 Modified: branches/dcc7-relay/src/libgadu.c Log: >From 80796d572e557d2835c1c3a004055f61c0a3638c Mon Sep 17 00:00:00 2001 From: Bartlomiej Zimon Date: Tue, 29 Dec 2009 09:38:13 +0100 Subject: [PATCH] - clean ups in gg_login (resolve relay addr) --- branches/1.9/src/libgadu.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) Modified: branches/dcc7-relay/src/libgadu.c =================================================================== --- branches/dcc7-relay/src/libgadu.c 2010-03-11 21:53:46 UTC (rev 949) +++ branches/dcc7-relay/src/libgadu.c 2010-03-11 22:00:52 UTC (rev 950) @@ -661,8 +661,10 @@ struct gg_session *gg_login(const struct gg_login_params *p) { struct gg_session *sess = NULL; - char *hostname, relay_hostname; + char *hostname; int port; + char *relay_hostname; + struct in_addr relay_addr; if (!p) { gg_debug(GG_DEBUG_FUNCTION, "** gg_login(%p);\n", p); @@ -812,7 +814,6 @@ } relay_hostname = GG_RELAY_HOST; - struct in_addr relay_addr; if (gg_gethostbyname_real(relay_hostname, &relay_addr, 0) == -1) { gg_debug(GG_DEBUG_MISC, "// gg_login() relay host \"%s\" not found\n", relay_hostname); sess->relay_addr = INADDR_NONE; From libgadu-commit at lists.ziew.org Thu Mar 11 23:03:04 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Thu, 11 Mar 2010 23:03:04 +0100 Subject: [libgadu-commit] r951 - branches/dcc7-relay/src Message-ID: <20100311220304.9EC2D17B44@toxygen.net> Author: wojtekka Date: 2010-03-11 23:03:04 +0100 (Thu, 11 Mar 2010) New Revision: 951 Modified: branches/dcc7-relay/src/common.c Log: >From dfaee92439e842aa75281487903a6b370bc79bc9 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zimon Date: Tue, 29 Dec 2009 09:40:12 +0100 Subject: [PATCH] - introduction of new debug function to dump buffers --- branches/1.9/src/common.c | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-) Modified: branches/dcc7-relay/src/common.c =================================================================== --- branches/dcc7-relay/src/common.c 2010-03-11 22:00:52 UTC (rev 950) +++ branches/dcc7-relay/src/common.c 2010-03-11 22:03:04 UTC (rev 951) @@ -168,6 +168,33 @@ } } +/** + * \internal Przekazuje informacj? odpluskwiania zwi?zane z zawarto?ci? pami?ci. + * + * \param sess Struktura sesji + * \param buf Adres w pami?ci + * \param buf_length Ilo?? danych do wy?wietlenia + * \param format Format wiadomo?ci (zgodny z \c printf) + * + * \ingroup debug + */ +void gg_debug_dump_session(struct gg_session *sess, char *buf, unsigned int buf_length, const char *format, ...) +{ + va_list ap; + + if ((gg_debug_level & GG_DEBUG_DUMP)) { + unsigned int i; + unsigned char *p = buf; + + va_start(ap, format); + gg_debug_common(sess, GG_DEBUG_DUMP, format, ap); + for (i = 0; i < buf_length; ++i) + gg_debug_session(sess, GG_DEBUG_DUMP, " %.2x", (unsigned char) *(p++)); + gg_debug_session(sess, GG_DEBUG_DUMP, "\n"); + va_end(ap); + } +} + #endif /** From libgadu-commit at lists.ziew.org Thu Mar 11 23:05:34 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Thu, 11 Mar 2010 23:05:34 +0100 Subject: [libgadu-commit] r952 - branches/dcc7-relay/src Message-ID: <20100311220534.8CC4017B44@toxygen.net> Author: wojtekka Date: 2010-03-11 23:05:34 +0100 (Thu, 11 Mar 2010) New Revision: 952 Modified: branches/dcc7-relay/src/common.c Log: Cofni?cie r951. Modified: branches/dcc7-relay/src/common.c =================================================================== --- branches/dcc7-relay/src/common.c 2010-03-11 22:03:04 UTC (rev 951) +++ branches/dcc7-relay/src/common.c 2010-03-11 22:05:34 UTC (rev 952) @@ -168,33 +168,6 @@ } } -/** - * \internal Przekazuje informacj? odpluskwiania zwi?zane z zawarto?ci? pami?ci. - * - * \param sess Struktura sesji - * \param buf Adres w pami?ci - * \param buf_length Ilo?? danych do wy?wietlenia - * \param format Format wiadomo?ci (zgodny z \c printf) - * - * \ingroup debug - */ -void gg_debug_dump_session(struct gg_session *sess, char *buf, unsigned int buf_length, const char *format, ...) -{ - va_list ap; - - if ((gg_debug_level & GG_DEBUG_DUMP)) { - unsigned int i; - unsigned char *p = buf; - - va_start(ap, format); - gg_debug_common(sess, GG_DEBUG_DUMP, format, ap); - for (i = 0; i < buf_length; ++i) - gg_debug_session(sess, GG_DEBUG_DUMP, " %.2x", (unsigned char) *(p++)); - gg_debug_session(sess, GG_DEBUG_DUMP, "\n"); - va_end(ap); - } -} - #endif /** From libgadu-commit at lists.ziew.org Thu Mar 11 23:06:31 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Thu, 11 Mar 2010 23:06:31 +0100 Subject: [libgadu-commit] r953 - branches/dcc7-relay/src Message-ID: <20100311220631.66A8817B44@toxygen.net> Author: wojtekka Date: 2010-03-11 23:06:30 +0100 (Thu, 11 Mar 2010) New Revision: 953 Modified: branches/dcc7-relay/src/dcc7.c Log: >From 40e096ce031929a5475f9df61e079f9f5c93270b Mon Sep 17 00:00:00 2001 From: Bartlomiej Zimon Date: Tue, 29 Dec 2009 09:42:27 +0100 Subject: [PATCH] - move declaration to the top of func. --- branches/1.9/src/dcc7.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) Modified: branches/dcc7-relay/src/dcc7.c =================================================================== --- branches/dcc7-relay/src/dcc7.c 2010-03-11 22:05:34 UTC (rev 952) +++ branches/dcc7-relay/src/dcc7.c 2010-03-11 22:06:30 UTC (rev 953) @@ -344,6 +344,7 @@ struct in_addr relay_addr; char *relay_hostname; int fd; + int ret = 1; if (!dcc) { gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_get_relay() invalid parameters\n"); @@ -389,7 +390,6 @@ memset(&reply_pkt, 0, sizeof(reply_pkt)); - int ret = 1; ret = read(fd, &reply_pkt, sizeof(reply_pkt)); close(fd); @@ -440,8 +440,7 @@ memset(&reply_pkt, 0, sizeof(reply_pkt)); - ret = 1; - ret = read(fd, &reply_pkt, sizeof(reply_pkt)); + ret = read(fd, &reply_pkt, sizeof(reply_pkt)); if ((gg_debug_level & GG_DEBUG_DUMP)) { unsigned int i; From libgadu-commit at lists.ziew.org Thu Mar 11 23:07:05 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Thu, 11 Mar 2010 23:07:05 +0100 Subject: [libgadu-commit] r954 - branches/dcc7-relay/src Message-ID: <20100311220706.243FF17B44@toxygen.net> Author: wojtekka Date: 2010-03-11 23:07:05 +0100 (Thu, 11 Mar 2010) New Revision: 954 Modified: branches/dcc7-relay/src/dcc7.c Log: >From f4a71d81cf63c0b5f6d0fa700a466b0e888bb091 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zimon Date: Tue, 29 Dec 2009 09:43:20 +0100 Subject: [PATCH] - change debug type of relay hosts --- branches/1.9/src/dcc7.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Modified: branches/dcc7-relay/src/dcc7.c =================================================================== --- branches/dcc7-relay/src/dcc7.c 2010-03-11 22:06:30 UTC (rev 953) +++ branches/dcc7-relay/src/dcc7.c 2010-03-11 22:07:05 UTC (rev 954) @@ -465,8 +465,8 @@ dcc->dcc_relays[1].relay_port = reply_pkt.port2; dcc->dcc_relays[1].relay_type = reply_pkt.type2; - gg_debug_session(dcc->sess, GG_DEBUG_DUMP, "// gg_dcc7_get_relay() found relay proxy: %s:%d,", inet_ntoa(*((struct in_addr*) &dcc->dcc_relays[0].relay_addr)), dcc->dcc_relays[0].relay_port); - gg_debug_session(dcc->sess, GG_DEBUG_DUMP, " %s:%d\n", inet_ntoa(*((struct in_addr*) &dcc->dcc_relays[1].relay_addr)), dcc->dcc_relays[1].relay_port); + gg_debug_session(dcc->sess, GG_DEBUG_MISC, "// gg_dcc7_get_relay() found relay proxy: %s:%d,", inet_ntoa(*((struct in_addr*) &dcc->dcc_relays[0].relay_addr)), dcc->dcc_relays[0].relay_port); + gg_debug_session(dcc->sess, GG_DEBUG_MISC, " %s:%d\n", inet_ntoa(*((struct in_addr*) &dcc->dcc_relays[1].relay_addr)), dcc->dcc_relays[1].relay_port); return 0; } From libgadu-commit at lists.ziew.org Thu Mar 11 23:07:26 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Thu, 11 Mar 2010 23:07:26 +0100 Subject: [libgadu-commit] r955 - branches/dcc7-relay/src Message-ID: <20100311220726.7174117B44@toxygen.net> Author: wojtekka Date: 2010-03-11 23:07:25 +0100 (Thu, 11 Mar 2010) New Revision: 955 Modified: branches/dcc7-relay/src/dcc7.c Log: >From c5a5899685c29cc489cd4f394b3476403f539989 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zimon Date: Tue, 29 Dec 2009 09:43:49 +0100 Subject: [PATCH] - use of new debug in dcc7.c --- branches/1.9/src/dcc7.c | 44 ++++++-------------------------------------- 1 files changed, 6 insertions(+), 38 deletions(-) Modified: branches/dcc7-relay/src/dcc7.c =================================================================== --- branches/dcc7-relay/src/dcc7.c 2010-03-11 22:07:05 UTC (rev 954) +++ branches/dcc7-relay/src/dcc7.c 2010-03-11 22:07:25 UTC (rev 955) @@ -375,16 +375,8 @@ pkt.type = gg_fix16(GG_DCC7_RELAY_TYPE_PROXY); pkt.dunno1 = gg_fix16(GG_DCC7_RELAY_DUNNO1); - if ((gg_debug_level & GG_DEBUG_DUMP)) { - unsigned int i; - unsigned char *p = &pkt; + gg_debug_dump_session(dcc->sess, &pkt, sizeof(pkt), "// gg_dcc7_get_relay() send pkt(0x%.2x)", gg_fix32(pkt.magic)); - gg_debug_session(dcc->sess, GG_DEBUG_DUMP, "// gg_dcc7_get_relay() send pkt(0x%.2x)", gg_fix32(pkt.magic)); - for (i = 0; i < sizeof(pkt); ++i) - gg_debug_session(dcc->sess, GG_DEBUG_DUMP, " %.2x", (unsigned char) *(p++)); - gg_debug_session(dcc->sess, GG_DEBUG_DUMP, "\n"); - } - if (write(fd, &pkt, sizeof(pkt)) == -1) return -1; @@ -394,16 +386,8 @@ close(fd); - if ((gg_debug_level & GG_DEBUG_DUMP)) { - unsigned int i; - unsigned char *p = &reply_pkt; + gg_debug_dump_session(dcc->sess, &reply_pkt, sizeof(reply_pkt), "// gg_dcc7_get_relay() read pkt(0x%.2x)", gg_fix32(reply_pkt.magic)); - gg_debug_session(dcc->sess, GG_DEBUG_DUMP, "// gg_dcc7_get_relay() read pkt(0x%.2x)", gg_fix32(reply_pkt.magic)); - for (i = 0; i < sizeof(reply_pkt); ++i) - gg_debug_session(dcc->sess, GG_DEBUG_DUMP, " %.2x", (unsigned char) *(p++)); - gg_debug_session(dcc->sess, GG_DEBUG_DUMP, "\n"); - } - // change query type to relay proxy pkt.type = gg_fix16(GG_DCC7_RELAY_TYPE_SERVER); // take first proxy but if server does reply with 0 use this server @@ -425,16 +409,8 @@ else relay_port = GG_RELAY_PORT; - if ((gg_debug_level & GG_DEBUG_DUMP)) { - unsigned int i; - unsigned char *p = &pkt; + gg_debug_dump_session(dcc->sess, &pkt, sizeof(pkt), "// gg_dcc7_get_relay() send pkt(0x%.2x)", gg_fix32(pkt.magic)); - gg_debug_session(dcc->sess, GG_DEBUG_DUMP, "// gg_dcc7_get_relay() send pkt(0x%.2x)", gg_fix32(pkt.magic)); - for (i = 0; i < sizeof(pkt); ++i) - gg_debug_session(dcc->sess, GG_DEBUG_DUMP, " %.2x", (unsigned char) *(p++)); - gg_debug_session(dcc->sess, GG_DEBUG_DUMP, "\n"); - } - if (write(fd, &pkt, sizeof(pkt)) == -1) return -1; @@ -442,17 +418,9 @@ ret = read(fd, &reply_pkt, sizeof(reply_pkt)); - if ((gg_debug_level & GG_DEBUG_DUMP)) { - unsigned int i; - unsigned char *p = &reply_pkt; - - gg_debug_session(dcc->sess, GG_DEBUG_DUMP, "// gg_dcc7_get_relay() read pkt(0x%.2x)", gg_fix32(reply_pkt.magic)); - for (i = 0; i < sizeof(reply_pkt); ++i) - gg_debug_session(dcc->sess, GG_DEBUG_DUMP, " %.2x", (unsigned char) *(p++)); - gg_debug_session(dcc->sess, GG_DEBUG_DUMP, "\n"); - } - close(fd); - retries--; + gg_debug_dump_session(dcc->sess, &reply_pkt, sizeof(reply_pkt), "// gg_dcc7_get_relay() read pkt(0x%.2x)", gg_fix32(reply_pkt.magic)); + close(fd); + retries--; } if (reply_pkt.magic != gg_fix32(GG_DCC7_RELAY_REPLY)) From libgadu-commit at lists.ziew.org Tue Mar 16 21:09:24 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Tue, 16 Mar 2010 21:09:24 +0100 Subject: [libgadu-commit] r956 - trunk/src Message-ID: <20100316200924.B4D8D17B51@toxygen.net> Author: wojtekka Date: 2010-03-16 21:09:23 +0100 (Tue, 16 Mar 2010) New Revision: 956 Modified: trunk/src/common.c Log: Niepotrzebne ?onglowanie typami. Modified: trunk/src/common.c =================================================================== --- trunk/src/common.c 2010-03-11 22:07:25 UTC (rev 955) +++ trunk/src/common.c 2010-03-16 20:09:23 UTC (rev 956) @@ -157,12 +157,11 @@ if ((gg_debug_level & GG_DEBUG_DUMP)) { unsigned int i; - unsigned char *p = buf; va_start(ap, format); gg_debug_common(sess, GG_DEBUG_DUMP, format, ap); for (i = 0; i < buf_length; ++i) - gg_debug_session(sess, GG_DEBUG_DUMP, " %.2x", (unsigned char) *(p++)); + gg_debug_session(sess, GG_DEBUG_DUMP, " %.2x", (unsigned char) buf[i]); gg_debug_session(sess, GG_DEBUG_DUMP, "\n"); va_end(ap); } From libgadu-commit at lists.ziew.org Tue Mar 16 21:10:12 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Tue, 16 Mar 2010 21:10:12 +0100 Subject: [libgadu-commit] r957 - trunk Message-ID: <20100316201013.0960017B59@toxygen.net> Author: wojtekka Date: 2010-03-16 21:10:12 +0100 (Tue, 16 Mar 2010) New Revision: 957 Modified: trunk/configure.ac Log: Sensowny komunikat o vsnprintf() w przypadku crosskompilacji. Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2010-03-16 20:09:23 UTC (rev 956) +++ trunk/configure.ac 2010-03-16 20:10:12 UTC (rev 957) @@ -67,6 +67,9 @@ if test "x$with_c99_vsnprintf" = "x"; then AC_MSG_CHECKING([for C99-compatible vsnprintf()]) + if test "x$cross_compiling" = "xyes"; then + AC_MSG_ERROR([cannot determine vsnprintf() behaviour when cross-compiling. You need to provide --with-c99-vsnprintf or --without-c99-vsnprintf option instead. It is safe to assume that the former is valid on most modern operating systems.]) + fi AC_TRY_RUN( [ #include From libgadu-commit at lists.ziew.org Mon Mar 29 00:01:15 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Mon, 29 Mar 2010 00:01:15 +0200 Subject: [libgadu-commit] r958 - in trunk: docs include src test/protocol/tests Message-ID: <20100328220116.012C117B4D@toxygen.net> Author: wojtekka Date: 2010-03-29 00:01:14 +0200 (Mon, 29 Mar 2010) New Revision: 958 Modified: trunk/docs/login.dox trunk/docs/status.dox trunk/include/libgadu.h.in trunk/src/events.c trunk/src/libgadu.c trunk/src/libgadu.sym trunk/test/protocol/tests/00-login.scr trunk/test/protocol/tests/30-status.scr Log: Dodanie obs?ugi flag statusu za pomoc? gg_login_params.status_flags i funkcji gg_change_status_flags(). Modified: trunk/docs/login.dox =================================================================== --- trunk/docs/login.dox 2010-03-16 20:10:12 UTC (rev 957) +++ trunk/docs/login.dox 2010-03-28 22:01:14 UTC (rev 958) @@ -41,7 +41,7 @@ Nowe statusy (nie przeszkadza?, poGGadaj ze mn?), opisy graficzne i wiadomo?ci kodowane UTF-8 b?d? dost?pne dopiero po ustawieniu odpowiednich parametr?w po??czenia. Jest to niezb?dne, poniewa? starsze klienty mog?yby nie dzia?a? -prawid?owo, gdyby przy domy?lnych parametrach po??czenia zmieni?oby si? +prawid?owo, gdyby przy domy?lnych parametrach po??czenia zmieni?o si? zachowanie biblioteki. \code Modified: trunk/docs/status.dox =================================================================== --- trunk/docs/status.dox 2010-03-16 20:10:12 UTC (rev 957) +++ trunk/docs/status.dox 2010-03-28 22:01:14 UTC (rev 958) @@ -22,11 +22,17 @@ \ref contacts "doda? do listy konktakt?w" ich identyfikatory, a nast?pnie obs?ugiwa? \ref events-list "zdarzenia" zwi?zane ze zmianami statusu. -Je?li pole \c protocol_features struktury \c gg_login_params zawiera -\c GG_FEATURE_IMAGE_DESCR, informacja o tym, ?e status zawiera opis jest -dodatkowo przekazywana za pomoc? flagi \c GG_STATUS_DESCR_MASK. To samo -dotyczy zmiany status?w os?b z listy kontakt?w. +Je?li pole \ref gg_login_params::protocol_features "\c protocol_features" +struktury \c gg_login_params zawiera \c GG_FEATURE_IMAGE_DESCR, informacja +o tym, ?e status zawiera opis jest dodatkowo przekazywana za pomoc? flagi +\c GG_STATUS_DESCR_MASK. To samo dotyczy zmiany status?w os?b z listy +kontakt?w. +Cz??? opcji jest dost?pna w postaci flag statusu, np. otrzymywanie link?w +od nieznajomych czy figurowanie jako klient mobilny. Mo?na je ustawi? za +pomoc? pola \ref gg_login_params::status_flags "\c status_flags" +struktury \c gg_login_params lub funkcj? \c gg_change_status_flags(). + \bug Nie ma mo?liwo?ci poprawnego odbierania status?w zawieraj?cych czas powrotu. Modified: trunk/include/libgadu.h.in =================================================================== --- trunk/include/libgadu.h.in 2010-03-16 20:10:12 UTC (rev 957) +++ trunk/include/libgadu.h.in 2010-03-28 22:01:14 UTC (rev 958) @@ -278,6 +278,7 @@ void (*resolver_cleanup)(void **private_data, int force); /**< Funkcja zwalniaj?ca zasoby po rozwi?zaniu nazwy */ int protocol_features; /**< Opcje protoko?u */ + int status_flags; /**< Flagi statusu */ }; /** @@ -574,9 +575,10 @@ gg_encoding_t encoding; /**< Rodzaj kodowania u?ywanego w sesji (domy?lnie CP1250) */ gg_resolver_t resolver; /**< Spos?b rozwi?zywania nazw (patrz \ref build-resolver) */ int protocol_features; /**< Opcje protoko?u (flagi GG_FEATURE_*). */ + int status_flags; /**< Flagi statusu (flagi GG_STATUS_FLAG_*, patrz \ref status). */ #ifndef DOXYGEN - char dummy[2 * sizeof(int)]; /**< \internal Miejsce na kilka kolejnych + char dummy[1 * sizeof(int)]; /**< \internal Miejsce na kilka kolejnych parametr?w, ?eby wraz z dodawaniem kolejnych parametr?w nie zmienia? si? rozmiar struktury */ #endif @@ -589,6 +591,7 @@ int gg_change_status(struct gg_session *sess, int status); int gg_change_status_descr(struct gg_session *sess, int status, const char *descr); int gg_change_status_descr_time(struct gg_session *sess, int status, const char *descr, int time); +int gg_change_status_flags(struct gg_session *sess, int flags); int gg_send_message(struct gg_session *sess, int msgclass, uin_t recipient, const unsigned char *message); int gg_send_message_richtext(struct gg_session *sess, int msgclass, uin_t recipient, const unsigned char *message, const unsigned char *format, int formatlen); int gg_send_message_confer(struct gg_session *sess, int msgclass, int recipients_count, uin_t *recipients, const unsigned char *message); @@ -1510,6 +1513,11 @@ #define GG_STATUS_DESCR_MASK 0x4000 #define GG_STATUS_FRIENDS_MASK 0x8000 +#define GG_STATUS_FLAG_UNKNOWN 0x00000001 +#define GG_STATUS_FLAG_VIDEO 0x00000002 +#define GG_STATUS_FLAG_MOBILE 0x00100000 +#define GG_STATUS_FLAG_SPAM 0x00800000 + #else /** @@ -1536,6 +1544,18 @@ GG_STATUS_FRIENDS_MASK, /**< Flaga bitowa dost?pno?ci tylko dla znajomych */ }; +/** + * Rodzaje status?w u?ytkownika. Mapa bitowa. + * + * \ingroup status + */ +enum { + GG_STATUS_FLAG_UNKNOWN, /**< Przeznaczenie nieznane, ale wyst?puje zawsze */ + GG_STATUS_FLAG_VIDEO, /**< Klient obs?uguje wideorozmowy */ + GG_STATUS_FLAG_MOBILE, /**< Klient mobilny (ikona telefonu kom?rkowego) */ + GG_STATUS_FLAG_SPAM, /**< Klient chce otrzymywa? linki od nieznajomych */ +}; + #endif /* DOXYGEN */ /** Modified: trunk/src/events.c =================================================================== --- trunk/src/events.c 2010-03-16 20:10:12 UTC (rev 957) +++ trunk/src/events.c 2010-03-28 22:01:14 UTC (rev 958) @@ -2080,7 +2080,7 @@ l.hash_type = sess->hash_type; memcpy(l.hash, login_hash, sizeof(login_hash)); l.status = gg_fix32(sess->initial_status ? sess->initial_status : GG_STATUS_AVAIL); - l.flags = gg_fix32(0x00800001); + l.flags = gg_fix32(sess->status_flags); l.features = gg_fix32(sess->protocol_features); l.image_size = sess->image_size; l.dunno2 = 0x64; Modified: trunk/src/libgadu.c =================================================================== --- trunk/src/libgadu.c 2010-03-16 20:10:12 UTC (rev 957) +++ trunk/src/libgadu.c 2010-03-28 22:01:14 UTC (rev 958) @@ -718,6 +718,9 @@ if (!(p->protocol_features & GG_FEATURE_MSG77)) sess->protocol_features |= GG_FEATURE_MSG80; + if (!(sess->status_flags = p->status_flags)) + sess->status_flags = 0x00800001; + sess->protocol_version = (p->protocol_version) ? p->protocol_version : GG_DEFAULT_PROTOCOL_VERSION; if (p->era_omnix) @@ -1110,7 +1113,7 @@ struct gg_new_status80 p; p.status = gg_fix32(status); - p.flags = gg_fix32(0x00800001); + p.flags = gg_fix32(sess->status_flags); p.description_size = gg_fix32(descr_len); res = gg_send_packet(sess, packet_type, @@ -1198,6 +1201,33 @@ } /** + * Funkcja zmieniaj?ca flagi statusu. + * + * \param sess Struktura sesji + * \param flags Nowe flagi statusu + * + * \return 0 je?li si? powiod?o, -1 w przypadku b??du + * + * \note Aby zmiany wesz?y w ?ycie, nale?y ponownie ustawi? status za pomoc? + * funkcji z rodziny \c gg_change_status(). + * + * \ingroup status + */ +int gg_change_status_flags(struct gg_session *sess, int flags) +{ + gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_change_status_flags(%p, 0x%08x);\n", sess, flags); + + if (sess == NULL) { + errno = EFAULT; + return -1; + } + + sess->status_flags = flags; + + return 0; +} + +/** * Wysy?a wiadomo?? do u?ytkownika. * * Zwraca losowy numer sekwencyjny, kt?ry mo?na zignorowa? albo wykorzysta? Modified: trunk/src/libgadu.sym =================================================================== --- trunk/src/libgadu.sym 2010-03-16 20:10:12 UTC (rev 957) +++ trunk/src/libgadu.sym 2010-03-28 22:01:14 UTC (rev 958) @@ -12,6 +12,7 @@ gg_change_status gg_change_status_descr gg_change_status_descr_time +gg_change_status_flags gg_chomp gg_connect gg_crc32 Modified: trunk/test/protocol/tests/00-login.scr =================================================================== --- trunk/test/protocol/tests/00-login.scr 2010-03-16 20:10:12 UTC (rev 957) +++ trunk/test/protocol/tests/00-login.scr 2010-03-28 22:01:14 UTC (rev 958) @@ -39,10 +39,10 @@ #----------------------------------------------------------------------------- # Login with parameters #----------------------------------------------------------------------------- -login (uin = 0x123456, password = "ABC", status = GG_STATUS_INVISIBLE_DESCR, status_descr = "Test", has_audio = 1, image_size = 255, hash_type = GG_LOGIN_HASH_GG32, external_addr = 127.0.0.1, external_port = 0x1234) +login (uin = 0x123456, password = "ABC", status = GG_STATUS_INVISIBLE_DESCR, status_descr = "Test", has_audio = 1, image_size = 255, hash_type = GG_LOGIN_HASH_GG32, external_addr = 127.0.0.1, external_port = 0x1234, status_flags = 0x11223344) expect connect send (01 00 00 00, auto, 12 34 56 78) -expect data (31 00 00 00, auto, 56 34 12 00, "pl", 01, 09 ad 7d 58 00*60, 16 00 00 00, 01 00 80 00, 07 00 00 00, 00 00 00 00, 00 00, 00 00 00 00, 00 00, ff, 64, 21 00 00 00, "Gadu-Gadu", 20, "Client", 20, "Build", 20, "8.0.0.8731", 04 00 00 00, "Test") +expect data (31 00 00 00, auto, 56 34 12 00, "pl", 01, 09 ad 7d 58 00*60, 16 00 00 00, 44 33 22 11, 07 00 00 00, 00 00 00 00, 00 00, 00 00 00 00, 00 00, ff, 64, 21 00 00 00, "Gadu-Gadu", 20, "Client", 20, "Build", 20, "8.0.0.8731", 04 00 00 00, "Test") send (03 00 00 00, auto) expect event GG_EVENT_CONN_SUCCESS logoff Modified: trunk/test/protocol/tests/30-status.scr =================================================================== --- trunk/test/protocol/tests/30-status.scr 2010-03-16 20:10:12 UTC (rev 957) +++ trunk/test/protocol/tests/30-status.scr 2010-03-28 22:01:14 UTC (rev 958) @@ -80,3 +80,18 @@ expect data (38 00 00 00, 0b 01 00 00, 02 00 00 00, 01 00 80 00, ff 00 00 00, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA") +#----------------------------------------------------------------------------- +# Changing status flags +#----------------------------------------------------------------------------- + +call { + gg_change_status_flags(session, 0x11223344); + gg_change_status(session, GG_STATUS_AVAIL); +} + +expect data (38 00 00 00, auto, 02 00 00 00, 44 33 22 11, 00 00 00 00) + +call { + gg_change_status_flags(session, 0x00800001); +} + From libgadu-commit at lists.ziew.org Mon Mar 29 21:54:07 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Mon, 29 Mar 2010 21:54:07 +0200 Subject: [libgadu-commit] r959 - branches/new-api/src Message-ID: <20100329195407.44FFB17B51@toxygen.net> Author: wojtekka Date: 2010-03-29 21:54:05 +0200 (Mon, 29 Mar 2010) New Revision: 959 Modified: branches/new-api/src/session.c Log: ?rednik?wka (Jakub Zawadzki) Modified: branches/new-api/src/session.c =================================================================== --- branches/new-api/src/session.c 2010-03-28 22:01:14 UTC (rev 958) +++ branches/new-api/src/session.c 2010-03-29 19:54:05 UTC (rev 959) @@ -453,7 +453,7 @@ struct gg_new_status80 p; p.status = gg_fix32(status); - p.flags = gg_fix32(0x00800001);; + p.flags = gg_fix32(0x00800001); p.descr_len = gg_fix32((tmp != NULL) ? strlen(tmp) : 0); gs->status = status; From libgadu-commit at lists.ziew.org Mon Mar 29 22:08:55 2010 From: libgadu-commit at lists.ziew.org (Libgadu commit list) Date: Mon, 29 Mar 2010 22:08:55 +0200 Subject: [libgadu-commit] r960 - trunk/src Message-ID: <20100329200856.2FB8F17B4F@toxygen.net> Author: wojtekka Date: 2010-03-29 22:08:55 +0200 (Mon, 29 Mar 2010) New Revision: 960 Modified: trunk/src/libgadu.c Log: Sta?e zamiast magicznych warto?ci (Marcin Owsiany) Modified: trunk/src/libgadu.c =================================================================== --- trunk/src/libgadu.c 2010-03-29 19:54:05 UTC (rev 959) +++ trunk/src/libgadu.c 2010-03-29 20:08:55 UTC (rev 960) @@ -719,7 +719,7 @@ sess->protocol_features |= GG_FEATURE_MSG80; if (!(sess->status_flags = p->status_flags)) - sess->status_flags = 0x00800001; + sess->status_flags = GG_STATUS_FLAG_UNKNOWN | GG_STATUS_FLAG_SPAM; sess->protocol_version = (p->protocol_version) ? p->protocol_version : GG_DEFAULT_PROTOCOL_VERSION;