[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.6,1.7
From: |
Philip S Tellis <address@hidden> |
Subject: |
[Ayttm-commits] CVS: ayttm/modules/yahoo2/libyahoo2 libyahoo2.c,1.6,1.7 yahoo2.h,1.4,1.5 yahoo2_types.h,1.1.1.1,1.2 yahoo_httplib.c,1.3,1.4 yahoo_httplib.h,1.1.1.1,1.2 |
Date: |
Fri, 24 Jan 2003 08:34:43 -0500 |
Update of /cvsroot/ayttm/ayttm/modules/yahoo2/libyahoo2
In directory subversions:/tmp/cvs-serv13526/modules/yahoo2/libyahoo2
Modified Files:
libyahoo2.c yahoo2.h yahoo2_types.h yahoo_httplib.c
yahoo_httplib.h
Log Message:
changed GList to LList in many places. please test.
Index: libyahoo2.c
===================================================================
RCS file: /cvsroot/ayttm/ayttm/modules/yahoo2/libyahoo2/libyahoo2.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- libyahoo2.c 21 Jan 2003 12:01:23 -0000 1.6
+++ libyahoo2.c 24 Jan 2003 13:34:41 -0000 1.7
@@ -69,6 +69,8 @@
#include <stdlib.h>
#include <ctype.h>
+#include <time.h>
+
#include "md5.h"
#include "yahoo2.h"
#include "yahoo_connections.h"
@@ -133,7 +135,7 @@
YAHOO_SERVICE_ADDIDENT, /* 0x10 */
YAHOO_SERVICE_ADDIGNORE,
YAHOO_SERVICE_PING,
- YAHOO_SERVICE_GOTGROUPRENAME, /* > 1, 36(old), 37(new) */
+ YAHOO_SERVICE_GOTGROUPRENAME, /* < 1, 36(old), 37(new) */
YAHOO_SERVICE_SYSMESSAGE = 0x14,
YAHOO_SERVICE_PASSTHROUGH2 = 0x16,
YAHOO_SERVICE_CONFINVITE = 0x18,
@@ -162,9 +164,9 @@
YAHOO_SERVICE_IGNORECONTACT, /* > 1, 7, 13 < 1, 66, 13, 0*/
YAHOO_SERVICE_REJECTCONTACT,
YAHOO_SERVICE_GROUPRENAME = 0x89, /* > 1, 65(new), 66(0), 67(old) */
- YAHOO_SERVICE_CHATONLINE = 0x96,
+ YAHOO_SERVICE_CHATONLINE = 0x96, /* > 109(id), 1, 6(abcde) < 0,1*/
YAHOO_SERVICE_CHATGOTO,
- YAHOO_SERVICE_CHATJOIN,
+ YAHOO_SERVICE_CHATJOIN, /* > 1 104-room 129-1600326591 62-2 */
YAHOO_SERVICE_CHATLEAVE,
YAHOO_SERVICE_CHATEXIT = 0x9b,
YAHOO_SERVICE_CHATLOGOUT = 0xa0,
@@ -1508,15 +1510,175 @@
return pkt;
}
+static void yahoo_yab_read(struct yab *yab, unsigned char *d, int len)
+{
+ char *st, *en;
+ char *data = (char *)d;
+ data[len]='\0';
+
+ NOTICE(("Got yab: %s", data));
+ st = strstr(data, "userid=\"") + strlen("userid=\"");
+ en = strchr(st, '"');
+ *en++ = '\0';
+
+ yab->id = yahoo_xmldecode(st);
+
+ st = strstr(en, "fname=\"");
+ if(st) {
+ st += strlen("fname=\"");
+ en = strchr(st, '"'); *en++ = '\0';
+ yab->fname = yahoo_xmldecode(st);
+ }
+
+ st = strstr(en, "lname=\"");
+ if(st) {
+ st += strlen("lname=\"");
+ en = strchr(st, '"'); *en++ = '\0';
+ yab->lname = yahoo_xmldecode(st);
+ }
+
+ st = strstr(en, "nname=\"");
+ if(st) {
+ st += strlen("nname=\"");
+ en = strchr(st, '"'); *en++ = '\0';
+ yab->nname = yahoo_xmldecode(st);
+ }
+
+ st = strstr(en, "email=\"");
+ if(st) {
+ st += strlen("email=\"");
+ en = strchr(st, '"'); *en++ = '\0';
+ yab->email = yahoo_xmldecode(st);
+ }
+
+ st = strstr(en, "hphone=\"");
+ if(st) {
+ st += strlen("hphone=\"");
+ en = strchr(st, '"'); *en++ = '\0';
+ yab->hphone = yahoo_xmldecode(st);
+ }
+
+ st = strstr(en, "wphone=\"");
+ if(st) {
+ st += strlen("wphone=\"");
+ en = strchr(st, '"'); *en++ = '\0';
+ yab->wphone = yahoo_xmldecode(st);
+ }
+
+ st = strstr(en, "mphone=\"");
+ if(st) {
+ st += strlen("mphone=\"");
+ en = strchr(st, '"'); *en++ = '\0';
+ yab->mphone = yahoo_xmldecode(st);
+ }
+}
+
+static struct yab * yahoo_getyab(struct yahoo_data *yd)
+{
+ struct yab *yab = NULL;
+ int pos = 0, end=0;
+
+ DEBUG_MSG(("rxlen is %d", yd->rxlen));
+
+ while(pos < yd->rxlen) {
+ if(yd->rxqueue[pos] == '<' && yd->rxqueue[pos+1] == 'r')
+ break;
+ pos++;
+ }
+
+ if(pos >= yd->rxlen)
+ return NULL;
+
+ end = pos+2;
+ while(end < yd->rxlen) {
+ if(yd->rxqueue[end] == '/' && yd->rxqueue[end+1] == '>')
+ break;
+ end++;
+ }
+
+ if(end >= yd->rxlen)
+ return NULL;
+
+ yab = y_new0(struct yab, 1);
+ yahoo_yab_read(yab, yd->rxqueue + pos, end+2-pos);
+
+
+ yd->rxlen -= end+1;
+ DEBUG_MSG(("rxlen == %d, rxqueue == %p", yd->rxlen, yd->rxqueue));
+ if (yd->rxlen>0) {
+ unsigned char *tmp = y_memdup(yd->rxqueue + end + 1, yd->rxlen);
+ FREE(yd->rxqueue);
+ yd->rxqueue = tmp;
+ DEBUG_MSG(("new rxlen == %d, rxqueue == %p", yd->rxlen,
yd->rxqueue));
+ } else {
+ DEBUG_MSG(("freed rxqueue == %p", yd->rxqueue));
+ FREE(yd->rxqueue);
+ }
+
+
+ return yab;
+}
+
int yahoo_write_ready(int id, int fd)
{
return 1;
}
+static void yahoo_process_pager_connection(struct yahoo_data *yd)
+{
+ struct yahoo_packet *pkt;
+
+ while ((pkt = yahoo_getdata(yd)) != NULL) {
+
+ yahoo_packet_process(yd, pkt);
+
+ yahoo_packet_free(pkt);
+ }
+}
+
+static void yahoo_process_ft_connection(struct yahoo_data *yd)
+{
+}
+
+static void yahoo_process_yab_connection(struct yahoo_data *yd)
+{
+ struct yab *yab;
+ YList *buds;
+
+ while((yab = yahoo_getyab(yd)) != NULL) {
+ for(buds = yd->buddies; buds; buds=buds->next) {
+ struct yahoo_buddy * bud = buds->data;
+ if(!strcmp(bud->id, yab->id)) {
+ bud->yab_entry = yab;
+ if(yab->nname) {
+ bud->real_name = strdup(yab->nname);
+ } else if(yab->fname && yab->lname) {
+ bud->real_name = y_new0(char,
+ strlen(yab->fname)+
+ strlen(yab->lname)+2
+ );
+ sprintf(bud->real_name, "%s %s",
+ yab->fname, yab->lname);
+ } else if(yab->fname) {
+ bud->real_name = strdup(yab->fname);
+ }
+ break; /* for */
+ }
+ }
+ }
+
+ YAHOO_CALLBACK(ext_yahoo_got_buddies)(yd->client_id, yd->buddies);
+}
+
+static void (*yahoo_process_connection[])(struct yahoo_data *) = {
+ yahoo_process_pager_connection,
+ yahoo_process_ft_connection,
+ yahoo_process_yab_connection
+};
+
int yahoo_read_ready(int id, int fd)
{
struct yahoo_data *yd = find_conn_by_id(id);
- struct yahoo_packet *pkt;
char buf[1024];
int len;
@@ -1550,12 +1712,7 @@
memcpy(yd->rxqueue + yd->rxlen, buf, len);
yd->rxlen += len;
- while ((pkt = yahoo_getdata(yd)) != NULL) {
-
- yahoo_packet_process(yd, pkt);
-
- yahoo_packet_free(pkt);
- }
+ yahoo_process_connection[yd->type](yd);
return len;
}
@@ -1643,7 +1800,7 @@
if(utf8)
yahoo_packet_hash(pkt, 97, "1");
- yahoo_packet_hash(pkt, 63, ";0");
+ yahoo_packet_hash(pkt, 63, ";0"); /* imvironment name; or ;0 */
yahoo_packet_hash(pkt, 64, "0");
@@ -1743,6 +1900,38 @@
}
}
+void yahoo_get_yab(int id)
+{
+ struct yahoo_data *yd = find_conn_by_id(id);
+ struct yahoo_data *nyd;
+ time_t tm = time(NULL);
+ char url[1024];
+ char buff[1024];
+
+ if(!yd)
+ return;
+
+ nyd = y_new0(struct yahoo_data, 1);
+ nyd->id = yd->id;
+ nyd->client_id = ++last_id;
+ nyd->type = YAHOO_CONNECTION_YAB;
+ nyd->buddies = yd->buddies;
+
+ snprintf(url, 1024, "http://insider.msg.yahoo.com/ycontent/?"
+ "filter=%lu&imv=%lu&system=%lu&sms=%lu&chatcat=%lu"
+ "&ab2=0&intl=us&os=win", tm, tm, tm, tm, tm);
+
+ snprintf(buff, sizeof(buff), "Y=%s; T=%s",
+ yd->cookie_y, yd->cookie_t);
+
+ nyd->fd = yahoo_http_get(url, buff);
+
+ add_to_list(nyd, nyd->fd);
+
+ YAHOO_CALLBACK(ext_yahoo_add_handler)(nyd->client_id, nyd->fd,
YAHOO_INPUT_READ);
+
+}
+
void yahoo_set_identity_status(int id, const char * identity, int active)
{
struct yahoo_data *yd = find_conn_by_id(id);
@@ -2061,7 +2250,7 @@
nyd->user = strdup(yd->user);
nyd->cookie_y = strdup(yd->cookie_y);
nyd->cookie_t = strdup(yd->cookie_t);
- nyd->type = YAHOO_CONNECTION_HTTP;
+ nyd->type = YAHOO_CONNECTION_FT;
pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANSFER,
YAHOO_STATUS_AVAILABLE, nyd->id);
@@ -2077,7 +2266,9 @@
snprintf(url, sizeof(url), "http://%s:%s/notifyft",
filetransfer_host, filetransfer_port);
- nyd->fd = yahoo_http_post(url, nyd, content_length + 4 + size);
+ snprintf((char *)buff, sizeof(buff), "Y=%s; T=%s",
+ nyd->cookie_y, nyd->cookie_t);
+ nyd->fd = yahoo_http_post(url, (char *)buff, content_length + 4 + size);
add_to_list(nyd, nyd->fd);
Index: yahoo2.h
===================================================================
RCS file: /cvsroot/ayttm/ayttm/modules/yahoo2/libyahoo2/yahoo2.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- yahoo2.h 21 Jan 2003 12:01:23 -0000 1.4
+++ yahoo2.h 24 Jan 2003 13:34:41 -0000 1.5
@@ -51,6 +51,8 @@
void yahoo_set_identity_status(int id, const char * identity, int active);
/* regets the entire buddy list from the server */
void yahoo_get_list(int id);
+/* download buddy contact information from your yahoo addressbook */
+void yahoo_get_yab(int id);
void yahoo_keepalive(int id);
/* from is the identity you're sending from. if NULL, the default is used */
Index: yahoo2_types.h
===================================================================
RCS file: /cvsroot/ayttm/ayttm/modules/yahoo2/libyahoo2/yahoo2_types.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- yahoo2_types.h 23 Dec 2002 22:05:09 -0000 1.1.1.1
+++ yahoo2_types.h 24 Jan 2003 13:34:41 -0000 1.2
@@ -100,7 +100,8 @@
enum yahoo_connection_type {
YAHOO_CONNECTION_PAGER=0,
- YAHOO_CONNECTION_HTTP=1
+ YAHOO_CONNECTION_FT,
+ YAHOO_CONNECTION_YAB
};
struct yahoo_data {
@@ -134,10 +135,22 @@
char *ignorelist;
};
+struct yab {
+ char *id;
+ char *fname;
+ char *lname;
+ char *nname;
+ char *email;
+ char *hphone;
+ char *wphone;
+ char *mphone;
+};
+
struct yahoo_buddy {
char *group;
char *id;
char *real_name;
+ struct yab *yab_entry;
};
#ifdef __cplusplus
Index: yahoo_httplib.c
===================================================================
RCS file: /cvsroot/ayttm/ayttm/modules/yahoo2/libyahoo2/yahoo_httplib.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- yahoo_httplib.c 19 Jan 2003 13:58:05 -0000 1.3
+++ yahoo_httplib.c 24 Jan 2003 13:34:41 -0000 1.4
@@ -203,6 +203,62 @@
return (str);
}
+char *yahoo_xmldecode(const char *instr)
+{
+ int ipos=0, bpos=0, epos=0;
+ char *str = NULL;
+ char entity[4]={0,0,0,0};
+ char *entitymap[5][2]={
+ {"amp;", "&"},
+ {"quot;", "\""},
+ {"lt;", "<"},
+ {"gt;", "<"},
+ {"nbsp;", " "}
+ };
+ unsigned dec;
+ int len = strlen(instr);
+
+ if(!(str = y_new(char, len+1) ))
+ return "";
+
+ while(instr[ipos]) {
+ while(instr[ipos] && instr[ipos]!='&')
+ if(instr[ipos]=='+') {
+ str[bpos++]=' ';
+ ipos++;
+ } else
+ str[bpos++] = instr[ipos++];
+ if(!instr[ipos] || !instr[ipos+1])
+ break;
+ ipos++;
+
+ if(instr[ipos] == '#') {
+ ipos++;
+ while(instr[ipos] != ';')
+ entity[epos++]=instr[ipos++];
+ sscanf(entity, "%u", &dec);
+ str[bpos++] = (char)dec;
+ ipos++;
+ } else {
+ int i;
+ for (i=0; i<5; i++)
+ if(!strncmp(instr+ipos, entitymap[i][0],
+ strlen(entitymap[i][0]))) {
+ str[bpos++] = entitymap[i][1][0];
+ ipos += strlen(entitymap[i][0]);
+ break;
+ }
+ }
+ }
+ str[bpos]='\0';
+
+ /* free extra alloc'ed mem. */
+ len = strlen(str);
+ str = y_renew(char, str, len+1);
+
+ return (str);
+}
+
static int yahoo_send_http_request(char *host, int port, char *request)
{
int fd = yahoo_connect(host, port);
@@ -213,7 +269,7 @@
return fd;
}
-int yahoo_http_post(const char *url, const struct yahoo_data *yd, long
content_length)
+int yahoo_http_post(const char *url, const char *cookies, long content_length)
{
char host[255];
int port = 80;
@@ -224,20 +280,20 @@
return 0;
snprintf(buff, sizeof(buff),
- "POST %s HTTP/1.0\n"
- "Content-length: %ld\n"
- "User-Agent: Mozilla/4.5 [en] (" PACKAGE "/" VERSION
")\n"
- "Host: %s:%d\n"
- "Cookie: Y=%s; T=%s\n"
- "\n",
+ "POST %s HTTP/1.0\r\n"
+ "Content-length: %ld\r\n"
+ "User-Agent: Mozilla/4.5 [en] (" PACKAGE "/" VERSION
")\r\n"
+ "Host: %s:%d\r\n"
+ "Cookie: %s\r\n"
+ "\r\n",
path, content_length,
host, port,
- yd->cookie_y, yd->cookie_t);
+ cookies);
return yahoo_send_http_request(host, port, buff);
}
-int yahoo_http_get(const char *url, const struct yahoo_data *yd)
+int yahoo_http_get(const char *url, const char *cookies)
{
char host[255];
int port = 80;
@@ -250,10 +306,10 @@
snprintf(buff, sizeof(buff),
"GET %s HTTP/1.0\r\n"
"Host: %s:%d\r\n"
- "User-Agent: Mozilla/4.6 (libyahoo/1.0)\r\n"
- "Cookie: Y=%s\r\n"
+ "User-Agent: Mozilla/4.5 [en] (" PACKAGE "/" VERSION
")\r\n"
+ "Cookie: %s\r\n"
"\r\n",
- path, host, port, yd->cookie_y);
+ path, host, port, cookies);
return yahoo_send_http_request(host, port, buff);
}
@@ -264,8 +320,10 @@
char *tmp=NULL;
int fd=0;
char buff[1024];
+
+ snprintf(buff, sizeof(buff), "Y=%s; T=%s", yd->cookie_y, yd->cookie_t);
- fd = yahoo_http_get(url, yd);
+ fd = yahoo_http_get(url, buff);
while(yahoo_tcp_readline(buff, 1024, fd) > 0) {
/* read up to blank line */
Index: yahoo_httplib.h
===================================================================
RCS file: /cvsroot/ayttm/ayttm/modules/yahoo2/libyahoo2/yahoo_httplib.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- yahoo_httplib.h 23 Dec 2002 22:05:09 -0000 1.1.1.1
+++ yahoo_httplib.h 24 Jan 2003 13:34:41 -0000 1.2
@@ -28,11 +28,13 @@
#include "yahoo2_types.h"
-int yahoo_tcp_readline(char *ptr, int maxlen, int fd);
char *yahoo_urlencode(const char *instr);
char *yahoo_urldecode(const char *instr);
-int yahoo_http_post(const char *url, const struct yahoo_data *yd, long size);
-int yahoo_http_get(const char *url, const struct yahoo_data *yd);
+char *yahoo_xmldecode(const char *instr);
+
+int yahoo_tcp_readline(char *ptr, int maxlen, int fd);
+int yahoo_http_post(const char *url, const char *cookies, long size);
+int yahoo_http_get(const char *url, const char *cookies);
int yahoo_get_url_fd(const char *url, const struct yahoo_data *yd,
char *filename, unsigned long *filesize);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Ayttm-commits] CVS: ayttm/modules/yahoo2/libyahoo2 libyahoo2.c,1.6,1.7 yahoo2.h,1.4,1.5 yahoo2_types.h,1.1.1.1,1.2 yahoo_httplib.c,1.3,1.4 yahoo_httplib.h,1.1.1.1,1.2,
Philip S Tellis <address@hidden> <=
- Prev by Date:
[Ayttm-commits] CVS: ayttm/modules/icq icq.c,1.6,1.7
- Next by Date:
[Ayttm-commits] CVS: ayttm ChangeLog,1.198,1.199 TODO,1.3,1.4 configure.in,1.194,1.195
- Previous by thread:
[Ayttm-commits] CVS: ayttm/modules/icq icq.c,1.6,1.7
- Next by thread:
[Ayttm-commits] CVS: ayttm ChangeLog,1.198,1.199 TODO,1.3,1.4 configure.in,1.194,1.195
- Index(es):