Mercurial > pidgin
comparison src/protocols/jabber/jabber.c @ 3257:4c28751180f9
[gaim-migrate @ 3275]
Change password on Jabber server (Thanks, Nathan Walp)
committer: Tailor Script <tailor@pidgin.im>
author | Jim Seymour <jseymour> |
---|---|
date | Sat, 18 May 2002 15:42:01 +0000 |
parents | d7ae897770d9 |
children | 8b1309bea7e5 |
comparison
equal
deleted
inserted
replaced
3256:a7c241854218 | 3257:4c28751180f9 |
---|---|
212 | 212 |
213 if((gjc->user = jid_new(p, user)) == NULL) { | 213 if((gjc->user = jid_new(p, user)) == NULL) { |
214 pool_free(p); /* no need for this anymore! */ | 214 pool_free(p); /* no need for this anymore! */ |
215 return (NULL); | 215 return (NULL); |
216 } | 216 } |
217 gjc->pass = pstrdup(p, pass); | 217 |
218 gjc->pass = strdup(pass); | |
218 | 219 |
219 gjc->state = JCONN_STATE_OFF; | 220 gjc->state = JCONN_STATE_OFF; |
220 gjc->was_connected = 0; | 221 gjc->was_connected = 0; |
221 gjc->id = 1; | 222 gjc->id = 1; |
222 gjc->fd = -1; | 223 gjc->fd = -1; |
230 { | 231 { |
231 if (!gjc) | 232 if (!gjc) |
232 return; | 233 return; |
233 | 234 |
234 gjab_stop(gjc); | 235 gjab_stop(gjc); |
236 free(gjc->pass); | |
235 pool_free(gjc->p); | 237 pool_free(gjc->p); |
236 } | 238 } |
237 | 239 |
238 static void gjab_state_handler(gjconn gjc, gjconn_state_h h) | 240 static void gjab_state_handler(gjconn gjc, gjconn_state_h h) |
239 { | 241 { |
701 remove_buddy(gc, group, b); | 703 remove_buddy(gc, group, b); |
702 do_export(gc); | 704 do_export(gc); |
703 } | 705 } |
704 } | 706 } |
705 | 707 |
708 static void jabber_change_passwd(struct gaim_connection *gc, char *old, char *new) | |
709 { | |
710 gjconn gjc = ((struct jabber_data *)gc->proto_data)->gjc; | |
711 | |
712 if(strcmp(old, gjc->pass)) | |
713 { | |
714 do_error_dialog(_("Incorrect current password! Password NOT Changed!"), | |
715 _("Password Change Error!")); | |
716 } | |
717 else if(!strcmp(old, new)) | |
718 { | |
719 do_error_dialog(_("New password same as old password! Password NOT Changed!"), | |
720 _("Password Change Error!")); | |
721 } | |
722 else | |
723 { | |
724 xmlnode x, y, z; | |
725 char *id; | |
726 | |
727 x = jutil_iqnew(JPACKET__SET, NS_REGISTER); | |
728 xmlnode_put_attrib(x, "to", gjc->user->server); | |
729 y = xmlnode_get_tag(x, "query"); | |
730 z = xmlnode_insert_tag(y, "username"); | |
731 xmlnode_insert_cdata(z, gjc->user->user, -1); | |
732 z = xmlnode_insert_tag(y, "password"); | |
733 xmlnode_insert_cdata(z, new, -1); | |
734 | |
735 id = gjab_getid(gjc); | |
736 xmlnode_put_attrib(x, "id", id); | |
737 | |
738 free(gjc->pass); | |
739 gjc->pass = strdup(new); | |
740 | |
741 g_hash_table_insert(gjc->queries, g_strdup(id), g_strdup("change_password")); | |
742 | |
743 gjab_send(gjc, x); | |
744 xmlnode_free(x); | |
745 } | |
746 } | |
747 | |
706 /* | 748 /* |
707 * keep track of away msg same as yahoo plugin | 749 * keep track of away msg same as yahoo plugin |
708 */ | 750 */ |
709 static void jabber_track_away(gjconn gjc, jpacket p, char *name, char *type) | 751 static void jabber_track_away(gjconn gjc, jpacket p, char *name, char *type) |
710 { | 752 { |
1549 /* | 1591 /* |
1550 * No actual vCard, but there's other stuff. This | 1592 * No actual vCard, but there's other stuff. This |
1551 * way the user always gets some kind of response. | 1593 * way the user always gets some kind of response. |
1552 */ | 1594 */ |
1553 jabber_handlevcard(gjc, NULL, from); | 1595 jabber_handlevcard(gjc, NULL, from); |
1596 } else if(!strcmp((char *) val, "change_password")) { | |
1597 char buf[BUF_LONG]; | |
1598 sprintf(buf,_("Password successfully changed.")); | |
1599 | |
1600 do_error_dialog(buf, _("Password Change")); | |
1554 } | 1601 } |
1555 } | 1602 } |
1556 } | 1603 } |
1557 | 1604 |
1558 } else if (jpacket_subtype(p) == JPACKET__ERROR) { | 1605 } else if (jpacket_subtype(p) == JPACKET__ERROR) { |
3125 if (!strcmp(act, _("Set User Info"))) { | 3172 if (!strcmp(act, _("Set User Info"))) { |
3126 jabber_setup_set_info(gc); | 3173 jabber_setup_set_info(gc); |
3127 /* | 3174 /* |
3128 } else if (!strcmp(act, _("Set Dir Info"))) { | 3175 } else if (!strcmp(act, _("Set Dir Info"))) { |
3129 show_set_dir(gc); | 3176 show_set_dir(gc); |
3177 */ | |
3130 } else if (!strcmp(act, _("Change Password"))) { | 3178 } else if (!strcmp(act, _("Change Password"))) { |
3131 show_change_passwd(gc); | 3179 show_change_passwd(gc); |
3132 */ | |
3133 } | 3180 } |
3134 } | 3181 } |
3135 | 3182 |
3136 static GList *jabber_actions() | 3183 static GList *jabber_actions() |
3137 { | 3184 { |
3138 GList *m = NULL; | 3185 GList *m = NULL; |
3139 | 3186 |
3140 m = g_list_append(m, _("Set User Info")); | 3187 m = g_list_append(m, _("Set User Info")); |
3141 /* | 3188 /* |
3142 m = g_list_append(m, _("Set Dir Info")); | 3189 m = g_list_append(m, _("Set Dir Info")); |
3190 */ | |
3143 m = g_list_append(m, _("Change Password")); | 3191 m = g_list_append(m, _("Change Password")); |
3144 */ | |
3145 | 3192 |
3146 return m; | 3193 return m; |
3147 } | 3194 } |
3148 | 3195 |
3149 static struct prpl *my_protocol = NULL; | 3196 static struct prpl *my_protocol = NULL; |
3170 ret->set_away = jabber_set_away; | 3217 ret->set_away = jabber_set_away; |
3171 ret->set_dir = NULL; | 3218 ret->set_dir = NULL; |
3172 ret->get_dir = NULL; | 3219 ret->get_dir = NULL; |
3173 ret->dir_search = NULL; | 3220 ret->dir_search = NULL; |
3174 ret->set_idle = jabber_set_idle; | 3221 ret->set_idle = jabber_set_idle; |
3175 ret->change_passwd = NULL; | 3222 ret->change_passwd = jabber_change_passwd; |
3176 ret->add_buddy = jabber_add_buddy; | 3223 ret->add_buddy = jabber_add_buddy; |
3177 ret->add_buddies = NULL; | 3224 ret->add_buddies = NULL; |
3178 ret->remove_buddy = jabber_remove_buddy; | 3225 ret->remove_buddy = jabber_remove_buddy; |
3179 ret->add_permit = NULL; | 3226 ret->add_permit = NULL; |
3180 ret->add_deny = NULL; | 3227 ret->add_deny = NULL; |