Mercurial > pidgin.yaz
comparison src/protocols/jabber/jabber.c @ 7124:be4ca65b3b48
[gaim-migrate @ 7691]
jabber password changing, and some other fix I forgot I made.
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Thu, 02 Oct 2003 04:56:25 +0000 |
parents | 6c8706109f92 |
children | 0e4894b3e2a6 |
comparison
equal
deleted
inserted
replaced
7123:d40966338ea6 | 7124:be4ca65b3b48 |
---|---|
183 } else if(!strcmp(packet->name, "presence")) { | 183 } else if(!strcmp(packet->name, "presence")) { |
184 jabber_presence_parse(js, packet); | 184 jabber_presence_parse(js, packet); |
185 } else if(!strcmp(packet->name, "message")) { | 185 } else if(!strcmp(packet->name, "message")) { |
186 jabber_message_parse(js, packet); | 186 jabber_message_parse(js, packet); |
187 } else if(!strcmp(packet->name, "stream:features")) { | 187 } else if(!strcmp(packet->name, "stream:features")) { |
188 if(js->state == JABBER_STREAM_AUTHENTICATING) { | 188 if(!js->registration && js->state == JABBER_STREAM_AUTHENTICATING) { |
189 jabber_auth_start(js, packet); | 189 jabber_auth_start(js, packet); |
190 } else if(js->state == JABBER_STREAM_REINITIALIZING) { | 190 } else if(js->state == JABBER_STREAM_REINITIALIZING) { |
191 jabber_session_init(js); | 191 jabber_session_init(js); |
192 } else { | 192 } else { |
193 gaim_debug(GAIM_DEBUG_WARNING, "jabber", | 193 gaim_debug(GAIM_DEBUG_WARNING, "jabber", |
842 m = g_list_append(m, GAIM_AWAY_CUSTOM); | 842 m = g_list_append(m, GAIM_AWAY_CUSTOM); |
843 | 843 |
844 return m; | 844 return m; |
845 } | 845 } |
846 | 846 |
847 static void jabber_password_change_result_cb(JabberStream *js, xmlnode *packet) | |
848 { | |
849 const char *type; | |
850 | |
851 type = xmlnode_get_attrib(packet, "type"); | |
852 | |
853 if(!strcmp(type, "result")) { | |
854 gaim_notify_info(js->gc, _("Password Changed"), _("Password Changed"), | |
855 _("Your password has been changed.")); | |
856 } else { | |
857 xmlnode *error; | |
858 char *buf, *error_txt = NULL; | |
859 | |
860 | |
861 if((error = xmlnode_get_child(packet, "error"))) | |
862 error_txt = xmlnode_get_data(error); | |
863 | |
864 if(error_txt) { | |
865 buf = g_strdup_printf(_("Error changing password: %s"), | |
866 error_txt); | |
867 g_free(error_txt); | |
868 } else { | |
869 buf = g_strdup(_("Unknown error occurred changing password")); | |
870 } | |
871 | |
872 gaim_notify_error(js->gc, _("Error"), _("Error"), buf); | |
873 g_free(buf); | |
874 } | |
875 } | |
876 | |
877 static void jabber_password_change_cb(JabberStream *js, | |
878 GaimRequestFields *fields) | |
879 { | |
880 const char *p1, *p2; | |
881 JabberIq *iq; | |
882 xmlnode *query, *y; | |
883 | |
884 p1 = gaim_request_fields_get_string(fields, "password1"); | |
885 p2 = gaim_request_fields_get_string(fields, "password2"); | |
886 | |
887 if(strcmp(p1, p2)) { | |
888 gaim_notify_error(js->gc, NULL, _("New passwords do not match."), NULL); | |
889 return; | |
890 } | |
891 | |
892 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); | |
893 | |
894 xmlnode_set_attrib(iq->node, "to", js->user->domain); | |
895 | |
896 query = xmlnode_get_child(iq->node, "query"); | |
897 | |
898 y = xmlnode_new_child(query, "username"); | |
899 xmlnode_insert_data(y, js->user->node, -1); | |
900 y = xmlnode_new_child(query, "password"); | |
901 xmlnode_insert_data(y, p1, -1); | |
902 | |
903 jabber_iq_set_callback(iq, jabber_password_change_result_cb); | |
904 | |
905 jabber_iq_send(iq); | |
906 | |
907 gaim_account_set_password(js->gc->account, p1); | |
908 } | |
909 | |
910 static void jabber_password_change(GaimConnection *gc) | |
911 { | |
912 JabberStream *js = gc->proto_data; | |
913 GaimRequestFields *fields; | |
914 GaimRequestFieldGroup *group; | |
915 GaimRequestField *field; | |
916 | |
917 fields = gaim_request_fields_new(); | |
918 group = gaim_request_field_group_new(NULL); | |
919 gaim_request_fields_add_group(fields, group); | |
920 | |
921 field = gaim_request_field_string_new("password1", _("Password"), | |
922 "", FALSE); | |
923 gaim_request_field_string_set_masked(field, TRUE); | |
924 gaim_request_field_group_add_field(group, field); | |
925 | |
926 field = gaim_request_field_string_new("password2", _("Password (again)"), | |
927 "", FALSE); | |
928 gaim_request_field_string_set_masked(field, TRUE); | |
929 gaim_request_field_group_add_field(group, field); | |
930 | |
931 gaim_request_fields(js->gc, _("Change Jabber Password"), | |
932 _("Change Jabber Password"), _("Please enter your new password"), | |
933 fields, _("OK"), G_CALLBACK(jabber_password_change_cb), | |
934 _("Cancel"), NULL, js); | |
935 } | |
936 | |
847 static GList *jabber_actions(GaimConnection *gc) | 937 static GList *jabber_actions(GaimConnection *gc) |
848 { | 938 { |
939 JabberStream *js = gc->proto_data; | |
849 GList *m = NULL; | 940 GList *m = NULL; |
850 struct proto_actions_menu *pam; | 941 struct proto_actions_menu *pam; |
851 | 942 |
852 pam = g_new0(struct proto_actions_menu, 1); | 943 pam = g_new0(struct proto_actions_menu, 1); |
853 pam->label = _("Set User Info"); | 944 pam->label = _("Set User Info"); |
854 pam->callback = jabber_setup_set_info; | 945 pam->callback = jabber_setup_set_info; |
855 pam->gc = gc; | 946 pam->gc = gc; |
856 m = g_list_append(m, pam); | 947 m = g_list_append(m, pam); |
857 | 948 |
858 /* XXX: Change Password */ | 949 if(js->protocol_version == JABBER_PROTO_0_9) { |
950 pam = g_new0(struct proto_actions_menu, 1); | |
951 pam->label = _("Change Password"); | |
952 pam->callback = jabber_password_change; | |
953 pam->gc = gc; | |
954 m = g_list_append(m, pam); | |
955 } | |
859 | 956 |
860 return m; | 957 return m; |
861 } | 958 } |
862 | 959 |
863 static GaimPluginProtocolInfo prpl_info = | 960 static GaimPluginProtocolInfo prpl_info = |
945 init_plugin(GaimPlugin *plugin) | 1042 init_plugin(GaimPlugin *plugin) |
946 { | 1043 { |
947 GaimAccountUserSplit *split; | 1044 GaimAccountUserSplit *split; |
948 GaimAccountOption *option; | 1045 GaimAccountOption *option; |
949 | 1046 |
950 /* Ugly Hack for SSL */ | |
951 GaimPlugin *ssl_plugin; | |
952 ssl_plugin = gaim_plugins_find_with_id("core-ssl"); | |
953 if (ssl_plugin != NULL && !gaim_plugin_is_loaded(ssl_plugin)) | |
954 gaim_plugin_load(ssl_plugin); | |
955 | |
956 split = gaim_account_user_split_new(_("Server"), "jabber.org", '@'); | 1047 split = gaim_account_user_split_new(_("Server"), "jabber.org", '@'); |
957 prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); | 1048 prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); |
958 | 1049 |
959 split = gaim_account_user_split_new(_("Resource"), "Gaim", '/'); | 1050 split = gaim_account_user_split_new(_("Resource"), "Gaim", '/'); |
960 prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); | 1051 prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); |
961 | 1052 |
962 if(gaim_ssl_is_supported()) { | 1053 option = gaim_account_option_bool_new(_("Force Old SSL"), "old_ssl", FALSE); |
963 option = gaim_account_option_bool_new(_("Force Old SSL"), "old_ssl", FALSE); | 1054 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
964 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | 1055 option); |
965 option); | |
966 } | |
967 | 1056 |
968 option = gaim_account_option_int_new(_("Port"), "port", 5222); | 1057 option = gaim_account_option_int_new(_("Port"), "port", 5222); |
969 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | 1058 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
970 option); | 1059 option); |
971 | 1060 |