# HG changeset patch # User Mikael Berthe # Date 1269289109 -3600 # Node ID 8c2651fc217a03770c381600e368c3fbe64d7d28 # Parent eef8c9fff72783b13ab940598706cba328c03f1e Improve initial display when there is an error message Chat mode is enabled automatically and the screen is refreshed. diff -r eef8c9fff727 -r 8c2651fc217a mcabber/mcabber/main.c --- a/mcabber/mcabber/main.c Sun Mar 21 18:12:34 2010 +0100 +++ b/mcabber/mcabber/main.c Mon Mar 22 21:18:29 2010 +0100 @@ -445,9 +445,14 @@ scr_show_buddy_window(); } else { /* Connection */ - xmpp_connect(); + if (xmpp_connect()) + scr_show_buddy_window(); } + // Initial drawing + scr_draw_roster(); + scr_do_update(); + { // add keypress processing source GSource *mc_source = g_source_new(&mcabber_source_funcs, sizeof(mcabber_source_t)); diff -r eef8c9fff727 -r 8c2651fc217a mcabber/mcabber/xmpp.c --- a/mcabber/mcabber/xmpp.c Sun Mar 21 18:12:34 2010 +0100 +++ b/mcabber/mcabber/xmpp.c Mon Mar 22 21:18:29 2010 +0100 @@ -1634,7 +1634,10 @@ } -void xmpp_connect(void) +// xmpp_connect() +// Return a non-zero value if there's an obvious problem +// (no JID, no password, etc.) +gint xmpp_connect(void) { const char *userjid, *password, *resource, *servername, *ssl_fpr; char *dynresource = NULL; @@ -1660,11 +1663,11 @@ if (!userjid) { scr_LogPrint(LPRINT_LOGNORM, "Your JID has not been specified!"); - return; + return -1; } if (!password) { scr_LogPrint(LPRINT_LOGNORM, "Your password has not been specified!"); - return; + return -1; } lconnection = lm_connection_new_with_context(NULL, main_context); @@ -1770,13 +1773,13 @@ if (ssl || tls) { scr_LogPrint(LPRINT_LOGNORM, "** Error: SSL is NOT available, " "please recompile loudmouth with SSL enabled."); - return; + return -1; } } if (ssl && tls) { scr_LogPrint(LPRINT_LOGNORM, "You can only set ssl or tls, not both."); - return; + return -1; } if (!port) @@ -1784,9 +1787,9 @@ lm_connection_set_port(lconnection, port); if (ssl_fpr && (!hex_to_fingerprint(ssl_fpr, fpr))) { - scr_LogPrint(LPRINT_LOGNORM, "** Plese set the fingerprint in the format " + scr_LogPrint(LPRINT_LOGNORM, "** Please set the fingerprint in the format " "97:5C:00:3F:1D:77:45:25:E2:C5:70:EC:83:C8:87:EE"); - return; + return -1; } lssl = lm_ssl_new((ssl_fpr ? fpr : NULL), ssl_cb, NULL, NULL); @@ -1796,15 +1799,16 @@ lm_ssl_unref(lssl); } else if (ssl || tls) { scr_LogPrint(LPRINT_LOGNORM, "** Error: Couldn't create SSL struct."); - return; + return -1; } if (!lm_connection_open(lconnection, connection_open_cb, NULL, FALSE, &error)) { _try_to_reconnect(); scr_LogPrint(LPRINT_LOGNORM, "Failed to open: %s", error->message); - g_error_free (error); + g_error_free(error); } + return 0; } // insert_entity_capabilities(presence_stanza) diff -r eef8c9fff727 -r 8c2651fc217a mcabber/mcabber/xmpp.h --- a/mcabber/mcabber/xmpp.h Sun Mar 21 18:12:34 2010 +0100 +++ b/mcabber/mcabber/xmpp.h Mon Mar 22 21:18:29 2010 +0100 @@ -32,7 +32,7 @@ extern LmConnection* lconnection; extern LmSSL* lssl; -void xmpp_connect(void); +int xmpp_connect(void); void xmpp_disconnect(void); gboolean xmpp_is_online(void);