Mercurial > pidgin.yaz
comparison src/protocols/zephyr/zephyr.c @ 8560:832fd9b754d0
[gaim-migrate @ 9304]
" Here's a patch for the problem larsl_school reported on
#gaim on the 13th, mostly taken from the irc plugin.
Whenever
an incoming im (or chat message) doesn't parse as
utf-8, it will be automatically interpreted as a byte
stream in a fallback
character set, (defaulting to iso-8859-1), and converted to
utf-8. It adds an option to the zephyr plugin,
"Encoding",
which is a translateable string. It still sends outgoing
messages as utf-8 though.
(06:57:06) larsl_school: Hello, I'm using Gaim 0.71 in
school and when I get a Zephyr message containing
swedish characters from the zwrite client, Gaim just
displays the whole message as an empty string?
(07:04:00) larsl_school: In the logs it looks like GAIM
is using UTF-8, but the messages from zwrite are coded
as extended ASCII. Can I make GAIM understand extended
ASCII (or at least display the parts of the message
that is normal ASCII)?" --Arun A Tharuvai
apparently there are TWO gaim zepher users!
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Fri, 02 Apr 2004 06:06:45 +0000 |
parents | 1c20aa5bd389 |
children | e3c059c3d92d |
comparison
equal
deleted
inserted
replaced
8559:1c20aa5bd389 | 8560:832fd9b754d0 |
---|---|
35 | 35 |
36 #include "zephyr/zephyr.h" | 36 #include "zephyr/zephyr.h" |
37 | 37 |
38 #include <strings.h> | 38 #include <strings.h> |
39 | 39 |
40 #define ZEPHYR_FALLBACK_CHARSET "ISO-8859-1" | |
41 | |
40 extern Code_t ZGetLocations(ZLocations_t *, int *); | 42 extern Code_t ZGetLocations(ZLocations_t *, int *); |
41 extern Code_t ZSetLocation(char *); | 43 extern Code_t ZSetLocation(char *); |
42 extern Code_t ZUnsetLocation(); | 44 extern Code_t ZUnsetLocation(); |
43 | 45 |
44 typedef struct _zframe zframe; | 46 typedef struct _zframe zframe; |
177 if (zt->id == id) | 179 if (zt->id == id) |
178 return zt; | 180 return zt; |
179 curr = curr->next; | 181 curr = curr->next; |
180 } | 182 } |
181 return NULL; | 183 return NULL; |
184 } | |
185 | |
186 static gchar *zephyr_recv_convert(char *string, int len) | |
187 { | |
188 gchar *utf8; | |
189 GError *err = NULL; | |
190 if (g_utf8_validate(string,len,NULL)) { | |
191 return g_strdup(string); | |
192 } else { | |
193 utf8 = g_convert(string, len, "UTF-8", | |
194 gaim_account_get_string(zgc->account, "encoding", ZEPHYR_FALLBACK_CHARSET), | |
195 NULL, NULL, &err); | |
196 if (err) { | |
197 gaim_debug(GAIM_DEBUG_ERROR, "zephyr", "recv conversion error: %s\n", err->message); | |
198 utf8 = g_strdup(_("(There was an error converting this message. Check the 'Encoding' option in the Account Editor)")); | |
199 } | |
200 | |
201 return utf8; | |
202 } | |
182 } | 203 } |
183 | 204 |
184 /* utility macros that are useful for zephyr_to_html */ | 205 /* utility macros that are useful for zephyr_to_html */ |
185 | 206 |
186 #define IS_OPENER(c) ((c == '{') || (c == '[') || (c == '(') || (c == '<')) | 207 #define IS_OPENER(c) ((c == '{') || (c == '[') || (c == '(') || (c == '<')) |
549 serv_got_update(zgc, b->name, nlocs, 0, 0, 0, 0); | 570 serv_got_update(zgc, b->name, nlocs, 0, 0, 0, 0); |
550 | 571 |
551 free(user); | 572 free(user); |
552 } | 573 } |
553 } else { | 574 } else { |
554 char *buf, *buf2; | 575 char *buf, *buf2, *buf3; |
555 char *send_inst; | 576 char *send_inst; |
556 char *realmptr; | 577 char *realmptr; |
557 GaimConversation *gconv1; | 578 GaimConversation *gconv1; |
558 GaimConvChat *gcc; | 579 GaimConvChat *gcc; |
559 char *ptr = notice.z_message + strlen(notice.z_message) + 1; | 580 char *ptr = notice.z_message + strlen(notice.z_message) + 1; |
560 int len = notice.z_message_len - ((int)ptr - (int)notice.z_message); | 581 int len = notice.z_message_len - ((int)ptr - (int)notice.z_message); |
561 char *sendertmp = g_strdup_printf("%s",gaim_zephyr_get_sender()); | 582 char *sendertmp = g_strdup_printf("%s",gaim_zephyr_get_sender()); |
562 GaimConvImFlags flags = 0; | 583 GaimConvImFlags flags = 0; |
563 if (len > 0) { | 584 if (len > 0) { |
564 gchar* tmpescape; | 585 gchar* tmpescape; |
565 buf = g_malloc(len + 1); | 586 buf = g_malloc(len + 1); |
566 g_snprintf(buf, len + 1, "%s", ptr); | 587 g_snprintf(buf, len + 1, "%s", ptr); |
567 g_strchomp(buf); | 588 g_strchomp(buf); |
568 tmpescape = gaim_escape_html(buf); | 589 tmpescape = gaim_escape_html(buf); |
569 buf2 = zephyr_to_html(tmpescape); | 590 buf2 = zephyr_to_html(tmpescape); |
570 g_free(buf); | 591 buf3 = zephyr_recv_convert(buf2,strlen(buf2)); |
592 g_free(buf2); | |
593 g_free(buf); | |
571 g_free(tmpescape); | 594 g_free(tmpescape); |
595 | |
572 if (!g_ascii_strcasecmp(notice.z_class, "MESSAGE") && | 596 if (!g_ascii_strcasecmp(notice.z_class, "MESSAGE") && |
573 !g_ascii_strcasecmp(notice.z_class_inst, "PERSONAL")) { | 597 !g_ascii_strcasecmp(notice.z_class_inst, "PERSONAL")) { |
574 if (!g_ascii_strcasecmp(notice.z_message, "Automated reply:")) | 598 if (!g_ascii_strcasecmp(notice.z_message, "Automated reply:")) |
575 flags |= GAIM_CONV_IM_AUTO_RESP; | 599 flags |= GAIM_CONV_IM_AUTO_RESP; |
576 serv_got_im(zgc, notice.z_sender, buf2, flags, time(NULL)); | 600 serv_got_im(zgc, notice.z_sender, buf3, flags, time(NULL)); |
577 } else { | 601 } else { |
578 zephyr_triple *zt1, *zt2; | 602 zephyr_triple *zt1, *zt2; |
579 zt1 = new_triple(notice.z_class, notice.z_class_inst, | 603 zt1 = new_triple(notice.z_class, notice.z_class_inst, |
580 notice.z_recipient); | 604 notice.z_recipient); |
581 zt2 = find_sub_by_triple(zt1); | 605 zt2 = find_sub_by_triple(zt1); |
608 } | 632 } |
609 } else { | 633 } else { |
610 send_inst = g_strdup_printf("%s %s",sendertmp,notice.z_class_inst); | 634 send_inst = g_strdup_printf("%s %s",sendertmp,notice.z_class_inst); |
611 } | 635 } |
612 serv_got_chat_in(zgc, zt2->id, send_inst, FALSE, | 636 serv_got_chat_in(zgc, zt2->id, send_inst, FALSE, |
613 buf2, time(NULL)); | 637 buf3, time(NULL)); |
614 | 638 |
615 gconv1 = gaim_find_conversation_with_account(zt2->name,zgc->account); | 639 gconv1 = gaim_find_conversation_with_account(zt2->name,zgc->account); |
616 gcc = gaim_conversation_get_chat_data(gconv1); | 640 gcc = gaim_conversation_get_chat_data(gconv1); |
617 /* gaim_conv_chat_set_topic(gcc,sendertmp,notice.z_class_inst); */ | 641 /* gaim_conv_chat_set_topic(gcc,sendertmp,notice.z_class_inst); */ |
618 for(gltmp = gaim_conv_chat_get_users(gcc);gltmp;gltmp=gltmp->next) { | 642 for(gltmp = gaim_conv_chat_get_users(gcc);gltmp;gltmp=gltmp->next) { |
632 g_free(sendertmp); | 656 g_free(sendertmp); |
633 g_free(send_inst); | 657 g_free(send_inst); |
634 } | 658 } |
635 free_triple(zt1); | 659 free_triple(zt1); |
636 } | 660 } |
637 g_free(buf2); | 661 g_free(buf3); |
638 } | 662 } |
639 } | 663 } |
640 } | 664 } |
641 | 665 |
642 static gint check_notify(gpointer data) | 666 static gint check_notify(gpointer data) |
1395 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,option); | 1419 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,option); |
1396 | 1420 |
1397 option = gaim_account_option_string_new(_("Exposure"),"exposure_level",tmp?tmp:EXPOSE_REALMVIS); | 1421 option = gaim_account_option_string_new(_("Exposure"),"exposure_level",tmp?tmp:EXPOSE_REALMVIS); |
1398 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,option); | 1422 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,option); |
1399 | 1423 |
1424 option = gaim_account_option_string_new(_("Encoding"),"encoding",ZEPHYR_FALLBACK_CHARSET); | |
1425 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,option); | |
1426 | |
1400 my_protocol = plugin; | 1427 my_protocol = plugin; |
1401 } | 1428 } |
1402 | 1429 |
1403 GAIM_INIT_PLUGIN(zephyr, init_plugin, info); | 1430 GAIM_INIT_PLUGIN(zephyr, init_plugin, info); |