Results 1 to 2 of 2

Thread: Gadu-gadu Protocol - logging

  1. #1
    Join Date
    Mar 2009
    Posts
    29
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Gadu-gadu Protocol - logging

    Hi, I have a trouble during the logging by gg protocol from http://toxygen.net/libgadu/protocol/. I connect with server and receive seed, but after sent packet and structure to login, don't receive any message(even package with any wrong communique). That my code:
    Qt Code:
    1. struct gg_header {
    2. int type; /* typ pakietu */
    3. int length; /* długość reszty pakietu */
    4. };
    5.  
    6. struct gg_login80 {
    7. int uin; /* numer Gadu-Gadu */ (gg number)
    8. char* language; /* język: "pl" */
    9. char hash_type; /* rodzaj funkcji skrótu hasła */
    10. char* hash; /* skrót hasła dopełniony \0 */
    11. int status; /* początkowy status połączenia */
    12. int flags; /* początkowe flagi połączenia */
    13. int features; /* opcje protokołu (0x00000007)*/(protocol option)
    14. int local_ip; /* lokalny adres połączeń bezpośrednich (nieużywany) */
    15. short local_port; /* lokalny port połączeń bezpośrednich (nieużywany) */
    16. int external_ip; /* zewnętrzny adres (nieużywany) */
    17. short external_port; /* zewnętrzny port (nieużywany) */
    18. char image_size; /* maksymalny rozmiar grafiki w KB */
    19. char unknown2; /* 0x64 */(idk)
    20. int version_len; /* długość ciągu z wersją (0x21) */
    21. char* version; /* "Gadu-Gadu Client build 8.0.0.7669" (bez \0) */
    22. int description_size; /* rozmiar opisu */
    23. };
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void MainWindow::login_GG(){
    2. gg_login80 *login = new gg_login80();
    3.  
    4. //example structure
    5. login->uin = 1234567;
    6. login->language = "pl";
    7. login->hash_type = GG_LOGIN_HASH_GG32;
    8. login->hash = "";
    9. login->status = GG_STATUS_AVAIL;
    10. login->flags = 0;
    11. login->features = 0x7;
    12. login->local_ip = 0;
    13. login->local_port = 0;
    14. login->external_ip = 0;
    15. login->external_port = 0;
    16. login->image_size = 0;
    17. login->unknown2 = 0x64;
    18. login->version_len = sizeof(login->version);
    19. login->version = "";
    20. login->description_size = 0;
    21.  
    22. gg_header *header = new gg_header;
    23. header->type = GG_LOGIN80;
    24. header->length = sizeof(GG_LOGIN80);
    25.  
    26. connect(socket, SIGNAL(readyRead()), this, SLOT(s_read()));
    27. socket->write((char*)header, sizeof(gg_header));
    28. socket->write((char*)login, sizeof(gg_login80));
    29. }
    30.  
    31. void MainWindow::s_read(){
    32. //That function doesn't call forth because server doesn't receive any package to read
    33. qDebug () << "Receive packet.";
    34. }
    To copy to clipboard, switch view to plain text mode 
    I test by tcpdump and appropriate functons in Qt, that packages are sending to server, unfortunately i don't recive anything (size of packet is 0).

  2. #2
    Join Date
    Jun 2009
    Location
    Kraków, Poland
    Posts
    23
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Gadu-gadu Protocol - logging

    EDITED

    Login packet has it's own structure. When you send wrong structure, server may not respond at all.
    You're making some mistakes:
    1) You can't use sizeof operator in header->length, because gg_login80 struct contains pointers to data, and you will send the data, not the pointers; (what's more, you meant "gg_login80" instead of const "GG_LOGIN80");
    2) hash variable has to be 64 bytes long, (and, BTW, are you counting it anywhere?).
    3) check if second's write method returns number equals to what you sent in header->length - when you sent less bytes, server will still wait for the rest.
    4) Casting header and login to char* for 95% will return crap (but not sure of it) - same bug with sizeof here, also.

    Generally, I advise you to log every packet (bytes) that you send / receive in order to check it's correctness.
    Last edited by Fenix Voltres; 20th February 2010 at 00:42.

Similar Threads

  1. Logging Qt User Actions
    By Frank J. Lhota in forum Qt Programming
    Replies: 14
    Last Post: 30th May 2014, 21:36
  2. logging support!!
    By Raajesh in forum Qt Programming
    Replies: 1
    Last Post: 18th June 2008, 19:18
  3. Cross Platform Logging
    By skyphyr in forum Qt Programming
    Replies: 2
    Last Post: 23rd November 2006, 16:32
  4. logging and tracing in Qt
    By Artschi in forum Qt Programming
    Replies: 4
    Last Post: 17th January 2006, 20:10

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.