comparison libpurple/protocols/jabber/jabber.c @ 32767:2ec94166be43

On the way to hiding the PurpleConnection struct. * Added purple_connection_get_flags() and purple_connection_set_flags() * Use purple_connection_ accessor functions.
author andrew.victor@mxit.com
date Tue, 18 Oct 2011 18:47:48 +0000
parents 10e5000326a5
children 50cd80d3554e
comparison
equal deleted inserted replaced
32766:ea2b621fd3ba 32767:2ec94166be43
850 850
851 static void tls_init(JabberStream *js) 851 static void tls_init(JabberStream *js)
852 { 852 {
853 purple_input_remove(js->gc->inpa); 853 purple_input_remove(js->gc->inpa);
854 js->gc->inpa = 0; 854 js->gc->inpa = 0;
855 js->gsc = purple_ssl_connect_with_host_fd(js->gc->account, js->fd, 855 js->gsc = purple_ssl_connect_with_host_fd(purple_connection_get_account(js->gc), js->fd,
856 jabber_login_callback_ssl, jabber_ssl_connect_failure, js->certificate_CN, js->gc); 856 jabber_login_callback_ssl, jabber_ssl_connect_failure, js->certificate_CN, js->gc);
857 /* The fd is no longer our concern */ 857 /* The fd is no longer our concern */
858 js->fd = -1; 858 js->fd = -1;
859 } 859 }
860 860
1084 { 1084 {
1085 PurpleConnection *gc = purple_account_get_connection(account); 1085 PurpleConnection *gc = purple_account_get_connection(account);
1086 JabberStream *js; 1086 JabberStream *js;
1087 PurpleStoredImage *image; 1087 PurpleStoredImage *image;
1088 1088
1089 gc->flags |= PURPLE_CONNECTION_HTML | 1089 purple_connection_set_flags(gc, PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY);
1090 PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY;
1091 js = jabber_stream_new(account); 1090 js = jabber_stream_new(account);
1092 if (js == NULL) 1091 if (js == NULL)
1093 return; 1092 return;
1094 1093
1095 /* TODO: Remove this at some point. Added 2010-02-14 (v2.6.6) */ 1094 /* TODO: Remove this at some point. Added 2010-02-14 (v2.6.6) */
1263 if(cbdata->js->registration && !strcmp(id, "username")) { 1262 if(cbdata->js->registration && !strcmp(id, "username")) {
1264 g_free(cbdata->js->user->node); 1263 g_free(cbdata->js->user->node);
1265 cbdata->js->user->node = g_strdup(value); 1264 cbdata->js->user->node = g_strdup(value);
1266 } 1265 }
1267 if(cbdata->js->registration && !strcmp(id, "password")) 1266 if(cbdata->js->registration && !strcmp(id, "password"))
1268 purple_account_set_password(cbdata->js->gc->account, value); 1267 purple_account_set_password(purple_connection_get_account(cbdata->js->gc), value);
1269 } 1268 }
1270 } 1269 }
1271 } 1270 }
1272 1271
1273 if(cbdata->js->registration) { 1272 if(cbdata->js->registration) {
1274 username = g_strdup_printf("%s@%s%s%s", cbdata->js->user->node, cbdata->js->user->domain, 1273 username = g_strdup_printf("%s@%s%s%s", cbdata->js->user->node, cbdata->js->user->domain,
1275 cbdata->js->user->resource ? "/" : "", 1274 cbdata->js->user->resource ? "/" : "",
1276 cbdata->js->user->resource ? cbdata->js->user->resource : ""); 1275 cbdata->js->user->resource ? cbdata->js->user->resource : "");
1277 purple_account_set_username(cbdata->js->gc->account, username); 1276 purple_account_set_username(purple_connection_get_account(cbdata->js->gc), username);
1278 g_free(username); 1277 g_free(username);
1279 } 1278 }
1280 1279
1281 jabber_iq_set_callback(iq, jabber_registration_result_cb, cbdata->who); 1280 jabber_iq_set_callback(iq, jabber_registration_result_cb, cbdata->who);
1282 1281
1421 } 1420 }
1422 1421
1423 if((node = xmlnode_get_child(query, "name"))) { 1422 if((node = xmlnode_get_child(query, "name"))) {
1424 if(js->registration) 1423 if(js->registration)
1425 field = purple_request_field_string_new("name", _("Name"), 1424 field = purple_request_field_string_new("name", _("Name"),
1426 purple_account_get_alias(js->gc->account), FALSE); 1425 purple_account_get_alias(purple_connection_get_account(js->gc)), FALSE);
1427 else { 1426 else {
1428 char *data = xmlnode_get_data(node); 1427 char *data = xmlnode_get_data(node);
1429 field = purple_request_field_string_new("name", _("Name"), data, FALSE); 1428 field = purple_request_field_string_new("name", _("Name"), data, FALSE);
1430 g_free(data); 1429 g_free(data);
1431 } 1430 }
1555 1554
1556 void jabber_unregister_account(PurpleAccount *account, PurpleAccountUnregistrationCb cb, void *user_data) { 1555 void jabber_unregister_account(PurpleAccount *account, PurpleAccountUnregistrationCb cb, void *user_data) {
1557 PurpleConnection *gc = purple_account_get_connection(account); 1556 PurpleConnection *gc = purple_account_get_connection(account);
1558 JabberStream *js; 1557 JabberStream *js;
1559 1558
1560 if(gc->state != PURPLE_CONNECTED) { 1559 if (purple_connection_get_state(gc) != PURPLE_CONNECTED) {
1561 if(gc->state != PURPLE_CONNECTING) 1560 if (purple_connection_get_state(gc) != PURPLE_CONNECTING)
1562 jabber_login(account); 1561 jabber_login(account);
1563 js = purple_connection_get_protocol_data(gc); 1562 js = purple_connection_get_protocol_data(gc);
1564 js->unregistration = TRUE; 1563 js->unregistration = TRUE;
1565 js->unregistration_cb = cb; 1564 js->unregistration_cb = cb;
1566 js->unregistration_user_data = user_data; 1565 js->unregistration_user_data = user_data;
2485 { 2484 {
2486 if (type == JABBER_IQ_RESULT) { 2485 if (type == JABBER_IQ_RESULT) {
2487 purple_notify_info(js->gc, _("Password Changed"), _("Password Changed"), 2486 purple_notify_info(js->gc, _("Password Changed"), _("Password Changed"),
2488 _("Your password has been changed.")); 2487 _("Your password has been changed."));
2489 2488
2490 purple_account_set_password(js->gc->account, (char *)data); 2489 purple_account_set_password(purple_connection_get_account(js->gc), (char *)data);
2491 } else { 2490 } else {
2492 char *msg = jabber_parse_error(js, packet, NULL); 2491 char *msg = jabber_parse_error(js, packet, NULL);
2493 2492
2494 purple_notify_error(js->gc, _("Error changing password"), 2493 purple_notify_error(js->gc, _("Error changing password"),
2495 _("Error changing password"), msg); 2494 _("Error changing password"), msg);
2740 SET_REASON(PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE); 2739 SET_REASON(PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE);
2741 text = _("Authorization mechanism too weak"); 2740 text = _("Authorization mechanism too weak");
2742 } else if(xmlnode_get_child(packet, "not-authorized")) { 2741 } else if(xmlnode_get_child(packet, "not-authorized")) {
2743 SET_REASON(PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED); 2742 SET_REASON(PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED);
2744 /* Clear the pasword if it isn't being saved */ 2743 /* Clear the pasword if it isn't being saved */
2745 if (!purple_account_get_remember_password(js->gc->account)) 2744 if (!purple_account_get_remember_password(purple_connection_get_account(js->gc)))
2746 purple_account_set_password(js->gc->account, NULL); 2745 purple_account_set_password(purple_connection_get_account(js->gc), NULL);
2747 text = _("Not Authorized"); 2746 text = _("Not Authorized");
2748 } else if(xmlnode_get_child(packet, "temporary-auth-failure")) { 2747 } else if(xmlnode_get_child(packet, "temporary-auth-failure")) {
2749 text = _("Temporary Authentication Failure"); 2748 text = _("Temporary Authentication Failure");
2750 } else { 2749 } else {
2751 SET_REASON(PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED); 2750 SET_REASON(PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED);