comparison libpurple/protocols/jabber/jabber.c @ 25101:b90c26f391b0

Don't send a 'to' attribute on an outgoing stanza if we didn't receive one. Fixes #6635, but there is another patch there that probably should be considered. committer: John Bailey <rekkanoryo@rekkanoryo.org>
author Paul Aurich <paul@darkrain42.org>
date Sun, 15 Feb 2009 21:26:22 +0000
parents 43055addf135
children a1a0293df07f 4b8c4870b13a 394252b681bc 3a0c2526364f f424f26dd329 754d7d478066 9fcff08ce726 25319f536d93 e0e0cecdcd16
comparison
equal deleted inserted replaced
25100:ede59a571c0a 25101:b90c26f391b0
807 if(js->registration) { 807 if(js->registration) {
808 buf = g_strdup_printf(_("Registration of %s@%s successful"), 808 buf = g_strdup_printf(_("Registration of %s@%s successful"),
809 js->user->node, js->user->domain); 809 js->user->node, js->user->domain);
810 if(account->registration_cb) 810 if(account->registration_cb)
811 (account->registration_cb)(account, TRUE, account->registration_cb_user_data); 811 (account->registration_cb)(account, TRUE, account->registration_cb_user_data);
812 } 812 } else {
813 else 813 g_return_if_fail(to != NULL);
814 buf = g_strdup_printf(_("Registration to %s successful"), 814 buf = g_strdup_printf(_("Registration to %s successful"),
815 to); 815 to);
816 }
816 purple_notify_info(NULL, _("Registration Successful"), 817 purple_notify_info(NULL, _("Registration Successful"),
817 _("Registration Successful"), buf); 818 _("Registration Successful"), buf);
818 g_free(buf); 819 g_free(buf);
819 } else { 820 } else {
820 char *msg = jabber_parse_error(js, packet, NULL); 821 char *msg = jabber_parse_error(js, packet, NULL);
837 jabber_unregistration_result_cb(JabberStream *js, xmlnode *packet, gpointer data) 838 jabber_unregistration_result_cb(JabberStream *js, xmlnode *packet, gpointer data)
838 { 839 {
839 const char *type = xmlnode_get_attrib(packet, "type"); 840 const char *type = xmlnode_get_attrib(packet, "type");
840 char *buf; 841 char *buf;
841 char *to = data; 842 char *to = data;
842 843
844 /* This function is never called for unregistering our XMPP account from
845 * the server, so there should always be a 'to' address. */
846 g_return_if_fail(to != NULL);
847
843 if(!strcmp(type, "result")) { 848 if(!strcmp(type, "result")) {
844 buf = g_strdup_printf(_("Registration from %s successfully removed"), 849 buf = g_strdup_printf(_("Registration from %s successfully removed"),
845 to); 850 to);
846 purple_notify_info(NULL, _("Unregistration Successful"), 851 purple_notify_info(NULL, _("Unregistration Successful"),
847 _("Unregistration Successful"), buf); 852 _("Unregistration Successful"), buf);
872 JabberIq *iq; 877 JabberIq *iq;
873 char *username; 878 char *username;
874 879
875 iq = jabber_iq_new_query(cbdata->js, JABBER_IQ_SET, "jabber:iq:register"); 880 iq = jabber_iq_new_query(cbdata->js, JABBER_IQ_SET, "jabber:iq:register");
876 query = xmlnode_get_child(iq->node, "query"); 881 query = xmlnode_get_child(iq->node, "query");
877 xmlnode_set_attrib(iq->node, "to", cbdata->who); 882 if (cbdata->who)
883 xmlnode_set_attrib(iq->node, "to", cbdata->who);
878 884
879 for(groups = purple_request_fields_get_groups(fields); groups; 885 for(groups = purple_request_fields_get_groups(fields); groups;
880 groups = groups->next) { 886 groups = groups->next) {
881 for(flds = purple_request_field_group_get_fields(groups->data); 887 for(flds = purple_request_field_group_get_fields(groups->data);
882 flds; flds = flds->next) { 888 flds; flds = flds->next) {
888 /* unregister from service. this doesn't include any of the fields, so remove them from the stanza by recreating it 894 /* unregister from service. this doesn't include any of the fields, so remove them from the stanza by recreating it
889 (there's no "remove child" function for xmlnode) */ 895 (there's no "remove child" function for xmlnode) */
890 jabber_iq_free(iq); 896 jabber_iq_free(iq);
891 iq = jabber_iq_new_query(cbdata->js, JABBER_IQ_SET, "jabber:iq:register"); 897 iq = jabber_iq_new_query(cbdata->js, JABBER_IQ_SET, "jabber:iq:register");
892 query = xmlnode_get_child(iq->node, "query"); 898 query = xmlnode_get_child(iq->node, "query");
893 xmlnode_set_attrib(iq->node,"to",cbdata->who); 899 if (cbdata->who)
900 xmlnode_set_attrib(iq->node,"to",cbdata->who);
894 xmlnode_new_child(query, "remove"); 901 xmlnode_new_child(query, "remove");
895 902
896 jabber_iq_set_callback(iq, jabber_unregistration_result_cb, cbdata->who); 903 jabber_iq_set_callback(iq, jabber_unregistration_result_cb, cbdata->who);
897 904
898 jabber_iq_send(iq); 905 jabber_iq_send(iq);
933 } else { 940 } else {
934 continue; 941 continue;
935 } 942 }
936 xmlnode_insert_data(y, value, -1); 943 xmlnode_insert_data(y, value, -1);
937 if(cbdata->js->registration && !strcmp(id, "username")) { 944 if(cbdata->js->registration && !strcmp(id, "username")) {
938 if(cbdata->js->user->node) 945 g_free(cbdata->js->user->node);
939 g_free(cbdata->js->user->node);
940 cbdata->js->user->node = g_strdup(value); 946 cbdata->js->user->node = g_strdup(value);
941 } 947 }
942 if(cbdata->js->registration && !strcmp(id, "password")) 948 if(cbdata->js->registration && !strcmp(id, "password"))
943 purple_account_set_password(cbdata->js->gc->account, value); 949 purple_account_set_password(cbdata->js->gc->account, value);
944 } 950 }
977 JabberIq *iq; 983 JabberIq *iq;
978 char *to = data; 984 char *to = data;
979 985
980 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); 986 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register");
981 query = xmlnode_get_child(iq->node, "query"); 987 query = xmlnode_get_child(iq->node, "query");
982 xmlnode_set_attrib(iq->node,"to",to); 988 if (to)
989 xmlnode_set_attrib(iq->node,"to",to);
983 990
984 xmlnode_insert_child(query, result); 991 xmlnode_insert_child(query, result);
985 992
986 jabber_iq_set_callback(iq, jabber_registration_result_cb, to); 993 jabber_iq_set_callback(iq, jabber_registration_result_cb, to);
987 jabber_iq_send(iq); 994 jabber_iq_send(iq);
1002 1009
1003 if(!(type = xmlnode_get_attrib(packet, "type")) || strcmp(type, "result")) 1010 if(!(type = xmlnode_get_attrib(packet, "type")) || strcmp(type, "result"))
1004 return; 1011 return;
1005 1012
1006 from = xmlnode_get_attrib(packet, "from"); 1013 from = xmlnode_get_attrib(packet, "from");
1007 if (!from) 1014
1008 from = js->serverFQDN;
1009 g_return_if_fail(from != NULL);
1010
1011 if(js->registration) { 1015 if(js->registration) {
1012 /* get rid of the login thingy */ 1016 /* get rid of the login thingy */
1013 purple_connection_set_state(js->gc, PURPLE_CONNECTED); 1017 purple_connection_set_state(js->gc, PURPLE_CONNECTED);
1014 } 1018 }
1015 1019
1150 _("Register"), G_CALLBACK(jabber_register_cb), 1154 _("Register"), G_CALLBACK(jabber_register_cb),
1151 _("Cancel"), G_CALLBACK(jabber_register_cancel_cb), 1155 _("Cancel"), G_CALLBACK(jabber_register_cancel_cb),
1152 purple_connection_get_account(js->gc), NULL, NULL, 1156 purple_connection_get_account(js->gc), NULL, NULL,
1153 cbdata); 1157 cbdata);
1154 else { 1158 else {
1155 char *title = registered?g_strdup_printf(_("Change Account Registration at %s"), from) 1159 char *title;
1160 g_return_if_fail(from != NULL);
1161 title = registered ? g_strdup_printf(_("Change Account Registration at %s"), from)
1156 :g_strdup_printf(_("Register New Account at %s"), from); 1162 :g_strdup_printf(_("Register New Account at %s"), from);
1157 purple_request_fields(js->gc, title, 1163 purple_request_fields(js->gc, title,
1158 title, instructions, fields, 1164 title, instructions, fields,
1159 (registered ? _("Change Registration") : _("Register")), G_CALLBACK(jabber_register_cb), 1165 (registered ? _("Change Registration") : _("Register")), G_CALLBACK(jabber_register_cb),
1160 _("Cancel"), G_CALLBACK(jabber_register_cancel_cb), 1166 _("Cancel"), G_CALLBACK(jabber_register_cancel_cb),