Mercurial > pidgin
comparison src/protocols/jabber/jabber.c @ 2975:626729653436
[gaim-migrate @ 2988]
I think I'm alone now ...
committer: Tailor Script <tailor@pidgin.im>
author | Rob Flynn <gaim@robflynn.com> |
---|---|
date | Fri, 22 Feb 2002 23:47:55 +0000 |
parents | b68c648618a3 |
children | 1143524a2eaf |
comparison
equal
deleted
inserted
replaced
2974:11f563b4153a | 2975:626729653436 |
---|---|
688 char *status = NULL; | 688 char *status = NULL; |
689 char *msg = NULL; | 689 char *msg = NULL; |
690 | 690 |
691 if((show = xmlnode_get_tag_data(p->x, "show")) != NULL) { | 691 if((show = xmlnode_get_tag_data(p->x, "show")) != NULL) { |
692 if (!strcasecmp(show, "away")) { | 692 if (!strcasecmp(show, "away")) { |
693 vshow = "Away"; | 693 vshow = _("Away"); |
694 } else if (!strcasecmp(show, "chat")) { | 694 } else if (!strcasecmp(show, "chat")) { |
695 vshow = "Online"; | 695 vshow = _("Online"); |
696 } else if (!strcasecmp(show, "xa")) { | 696 } else if (!strcasecmp(show, "xa")) { |
697 vshow = "Extended Away"; | 697 vshow = _("Extended Away"); |
698 } else if (!strcasecmp(show, "dnd")) { | 698 } else if (!strcasecmp(show, "dnd")) { |
699 vshow = "Do Not Disturb"; | 699 vshow = _("Do Not Disturb"); |
700 } | 700 } |
701 } | 701 } |
702 | 702 |
703 status = xmlnode_get_tag_data(p->x, "status"); | 703 status = xmlnode_get_tag_data(p->x, "status"); |
704 | 704 |
1083 } | 1083 } |
1084 | 1084 |
1085 buddyname = g_strdup_printf("%s@%s", who->user, who->server); | 1085 buddyname = g_strdup_printf("%s@%s", who->user, who->server); |
1086 | 1086 |
1087 if((g = xmlnode_get_tag(x, "group")) == NULL || (groupname = xmlnode_get_data(g)) == NULL) { | 1087 if((g = xmlnode_get_tag(x, "group")) == NULL || (groupname = xmlnode_get_data(g)) == NULL) { |
1088 groupname = "Buddies"; | 1088 groupname = _("Buddies"); |
1089 } | 1089 } |
1090 | 1090 |
1091 | 1091 |
1092 if (BUD_SUB_TO_PEND(sub, ask) || BUD_SUBD_TO(sub, ask)) { | 1092 if (BUD_SUB_TO_PEND(sub, ask) || BUD_SUBD_TO(sub, ask)) { |
1093 if ((b = find_buddy(GJ_GC(gjc), buddyname)) == NULL) { | 1093 if ((b = find_buddy(GJ_GC(gjc), buddyname)) == NULL) { |
1136 static void jabber_handleauthresp(gjconn gjc, jpacket p) | 1136 static void jabber_handleauthresp(gjconn gjc, jpacket p) |
1137 { | 1137 { |
1138 if (jpacket_subtype(p) == JPACKET__RESULT) { | 1138 if (jpacket_subtype(p) == JPACKET__RESULT) { |
1139 if (xmlnode_has_children(p->x)) { | 1139 if (xmlnode_has_children(p->x)) { |
1140 xmlnode query = xmlnode_get_tag(p->x, "query"); | 1140 xmlnode query = xmlnode_get_tag(p->x, "query"); |
1141 set_login_progress(GJ_GC(gjc), 4, "Authenticating"); | 1141 set_login_progress(GJ_GC(gjc), 4, _("Authenticating")); |
1142 if (!xmlnode_get_tag(query, "digest")) { | 1142 if (!xmlnode_get_tag(query, "digest")) { |
1143 g_free(gjc->sid); | 1143 g_free(gjc->sid); |
1144 gjc->sid = NULL; | 1144 gjc->sid = NULL; |
1145 } | 1145 } |
1146 gjab_auth(gjc); | 1146 gjab_auth(gjc); |
1173 g_snprintf(msg, sizeof(msg), "Error %d: %s", errcode, errmsg); | 1173 g_snprintf(msg, sizeof(msg), "Error %d: %s", errcode, errmsg); |
1174 } else | 1174 } else |
1175 g_snprintf(msg, sizeof(msg), "%s", errmsg); | 1175 g_snprintf(msg, sizeof(msg), "%s", errmsg); |
1176 hide_login_progress(GJ_GC(gjc), msg); | 1176 hide_login_progress(GJ_GC(gjc), msg); |
1177 } else { | 1177 } else { |
1178 hide_login_progress(GJ_GC(gjc), "Unknown login error"); | 1178 hide_login_progress(GJ_GC(gjc), _("Unknown login error")); |
1179 } | 1179 } |
1180 | 1180 |
1181 jd->die = TRUE; | 1181 jd->die = TRUE; |
1182 } | 1182 } |
1183 } | 1183 } |
1403 | 1403 |
1404 static void jabber_handlestate(gjconn gjc, int state) | 1404 static void jabber_handlestate(gjconn gjc, int state) |
1405 { | 1405 { |
1406 switch (state) { | 1406 switch (state) { |
1407 case JCONN_STATE_OFF: | 1407 case JCONN_STATE_OFF: |
1408 hide_login_progress(GJ_GC(gjc), "Unable to connect"); | 1408 hide_login_progress(GJ_GC(gjc), _("Unable to connect")); |
1409 signoff(GJ_GC(gjc)); | 1409 signoff(GJ_GC(gjc)); |
1410 break; | 1410 break; |
1411 case JCONN_STATE_CONNECTED: | 1411 case JCONN_STATE_CONNECTED: |
1412 set_login_progress(GJ_GC(gjc), 2, "Connected"); | 1412 set_login_progress(GJ_GC(gjc), 2, _("Connected")); |
1413 break; | 1413 break; |
1414 case JCONN_STATE_ON: | 1414 case JCONN_STATE_ON: |
1415 set_login_progress(GJ_GC(gjc), 3, "Requesting Authentication Method"); | 1415 set_login_progress(GJ_GC(gjc), 3, _("Requesting Authentication Method")); |
1416 gjab_reqauth(gjc); | 1416 gjab_reqauth(gjc); |
1417 break; | 1417 break; |
1418 default: | 1418 default: |
1419 debug_printf("state change: %d\n", state); | 1419 debug_printf("state change: %d\n", state); |
1420 } | 1420 } |
1428 char *loginname = create_valid_jid(user->username, DEFAULT_SERVER, "GAIM"); | 1428 char *loginname = create_valid_jid(user->username, DEFAULT_SERVER, "GAIM"); |
1429 | 1429 |
1430 jd->hash = g_hash_table_new(g_str_hash, g_str_equal); | 1430 jd->hash = g_hash_table_new(g_str_hash, g_str_equal); |
1431 jd->chats = NULL; /* we have no chats yet */ | 1431 jd->chats = NULL; /* we have no chats yet */ |
1432 | 1432 |
1433 set_login_progress(gc, 1, "Connecting"); | 1433 set_login_progress(gc, 1, _("Connecting")); |
1434 | 1434 |
1435 if (!(jd->gjc = gjab_new(loginname, user->password, gc))) { | 1435 if (!(jd->gjc = gjab_new(loginname, user->password, gc))) { |
1436 g_free(loginname); | 1436 g_free(loginname); |
1437 debug_printf("jabber: unable to connect (jab_new failed)\n"); | 1437 debug_printf("jabber: unable to connect (jab_new failed)\n"); |
1438 hide_login_progress(gc, "Unable to connect"); | 1438 hide_login_progress(gc, _("Unable to connect")); |
1439 signoff(gc); | 1439 signoff(gc); |
1440 return; | 1440 return; |
1441 } | 1441 } |
1442 | 1442 |
1443 g_free(loginname); | 1443 g_free(loginname); |
1966 realwho = g_strdup(who); | 1966 realwho = g_strdup(who); |
1967 } | 1967 } |
1968 *ap++ = g_strdup_printf("<B>Jabber ID:</B> %s<BR>\n", realwho); | 1968 *ap++ = g_strdup_printf("<B>Jabber ID:</B> %s<BR>\n", realwho); |
1969 | 1969 |
1970 if((status = g_hash_table_lookup(jd->hash, realwho)) == NULL) { | 1970 if((status = g_hash_table_lookup(jd->hash, realwho)) == NULL) { |
1971 status = "Online"; | 1971 status = _("Online"); |
1972 } | 1972 } |
1973 *ap++ = g_strdup_printf("<B>Status:</B> %s<BR>\n", status); | 1973 *ap++ = g_strdup_printf("<B>Status:</B> %s<BR>\n", status); |
1974 | 1974 |
1975 *ap = NULL; | 1975 *ap = NULL; |
1976 | 1976 |
2203 int editable; /* should entry field be editable? */ | 2203 int editable; /* should entry field be editable? */ |
2204 char *tag; /* tag text */ | 2204 char *tag; /* tag text */ |
2205 char *ptag; /* parent tag "path" text */ | 2205 char *ptag; /* parent tag "path" text */ |
2206 char *url; /* vCard display format if URL */ | 2206 char *url; /* vCard display format if URL */ |
2207 } vcard_template_data[] = { | 2207 } vcard_template_data[] = { |
2208 {"Full Name", NULL, TRUE, TRUE, "FN", NULL, NULL}, | 2208 {N_("Full Name"), NULL, TRUE, TRUE, "FN", NULL, NULL}, |
2209 {"Family Name", NULL, TRUE, TRUE, "FAMILY", "N", NULL}, | 2209 {N_("Family Name"), NULL, TRUE, TRUE, "FAMILY", "N", NULL}, |
2210 {"Given Name", NULL, TRUE, TRUE, "GIVEN", "N", NULL}, | 2210 {N_("Given Name"), NULL, TRUE, TRUE, "GIVEN", "N", NULL}, |
2211 {"Nickname", NULL, TRUE, TRUE, "NICKNAME", NULL, NULL}, | 2211 {N_("Nickname"), NULL, TRUE, TRUE, "NICKNAME", NULL, NULL}, |
2212 {"URL", NULL, TRUE, TRUE, "URL", NULL, "<A HREF=\"%s\">%s</A>"}, | 2212 {N_("URL"), NULL, TRUE, TRUE, "URL", NULL, "<A HREF=\"%s\">%s</A>"}, |
2213 {"Street Address", NULL, TRUE, TRUE, "STREET", "ADR", NULL}, | 2213 {N_("Street Address"), NULL, TRUE, TRUE, "STREET", "ADR", NULL}, |
2214 {"Extended Address", NULL, TRUE, TRUE, "EXTADD", "ADR", NULL}, | 2214 {N_("Extended Address"), NULL, TRUE, TRUE, "EXTADD", "ADR", NULL}, |
2215 {"Locality", NULL, TRUE, TRUE, "LOCALITY", "ADR", NULL}, | 2215 {N_("Locality"), NULL, TRUE, TRUE, "LOCALITY", "ADR", NULL}, |
2216 {"Region", NULL, TRUE, TRUE, "REGION", "ADR", NULL}, | 2216 {N_("Region"), NULL, TRUE, TRUE, "REGION", "ADR", NULL}, |
2217 {"Postal Code", NULL, TRUE, TRUE, "PCODE", "ADR", NULL}, | 2217 {N_("Postal Code"), NULL, TRUE, TRUE, "PCODE", "ADR", NULL}, |
2218 {"Country", NULL, TRUE, TRUE, "COUNTRY", "ADR", NULL}, | 2218 {N_("Country"), NULL, TRUE, TRUE, "COUNTRY", "ADR", NULL}, |
2219 {"Telephone", NULL, TRUE, TRUE, "TELEPHONE", NULL, NULL}, | 2219 {N_("Telephone"), NULL, TRUE, TRUE, "TELEPHONE", NULL, NULL}, |
2220 {"Email", NULL, TRUE, TRUE, "EMAIL", NULL, "<A HREF=\"mailto:%s\">%s</A>"}, | 2220 {N_("Email"), NULL, TRUE, TRUE, "EMAIL", NULL, "<A HREF=\"mailto:%s\">%s</A>"}, |
2221 {"Organization Name", NULL, TRUE, TRUE, "ORGNAME", "ORG", NULL}, | 2221 {N_("Organization Name"), NULL, TRUE, TRUE, "ORGNAME", "ORG", NULL}, |
2222 {"Organization Unit", NULL, TRUE, TRUE, "ORGUNIT", "ORG", NULL}, | 2222 {N_("Organization Unit"), NULL, TRUE, TRUE, "ORGUNIT", "ORG", NULL}, |
2223 {"Title", NULL, TRUE, TRUE, "TITLE", NULL, NULL}, | 2223 {N_("Title"), NULL, TRUE, TRUE, "TITLE", NULL, NULL}, |
2224 {"Role", NULL, TRUE, TRUE, "ROLE", NULL, NULL}, | 2224 {N_("Role"), NULL, TRUE, TRUE, "ROLE", NULL, NULL}, |
2225 {"Birthday", NULL, TRUE, TRUE, "BDAY", NULL, NULL}, | 2225 {N_("Birthday"), NULL, TRUE, TRUE, "BDAY", NULL, NULL}, |
2226 {"Description", NULL, TRUE, TRUE, "DESC", NULL, NULL}, | 2226 {N_("Description"), NULL, TRUE, TRUE, "DESC", NULL, NULL}, |
2227 {"", NULL, TRUE, TRUE, "N", NULL, NULL}, | 2227 {"", NULL, TRUE, TRUE, "N", NULL, NULL}, |
2228 {"", NULL, TRUE, TRUE, "ADR", NULL, NULL}, | 2228 {"", NULL, TRUE, TRUE, "ADR", NULL, NULL}, |
2229 {"", NULL, TRUE, TRUE, "ORG", NULL, NULL}, | 2229 {"", NULL, TRUE, TRUE, "ORG", NULL, NULL}, |
2230 {NULL, NULL, 0, 0, NULL, NULL, NULL} | 2230 {NULL, NULL, 0, 0, NULL, NULL, NULL} |
2231 }; | 2231 }; |
2246 | 2246 |
2247 /* | 2247 /* |
2248 * V-Card user instructions | 2248 * V-Card user instructions |
2249 */ | 2249 */ |
2250 static char *multi_entry_instructions = | 2250 static char *multi_entry_instructions = |
2251 "Enter the stuff you feel comfortable with. Leave the rest blank."; | 2251 N_("All items below are optional. Enter only the information with which you feel comfortable"); |
2252 static char *entries_title = N_("User Identity"); | |
2252 | 2253 |
2253 /* | 2254 /* |
2254 * Used by routines to parse an XML-encoded string into an xmlnode tree | 2255 * Used by routines to parse an XML-encoded string into an xmlnode tree |
2255 */ | 2256 */ |
2256 typedef struct { | 2257 typedef struct { |
2304 } | 2305 } |
2305 } | 2306 } |
2306 } | 2307 } |
2307 | 2308 |
2308 if((status = g_hash_table_lookup(jd->hash, buddy)) == NULL) { | 2309 if((status = g_hash_table_lookup(jd->hash, buddy)) == NULL) { |
2309 status = "Online"; | 2310 status = _("Online"); |
2310 } | 2311 } |
2311 *ap++ = g_strdup_printf("<B>Status:</B> %s<BR>\n", status); | 2312 *ap++ = g_strdup_printf("<B>Status:</B> %s<BR>\n", status); |
2312 | 2313 |
2313 /* | 2314 /* |
2314 * "Description" handled as a special case: get a copy of the | 2315 * "Description" handled as a special case: get a copy of the |
2662 | 2663 |
2663 if(user_info != NULL) { | 2664 if(user_info != NULL) { |
2664 g_free(user_info); | 2665 g_free(user_info); |
2665 } | 2666 } |
2666 | 2667 |
2667 b->title = "Gaim - vCard Wizzard"; | 2668 b->title = _("Gaim - Edit Jabber vCard"); |
2668 b->wmclass_name = "set_info"; | 2669 b->wmclass_name = "set_info"; |
2669 b->wmclass_class = "Gaim"; | 2670 b->wmclass_class = "Gaim"; |
2670 b->instructions->text = g_strdup(multi_entry_instructions); | 2671 b->instructions->text = g_strdup(multi_entry_instructions); |
2672 b->entries_title = g_strdup(entries_title); | |
2671 | 2673 |
2672 b->custom = (void *) jabber_format_info; | 2674 b->custom = (void *) jabber_format_info; |
2673 | 2675 |
2674 show_set_vcard(b); | 2676 show_set_vcard(b); |
2675 } | 2677 } |
2735 } | 2737 } |
2736 } | 2738 } |
2737 } else { | 2739 } else { |
2738 debug_printf("registration successful!\n"); | 2740 debug_printf("registration successful!\n"); |
2739 | 2741 |
2740 hide_login_progress_notice(GJ_GC(gjc), "Server Registration successful!"); | 2742 hide_login_progress_notice(GJ_GC(gjc), _("Server Registration successful!")); |
2741 /* | 2743 /* |
2742 * TBD: is this the correct way to do away with a | 2744 * TBD: is this the correct way to do away with a |
2743 * gaim_connection and all its associated memory | 2745 * gaim_connection and all its associated memory |
2744 * allocs, etc.? | 2746 * allocs, etc.? |
2745 */ | 2747 */ |
2762 g_snprintf(msg, sizeof(msg), "Error %d: %s", errcode, errmsg); | 2764 g_snprintf(msg, sizeof(msg), "Error %d: %s", errcode, errmsg); |
2763 } else | 2765 } else |
2764 g_snprintf(msg, sizeof(msg), "%s", errmsg); | 2766 g_snprintf(msg, sizeof(msg), "%s", errmsg); |
2765 hide_login_progress(GJ_GC(gjc), msg); | 2767 hide_login_progress(GJ_GC(gjc), msg); |
2766 } else { | 2768 } else { |
2767 hide_login_progress(GJ_GC(gjc), "Unknown registration error"); | 2769 hide_login_progress(GJ_GC(gjc), _("Unknown registration error")); |
2768 } | 2770 } |
2769 | 2771 |
2770 jd->die = TRUE; | 2772 jd->die = TRUE; |
2771 } | 2773 } |
2772 } | 2774 } |
2838 */ | 2840 */ |
2839 static void jabber_handle_registration_state(gjconn gjc, int state) | 2841 static void jabber_handle_registration_state(gjconn gjc, int state) |
2840 { | 2842 { |
2841 switch (state) { | 2843 switch (state) { |
2842 case JCONN_STATE_OFF: | 2844 case JCONN_STATE_OFF: |
2843 hide_login_progress(GJ_GC(gjc), "Unable to connect"); | 2845 hide_login_progress(GJ_GC(gjc), _("Unable to connect")); |
2844 signoff(GJ_GC(gjc)); | 2846 signoff(GJ_GC(gjc)); |
2845 break; | 2847 break; |
2846 case JCONN_STATE_CONNECTED: | 2848 case JCONN_STATE_CONNECTED: |
2847 /* | 2849 /* |
2848 * TBD? | 2850 * TBD? |
2849 set_login_progress(GJ_GC(gjc), 2, "Connected"); | 2851 set_login_progress(GJ_GC(gjc), 2, _("Connected")); |
2850 */ | 2852 */ |
2851 break; | 2853 break; |
2852 case JCONN_STATE_ON: | 2854 case JCONN_STATE_ON: |
2853 /* | 2855 /* |
2854 * TBD? | 2856 * TBD? |
2855 set_login_progress(GJ_GC(gjc), 3, "Requesting Authentication Method"); | 2857 set_login_progress(GJ_GC(gjc), 3, _("Requesting Authentication Method")); |
2856 */ | 2858 */ |
2857 gjab_reqreg(gjc); | 2859 gjab_reqreg(gjc); |
2858 /* | 2860 /* |
2859 * TBD: A work-in-progress | 2861 * TBD: A work-in-progress |
2860 gjab_reqregreqs(gjc); | 2862 gjab_reqregreqs(gjc); |
2882 jd->chats = NULL; | 2884 jd->chats = NULL; |
2883 | 2885 |
2884 if ((jd->gjc = gjab_new(loginname, au->password, gc)) == NULL) { | 2886 if ((jd->gjc = gjab_new(loginname, au->password, gc)) == NULL) { |
2885 g_free(loginname); | 2887 g_free(loginname); |
2886 debug_printf("jabber: unable to connect (jab_new failed)\n"); | 2888 debug_printf("jabber: unable to connect (jab_new failed)\n"); |
2887 hide_login_progress(gc, "Unable to connect"); | 2889 hide_login_progress(gc, _("Unable to connect")); |
2888 signoff(gc); | 2890 signoff(gc); |
2889 } else { | 2891 } else { |
2890 gjab_state_handler(jd->gjc, jabber_handle_registration_state); | 2892 gjab_state_handler(jd->gjc, jabber_handle_registration_state); |
2891 gjab_packet_handler(jd->gjc, jabber_handleregresp); | 2893 gjab_packet_handler(jd->gjc, jabber_handleregresp); |
2892 jd->gjc->queries = NULL; | 2894 jd->gjc->queries = NULL; |
2900 /* End Jabber "user registration" support */ | 2902 /* End Jabber "user registration" support */ |
2901 /*----------------------------------------*/ | 2903 /*----------------------------------------*/ |
2902 | 2904 |
2903 static void jabber_do_action(struct gaim_connection *gc, char *act) | 2905 static void jabber_do_action(struct gaim_connection *gc, char *act) |
2904 { | 2906 { |
2905 if (!strcmp(act, "Set User Info")) { | 2907 if (!strcmp(act, _("Set User Info"))) { |
2906 jabber_setup_set_info(gc); | 2908 jabber_setup_set_info(gc); |
2907 /* | 2909 /* |
2908 } else if (!strcmp(act, "Set Dir Info")) { | 2910 } else if (!strcmp(act, _("Set Dir Info"))) { |
2909 show_set_dir(gc); | 2911 show_set_dir(gc); |
2910 } else if (!strcmp(act, "Change Password")) { | 2912 } else if (!strcmp(act, _("Change Password"))) { |
2911 show_change_passwd(gc); | 2913 show_change_passwd(gc); |
2912 */ | 2914 */ |
2913 } | 2915 } |
2914 } | 2916 } |
2915 | 2917 |
2916 static GList *jabber_actions() | 2918 static GList *jabber_actions() |
2917 { | 2919 { |
2918 GList *m = NULL; | 2920 GList *m = NULL; |
2919 | 2921 |
2920 m = g_list_append(m, "Set User Info"); | 2922 m = g_list_append(m, _("Set User Info")); |
2921 /* | 2923 /* |
2922 m = g_list_append(m, "Set Dir Info"); | 2924 m = g_list_append(m, _("Set Dir Info")); |
2923 m = g_list_append(m, "Change Password"); | 2925 m = g_list_append(m, _("Change Password")); |
2924 */ | 2926 */ |
2925 | 2927 |
2926 return m; | 2928 return m; |
2927 } | 2929 } |
2928 | 2930 |