transport: fix, assign all data before change connection state
commit4e71ebcbf090b86a85f89f43a59a3123bfb53039
authorAntonio Borneo <borneo.antonio@gmail.com>
Tue, 17 Feb 2015 01:49:46 +0000 (17 09:49 +0800)
committerAntonio Borneo <borneo.antonio@gmail.com>
Wed, 18 Feb 2015 04:54:08 +0000 (18 12:54 +0800)
tree3dfc2a9666698885cab1f78ca4124ca32135185c
parent7ac053271f74f3c3d3b2d2d01dccda13237b344b
transport: fix, assign all data before change connection state

When used with purple, call to sipe_backend_connection_completed()
triggers purple to change state to PURPLE_CONNECTED and to emit
the events "signed-on", "account-signed-on" and "autojoin".

An application willing to communicate (message, file xfer, ...)
will be waiting for connection. It has registered a callback to
one of the events above to be informed of connection ready.

With current code, the connection info are still not fully parsed
when the events are emitted. Following data are not yet assigned:
- sipe_private->contact;
- sipe_private->allowed_events;
- sipe_private->public.flags
Without these information, the application cannot start the
communication immediately; it will the and receive reply from
server:
SIP/2.0 400 Invalid Contact information

Move call to sipe_backend_connection_completed() few lines below,
when info are fully parsed and all data already assigned.

How to reproduce it:
- use "nullclient" available as an example in libpurple;
- enable debug messages in init_libpurple() by changing:
    - purple_debug_set_enabled(FALSE);
    + purple_debug_set_enabled(TRUE);
- add an action in callback signed_on(), e.g.
    + serv_send_file(gc, "sip_account", "file_name");
  with proper strings for file to send and destination account.

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
src/core/sip-transport.c