comparison mcabber/src/xmpp.c @ 1610:6db9f403f707

Replace 'username' with 'jid' in the configuration file The previous behaviour doesn't make much sense anymore. MCabber does DNS SRV lookups so providing the server name is usually not needed.
author Mikael Berthe <mikael@lilotux.net>
date Sun, 11 Oct 2009 20:06:47 +0200
parents 351427ef0b4b
children f9bf561e54d0
comparison
equal deleted inserted replaced
1609:af5bdd167b04 1610:6db9f403f707
850 } 850 }
851 851
852 static void connection_open_cb(LmConnection *connection, gboolean success, 852 static void connection_open_cb(LmConnection *connection, gboolean success,
853 gpointer user_data) 853 gpointer user_data)
854 { 854 {
855 const char *username, *password, *resource, *servername; 855 const char *userjid, *password, *resource, *servername;
856 GError *error; 856 GError *error;
857 857
858 if (success) { 858 if (success) {
859 servername = settings_opt_get("server"); 859 servername = settings_opt_get("server");
860 username = settings_opt_get("username"); 860 userjid = settings_opt_get("jid");
861 password = settings_opt_get("password"); 861 password = settings_opt_get("password");
862 resource = strchr(lm_connection_get_jid(connection), 862 resource = strchr(lm_connection_get_jid(connection),
863 JID_RESOURCE_SEPARATOR); 863 JID_RESOURCE_SEPARATOR);
864 if (resource) 864 if (resource)
865 resource++; 865 resource++;
866 866
867 if (!lm_connection_authenticate(lconnection, username, password, resource, 867 if (!lm_connection_authenticate(lconnection, userjid, password, resource,
868 connection_auth_cb, NULL, FALSE, &error)) { 868 connection_auth_cb, NULL, FALSE, &error)) {
869 scr_LogPrint(LPRINT_LOGNORM, "Failed to authenticate: %s\n", 869 scr_LogPrint(LPRINT_LOGNORM, "Failed to authenticate: %s\n",
870 error->message); 870 error->message);
871 _try_to_reconnect(); 871 _try_to_reconnect();
872 } 872 }
1560 } 1560 }
1561 1561
1562 1562
1563 void xmpp_connect(void) 1563 void xmpp_connect(void)
1564 { 1564 {
1565 const char *username, *password, *resource, *servername, *ssl_fpr; 1565 const char *userjid, *password, *resource, *servername, *ssl_fpr;
1566 char *dynresource = NULL; 1566 char *dynresource = NULL;
1567 char fpr[16]; 1567 char fpr[16];
1568 const char *proxy_host; 1568 const char *proxy_host;
1569 const char *resource_prefix = PACKAGE_NAME; 1569 const char *resource_prefix = PACKAGE_NAME;
1570 char *fjid; 1570 char *fjid;
1577 1577
1578 if (lconnection && lm_connection_is_open(lconnection)) 1578 if (lconnection && lm_connection_is_open(lconnection))
1579 xmpp_disconnect(); 1579 xmpp_disconnect();
1580 1580
1581 servername = settings_opt_get("server"); 1581 servername = settings_opt_get("server");
1582 username = settings_opt_get("username"); 1582 userjid = settings_opt_get("jid");
1583 password = settings_opt_get("password"); 1583 password = settings_opt_get("password");
1584 resource = settings_opt_get("resource"); 1584 resource = settings_opt_get("resource");
1585 proxy_host = settings_opt_get("proxy_host"); 1585 proxy_host = settings_opt_get("proxy_host");
1586 ssl_fpr = settings_opt_get("ssl_fingerprint"); 1586 ssl_fpr = settings_opt_get("ssl_fingerprint");
1587 1587
1588 if (!servername) { 1588 if (!userjid) {
1589 scr_LogPrint(LPRINT_LOGNORM, "Server name has not been specified!"); 1589 scr_LogPrint(LPRINT_LOGNORM, "Your JID has not been specified!");
1590 return;
1591 }
1592
1593 if (!username) {
1594 scr_LogPrint(LPRINT_LOGNORM, "User name has not been specified!");
1595 return; 1590 return;
1596 } 1591 }
1597 if (!password) { 1592 if (!password) {
1598 scr_LogPrint(LPRINT_LOGNORM, "Password has not been specified!"); 1593 scr_LogPrint(LPRINT_LOGNORM, "Your password has not been specified!");
1599 return; 1594 return;
1600 } 1595 }
1601 1596
1602 lconnection = lm_connection_new_with_context 1597 lconnection = lm_connection_new_with_context
1603 (NULL, g_main_loop_get_context(main_loop)); 1598 (NULL, g_main_loop_get_context(main_loop));
1682 scr_LogPrint(LPRINT_NORMAL|LPRINT_DEBUG, " using proxy %s:%d", 1677 scr_LogPrint(LPRINT_NORMAL|LPRINT_DEBUG, " using proxy %s:%d",
1683 proxy_host, proxy_port); 1678 proxy_host, proxy_port);
1684 } 1679 }
1685 } 1680 }
1686 1681
1687 fjid = compose_jid(username, servername, resource); 1682 fjid = compose_jid(userjid, servername, resource);
1688 lm_connection_set_jid(lconnection, fjid); 1683 lm_connection_set_jid(lconnection, fjid);
1684 if (servername)
1685 lm_connection_set_server(lconnection, servername);
1689 #if defined(HAVE_LIBOTR) 1686 #if defined(HAVE_LIBOTR)
1690 otr_init(fjid); 1687 otr_init(fjid);
1691 #endif 1688 #endif
1692 g_free(fjid); 1689 g_free(fjid);
1693 g_free(dynresource); 1690 g_free(dynresource);