Mercurial > pidgin
comparison src/protocols/jabber/jabber.c @ 6339:cc527f9ba197
[gaim-migrate @ 6838]
Jabber no longer uses the vcard API stuff, and now uses the multi-field
dialog stuff. Jabber is now core/UI split!! Hurray! Now I can access my
Jabber accounts on my PDA.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Wed, 30 Jul 2003 08:09:54 +0000 |
parents | 3613007cbb6e |
children | 1fa4410d2e13 |
comparison
equal
deleted
inserted
replaced
6338:644ebf75f686 | 6339:cc527f9ba197 |
---|---|
3660 {NULL, NULL}, | 3660 {NULL, NULL}, |
3661 }; | 3661 }; |
3662 | 3662 |
3663 | 3663 |
3664 /* | 3664 /* |
3665 * V-Card user instructions | |
3666 */ | |
3667 static char *multi_entry_instructions = | |
3668 N_("All items below are optional. Enter only the information with which you feel comfortable"); | |
3669 static char *entries_title = N_("User Identity"); | |
3670 | |
3671 /* | |
3672 * Used by routines to parse an XML-encoded string into an xmlnode tree | 3665 * Used by routines to parse an XML-encoded string into an xmlnode tree |
3673 */ | 3666 */ |
3674 typedef struct { | 3667 typedef struct { |
3675 XML_Parser parser; | 3668 XML_Parser parser; |
3676 xmlnode current; | 3669 xmlnode current; |
3957 * to said string. | 3950 * to said string. |
3958 * | 3951 * |
3959 * g_free()'ing the returned string space is the responsibility of | 3952 * g_free()'ing the returned string space is the responsibility of |
3960 * the caller. | 3953 * the caller. |
3961 */ | 3954 */ |
3962 static gchar *jabber_format_info(MultiEntryDlg *b) | 3955 static void |
3963 { | 3956 jabber_format_info(GaimConnection *gc, GaimRequestFields *fields) |
3957 { | |
3958 GaimAccount *account; | |
3964 xmlnode vc_node; | 3959 xmlnode vc_node; |
3965 GSList *list; | 3960 GaimRequestField *field; |
3966 MultiEntryData *med; | 3961 const char *text; |
3967 MultiTextData *mtd; | |
3968 char *p; | 3962 char *p; |
3969 | 3963 const struct vcard_template *vc_tp; |
3970 struct tag_attr *tag_attr; | 3964 struct tag_attr *tag_attr; |
3971 | 3965 |
3972 vc_node = xmlnode_new_tag("vCard"); | 3966 vc_node = xmlnode_new_tag("vCard"); |
3973 | 3967 |
3974 for(tag_attr = vcard_tag_attr_list; tag_attr->attr != NULL; ++tag_attr) | 3968 for(tag_attr = vcard_tag_attr_list; tag_attr->attr != NULL; ++tag_attr) |
3975 xmlnode_put_attrib(vc_node, tag_attr->attr, tag_attr->value); | 3969 xmlnode_put_attrib(vc_node, tag_attr->attr, tag_attr->value); |
3976 | 3970 |
3977 for(list = b->multi_entry_items; list != NULL; list = list->next) { | 3971 for (vc_tp = vcard_template_data; vc_tp->label != NULL; vc_tp++) { |
3978 med = (MultiEntryData *) list->data; | 3972 if (*vc_tp->label == '\0') |
3979 if(med->label != NULL && med->text != NULL && (med->text)[0] != '\0') { | 3973 continue; |
3980 if((p = tag_for_label(med->label)) != NULL) { | 3974 |
3981 xmlnode xp; | 3975 field = gaim_request_fields_get_field(fields, vc_tp->tag); |
3982 if((xp = insert_tag_to_parent_tag(vc_node, NULL, p)) != NULL) { | 3976 text = gaim_request_field_string_get_value(field); |
3983 xmlnode_insert_cdata(xp, med->text, -1); | 3977 |
3984 } | 3978 gaim_debug(GAIM_DEBUG_INFO, "jabber", |
3979 "Setting %s to '%s'\n", vc_tp->tag, text); | |
3980 | |
3981 if (text != NULL && *text != '\0') { | |
3982 xmlnode xp; | |
3983 | |
3984 if ((xp = insert_tag_to_parent_tag(vc_node, | |
3985 NULL, vc_tp->tag)) != NULL) { | |
3986 | |
3987 xmlnode_insert_cdata(xp, text, -1); | |
3985 } | 3988 } |
3986 } | 3989 } |
3987 } | 3990 } |
3988 | |
3989 for(list = b->multi_text_items; list != NULL; list = list->next) { | |
3990 mtd = (MultiTextData *) list->data; | |
3991 if(mtd->label != NULL && mtd->text != NULL && (mtd->text)[0] != '\0') { | |
3992 if((p = tag_for_label(mtd->label)) != NULL) { | |
3993 xmlnode xp; | |
3994 if((xp = insert_tag_to_parent_tag(vc_node, NULL, p)) != NULL) { | |
3995 xmlnode_insert_cdata(xp, mtd->text, -1); | |
3996 } | |
3997 } | |
3998 } | |
3999 } | |
4000 | |
4001 | 3991 |
4002 p = g_strdup(xmlnode2str(vc_node)); | 3992 p = g_strdup(xmlnode2str(vc_node)); |
4003 xmlnode_free(vc_node); | 3993 xmlnode_free(vc_node); |
4004 | 3994 |
4005 return(p); | 3995 account = gaim_connection_get_account(gc); |
3996 | |
3997 if (account != NULL) { | |
3998 gaim_account_set_user_info(account, p); | |
3999 | |
4000 if (gc != NULL) | |
4001 serv_set_info(gc, p); | |
4002 } | |
4003 | |
4004 g_free(p); | |
4006 } | 4005 } |
4007 | 4006 |
4008 /* | 4007 /* |
4009 * This gets executed by the proto action | 4008 * This gets executed by the proto action |
4010 * | 4009 * |
4011 * Creates a new MultiEntryDlg struct, gets the XML-formatted user_info | 4010 * Creates a new GaimRequestFields struct, gets the XML-formatted user_info |
4012 * string (if any) into GSLists for the (multi-entry) edit dialog and | 4011 * string (if any) into GSLists for the (multi-entry) edit dialog and |
4013 * calls the set_vcard dialog. | 4012 * calls the set_vcard dialog. |
4014 */ | 4013 */ |
4015 static void jabber_setup_set_info(GaimConnection *gc) | 4014 static void jabber_setup_set_info(GaimConnection *gc) |
4016 { | 4015 { |
4017 MultiEntryData *data; | 4016 GaimRequestFields *fields; |
4017 GaimRequestFieldGroup *group; | |
4018 GaimRequestField *field; | |
4018 const struct vcard_template *vc_tp; | 4019 const struct vcard_template *vc_tp; |
4019 char *user_info; | 4020 char *user_info; |
4020 MultiEntryDlg *b = multi_entry_dialog_new(); | |
4021 char *cdata; | 4021 char *cdata; |
4022 xmlnode x_vc_data = NULL; | 4022 xmlnode x_vc_data = NULL; |
4023 | 4023 |
4024 b->account = gc->account; | 4024 fields = gaim_request_fields_new(); |
4025 | 4025 group = gaim_request_field_group_new(NULL); |
4026 gaim_request_fields_add_group(fields, group); | |
4026 | 4027 |
4027 /* | 4028 /* |
4028 * Get existing, XML-formatted, user info | 4029 * Get existing, XML-formatted, user info |
4029 */ | 4030 */ |
4030 if((user_info = g_strdup(gaim_account_get_user_info(gc->account))) != NULL) | 4031 if((user_info = g_strdup(gaim_account_get_user_info(gc->account))) != NULL) |
4044 gchar *tag = g_strdup_printf("%s/%s", vc_tp->ptag, vc_tp->tag); | 4045 gchar *tag = g_strdup_printf("%s/%s", vc_tp->ptag, vc_tp->tag); |
4045 cdata = xmlnode_get_tag_data(x_vc_data, tag); | 4046 cdata = xmlnode_get_tag_data(x_vc_data, tag); |
4046 g_free(tag); | 4047 g_free(tag); |
4047 } | 4048 } |
4048 if(strcmp(vc_tp->tag, "DESC") == 0) { | 4049 if(strcmp(vc_tp->tag, "DESC") == 0) { |
4050 field = gaim_request_field_string_new(vc_tp->tag, | |
4051 _(vc_tp->label), cdata, | |
4052 TRUE); | |
4053 #if 0 | |
4049 multi_text_list_update(&(b->multi_text_items), | 4054 multi_text_list_update(&(b->multi_text_items), |
4050 vc_tp->label, cdata, TRUE); | 4055 vc_tp->label, cdata, TRUE); |
4056 #endif | |
4051 } else { | 4057 } else { |
4058 field = gaim_request_field_string_new(vc_tp->tag, | |
4059 _(vc_tp->label), cdata, | |
4060 FALSE); | |
4061 #if 0 | |
4052 data = multi_entry_list_update(&(b->multi_entry_items), | 4062 data = multi_entry_list_update(&(b->multi_entry_items), |
4053 vc_tp->label, cdata, TRUE); | 4063 vc_tp->label, cdata, TRUE); |
4054 data->visible = vc_tp->visible; | 4064 data->visible = vc_tp->visible; |
4055 data->editable = vc_tp->editable; | 4065 data->editable = vc_tp->editable; |
4056 } | 4066 #endif |
4057 } | 4067 } |
4058 | 4068 |
4069 gaim_request_field_group_add_field(group, field); | |
4070 } | |
4059 | 4071 |
4060 if(x_vc_data != NULL) { | 4072 if(x_vc_data != NULL) { |
4061 xmlnode_free(x_vc_data); | 4073 xmlnode_free(x_vc_data); |
4062 } else { | 4074 } else { |
4075 /* | |
4076 * I'm commenting this out for now. faceprint can look at it | |
4077 * later. The comment below says this is going away "real soon now," | |
4078 * but it's probably been here a really long time. Getting this | |
4079 * to work with the multi-field stuff won't be pretty, since we're | |
4080 * manually going to have to search through all fields for the | |
4081 * label and update. | |
4082 * | |
4083 * -- ChipX86 | |
4084 */ | |
4085 #if 0 | |
4063 /* | 4086 /* |
4064 * Early Beta versions had a different user_info storage format--let's | 4087 * Early Beta versions had a different user_info storage format--let's |
4065 * see if that works. | 4088 * see if that works. |
4066 * | 4089 * |
4067 * This goes away RSN. | 4090 * This goes away RSN. |
4087 } | 4110 } |
4088 g_strfreev(str_list2); | 4111 g_strfreev(str_list2); |
4089 } | 4112 } |
4090 g_strfreev(str_list); | 4113 g_strfreev(str_list); |
4091 } | 4114 } |
4115 #endif | |
4092 } | 4116 } |
4093 | 4117 |
4094 g_free(user_info); | 4118 g_free(user_info); |
4095 | 4119 |
4096 b->title = _("Gaim - Edit Jabber vCard"); | 4120 gaim_request_fields(gc, _("Edit Jabber vCard"), |
4097 b->role = "set_info"; | 4121 _("Edit Jabber vCard"), |
4098 b->instructions->text = g_strdup(_(multi_entry_instructions)); | 4122 _("All items below are optional. Enter only the " |
4099 b->entries_title = g_strdup(_(entries_title)); | 4123 "information with which you feel comfortable."), |
4100 | 4124 fields, |
4101 b->custom = (void *) jabber_format_info; | 4125 _("Save"), G_CALLBACK(jabber_format_info), |
4102 | 4126 _("Cancel"), NULL, |
4103 show_set_vcard(b); | 4127 gc); |
4104 } | 4128 } |
4105 | 4129 |
4106 /*---------------------------------------*/ | 4130 /*---------------------------------------*/ |
4107 /* End Jabber "set info" (vCard) support */ | 4131 /* End Jabber "set info" (vCard) support */ |
4108 /*---------------------------------------*/ | 4132 /*---------------------------------------*/ |