Mercurial > pidgin
comparison libpurple/protocols/jabber/jabber.c @ 18920:2a9d60d7af82
Implemented a callback for unregistering, mirroring the registration callback. Since this is a new API, I can do it properly by passing it right in the unregister function call, instead of having a separate function for setting it.
author | Andreas Monitzer <pidgin@monitzer.com> |
---|---|
date | Tue, 31 Jul 2007 03:50:41 +0000 |
parents | 177552010f1d |
children | ba3b22cd280b |
comparison
equal
deleted
inserted
replaced
18919:177552010f1d | 18920:2a9d60d7af82 |
---|---|
1118 } | 1118 } |
1119 } | 1119 } |
1120 } | 1120 } |
1121 | 1121 |
1122 static void jabber_unregister_account_iq_cb(JabberStream *js, xmlnode *packet, gpointer data) { | 1122 static void jabber_unregister_account_iq_cb(JabberStream *js, xmlnode *packet, gpointer data) { |
1123 PurpleAccount *account = purple_connection_get_account(js->gc); | |
1123 const char *type = xmlnode_get_attrib(packet,"type"); | 1124 const char *type = xmlnode_get_attrib(packet,"type"); |
1124 if(!strcmp(type,"error")) { | 1125 if(!strcmp(type,"error")) { |
1125 char *msg = jabber_parse_error(js, packet); | 1126 char *msg = jabber_parse_error(js, packet); |
1126 | 1127 |
1127 purple_notify_error(js->gc, _("Error unregistering account"), | 1128 purple_notify_error(js->gc, _("Error unregistering account"), |
1128 _("Error unregistering account"), msg); | 1129 _("Error unregistering account"), msg); |
1129 g_free(msg); | 1130 g_free(msg); |
1131 if(js->unregistration_cb) | |
1132 js->unregistration_cb(account, TRUE, js->unregistration_user_data); | |
1130 } else if(!strcmp(type,"result")) { | 1133 } else if(!strcmp(type,"result")) { |
1131 purple_notify_info(js->gc, _("Account successfully unregistered"), | 1134 purple_notify_info(js->gc, _("Account successfully unregistered"), |
1132 _("Account successfully unregistered"), NULL); | 1135 _("Account successfully unregistered"), NULL); |
1136 if(js->unregistration_cb) | |
1137 js->unregistration_cb(account, FALSE, js->unregistration_user_data); | |
1133 } | 1138 } |
1134 } | 1139 } |
1135 | 1140 |
1136 static void jabber_unregister_account_cb(JabberStream *js) { | 1141 static void jabber_unregister_account_cb(JabberStream *js) { |
1137 JabberIq *iq; | 1142 JabberIq *iq; |
1148 jabber_iq_set_callback(iq,jabber_unregister_account_iq_cb,NULL); | 1153 jabber_iq_set_callback(iq,jabber_unregister_account_iq_cb,NULL); |
1149 | 1154 |
1150 jabber_iq_send(iq); | 1155 jabber_iq_send(iq); |
1151 } | 1156 } |
1152 | 1157 |
1153 void jabber_unregister_account(PurpleAccount *account) { | 1158 void jabber_unregister_account(PurpleAccount *account, PurpleAccountUnregistrationCb cb, void *user_data) { |
1154 PurpleConnection *gc = purple_account_get_connection(account); | 1159 PurpleConnection *gc = purple_account_get_connection(account); |
1155 JabberStream *js; | 1160 JabberStream *js; |
1156 | 1161 |
1157 if(gc->state != PURPLE_CONNECTED) { | 1162 if(gc->state != PURPLE_CONNECTED) { |
1158 if(gc->state != PURPLE_CONNECTING) | 1163 if(gc->state != PURPLE_CONNECTING) |
1159 jabber_login(account); | 1164 jabber_login(account); |
1160 js = gc->proto_data; | 1165 js = gc->proto_data; |
1161 js->unregistration = TRUE; | 1166 js->unregistration = TRUE; |
1167 js->unregistration_cb = cb; | |
1168 js->unregistration_user_data = user_data; | |
1162 return; | 1169 return; |
1163 } | 1170 } |
1164 | 1171 |
1165 js = gc->proto_data; | 1172 js = gc->proto_data; |
1166 assert(!js->unregistration); /* don't allow multiple calls */ | 1173 assert(!js->unregistration); /* don't allow multiple calls */ |
1167 js->unregistration = TRUE; | 1174 js->unregistration = TRUE; |
1175 js->unregistration_cb = cb; | |
1176 js->unregistration_user_data = user_data; | |
1168 | 1177 |
1169 jabber_unregister_account_cb(js); | 1178 jabber_unregister_account_cb(js); |
1170 } | 1179 } |
1171 | 1180 |
1172 void jabber_close(PurpleConnection *gc) | 1181 void jabber_close(PurpleConnection *gc) |