Mercurial > pidgin
comparison libpurple/protocols/jabber/jabber.c @ 26612:28381a8889a8
This is a little less...repetitious
This is a little less...repetitious
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Fri, 17 Apr 2009 06:05:07 +0000 |
parents | 332d967670e0 |
children | 5149ecc8f456 |
comparison
equal
deleted
inserted
replaced
26611:472b0f3c36c3 | 26612:28381a8889a8 |
---|---|
988 | 988 |
989 jabber_iq_set_callback(iq, jabber_registration_result_cb, to); | 989 jabber_iq_set_callback(iq, jabber_registration_result_cb, to); |
990 jabber_iq_send(iq); | 990 jabber_iq_send(iq); |
991 } | 991 } |
992 | 992 |
993 static const struct { | |
994 const char *name; | |
995 const char *label; | |
996 } registration_fields[] = { | |
997 { "email", N_("Email") }, | |
998 { "nick", N_("Nickname") }, | |
999 { "first", N_("First name") }, | |
1000 { "last", N_("Last name") }, | |
1001 { "address", N_("Address") }, | |
1002 { "city", N_("City") }, | |
1003 { "state", N_("State") }, | |
1004 { "zip", N_("Postal code") }, | |
1005 { "phone", N_("Phone") }, | |
1006 { "url", N_("URL") }, | |
1007 { "date", N_("Date") }, | |
1008 { NULL, NULL } | |
1009 }; | |
1010 | |
993 void jabber_register_parse(JabberStream *js, const char *from, JabberIqType type, | 1011 void jabber_register_parse(JabberStream *js, const char *from, JabberIqType type, |
994 const char *id, xmlnode *query) | 1012 const char *id, xmlnode *query) |
995 { | 1013 { |
996 PurpleAccount *account = purple_connection_get_account(js->gc); | 1014 PurpleAccount *account = purple_connection_get_account(js->gc); |
997 PurpleRequestFields *fields; | 1015 PurpleRequestFields *fields; |
999 PurpleRequestField *field; | 1017 PurpleRequestField *field; |
1000 xmlnode *x, *y; | 1018 xmlnode *x, *y; |
1001 char *instructions; | 1019 char *instructions; |
1002 JabberRegisterCBData *cbdata; | 1020 JabberRegisterCBData *cbdata; |
1003 gboolean registered = FALSE; | 1021 gboolean registered = FALSE; |
1022 int i; | |
1004 | 1023 |
1005 if (type != JABBER_IQ_RESULT) | 1024 if (type != JABBER_IQ_RESULT) |
1006 return; | 1025 return; |
1007 | 1026 |
1008 if (!from) | 1027 if (!from) |
1073 field = purple_request_field_string_new("password", _("Password"), NULL, FALSE); | 1092 field = purple_request_field_string_new("password", _("Password"), NULL, FALSE); |
1074 | 1093 |
1075 purple_request_field_string_set_masked(field, TRUE); | 1094 purple_request_field_string_set_masked(field, TRUE); |
1076 purple_request_field_group_add_field(group, field); | 1095 purple_request_field_group_add_field(group, field); |
1077 } | 1096 } |
1097 | |
1078 if(xmlnode_get_child(query, "name")) { | 1098 if(xmlnode_get_child(query, "name")) { |
1079 if(js->registration) | 1099 if(js->registration) |
1080 field = purple_request_field_string_new("name", _("Name"), | 1100 field = purple_request_field_string_new("name", _("Name"), |
1081 purple_account_get_alias(js->gc->account), FALSE); | 1101 purple_account_get_alias(js->gc->account), FALSE); |
1082 else | 1102 else |
1083 field = purple_request_field_string_new("name", _("Name"), NULL, FALSE); | 1103 field = purple_request_field_string_new("name", _("Name"), NULL, FALSE); |
1084 purple_request_field_group_add_field(group, field); | 1104 purple_request_field_group_add_field(group, field); |
1085 } | 1105 } |
1086 if(xmlnode_get_child(query, "email")) { | 1106 |
1087 field = purple_request_field_string_new("email", _("Email"), NULL, FALSE); | 1107 for (i = 0; registration_fields[i].name != NULL; ++i) { |
1088 purple_request_field_group_add_field(group, field); | 1108 if (xmlnode_get_child(query, registration_fields[i].name)) { |
1089 } | 1109 field = purple_request_field_string_new(registration_fields[i].name, |
1090 if(xmlnode_get_child(query, "nick")) { | 1110 _(registration_fields[i].label), |
1091 field = purple_request_field_string_new("nick", _("Nickname"), NULL, FALSE); | 1111 NULL, FALSE); |
1092 purple_request_field_group_add_field(group, field); | 1112 purple_request_field_group_add_field(group, field); |
1093 } | 1113 } |
1094 if(xmlnode_get_child(query, "first")) { | 1114 } |
1095 field = purple_request_field_string_new("first", _("First name"), NULL, FALSE); | 1115 |
1096 purple_request_field_group_add_field(group, field); | |
1097 } | |
1098 if(xmlnode_get_child(query, "last")) { | |
1099 field = purple_request_field_string_new("last", _("Last name"), NULL, FALSE); | |
1100 purple_request_field_group_add_field(group, field); | |
1101 } | |
1102 if(xmlnode_get_child(query, "address")) { | |
1103 field = purple_request_field_string_new("address", _("Address"), NULL, FALSE); | |
1104 purple_request_field_group_add_field(group, field); | |
1105 } | |
1106 if(xmlnode_get_child(query, "city")) { | |
1107 field = purple_request_field_string_new("city", _("City"), NULL, FALSE); | |
1108 purple_request_field_group_add_field(group, field); | |
1109 } | |
1110 if(xmlnode_get_child(query, "state")) { | |
1111 field = purple_request_field_string_new("state", _("State"), NULL, FALSE); | |
1112 purple_request_field_group_add_field(group, field); | |
1113 } | |
1114 if(xmlnode_get_child(query, "zip")) { | |
1115 field = purple_request_field_string_new("zip", _("Postal code"), NULL, FALSE); | |
1116 purple_request_field_group_add_field(group, field); | |
1117 } | |
1118 if(xmlnode_get_child(query, "phone")) { | |
1119 field = purple_request_field_string_new("phone", _("Phone"), NULL, FALSE); | |
1120 purple_request_field_group_add_field(group, field); | |
1121 } | |
1122 if(xmlnode_get_child(query, "url")) { | |
1123 field = purple_request_field_string_new("url", _("URL"), NULL, FALSE); | |
1124 purple_request_field_group_add_field(group, field); | |
1125 } | |
1126 if(xmlnode_get_child(query, "date")) { | |
1127 field = purple_request_field_string_new("date", _("Date"), NULL, FALSE); | |
1128 purple_request_field_group_add_field(group, field); | |
1129 } | |
1130 if(registered) { | 1116 if(registered) { |
1131 field = purple_request_field_bool_new("unregister", _("Unregister"), FALSE); | 1117 field = purple_request_field_bool_new("unregister", _("Unregister"), FALSE); |
1132 purple_request_field_group_add_field(group, field); | 1118 purple_request_field_group_add_field(group, field); |
1133 } | 1119 } |
1134 | 1120 |