[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Ayttm-commits] CVS: ayttm/modules/yahoo2/libyahoo2 libyahoo2.c,1.2,1.3
From: |
Philip S Tellis <address@hidden> |
Subject: |
[Ayttm-commits] CVS: ayttm/modules/yahoo2/libyahoo2 libyahoo2.c,1.2,1.3 yahoo2.h,1.1.1.1,1.2 yahoo2_callbacks.h,1.1.1.1,1.2 yahoo_util.c,1.1.1.1,1.2 yahoo_util.h,1.1.1.1,1.2 |
Date: |
Wed, 15 Jan 2003 07:53:38 -0500 |
Update of /cvsroot/ayttm/ayttm/modules/yahoo2/libyahoo2
In directory subversions:/tmp/cvs-serv9067/modules/yahoo2/libyahoo2
Modified Files:
libyahoo2.c yahoo2.h yahoo2_callbacks.h yahoo_util.c
yahoo_util.h
Log Message:
updates for utf8 processig for incoming and outgoing messages
Index: libyahoo2.c
===================================================================
RCS file: /cvsroot/ayttm/ayttm/modules/yahoo2/libyahoo2/libyahoo2.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- libyahoo2.c 30 Dec 2002 18:34:43 -0000 1.2
+++ libyahoo2.c 15 Jan 2003 12:53:34 -0000 1.3
@@ -678,6 +678,7 @@
char *who = NULL;
char *room = NULL;
char *id = NULL;
+ int utf8 = 0;
YList *members = NULL;
YList *l;
@@ -715,6 +716,9 @@
id = pair->value;
if (pair->key == 3) /* message sender */
who = pair->value;
+
+ if (pair->key == 97)
+ utf8 = atoi(pair->value);
}
if(!room)
@@ -760,47 +764,68 @@
break;
case YAHOO_SERVICE_CONFMSG:
if(who)
- YAHOO_CALLBACK(ext_yahoo_conf_message)(yd->client_id,
who, room, msg);
+ YAHOO_CALLBACK(ext_yahoo_conf_message)(yd->client_id,
who, room, msg, utf8);
break;
}
}
static void yahoo_process_message(struct yahoo_data *yd, struct yahoo_packet
*pkt)
{
- char *msg = NULL;
- char *from = NULL;
- char *real_from = NULL;
- long tm = 0L;
YList *l;
-
+ YList * messages = NULL;
+
+ struct m {
+ int i_31;
+ int i_32;
+ char *to;
+ char *from;
+ long tm;
+ char *msg;
+ int utf8;
+ } *message = y_new0(struct m, 1);
+
for (l = pkt->hash; l; l = l->next) {
struct yahoo_pair *pair = l->data;
- if (pair->key == 0)
- real_from = pair->value;
- else if (pair->key == 1)
- from = pair->value;
- else if (pair->key == 4)
- from = pair->value;
+ if (pair->key == 1 || pair->key == 4)
+ message->from = pair->value;
+ else if (pair->key == 5)
+ message->to = pair->value;
else if (pair->key == 15)
- tm = strtol(pair->value, NULL, 10);
- else if (pair->key == 14 || pair->key == 16) {
+ message->tm = strtol(pair->value, NULL, 10);
+ else if (pair->key == 97)
+ message->utf8 = atoi(pair->value);
/* user message */ /* sys message */
- msg = pair->value;
- if (pkt->service == YAHOO_SERVICE_SYSMESSAGE) {
-
YAHOO_CALLBACK(ext_yahoo_system_message)(yd->client_id, msg);
- } else if (pkt->status <= 2 || pkt->status == 5) {
- YAHOO_CALLBACK(ext_yahoo_got_im)(yd->client_id,
from, msg, tm, pkt->status);
- } else if (pkt->status == 0xffffffff) {
- YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id,
msg, 0);
+ else if (pair->key == 14 || pair->key == 16)
+ message->msg = pair->value;
+ else if (pair->key == 31) {
+ if(message->i_31) {
+ messages = y_list_append(messages, message);
+ message = y_new0(struct m, 1);
}
- tm = 0L;
- msg = from = real_from = NULL;
+ message->i_31 = atoi(pair->value);
}
+ else if (pair->key == 32)
+ message->i_32 = atoi(pair->value);
else
LOG(("yahoo_process_message: status: %d, key: %d,
value: %s",
pkt->status, pair->key, pair->value));
}
+ messages = y_list_append(messages, message);
+
+ for (l = messages; l; l=l->next) {
+ message = l->data;
+ if (pkt->service == YAHOO_SERVICE_SYSMESSAGE) {
+ YAHOO_CALLBACK(ext_yahoo_system_message)(yd->client_id,
message->msg);
+ } else if (pkt->status <= 2 || pkt->status == 5) {
+ YAHOO_CALLBACK(ext_yahoo_got_im)(yd->client_id,
message->from, message->msg, message->tm, pkt->status, message->utf8);
+ } else if (pkt->status == 0xffffffff) {
+ YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id,
message->msg, 0);
+ }
+ free(message);
+ }
+
+ y_list_free(messages);
}
@@ -1580,7 +1605,7 @@
yahoo_free_data(yd);
}
-void yahoo_send_im(int id, const char *from, const char *who, const char *what)
+void yahoo_send_im(int id, const char *from, const char *who, const char
*what, int utf8)
{
struct yahoo_data *yd = find_conn_by_id(id);
struct yahoo_packet *pkt = NULL;
@@ -1595,6 +1620,9 @@
yahoo_packet_hash(pkt, 5, who);
yahoo_packet_hash(pkt, 14, what);
+ if(utf8)
+ yahoo_packet_hash(pkt, 97, "1");
+
yahoo_send_packet(yd, pkt, 0);
yahoo_packet_free(pkt);
@@ -1954,7 +1982,7 @@
yahoo_packet_free(pkt);
}
-void yahoo_conference_message(int id, const char * from, YList *who, const
char *room, const char *msg)
+void yahoo_conference_message(int id, const char * from, YList *who, const
char *room, const char *msg, int utf8)
{
struct yahoo_data *yd = find_conn_by_id(id);
struct yahoo_packet *pkt;
@@ -1970,6 +1998,9 @@
}
yahoo_packet_hash(pkt, 57, room);
yahoo_packet_hash(pkt, 14, msg);
+
+ if(utf8)
+ yahoo_packet_hash(pkt, 97, "1");
yahoo_send_packet(yd, pkt, 0);
Index: yahoo2.h
===================================================================
RCS file: /cvsroot/ayttm/ayttm/modules/yahoo2/libyahoo2/yahoo2.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- yahoo2.h 23 Dec 2002 22:05:08 -0000 1.1.1.1
+++ yahoo2.h 15 Jan 2003 12:53:34 -0000 1.2
@@ -67,7 +67,8 @@
void yahoo_keepalive(int id);
/* from is the identity you're sending from. if NULL, the default is used */
-void yahoo_send_im(int id, const char *from, const char *who, const char *msg);
+/* utf8 is whether msg is a utf8 string or not. */
+void yahoo_send_im(int id, const char *from, const char *who, const char *msg,
int utf8);
/* if type is true, send typing notice, else send stopped typing notice */
void yahoo_send_typing(int id, const char *from, const char *who, int typ);
@@ -85,7 +86,7 @@
void yahoo_conference_invite(int id, const char * from, YList *who, const char
*room, const char *msg);
void yahoo_conference_addinvite(int id, const char * from, const char *who,
const char *room, const YList * members, const char *msg);
void yahoo_conference_decline(int id, const char * from, YList *who, const
char *room, const char *msg);
-void yahoo_conference_message(int id, const char * from, YList *who, const
char *room, const char *msg);
+void yahoo_conference_message(int id, const char * from, YList *who, const
char *room, const char *msg, int utf8);
void yahoo_conference_logon(int id, const char * from, YList *who, const char
*room);
void yahoo_conference_logoff(int id, const char * from, YList *who, const char
*room);
Index: yahoo2_callbacks.h
===================================================================
RCS file: /cvsroot/ayttm/ayttm/modules/yahoo2/libyahoo2/yahoo2_callbacks.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- yahoo2_callbacks.h 23 Dec 2002 22:05:09 -0000 1.1.1.1
+++ yahoo2_callbacks.h 15 Jan 2003 12:53:34 -0000 1.2
@@ -149,8 +149,9 @@
* 1
* 2 == error sending message
* 5
+ * utf8 - whether the message is encoded as utf8 or not
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_got_im)(int id, char *who, char *msg, long
tm, int stat);
+void YAHOO_CALLBACK_TYPE(ext_yahoo_got_im)(int id, char *who, char *msg, long
tm, int stat, int utf8);
@@ -218,8 +219,9 @@
* who - the user who messaged
* room - the room
* msg - the message
+ * utf8 - whether the message is utf8 encoded or not
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_message)(int id, char *who, char
*room, char *msg);
+void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_message)(int id, char *who, char
*room, char *msg, int utf8);
Index: yahoo_util.c
===================================================================
RCS file: /cvsroot/ayttm/ayttm/modules/yahoo2/libyahoo2/yahoo_util.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- yahoo_util.c 23 Dec 2002 22:05:09 -0000 1.1.1.1
+++ yahoo_util.c 15 Jan 2003 12:53:34 -0000 1.2
@@ -55,6 +55,56 @@
return new_string;
}
+char * y_str_to_utf8(const char *in)
+{
+ unsigned int n, i = 0;
+ char *result = NULL;
+
+ if(in == NULL || *in == '\0')
+ return "";
+
+ result = malloc(strlen(in) * 2 + 1);
+
+ /* convert a string to UTF-8 Format */
+ for (n = 0; n < strlen(in); n++) {
+ unsigned char c = (unsigned char)in[n];
+
+ if (c < 128) {
+ result[i++] = (char) c;
+ } else {
+ result[i++] = (char) ((c >> 6) | 192);
+ result[i++] = (char) ((c & 63) | 128);
+ }
+ }
+ result[i] = '\0';
+ return result;
+}
+
+char * y_utf8_to_str(const char *in)
+{
+ int i = 0;
+ unsigned int n;
+ char *result = NULL;
+
+ if(in == NULL || *in == '\0')
+ return "";
+
+ result = malloc(strlen(in) + 1);
+
+ /* convert a string from UTF-8 Format */
+ for (n = 0; n < strlen(in); n++) {
+ unsigned char c = in[n];
+
+ if (c < 128) {
+ result[i++] = (char) c;
+ } else {
+ result[i++] = (c << 6) | (in[++n] & 63);
+ }
+ }
+ result[i] = '\0';
+ return result;
+}
+
#if !HAVE_GLIB
void y_strfreev(char ** vector)
Index: yahoo_util.h
===================================================================
RCS file: /cvsroot/ayttm/ayttm/modules/yahoo2/libyahoo2/yahoo_util.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- yahoo_util.h 23 Dec 2002 22:05:09 -0000 1.1.1.1
+++ yahoo_util.h 15 Jan 2003 12:53:34 -0000 1.2
@@ -82,6 +82,8 @@
#endif
char * y_string_append(char * str, char * append);
+char * y_str_to_utf8(const char * in);
+char * y_utf8_to_str(const char * in);
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Ayttm-commits] CVS: ayttm/modules/yahoo2/libyahoo2 libyahoo2.c,1.2,1.3 yahoo2.h,1.1.1.1,1.2 yahoo2_callbacks.h,1.1.1.1,1.2 yahoo_util.c,1.1.1.1,1.2 yahoo_util.h,1.1.1.1,1.2,
Philip S Tellis <address@hidden> <=
- Prev by Date:
[Ayttm-commits] CVS: ayttm/modules/msn2/libmsn2 msn_core.C,1.12,1.13 msn_core.h,1.3,1.4 msn_interface.C,1.2,1.3 msn_interface.h,1.2,1.3
- Next by Date:
[Ayttm-commits] CVS: ayttm configure.in,1.115,1.116 ChangeLog,1.118,1.119
- Previous by thread:
[Ayttm-commits] CVS: ayttm/modules/msn2/libmsn2 msn_core.C,1.12,1.13 msn_core.h,1.3,1.4 msn_interface.C,1.2,1.3 msn_interface.h,1.2,1.3
- Next by thread:
[Ayttm-commits] CVS: ayttm configure.in,1.115,1.116 ChangeLog,1.118,1.119
- Index(es):