ayttm-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Ayttm-commits] CVS: ayttm/modules/yahoo2 yahoo.c,1.11,1.12


From: Philip S Tellis <address@hidden>
Subject: [Ayttm-commits] CVS: ayttm/modules/yahoo2 yahoo.c,1.11,1.12
Date: Wed, 15 Jan 2003 07:53:38 -0500

Update of /cvsroot/ayttm/ayttm/modules/yahoo2
In directory subversions:/tmp/cvs-serv9067/modules/yahoo2

Modified Files:
        yahoo.c 
Log Message:
updates for utf8 processig for incoming and outgoing messages

Index: yahoo.c
===================================================================
RCS file: /cvsroot/ayttm/ayttm/modules/yahoo2/yahoo.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- yahoo.c     14 Jan 2003 23:30:16 -0000      1.11
+++ yahoo.c     15 Jan 2003 12:53:34 -0000      1.12
@@ -66,6 +66,7 @@
 
 #include "yahoo2.h"
 #include "yahoo2_callbacks.h"
+#include "yahoo_util.h"
 
 #include "libproxy/libproxy.h"
 
@@ -710,7 +711,7 @@
        }
 }
 
-void ext_yahoo_got_im(int id, char *who, char *msg, long tm, int stat)
+void ext_yahoo_got_im(int id, char *who, char *msg, long tm, int stat, int 
utf8)
 {
        if(stat == 2) {
                LOG(("Error sending message to %s", who));
@@ -723,24 +724,9 @@
                char buff[2048];
 
                int i=0,j=0;
-               unsigned char *umsg = (unsigned char *)msg;
-               while(umsg[i]) {
-                       if(umsg[i] < (unsigned char)0x80) {     /* 7 bit ASCII 
*/
-                               umsg[j] = umsg[i];
-                               i++; 
-                       } else if(umsg[i] < (unsigned char)0xC4) {/* ISOLatin1 
*/
-                               umsg[j] = (umsg[i]<<6) | (umsg[i+1] & 0x3F);
-                               i+=2;
-                       } else if(umsg[i] < (unsigned char)0xE0) {
-                               umsg[j] = '.';
-                               i+=3;
-                       } else if(umsg[i] < (unsigned char)0xF0) {
-                               umsg[j] = '.';
-                               i+=4;
-                       }
-                       j++;
-               }
-               umsg[j]='\0';
+               char *umsg = msg;
+               if(utf8)
+                       umsg = y_utf8_to_str(msg);
 
                if(tm) {
                        char newmessage[2048];
@@ -749,7 +735,7 @@
                        strncpy(timestr, ctime(&tm), sizeof(timestr));
                        timestr[strlen(timestr) - 1] = '\0';
 
-                       sprintf(newmessage, _("<FONT COLOR=\"#0000FF\">[Offline 
message at %s]</FONT><BR>%s"), timestr, msg);
+                       sprintf(newmessage, _("<FONT COLOR=\"#0000FF\">[Offline 
message at %s]</FONT><BR>%s"), timestr, umsg);
 
                        sender = find_account_by_handle(who, 
SERVICE_INFO.protocol_id);
                        if (sender == NULL) {
@@ -760,7 +746,7 @@
                        receiver = yahoo_find_local_account_by_id(id);
                        eb_yahoo_decode_yahoo_colors(buff, newmessage);
                        eb_parse_incoming_message(receiver, sender, 
&SERVICE_INFO, buff);
-                       LOG(("<incoming offline message: %s: %s>", who, msg));
+                       LOG(("<incoming offline message: %s: %s>", who, umsg));
 
                } else {
                        sender = find_account_by_handle(who, 
SERVICE_INFO.protocol_id);
@@ -773,11 +759,14 @@
                        }
                        receiver = yahoo_find_local_account_by_id(id);
 
-                       LOG(("<incoming message: %s: %s>", who, msg));
-                       eb_yahoo_decode_yahoo_colors(buff, msg);
+                       LOG(("<incoming message: %s: %s>", who, umsg));
+                       eb_yahoo_decode_yahoo_colors(buff, umsg);
                        eb_parse_incoming_message(receiver, sender, 
&SERVICE_INFO, buff);
 
                }
+
+               if(utf8)
+                       FREE(umsg);
        }
 }
 
@@ -1197,20 +1186,41 @@
 }
 #endif
 
-void ext_yahoo_conf_message(int id, char *who, char *room, char *msg)
+void ext_yahoo_conf_message(int id, char *who, char *room, char *msg, int utf8)
 {
+       int i=0, j=0;
+       unsigned char * umsg = (unsigned char *)msg;
        eb_chat_room *chat_room = find_chat_room_by_id(room);
 
        if(!chat_room)
                return;
 
-       eb_chat_room_show_message(chat_room, who, msg);
+       while(umsg[i]) {
+               if(umsg[i] < (unsigned char)0x80) {     /* 7 bit ASCII */
+                       umsg[j] = umsg[i];
+                       i++; 
+               } else if(umsg[i] < (unsigned char)0xC4) {/* ISOLatin1 */
+                       umsg[j] = (umsg[i]<<6) | (umsg[i+1] & 0x3F);
+                       i+=2;
+               } else if(umsg[i] < (unsigned char)0xE0) {
+                       umsg[j] = '.';
+                       i+=3;
+               } else if(umsg[i] < (unsigned char)0xF0) {
+                       umsg[j] = '.';
+                       i+=4;
+               }
+               j++;
+       }
+       umsg[j]='\0';
+
+       eb_chat_room_show_message(chat_room, who, umsg);
 }
 
 void eb_yahoo_send_chat_room_message(eb_chat_room * room, gchar * message)
 {
        eb_yahoo_chat_room_data *ycrd;
        eb_yahoo_local_account_data *ylad;
+       char * encoded = y_str_to_utf8(message);
                
        if(!room) {
                WARNING(("room is null"));
@@ -1223,7 +1233,8 @@
        ylad = room->chat_room_account->protocol_local_account_data;
        
        ycrd = room->protocol_local_chat_room_data;
-       yahoo_conference_message(ycrd->id, ylad->act_id, ycrd->members, 
ycrd->room, message);
+       yahoo_conference_message(ycrd->id, ylad->act_id, ycrd->members, 
ycrd->room, encoded, 1);
+       FREE(encoded);
 }
 
 void eb_yahoo_join_chat_room(eb_chat_room * room)
@@ -1648,10 +1659,13 @@
                      gchar * message)
 {
        eb_yahoo_local_account_data *ylad = 
account_from->protocol_local_account_data;
+       char * encoded = y_str_to_utf8(message);
 
        LOG(("eb_yahoo_send_im: %s => %s: %s", account_from->handle,
             account_to->handle, message));
-       yahoo_send_im(ylad->id, ylad->act_id, account_to->handle, message);
+       yahoo_send_im(ylad->id, ylad->act_id, account_to->handle, encoded, 1);
+
+       FREE(encoded);
 }
 
 eb_local_account *eb_yahoo_read_local_account_config(GList * pairs)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]