aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2010-07-24 15:29:48 +0200
committerWilmer van der Gaast <wilmer@gaast.net>2010-07-24 15:29:48 +0200
commitc8791f25459aeb32f770c46bd3a3613c9fd2d0e2 (patch)
tree6fb660cf39c58f3d880d4db7466391fdff169811
parent938c30512f4dac4f084fd6bb8b7f41655de9bce4 (diff)
parentc495217e7c02c908d831645b033cf115ccdc3d6d (diff)
Merging libyahoo2 fixes. Now completely up-to-date with libyahoo2 svn
again, should try to keep it up a little bit better and submit my fixes upstream. This also adds code for Yahoo! file transfers but BitlBee isn't using it yet. (It doesn't seem to support flow control which makes this complicated.)
-rw-r--r--protocols/yahoo/Makefile2
-rw-r--r--protocols/yahoo/libyahoo2.c4183
-rw-r--r--protocols/yahoo/yahoo.c157
-rw-r--r--protocols/yahoo/yahoo2.h151
-rw-r--r--protocols/yahoo/yahoo2_callbacks.h309
-rw-r--r--protocols/yahoo/yahoo2_types.h538
-rw-r--r--protocols/yahoo/yahoo_fn.h17
-rw-r--r--protocols/yahoo/yahoo_httplib.c337
-rw-r--r--protocols/yahoo/yahoo_httplib.h26
-rw-r--r--protocols/yahoo/yahoo_list.h2
-rw-r--r--protocols/yahoo/yahoo_util.c6
-rw-r--r--protocols/yahoo/yahoo_util.h20
12 files changed, 3030 insertions, 2718 deletions
diff --git a/protocols/yahoo/Makefile b/protocols/yahoo/Makefile
index 20ecce71..e5374538 100644
--- a/protocols/yahoo/Makefile
+++ b/protocols/yahoo/Makefile
@@ -14,7 +14,7 @@ endif
# [SH] Program variables
objects = yahoo.o crypt.o libyahoo2.o yahoo_fn.o yahoo_httplib.o yahoo_util.o
-CFLAGS += -Wall -DSTDC_HEADERS -DHAVE_STRING_H -DHAVE_STRCHR -DHAVE_MEMCPY -DHAVE_GLIB
+CFLAGS += -Wall -DSTDC_HEADERS -DHAVE_STRING_H -DHAVE_STRCHR -DHAVE_MEMCPY -DHAVE_GLIB -Wno-pointer-to-int-cast
LFLAGS += -r
# [SH] Phony targets
diff --git a/protocols/yahoo/libyahoo2.c b/protocols/yahoo/libyahoo2.c
index 1bfc2e59..bd111654 100644
--- a/protocols/yahoo/libyahoo2.c
+++ b/protocols/yahoo/libyahoo2.c
@@ -2,6 +2,8 @@
* libyahoo2: libyahoo2.c
*
* Some code copyright (C) 2002-2004, Philip S Tellis <philip.tellis AT gmx.net>
+ * YMSG16 code copyright (C) 2009,
+ * Siddhesh Poyarekar <siddhesh dot poyarekar at gmail dot com>
*
* Yahoo Search copyright (C) 2003, Konstantin Klyagin <konst AT konst.org.ua>
*
@@ -26,6 +28,8 @@
* Portions of Sylpheed copyright 2000-2002 Hiroyuki Yamamoto
* <hiro-y@kcn.ne.jp>
*
+ * YMSG16 authentication code based mostly on write-up at:
+ * http://www.carbonize.co.uk/ymsg16.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -91,9 +95,9 @@ char *strchr (), *strrchr ();
#include "http_client.h"
#ifdef USE_STRUCT_CALLBACKS
-struct yahoo_callbacks *yc=NULL;
+struct yahoo_callbacks *yc = NULL;
-void yahoo_register_callbacks(struct yahoo_callbacks * tyc)
+void yahoo_register_callbacks(struct yahoo_callbacks *tyc)
{
yc = tyc;
}
@@ -103,21 +107,23 @@ void yahoo_register_callbacks(struct yahoo_callbacks * tyc)
#define YAHOO_CALLBACK(x) x
#endif
-static int yahoo_send_data(int fd, void *data, int len);
+static int yahoo_send_data(void *fd, void *data, int len);
+static void _yahoo_http_connected(int id, void *fd, int error, void *data);
+static void yahoo_connected(void *fd, int error, void *data);
-int yahoo_log_message(char * fmt, ...)
+int yahoo_log_message(char *fmt, ...)
{
char out[1024];
va_list ap;
va_start(ap, fmt);
vsnprintf(out, sizeof(out), fmt, ap);
va_end(ap);
- return YAHOO_CALLBACK(ext_yahoo_log)("%s", out);
+ return YAHOO_CALLBACK(ext_yahoo_log) ("%s", out);
}
-int yahoo_connect(char * host, int port)
+int yahoo_connect(char *host, int port)
{
- return YAHOO_CALLBACK(ext_yahoo_connect)(host, port);
+ return YAHOO_CALLBACK(ext_yahoo_connect) (host, port);
}
static enum yahoo_log_level log_level = YAHOO_LOG_NONE;
@@ -135,97 +141,30 @@ int yahoo_set_log_level(enum yahoo_log_level level)
}
/* default values for servers */
-static char pager_host[] = "scs.msg.yahoo.com";
+static char *default_pager_hosts[] = { "scs.msg.yahoo.com",
+ "scsa.msg.yahoo.com",
+ "scsb.msg.yahoo.com",
+ "scsc.msg.yahoo.com",
+ NULL};
+
static int pager_port = 5050;
-static int fallback_ports[]={23, 25, 80, 20, 119, 8001, 8002, 5050, 0};
-static char filetransfer_host[]="filetransfer.msg.yahoo.com";
-static int filetransfer_port=80;
-static char webcam_host[]="webcam.yahoo.com";
-static int webcam_port=5100;
-static char webcam_description[]="";
-static char local_host[]="";
-static int conn_type=Y_WCM_DSL;
+static int fallback_ports[] = { 23, 25, 80, 20, 119, 8001, 8002, 5050, 0 };
+
+static char filetransfer_host[] = "filetransfer.msg.yahoo.com";
+static int filetransfer_port = 80;
+static char webcam_host[] = "webcam.yahoo.com";
+static int webcam_port = 5100;
+static char webcam_description[] = "";
+static char local_host[] = "";
+static int conn_type = Y_WCM_DSL;
static char profile_url[] = "http://profiles.yahoo.com/";
-enum yahoo_service { /* these are easier to see in hex */
- YAHOO_SERVICE_LOGON = 1,
- YAHOO_SERVICE_LOGOFF,
- YAHOO_SERVICE_ISAWAY,
- YAHOO_SERVICE_ISBACK,
- YAHOO_SERVICE_IDLE, /* 5 (placemarker) */
- YAHOO_SERVICE_MESSAGE,
- YAHOO_SERVICE_IDACT,
- YAHOO_SERVICE_IDDEACT,
- YAHOO_SERVICE_MAILSTAT,
- YAHOO_SERVICE_USERSTAT, /* 0xa */
- YAHOO_SERVICE_NEWMAIL,
- YAHOO_SERVICE_CHATINVITE,
- YAHOO_SERVICE_CALENDAR,
- YAHOO_SERVICE_NEWPERSONALMAIL,
- YAHOO_SERVICE_NEWCONTACT,
- YAHOO_SERVICE_ADDIDENT, /* 0x10 */
- YAHOO_SERVICE_ADDIGNORE,
- YAHOO_SERVICE_PING,
- YAHOO_SERVICE_GOTGROUPRENAME, /* < 1, 36(old), 37(new) */
- YAHOO_SERVICE_SYSMESSAGE = 0x14,
- YAHOO_SERVICE_SKINNAME = 0x15,
- YAHOO_SERVICE_PASSTHROUGH2 = 0x16,
- YAHOO_SERVICE_CONFINVITE = 0x18,
- YAHOO_SERVICE_CONFLOGON,
- YAHOO_SERVICE_CONFDECLINE,
- YAHOO_SERVICE_CONFLOGOFF,
- YAHOO_SERVICE_CONFADDINVITE,
- YAHOO_SERVICE_CONFMSG,
- YAHOO_SERVICE_CHATLOGON,
- YAHOO_SERVICE_CHATLOGOFF,
- YAHOO_SERVICE_CHATMSG = 0x20,
- YAHOO_SERVICE_GAMELOGON = 0x28,
- YAHOO_SERVICE_GAMELOGOFF,
- YAHOO_SERVICE_GAMEMSG = 0x2a,
- YAHOO_SERVICE_FILETRANSFER = 0x46,
- YAHOO_SERVICE_VOICECHAT = 0x4A,
- YAHOO_SERVICE_NOTIFY,
- YAHOO_SERVICE_VERIFY,
- YAHOO_SERVICE_P2PFILEXFER,
- YAHOO_SERVICE_PEERTOPEER = 0x4F, /* Checks if P2P possible */
- YAHOO_SERVICE_WEBCAM,
- YAHOO_SERVICE_AUTHRESP = 0x54,
- YAHOO_SERVICE_LIST,
- YAHOO_SERVICE_AUTH = 0x57,
- YAHOO_SERVICE_AUTHBUDDY = 0x6d,
- YAHOO_SERVICE_ADDBUDDY = 0x83,
- YAHOO_SERVICE_REMBUDDY,
- 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_Y7_PING = 0x8A, /* 0 - id and that's it?? */
- YAHOO_SERVICE_CHATONLINE = 0x96, /* > 109(id), 1, 6(abcde) < 0,1*/
- YAHOO_SERVICE_CHATGOTO,
- YAHOO_SERVICE_CHATJOIN, /* > 1 104-room 129-1600326591 62-2 */
- YAHOO_SERVICE_CHATLEAVE,
- YAHOO_SERVICE_CHATEXIT = 0x9b,
- YAHOO_SERVICE_CHATADDINVITE = 0x9d,
- YAHOO_SERVICE_CHATLOGOUT = 0xa0,
- YAHOO_SERVICE_CHATPING,
- YAHOO_SERVICE_COMMENT = 0xa8,
- YAHOO_SERVICE_STEALTH = 0xb9,
- YAHOO_SERVICE_PICTURE_CHECKSUM = 0xbd,
- YAHOO_SERVICE_PICTURE = 0xbe,
- YAHOO_SERVICE_PICTURE_UPDATE = 0xc1,
- YAHOO_SERVICE_PICTURE_UPLOAD = 0xc2,
- YAHOO_SERVICE_Y6_VISIBILITY=0xc5,
- YAHOO_SERVICE_Y6_STATUS_UPDATE=0xc6,
- YAHOO_PHOTOSHARE_INIT=0xd2,
- YAHOO_SERVICE_CONTACT_YMSG13=0xd6,
- YAHOO_PHOTOSHARE_PREV=0xd7,
- YAHOO_PHOTOSHARE_KEY=0xd8,
- YAHOO_PHOTOSHARE_TRANS=0xda,
- YAHOO_FILE_TRANSFER_INIT_YMSG13=0xdc,
- YAHOO_FILE_TRANSFER_GET_YMSG13=0xdd,
- YAHOO_FILE_TRANSFER_PUT_YMSG13=0xde,
- YAHOO_SERVICE_YMSG15_STATUS=0xf0,
- YAHOO_SERVICE_YMSG15_BUDDY_LIST=0xf1,
+struct connect_callback_data {
+ struct yahoo_data *yd;
+ int tag;
+ int i;
+ int server_i;
};
struct yahoo_pair {
@@ -241,15 +180,15 @@ struct yahoo_packet {
};
struct yahoo_search_state {
- int lsearch_type;
- char *lsearch_text;
- int lsearch_gender;
- int lsearch_agerange;
- int lsearch_photo;
- int lsearch_yahoo_only;
- int lsearch_nstart;
- int lsearch_nfound;
- int lsearch_ntotal;
+ int lsearch_type;
+ char *lsearch_text;
+ int lsearch_gender;
+ int lsearch_agerange;
+ int lsearch_photo;
+ int lsearch_yahoo_only;
+ int lsearch_nstart;
+ int lsearch_nfound;
+ int lsearch_ntotal;
};
struct data_queue {
@@ -263,34 +202,52 @@ struct yahoo_input_data {
struct yahoo_webcam_data *wcd;
struct yahoo_search_state *ys;
- int fd;
+ void *fd;
enum yahoo_connection_type type;
-
- unsigned char *rxqueue;
- int rxlen;
- int read_tag;
+
+ unsigned char *rxqueue;
+ int rxlen;
+ int read_tag;
YList *txqueues;
- int write_tag;
+ int write_tag;
};
struct yahoo_server_settings {
char *pager_host;
- int pager_port;
+ int pager_port;
char *filetransfer_host;
- int filetransfer_port;
+ int filetransfer_port;
char *webcam_host;
- int webcam_port;
+ int webcam_port;
char *webcam_description;
char *local_host;
- int conn_type;
+ int conn_type;
+ char **pager_host_list;
};
-static void * _yahoo_default_server_settings()
+static void yahoo_process_ft_connection(struct yahoo_input_data *yid, int over);
+
+static void yahoo_process_filetransfer(struct yahoo_input_data *yid,
+ struct yahoo_packet *pkt);
+static void yahoo_process_filetransferinfo(struct yahoo_input_data *yid,
+ struct yahoo_packet *pkt);
+static void yahoo_process_filetransferaccept(struct yahoo_input_data *yid,
+ struct yahoo_packet *pkt);
+
+static void yahoo_https_auth(struct yahoo_input_data *yid, const char *seed, const char *sn);
+
+static void *_yahoo_default_server_settings()
{
- struct yahoo_server_settings *yss = y_new0(struct yahoo_server_settings, 1);
+ struct yahoo_server_settings *yss =
+ y_new0(struct yahoo_server_settings, 1);
+
+ /* Give preference to the default host list
+ * Make sure that only one of the two is set at any time
+ */
+ yss->pager_host = NULL;
+ yss->pager_host_list = default_pager_hosts;
- yss->pager_host = strdup(pager_host);
yss->pager_port = pager_port;
yss->filetransfer_host = strdup(filetransfer_host);
yss->filetransfer_port = filetransfer_port;
@@ -303,54 +260,61 @@ static void * _yahoo_default_server_settings()
return yss;
}
-static void * _yahoo_assign_server_settings(va_list ap)
+static void *_yahoo_assign_server_settings(va_list ap)
{
struct yahoo_server_settings *yss = _yahoo_default_server_settings();
char *key;
char *svalue;
- int nvalue;
+ int nvalue;
+ char **pvalue;
- while(1) {
+ while (1) {
key = va_arg(ap, char *);
- if(key == NULL)
+ if (key == NULL)
break;
- if(!strcmp(key, "pager_host")) {
+ if (!strcmp(key, "pager_host")) {
svalue = va_arg(ap, char *);
free(yss->pager_host);
yss->pager_host = strdup(svalue);
- } else if(!strcmp(key, "pager_port")) {
+ yss->pager_host_list = NULL;
+ } else if (!strcmp(key, "pager_host_list")) {
+ pvalue = va_arg(ap, char **);
+ yss->pager_host_list = pvalue;
+ free(yss->pager_host);
+ yss->pager_host = NULL;
+ } else if (!strcmp(key, "pager_port")) {
nvalue = va_arg(ap, int);
yss->pager_port = nvalue;
- } else if(!strcmp(key, "filetransfer_host")) {
+ } else if (!strcmp(key, "filetransfer_host")) {
svalue = va_arg(ap, char *);
free(yss->filetransfer_host);
yss->filetransfer_host = strdup(svalue);
- } else if(!strcmp(key, "filetransfer_port")) {
+ } else if (!strcmp(key, "filetransfer_port")) {
nvalue = va_arg(ap, int);
yss->filetransfer_port = nvalue;
- } else if(!strcmp(key, "webcam_host")) {
+ } else if (!strcmp(key, "webcam_host")) {
svalue = va_arg(ap, char *);
free(yss->webcam_host);
yss->webcam_host = strdup(svalue);
- } else if(!strcmp(key, "webcam_port")) {
+ } else if (!strcmp(key, "webcam_port")) {
nvalue = va_arg(ap, int);
yss->webcam_port = nvalue;
- } else if(!strcmp(key, "webcam_description")) {
+ } else if (!strcmp(key, "webcam_description")) {
svalue = va_arg(ap, char *);
free(yss->webcam_description);
yss->webcam_description = strdup(svalue);
- } else if(!strcmp(key, "local_host")) {
+ } else if (!strcmp(key, "local_host")) {
svalue = va_arg(ap, char *);
free(yss->local_host);
yss->local_host = strdup(svalue);
- } else if(!strcmp(key, "conn_type")) {
+ } else if (!strcmp(key, "conn_type")) {
nvalue = va_arg(ap, int);
yss->conn_type = nvalue;
} else {
WARNING(("Unknown key passed to yahoo_init, "
- "perhaps you didn't terminate the list "
- "with NULL"));
+ "perhaps you didn't terminate the list "
+ "with NULL"));
}
}
@@ -359,7 +323,7 @@ static void * _yahoo_assign_server_settings(va_list ap)
static void yahoo_free_server_settings(struct yahoo_server_settings *yss)
{
- if(!yss)
+ if (!yss)
return;
free(yss->pager_host);
@@ -371,30 +335,33 @@ static void yahoo_free_server_settings(struct yahoo_server_settings *yss)
free(yss);
}
-static YList *conns=NULL;
-static YList *inputs=NULL;
-static int last_id=0;
+static YList *conns = NULL;
+static YList *inputs = NULL;
+static int last_id = 0;
static void add_to_list(struct yahoo_data *yd)
{
conns = y_list_prepend(conns, yd);
}
-static struct yahoo_data * find_conn_by_id(int id)
+
+static struct yahoo_data *find_conn_by_id(int id)
{
YList *l;
- for(l = conns; l; l = y_list_next(l)) {
+ for (l = conns; l; l = y_list_next(l)) {
struct yahoo_data *yd = l->data;
- if(yd->client_id == id)
+ if (yd->client_id == id)
return yd;
}
return NULL;
}
+
static void del_from_list(struct yahoo_data *yd)
{
conns = y_list_remove(conns, yd);
}
/* call repeatedly to get the next one */
+/*
static struct yahoo_input_data * find_input_by_id(int id)
{
YList *l;
@@ -405,41 +372,45 @@ static struct yahoo_input_data * find_input_by_id(int id)
}
return NULL;
}
+*/
-static struct yahoo_input_data * find_input_by_id_and_webcam_user(int id, const char * who)
+static struct yahoo_input_data *find_input_by_id_and_webcam_user(int id,
+ const char *who)
{
YList *l;
LOG(("find_input_by_id_and_webcam_user"));
- for(l = inputs; l; l = y_list_next(l)) {
+ for (l = inputs; l; l = y_list_next(l)) {
struct yahoo_input_data *yid = l->data;
- if(yid->type == YAHOO_CONNECTION_WEBCAM && yid->yd->client_id == id
- && yid->wcm &&
- ((who && yid->wcm->user && !strcmp(who, yid->wcm->user)) ||
- !(yid->wcm->user && !who)))
+ if (yid->type == YAHOO_CONNECTION_WEBCAM
+ && yid->yd->client_id == id && yid->wcm && ((who
+ && yid->wcm->user
+ && !strcmp(who, yid->wcm->user))
+ || !(yid->wcm->user && !who)))
return yid;
}
return NULL;
}
-static struct yahoo_input_data * find_input_by_id_and_type(int id, enum yahoo_connection_type type)
+static struct yahoo_input_data *find_input_by_id_and_type(int id,
+ enum yahoo_connection_type type)
{
YList *l;
LOG(("find_input_by_id_and_type"));
- for(l = inputs; l; l = y_list_next(l)) {
+ for (l = inputs; l; l = y_list_next(l)) {
struct yahoo_input_data *yid = l->data;
- if(yid->type == type && yid->yd->client_id == id)
+ if (yid->type == type && yid->yd->client_id == id)
return yid;
}
return NULL;
}
-static struct yahoo_input_data * find_input_by_id_and_fd(int id, int fd)
+static struct yahoo_input_data *find_input_by_id_and_fd(int id, void *fd)
{
YList *l;
LOG(("find_input_by_id_and_fd"));
- for(l = inputs; l; l = y_list_next(l)) {
+ for (l = inputs; l; l = y_list_next(l)) {
struct yahoo_input_data *yid = l->data;
- if(yid->fd == fd && yid->yd->client_id == id)
+ if (yid->fd == fd && yid->yd->client_id == id)
return yid;
}
return NULL;
@@ -447,36 +418,34 @@ static struct yahoo_input_data * find_input_by_id_and_fd(int id, int fd)
static int count_inputs_with_id(int id)
{
- int c=0;
+ int c = 0;
YList *l;
LOG(("counting %d", id));
- for(l = inputs; l; l = y_list_next(l)) {
+ for (l = inputs; l; l = y_list_next(l)) {
struct yahoo_input_data *yid = l->data;
- if(yid->yd->client_id == id)
+ if (yid->yd->client_id == id)
c++;
}
LOG(("%d", c));
return c;
}
-
extern char *yahoo_crypt(char *, char *);
/* Free a buddy list */
-static void yahoo_free_buddies(YList * list)
+static void yahoo_free_buddies(YList *list)
{
YList *l;
- for(l = list; l; l = l->next)
- {
+ for (l = list; l; l = l->next) {
struct yahoo_buddy *bud = l->data;
- if(!bud)
+ if (!bud)
continue;
FREE(bud->group);
FREE(bud->id);
FREE(bud->real_name);
- if(bud->yab_entry) {
+ if (bud->yab_entry) {
FREE(bud->yab_entry->fname);
FREE(bud->yab_entry->lname);
FREE(bud->yab_entry->nname);
@@ -495,7 +464,7 @@ static void yahoo_free_buddies(YList * list)
}
/* Free an identities list */
-static void yahoo_free_identities(YList * list)
+static void yahoo_free_identities(YList *list)
{
while (list) {
YList *n = list;
@@ -524,6 +493,7 @@ static void yahoo_free_data(struct yahoo_data *yd)
FREE(yd->password);
FREE(yd->cookie_y);
FREE(yd->cookie_t);
+ FREE(yd->cookie_b);
FREE(yd->cookie_c);
FREE(yd->login_cookie);
FREE(yd->login_id);
@@ -539,8 +509,8 @@ static void yahoo_free_data(struct yahoo_data *yd)
#define YAHOO_PACKET_HDRLEN (4 + 2 + 2 + 2 + 2 + 4 + 4)
-static struct yahoo_packet *yahoo_packet_new(enum yahoo_service service,
- enum yahoo_status status, int id)
+static struct yahoo_packet *yahoo_packet_new(enum yahoo_service service,
+ enum ypacket_status status, int id)
{
struct yahoo_packet *pkt = y_new0(struct yahoo_packet, 1);
@@ -551,7 +521,8 @@ static struct yahoo_packet *yahoo_packet_new(enum yahoo_service service,
return pkt;
}
-static void yahoo_packet_hash(struct yahoo_packet *pkt, int key, const char *value)
+static void yahoo_packet_hash(struct yahoo_packet *pkt, int key,
+ const char *value)
{
struct yahoo_pair *pair = y_new0(struct yahoo_pair, 1);
pair->key = key;
@@ -596,7 +567,8 @@ static int yahoo_packet_length(struct yahoo_packet *pkt)
(((*((buf)+2))&0xff)<< 8) + \
(((*((buf)+3))&0xff)))
-static void yahoo_packet_read(struct yahoo_packet *pkt, unsigned char *data, int len)
+static void yahoo_packet_read(struct yahoo_packet *pkt, unsigned char *data,
+ int len)
{
int pos = 0;
@@ -649,7 +621,8 @@ static void yahoo_packet_read(struct yahoo_packet *pkt, unsigned char *data, int
pair->value = strdup(value);
FREE(value);
pkt->hash = y_list_append(pkt->hash, pair);
- DEBUG_MSG(("Key: %d \tValue: %s", pair->key, pair->value));
+ DEBUG_MSG(("Key: %d \tValue: %s", pair->key,
+ pair->value));
} else {
FREE(pair);
}
@@ -689,30 +662,29 @@ static void yahoo_dump_unhandled(struct yahoo_packet *pkt)
}
}
-
static void yahoo_packet_dump(unsigned char *data, int len)
{
- if(yahoo_get_log_level() >= YAHOO_LOG_DEBUG) {
+ if (yahoo_get_log_level() >= YAHOO_LOG_DEBUG) {
int i;
for (i = 0; i < len; i++) {
if ((i % 8 == 0) && i)
- YAHOO_CALLBACK(ext_yahoo_log)(" ");
+ YAHOO_CALLBACK(ext_yahoo_log) (" ");
if ((i % 16 == 0) && i)
- YAHOO_CALLBACK(ext_yahoo_log)("\n");
- YAHOO_CALLBACK(ext_yahoo_log)("%02x ", data[i]);
+ YAHOO_CALLBACK(ext_yahoo_log) ("\n");
+ YAHOO_CALLBACK(ext_yahoo_log) ("%02x ", data[i]);
}
- YAHOO_CALLBACK(ext_yahoo_log)("\n");
+ YAHOO_CALLBACK(ext_yahoo_log) ("\n");
for (i = 0; i < len; i++) {
if ((i % 8 == 0) && i)
- YAHOO_CALLBACK(ext_yahoo_log)(" ");
+ YAHOO_CALLBACK(ext_yahoo_log) (" ");
if ((i % 16 == 0) && i)
- YAHOO_CALLBACK(ext_yahoo_log)("\n");
+ YAHOO_CALLBACK(ext_yahoo_log) ("\n");
if (isprint(data[i]))
- YAHOO_CALLBACK(ext_yahoo_log)(" %c ", data[i]);
+ YAHOO_CALLBACK(ext_yahoo_log) (" %c ", data[i]);
else
- YAHOO_CALLBACK(ext_yahoo_log)(" . ");
+ YAHOO_CALLBACK(ext_yahoo_log) (" . ");
}
- YAHOO_CALLBACK(ext_yahoo_log)("\n");
+ YAHOO_CALLBACK(ext_yahoo_log) ("\n");
}
}
@@ -722,7 +694,8 @@ static void to_y64(unsigned char *out, const unsigned char *in, int inlen)
base64_encode_real(in, inlen, out, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-");
}
-static void yahoo_add_to_send_queue(struct yahoo_input_data *yid, void *data, int length)
+static void yahoo_add_to_send_queue(struct yahoo_input_data *yid, void *data,
+ int length)
{
struct data_queue *tx = y_new0(struct data_queue, 1);
tx->queue = y_new0(unsigned char, length);
@@ -731,15 +704,17 @@ static void yahoo_add_to_send_queue(struct yahoo_input_data *yid, void *data, in
yid->txqueues = y_list_append(yid->txqueues, tx);
- if(!yid->write_tag)
- yid->write_tag=YAHOO_CALLBACK(ext_yahoo_add_handler)(yid->yd->client_id, yid->fd, YAHOO_INPUT_WRITE, yid);
+ if (!yid->write_tag)
+ yid->write_tag =
+ YAHOO_CALLBACK(ext_yahoo_add_handler) (yid->yd->
+ client_id, yid->fd, YAHOO_INPUT_WRITE, yid);
}
-static void yahoo_send_packet(struct yahoo_input_data *yid, struct yahoo_packet *pkt, int extra_pad)
+static void yahoo_send_packet(struct yahoo_input_data *yid,
+ struct yahoo_packet *pkt, int extra_pad)
{
int pktlen = yahoo_packet_length(pkt);
int len = YAHOO_PACKET_HDRLEN + pktlen;
-
unsigned char *data;
int pos = 0;
@@ -748,19 +723,20 @@ static void yahoo_send_packet(struct yahoo_input_data *yid, struct yahoo_packet
data = y_new0(unsigned char, len + 1);
- memcpy(data + pos, "YMSG", 4); pos += 4;
- pos += yahoo_put16(data + pos, YAHOO_PROTO_VER);
- pos += yahoo_put16(data + pos, 0x0000);
- pos += yahoo_put16(data + pos, pktlen + extra_pad);
- pos += yahoo_put16(data + pos, pkt->service);
- pos += yahoo_put32(data + pos, pkt->status);
- pos += yahoo_put32(data + pos, pkt->id);
+ memcpy(data + pos, "YMSG", 4);
+ pos += 4;
+ pos += yahoo_put16(data + pos, YAHOO_PROTO_VER); /* version [latest 12 0x000c] */
+ pos += yahoo_put16(data + pos, 0x0000); /* HIWORD pkt length??? */
+ pos += yahoo_put16(data + pos, pktlen + extra_pad); /* LOWORD pkt length? */
+ pos += yahoo_put16(data + pos, pkt->service); /* service */
+ pos += yahoo_put32(data + pos, pkt->status); /* status [4bytes] */
+ pos += yahoo_put32(data + pos, pkt->id); /* session [4bytes] */
yahoo_packet_write(pkt, data + pos);
yahoo_packet_dump(data, len);
-
- if( yid->type == YAHOO_CONNECTION_FT )
+
+ if (yid->type == YAHOO_CONNECTION_FT)
yahoo_send_data(yid->fd, data, len);
else
yahoo_add_to_send_queue(yid, data, len);
@@ -781,92 +757,94 @@ static void yahoo_packet_free(struct yahoo_packet *pkt)
FREE(pkt);
}
-static int yahoo_send_data(int fd, void *data, int len)
+static int yahoo_send_data(void *fd, void *data, int len)
{
int ret;
int e;
- if (fd < 0)
+ if (fd == NULL)
return -1;
yahoo_packet_dump(data, len);
do {
- ret = write(fd, data, len);
- } while(ret == -1 && errno==EINTR);
- e=errno;
+ ret = YAHOO_CALLBACK(ext_yahoo_write) (fd, data, len);
+ } while (ret == -1 && errno == EINTR);
+ e = errno;
- if (ret == -1) {
+ if (ret == -1) {
LOG(("wrote data: ERR %s", strerror(errno)));
} else {
LOG(("wrote data: OK"));
}
- errno=e;
+ errno = e;
return ret;
}
-void yahoo_close(int id)
+void yahoo_close(int id)
{
struct yahoo_data *yd = find_conn_by_id(id);
-
- if(!yd)
+ if (!yd)
return;
del_from_list(yd);
yahoo_free_data(yd);
- if(id == last_id)
+ if (id == last_id)
last_id--;
}
-static void yahoo_input_close(struct yahoo_input_data *yid)
+static void yahoo_input_close(struct yahoo_input_data *yid)
{
inputs = y_list_remove(inputs, yid);
- LOG(("yahoo_input_close(read)"));
- YAHOO_CALLBACK(ext_yahoo_remove_handler)(yid->yd->client_id, yid->read_tag);
- LOG(("yahoo_input_close(write)"));
- YAHOO_CALLBACK(ext_yahoo_remove_handler)(yid->yd->client_id, yid->write_tag);
+ LOG(("yahoo_input_close(read)"));
+ YAHOO_CALLBACK(ext_yahoo_remove_handler) (yid->yd->client_id,
+ yid->read_tag);
+ LOG(("yahoo_input_close(write)"));
+ YAHOO_CALLBACK(ext_yahoo_remove_handler) (yid->yd->client_id,
+ yid->write_tag);
yid->read_tag = yid->write_tag = 0;
- if(yid->fd)
- close(yid->fd);
+ if (yid->fd)
+ YAHOO_CALLBACK(ext_yahoo_close) (yid->fd);
yid->fd = 0;
FREE(yid->rxqueue);
- if(count_inputs_with_id(yid->yd->client_id) == 0) {
+ if (count_inputs_with_id(yid->yd->client_id) == 0) {
LOG(("closing %d", yid->yd->client_id));
yahoo_close(yid->yd->client_id);
}
yahoo_free_webcam(yid->wcm);
- if(yid->wcd)
+ if (yid->wcd)
FREE(yid->wcd);
- if(yid->ys) {
+ if (yid->ys) {
FREE(yid->ys->lsearch_text);
FREE(yid->ys);
}
FREE(yid);
}
-static int is_same_bud(const void * a, const void * b) {
+static int is_same_bud(const void *a, const void *b)
+{
const struct yahoo_buddy *subject = a;
const struct yahoo_buddy *object = b;
return strcmp(subject->id, object->id);
}
-static char * getcookie(char *rawcookie)
+static char *getcookie(char *rawcookie)
{
- char * cookie=NULL;
- char * tmpcookie;
- char * cookieend;
+ char *cookie = NULL;
+ char *tmpcookie;
+ char *cookieend;
- if (strlen(rawcookie) < 2)
+ if (strlen(rawcookie) < 2)
return NULL;
- tmpcookie = strdup(rawcookie+2);
+ tmpcookie = strdup(rawcookie + 2);
cookieend = strchr(tmpcookie, ';');
- if(cookieend)
+ if (cookieend)
*cookieend = '\0';
cookie = strdup(tmpcookie);
@@ -876,18 +854,18 @@ static char * getcookie(char *rawcookie)
return cookie;
}
-static char * getlcookie(char *cookie)
+static char *getlcookie(char *cookie)
{
char *tmp;
char *tmpend;
char *login_cookie = NULL;
tmpend = strstr(cookie, "n=");
- if(tmpend) {
- tmp = strdup(tmpend+2);
+ if (tmpend) {
+ tmp = strdup(tmpend + 2);
tmpend = strchr(tmp, '&');
- if(tmpend)
- *tmpend='\0';
+ if (tmpend)
+ *tmpend = '\0';
login_cookie = strdup(tmp);
FREE(tmp);
}
@@ -895,7 +873,8 @@ static char * getlcookie(char *cookie)
return login_cookie;
}
-static void yahoo_process_notify(struct yahoo_input_data *yid, struct yahoo_packet *pkt)
+static void yahoo_process_notify(struct yahoo_input_data *yid,
+ struct yahoo_packet *pkt)
{
struct yahoo_data *yd = yid->yd;
char *msg = NULL;
@@ -926,84 +905,31 @@ static void yahoo_process_notify(struct yahoo_input_data *yid, struct yahoo_pack
if (!msg)
return;
-
- if (!strncasecmp(msg, "TYPING", strlen("TYPING")))
- YAHOO_CALLBACK(ext_yahoo_typing_notify)(yd->client_id, to, from, stat);
- else if (!strncasecmp(msg, "GAME", strlen("GAME")))
- YAHOO_CALLBACK(ext_yahoo_game_notify)(yd->client_id, to, from, stat);
- else if (!strncasecmp(msg, "WEBCAMINVITE", strlen("WEBCAMINVITE")))
- {
+
+ if (!strncasecmp(msg, "TYPING", strlen("TYPING")))
+ YAHOO_CALLBACK(ext_yahoo_typing_notify) (yd->client_id, to,
+ from, stat);
+ else if (!strncasecmp(msg, "GAME", strlen("GAME")))
+ YAHOO_CALLBACK(ext_yahoo_game_notify) (yd->client_id, to, from,
+ stat, ind);
+ else if (!strncasecmp(msg, "WEBCAMINVITE", strlen("WEBCAMINVITE"))) {
if (!strcmp(ind, " ")) {
- YAHOO_CALLBACK(ext_yahoo_webcam_invite)(yd->client_id, to, from);
+ YAHOO_CALLBACK(ext_yahoo_webcam_invite) (yd->client_id,
+ to, from);
} else {
accept = atoi(ind);
/* accept the invitation (-1 = deny 1 = accept) */
if (accept < 0)
accept = 0;
- YAHOO_CALLBACK(ext_yahoo_webcam_invite_reply)(yd->client_id, to, from, accept);
+ YAHOO_CALLBACK(ext_yahoo_webcam_invite_reply) (yd->
+ client_id, to, from, accept);
}
- }
- else
+ } else
LOG(("Got unknown notification: %s", msg));
}
-static void yahoo_process_filetransfer(struct yahoo_input_data *yid, struct yahoo_packet *pkt)
-{
- struct yahoo_data *yd = yid->yd;
- char *from=NULL;
- char *to=NULL;
- char *msg=NULL;
- char *url=NULL;
- long expires=0;
-
- char *service=NULL;
-
- char *filename=NULL;
- unsigned long filesize=0L;
-
- YList *l;
- for (l = pkt->hash; l; l = l->next) {
- struct yahoo_pair *pair = l->data;
- if (pair->key == 4)
- from = pair->value;
- if (pair->key == 5)
- to = pair->value;
- if (pair->key == 14)
- msg = pair->value;
- if (pair->key == 20)
- url = pair->value;
- if (pair->key == 38)
- expires = atol(pair->value);
-
- if (pair->key == 27)
- filename = pair->value;
- if (pair->key == 28)
- filesize = atol(pair->value);
-
- if (pair->key == 49)
- service = pair->value;
- }
-
- if(pkt->service == YAHOO_SERVICE_P2PFILEXFER) {
- if(strcmp("FILEXFER", service) != 0) {
- WARNING(("unhandled service 0x%02x", pkt->service));
- yahoo_dump_unhandled(pkt);
- return;
- }
- }
-
- if(msg) {
- char *tmp;
- tmp = strchr(msg, '\006');
- if(tmp)
- *tmp = '\0';
- }
- if(url && from)
- YAHOO_CALLBACK(ext_yahoo_got_file)(yd->client_id, to, from, url, expires, msg, filename, filesize);
-
-}
-
-static void yahoo_process_conference(struct yahoo_input_data *yid, struct yahoo_packet *pkt)
+static void yahoo_process_conference(struct yahoo_input_data *yid,
+ struct yahoo_packet *pkt)
{
struct yahoo_data *yd = yid->yd;
char *msg = NULL;
@@ -1011,98 +937,102 @@ static void yahoo_process_conference(struct yahoo_input_data *yid, struct yahoo_
char *who = NULL;
char *room = NULL;
char *id = NULL;
- int utf8 = 0;
+ int utf8 = 0;
YList *members = NULL;
YList *l;
-
+
for (l = pkt->hash; l; l = l->next) {
struct yahoo_pair *pair = l->data;
if (pair->key == 50)
host = pair->value;
-
- if (pair->key == 52) { /* invite */
+
+ if (pair->key == 52) { /* invite */
members = y_list_append(members, strdup(pair->value));
}
- if (pair->key == 53) /* logon */
+ if (pair->key == 53) /* logon */
who = pair->value;
- if (pair->key == 54) /* decline */
+ if (pair->key == 54) /* decline */
who = pair->value;
- if (pair->key == 55) /* unavailable (status == 2) */
+ if (pair->key == 55) /* unavailable (status == 2) */
who = pair->value;
- if (pair->key == 56) /* logoff */
+ if (pair->key == 56) /* logoff */
who = pair->value;
if (pair->key == 57)
room = pair->value;
- if (pair->key == 58) /* join message */
+ if (pair->key == 58) /* join message */
msg = pair->value;
- if (pair->key == 14) /* decline/conf message */
+ if (pair->key == 14) /* decline/conf message */
msg = pair->value;
- if (pair->key == 13)
- ;
- if (pair->key == 16) /* error */
+ if (pair->key == 13) ;
+ if (pair->key == 16) /* error */
msg = pair->value;
- if (pair->key == 1) /* my id */
+ if (pair->key == 1) /* my id */
id = pair->value;
- if (pair->key == 3) /* message sender */
+ if (pair->key == 3) /* message sender */
who = pair->value;
if (pair->key == 97)
utf8 = atoi(pair->value);
}
- if(!room)
+ if (!room)
return;
- if(host) {
- for(l = members; l; l = l->next) {
- char * w = l->data;
- if(!strcmp(w, host))
+ if (host) {
+ for (l = members; l; l = l->next) {
+ char *w = l->data;
+ if (!strcmp(w, host))
break;
}
- if(!l)
+ if (!l)
members = y_list_append(members, strdup(host));
}
/* invite, decline, join, left, message -> status == 1 */
- switch(pkt->service) {
+ switch (pkt->service) {
case YAHOO_SERVICE_CONFINVITE:
- if(pkt->status == 2)
- ;
- else if(members)
- YAHOO_CALLBACK(ext_yahoo_got_conf_invite)(yd->client_id, id, host, room, msg, members);
- else if(msg)
- YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, msg, 0, E_CONFNOTAVAIL);
+ if (pkt->status == 2) ;
+ else if (members)
+ YAHOO_CALLBACK(ext_yahoo_got_conf_invite) (yd->
+ client_id, id, host, room, msg, members);
+ else if (msg)
+ YAHOO_CALLBACK(ext_yahoo_error) (yd->client_id, msg, 0,
+ E_CONFNOTAVAIL);
break;
case YAHOO_SERVICE_CONFADDINVITE:
- if(pkt->status == 2)
- ;
- else
- YAHOO_CALLBACK(ext_yahoo_got_conf_invite)(yd->client_id, id, host, room, msg, members);
+ if (pkt->status == 1)
+ YAHOO_CALLBACK(ext_yahoo_got_conf_invite) (yd->
+ client_id, id, host, room, msg, members);
break;
case YAHOO_SERVICE_CONFDECLINE:
- if(who)
- YAHOO_CALLBACK(ext_yahoo_conf_userdecline)(yd->client_id, id, who, room, msg);
+ if (who)
+ YAHOO_CALLBACK(ext_yahoo_conf_userdecline) (yd->
+ client_id, id, who, room, msg);
break;
case YAHOO_SERVICE_CONFLOGON:
- if(who)
- YAHOO_CALLBACK(ext_yahoo_conf_userjoin)(yd->client_id, id, who, room);
+ if (who)
+ YAHOO_CALLBACK(ext_yahoo_conf_userjoin) (yd->client_id,
+ id, who, room);
break;
case YAHOO_SERVICE_CONFLOGOFF:
- if(who)
- YAHOO_CALLBACK(ext_yahoo_conf_userleave)(yd->client_id, id, who, room);
+ if (who)
+ YAHOO_CALLBACK(ext_yahoo_conf_userleave) (yd->client_id,
+ id, who, room);
break;
case YAHOO_SERVICE_CONFMSG:
- if(who)
- YAHOO_CALLBACK(ext_yahoo_conf_message)(yd->client_id, id, who, room, msg, utf8);
+ if (who)
+ YAHOO_CALLBACK(ext_yahoo_conf_message) (yd->client_id,
+ id, who, room, msg, utf8);
break;
}
}
-static void yahoo_process_chat(struct yahoo_input_data *yid, struct yahoo_packet *pkt)
+static void yahoo_process_chat(struct yahoo_input_data *yid,
+ struct yahoo_packet *pkt)
{
char *msg = NULL;
char *id = NULL;
@@ -1111,13 +1041,13 @@ static void yahoo_process_chat(struct yahoo_input_data *yid, struct yahoo_packet
char *topic = NULL;
YList *members = NULL;
struct yahoo_chat_member *currentmember = NULL;
- int msgtype = 1;
- int utf8 = 0;
- int firstjoin = 0;
- int membercount = 0;
- int chaterr=0;
+ int msgtype = 1;
+ int utf8 = 0;
+ int firstjoin = 0;
+ int membercount = 0;
+ int chaterr = 0;
YList *l;
-
+
yahoo_dump_unhandled(pkt);
for (l = pkt->hash; l; l = l->next) {
struct yahoo_pair *pair = l->data;
@@ -1147,7 +1077,8 @@ static void yahoo_process_chat(struct yahoo_input_data *yid, struct yahoo_packet
who = pair->value;
if (pkt->service == YAHOO_SERVICE_CHATJOIN) {
- currentmember = y_new0(struct yahoo_chat_member, 1);
+ currentmember =
+ y_new0(struct yahoo_chat_member, 1);
currentmember->id = strdup(pair->value);
members = y_list_append(members, currentmember);
}
@@ -1177,7 +1108,6 @@ static void yahoo_process_chat(struct yahoo_input_data *yid, struct yahoo_packet
currentmember->location = strdup(pair->value);
}
-
if (pair->key == 130) {
/* first join */
firstjoin = 1;
@@ -1195,17 +1125,19 @@ static void yahoo_process_chat(struct yahoo_input_data *yid, struct yahoo_packet
if (pair->key == 114) {
/* message error not sure what all the pair values mean */
/* but -1 means no session in room */
- chaterr= atoi(pair->value);
+ chaterr = atoi(pair->value);
}
}
- if(!room) {
- if (pkt->service == YAHOO_SERVICE_CHATLOGOUT) { /* yahoo originated chat logout */
- YAHOO_CALLBACK(ext_yahoo_chat_yahoologout)(yid->yd->client_id, id);
- return ;
+ if (!room) {
+ if (pkt->service == YAHOO_SERVICE_CHATLOGOUT) { /* yahoo originated chat logout */
+ YAHOO_CALLBACK(ext_yahoo_chat_yahoologout) (yid->yd->
+ client_id, id);
+ return;
}
- if (pkt->service == YAHOO_SERVICE_COMMENT && chaterr) {
- YAHOO_CALLBACK(ext_yahoo_chat_yahooerror)(yid->yd->client_id, id);
+ if (pkt->service == YAHOO_SERVICE_COMMENT && chaterr) {
+ YAHOO_CALLBACK(ext_yahoo_chat_yahooerror) (yid->yd->
+ client_id, id);
return;
}
@@ -1213,103 +1145,156 @@ static void yahoo_process_chat(struct yahoo_input_data *yid, struct yahoo_packet
return;
}
- switch(pkt->service) {
+ switch (pkt->service) {
case YAHOO_SERVICE_CHATJOIN:
- if(y_list_length(members) != membercount) {
+ if (y_list_length(members) != membercount) {
WARNING(("Count of members doesn't match No. of members we got"));
}
- if(firstjoin && members) {
- YAHOO_CALLBACK(ext_yahoo_chat_join)(yid->yd->client_id, id, room, topic, members, yid->fd);
- } else if(who) {
- if(y_list_length(members) != 1) {
+ if (firstjoin && members) {
+ YAHOO_CALLBACK(ext_yahoo_chat_join) (yid->yd->client_id,
+ id, room, topic, members, yid->fd);
+ } else if (who) {
+ if (y_list_length(members) != 1) {
WARNING(("Got more than 1 member on a normal join"));
}
/* this should only ever have one, but just in case */
- while(members) {
+ while (members) {
YList *n = members->next;
currentmember = members->data;
- YAHOO_CALLBACK(ext_yahoo_chat_userjoin)(yid->yd->client_id, id, room, currentmember);
+ YAHOO_CALLBACK(ext_yahoo_chat_userjoin) (yid->
+ yd->client_id, id, room, currentmember);
y_list_free_1(members);
- members=n;
+ members = n;
}
}
break;
case YAHOO_SERVICE_CHATEXIT:
- if(who) {
- YAHOO_CALLBACK(ext_yahoo_chat_userleave)(yid->yd->client_id, id, room, who);
+ if (who) {
+ YAHOO_CALLBACK(ext_yahoo_chat_userleave) (yid->yd->
+ client_id, id, room, who);
}
break;
case YAHOO_SERVICE_COMMENT:
- if(who) {
- YAHOO_CALLBACK(ext_yahoo_chat_message)(yid->yd->client_id, id, who, room, msg, msgtype, utf8);
+ if (who) {
+ YAHOO_CALLBACK(ext_yahoo_chat_message) (yid->yd->
+ client_id, id, who, room, msg, msgtype, utf8);
}
break;
}
}
-static void yahoo_process_message(struct yahoo_input_data *yid, struct yahoo_packet *pkt)
+static void yahoo_process_message(struct yahoo_input_data *yid,
+ struct yahoo_packet *pkt)
{
struct yahoo_data *yd = yid->yd;
YList *l;
- YList * messages = NULL;
+ YList *messages = NULL;
struct m {
- int i_31;
- int i_32;
+ int i_31;
+ int i_32;
char *to;
char *from;
long tm;
char *msg;
- int utf8;
+ int utf8;
+ char *gunk;
} *message = y_new0(struct m, 1);
for (l = pkt->hash; l; l = l->next) {
struct yahoo_pair *pair = l->data;
- if (pair->key == 1 || pair->key == 4)
- {
- if(!message->from)
+ if (pair->key == 1 || pair->key == 4) {
+ if (!message->from)
message->from = pair->value;
- }
- else if (pair->key == 5)
+ } else if (pair->key == 5)
message->to = pair->value;
else if (pair->key == 15)
message->tm = strtol(pair->value, NULL, 10);
else if (pair->key == 97)
message->utf8 = atoi(pair->value);
- /* user message */ /* sys message */
+ /* This comes when the official client sends us a message */
+ else if (pair->key == 429)
+ message->gunk = pair->value;
+ /* user message *//* sys message */
else if (pair->key == 14 || pair->key == 16)
message->msg = pair->value;
else if (pair->key == 31) {
- if(message->i_31) {
+ if (message->i_31) {
messages = y_list_append(messages, message);
message = y_new0(struct m, 1);
}
message->i_31 = atoi(pair->value);
- }
- else if (pair->key == 32)
+ } 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));
+ 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) {
+ 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);
+ YAHOO_CALLBACK(ext_yahoo_system_message) (yd->client_id,
+ message->to, message->from, message->msg);
} else if (pkt->status <= 2 || pkt->status == 5) {
- YAHOO_CALLBACK(ext_yahoo_got_im)(yd->client_id, message->to, message->from, message->msg, message->tm, pkt->status, message->utf8);
+ /* Confirm message receipt if we got the gunk */
+ if(message->gunk) {
+ struct yahoo_packet *outpkt;
+
+ outpkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE_CONFIRM,
+ YPACKET_STATUS_DEFAULT, 0);
+ yahoo_packet_hash(outpkt, 1, yd->user);
+ yahoo_packet_hash(outpkt, 5, message->from);
+ yahoo_packet_hash(outpkt, 302, "430");
+ yahoo_packet_hash(outpkt, 430, message->gunk);
+ yahoo_packet_hash(outpkt, 303, "430");
+ yahoo_packet_hash(outpkt, 450, "0");
+ yahoo_send_packet(yid, outpkt, 0);
+
+ yahoo_packet_free(outpkt);
+ }
+
+ if (!strcmp(message->msg, "<ding>"))
+ YAHOO_CALLBACK(ext_yahoo_got_buzz) (yd->client_id,
+ message->to, message->from, message->tm);
+ else
+ YAHOO_CALLBACK(ext_yahoo_got_im) (yd->client_id,
+ message->to, 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, E_SYSTEM);
+ YAHOO_CALLBACK(ext_yahoo_error) (yd->client_id,
+ message->msg, 0, E_SYSTEM);
}
- free(message);
+ FREE(message);
}
y_list_free(messages);
}
+/*
+ * Here's what multi-level packets look like. Data in brackets is the value.
+ *
+ * 3 level:
+ * =======
+ *
+ * 302 (318) - Beginning level 1
+ * 300 (318) - Begin level 2
+ * 302 (319) - End level 2 header
+ * 300 (319) - Begin level 3
+ * 301 (319) - End level 3
+ * 303 (319) - End level 2
+ * 303 (318) - End level 1
+ *
+ * 2 level:
+ * =======
+ *
+ * 302 (315) - Beginning level 1
+ * 300 (315) - Begin level 2
+ * 301 (315) - End level 2
+ * 303 (315) - End level 1
+ *
+ */
static void yahoo_process_status(struct yahoo_input_data *yid,
struct yahoo_packet *pkt)
{
@@ -1326,10 +1311,12 @@ static void yahoo_process_status(struct yahoo_input_data *yid,
return;
}
- /* Status updates may be spread accross multiple packets and not
- even on buddy boundaries, so keeping some state is important.
- So, continue where we left off, and only add a user entry to
- the list once it's complete (301-315 End buddy). */
+ /*
+ * Status updates may be spread accross multiple packets and not
+ * even on buddy boundaries, so keeping some state is important.
+ * So, continue where we left off, and only add a user entry to
+ * the list once it's complete (301-315 End buddy).
+ */
u = yd->half_user;
for (l = pkt->hash; l; l = l->next) {
@@ -1593,17 +1580,20 @@ static void yahoo_process_list(struct yahoo_input_data *yid,
YAHOO_CALLBACK(ext_yahoo_got_cookies) (yd->client_id);
}
-static void yahoo_process_verify(struct yahoo_input_data *yid, struct yahoo_packet *pkt)
+static void yahoo_process_verify(struct yahoo_input_data *yid,
+ struct yahoo_packet *pkt)
{
struct yahoo_data *yd = yid->yd;
- if(pkt->status != 0x01) {
+ if (pkt->status != 0x01) {
DEBUG_MSG(("expected status: 0x01, got: %d", pkt->status));
- YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, YAHOO_LOGIN_LOCK, "");
+ YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id,
+ YAHOO_LOGIN_LOCK, "");
return;
}
- pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, YAHOO_STATUS_AVAILABLE, yd->session_id);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, YPACKET_STATUS_DEFAULT,
+ yd->session_id);
yahoo_packet_hash(pkt, 1, yd->user);
yahoo_send_packet(yid, pkt, 0);
@@ -1612,7 +1602,8 @@ static void yahoo_process_verify(struct yahoo_input_data *yid, struct yahoo_pack
}
-static void yahoo_process_picture_checksum( struct yahoo_input_data *yid, struct yahoo_packet *pkt)
+static void yahoo_process_picture_checksum(struct yahoo_input_data *yid,
+ struct yahoo_packet *pkt)
{
struct yahoo_data *yd = yid->yd;
char *from = NULL;
@@ -1620,30 +1611,30 @@ static void yahoo_process_picture_checksum( struct yahoo_input_data *yid, struct
int checksum = 0;
YList *l;
- for(l = pkt->hash; l; l = l->next)
- {
+ for (l = pkt->hash; l; l = l->next) {
struct yahoo_pair *pair = l->data;
- switch(pair->key)
- {
- case 1:
- case 4:
- from = pair->value;
- case 5:
- to = pair->value;
- break;
- case 212:
- break;
- case 192:
- checksum = atoi( pair->value );
- break;
+ switch (pair->key) {
+ case 1:
+ case 4:
+ from = pair->value;
+ case 5:
+ to = pair->value;
+ break;
+ case 212:
+ break;
+ case 192:
+ checksum = atoi(pair->value);
+ break;
}
}
- YAHOO_CALLBACK(ext_yahoo_got_buddyicon_checksum)(yd->client_id,to,from,checksum);
+ YAHOO_CALLBACK(ext_yahoo_got_buddyicon_checksum) (yd->client_id, to,
+ from, checksum);
}
-static void yahoo_process_picture(struct yahoo_input_data *yid, struct yahoo_packet *pkt)
+static void yahoo_process_picture(struct yahoo_input_data *yid,
+ struct yahoo_packet *pkt)
{
struct yahoo_data *yd = yid->yd;
char *url = NULL;
@@ -1652,607 +1643,108 @@ static void yahoo_process_picture(struct yahoo_input_data *yid, struct yahoo_pac
int status = 0;
int checksum = 0;
YList *l;
-
- for(l = pkt->hash; l; l = l->next)
- {
+
+ for (l = pkt->hash; l; l = l->next) {
struct yahoo_pair *pair = l->data;
- switch(pair->key)
- {
+ switch (pair->key) {
case 1:
- case 4: /* sender */
+ case 4: /* sender */
from = pair->value;
break;
- case 5: /* we */
+ case 5: /* we */
to = pair->value;
break;
- case 13: /* request / sending */
- status = atoi( pair->value );
+ case 13: /* request / sending */
+ status = atoi(pair->value);
break;
- case 20: /* url */
+ case 20: /* url */
url = pair->value;
break;
case 192: /*checksum */
- checksum = atoi( pair->value );
+ checksum = atoi(pair->value);
break;
}
}
- switch( status )
- {
- case 1: /* this is a request, ignore for now */
- YAHOO_CALLBACK(ext_yahoo_got_buddyicon_request)(yd->client_id, to, from);
- break;
- case 2: /* this is cool - we get a picture :) */
- YAHOO_CALLBACK(ext_yahoo_got_buddyicon)(yd->client_id,to, from, url, checksum);
- break;
+ switch (status) {
+ case 1: /* this is a request, ignore for now */
+ YAHOO_CALLBACK(ext_yahoo_got_buddyicon_request) (yd->client_id,
+ to, from);
+ break;
+ case 2: /* this is cool - we get a picture :) */
+ YAHOO_CALLBACK(ext_yahoo_got_buddyicon) (yd->client_id, to,
+ from, url, checksum);
+ break;
}
}
-static void yahoo_process_picture_upload(struct yahoo_input_data *yid, struct yahoo_packet *pkt)
+static void yahoo_process_picture_upload(struct yahoo_input_data *yid,
+ struct yahoo_packet *pkt)
{
struct yahoo_data *yd = yid->yd;
YList *l;
char *url = NULL;
- if ( pkt->status != 1 )
+ if (pkt->status != 1)
return; /* something went wrong */
-
- for(l = pkt->hash; l; l = l->next)
- {
- struct yahoo_pair *pair = l->data;
- switch(pair->key)
- {
- case 5: /* we */
- break;
- case 20: /* url */
- url = pair->value;
- break;
- case 27: /* local filename */
- break;
- case 38: /* time */
- break;
- }
- }
-
- YAHOO_CALLBACK(ext_yahoo_buddyicon_uploaded)(yd->client_id, url);
-}
-
-static void yahoo_process_auth_pre_0x0b(struct yahoo_input_data *yid,
- const char *seed, const char *sn)
-{
- struct yahoo_data *yd = yid->yd;
-
- /* So, Yahoo has stopped supporting its older clients in India, and
- * undoubtedly will soon do so in the rest of the world.
- *
- * The new clients use this authentication method. I warn you in
- * advance, it's bizzare, convoluted, inordinately complicated.
- * It's also no more secure than crypt() was. The only purpose this
- * scheme could serve is to prevent third part clients from connecting
- * to their servers.
- *
- * Sorry, Yahoo.
- */
-
- struct yahoo_packet *pack;
-
- md5_byte_t result[16];
- md5_state_t ctx;
- char *crypt_result;
- unsigned char *password_hash = malloc(25);
- unsigned char *crypt_hash = malloc(25);
- unsigned char *hash_string_p = malloc(50 + strlen(sn));
- unsigned char *hash_string_c = malloc(50 + strlen(sn));
-
- char checksum;
-
- int sv;
-
- unsigned char *result6 = malloc(25);
- unsigned char *result96 = malloc(25);
-
- sv = seed[15];
- sv = (sv % 8) % 5;
-
- md5_init(&ctx);
- md5_append(&ctx, (md5_byte_t *)yd->password, strlen(yd->password));
- md5_finish(&ctx, result);
- to_y64(password_hash, result, 16);
-
- md5_init(&ctx);
- crypt_result = yahoo_crypt(yd->password, "$1$_2S43d5f$");
- md5_append(&ctx, (md5_byte_t *)crypt_result, strlen(crypt_result));
- md5_finish(&ctx, result);
- to_y64(crypt_hash, result, 16);
- free(crypt_result);
-
- switch (sv) {
- case 0:
- checksum = seed[seed[7] % 16];
- snprintf((char *)hash_string_p, strlen(sn) + 50,
- "%c%s%s%s", checksum, password_hash, yd->user, seed);
- snprintf((char *)hash_string_c, strlen(sn) + 50,
- "%c%s%s%s", checksum, crypt_hash, yd->user, seed);
- break;
- case 1:
- checksum = seed[seed[9] % 16];
- snprintf((char *)hash_string_p, strlen(sn) + 50,
- "%c%s%s%s", checksum, yd->user, seed, password_hash);
- snprintf((char *)hash_string_c, strlen(sn) + 50,
- "%c%s%s%s", checksum, yd->user, seed, crypt_hash);
- break;
- case 2:
- checksum = seed[seed[15] % 16];
- snprintf((char *)hash_string_p, strlen(sn) + 50,
- "%c%s%s%s", checksum, seed, password_hash, yd->user);
- snprintf((char *)hash_string_c, strlen(sn) + 50,
- "%c%s%s%s", checksum, seed, crypt_hash, yd->user);
- break;
- case 3:
- checksum = seed[seed[1] % 16];
- snprintf((char *)hash_string_p, strlen(sn) + 50,
- "%c%s%s%s", checksum, yd->user, password_hash, seed);
- snprintf((char *)hash_string_c, strlen(sn) + 50,
- "%c%s%s%s", checksum, yd->user, crypt_hash, seed);
- break;
- case 4:
- checksum = seed[seed[3] % 16];
- snprintf((char *)hash_string_p, strlen(sn) + 50,
- "%c%s%s%s", checksum, password_hash, seed, yd->user);
- snprintf((char *)hash_string_c, strlen(sn) + 50,
- "%c%s%s%s", checksum, crypt_hash, seed, yd->user);
- break;
- }
-
- md5_init(&ctx);
- md5_append(&ctx, (md5_byte_t *)hash_string_p, strlen((char *)hash_string_p));
- md5_finish(&ctx, result);
- to_y64(result6, result, 16);
-
- md5_init(&ctx);
- md5_append(&ctx, (md5_byte_t *)hash_string_c, strlen((char *)hash_string_c));
- md5_finish(&ctx, result);
- to_y64(result96, result, 16);
-
- pack = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, yd->initial_status, yd->session_id);
- yahoo_packet_hash(pack, 0, yd->user);
- yahoo_packet_hash(pack, 6, (char *)result6);
- yahoo_packet_hash(pack, 96, (char *)result96);
- yahoo_packet_hash(pack, 1, yd->user);
-
- yahoo_send_packet(yid, pack, 0);
-
- FREE(result6);
- FREE(result96);
- FREE(password_hash);
- FREE(crypt_hash);
- FREE(hash_string_p);
- FREE(hash_string_c);
-
- yahoo_packet_free(pack);
-
-}
-
-/*
- * New auth protocol cracked by Cerulean Studios and sent in to Gaim
- */
-static void yahoo_process_auth_0x0b(struct yahoo_input_data *yid, const char *seed, const char *sn)
-{
- struct yahoo_packet *pack = NULL;
- struct yahoo_data *yd = yid->yd;
-
- md5_byte_t result[16];
- md5_state_t ctx;
-
- sha1_state_t ctx1;
- sha1_state_t ctx2;
-
- char *alphabet1 = "FBZDWAGHrJTLMNOPpRSKUVEXYChImkwQ";
- char *alphabet2 = "F0E1D2C3B4A59687abcdefghijklmnop";
-
- char *challenge_lookup = "qzec2tb3um1olpar8whx4dfgijknsvy5";
- char *operand_lookup = "+|&%/*^-";
- char *delimit_lookup = ",;";
-
- unsigned char *password_hash = malloc(25);
- unsigned char *crypt_hash = malloc(25);
- char *crypt_result = NULL;
- unsigned char pass_hash_xor1[64];
- unsigned char pass_hash_xor2[64];
- unsigned char crypt_hash_xor1[64];
- unsigned char crypt_hash_xor2[64];
- unsigned char chal[7];
- char resp_6[100];
- char resp_96[100];
-
- unsigned char digest1[20];
- unsigned char digest2[20];
- unsigned char magic_key_char[4];
- const unsigned char *magic_ptr;
-
- unsigned int magic[64];
- unsigned int magic_work=0;
-
- char comparison_src[20];
-
- int x, j, i;
- int cnt = 0;
- int magic_cnt = 0;
- int magic_len;
- int depth =0, table =0;
-
- memset(&pass_hash_xor1, 0, 64);
- memset(&pass_hash_xor2, 0, 64);
- memset(&crypt_hash_xor1, 0, 64);
- memset(&crypt_hash_xor2, 0, 64);
- memset(&digest1, 0, 20);
- memset(&digest2, 0, 20);
- memset(&magic, 0, 64);
- memset(&resp_6, 0, 100);
- memset(&resp_96, 0, 100);
- memset(&magic_key_char, 0, 4);
-
- /*
- * Magic: Phase 1. Generate what seems to be a 30
- * byte value (could change if base64
- * ends up differently? I don't remember and I'm
- * tired, so use a 64 byte buffer.
- */
-
- magic_ptr = (unsigned char *)seed;
-
- while (*magic_ptr != 0) {
- char *loc;
-
- /* Ignore parentheses. */
-
- if (*magic_ptr == '(' || *magic_ptr == ')') {
- magic_ptr++;
- continue;
- }
-
- /* Characters and digits verify against
- the challenge lookup.
- */
-
- if (isalpha(*magic_ptr) || isdigit(*magic_ptr)) {
- loc = strchr(challenge_lookup, *magic_ptr);
- if (!loc) {
- /* This isn't good */
- continue;
- }
-
- /* Get offset into lookup table and lsh 3. */
-
- magic_work = loc - challenge_lookup;
- magic_work <<= 3;
-
- magic_ptr++;
- continue;
- } else {
- unsigned int local_store;
-
- loc = strchr(operand_lookup, *magic_ptr);
- if (!loc) {
- /* Also not good. */
- continue;
- }
-
- local_store = loc - operand_lookup;
-
- /* Oops; how did this happen? */
- if (magic_cnt >= 64)
- break;
-
- magic[magic_cnt++] = magic_work | local_store;
- magic_ptr++;
- continue;
- }
- }
-
- magic_len = magic_cnt;
- magic_cnt = 0;
-
- /* Magic: Phase 2. Take generated magic value and
- * sprinkle fairy dust on the values. */
-
- for (magic_cnt = magic_len-2; magic_cnt >= 0; magic_cnt--) {
- unsigned char byte1;
- unsigned char byte2;
-
- /* Bad. Abort.
- */
- if (magic_cnt >= magic_len) {
- WARNING(("magic_cnt(%d) magic_len(%d)", magic_cnt, magic_len))
- break;
- }
-
- byte1 = magic[magic_cnt];
- byte2 = magic[magic_cnt+1];
-
- byte1 *= 0xcd;
- byte1 ^= byte2;
-
- magic[magic_cnt+1] = byte1;
- }
-
- /* Magic: Phase 3. This computes 20 bytes. The first 4 bytes are used as our magic
- * key (and may be changed later); the next 16 bytes are an MD5 sum of the magic key
- * plus 3 bytes. The 3 bytes are found by looping, and they represent the offsets
- * into particular functions we'll later call to potentially alter the magic key.
- *
- * %-)
- */
-
- magic_cnt = 1;
- x = 0;
-
- do {
- unsigned int bl = 0;
- unsigned int cl = magic[magic_cnt++];
-
- if (magic_cnt >= magic_len)
- break;
-
- if (cl > 0x7F) {
- if (cl < 0xe0)
- bl = cl = (cl & 0x1f) << 6;
- else {
- bl = magic[magic_cnt++];
- cl = (cl & 0x0f) << 6;
- bl = ((bl & 0x3f) + cl) << 6;
- }
-
- cl = magic[magic_cnt++];
- bl = (cl & 0x3f) + bl;
- } else
- bl = cl;
-
- comparison_src[x++] = (bl & 0xff00) >> 8;
- comparison_src[x++] = bl & 0xff;
- } while (x < 20);
-
- /* Dump magic key into a char for SHA1 action. */
-
-
- for(x = 0; x < 4; x++)
- magic_key_char[x] = comparison_src[x];
-
- /* Compute values for recursive function table! */
- memcpy( chal, magic_key_char, 4 );
- x = 1;
- for( i = 0; i < 0xFFFF && x; i++ )
- {
- for( j = 0; j < 5 && x; j++ )
- {
- chal[4] = i;
- chal[5] = i >> 8;
- chal[6] = j;
- md5_init( &ctx );
- md5_append( &ctx, chal, 7 );
- md5_finish( &ctx, result );
- if( memcmp( comparison_src + 4, result, 16 ) == 0 )
- {
- depth = i;
- table = j;
- x = 0;
- }
- }
- }
-
- /* Transform magic_key_char using transform table */
- x = magic_key_char[3] << 24 | magic_key_char[2] << 16
- | magic_key_char[1] << 8 | magic_key_char[0];
- x = yahoo_xfrm( table, depth, x );
- x = yahoo_xfrm( table, depth, x );
- magic_key_char[0] = x & 0xFF;
- magic_key_char[1] = x >> 8 & 0xFF;
- magic_key_char[2] = x >> 16 & 0xFF;
- magic_key_char[3] = x >> 24 & 0xFF;
-
- /* Get password and crypt hashes as per usual. */
- md5_init(&ctx);
- md5_append(&ctx, (md5_byte_t *)yd->password, strlen(yd->password));
- md5_finish(&ctx, result);
- to_y64(password_hash, result, 16);
-
- md5_init(&ctx);
- crypt_result = yahoo_crypt(yd->password, "$1$_2S43d5f$");
- md5_append(&ctx, (md5_byte_t *)crypt_result, strlen(crypt_result));
- md5_finish(&ctx, result);
- to_y64(crypt_hash, result, 16);
- free(crypt_result);
-
- /* Our first authentication response is based off
- * of the password hash. */
-
- for (x = 0; x < (int)strlen((char *)password_hash); x++)
- pass_hash_xor1[cnt++] = password_hash[x] ^ 0x36;
-
- if (cnt < 64)
- memset(&(pass_hash_xor1[cnt]), 0x36, 64-cnt);
-
- cnt = 0;
-
- for (x = 0; x < (int)strlen((char *)password_hash); x++)
- pass_hash_xor2[cnt++] = password_hash[x] ^ 0x5c;
-
- if (cnt < 64)
- memset(&(pass_hash_xor2[cnt]), 0x5c, 64-cnt);
-
- sha1_init(&ctx1);
- sha1_init(&ctx2);
-
- /* The first context gets the password hash XORed
- * with 0x36 plus a magic value
- * which we previously extrapolated from our
- * challenge. */
-
- sha1_append(&ctx1, pass_hash_xor1, 64);
- if (j >= 3 )
- ctx1.Length_Low = 0x1ff;
- sha1_append(&ctx1, magic_key_char, 4);
- sha1_finish(&ctx1, digest1);
-
- /* The second context gets the password hash XORed
- * with 0x5c plus the SHA-1 digest
- * of the first context. */
-
- sha1_append(&ctx2, pass_hash_xor2, 64);
- sha1_append(&ctx2, digest1, 20);
- sha1_finish(&ctx2, digest2);
-
- /* Now that we have digest2, use it to fetch
- * characters from an alphabet to construct
- * our first authentication response. */
-
- for (x = 0; x < 20; x += 2) {
- unsigned int val = 0;
- unsigned int lookup = 0;
- char byte[6];
-
- memset(&byte, 0, 6);
-
- /* First two bytes of digest stuffed
- * together.
- */
-
- val = digest2[x];
- val <<= 8;
- val += digest2[x+1];
+ for (l = pkt->hash; l; l = l->next) {
+ struct yahoo_pair *pair = l->data;
- lookup = (val >> 0x0b);
- lookup &= 0x1f;
- if (lookup >= strlen(alphabet1))
+ switch (pair->key) {
+ case 5: /* we */
break;
- sprintf(byte, "%c", alphabet1[lookup]);
- strcat(resp_6, byte);
- strcat(resp_6, "=");
-
- lookup = (val >> 0x06);
- lookup &= 0x1f;
- if (lookup >= strlen(alphabet2))
+ case 20: /* url */
+ url = pair->value;
break;
- sprintf(byte, "%c", alphabet2[lookup]);
- strcat(resp_6, byte);
-
- lookup = (val >> 0x01);
- lookup &= 0x1f;
- if (lookup >= strlen(alphabet2))
+ case 27: /* local filename */
break;
- sprintf(byte, "%c", alphabet2[lookup]);
- strcat(resp_6, byte);
-
- lookup = (val & 0x01);
- if (lookup >= strlen(delimit_lookup))
+ case 38: /* time */
break;
- sprintf(byte, "%c", delimit_lookup[lookup]);
- strcat(resp_6, byte);
+ }
}
- /* Our second authentication response is based off
- * of the crypto hash. */
-
- cnt = 0;
- memset(&digest1, 0, 20);
- memset(&digest2, 0, 20);
-
- for (x = 0; x < (int)strlen((char *)crypt_hash); x++)
- crypt_hash_xor1[cnt++] = crypt_hash[x] ^ 0x36;
-
- if (cnt < 64)
- memset(&(crypt_hash_xor1[cnt]), 0x36, 64-cnt);
-
- cnt = 0;
-
- for (x = 0; x < (int)strlen((char *)crypt_hash); x++)
- crypt_hash_xor2[cnt++] = crypt_hash[x] ^ 0x5c;
-
- if (cnt < 64)
- memset(&(crypt_hash_xor2[cnt]), 0x5c, 64-cnt);
-
- sha1_init(&ctx1);
- sha1_init(&ctx2);
-
- /* The first context gets the password hash XORed
- * with 0x36 plus a magic value
- * which we previously extrapolated from our
- * challenge. */
-
- sha1_append(&ctx1, crypt_hash_xor1, 64);
- if (j >= 3 )
- ctx1.Length_Low = 0x1ff;
- sha1_append(&ctx1, magic_key_char, 4);
- sha1_finish(&ctx1, digest1);
-
- /* The second context gets the password hash XORed
- * with 0x5c plus the SHA-1 digest
- * of the first context. */
-
- sha1_append(&ctx2, crypt_hash_xor2, 64);
- sha1_append(&ctx2, digest1, 20);
- sha1_finish(&ctx2, digest2);
-
- /* Now that we have digest2, use it to fetch
- * characters from an alphabet to construct
- * our first authentication response. */
-
- for (x = 0; x < 20; x += 2) {
- unsigned int val = 0;
- unsigned int lookup = 0;
+ YAHOO_CALLBACK(ext_yahoo_buddyicon_uploaded) (yd->client_id, url);
+}
- char byte[6];
+void yahoo_login(int id, int initial)
+{
+ struct yahoo_data *yd = find_conn_by_id(id);
+ struct connect_callback_data *ccd;
+ struct yahoo_server_settings *yss;
+ int tag;
- memset(&byte, 0, 6);
+ char *host;
- /* First two bytes of digest stuffed
- * together. */
+ struct yahoo_input_data *yid = y_new0(struct yahoo_input_data, 1);
+ yid->yd = yd;
+ yid->type = YAHOO_CONNECTION_PAGER;
+ inputs = y_list_prepend(inputs, yid);
- val = digest2[x];
- val <<= 8;
- val += digest2[x+1];
+ yd->initial_status = initial;
+ yss = yd->server_settings;
- lookup = (val >> 0x0b);
- lookup &= 0x1f;
- if (lookup >= strlen(alphabet1))
- break;
- sprintf(byte, "%c", alphabet1[lookup]);
- strcat(resp_96, byte);
- strcat(resp_96, "=");
+ ccd = y_new0(struct connect_callback_data, 1);
+ ccd->yd = yd;
- lookup = (val >> 0x06);
- lookup &= 0x1f;
- if (lookup >= strlen(alphabet2))
- break;
- sprintf(byte, "%c", alphabet2[lookup]);
- strcat(resp_96, byte);
+ host = yss->pager_host;
- lookup = (val >> 0x01);
- lookup &= 0x1f;
- if (lookup >= strlen(alphabet2))
- break;
- sprintf(byte, "%c", alphabet2[lookup]);
- strcat(resp_96, byte);
+ if (!host)
+ host = yss->pager_host_list[0];
- lookup = (val & 0x01);
- if (lookup >= strlen(delimit_lookup))
- break;
- sprintf(byte, "%c", delimit_lookup[lookup]);
- strcat(resp_96, byte);
- }
+ tag = YAHOO_CALLBACK(ext_yahoo_connect_async) (yd->client_id,
+ host, yss->pager_port, yahoo_connected, ccd, 0);
- pack = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, yd->initial_status, yd->session_id);
- yahoo_packet_hash(pack, 0, sn);
- yahoo_packet_hash(pack, 6, resp_6);
- yahoo_packet_hash(pack, 96, resp_96);
- yahoo_packet_hash(pack, 1, sn);
- yahoo_send_packet(yid, pack, 0);
- yahoo_packet_free(pack);
-
- free(password_hash);
- free(crypt_hash);
+ /*
+ * if tag <= 0, then callback has already been called
+ * so ccd will have been freed
+ */
+ if (tag > 0)
+ ccd->tag = tag;
+ else if (tag < 0)
+ YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id,
+ YAHOO_LOGIN_SOCK, NULL);
}
struct yahoo_https_auth_data
@@ -2302,7 +1794,7 @@ static enum yahoo_status yahoo_https_status_parse(int code)
}
}
-static void yahoo_process_auth_0x10(struct yahoo_input_data *yid, const char *seed, const char *sn)
+static void yahoo_https_auth(struct yahoo_input_data *yid, const char *seed, const char *sn)
{
struct yahoo_https_auth_data *had = g_new0(struct yahoo_https_auth_data, 1);
@@ -2352,17 +1844,17 @@ static void yahoo_https_auth_token_finish(struct http_request *req)
yd = yid->yd;
if (req->status_code != 200) {
- YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, 2000 + req->status_code, NULL);
+ YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, 2000 + req->status_code, NULL);
goto fail;
}
if (sscanf(req->reply_body, "%d", &st) != 1 || st != 0) {
- YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, yahoo_https_status_parse(st), NULL);
+ YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, yahoo_https_status_parse(st), NULL);
goto fail;
}
if ((had->token = yahoo_ha_find_key(req->reply_body, "ymsgr")) == NULL) {
- YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, 3001, NULL);
+ YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, 3001, NULL);
goto fail;
}
@@ -2408,19 +1900,19 @@ static void yahoo_https_auth_finish(struct http_request *req)
unsigned char yhash[32];
if (req->status_code != 200) {
- YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, 2000 + req->status_code, NULL);
+ YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, 2000 + req->status_code, NULL);
goto fail;
}
if (sscanf(req->reply_body, "%d", &st) != 1 || st != 0) {
- YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, yahoo_https_status_parse(st), NULL);
+ YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, yahoo_https_status_parse(st), NULL);
goto fail;
}
if ((yd->cookie_y = yahoo_ha_find_key(req->reply_body, "Y")) == NULL ||
(yd->cookie_t = yahoo_ha_find_key(req->reply_body, "T")) == NULL ||
(crumb = yahoo_ha_find_key(req->reply_body, "crumb")) == NULL) {
- YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, 3002, NULL);
+ YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, 3002, NULL);
goto fail;
}
@@ -2453,52 +1945,53 @@ fail:
g_free(had);
}
-static void yahoo_process_auth(struct yahoo_input_data *yid, struct yahoo_packet *pkt)
+static void yahoo_process_auth(struct yahoo_input_data *yid,
+ struct yahoo_packet *pkt)
{
char *seed = NULL;
- char *sn = NULL;
+ char *sn = NULL;
YList *l = pkt->hash;
int m = 0;
+ struct yahoo_data *yd = yid->yd;
while (l) {
struct yahoo_pair *pair = l->data;
- if (pair->key == 94)
+
+ switch (pair->key) {
+ case 94:
seed = pair->value;
- if (pair->key == 1)
+ break;
+ case 1:
sn = pair->value;
- if (pair->key == 13)
+ break;
+ case 13:
m = atoi(pair->value);
+ break;
+ }
l = l->next;
}
- if (!seed)
+ if (!seed)
return;
- switch (m) {
- case 0:
- yahoo_process_auth_pre_0x0b(yid, seed, sn);
- break;
- case 1:
- yahoo_process_auth_0x0b(yid, seed, sn);
- break;
- case 2:
- yahoo_process_auth_0x10(yid, seed, sn);
- break;
- default:
- /* call error */
- WARNING(("unknown auth type %d", m));
- yahoo_process_auth_0x0b(yid, seed, sn);
- break;
+ if (m==2)
+ yahoo_https_auth(yid, seed, sn);
+ else {
+ /* call error */
+ WARNING(("unknown auth type %d", m));
+ YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id,
+ YAHOO_LOGIN_UNKNOWN, NULL);
}
}
-static void yahoo_process_auth_resp(struct yahoo_input_data *yid, struct yahoo_packet *pkt)
+static void yahoo_process_auth_resp(struct yahoo_input_data *yid,
+ struct yahoo_packet *pkt)
{
struct yahoo_data *yd = yid->yd;
char *login_id;
char *handle;
- char *url=NULL;
- int login_status=0;
+ char *url = NULL;
+ int login_status = -1;
YList *l;
@@ -2514,13 +2007,15 @@ static void yahoo_process_auth_resp(struct yahoo_input_data *yid, struct yahoo_p
login_status = atoi(pair->value);
}
- if(pkt->status == 0xffffffff) {
- YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, login_status, url);
- /* yahoo_logoff(yd->client_id);*/
+ if (pkt->status == YPACKET_STATUS_DISCONNECTED) {
+ YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id,
+ login_status, url);
+ /* yahoo_logoff(yd->client_id); */
}
}
-static void yahoo_process_mail(struct yahoo_input_data *yid, struct yahoo_packet *pkt)
+static void yahoo_process_mail(struct yahoo_input_data *yid,
+ struct yahoo_packet *pkt)
{
struct yahoo_data *yd = yid->yd;
char *who = NULL;
@@ -2546,12 +2041,46 @@ static void yahoo_process_mail(struct yahoo_input_data *yid, struct yahoo_packet
if (who && email && subj) {
char from[1024];
snprintf(from, sizeof(from), "%s (%s)", who, email);
- YAHOO_CALLBACK(ext_yahoo_mail_notify)(yd->client_id, from, subj, count);
- } else if(count > 0)
- YAHOO_CALLBACK(ext_yahoo_mail_notify)(yd->client_id, NULL, NULL, count);
+ YAHOO_CALLBACK(ext_yahoo_mail_notify) (yd->client_id, from,
+ subj, count);
+ } else if (count > 0)
+ YAHOO_CALLBACK(ext_yahoo_mail_notify) (yd->client_id, NULL,
+ NULL, count);
}
-static void yahoo_process_contact(struct yahoo_input_data *yid, struct yahoo_packet *pkt)
+static void yahoo_process_new_contact(struct yahoo_input_data *yid,
+ struct yahoo_packet *pkt)
+{
+ struct yahoo_data *yd = yid->yd;
+ char *me = NULL;
+ char *who = NULL;
+ char *msg = NULL;
+ int online = -1;
+
+ YList *l;
+
+ for (l = pkt->hash; l; l = l->next) {
+ struct yahoo_pair *pair = l->data;
+ if (pair->key == 4)
+ who = pair->value;
+ else if (pair->key == 5)
+ me = pair->value;
+ else if (pair->key == 14)
+ msg = pair->value;
+ else if (pair->key == 13)
+ online = strtol(pair->value, NULL, 10);
+ }
+
+ if (who && online < 0)
+ YAHOO_CALLBACK(ext_yahoo_contact_added) (yd->client_id, me, who,
+ msg);
+ else if (online == 2)
+ YAHOO_CALLBACK(ext_yahoo_rejected) (yd->client_id, who, msg);
+}
+
+/* UNUSED? */
+static void yahoo_process_contact(struct yahoo_input_data *yid,
+ struct yahoo_packet *pkt)
{
struct yahoo_data *yd = yid->yd;
char *id = NULL;
@@ -2560,7 +2089,7 @@ static void yahoo_process_contact(struct yahoo_input_data *yid, struct yahoo_pac
char *name = NULL;
long tm = 0L;
int state = YAHOO_STATUS_AVAILABLE;
- int online = FALSE;
+ int online = 0;
int away = 0;
int idle = 0;
int mobile = 0;
@@ -2589,18 +2118,21 @@ static void yahoo_process_contact(struct yahoo_input_data *yid, struct yahoo_pac
idle = strtol(pair->value, NULL, 10);
else if (pair->key == 60)
mobile = strtol(pair->value, NULL, 10);
-
+
}
if (id)
- YAHOO_CALLBACK(ext_yahoo_contact_added)(yd->client_id, id, who, msg);
+ YAHOO_CALLBACK(ext_yahoo_contact_added) (yd->client_id, id, who,
+ msg);
else if (name)
- YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, name, state, msg, away, idle, mobile);
- else if(pkt->status == 0x07)
- YAHOO_CALLBACK(ext_yahoo_rejected)(yd->client_id, who, msg);
+ YAHOO_CALLBACK(ext_yahoo_status_changed) (yd->client_id, name,
+ state, msg, away, idle, mobile);
+ else if (pkt->status == 0x07)
+ YAHOO_CALLBACK(ext_yahoo_rejected) (yd->client_id, who, msg);
}
-static void yahoo_process_buddyadd(struct yahoo_input_data *yid, struct yahoo_packet *pkt)
+static void yahoo_process_buddyadd(struct yahoo_input_data *yid,
+ struct yahoo_packet *pkt)
{
struct yahoo_data *yd = yid->yd;
char *who = NULL;
@@ -2608,7 +2140,7 @@ static void yahoo_process_buddyadd(struct yahoo_input_data *yid, struct yahoo_pa
int status = 0;
char *me = NULL;
- struct yahoo_buddy *bud=NULL;
+ struct yahoo_buddy *bud = NULL;
YList *l;
for (l = pkt->hash; l; l = l->next) {
@@ -2623,51 +2155,30 @@ static void yahoo_process_buddyadd(struct yahoo_input_data *yid, struct yahoo_pa
status = strtol(pair->value, NULL, 10);
}
- yahoo_dump_unhandled(pkt);
-
- if(!who)
+ if (!who)
return;
- if(!where)
+ if (!where)
where = "Unknown";
- /* status: 0 == Successful, 1 == Error (does not exist), 2 == Already in list */
- if( status == 0 ) {
- bud = y_new0(struct yahoo_buddy, 1);
- bud->id = strdup(who);
- bud->group = strdup(where);
- bud->real_name = NULL;
-
- yd->buddies = y_list_append(yd->buddies, bud);
-
- /* Possibly called already, but at least the call above doesn't
- seem to happen every time (not anytime I tried). */
- YAHOO_CALLBACK(ext_yahoo_contact_added)(yd->client_id, me, who, NULL);
- }
+ bud = y_new0(struct yahoo_buddy, 1);
+ bud->id = strdup(who);
+ bud->group = strdup(where);
+ bud->real_name = NULL;
-/* YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, who, status, NULL, (status==YAHOO_STATUS_AVAILABLE?0:1)); */
-}
+ yd->buddies = y_list_append(yd->buddies, bud);
-static void yahoo_process_contact_ymsg13(struct yahoo_input_data *yid, struct yahoo_packet *pkt)
-{
- char* who=NULL;
- char* me=NULL;
- char* msg=NULL;
- YList *l;
- for (l = pkt->hash; l; l = l->next) {
- struct yahoo_pair *pair = l->data;
- if (pair->key == 4)
- who = pair->value;
- else if (pair->key == 5)
- me = pair->value;
- else
- DEBUG_MSG(("unknown key: %d = %s", pair->key, pair->value));
+ /* A non-zero status (i've seen 2) seems to mean the buddy is already
+ * added and is online */
+ if (status) {
+ LOG(("Setting online see packet for info"));
+ yahoo_dump_unhandled(pkt);
+ YAHOO_CALLBACK(ext_yahoo_status_changed) (yd->client_id, who,
+ YAHOO_STATUS_AVAILABLE, NULL, 0, 0, 0);
}
-
- if(pkt->status==3)
- YAHOO_CALLBACK(ext_yahoo_contact_auth_request)(yid->yd->client_id, me, who, msg);
}
-static void yahoo_process_buddydel(struct yahoo_input_data *yid, struct yahoo_packet *pkt)
+static void yahoo_process_buddydel(struct yahoo_input_data *yid,
+ struct yahoo_packet *pkt)
{
struct yahoo_data *yd = yid->yd;
char *who = NULL;
@@ -2690,12 +2201,13 @@ static void yahoo_process_buddydel(struct yahoo_input_data *yid, struct yahoo_pa
else if (pair->key == 66)
unk_66 = strtol(pair->value, NULL, 10);
else
- DEBUG_MSG(("unknown key: %d = %s", pair->key, pair->value));
+ DEBUG_MSG(("unknown key: %d = %s", pair->key,
+ pair->value));
}
- if(!who || !where)
+ if (!who || !where)
return;
-
+
bud = y_new0(struct yahoo_buddy, 1);
bud->id = strdup(who);
bud->group = strdup(where);
@@ -2706,7 +2218,7 @@ static void yahoo_process_buddydel(struct yahoo_input_data *yid, struct yahoo_pa
FREE(bud->group);
FREE(bud);
- if(buddy) {
+ if (buddy) {
bud = buddy->data;
yd->buddies = y_list_remove_link(yd->buddies, buddy);
y_list_free_1(buddy);
@@ -2716,16 +2228,17 @@ static void yahoo_process_buddydel(struct yahoo_input_data *yid, struct yahoo_pa
FREE(bud->real_name);
FREE(bud);
- bud=NULL;
+ bud = NULL;
}
}
-static void yahoo_process_ignore(struct yahoo_input_data *yid, struct yahoo_packet *pkt)
+static void yahoo_process_ignore(struct yahoo_input_data *yid,
+ struct yahoo_packet *pkt)
{
char *who = NULL;
- int status = 0;
+ int status = 0;
char *me = NULL;
- int un_ignore = 0;
+ int un_ignore = 0;
YList *l;
for (l = pkt->hash; l; l = l->next) {
@@ -2734,27 +2247,27 @@ static void yahoo_process_ignore(struct yahoo_input_data *yid, struct yahoo_pack
who = pair->value;
if (pair->key == 1)
me = pair->value;
- if (pair->key == 13) /* 1 == ignore, 2 == unignore */
+ if (pair->key == 13) /* 1 == ignore, 2 == unignore */
un_ignore = strtol(pair->value, NULL, 10);
- if (pair->key == 66)
+ if (pair->key == 66)
status = strtol(pair->value, NULL, 10);
}
-
/*
* status
- * 0 - ok
- * 2 - already in ignore list, could not add
- * 3 - not in ignore list, could not delete
- * 12 - is a buddy, could not add
+ * 0 - ok
+ * 2 - already in ignore list, could not add
+ * 3 - not in ignore list, could not delete
+ * 12 - is a buddy, could not add
*/
/* if(status)
YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, who, 0, status);
-*/
+*/
}
-static void yahoo_process_voicechat(struct yahoo_input_data *yid, struct yahoo_packet *pkt)
+static void yahoo_process_voicechat(struct yahoo_input_data *yid,
+ struct yahoo_packet *pkt)
{
char *who = NULL;
char *me = NULL;
@@ -2769,12 +2282,13 @@ static void yahoo_process_voicechat(struct yahoo_input_data *yid, struct yahoo_p
if (pair->key == 5)
me = pair->value;
if (pair->key == 13)
- voice_room=pair->value;
- if (pair->key == 57)
- room=pair->value;
+ voice_room = pair->value;
+ if (pair->key == 57)
+ room = pair->value;
}
- NOTICE(("got voice chat invite from %s in %s to identity %s", who, room, me));
+ NOTICE(("got voice chat invite from %s in %s to identity %s", who, room,
+ me));
/*
* send: s:0 1:me 5:who 57:room 13:1
* ???? s:4 5:who 10:99 19:-1615114531
@@ -2786,33 +2300,59 @@ static void yahoo_process_voicechat(struct yahoo_input_data *yid, struct yahoo_p
*/
}
-static void yahoo_process_ping(struct yahoo_input_data *yid, struct yahoo_packet *pkt)
+static void yahoo_process_ping(struct yahoo_input_data *yid,
+ struct yahoo_packet *pkt)
{
char *errormsg = NULL;
-
+
YList *l;
for (l = pkt->hash; l; l = l->next) {
struct yahoo_pair *pair = l->data;
if (pair->key == 16)
errormsg = pair->value;
}
-
+
NOTICE(("got ping packet"));
- YAHOO_CALLBACK(ext_yahoo_got_ping)(yid->yd->client_id, errormsg);
+ YAHOO_CALLBACK(ext_yahoo_got_ping) (yid->yd->client_id, errormsg);
}
-static void _yahoo_webcam_get_server_connected(int fd, int error, void *d)
+static void yahoo_process_buddy_change_group(struct yahoo_input_data *yid,
+ struct yahoo_packet *pkt)
+{
+ YList *l;
+ char *me = NULL;
+ char *who = NULL;
+ char *old_group = NULL;
+ char *new_group = NULL;
+
+ for (l = pkt->hash; l; l = l->next) {
+ struct yahoo_pair *pair = l->data;
+ if (pair->key == 1)
+ me = pair->value;
+ if (pair->key == 7)
+ who = pair->value;
+ if (pair->key == 224)
+ old_group = pair->value;
+ if (pair->key == 264)
+ new_group = pair->value;
+ }
+
+ YAHOO_CALLBACK(ext_yahoo_got_buddy_change_group) (yid->yd->client_id,
+ me, who, old_group, new_group);
+}
+
+static void _yahoo_webcam_get_server_connected(void *fd, int error, void *d)
{
struct yahoo_input_data *yid = d;
char *who = yid->wcm->user;
char *data = NULL;
char *packet = NULL;
- unsigned char magic_nr[] = {0, 1, 0};
+ unsigned char magic_nr[] = { 0, 1, 0 };
unsigned char header_len = 8;
unsigned int len = 0;
unsigned int pos = 0;
- if(error || fd <= 0) {
+ if (error || !fd) {
FREE(who);
FREE(yid);
return;
@@ -2820,7 +2360,7 @@ static void _yahoo_webcam_get_server_connected(int fd, int error, void *d)
yid->fd = fd;
inputs = y_list_prepend(inputs, yid);
-
+
/* send initial packet */
if (who)
data = strdup("<RVWCFG>");
@@ -2830,8 +2370,7 @@ static void _yahoo_webcam_get_server_connected(int fd, int error, void *d)
FREE(data);
/* send data */
- if (who)
- {
+ if (who) {
data = strdup("g=");
data = y_string_append(data, who);
data = y_string_append(data, "\r\n");
@@ -2850,10 +2389,13 @@ static void _yahoo_webcam_get_server_connected(int fd, int error, void *d)
FREE(packet);
FREE(data);
- yid->read_tag=YAHOO_CALLBACK(ext_yahoo_add_handler)(yid->yd->client_id, fd, YAHOO_INPUT_READ, yid);
+ yid->read_tag =
+ YAHOO_CALLBACK(ext_yahoo_add_handler) (yid->yd->client_id, fd,
+ YAHOO_INPUT_READ, yid);
}
-static void yahoo_webcam_get_server(struct yahoo_input_data *y, char *who, char *key)
+static void yahoo_webcam_get_server(struct yahoo_input_data *y, char *who,
+ char *key)
{
struct yahoo_input_data *yid = y_new0(struct yahoo_input_data, 1);
struct yahoo_server_settings *yss = y->yd->server_settings;
@@ -2861,34 +2403,36 @@ static void yahoo_webcam_get_server(struct yahoo_input_data *y, char *who, char
yid->type = YAHOO_CONNECTION_WEBCAM_MASTER;
yid->yd = y->yd;
yid->wcm = y_new0(struct yahoo_webcam, 1);
- yid->wcm->user = who?strdup(who):NULL;
- yid->wcm->direction = who?YAHOO_WEBCAM_DOWNLOAD:YAHOO_WEBCAM_UPLOAD;
+ yid->wcm->user = who ? strdup(who) : NULL;
+ yid->wcm->direction = who ? YAHOO_WEBCAM_DOWNLOAD : YAHOO_WEBCAM_UPLOAD;
yid->wcm->key = strdup(key);
- YAHOO_CALLBACK(ext_yahoo_connect_async)(yid->yd->client_id, yss->webcam_host, yss->webcam_port,
- _yahoo_webcam_get_server_connected, yid);
+ YAHOO_CALLBACK(ext_yahoo_connect_async) (yid->yd->client_id,
+ yss->webcam_host, yss->webcam_port,
+ _yahoo_webcam_get_server_connected, yid, 0);
}
-static YList *webcam_queue=NULL;
-static void yahoo_process_webcam_key(struct yahoo_input_data *yid, struct yahoo_packet *pkt)
+static YList *webcam_queue = NULL;
+static void yahoo_process_webcam_key(struct yahoo_input_data *yid,
+ struct yahoo_packet *pkt)
{
char *me = NULL;
char *key = NULL;
char *who = NULL;
YList *l;
- // yahoo_dump_unhandled(pkt);
+ yahoo_dump_unhandled(pkt);
for (l = pkt->hash; l; l = l->next) {
struct yahoo_pair *pair = l->data;
if (pair->key == 5)
me = pair->value;
- if (pair->key == 61)
- key=pair->value;
+ if (pair->key == 61)
+ key = pair->value;
}
l = webcam_queue;
- if(!l)
+ if (!l)
return;
who = l->data;
webcam_queue = y_list_remove_link(webcam_queue, webcam_queue);
@@ -2897,12 +2441,11 @@ static void yahoo_process_webcam_key(struct yahoo_input_data *yid, struct yahoo_
FREE(who);
}
-static void yahoo_packet_process(struct yahoo_input_data *yid, struct yahoo_packet *pkt)
+static void yahoo_packet_process(struct yahoo_input_data *yid,
+ struct yahoo_packet *pkt)
{
DEBUG_MSG(("yahoo_packet_process: 0x%02x", pkt->service));
- yahoo_dump_unhandled(pkt);
- switch (pkt->service)
- {
+ switch (pkt->service) {
case YAHOO_SERVICE_USERSTAT:
case YAHOO_SERVICE_LOGON:
case YAHOO_SERVICE_LOGOFF:
@@ -2913,7 +2456,7 @@ static void yahoo_packet_process(struct yahoo_input_data *yid, struct yahoo_pack
case YAHOO_SERVICE_IDACT:
case YAHOO_SERVICE_IDDEACT:
case YAHOO_SERVICE_Y6_STATUS_UPDATE:
- case YAHOO_SERVICE_YMSG15_STATUS:
+ case YAHOO_SERVICE_Y8_STATUS:
yahoo_process_status(yid, pkt);
break;
case YAHOO_SERVICE_NOTIFY:
@@ -2927,7 +2470,9 @@ static void yahoo_packet_process(struct yahoo_input_data *yid, struct yahoo_pack
case YAHOO_SERVICE_NEWMAIL:
yahoo_process_mail(yid, pkt);
break;
- case YAHOO_SERVICE_REJECTCONTACT:
+ case YAHOO_SERVICE_Y7_AUTHORIZATION:
+ yahoo_process_new_contact(yid, pkt);
+ break;
case YAHOO_SERVICE_NEWCONTACT:
yahoo_process_contact(yid, pkt);
break;
@@ -2962,15 +2507,18 @@ static void yahoo_packet_process(struct yahoo_input_data *yid, struct yahoo_pack
yahoo_process_chat(yid, pkt);
break;
case YAHOO_SERVICE_P2PFILEXFER:
- case YAHOO_SERVICE_FILETRANSFER:
+ case YAHOO_SERVICE_Y7_FILETRANSFER:
yahoo_process_filetransfer(yid, pkt);
break;
+ case YAHOO_SERVICE_Y7_FILETRANSFERINFO:
+ yahoo_process_filetransferinfo(yid, pkt);
+ break;
+ case YAHOO_SERVICE_Y7_FILETRANSFERACCEPT:
+ yahoo_process_filetransferaccept(yid, pkt);
+ break;
case YAHOO_SERVICE_ADDBUDDY:
yahoo_process_buddyadd(yid, pkt);
break;
- case YAHOO_SERVICE_CONTACT_YMSG13:
- yahoo_process_contact_ymsg13(yid,pkt);
- break;
case YAHOO_SERVICE_REMBUDDY:
yahoo_process_buddydel(yid, pkt);
break;
@@ -2986,6 +2534,9 @@ static void yahoo_packet_process(struct yahoo_input_data *yid, struct yahoo_pack
case YAHOO_SERVICE_PING:
yahoo_process_ping(yid, pkt);
break;
+ case YAHOO_SERVICE_Y7_CHANGE_GROUP:
+ yahoo_process_buddy_change_group(yid, pkt);
+ break;
case YAHOO_SERVICE_IDLE:
case YAHOO_SERVICE_MAILSTAT:
case YAHOO_SERVICE_CHATINVITE:
@@ -2999,6 +2550,7 @@ static void yahoo_packet_process(struct yahoo_input_data *yid, struct yahoo_pack
case YAHOO_SERVICE_CHATLOGON:
case YAHOO_SERVICE_CHATLOGOFF:
case YAHOO_SERVICE_CHATMSG:
+ case YAHOO_SERVICE_REJECTCONTACT:
case YAHOO_SERVICE_PEERTOPEER:
WARNING(("unhandled service 0x%02x", pkt->service));
yahoo_dump_unhandled(pkt);
@@ -3011,9 +2563,10 @@ static void yahoo_packet_process(struct yahoo_input_data *yid, struct yahoo_pack
break;
case YAHOO_SERVICE_PICTURE_UPLOAD:
yahoo_process_picture_upload(yid, pkt);
- break;
- case YAHOO_SERVICE_YMSG15_BUDDY_LIST: /* Buddy List */
+ break;
+ case YAHOO_SERVICE_Y8_LIST: /* Buddy List */
yahoo_process_buddy_list(yid, pkt);
+ break;
default:
WARNING(("unknown service 0x%02x", pkt->service));
yahoo_dump_unhandled(pkt);
@@ -3021,14 +2574,14 @@ static void yahoo_packet_process(struct yahoo_input_data *yid, struct yahoo_pack
}
}
-static struct yahoo_packet * yahoo_getdata(struct yahoo_input_data * yid)
+static struct yahoo_packet *yahoo_getdata(struct yahoo_input_data *yid)
{
struct yahoo_packet *pkt;
struct yahoo_data *yd = yid->yd;
int pos = 0;
int pktlen;
- if(!yd)
+ if (!yd)
return NULL;
DEBUG_MSG(("rxlen is %d", yid->rxlen));
@@ -3037,13 +2590,13 @@ static struct yahoo_packet * yahoo_getdata(struct yahoo_input_data * yid)
return NULL;
}
- pos += 4; /* YMSG */
+ pos += 4; /* YMSG */
pos += 2;
pos += 2;
- pktlen = yahoo_get16(yid->rxqueue + pos); pos += 2;
- DEBUG_MSG(("%d bytes to read, rxlen is %d",
- pktlen, yid->rxlen));
+ pktlen = yahoo_get16(yid->rxqueue + pos);
+ pos += 2;
+ DEBUG_MSG(("%d bytes to read, rxlen is %d", pktlen, yid->rxlen));
if (yid->rxlen < (YAHOO_PACKET_HDRLEN + pktlen)) {
DEBUG_MSG(("len < YAHOO_PACKET_HDRLEN + pktlen"));
@@ -3055,11 +2608,14 @@ static struct yahoo_packet * yahoo_getdata(struct yahoo_input_data * yid)
pkt = yahoo_packet_new(0, 0, 0);
- pkt->service = yahoo_get16(yid->rxqueue + pos); pos += 2;
- pkt->status = yahoo_get32(yid->rxqueue + pos); pos += 4;
+ pkt->service = yahoo_get16(yid->rxqueue + pos);
+ pos += 2;
+ pkt->status = yahoo_get32(yid->rxqueue + pos);
+ pos += 4;
DEBUG_MSG(("Yahoo Service: 0x%02x Status: %d", pkt->service,
- pkt->status));
- pkt->id = yahoo_get32(yid->rxqueue + pos); pos += 4;
+ pkt->status));
+ pkt->id = yahoo_get32(yid->rxqueue + pos);
+ pos += 4;
yd->session_id = pkt->id;
@@ -3067,12 +2623,13 @@ static struct yahoo_packet * yahoo_getdata(struct yahoo_input_data * yid)
yid->rxlen -= YAHOO_PACKET_HDRLEN + pktlen;
DEBUG_MSG(("rxlen == %d, rxqueue == %p", yid->rxlen, yid->rxqueue));
- if (yid->rxlen>0) {
- unsigned char *tmp = y_memdup(yid->rxqueue + YAHOO_PACKET_HDRLEN
- + pktlen, yid->rxlen);
+ if (yid->rxlen > 0) {
+ unsigned char *tmp = y_memdup(yid->rxqueue + YAHOO_PACKET_HDRLEN
+ + pktlen, yid->rxlen);
FREE(yid->rxqueue);
yid->rxqueue = tmp;
- DEBUG_MSG(("new rxlen == %d, rxqueue == %p", yid->rxlen, yid->rxqueue));
+ DEBUG_MSG(("new rxlen == %d, rxqueue == %p", yid->rxlen,
+ yid->rxqueue));
} else {
DEBUG_MSG(("freed rxqueue == %p", yid->rxqueue));
FREE(yid->rxqueue);
@@ -3081,136 +2638,166 @@ static struct yahoo_packet * yahoo_getdata(struct yahoo_input_data * yid)
return pkt;
}
-static void yahoo_yab_read(struct yab *yab, unsigned char *d, int len)
+static struct yab *yahoo_yab_read(unsigned char *d, int len)
{
char *st, *en;
char *data = (char *)d;
- data[len]='\0';
+ struct yab *yab = NULL;
+
+ data[len] = '\0';
DEBUG_MSG(("Got yab: %s", data));
- st = en = strstr(data, "userid=\"");
- if(st) {
- st += strlen("userid=\"");
- en = strchr(st, '"'); *en++ = '\0';
- yab->id = yahoo_xmldecode(st);
+ st = en = strstr(data, "e0=\"");
+ if (st) {
+ yab = y_new0(struct yab, 1);
+
+ st += strlen("e0=\"");
+ en = strchr(st, '"');
+ *en++ = '\0';
+ yab->email = yahoo_xmldecode(st);
}
- st = strstr(en, "fname=\"");
- if(st) {
- st += strlen("fname=\"");
- en = strchr(st, '"'); *en++ = '\0';
+ if (!en)
+ return NULL;
+
+ st = strstr(en, "id=\"");
+ if (st) {
+ st += strlen("id=\"");
+ en = strchr(st, '"');
+ *en++ = '\0';
+ yab->yid = atoi(yahoo_xmldecode(st));
+ }
+
+ st = strstr(en, "fn=\"");
+ if (st) {
+ st += strlen("fn=\"");
+ en = strchr(st, '"');
+ *en++ = '\0';
yab->fname = yahoo_xmldecode(st);
}
- st = strstr(en, "lname=\"");
- if(st) {
- st += strlen("lname=\"");
- en = strchr(st, '"'); *en++ = '\0';
+ st = strstr(en, "ln=\"");
+ if (st) {
+ st += strlen("ln=\"");
+ en = strchr(st, '"');
+ *en++ = '\0';
yab->lname = yahoo_xmldecode(st);
}
- st = strstr(en, "nname=\"");
- if(st) {
- st += strlen("nname=\"");
- en = strchr(st, '"'); *en++ = '\0';
+ st = strstr(en, "nn=\"");
+ if (st) {
+ st += strlen("nn=\"");
+ 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, "yi=\"");
+ if (st) {
+ st += strlen("yi=\"");
+ en = strchr(st, '"');
+ *en++ = '\0';
+ yab->id = yahoo_xmldecode(st);
}
st = strstr(en, "hphone=\"");
- if(st) {
+ if (st) {
st += strlen("hphone=\"");
- en = strchr(st, '"'); *en++ = '\0';
+ en = strchr(st, '"');
+ *en++ = '\0';
yab->hphone = yahoo_xmldecode(st);
}
st = strstr(en, "wphone=\"");
- if(st) {
+ if (st) {
st += strlen("wphone=\"");
- en = strchr(st, '"'); *en++ = '\0';
+ en = strchr(st, '"');
+ *en++ = '\0';
yab->wphone = yahoo_xmldecode(st);
}
st = strstr(en, "mphone=\"");
- if(st) {
+ if (st) {
st += strlen("mphone=\"");
- en = strchr(st, '"'); *en++ = '\0';
+ en = strchr(st, '"');
+ *en++ = '\0';
yab->mphone = yahoo_xmldecode(st);
}
st = strstr(en, "dbid=\"");
- if(st) {
+ if (st) {
st += strlen("dbid=\"");
- en = strchr(st, '"'); *en++ = '\0';
+ en = strchr(st, '"');
+ *en++ = '\0';
yab->dbid = atoi(st);
}
+
+ return yab;
}
-static struct yab * yahoo_getyab(struct yahoo_input_data *yid)
+static struct yab *yahoo_getyab(struct yahoo_input_data *yid)
{
struct yab *yab = NULL;
- int pos = 0, end=0;
+ int pos = 0, end = 0;
struct yahoo_data *yd = yid->yd;
- if(!yd)
- return NULL;
-
- DEBUG_MSG(("rxlen is %d", yid->rxlen));
-
- if(yid->rxlen <= strlen("<record"))
+ if (!yd)
return NULL;
- /* start with <record */
- while(pos < yid->rxlen-strlen("<record")+1
- && memcmp(yid->rxqueue + pos, "<record", strlen("<record")))
- pos++;
-
- if(pos >= yid->rxlen-1)
- return NULL;
-
- end = pos+2;
- /* end with /> */
- while(end < yid->rxlen-strlen("/>")+1 && memcmp(yid->rxqueue + end, "/>", strlen("/>")))
- end++;
-
- if(end >= yid->rxlen-1)
- return NULL;
-
- yab = y_new0(struct yab, 1);
- yahoo_yab_read(yab, yid->rxqueue + pos, end+2-pos);
-
-
- yid->rxlen -= end+1;
- DEBUG_MSG(("rxlen == %d, rxqueue == %p", yid->rxlen, yid->rxqueue));
- if (yid->rxlen>0) {
- unsigned char *tmp = y_memdup(yid->rxqueue + end + 1, yid->rxlen);
- FREE(yid->rxqueue);
- yid->rxqueue = tmp;
- DEBUG_MSG(("new rxlen == %d, rxqueue == %p", yid->rxlen, yid->rxqueue));
- } else {
- DEBUG_MSG(("freed rxqueue == %p", yid->rxqueue));
- FREE(yid->rxqueue);
- }
+ do {
+ DEBUG_MSG(("rxlen is %d", yid->rxlen));
+
+ if (yid->rxlen <= strlen("<ct"))
+ return NULL;
+
+ /* start with <ct */
+ while (pos < yid->rxlen - strlen("<ct") + 1
+ && memcmp(yid->rxqueue + pos, "<ct", strlen("<ct")))
+ pos++;
+
+ if (pos >= yid->rxlen - 1)
+ return NULL;
+
+ end = pos + 2;
+ /* end with > */
+ while (end < yid->rxlen - strlen(">")
+ && memcmp(yid->rxqueue + end, ">", strlen(">")))
+ end++;
+
+ if (end >= yid->rxlen - 1)
+ return NULL;
+
+ yab = yahoo_yab_read(yid->rxqueue + pos, end + 2 - pos);
+
+ yid->rxlen -= end + 1;
+ DEBUG_MSG(("rxlen == %d, rxqueue == %p", yid->rxlen,
+ yid->rxqueue));
+ if (yid->rxlen > 0) {
+ unsigned char *tmp =
+ y_memdup(yid->rxqueue + end + 1, yid->rxlen);
+ FREE(yid->rxqueue);
+ yid->rxqueue = tmp;
+ DEBUG_MSG(("new rxlen == %d, rxqueue == %p", yid->rxlen,
+ yid->rxqueue));
+ } else {
+ DEBUG_MSG(("freed rxqueue == %p", yid->rxqueue));
+ FREE(yid->rxqueue);
+ }
+ } while (!yab && end < yid->rxlen - 1);
return yab;
}
-static char * yahoo_getwebcam_master(struct yahoo_input_data *yid)
+static char *yahoo_getwebcam_master(struct yahoo_input_data *yid)
{
- unsigned int pos=0;
- unsigned int len=0;
- unsigned int status=0;
- char *server=NULL;
+ unsigned int pos = 0;
+ unsigned int len = 0;
+ unsigned int status = 0;
+ char *server = NULL;
struct yahoo_data *yd = yid->yd;
- if(!yid || !yd)
+ if (!yid || !yd)
return NULL;
DEBUG_MSG(("rxlen is %d", yid->rxlen));
@@ -3222,14 +2809,11 @@ static char * yahoo_getwebcam_master(struct yahoo_input_data *yid)
/* extract status (0 = ok, 6 = webcam not online) */
status = yid->rxqueue[pos++];
- if (status == 0)
- {
- pos += 2; /* skip next 2 bytes */
- server = y_memdup(yid->rxqueue+pos, 16);
+ if (status == 0) {
+ pos += 2; /* skip next 2 bytes */
+ server = y_memdup(yid->rxqueue + pos, 16);
pos += 16;
- }
- else if (status == 6)
- {
+ } else if (status == 6) {
YAHOO_CALLBACK(ext_yahoo_webcam_closed)
(yd->client_id, yid->wcm->user, 4);
}
@@ -3238,11 +2822,12 @@ static char * yahoo_getwebcam_master(struct yahoo_input_data *yid)
yid->rxlen -= len;
DEBUG_MSG(("rxlen == %d, rxqueue == %p", yid->rxlen, yid->rxqueue));
- if (yid->rxlen>0) {
+ if (yid->rxlen > 0) {
unsigned char *tmp = y_memdup(yid->rxqueue + pos, yid->rxlen);
FREE(yid->rxqueue);
yid->rxqueue = tmp;
- DEBUG_MSG(("new rxlen == %d, rxqueue == %p", yid->rxlen, yid->rxqueue));
+ DEBUG_MSG(("new rxlen == %d, rxqueue == %p", yid->rxlen,
+ yid->rxqueue));
} else {
DEBUG_MSG(("freed rxqueue == %p", yid->rxqueue));
FREE(yid->rxqueue);
@@ -3253,35 +2838,33 @@ static char * yahoo_getwebcam_master(struct yahoo_input_data *yid)
static int yahoo_get_webcam_data(struct yahoo_input_data *yid)
{
- unsigned char reason=0;
- unsigned int pos=0;
- unsigned int begin=0;
- unsigned int end=0;
- unsigned int closed=0;
- unsigned char header_len=0;
+ unsigned char reason = 0;
+ unsigned int pos = 0;
+ unsigned int begin = 0;
+ unsigned int end = 0;
+ unsigned int closed = 0;
+ unsigned char header_len = 0;
char *who;
- int connect=0;
+ int connect = 0;
struct yahoo_data *yd = yid->yd;
- if(!yd)
+ if (!yd)
return -1;
- if(!yid->wcm || !yid->wcd || !yid->rxlen)
+ if (!yid->wcm || !yid->wcd || !yid->rxlen)
return -1;
DEBUG_MSG(("rxlen is %d", yid->rxlen));
/* if we are not reading part of image then read header */
- if (!yid->wcd->to_read)
- {
- header_len=yid->rxqueue[pos++];
- yid->wcd->packet_type=0;
+ if (!yid->wcd->to_read) {
+ header_len = yid->rxqueue[pos++];
+ yid->wcd->packet_type = 0;
if (yid->rxlen < header_len)
return 0;
- if (header_len >= 8)
- {
+ if (header_len >= 8) {
reason = yid->rxqueue[pos++];
/* next 2 bytes should always be 05 00 */
pos += 2;
@@ -3289,8 +2872,7 @@ static int yahoo_get_webcam_data(struct yahoo_input_data *yid)
pos += 4;
yid->wcd->to_read = yid->wcd->data_size;
}
- if (header_len >= 13)
- {
+ if (header_len >= 13) {
yid->wcd->packet_type = yid->rxqueue[pos++];
yid->wcd->timestamp = yahoo_get32(yid->rxqueue + pos);
pos += 4;
@@ -3302,7 +2884,8 @@ static int yahoo_get_webcam_data(struct yahoo_input_data *yid)
begin = pos;
pos += yid->wcd->to_read;
- if (pos > yid->rxlen) pos = yid->rxlen;
+ if (pos > yid->rxlen)
+ pos = yid->rxlen;
/* if it is not an image then make sure we have the whole packet */
if (yid->wcd->packet_type != 0x02) {
@@ -3315,93 +2898,95 @@ static int yahoo_get_webcam_data(struct yahoo_input_data *yid)
}
DEBUG_MSG(("packet type %.2X, data length %d", yid->wcd->packet_type,
- yid->wcd->data_size));
+ yid->wcd->data_size));
/* find out what kind of packet we got */
- switch (yid->wcd->packet_type)
- {
- case 0x00:
- /* user requests to view webcam (uploading) */
- if (yid->wcd->data_size &&
- yid->wcm->direction == YAHOO_WEBCAM_UPLOAD) {
- end = begin;
- while (end <= yid->rxlen &&
- yid->rxqueue[end++] != 13);
- if (end > begin)
- {
- who = y_memdup(yid->rxqueue + begin, end - begin);
- who[end - begin - 1] = 0;
- YAHOO_CALLBACK(ext_yahoo_webcam_viewer)(yd->client_id, who + 2, 2);
- FREE(who);
- }
+ switch (yid->wcd->packet_type) {
+ case 0x00:
+ /* user requests to view webcam (uploading) */
+ if (yid->wcd->data_size &&
+ yid->wcm->direction == YAHOO_WEBCAM_UPLOAD) {
+ end = begin;
+ while (end <= yid->rxlen && yid->rxqueue[end++] != 13) ;
+ if (end > begin) {
+ who = y_memdup(yid->rxqueue + begin,
+ end - begin);
+ who[end - begin - 1] = 0;
+ YAHOO_CALLBACK(ext_yahoo_webcam_viewer) (yd->
+ client_id, who + 2, 2);
+ FREE(who);
}
+ }
- if (yid->wcm->direction == YAHOO_WEBCAM_DOWNLOAD) {
- /* timestamp/status field */
- /* 0 = declined viewing permission */
- /* 1 = accepted viewing permission */
- if (yid->wcd->timestamp == 0) {
- YAHOO_CALLBACK(ext_yahoo_webcam_closed)(yd->client_id, yid->wcm->user, 3);
- }
- }
- break;
- case 0x01: /* status packets?? */
- /* timestamp contains status info */
- /* 00 00 00 01 = we have data?? */
- break;
- case 0x02: /* image data */
- YAHOO_CALLBACK(ext_yahoo_got_webcam_image)(yd->client_id,
- yid->wcm->user, yid->rxqueue + begin,
- yid->wcd->data_size, pos - begin,
- yid->wcd->timestamp);
- break;
- case 0x05: /* response packets when uploading */
- if (!yid->wcd->data_size) {
- YAHOO_CALLBACK(ext_yahoo_webcam_data_request)(yd->client_id, yid->wcd->timestamp);
+ if (yid->wcm->direction == YAHOO_WEBCAM_DOWNLOAD) {
+ /* timestamp/status field */
+ /* 0 = declined viewing permission */
+ /* 1 = accepted viewing permission */
+ if (yid->wcd->timestamp == 0) {
+ YAHOO_CALLBACK(ext_yahoo_webcam_closed) (yd->
+ client_id, yid->wcm->user, 3);
}
+ }
+ break;
+ case 0x01: /* status packets?? */
+ /* timestamp contains status info */
+ /* 00 00 00 01 = we have data?? */
+ break;
+ case 0x02: /* image data */
+ YAHOO_CALLBACK(ext_yahoo_got_webcam_image) (yd->client_id,
+ yid->wcm->user, yid->rxqueue + begin,
+ yid->wcd->data_size, pos - begin, yid->wcd->timestamp);
+ break;
+ case 0x05: /* response packets when uploading */
+ if (!yid->wcd->data_size) {
+ YAHOO_CALLBACK(ext_yahoo_webcam_data_request) (yd->
+ client_id, yid->wcd->timestamp);
+ }
+ break;
+ case 0x07: /* connection is closing */
+ switch (reason) {
+ case 0x01: /* user closed connection */
+ closed = 1;
break;
- case 0x07: /* connection is closing */
- switch(reason)
- {
- case 0x01: /* user closed connection */
- closed = 1;
- break;
- case 0x0F: /* user cancelled permission */
- closed = 2;
- break;
- }
- YAHOO_CALLBACK(ext_yahoo_webcam_closed)(yd->client_id, yid->wcm->user, closed);
- break;
- case 0x0C: /* user connected */
- case 0x0D: /* user disconnected */
- if (yid->wcd->data_size) {
- who = y_memdup(yid->rxqueue + begin, pos - begin + 1);
- who[pos - begin] = 0;
- if (yid->wcd->packet_type == 0x0C)
- connect=1;
- else
- connect=0;
- YAHOO_CALLBACK(ext_yahoo_webcam_viewer)(yd->client_id, who, connect);
- FREE(who);
- }
- break;
- case 0x13: /* user data */
- /* i=user_ip (ip of the user we are viewing) */
- /* j=user_ext_ip (external ip of the user we */
- /* are viewing) */
- break;
- case 0x17: /* ?? */
+ case 0x0F: /* user cancelled permission */
+ closed = 2;
break;
+ }
+ YAHOO_CALLBACK(ext_yahoo_webcam_closed) (yd->client_id,
+ yid->wcm->user, closed);
+ break;
+ case 0x0C: /* user connected */
+ case 0x0D: /* user disconnected */
+ if (yid->wcd->data_size) {
+ who = y_memdup(yid->rxqueue + begin, pos - begin + 1);
+ who[pos - begin] = 0;
+ if (yid->wcd->packet_type == 0x0C)
+ connect = 1;
+ else
+ connect = 0;
+ YAHOO_CALLBACK(ext_yahoo_webcam_viewer) (yd->client_id,
+ who, connect);
+ FREE(who);
+ }
+ break;
+ case 0x13: /* user data */
+ /* i=user_ip (ip of the user we are viewing) */
+ /* j=user_ext_ip (external ip of the user we */
+ /* are viewing) */
+ break;
+ case 0x17: /* ?? */
+ break;
}
yid->wcd->to_read -= pos - begin;
yid->rxlen -= pos;
DEBUG_MSG(("rxlen == %d, rxqueue == %p", yid->rxlen, yid->rxqueue));
- if (yid->rxlen>0) {
+ if (yid->rxlen > 0) {
unsigned char *tmp = y_memdup(yid->rxqueue + pos, yid->rxlen);
FREE(yid->rxqueue);
yid->rxqueue = tmp;
- DEBUG_MSG(("new rxlen == %d, rxqueue == %p", yid->rxlen, yid->rxqueue));
+ DEBUG_MSG(("new rxlen == %d, rxqueue == %p", yid->rxlen,
+ yid->rxqueue));
} else {
DEBUG_MSG(("freed rxqueue == %p", yid->rxqueue));
FREE(yid->rxqueue);
@@ -3414,60 +2999,64 @@ static int yahoo_get_webcam_data(struct yahoo_input_data *yid)
return 0;
}
-int yahoo_write_ready(int id, int fd, void *data)
+int yahoo_write_ready(int id, void *fd, void *data)
{
struct yahoo_input_data *yid = data;
int len;
struct data_queue *tx;
- LOG(("write callback: id=%d fd=%d data=%p", id, fd, data));
- if(!yid || !yid->txqueues || !find_conn_by_id(id))
+ LOG(("write callback: id=%d fd=%p data=%p", id, fd, data));
+ if (!yid || !yid->txqueues)
return -2;
-
+
tx = yid->txqueues->data;
LOG(("writing %d bytes", tx->len));
len = yahoo_send_data(fd, tx->queue, MIN(1024, tx->len));
- if(len == -1 && errno == EAGAIN)
+ if (len == -1 && errno == EAGAIN)
return 1;
- if(len <= 0) {
+ if (len <= 0) {
int e = errno;
DEBUG_MSG(("len == %d (<= 0)", len));
- while(yid->txqueues) {
- YList *l=yid->txqueues;
+ while (yid->txqueues) {
+ YList *l = yid->txqueues;
tx = l->data;
free(tx->queue);
free(tx);
- yid->txqueues = y_list_remove_link(yid->txqueues, yid->txqueues);
+ yid->txqueues =
+ y_list_remove_link(yid->txqueues,
+ yid->txqueues);
y_list_free_1(l);
}
- LOG(("yahoo_write_ready(%d, %d) len < 0", id, fd));
- YAHOO_CALLBACK(ext_yahoo_remove_handler)(id, yid->write_tag);
+ LOG(("yahoo_write_ready(%d, %p) len < 0", id, fd));
+ YAHOO_CALLBACK(ext_yahoo_remove_handler) (id, yid->write_tag);
yid->write_tag = 0;
- errno=e;
+ errno = e;
return 0;
}
tx->len -= len;
- if(tx->len > 0) {
+ if (tx->len > 0) {
unsigned char *tmp = y_memdup(tx->queue + len, tx->len);
FREE(tx->queue);
tx->queue = tmp;
} else {
- YList *l=yid->txqueues;
+ YList *l = yid->txqueues;
free(tx->queue);
free(tx);
- yid->txqueues = y_list_remove_link(yid->txqueues, yid->txqueues);
+ yid->txqueues =
+ y_list_remove_link(yid->txqueues, yid->txqueues);
y_list_free_1(l);
/*
- if(!yid->txqueues)
- LOG(("yahoo_write_ready(%d, %d) !yxqueues", id, fd));
- */
- if(!yid->txqueues) {
- LOG(("yahoo_write_ready(%d, %d) !yxqueues", id, fd));
- YAHOO_CALLBACK(ext_yahoo_remove_handler)(id, yid->write_tag);
+ if(!yid->txqueues)
+ LOG(("yahoo_write_ready(%d, %d) !yxqueues", id, fd));
+ */
+ if (!yid->txqueues) {
+ LOG(("yahoo_write_ready(%d, %p) !txqueues", id, fd));
+ YAHOO_CALLBACK(ext_yahoo_remove_handler) (id,
+ yid->write_tag);
yid->write_tag = 0;
}
}
@@ -3475,17 +3064,18 @@ int yahoo_write_ready(int id, int fd, void *data)
return 1;
}
-static void yahoo_process_pager_connection(struct yahoo_input_data *yid, int over)
+static void yahoo_process_pager_connection(struct yahoo_input_data *yid,
+ int over)
{
struct yahoo_packet *pkt;
struct yahoo_data *yd = yid->yd;
int id = yd->client_id;
- if(over)
+ if (over)
return;
- while (find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER)
- && (pkt = yahoo_getdata(yid)) != NULL) {
+ while (find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER)
+ && (pkt = yahoo_getdata(yid)) != NULL) {
yahoo_packet_process(yid, pkt);
@@ -3493,17 +3083,15 @@ static void yahoo_process_pager_connection(struct yahoo_input_data *yid, int ove
}
}
-static void yahoo_process_ft_connection(struct yahoo_input_data *yid, int over)
-{
-}
-
-static void yahoo_process_chatcat_connection(struct yahoo_input_data *yid, int over)
+static void yahoo_process_chatcat_connection(struct yahoo_input_data *yid,
+ int over)
{
- if(over)
+ if (over)
return;
- if (strstr((char*)yid->rxqueue+(yid->rxlen-20), "</content>")) {
- YAHOO_CALLBACK(ext_yahoo_chat_cat_xml)(yid->yd->client_id, (char*)yid->rxqueue);
+ if (strstr((char *)yid->rxqueue + (yid->rxlen - 20), "</content>")) {
+ YAHOO_CALLBACK(ext_yahoo_chat_cat_xml) (yid->yd->client_id,
+ (char *)yid->rxqueue);
}
}
@@ -3512,111 +3100,143 @@ static void yahoo_process_yab_connection(struct yahoo_input_data *yid, int over)
struct yahoo_data *yd = yid->yd;
struct yab *yab;
YList *buds;
- int changed=0;
+ int changed = 0;
int id = yd->client_id;
+ int yab_used = 0;
+
+ LOG(("Got data for YAB"));
- if(over)
+ if (over)
return;
- while(find_input_by_id_and_type(id, YAHOO_CONNECTION_YAB)
- && (yab = yahoo_getyab(yid)) != NULL) {
- if(!yab->id)
+ while (find_input_by_id_and_type(id, YAHOO_CONNECTION_YAB)
+ && (yab = yahoo_getyab(yid)) != NULL) {
+ if (!yab->id)
continue;
- changed=1;
- for(buds = yd->buddies; buds; buds=buds->next) {
- struct yahoo_buddy * bud = buds->data;
- if(!strcmp(bud->id, yab->id)) {
+
+ changed = 1;
+ yab_used = 0;
+ for (buds = yd->buddies; buds; buds = buds->next) {
+ struct yahoo_buddy *bud = buds->data;
+ if (!strcmp(bud->id, yab->id)) {
+ yab_used = 1;
bud->yab_entry = yab;
- if(yab->nname) {
+ 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
- );
+ } 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) {
+ yab->fname, yab->lname);
+ } else if (yab->fname) {
bud->real_name = strdup(yab->fname);
}
- break; /* for */
+ break; /* for */
}
}
+
+ if (!yab_used) {
+ FREE(yab->fname);
+ FREE(yab->lname);
+ FREE(yab->nname);
+ FREE(yab->id);
+ FREE(yab->email);
+ FREE(yab->hphone);
+ FREE(yab->wphone);
+ FREE(yab->mphone);
+ FREE(yab);
+ }
+
}
- if(changed)
- YAHOO_CALLBACK(ext_yahoo_got_buddies)(yd->client_id, yd->buddies);
+ if (changed)
+ YAHOO_CALLBACK(ext_yahoo_got_buddies) (yd->client_id,
+ yd->buddies);
}
-static void yahoo_process_search_connection(struct yahoo_input_data *yid, int over)
+static void yahoo_process_search_connection(struct yahoo_input_data *yid,
+ int over)
{
- struct yahoo_found_contact *yct=NULL;
+ struct yahoo_found_contact *yct = NULL;
char *p = (char *)yid->rxqueue, *np, *cp;
int k, n;
- int start=0, found=0, total=0;
- YList *contacts=NULL;
- struct yahoo_input_data *pyid = find_input_by_id_and_type(yid->yd->client_id, YAHOO_CONNECTION_PAGER);
+ int start = 0, found = 0, total = 0;
+ YList *contacts = NULL;
+ struct yahoo_input_data *pyid =
+ find_input_by_id_and_type(yid->yd->client_id,
+ YAHOO_CONNECTION_PAGER);
- if(!over || !pyid)
+ if (!over || !pyid)
return;
- if(p && (p=strstr(p, "\r\n\r\n"))) {
+ if (p && (p = strstr(p, "\r\n\r\n"))) {
p += 4;
- for(k = 0; (p = strchr(p, 4)) && (k < 4); k++) {
+ for (k = 0; (p = strchr(p, 4)) && (k < 4); k++) {
p++;
n = atoi(p);
- switch(k) {
- case 0: found = pyid->ys->lsearch_nfound = n; break;
- case 2: start = pyid->ys->lsearch_nstart = n; break;
- case 3: total = pyid->ys->lsearch_ntotal = n; break;
+ switch (k) {
+ case 0:
+ found = pyid->ys->lsearch_nfound = n;
+ break;
+ case 2:
+ start = pyid->ys->lsearch_nstart = n;
+ break;
+ case 3:
+ total = pyid->ys->lsearch_ntotal = n;
+ break;
}
}
- if(p)
+ if (p)
p++;
- k=0;
- while(p && *p) {
+ k = 0;
+ while (p && *p) {
cp = p;
np = strchr(p, 4);
- if(!np)
+ if (!np)
break;
*np = 0;
- p = np+1;
-
- switch(k++) {
- case 1:
- if(strlen(cp) > 2 && y_list_length(contacts) < total) {
- yct = y_new0(struct yahoo_found_contact, 1);
- contacts = y_list_append(contacts, yct);
- yct->id = cp+2;
- } else {
- *p = 0;
- }
- break;
- case 2:
- yct->online = !strcmp(cp, "2") ? 1 : 0;
- break;
- case 3:
- yct->gender = cp;
- break;
- case 4:
- yct->age = atoi(cp);
- break;
- case 5:
- if(strcmp(cp, "5") != 0)
- yct->location = cp;
- k = 0;
- break;
+ p = np + 1;
+
+ switch (k++) {
+ case 1:
+ if (strlen(cp) > 2
+ && y_list_length(contacts) < total) {
+ yct = y_new0(struct yahoo_found_contact,
+ 1);
+ contacts = y_list_append(contacts, yct);
+ yct->id = cp + 2;
+ } else {
+ *p = 0;
+ }
+ break;
+ case 2:
+ yct->online = !strcmp(cp, "2") ? 1 : 0;
+ break;
+ case 3:
+ yct->gender = cp;
+ break;
+ case 4:
+ yct->age = atoi(cp);
+ break;
+ case 5:
+ /* not worth the context switch for strcmp */
+ if (cp[0] != '\005' || cp[1] != '\000')
+ yct->location = cp;
+ k = 0;
+ break;
}
}
}
- YAHOO_CALLBACK(ext_yahoo_got_search_result)(yid->yd->client_id, found, start, total, contacts);
+ YAHOO_CALLBACK(ext_yahoo_got_search_result) (yid->yd->client_id, found,
+ start, total, contacts);
- while(contacts) {
+ while (contacts) {
YList *node = contacts;
contacts = y_list_remove_link(contacts, node);
free(node->data);
@@ -3624,20 +3244,20 @@ static void yahoo_process_search_connection(struct yahoo_input_data *yid, int ov
}
}
-static void _yahoo_webcam_connected(int fd, int error, void *d)
+static void _yahoo_webcam_connected(void *fd, int error, void *d)
{
struct yahoo_input_data *yid = d;
struct yahoo_webcam *wcm = yid->wcm;
struct yahoo_data *yd = yid->yd;
char conn_type[100];
- char *data=NULL;
- char *packet=NULL;
- unsigned char magic_nr[] = {1, 0, 0, 0, 1};
- unsigned header_len=0;
- unsigned int len=0;
- unsigned int pos=0;
-
- if(error || fd <= 0) {
+ char *data = NULL;
+ char *packet = NULL;
+ unsigned char magic_nr[] = { 1, 0, 0, 0, 1 };
+ unsigned header_len = 0;
+ unsigned int len = 0;
+ unsigned int pos = 0;
+
+ if (error || !fd) {
FREE(yid);
return;
}
@@ -3647,74 +3267,70 @@ static void _yahoo_webcam_connected(int fd, int error, void *d)
LOG(("Connected"));
/* send initial packet */
- switch (wcm->direction)
- {
- case YAHOO_WEBCAM_DOWNLOAD:
- data = strdup("<REQIMG>");
- break;
- case YAHOO_WEBCAM_UPLOAD:
- data = strdup("<SNDIMG>");
- break;
- default:
- return;
+ switch (wcm->direction) {
+ case YAHOO_WEBCAM_DOWNLOAD:
+ data = strdup("<REQIMG>");
+ break;
+ case YAHOO_WEBCAM_UPLOAD:
+ data = strdup("<SNDIMG>");
+ break;
+ default:
+ return;
}
yahoo_add_to_send_queue(yid, data, strlen(data));
FREE(data);
/* send data */
- switch (wcm->direction)
- {
- case YAHOO_WEBCAM_DOWNLOAD:
- header_len = 8;
- data = strdup("a=2\r\nc=us\r\ne=21\r\nu=");
- data = y_string_append(data, yd->user);
- data = y_string_append(data, "\r\nt=");
- data = y_string_append(data, wcm->key);
- data = y_string_append(data, "\r\ni=");
- data = y_string_append(data, wcm->my_ip);
- data = y_string_append(data, "\r\ng=");
- data = y_string_append(data, wcm->user);
- data = y_string_append(data, "\r\no=w-2-5-1\r\np=");
- snprintf(conn_type, sizeof(conn_type), "%d", wcm->conn_type);
- data = y_string_append(data, conn_type);
- data = y_string_append(data, "\r\n");
- break;
- case YAHOO_WEBCAM_UPLOAD:
- header_len = 13;
- data = strdup("a=2\r\nc=us\r\nu=");
- data = y_string_append(data, yd->user);
- data = y_string_append(data, "\r\nt=");
- data = y_string_append(data, wcm->key);
- data = y_string_append(data, "\r\ni=");
- data = y_string_append(data, wcm->my_ip);
- data = y_string_append(data, "\r\no=w-2-5-1\r\np=");
- snprintf(conn_type, sizeof(conn_type), "%d", wcm->conn_type);
- data = y_string_append(data, conn_type);
- data = y_string_append(data, "\r\nb=");
- data = y_string_append(data, wcm->description);
- data = y_string_append(data, "\r\n");
- break;
+ switch (wcm->direction) {
+ case YAHOO_WEBCAM_DOWNLOAD:
+ header_len = 8;
+ data = strdup("a=2\r\nc=us\r\ne=21\r\nu=");
+ data = y_string_append(data, yd->user);
+ data = y_string_append(data, "\r\nt=");
+ data = y_string_append(data, wcm->key);
+ data = y_string_append(data, "\r\ni=");
+ data = y_string_append(data, wcm->my_ip);
+ data = y_string_append(data, "\r\ng=");
+ data = y_string_append(data, wcm->user);
+ data = y_string_append(data, "\r\no=w-2-5-1\r\np=");
+ snprintf(conn_type, sizeof(conn_type), "%d", wcm->conn_type);
+ data = y_string_append(data, conn_type);
+ data = y_string_append(data, "\r\n");
+ break;
+ case YAHOO_WEBCAM_UPLOAD:
+ header_len = 13;
+ data = strdup("a=2\r\nc=us\r\nu=");
+ data = y_string_append(data, yd->user);
+ data = y_string_append(data, "\r\nt=");
+ data = y_string_append(data, wcm->key);
+ data = y_string_append(data, "\r\ni=");
+ data = y_string_append(data, wcm->my_ip);
+ data = y_string_append(data, "\r\no=w-2-5-1\r\np=");
+ snprintf(conn_type, sizeof(conn_type), "%d", wcm->conn_type);
+ data = y_string_append(data, conn_type);
+ data = y_string_append(data, "\r\nb=");
+ data = y_string_append(data, wcm->description);
+ data = y_string_append(data, "\r\n");
+ break;
}
len = strlen(data);
packet = y_new0(char, header_len + len);
packet[pos++] = header_len;
packet[pos++] = 0;
- switch (wcm->direction)
- {
- case YAHOO_WEBCAM_DOWNLOAD:
- packet[pos++] = 1;
- packet[pos++] = 0;
- break;
- case YAHOO_WEBCAM_UPLOAD:
- packet[pos++] = 5;
- packet[pos++] = 0;
- break;
+ switch (wcm->direction) {
+ case YAHOO_WEBCAM_DOWNLOAD:
+ packet[pos++] = 1;
+ packet[pos++] = 0;
+ break;
+ case YAHOO_WEBCAM_UPLOAD:
+ packet[pos++] = 5;
+ packet[pos++] = 0;
+ break;
}
pos += yahoo_put32(packet + pos, len);
- if (wcm->direction == YAHOO_WEBCAM_UPLOAD)
- {
+ if (wcm->direction == YAHOO_WEBCAM_UPLOAD) {
memcpy(packet + pos, magic_nr, sizeof(magic_nr));
pos += sizeof(magic_nr);
}
@@ -3723,7 +3339,9 @@ static void _yahoo_webcam_connected(int fd, int error, void *d)
FREE(packet);
FREE(data);
- yid->read_tag=YAHOO_CALLBACK(ext_yahoo_add_handler)(yid->yd->client_id, yid->fd, YAHOO_INPUT_READ, yid);
+ yid->read_tag =
+ YAHOO_CALLBACK(ext_yahoo_add_handler) (yid->yd->client_id,
+ yid->fd, YAHOO_INPUT_READ, yid);
}
static void yahoo_webcam_connect(struct yahoo_input_data *y)
@@ -3748,23 +3366,23 @@ static void yahoo_webcam_connect(struct yahoo_input_data *y)
yid->wcd = y_new0(struct yahoo_webcam_data, 1);
LOG(("Connecting to: %s:%d", wcm->server, wcm->port));
- YAHOO_CALLBACK(ext_yahoo_connect_async)(y->yd->client_id, wcm->server, wcm->port,
- _yahoo_webcam_connected, yid);
+ YAHOO_CALLBACK(ext_yahoo_connect_async) (y->yd->client_id, wcm->server,
+ wcm->port, _yahoo_webcam_connected, yid, 0);
}
-static void yahoo_process_webcam_master_connection(struct yahoo_input_data *yid, int over)
+static void yahoo_process_webcam_master_connection(struct yahoo_input_data *yid,
+ int over)
{
- char* server;
+ char *server;
struct yahoo_server_settings *yss;
- if(over)
+ if (over)
return;
server = yahoo_getwebcam_master(yid);
- if (server)
- {
+ if (server) {
yss = yid->yd->server_settings;
yid->wcm->server = strdup(server);
yid->wcm->port = yss->webcam_port;
@@ -3777,72 +3395,74 @@ static void yahoo_process_webcam_master_connection(struct yahoo_input_data *yid,
}
}
-static void yahoo_process_webcam_connection(struct yahoo_input_data *yid, int over)
+static void yahoo_process_webcam_connection(struct yahoo_input_data *yid,
+ int over)
{
int id = yid->yd->client_id;
- int fd = yid->fd;
+ void *fd = yid->fd;
- if(over)
+ if (over)
return;
/* as long as we still have packets available keep processing them */
- while (find_input_by_id_and_fd(id, fd)
- && yahoo_get_webcam_data(yid) == 1);
-}
-
-static void (*yahoo_process_connection[])(struct yahoo_input_data *, int over) = {
- yahoo_process_pager_connection,
- yahoo_process_ft_connection,
- yahoo_process_yab_connection,
- yahoo_process_webcam_master_connection,
- yahoo_process_webcam_connection,
- yahoo_process_chatcat_connection,
- yahoo_process_search_connection,
-};
+ while (find_input_by_id_and_fd(id, fd)
+ && yahoo_get_webcam_data(yid) == 1) ;
+}
+
+static void (*yahoo_process_connection[]) (struct yahoo_input_data *,
+ int over) = {
+yahoo_process_pager_connection, yahoo_process_ft_connection,
+ yahoo_process_yab_connection,
+ yahoo_process_webcam_master_connection,
+ yahoo_process_webcam_connection,
+ yahoo_process_chatcat_connection,
+ yahoo_process_search_connection};
-int yahoo_read_ready(int id, int fd, void *data)
+int yahoo_read_ready(int id, void *fd, void *data)
{
struct yahoo_input_data *yid = data;
char buf[1024];
int len;
- LOG(("read callback: id=%d fd=%d data=%p", id, fd, data));
- if(!yid)
+ LOG(("read callback: id=%d fd=%p data=%p", id, fd, data));
+ if (!yid)
return -2;
-
do {
- len = read(fd, buf, sizeof(buf));
- } while(len == -1 && errno == EINTR);
+ len = YAHOO_CALLBACK(ext_yahoo_read) (fd, buf, sizeof(buf));
+ } while (len == -1 && errno == EINTR);
- if(len == -1 && (errno == EAGAIN||errno == EINTR)) /* we'll try again later */
+ if (len == -1 && (errno == EAGAIN || errno == EINTR)) /* we'll try again later */
return 1;
if (len <= 0) {
int e = errno;
DEBUG_MSG(("len == %d (<= 0)", len));
- if(yid->type == YAHOO_CONNECTION_PAGER) {
- YAHOO_CALLBACK(ext_yahoo_error)(yid->yd->client_id, "Connection closed by server", 1, E_CONNECTION);
+ if (yid->type == YAHOO_CONNECTION_PAGER) {
+ YAHOO_CALLBACK(ext_yahoo_login_response) (yid->yd->
+ client_id, YAHOO_LOGIN_SOCK, NULL);
}
- yahoo_process_connection[yid->type](yid, 1);
+ yahoo_process_connection[yid->type] (yid, 1);
yahoo_input_close(yid);
/* no need to return an error, because we've already fixed it */
- if(len == 0)
+ if (len == 0)
return 1;
- errno=e;
+ errno = e;
LOG(("read error: %s", strerror(errno)));
return -1;
}
- yid->rxqueue = y_renew(unsigned char, yid->rxqueue, len + yid->rxlen);
+ yid->rxqueue =
+ y_renew(unsigned char, yid->rxqueue, len + yid->rxlen + 1);
memcpy(yid->rxqueue + yid->rxlen, buf, len);
yid->rxlen += len;
+ yid->rxqueue[yid->rxlen] = 0;
- yahoo_process_connection[yid->type](yid, 0);
+ yahoo_process_connection[yid->type] (yid, 0);
return len;
}
@@ -3854,7 +3474,7 @@ int yahoo_init_with_attributes(const char *username, const char *password, ...)
yd = y_new0(struct yahoo_data, 1);
- if(!yd)
+ if (!yd)
return 0;
yd->user = strdup(username);
@@ -3879,13 +3499,7 @@ int yahoo_init(const char *username, const char *password)
return yahoo_init_with_attributes(username, password, NULL);
}
-struct connect_callback_data {
- struct yahoo_data *yd;
- int tag;
- int i;
-};
-
-static void yahoo_connected(int fd, int error, void *data)
+static void yahoo_connected(void *fd, int error, void *data)
{
struct connect_callback_data *ccd = data;
struct yahoo_data *yd = ccd->yd;
@@ -3893,114 +3507,112 @@ static void yahoo_connected(int fd, int error, void *data)
struct yahoo_input_data *yid;
struct yahoo_server_settings *yss = yd->server_settings;
- if(error) {
- if(fallback_ports[ccd->i]) {
- int tag;
- yss->pager_port = fallback_ports[ccd->i++];
- tag = YAHOO_CALLBACK(ext_yahoo_connect_async)(yd->client_id, yss->pager_host,
- yss->pager_port, yahoo_connected, ccd);
+ if (error) {
+ int tag;
+ if (fallback_ports[ccd->i]) {
+ char *host = yss->pager_host;
+
+ if (!host)
+ host = yss->pager_host_list[ccd->server_i];
- if(tag > 0)
- ccd->tag=tag;
+ yss->pager_port = fallback_ports[ccd->i++];
+ tag = YAHOO_CALLBACK(ext_yahoo_connect_async) (yd->
+ client_id, host, yss->pager_port,
+ yahoo_connected, ccd, 0);
+
+ if (tag > 0)
+ ccd->tag = tag;
+ } else if (yss->pager_host_list
+ && yss->pager_host_list[ccd->server_i]) {
+
+ /* Get back to the default port */
+ yss->pager_port = pager_port;
+ ccd->server_i++;
+ LOG(("Fallback: Connecting to %s:%d", yss->pager_host_list[ccd->server_i], yss->pager_port));
+
+ ccd->i = 0;
+ tag = YAHOO_CALLBACK(ext_yahoo_connect_async) (yd->client_id,
+ yss->pager_host_list[ccd->server_i], yss->pager_port,
+ yahoo_connected, ccd, 0);
} else {
FREE(ccd);
- YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, YAHOO_LOGIN_SOCK, NULL);
+ YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id,
+ YAHOO_LOGIN_SOCK, NULL);
}
return;
}
FREE(ccd);
- /* fd < 0 && error == 0 means connect was cancelled */
- if(fd < 0)
+ /* fd == NULL && error == 0 means connect was cancelled */
+ if (!fd)
return;
- pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, YAHOO_STATUS_AVAILABLE, yd->session_id);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, YPACKET_STATUS_DEFAULT,
+ yd->session_id);
NOTICE(("Sending initial packet"));
yahoo_packet_hash(pkt, 1, yd->user);
- yid = y_new0(struct yahoo_input_data, 1);
- yid->yd = yd;
+ yid = find_input_by_id_and_type(yd->client_id, YAHOO_CONNECTION_PAGER);
yid->fd = fd;
- inputs = y_list_prepend(inputs, yid);
yahoo_send_packet(yid, pkt, 0);
yahoo_packet_free(pkt);
- yid->read_tag=YAHOO_CALLBACK(ext_yahoo_add_handler)(yid->yd->client_id, yid->fd, YAHOO_INPUT_READ, yid);
+ yid->read_tag =
+ YAHOO_CALLBACK(ext_yahoo_add_handler) (yid->yd->client_id,
+ yid->fd, YAHOO_INPUT_READ, yid);
}
-void yahoo_login(int id, int initial)
+void *yahoo_get_fd(int id)
{
- struct yahoo_data *yd = find_conn_by_id(id);
- struct connect_callback_data *ccd;
- struct yahoo_server_settings *yss;
- int tag;
-
- if(!yd)
- return;
-
- yss = yd->server_settings;
-
- yd->initial_status = initial;
-
- ccd = y_new0(struct connect_callback_data, 1);
- ccd->yd = yd;
- tag = YAHOO_CALLBACK(ext_yahoo_connect_async)(yd->client_id, yss->pager_host, yss->pager_port,
- yahoo_connected, ccd);
-
- /*
- * if tag <= 0, then callback has already been called
- * so ccd will have been freed
- */
- if(tag > 0)
- ccd->tag = tag;
- else if(tag < 0)
- YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, YAHOO_LOGIN_SOCK, NULL);
-}
-
-
-int yahoo_get_fd(int id)
-{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
- if(!yid)
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ if (!yid)
return 0;
else
return yid->fd;
}
-void yahoo_send_im(int id, const char *from, const char *who, const char *what, int utf8, int picture)
+void yahoo_send_buzz(int id, const char *from, const char *who)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ yahoo_send_im(id, from, who, "<ding>", 1, 0);
+}
+
+void yahoo_send_im(int id, const char *from, const char *who, const char *what,
+ int utf8, int picture)
+{
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
struct yahoo_packet *pkt = NULL;
struct yahoo_data *yd;
char pic_str[10];
- if(!yid)
+ if (!yid)
return;
yd = yid->yd;
- pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, YAHOO_STATUS_OFFLINE, yd->session_id);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, YAHOO_STATUS_OFFLINE,
+ yd->session_id);
snprintf(pic_str, sizeof(pic_str), "%d", picture);
-
- if(from && strcmp(from, yd->user))
+
+ if (from && strcmp(from, yd->user))
yahoo_packet_hash(pkt, 0, yd->user);
- yahoo_packet_hash(pkt, 1, from?from:yd->user);
+ yahoo_packet_hash(pkt, 1, from ? from : yd->user);
yahoo_packet_hash(pkt, 5, who);
yahoo_packet_hash(pkt, 14, what);
- if(utf8)
+ if (utf8)
yahoo_packet_hash(pkt, 97, "1");
yahoo_packet_hash(pkt, 63, ";0"); /* imvironment name; or ;0 */
yahoo_packet_hash(pkt, 64, "0");
yahoo_packet_hash(pkt, 206, pic_str);
-
yahoo_send_packet(yid, pkt, 0);
yahoo_packet_free(pkt);
@@ -4008,17 +3620,19 @@ void yahoo_send_im(int id, const char *from, const char *who, const char *what,
void yahoo_send_typing(int id, const char *from, const char *who, int typ)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
struct yahoo_data *yd;
struct yahoo_packet *pkt = NULL;
- if(!yid)
+ if (!yid)
return;
yd = yid->yd;
- pkt = yahoo_packet_new(YAHOO_SERVICE_NOTIFY, YAHOO_STATUS_NOTIFY, yd->session_id);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_NOTIFY, YPACKET_STATUS_NOTIFY,
+ yd->session_id);
yahoo_packet_hash(pkt, 5, who);
- yahoo_packet_hash(pkt, 1, from?from:yd->user);
+ yahoo_packet_hash(pkt, 1, from ? from : yd->user);
yahoo_packet_hash(pkt, 14, " ");
yahoo_packet_hash(pkt, 13, typ ? "1" : "0");
yahoo_packet_hash(pkt, 49, "TYPING");
@@ -4030,22 +3644,25 @@ void yahoo_send_typing(int id, const char *from, const char *who, int typ)
void yahoo_set_away(int id, enum yahoo_status state, const char *msg, int away)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
struct yahoo_data *yd;
struct yahoo_packet *pkt = NULL;
int old_status;
char s[4];
- if(!yid)
+ if (!yid)
return;
yd = yid->yd;
+
old_status = yd->current_status;
yd->current_status = state;
/* Thank you libpurple :) */
if (yd->current_status == YAHOO_STATUS_INVISIBLE) {
- pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBILITY, YAHOO_STATUS_AVAILABLE, 0);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBLE_TOGGLE,
+ YAHOO_STATUS_AVAILABLE, 0);
yahoo_packet_hash(pkt, 13, "2");
yahoo_send_packet(yid, pkt, 0);
yahoo_packet_free(pkt);
@@ -4053,7 +3670,8 @@ void yahoo_set_away(int id, enum yahoo_status state, const char *msg, int away)
return;
}
- pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, yd->current_status, yd->session_id);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE,
+ yd->current_status, yd->session_id);
snprintf(s, sizeof(s), "%d", yd->current_status);
yahoo_packet_hash(pkt, 10, s);
yahoo_packet_hash(pkt, 19, msg && state == YAHOO_STATUS_CUSTOM ? msg : "");
@@ -4061,8 +3679,9 @@ void yahoo_set_away(int id, enum yahoo_status state, const char *msg, int away)
yahoo_send_packet(yid, pkt, 0);
yahoo_packet_free(pkt);
- if(old_status == YAHOO_STATUS_INVISIBLE) {
- pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBILITY, YAHOO_STATUS_AVAILABLE, 0);
+ if (old_status == YAHOO_STATUS_INVISIBLE) {
+ pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBLE_TOGGLE,
+ YAHOO_STATUS_AVAILABLE, 0);
yahoo_packet_hash(pkt, 13, "1");
yahoo_send_packet(yid, pkt, 0);
yahoo_packet_free(pkt);
@@ -4071,21 +3690,23 @@ void yahoo_set_away(int id, enum yahoo_status state, const char *msg, int away)
void yahoo_logoff(int id)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
struct yahoo_data *yd;
struct yahoo_packet *pkt = NULL;
- if(!yid)
+ if (!yid)
return;
yd = yid->yd;
LOG(("yahoo_logoff: current status: %d", yd->current_status));
- if(yd->current_status != -1 && 0) {
+ if (yd->current_status != -1 && 0) {
/* Meh. Don't send this. The event handlers are not going to
get to do this so it'll just leak memory. And the TCP
connection reset will hopefully be clear enough. */
- pkt = yahoo_packet_new(YAHOO_SERVICE_LOGOFF, YAHOO_STATUS_AVAILABLE, yd->session_id);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_LOGOFF,
+ YPACKET_STATUS_DEFAULT, yd->session_id);
yd->current_status = -1;
if (pkt) {
@@ -4094,22 +3715,25 @@ void yahoo_logoff(int id)
}
}
- do {
+/* do {
yahoo_input_close(yid);
- } while((yid = find_input_by_id(id)));
+ } while((yid = find_input_by_id(id)));*/
+
}
void yahoo_get_list(int id)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
struct yahoo_data *yd;
struct yahoo_packet *pkt = NULL;
- if(!yid)
+ if (!yid)
return;
yd = yid->yd;
- pkt = yahoo_packet_new(YAHOO_SERVICE_LIST, YAHOO_STATUS_AVAILABLE, yd->session_id);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_LIST, YPACKET_STATUS_DEFAULT,
+ yd->session_id);
yahoo_packet_hash(pkt, 1, yd->user);
if (pkt) {
yahoo_send_packet(yid, pkt, 0);
@@ -4117,139 +3741,136 @@ void yahoo_get_list(int id)
}
}
-static void _yahoo_http_connected(int id, int fd, int error, void *data)
+static void _yahoo_http_connected(int id, void *fd, int error, void *data)
{
struct yahoo_input_data *yid = data;
- if(fd <= 0) {
+ if (fd == NULL || error) {
inputs = y_list_remove(inputs, yid);
FREE(yid);
return;
}
yid->fd = fd;
- yid->read_tag=YAHOO_CALLBACK(ext_yahoo_add_handler)(yid->yd->client_id, fd, YAHOO_INPUT_READ, yid);
+ yid->read_tag =
+ YAHOO_CALLBACK(ext_yahoo_add_handler) (yid->yd->client_id, fd,
+ YAHOO_INPUT_READ, yid);
}
+/* FIXME Get address book from address.yahoo.com instead */
void yahoo_get_yab(int id)
{
struct yahoo_data *yd = find_conn_by_id(id);
struct yahoo_input_data *yid;
char url[1024];
- char buff[1024];
+ char buff[2048];
- if(!yd)
+ if (!yd)
return;
yid = y_new0(struct yahoo_input_data, 1);
yid->yd = yd;
yid->type = YAHOO_CONNECTION_YAB;
- snprintf(url, 1024, "http://insider.msg.yahoo.com/ycontent/?ab2=0");
+ LOG(("Sending request for Address Book"));
+
+ snprintf(url, 1024,
+ "http://address.yahoo.com/yab/us?v=XM&prog=ymsgr&.intl=us"
+ "&diffs=1&t=0&tags=short&rt=0&prog-ver=8.1.0.249&useutf8=1&legenc=codepage-1252");
- snprintf(buff, sizeof(buff), "Y=%s; T=%s",
- yd->cookie_y, yd->cookie_t);
+ snprintf(buff, sizeof(buff), "Y=%s; T=%s", yd->cookie_y, yd->cookie_t);
inputs = y_list_prepend(inputs, yid);
- yahoo_http_get(yid->yd->client_id, url, buff,
- _yahoo_http_connected, yid);
+ yahoo_http_get(yid->yd->client_id, url, buff, 0, 0,
+ _yahoo_http_connected, yid);
+}
+
+struct yahoo_post_data {
+ struct yahoo_input_data *yid;
+ char *data;
+};
+
+static void _yahoo_http_post_connected(int id, void *fd, int error, void *data)
+{
+ struct yahoo_post_data *yad = data;
+ struct yahoo_input_data *yid = yad->yid;
+ char *buff = yad->data;
+
+ if (!fd) {
+ inputs = y_list_remove(inputs, yid);
+ FREE(yid);
+ return;
+ }
+
+ YAHOO_CALLBACK(ext_yahoo_write) (fd, buff, strlen(buff));
+
+ yid->fd = fd;
+ yid->read_tag =
+ YAHOO_CALLBACK(ext_yahoo_add_handler) (yid->yd->client_id, fd,
+ YAHOO_INPUT_READ, yid);
+
+ FREE(buff);
+ FREE(yad);
}
-void yahoo_set_yab(int id, struct yab * yab)
+/* FIXME This is also likely affected */
+void yahoo_set_yab(int id, struct yab *yab)
{
+ struct yahoo_post_data *yad = y_new0(struct yahoo_post_data, 1);
struct yahoo_data *yd = find_conn_by_id(id);
struct yahoo_input_data *yid;
char url[1024];
char buff[1024];
- char *temp;
- int size = sizeof(url)-1;
+ char post[1024];
+ int size = 0;
- if(!yd)
+ if (!yd)
return;
yid = y_new0(struct yahoo_input_data, 1);
yid->type = YAHOO_CONNECTION_YAB;
yid->yd = yd;
- strncpy(url, "http://insider.msg.yahoo.com/ycontent/?addab2=0", size);
-
- if(yab->dbid) {
- /* change existing yab */
- char tmp[32];
- strncat(url, "&ee=1&ow=1&id=", size - strlen(url));
- snprintf(tmp, sizeof(tmp), "%d", yab->dbid);
- strncat(url, tmp, size - strlen(url));
- }
-
- if(yab->fname) {
- strncat(url, "&fn=", size - strlen(url));
- temp = yahoo_urlencode(yab->fname);
- strncat(url, temp, size - strlen(url));
- free(temp);
- }
- if(yab->lname) {
- strncat(url, "&ln=", size - strlen(url));
- temp = yahoo_urlencode(yab->lname);
- strncat(url, temp, size - strlen(url));
- free(temp);
- }
- strncat(url, "&yid=", size - strlen(url));
- temp = yahoo_urlencode(yab->id);
- strncat(url, temp, size - strlen(url));
- free(temp);
- if(yab->nname) {
- strncat(url, "&nn=", size - strlen(url));
- temp = yahoo_urlencode(yab->nname);
- strncat(url, temp, size - strlen(url));
- free(temp);
- }
- if(yab->email) {
- strncat(url, "&e=", size - strlen(url));
- temp = yahoo_urlencode(yab->email);
- strncat(url, temp, size - strlen(url));
- free(temp);
- }
- if(yab->hphone) {
- strncat(url, "&hp=", size - strlen(url));
- temp = yahoo_urlencode(yab->hphone);
- strncat(url, temp, size - strlen(url));
- free(temp);
- }
- if(yab->wphone) {
- strncat(url, "&wp=", size - strlen(url));
- temp = yahoo_urlencode(yab->wphone);
- strncat(url, temp, size - strlen(url));
- free(temp);
- }
- if(yab->mphone) {
- strncat(url, "&mp=", size - strlen(url));
- temp = yahoo_urlencode(yab->mphone);
- strncat(url, temp, size - strlen(url));
- free(temp);
- }
- strncat(url, "&pp=0", size - strlen(url));
-
- snprintf(buff, sizeof(buff), "Y=%s; T=%s",
- yd->cookie_y, yd->cookie_t);
+ if(yab->yid)
+ size = snprintf(post, sizeof(post), "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+ "<ab k=\"%s\" cc=\"%d\">"
+ "<ct id=\"%d\" e=\"1\" yi=\"%s\" nn=\"%s\" />"
+ "</ab>", yd->user, 9, yab->yid, /* Don't know why */
+ yab->id, yab->nname?yab->nname:"");
+ else
+ size = snprintf(post, sizeof(post), "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+ "<ab k=\"%s\" cc=\"%d\">"
+ "<ct a=\"1\" yi=\"%s\" nn=\"%s\" />"
+ "</ab>", yd->user, 1, /* Don't know why */
+ yab->id, yab->nname?yab->nname:"");
+
+ yad->yid = yid;
+ yad->data = strdup(post);
+
+ strcpy(url, "http://address.yahoo.com/yab/us?v=XM&prog=ymsgr&.intl=us"
+ "&sync=1&tags=short&noclear=1&useutf8=1&legenc=codepage-1252");
+
+ snprintf(buff, sizeof(buff), "Y=%s; T=%s", yd->cookie_y, yd->cookie_t);
inputs = y_list_prepend(inputs, yid);
- yahoo_http_get(yid->yd->client_id, url, buff,
- _yahoo_http_connected, yid);
+ yahoo_http_post(yid->yd->client_id, url, buff, size,
+ _yahoo_http_post_connected, yad);
}
-void yahoo_set_identity_status(int id, const char * identity, int active)
+void yahoo_set_identity_status(int id, const char *identity, int active)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
struct yahoo_data *yd;
struct yahoo_packet *pkt = NULL;
- if(!yid)
+ if (!yid)
return;
yd = yid->yd;
- pkt = yahoo_packet_new(active?YAHOO_SERVICE_IDACT:YAHOO_SERVICE_IDDEACT,
- YAHOO_STATUS_AVAILABLE, yd->session_id);
+ pkt = yahoo_packet_new(active ? YAHOO_SERVICE_IDACT :
+ YAHOO_SERVICE_IDDEACT, YPACKET_STATUS_DEFAULT, yd->session_id);
yahoo_packet_hash(pkt, 3, identity);
if (pkt) {
yahoo_send_packet(yid, pkt, 0);
@@ -4259,15 +3880,17 @@ void yahoo_set_identity_status(int id, const char * identity, int active)
void yahoo_refresh(int id)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
struct yahoo_data *yd;
struct yahoo_packet *pkt = NULL;
- if(!yid)
+ if (!yid)
return;
yd = yid->yd;
- pkt = yahoo_packet_new(YAHOO_SERVICE_USERSTAT, YAHOO_STATUS_AVAILABLE, yd->session_id);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_USERSTAT, YPACKET_STATUS_DEFAULT,
+ yd->session_id);
if (pkt) {
yahoo_send_packet(yid, pkt, 0);
yahoo_packet_free(pkt);
@@ -4276,54 +3899,59 @@ void yahoo_refresh(int id)
void yahoo_keepalive(int id)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
struct yahoo_data *yd;
- struct yahoo_packet *pkt=NULL;
- if(!yid)
+ struct yahoo_packet *pkt = NULL;
+ if (!yid)
return;
yd = yid->yd;
- pkt = yahoo_packet_new(YAHOO_SERVICE_PING, YAHOO_STATUS_AVAILABLE, yd->session_id);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_PING, YPACKET_STATUS_DEFAULT,
+ yd->session_id);
yahoo_send_packet(yid, pkt, 0);
yahoo_packet_free(pkt);
}
-void yahoo_chat_keepalive (int id)
+void yahoo_chat_keepalive(int id)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type (id, YAHOO_CONNECTION_PAGER);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
struct yahoo_data *yd;
struct yahoo_packet *pkt = NULL;
if (!yid)
- return;
+ return;
yd = yid->yd;
- pkt = yahoo_packet_new (YAHOO_SERVICE_CHATPING, YAHOO_STATUS_AVAILABLE, yd->session_id);
- yahoo_send_packet (yid, pkt, 0);
- yahoo_packet_free (pkt);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_CHATPING, YPACKET_STATUS_DEFAULT,
+ yd->session_id);
+ yahoo_send_packet(yid, pkt, 0);
+ yahoo_packet_free(pkt);
}
-void yahoo_add_buddy(int id, const char *who, const char *group, const char *msg)
+void yahoo_add_buddy(int id, const char *who, const char *group,
+ const char *msg)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
struct yahoo_data *yd;
struct yahoo_packet *pkt;
- if(!yid)
+ if (!yid)
return;
yd = yid->yd;
if (!yd->logged_in)
return;
- pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YPACKET_STATUS_DEFAULT, yd->session_id);
-
- if (msg != NULL) /* add message/request "it's me add me" */
+ pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YPACKET_STATUS_DEFAULT,
+ yd->session_id);
+ if (msg != NULL) /* add message/request "it's me add me" */
yahoo_packet_hash(pkt, 14, msg);
else
- yahoo_packet_hash(pkt,14,"");
-
+ yahoo_packet_hash(pkt, 14, "");
yahoo_packet_hash(pkt, 65, group);
yahoo_packet_hash(pkt, 97, "1");
yahoo_packet_hash(pkt, 1, yd->user);
@@ -4333,23 +3961,23 @@ void yahoo_add_buddy(int id, const char *who, const char *group, const char *msg
yahoo_packet_hash(pkt, 334, "0");
yahoo_packet_hash(pkt, 301, "319");
yahoo_packet_hash(pkt, 303, "319");
-
-
yahoo_send_packet(yid, pkt, 0);
yahoo_packet_free(pkt);
}
void yahoo_remove_buddy(int id, const char *who, const char *group)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
struct yahoo_data *yd;
struct yahoo_packet *pkt = NULL;
- if(!yid)
+ if (!yid)
return;
yd = yid->yd;
- pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, yd->session_id);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YPACKET_STATUS_DEFAULT,
+ yd->session_id);
yahoo_packet_hash(pkt, 1, yd->user);
yahoo_packet_hash(pkt, 7, who);
@@ -4358,151 +3986,129 @@ void yahoo_remove_buddy(int id, const char *who, const char *group)
yahoo_packet_free(pkt);
}
-void yahoo_accept_buddy_ymsg13(int id,const char* me,const char* who){
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
- struct yahoo_data *yd;
-
- if(!yid)
- return;
- yd = yid->yd;
-
- struct yahoo_packet* pkt=NULL;
- pkt= yahoo_packet_new(YAHOO_SERVICE_CONTACT_YMSG13,YAHOO_STATUS_AVAILABLE,0);
-
- yahoo_packet_hash(pkt,1,me ?: yd->user);
- yahoo_packet_hash(pkt,5,who);
- yahoo_packet_hash(pkt,13,"1");
- yahoo_packet_hash(pkt,334,"0");
- yahoo_send_packet(yid, pkt, 0);
- yahoo_packet_free(pkt);
-}
-
-void yahoo_reject_buddy_ymsg13(int id,const char* me,const char* who,const char* msg){
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
- struct yahoo_data *yd;
-
- if(!yid)
- return;
- yd = yid->yd;
-
- struct yahoo_packet* pkt=NULL;
- pkt= yahoo_packet_new(YAHOO_SERVICE_CONTACT_YMSG13,YAHOO_STATUS_AVAILABLE,0);
-
- yahoo_packet_hash(pkt,1,me ?: yd->user);
- yahoo_packet_hash(pkt,5,who);
-// yahoo_packet_hash(pkt,241,YAHOO_PROTO_VER);
- yahoo_packet_hash(pkt,13,"2");
- yahoo_packet_hash(pkt,334,"0");
- yahoo_packet_hash(pkt,97,"1");
- yahoo_packet_hash(pkt,14,msg?:"");
-
- yahoo_send_packet(yid, pkt, 0);
- yahoo_packet_free(pkt);
-
-}
-
-void yahoo_reject_buddy(int id, const char *who, const char *msg)
+void yahoo_confirm_buddy(int id, const char *who, int reject, const char *msg)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
struct yahoo_data *yd;
struct yahoo_packet *pkt;
- if(!yid)
+ if (!yid)
return;
yd = yid->yd;
if (!yd->logged_in)
return;
- pkt = yahoo_packet_new(YAHOO_SERVICE_REJECTCONTACT, YAHOO_STATUS_AVAILABLE, yd->session_id);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_Y7_AUTHORIZATION,
+ YPACKET_STATUS_DEFAULT, yd->session_id);
yahoo_packet_hash(pkt, 1, yd->user);
- yahoo_packet_hash(pkt, 7, who);
- yahoo_packet_hash(pkt, 14, msg);
+ yahoo_packet_hash(pkt, 5, who);
+ if (reject)
+ yahoo_packet_hash(pkt, 13, "2");
+ else {
+ yahoo_packet_hash(pkt, 241, "0");
+ yahoo_packet_hash(pkt, 13, "1");
+ }
+
+ yahoo_packet_hash(pkt, 334, "0");
+
+ if (reject) {
+ yahoo_packet_hash(pkt, 14, msg ? msg : "");
+ yahoo_packet_hash(pkt, 97, "1");
+ }
+
yahoo_send_packet(yid, pkt, 0);
yahoo_packet_free(pkt);
}
void yahoo_ignore_buddy(int id, const char *who, int unignore)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
struct yahoo_data *yd;
struct yahoo_packet *pkt;
- if(!yid)
+ if (!yid)
return;
yd = yid->yd;
if (!yd->logged_in)
return;
- pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, YAHOO_STATUS_AVAILABLE, yd->session_id);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT,
+ YPACKET_STATUS_DEFAULT, yd->session_id);
yahoo_packet_hash(pkt, 1, yd->user);
yahoo_packet_hash(pkt, 7, who);
- yahoo_packet_hash(pkt, 13, unignore?"2":"1");
+ yahoo_packet_hash(pkt, 13, unignore ? "2" : "1");
yahoo_send_packet(yid, pkt, 0);
yahoo_packet_free(pkt);
}
void yahoo_stealth_buddy(int id, const char *who, int unstealth)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
struct yahoo_data *yd;
struct yahoo_packet *pkt;
- if(!yid)
+ if (!yid)
return;
yd = yid->yd;
if (!yd->logged_in)
return;
- pkt = yahoo_packet_new(YAHOO_SERVICE_STEALTH, YAHOO_STATUS_AVAILABLE, yd->session_id);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_STEALTH_PERM,
+ YPACKET_STATUS_DEFAULT, yd->session_id);
yahoo_packet_hash(pkt, 1, yd->user);
yahoo_packet_hash(pkt, 7, who);
- yahoo_packet_hash(pkt, 31, unstealth?"2":"1");
+ yahoo_packet_hash(pkt, 31, unstealth ? "2" : "1");
yahoo_packet_hash(pkt, 13, "2");
yahoo_send_packet(yid, pkt, 0);
yahoo_packet_free(pkt);
}
-void yahoo_change_buddy_group(int id, const char *who, const char *old_group, const char *new_group)
+void yahoo_change_buddy_group(int id, const char *who, const char *old_group,
+ const char *new_group)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
struct yahoo_data *yd;
struct yahoo_packet *pkt = NULL;
- if(!yid)
+ if (!yid)
return;
yd = yid->yd;
- pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, yd->session_id);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_Y7_CHANGE_GROUP,
+ YPACKET_STATUS_DEFAULT, yd->session_id);
yahoo_packet_hash(pkt, 1, yd->user);
+ yahoo_packet_hash(pkt, 302, "240");
+ yahoo_packet_hash(pkt, 300, "240");
yahoo_packet_hash(pkt, 7, who);
- yahoo_packet_hash(pkt, 65, new_group);
- yahoo_packet_hash(pkt, 14, " ");
-
- yahoo_send_packet(yid, pkt, 0);
- yahoo_packet_free(pkt);
+ yahoo_packet_hash(pkt, 224, old_group);
+ yahoo_packet_hash(pkt, 264, new_group);
+ yahoo_packet_hash(pkt, 301, "240");
+ yahoo_packet_hash(pkt, 303, "240");
- pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, yd->session_id);
- yahoo_packet_hash(pkt, 1, yd->user);
- yahoo_packet_hash(pkt, 7, who);
- yahoo_packet_hash(pkt, 65, old_group);
yahoo_send_packet(yid, pkt, 0);
yahoo_packet_free(pkt);
}
void yahoo_group_rename(int id, const char *old_group, const char *new_group)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
struct yahoo_data *yd;
struct yahoo_packet *pkt = NULL;
- if(!yid)
+ if (!yid)
return;
yd = yid->yd;
- pkt = yahoo_packet_new(YAHOO_SERVICE_GROUPRENAME, YAHOO_STATUS_AVAILABLE, yd->session_id);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_GROUPRENAME,
+ YPACKET_STATUS_DEFAULT, yd->session_id);
yahoo_packet_hash(pkt, 1, yd->user);
yahoo_packet_hash(pkt, 65, old_group);
yahoo_packet_hash(pkt, 67, new_group);
@@ -4511,24 +4117,27 @@ void yahoo_group_rename(int id, const char *old_group, const char *new_group)
yahoo_packet_free(pkt);
}
-void yahoo_conference_addinvite(int id, const char * from, const char *who, const char *room, const YList * members, const char *msg)
+void yahoo_conference_addinvite(int id, const char *from, const char *who,
+ const char *room, const YList *members, const char *msg)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
struct yahoo_data *yd;
struct yahoo_packet *pkt;
-
- if(!yid)
+
+ if (!yid)
return;
yd = yid->yd;
- pkt = yahoo_packet_new(YAHOO_SERVICE_CONFADDINVITE, YAHOO_STATUS_AVAILABLE, yd->session_id);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_CONFADDINVITE,
+ YPACKET_STATUS_DEFAULT, yd->session_id);
- yahoo_packet_hash(pkt, 1, (from?from:yd->user));
+ yahoo_packet_hash(pkt, 1, (from ? from : yd->user));
yahoo_packet_hash(pkt, 51, who);
yahoo_packet_hash(pkt, 57, room);
yahoo_packet_hash(pkt, 58, msg);
yahoo_packet_hash(pkt, 13, "0");
- for(; members; members = members->next) {
+ for (; members; members = members->next) {
yahoo_packet_hash(pkt, 52, (char *)members->data);
yahoo_packet_hash(pkt, 53, (char *)members->data);
}
@@ -4539,21 +4148,24 @@ void yahoo_conference_addinvite(int id, const char * from, const char *who, cons
yahoo_packet_free(pkt);
}
-void yahoo_conference_invite(int id, const char * from, YList *who, const char *room, const char *msg)
+void yahoo_conference_invite(int id, const char *from, YList *who,
+ const char *room, const char *msg)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
struct yahoo_data *yd;
struct yahoo_packet *pkt;
-
- if(!yid)
+
+ if (!yid)
return;
yd = yid->yd;
- pkt = yahoo_packet_new(YAHOO_SERVICE_CONFINVITE, YAHOO_STATUS_AVAILABLE, yd->session_id);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_CONFINVITE, YPACKET_STATUS_DEFAULT,
+ yd->session_id);
- yahoo_packet_hash(pkt, 1, (from?from:yd->user));
+ yahoo_packet_hash(pkt, 1, (from ? from : yd->user));
yahoo_packet_hash(pkt, 50, yd->user);
- for(; who; who = who->next) {
+ for (; who; who = who->next) {
yahoo_packet_hash(pkt, 52, (char *)who->data);
}
yahoo_packet_hash(pkt, 57, room);
@@ -4565,45 +4177,51 @@ void yahoo_conference_invite(int id, const char * from, YList *who, const char *
yahoo_packet_free(pkt);
}
-void yahoo_conference_logon(int id, const char *from, YList *who, const char *room)
+void yahoo_conference_logon(int id, const char *from, YList *who,
+ const char *room)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
struct yahoo_data *yd;
struct yahoo_packet *pkt;
-
- if(!yid)
+
+ if (!yid)
return;
yd = yid->yd;
- pkt = yahoo_packet_new(YAHOO_SERVICE_CONFLOGON, YAHOO_STATUS_AVAILABLE, yd->session_id);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_CONFLOGON, YPACKET_STATUS_DEFAULT,
+ yd->session_id);
- yahoo_packet_hash(pkt, 1, (from?from:yd->user));
- for(; who; who = who->next) {
- yahoo_packet_hash(pkt, 3, (char *)who->data);
- }
+ yahoo_packet_hash(pkt, 1, (from ? from : yd->user));
+ yahoo_packet_hash(pkt, 3, (from ? from : yd->user));
yahoo_packet_hash(pkt, 57, room);
+ for (; who; who = who->next)
+ yahoo_packet_hash(pkt, 3, (char *)who->data);
yahoo_send_packet(yid, pkt, 0);
yahoo_packet_free(pkt);
}
-void yahoo_conference_decline(int id, const char * from, YList *who, const char *room, const char *msg)
+void yahoo_conference_decline(int id, const char *from, YList *who,
+ const char *room, const char *msg)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
struct yahoo_data *yd;
struct yahoo_packet *pkt;
-
- if(!yid)
+
+ if (!yid)
return;
yd = yid->yd;
- pkt = yahoo_packet_new(YAHOO_SERVICE_CONFDECLINE, YAHOO_STATUS_AVAILABLE, yd->session_id);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_CONFDECLINE,
+ YPACKET_STATUS_DEFAULT, yd->session_id);
- yahoo_packet_hash(pkt, 1, (from?from:yd->user));
- for(; who; who = who->next) {
+ yahoo_packet_hash(pkt, 1, (from ? from : yd->user));
+ yahoo_packet_hash(pkt, 3, (from ? from : yd->user));
+ for (; who; who = who->next)
yahoo_packet_hash(pkt, 3, (char *)who->data);
- }
yahoo_packet_hash(pkt, 57, room);
yahoo_packet_hash(pkt, 14, msg);
@@ -4612,22 +4230,26 @@ void yahoo_conference_decline(int id, const char * from, YList *who, const char
yahoo_packet_free(pkt);
}
-void yahoo_conference_logoff(int id, const char * from, YList *who, const char *room)
+void yahoo_conference_logoff(int id, const char *from, YList *who,
+ const char *room)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
struct yahoo_data *yd;
struct yahoo_packet *pkt;
-
- if(!yid)
+
+ if (!yid)
return;
yd = yid->yd;
- pkt = yahoo_packet_new(YAHOO_SERVICE_CONFLOGOFF, YAHOO_STATUS_AVAILABLE, yd->session_id);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_CONFLOGOFF, YPACKET_STATUS_DEFAULT,
+ yd->session_id);
- yahoo_packet_hash(pkt, 1, (from?from:yd->user));
- for(; who; who = who->next) {
+ yahoo_packet_hash(pkt, 1, (from ? from : yd->user));
+ yahoo_packet_hash(pkt, 3, (from ? from : yd->user));
+ for (; who; who = who->next)
yahoo_packet_hash(pkt, 3, (char *)who->data);
- }
+
yahoo_packet_hash(pkt, 57, room);
yahoo_send_packet(yid, pkt, 0);
@@ -4635,26 +4257,30 @@ void yahoo_conference_logoff(int id, const char * from, YList *who, const char *
yahoo_packet_free(pkt);
}
-void yahoo_conference_message(int id, const char * from, YList *who, const char *room, const char *msg, int utf8)
+void yahoo_conference_message(int id, const char *from, YList *who,
+ const char *room, const char *msg, int utf8)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
struct yahoo_data *yd;
struct yahoo_packet *pkt;
-
- if(!yid)
+
+ if (!yid)
return;
yd = yid->yd;
- pkt = yahoo_packet_new(YAHOO_SERVICE_CONFMSG, YAHOO_STATUS_AVAILABLE, yd->session_id);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_CONFMSG, YPACKET_STATUS_DEFAULT,
+ yd->session_id);
- yahoo_packet_hash(pkt, 1, (from?from:yd->user));
- for(; who; who = who->next) {
+ yahoo_packet_hash(pkt, 1, (from ? from : yd->user));
+ yahoo_packet_hash(pkt, 53, (from ? from : yd->user));
+ for (; who; who = who->next)
yahoo_packet_hash(pkt, 53, (char *)who->data);
- }
+
yahoo_packet_hash(pkt, 57, room);
yahoo_packet_hash(pkt, 14, msg);
- if(utf8)
+ if (utf8)
yahoo_packet_hash(pkt, 97, "1");
yahoo_send_packet(yid, pkt, 0);
@@ -4669,7 +4295,7 @@ void yahoo_get_chatrooms(int id, int chatroomid)
char url[1024];
char buff[1024];
- if(!yd)
+ if (!yd)
return;
yid = y_new0(struct yahoo_input_data, 1);
@@ -4677,32 +4303,39 @@ void yahoo_get_chatrooms(int id, int chatroomid)
yid->type = YAHOO_CONNECTION_CHATCAT;
if (chatroomid == 0) {
- snprintf(url, 1024, "http://insider.msg.yahoo.com/ycontent/?chatcat=0");
+ snprintf(url, 1024,
+ "http://insider.msg.yahoo.com/ycontent/?chatcat=0");
} else {
- snprintf(url, 1024, "http://insider.msg.yahoo.com/ycontent/?chatroom_%d=0",chatroomid);
+ snprintf(url, 1024,
+ "http://insider.msg.yahoo.com/ycontent/?chatroom_%d=0",
+ chatroomid);
}
snprintf(buff, sizeof(buff), "Y=%s; T=%s", yd->cookie_y, yd->cookie_t);
inputs = y_list_prepend(inputs, yid);
- yahoo_http_get(yid->yd->client_id, url, buff, _yahoo_http_connected, yid);
+ yahoo_http_get(yid->yd->client_id, url, buff, 0, 0,
+ _yahoo_http_connected, yid);
}
-void yahoo_chat_logon(int id, const char *from, const char *room, const char *roomid)
+void yahoo_chat_logon(int id, const char *from, const char *room,
+ const char *roomid)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
struct yahoo_data *yd;
struct yahoo_packet *pkt;
-
- if(!yid)
+
+ if (!yid)
return;
yd = yid->yd;
- pkt = yahoo_packet_new(YAHOO_SERVICE_CHATONLINE, YAHOO_STATUS_AVAILABLE, yd->session_id);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_CHATONLINE, YPACKET_STATUS_DEFAULT,
+ yd->session_id);
- yahoo_packet_hash(pkt, 1, (from?from:yd->user));
+ yahoo_packet_hash(pkt, 1, (from ? from : yd->user));
yahoo_packet_hash(pkt, 109, yd->user);
yahoo_packet_hash(pkt, 6, "abcde");
@@ -4710,41 +4343,44 @@ void yahoo_chat_logon(int id, const char *from, const char *room, const char *ro
yahoo_packet_free(pkt);
- pkt = yahoo_packet_new(YAHOO_SERVICE_CHATJOIN, YAHOO_STATUS_AVAILABLE, yd->session_id);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_CHATJOIN, YPACKET_STATUS_DEFAULT,
+ yd->session_id);
- yahoo_packet_hash(pkt, 1, (from?from:yd->user));
+ yahoo_packet_hash(pkt, 1, (from ? from : yd->user));
yahoo_packet_hash(pkt, 104, room);
yahoo_packet_hash(pkt, 129, roomid);
- yahoo_packet_hash(pkt, 62, "2"); /* ??? */
+ yahoo_packet_hash(pkt, 62, "2"); /* ??? */
yahoo_send_packet(yid, pkt, 0);
yahoo_packet_free(pkt);
}
-
-void yahoo_chat_message(int id, const char *from, const char *room, const char *msg, const int msgtype, const int utf8)
+void yahoo_chat_message(int id, const char *from, const char *room,
+ const char *msg, const int msgtype, const int utf8)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
struct yahoo_data *yd;
struct yahoo_packet *pkt;
char buf[2];
-
- if(!yid)
+
+ if (!yid)
return;
yd = yid->yd;
- pkt = yahoo_packet_new(YAHOO_SERVICE_COMMENT, YAHOO_STATUS_AVAILABLE, yd->session_id);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_COMMENT, YPACKET_STATUS_DEFAULT,
+ yd->session_id);
- yahoo_packet_hash(pkt, 1, (from?from:yd->user));
+ yahoo_packet_hash(pkt, 1, (from ? from : yd->user));
yahoo_packet_hash(pkt, 104, room);
yahoo_packet_hash(pkt, 117, msg);
-
+
snprintf(buf, sizeof(buf), "%d", msgtype);
yahoo_packet_hash(pkt, 124, buf);
- if(utf8)
+ if (utf8)
yahoo_packet_hash(pkt, 97, "1");
yahoo_send_packet(yid, pkt, 0);
@@ -4752,21 +4388,22 @@ void yahoo_chat_message(int id, const char *from, const char *room, const char
yahoo_packet_free(pkt);
}
-
void yahoo_chat_logoff(int id, const char *from)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
struct yahoo_data *yd;
struct yahoo_packet *pkt;
-
- if(!yid)
+
+ if (!yid)
return;
yd = yid->yd;
- pkt = yahoo_packet_new(YAHOO_SERVICE_CHATLOGOUT, YAHOO_STATUS_AVAILABLE, yd->session_id);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_CHATLOGOUT, YPACKET_STATUS_DEFAULT,
+ yd->session_id);
- yahoo_packet_hash(pkt, 1, (from?from:yd->user));
+ yahoo_packet_hash(pkt, 1, (from ? from : yd->user));
yahoo_send_packet(yid, pkt, 0);
@@ -4775,16 +4412,18 @@ void yahoo_chat_logoff(int id, const char *from)
void yahoo_buddyicon_request(int id, const char *who)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
struct yahoo_data *yd;
struct yahoo_packet *pkt;
- if( !yid )
+ if (!yid)
return;
yd = yid->yd;
-
- pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YAHOO_STATUS_AVAILABLE, 0);
+
+ pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YPACKET_STATUS_DEFAULT,
+ 0);
yahoo_packet_hash(pkt, 4, yd->user);
yahoo_packet_hash(pkt, 5, who);
yahoo_packet_hash(pkt, 13, "1");
@@ -4793,21 +4432,24 @@ void yahoo_buddyicon_request(int id, const char *who)
yahoo_packet_free(pkt);
}
-void yahoo_send_picture_info(int id, const char *who, const char *url, int checksum)
+void yahoo_send_picture_info(int id, const char *who, const char *url,
+ int checksum)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
struct yahoo_data *yd;
struct yahoo_packet *pkt;
char checksum_str[10];
- if( !yid )
+ if (!yid)
return;
yd = yid->yd;
snprintf(checksum_str, sizeof(checksum_str), "%d", checksum);
- pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YAHOO_STATUS_AVAILABLE, 0);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YPACKET_STATUS_DEFAULT,
+ 0);
yahoo_packet_hash(pkt, 1, yd->user);
yahoo_packet_hash(pkt, 4, yd->user);
yahoo_packet_hash(pkt, 5, who);
@@ -4821,19 +4463,21 @@ void yahoo_send_picture_info(int id, const char *who, const char *url, int check
void yahoo_send_picture_update(int id, const char *who, int type)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
struct yahoo_data *yd;
struct yahoo_packet *pkt;
char type_str[10];
- if( !yid )
+ if (!yid)
return;
yd = yid->yd;
snprintf(type_str, sizeof(type_str), "%d", type);
- pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_UPDATE, YAHOO_STATUS_AVAILABLE, 0);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_UPDATE,
+ YPACKET_STATUS_DEFAULT, 0);
yahoo_packet_hash(pkt, 1, yd->user);
yahoo_packet_hash(pkt, 5, who);
yahoo_packet_hash(pkt, 206, type_str);
@@ -4844,21 +4488,23 @@ void yahoo_send_picture_update(int id, const char *who, int type)
void yahoo_send_picture_checksum(int id, const char *who, int checksum)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
struct yahoo_data *yd;
struct yahoo_packet *pkt;
char checksum_str[10];
- if( !yid )
+ if (!yid)
return;
yd = yid->yd;
-
+
snprintf(checksum_str, sizeof(checksum_str), "%d", checksum);
- pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_CHECKSUM, YAHOO_STATUS_AVAILABLE, 0);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_CHECKSUM,
+ YPACKET_STATUS_DEFAULT, 0);
yahoo_packet_hash(pkt, 1, yd->user);
- if( who != 0 )
+ if (who != 0)
yahoo_packet_hash(pkt, 5, who);
yahoo_packet_hash(pkt, 192, checksum_str);
yahoo_packet_hash(pkt, 212, "1");
@@ -4869,19 +4515,21 @@ void yahoo_send_picture_checksum(int id, const char *who, int checksum)
void yahoo_webcam_close_feed(int id, const char *who)
{
- struct yahoo_input_data *yid = find_input_by_id_and_webcam_user(id, who);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_webcam_user(id, who);
- if(yid)
+ if (yid)
yahoo_input_close(yid);
}
void yahoo_webcam_get_feed(int id, const char *who)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
struct yahoo_data *yd;
struct yahoo_packet *pkt;
-
- if(!yid)
+
+ if (!yid)
return;
/*
@@ -4891,11 +4539,12 @@ void yahoo_webcam_get_feed(int id, const char *who)
* order that we request them.
* The queue is popped in yahoo_process_webcam_key
*/
- webcam_queue = y_list_append(webcam_queue, who?strdup(who):NULL);
+ webcam_queue = y_list_append(webcam_queue, who ? strdup(who) : NULL);
yd = yid->yd;
- pkt = yahoo_packet_new(YAHOO_SERVICE_WEBCAM, YAHOO_STATUS_AVAILABLE, yd->session_id);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_WEBCAM, YPACKET_STATUS_DEFAULT,
+ yd->session_id);
yahoo_packet_hash(pkt, 1, yd->user);
if (who != NULL)
@@ -4905,9 +4554,11 @@ void yahoo_webcam_get_feed(int id, const char *who)
yahoo_packet_free(pkt);
}
-void yahoo_webcam_send_image(int id, unsigned char *image, unsigned int length, unsigned int timestamp)
+void yahoo_webcam_send_image(int id, unsigned char *image, unsigned int length,
+ unsigned int timestamp)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_WEBCAM);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_WEBCAM);
unsigned char *packet;
unsigned char header_len = 13;
unsigned int pos = 0;
@@ -4919,10 +4570,10 @@ void yahoo_webcam_send_image(int id, unsigned char *image, unsigned int length,
packet[pos++] = header_len;
packet[pos++] = 0;
- packet[pos++] = 5; /* version byte?? */
+ packet[pos++] = 5; /* version byte?? */
packet[pos++] = 0;
pos += yahoo_put32(packet + pos, length);
- packet[pos++] = 2; /* packet type, image */
+ packet[pos++] = 2; /* packet type, image */
pos += yahoo_put32(packet + pos, timestamp);
yahoo_add_to_send_queue(yid, packet, header_len);
FREE(packet);
@@ -4931,9 +4582,10 @@ void yahoo_webcam_send_image(int id, unsigned char *image, unsigned int length,
yahoo_add_to_send_queue(yid, image, length);
}
-void yahoo_webcam_accept_viewer(int id, const char* who, int accept)
+void yahoo_webcam_accept_viewer(int id, const char *who, int accept)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_WEBCAM);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_WEBCAM);
char *packet = NULL;
char *data = NULL;
unsigned char header_len = 13;
@@ -4944,17 +4596,17 @@ void yahoo_webcam_accept_viewer(int id, const char* who, int accept)
return;
data = strdup("u=");
- data = y_string_append(data, (char*)who);
+ data = y_string_append(data, (char *)who);
data = y_string_append(data, "\r\n");
len = strlen(data);
packet = y_new0(char, header_len + len);
packet[pos++] = header_len;
packet[pos++] = 0;
- packet[pos++] = 5; /* version byte?? */
+ packet[pos++] = 5; /* version byte?? */
packet[pos++] = 0;
pos += yahoo_put32(packet + pos, len);
- packet[pos++] = 0; /* packet type */
+ packet[pos++] = 0; /* packet type */
pos += yahoo_put32(packet + pos, accept);
memcpy(packet + pos, data, len);
FREE(data);
@@ -4964,13 +4616,15 @@ void yahoo_webcam_accept_viewer(int id, const char* who, int accept)
void yahoo_webcam_invite(int id, const char *who)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
struct yahoo_packet *pkt;
-
- if(!yid)
+
+ if (!yid)
return;
- pkt = yahoo_packet_new(YAHOO_SERVICE_NOTIFY, YAHOO_STATUS_NOTIFY, yid->yd->session_id);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_NOTIFY, YPACKET_STATUS_NOTIFY,
+ yid->yd->session_id);
yahoo_packet_hash(pkt, 49, "WEBCAMINVITE");
yahoo_packet_hash(pkt, 14, " ");
@@ -4982,7 +4636,8 @@ void yahoo_webcam_invite(int id, const char *who)
yahoo_packet_free(pkt);
}
-static void yahoo_search_internal(int id, int t, const char *text, int g, int ar, int photo, int yahoo_only, int startpos, int total)
+static void yahoo_search_internal(int id, int t, const char *text, int g,
+ int ar, int photo, int yahoo_only, int startpos, int total)
{
struct yahoo_data *yd = find_conn_by_id(id);
struct yahoo_input_data *yid;
@@ -4990,7 +4645,7 @@ static void yahoo_search_internal(int id, int t, const char *text, int g, int ar
char buff[1024];
char *ctext, *p;
- if(!yd)
+ if (!yd)
return;
yid = y_new0(struct yahoo_input_data, 1);
@@ -4998,38 +4653,43 @@ static void yahoo_search_internal(int id, int t, const char *text, int g, int ar
yid->type = YAHOO_CONNECTION_SEARCH;
/*
- age range
- .ar=1 - 13-18, 2 - 18-25, 3 - 25-35, 4 - 35-50, 5 - 50-70, 6 - 70+
- */
+ age range
+ .ar=1 - 13-18, 2 - 18-25, 3 - 25-35, 4 - 35-50, 5 - 50-70, 6 - 70+
+ */
- snprintf(buff, sizeof(buff), "&.sq=%%20&.tt=%d&.ss=%d", total, startpos);
+ snprintf(buff, sizeof(buff), "&.sq=%%20&.tt=%d&.ss=%d", total,
+ startpos);
ctext = strdup(text);
- while((p = strchr(ctext, ' ')))
+ while ((p = strchr(ctext, ' ')))
*p = '+';
- snprintf(url, 1024, "http://members.yahoo.com/interests?.oc=m&.kw=%s&.sb=%d&.g=%d&.ar=0%s%s%s",
- ctext, t, g, photo ? "&.p=y" : "", yahoo_only ? "&.pg=y" : "",
- startpos ? buff : "");
+ snprintf(url, 1024,
+ "http://members.yahoo.com/interests?.oc=m&.kw=%s&.sb=%d&.g=%d&.ar=0%s%s%s",
+ ctext, t, g, photo ? "&.p=y" : "", yahoo_only ? "&.pg=y" : "",
+ startpos ? buff : "");
FREE(ctext);
snprintf(buff, sizeof(buff), "Y=%s; T=%s", yd->cookie_y, yd->cookie_t);
inputs = y_list_prepend(inputs, yid);
- yahoo_http_get(yid->yd->client_id, url, buff, _yahoo_http_connected, yid);
+ yahoo_http_get(yid->yd->client_id, url, buff, 0, 0,
+ _yahoo_http_connected, yid);
}
-void yahoo_search(int id, enum yahoo_search_type t, const char *text, enum yahoo_search_gender g, enum yahoo_search_agerange ar,
- int photo, int yahoo_only)
+void yahoo_search(int id, enum yahoo_search_type t, const char *text,
+ enum yahoo_search_gender g, enum yahoo_search_agerange ar, int photo,
+ int yahoo_only)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
struct yahoo_search_state *yss;
- if(!yid)
+ if (!yid)
return;
- if(!yid->ys)
+ if (!yid->ys)
yid->ys = y_new0(struct yahoo_search_state, 1);
yss = yid->ys;
@@ -5047,273 +4707,708 @@ void yahoo_search(int id, enum yahoo_search_type t, const char *text, enum yahoo
void yahoo_search_again(int id, int start)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ struct yahoo_input_data *yid =
+ find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
struct yahoo_search_state *yss;
- if(!yid || !yid->ys)
+ if (!yid || !yid->ys)
return;
yss = yid->ys;
- if(start == -1)
+ if (start == -1)
start = yss->lsearch_nstart + yss->lsearch_nfound;
- yahoo_search_internal(id, yss->lsearch_type, yss->lsearch_text,
- yss->lsearch_gender, yss->lsearch_agerange,
- yss->lsearch_photo, yss->lsearch_yahoo_only,
- start, yss->lsearch_ntotal);
+ yahoo_search_internal(id, yss->lsearch_type, yss->lsearch_text,
+ yss->lsearch_gender, yss->lsearch_agerange,
+ yss->lsearch_photo, yss->lsearch_yahoo_only,
+ start, yss->lsearch_ntotal);
+}
+
+void yahoo_send_picture(int id, const char *name, unsigned long size,
+ yahoo_get_fd_callback callback, void *data)
+{
+ /* Not Implemented */
}
+/* File Transfer */
+static YList *active_file_transfers = NULL;
+
+enum {
+ FT_STATE_HEAD = 1,
+ FT_STATE_RECV,
+ FT_STATE_RECV_START,
+ FT_STATE_SEND
+};
+
struct send_file_data {
- struct yahoo_packet *pkt;
+ int client_id;
+ char *id;
+ char *who;
+ char *filename;
+ char *ip_addr;
+ char *token;
+ int size;
+
+ struct yahoo_input_data *yid;
+ int state;
+
yahoo_get_fd_callback callback;
- void *user_data;
+ void *data;
};
-static void _yahoo_send_picture_connected(int id, int fd, int error, void *data)
+static char *yahoo_get_random(void)
+{
+ int i = 0;
+ int r = 0;
+ int c = 0;
+ char out[25];
+
+ out[24] = '\0';
+ out[23] = '$';
+ out[22] = '$';
+
+ for (i = 0; i < 22; i++) {
+ if(r == 0)
+ r = rand();
+
+ c = r%61;
+
+ if(c<26)
+ out[i] = c + 'a';
+ else if (c<52)
+ out[i] = c - 26 + 'A';
+ else
+ out[i] = c - 52 + '0';
+
+ r /= 61;
+ }
+
+ return strdup(out);
+}
+
+static int _are_same_id(const void *sfd1, const void *id)
+{
+ return strcmp(((struct send_file_data *)sfd1)->id, (char *)id);
+}
+
+static int _are_same_yid(const void *sfd1, const void *yid)
+{
+ if(((struct send_file_data *)sfd1)->yid == yid)
+ return 0;
+ else
+ return 1;
+}
+
+static struct send_file_data *yahoo_get_active_transfer(char *id)
+{
+ YList *l = y_list_find_custom(active_file_transfers, id,
+ _are_same_id);
+
+ if(l)
+ return (struct send_file_data *)l->data;
+
+ return NULL;
+}
+
+static struct send_file_data *yahoo_get_active_transfer_with_yid(void *yid)
+{
+ YList *l = y_list_find_custom(active_file_transfers, yid,
+ _are_same_yid);
+
+ if(l)
+ return (struct send_file_data *)l->data;
+
+ return NULL;
+}
+
+static void yahoo_add_active_transfer(struct send_file_data *sfd)
+{
+ active_file_transfers = y_list_prepend(active_file_transfers, sfd);
+}
+
+static void yahoo_remove_active_transfer(struct send_file_data *sfd)
+{
+ active_file_transfers = y_list_remove(active_file_transfers, sfd);
+ free(sfd->id);
+ free(sfd->who);
+ free(sfd->filename);
+ free(sfd->ip_addr);
+ FREE(sfd);
+}
+
+static void _yahoo_ft_upload_connected(int id, void *fd, int error, void *data)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_FT);
struct send_file_data *sfd = data;
- struct yahoo_packet *pkt = sfd->pkt;
- unsigned char buff[1024];
+ struct yahoo_input_data *yid = sfd->yid;
- if(fd <= 0) {
- sfd->callback(id, fd, error, sfd->user_data);
- FREE(sfd);
- yahoo_packet_free(pkt);
+ if (!fd) {
inputs = y_list_remove(inputs, yid);
FREE(yid);
return;
}
+ sfd->callback(id, fd, error, sfd->data);
+
yid->fd = fd;
- yahoo_send_packet(yid, pkt, 8);
- yahoo_packet_free(pkt);
+ yid->read_tag =
+ YAHOO_CALLBACK(ext_yahoo_add_handler) (yid->yd->client_id, fd,
+ YAHOO_INPUT_READ, yid);
+}
- snprintf((char *)buff, sizeof(buff), "29");
- buff[2] = 0xc0;
- buff[3] = 0x80;
-
- write(yid->fd, buff, 4);
+static void yahoo_file_transfer_upload(struct yahoo_data *yd,
+ struct send_file_data *sfd)
+{
+ char url[256];
+ char buff[4096];
+ char *sender_enc = NULL, *recv_enc = NULL, *token_enc = NULL;
- /* YAHOO_CALLBACK(ext_yahoo_add_handler)(nyd->fd, YAHOO_INPUT_READ); */
+ struct yahoo_input_data *yid = y_new0(struct yahoo_input_data, 1);
- sfd->callback(id, fd, error, sfd->user_data);
- FREE(sfd);
- inputs = y_list_remove(inputs, yid);
- /*
- while(yahoo_tcp_readline(buff, sizeof(buff), nyd->fd) > 0) {
- if(!strcmp(buff, ""))
- break;
+ yid->yd = yd;
+ yid->type = YAHOO_CONNECTION_FT;
+
+ inputs = y_list_prepend(inputs, yid);
+ sfd->yid = yid;
+ sfd->state = FT_STATE_SEND;
+
+ token_enc = yahoo_urlencode(sfd->token);
+ sender_enc = yahoo_urlencode(yd->user);
+ recv_enc = yahoo_urlencode(sfd->who);
+
+ snprintf(url, sizeof(url),
+ "http://%s/relay?token=%s&sender=%s&recver=%s", sfd->ip_addr,
+ token_enc, sender_enc, recv_enc);
+
+ snprintf(buff, sizeof(buff), "T=%s; Y=%s", yd->cookie_t, yd->cookie_y);
+
+ yahoo_http_post(yd->client_id, url, buff, sfd->size,
+ _yahoo_ft_upload_connected, sfd);
+
+ FREE(token_enc);
+ FREE(sender_enc);
+ FREE(recv_enc);
}
- */
- yahoo_input_close(yid);
+static void yahoo_init_ft_recv(struct yahoo_data *yd,
+ struct send_file_data *sfd)
+{
+ char url[256];
+ char buff[1024];
+ char *sender_enc = NULL, *recv_enc = NULL, *token_enc = NULL;
+
+ struct yahoo_input_data *yid = y_new0(struct yahoo_input_data, 1);
+
+ yid->yd = yd;
+ yid->type = YAHOO_CONNECTION_FT;
+
+ inputs = y_list_prepend(inputs, yid);
+ sfd->yid = yid;
+ sfd->state = FT_STATE_HEAD;
+
+ token_enc = yahoo_urlencode(sfd->token);
+ sender_enc = yahoo_urlencode(sfd->who);
+ recv_enc = yahoo_urlencode(yd->user);
+
+ snprintf(url, sizeof(url),
+ "http://%s/relay?token=%s&sender=%s&recver=%s", sfd->ip_addr,
+ token_enc, sender_enc, recv_enc);
+
+ snprintf(buff, sizeof(buff), "Y=%s; T=%s", yd->cookie_y, yd->cookie_t);
+
+ yahoo_http_head(yid->yd->client_id, url, buff, 0, NULL,
+ _yahoo_http_connected, yid);
+
+ FREE(token_enc);
+ FREE(sender_enc);
+ FREE(recv_enc);
}
-void yahoo_send_picture(int id, const char *name, unsigned long size,
- yahoo_get_fd_callback callback, void *data)
+static void yahoo_file_transfer_accept(struct yahoo_input_data *yid,
+ struct send_file_data *sfd)
{
- struct yahoo_data *yd = find_conn_by_id(id);
- struct yahoo_input_data *yid;
- struct yahoo_server_settings *yss;
- struct yahoo_packet *pkt = NULL;
- char size_str[10];
- char expire_str[10];
- long content_length=0;
- unsigned char buff[1024];
- char url[255];
+ struct yahoo_packet *pkt;
+
+ pkt = yahoo_packet_new(YAHOO_SERVICE_Y7_FILETRANSFERACCEPT,
+ YPACKET_STATUS_DEFAULT, yid->yd->session_id);
+
+ yahoo_packet_hash(pkt, 1, yid->yd->user);
+ yahoo_packet_hash(pkt, 5, sfd->who);
+ yahoo_packet_hash(pkt, 265, sfd->id);
+ yahoo_packet_hash(pkt, 27, sfd->filename);
+ yahoo_packet_hash(pkt, 249, "3");
+ yahoo_packet_hash(pkt, 251, sfd->token);
+
+ yahoo_send_packet(yid, pkt, 0);
+
+ yahoo_packet_free(pkt);
+
+ yahoo_init_ft_recv(yid->yd, sfd);
+}
+
+static void yahoo_process_filetransferaccept(struct yahoo_input_data *yid,
+ struct yahoo_packet *pkt)
+{
+ YList *l;
struct send_file_data *sfd;
+ char *who = NULL;
+ char *filename = NULL;
+ char *id = NULL;
+ char *token = NULL;
- if(!yd)
- return;
+ for (l = pkt->hash; l; l = l->next) {
+ struct yahoo_pair *pair = l->data;
+ switch (pair->key) {
+ case 4:
+ who = pair->value;
+ break;
+ case 5:
+ /* Me... don't care */
+ break;
+ case 249:
+ break;
+ case 265:
+ id = pair->value;
+ break;
+ case 251:
+ token = pair->value;
+ break;
+ case 27:
+ filename = pair->value;
+ break;
+ }
+ }
- yss = yd->server_settings;
+ sfd = yahoo_get_active_transfer(id);
- yid = y_new0(struct yahoo_input_data, 1);
- yid->yd = yd;
- yid->type = YAHOO_CONNECTION_FT;
+ if (sfd) {
+ sfd->token = strdup(token);
- pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_UPLOAD, YAHOO_STATUS_AVAILABLE, yd->session_id);
+ yahoo_file_transfer_upload(yid->yd, sfd);
+ }
+ else {
+ YAHOO_CALLBACK(ext_yahoo_file_transfer_done)
+ (yid->yd->client_id, YAHOO_FILE_TRANSFER_UNKNOWN,
+ sfd->data);
- snprintf(size_str, sizeof(size_str), "%ld", size);
- snprintf(expire_str, sizeof(expire_str), "%ld", (long)604800);
+ yahoo_remove_active_transfer(sfd);
+ }
+}
- yahoo_packet_hash(pkt, 0, yd->user);
- yahoo_packet_hash(pkt, 1, yd->user);
- yahoo_packet_hash(pkt, 14, "");
- yahoo_packet_hash(pkt, 27, name);
- yahoo_packet_hash(pkt, 28, size_str);
- yahoo_packet_hash(pkt, 38, expire_str);
-
+static void yahoo_process_filetransferinfo(struct yahoo_input_data *yid,
+ struct yahoo_packet *pkt)
+{
+ YList *l;
+ char *who = NULL;
+ char *filename = NULL;
+ char *id = NULL;
+ char *token = NULL;
+ char *ip_addr = NULL;
- content_length = YAHOO_PACKET_HDRLEN + yahoo_packet_length(pkt);
+ struct send_file_data *sfd;
- snprintf(url, sizeof(url), "http://%s:%d/notifyft",
- yss->filetransfer_host, yss->filetransfer_port);
- snprintf((char *)buff, sizeof(buff), "Y=%s; T=%s",
- yd->cookie_y, yd->cookie_t);
- inputs = y_list_prepend(inputs, yid);
+ for (l = pkt->hash; l; l = l->next) {
+ struct yahoo_pair *pair = l->data;
+ switch (pair->key) {
+ case 1:
+ case 4:
+ who = pair->value;
+ break;
+ case 5:
+ /* Me... don't care */
+ break;
+ case 249:
+ break;
+ case 265:
+ id = pair->value;
+ break;
+ case 250:
+ ip_addr = pair->value;
+ break;
+ case 251:
+ token = pair->value;
+ break;
+ case 27:
+ filename = pair->value;
+ break;
+ }
+ }
- sfd = y_new0(struct send_file_data, 1);
- sfd->pkt = pkt;
- sfd->callback = callback;
- sfd->user_data = data;
- yahoo_http_post(yid->yd->client_id, url, (char *)buff, content_length+4+size,
- _yahoo_send_picture_connected, sfd);
+ sfd = yahoo_get_active_transfer(id);
+
+ if (sfd) {
+ sfd->token = strdup(token);
+ sfd->ip_addr = strdup(ip_addr);
+
+ yahoo_file_transfer_accept(yid, sfd);
+ }
+ else {
+ YAHOO_CALLBACK(ext_yahoo_file_transfer_done)
+ (yid->yd->client_id, YAHOO_FILE_TRANSFER_UNKNOWN,
+ sfd->data);
+
+ yahoo_remove_active_transfer(sfd);
+ }
}
-static void _yahoo_send_file_connected(int id, int fd, int error, void *data)
+static void yahoo_send_filetransferinfo(struct yahoo_data *yd,
+ struct send_file_data *sfd)
{
- struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_FT);
- struct send_file_data *sfd = data;
- struct yahoo_packet *pkt = sfd->pkt;
- unsigned char buff[1024];
+ struct yahoo_input_data *yid;
+ struct yahoo_packet *pkt;
+
+ yid = find_input_by_id_and_type(yd->client_id, YAHOO_CONNECTION_PAGER);
+ sfd->ip_addr = YAHOO_CALLBACK(ext_yahoo_get_ip_addr)("relay.yahoo.com");
+
+ if (!sfd->ip_addr) {
+ YAHOO_CALLBACK(ext_yahoo_file_transfer_done)
+ (yd->client_id, YAHOO_FILE_TRANSFER_RELAY, sfd->data);
+
+ yahoo_remove_active_transfer(sfd);
- if(fd <= 0) {
- sfd->callback(id, fd, error, sfd->user_data);
- FREE(sfd);
- yahoo_packet_free(pkt);
- inputs = y_list_remove(inputs, yid);
- FREE(yid);
return;
}
- yid->fd = fd;
- yahoo_send_packet(yid, pkt, 8);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_Y7_FILETRANSFERINFO,
+ YPACKET_STATUS_DEFAULT, yd->session_id);
+
+ yahoo_packet_hash(pkt, 1, yd->user);
+ yahoo_packet_hash(pkt, 5, sfd->who);
+ yahoo_packet_hash(pkt, 265, sfd->id);
+ yahoo_packet_hash(pkt, 27, sfd->filename);
+ yahoo_packet_hash(pkt, 249, "3");
+ yahoo_packet_hash(pkt, 250, sfd->ip_addr);
+
+ yahoo_send_packet(yid, pkt, 0);
+
yahoo_packet_free(pkt);
+}
- snprintf((char *)buff, sizeof(buff), "29");
- buff[2] = 0xc0;
- buff[3] = 0x80;
-
- write(yid->fd, buff, 4);
+static void yahoo_process_filetransfer(struct yahoo_input_data *yid,
+ struct yahoo_packet *pkt)
+{
+ YList *l;
+ char *who = NULL;
+ char *filename = NULL;
+ char *msg = NULL;
+ char *id = NULL;
+ int action = 0;
+ int size = 0;
+ struct yahoo_data *yd = yid->yd;
-/* YAHOO_CALLBACK(ext_yahoo_add_handler)(nyd->fd, YAHOO_INPUT_READ); */
+ struct send_file_data *sfd;
- sfd->callback(id, fd, error, sfd->user_data);
- FREE(sfd);
- inputs = y_list_remove(inputs, yid);
- /*
- while(yahoo_tcp_readline(buff, sizeof(buff), nyd->fd) > 0) {
- if(!strcmp(buff, ""))
+ for (l = pkt->hash; l; l = l->next) {
+ struct yahoo_pair *pair = l->data;
+ switch (pair->key) {
+ case 4:
+ who = pair->value;
+ break;
+ case 5:
+ /* Me... don't care */
+ break;
+ case 222:
+ action = atoi(pair->value);
+ break;
+ case 265:
+ id = pair->value;
+ break;
+ case 266: /* Don't know */
+ break;
+ case 302: /* Start Data? */
+ break;
+ case 300:
+ break;
+ case 27:
+ filename = pair->value;
break;
+ case 28:
+ size = atoi(pair->value);
+ break;
+ case 14:
+ msg = pair->value;
+ case 301: /* End Data? */
+ break;
+ case 303:
+ break;
+
+ }
+ }
+
+ if (action == YAHOO_FILE_TRANSFER_INIT) {
+ /* Received a FT request from buddy */
+ sfd = y_new0(struct send_file_data, 1);
+
+ sfd->client_id = yd->client_id;
+ sfd->id = strdup(id);
+ sfd->who = strdup(who);
+ sfd->filename = strdup(filename);
+ sfd->size = size;
+
+ yahoo_add_active_transfer(sfd);
+
+ YAHOO_CALLBACK(ext_yahoo_got_file) (yd->client_id, yd->user,
+ who, msg, filename, size, sfd->id);
}
+ else {
+ /* Response to our request */
+ sfd = yahoo_get_active_transfer(id);
- */
- yahoo_input_close(yid);
+ if (sfd && action == YAHOO_FILE_TRANSFER_ACCEPT) {
+ yahoo_send_filetransferinfo(yd, sfd);
+ }
+ else if (!sfd || action == YAHOO_FILE_TRANSFER_REJECT) {
+ YAHOO_CALLBACK(ext_yahoo_file_transfer_done)
+ (yd->client_id, YAHOO_FILE_TRANSFER_REJECT,
+ sfd->data);
+
+ yahoo_remove_active_transfer(sfd);
+ }
+ }
}
-void yahoo_send_file(int id, const char *who, const char *msg,
- const char *name, unsigned long size,
- yahoo_get_fd_callback callback, void *data)
+void yahoo_send_file(int id, const char *who, const char *msg,
+ const char *name, unsigned long size,
+ yahoo_get_fd_callback callback, void *data)
{
- struct yahoo_data *yd = find_conn_by_id(id);
- struct yahoo_input_data *yid;
- struct yahoo_server_settings *yss;
struct yahoo_packet *pkt = NULL;
char size_str[10];
- long content_length=0;
- unsigned char buff[1024];
- char url[255];
+ struct yahoo_input_data *yid;
+ struct yahoo_data *yd;
struct send_file_data *sfd;
+
+ yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
+ yd = find_conn_by_id(id);
+ sfd = y_new0(struct send_file_data, 1);
- if(!yd)
- return;
+ sfd->client_id = id;
+ sfd->id = yahoo_get_random();
+ sfd->who = strdup(who);
+ sfd->filename = strdup(name);
+ sfd->size = size;
+ sfd->callback = callback;
+ sfd->data = data;
- yss = yd->server_settings;
+ yahoo_add_active_transfer(sfd);
- yid = y_new0(struct yahoo_input_data, 1);
- yid->yd = yd;
- yid->type = YAHOO_CONNECTION_FT;
+ if (!yd)
+ return;
- pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANSFER, YAHOO_STATUS_AVAILABLE, yd->session_id);
+ pkt = yahoo_packet_new(YAHOO_SERVICE_Y7_FILETRANSFER,
+ YPACKET_STATUS_DEFAULT, yd->session_id);
snprintf(size_str, sizeof(size_str), "%ld", size);
- yahoo_packet_hash(pkt, 0, yd->user);
+ yahoo_packet_hash(pkt, 1, yd->user);
yahoo_packet_hash(pkt, 5, who);
- yahoo_packet_hash(pkt, 14, msg);
+ yahoo_packet_hash(pkt, 265, sfd->id);
+ yahoo_packet_hash(pkt, 222, "1");
+ yahoo_packet_hash(pkt, 266, "1");
+ yahoo_packet_hash(pkt, 302, "268");
+ yahoo_packet_hash(pkt, 300, "268");
yahoo_packet_hash(pkt, 27, name);
yahoo_packet_hash(pkt, 28, size_str);
+ yahoo_packet_hash(pkt, 301, "268");
+ yahoo_packet_hash(pkt, 303, "268");
- content_length = YAHOO_PACKET_HDRLEN + yahoo_packet_length(pkt);
+ yahoo_send_packet(yid, pkt, 0);
- snprintf(url, sizeof(url), "http://%s:%d/notifyft",
- yss->filetransfer_host, yss->filetransfer_port);
- snprintf((char *)buff, sizeof(buff), "Y=%s; T=%s",
- yd->cookie_y, yd->cookie_t);
- inputs = y_list_prepend(inputs, yid);
+ yahoo_packet_free(pkt);
+}
- sfd = y_new0(struct send_file_data, 1);
- sfd->pkt = pkt;
- sfd->callback = callback;
- sfd->user_data = data;
- yahoo_http_post(yid->yd->client_id, url, (char *)buff, content_length+4+size,
- _yahoo_send_file_connected, sfd);
+void yahoo_send_file_transfer_response(int client_id, int response, char *id, void *data)
+{
+ struct yahoo_packet *pkt = NULL;
+ char resp[2];
+ struct yahoo_input_data *yid;
+
+ struct send_file_data *sfd = yahoo_get_active_transfer(id);
+
+ sfd->data = data;
+
+ yid = find_input_by_id_and_type(client_id, YAHOO_CONNECTION_PAGER);
+
+ pkt = yahoo_packet_new(YAHOO_SERVICE_Y7_FILETRANSFER,
+ YPACKET_STATUS_DEFAULT, yid->yd->session_id);
+
+ snprintf(resp, sizeof(resp), "%d", response);
+
+ yahoo_packet_hash(pkt, 1, yid->yd->user);
+ yahoo_packet_hash(pkt, 5, sfd->who);
+ yahoo_packet_hash(pkt, 265, sfd->id);
+ yahoo_packet_hash(pkt, 222, resp);
+
+ yahoo_send_packet(yid, pkt, 0);
+
+ yahoo_packet_free(pkt);
+
+ if(response == YAHOO_FILE_TRANSFER_REJECT)
+ yahoo_remove_active_transfer(sfd);
+}
+
+static void yahoo_process_ft_connection(struct yahoo_input_data *yid, int over)
+{
+ struct send_file_data *sfd;
+ struct yahoo_data *yd = yid->yd;
+
+ sfd = yahoo_get_active_transfer_with_yid(yid);
+
+ if (!sfd) {
+ LOG(("Something funny happened. yid %p has no sfd.\n", yid));
+ return;
+ }
+
+ /*
+ * We want to handle only the complete data with HEAD since we don't
+ * want a situation where both the GET and HEAD are active.
+ * With SEND, we really can't do much with partial response
+ */
+ if ((sfd->state == FT_STATE_HEAD || sfd->state == FT_STATE_SEND)
+ && !over)
+ return;
+
+ if (sfd->state == FT_STATE_HEAD) {
+ /* Do a GET */
+ char url[256];
+ char buff[1024];
+ char *sender_enc = NULL, *recv_enc = NULL, *token_enc = NULL;
+
+ struct yahoo_input_data *yid_ft =
+ y_new0(struct yahoo_input_data, 1);
+
+ yid_ft->yd = yid->yd;
+ yid_ft->type = YAHOO_CONNECTION_FT;
+
+ inputs = y_list_prepend(inputs, yid_ft);
+ sfd->yid = yid_ft;
+ sfd->state = FT_STATE_RECV;
+
+ token_enc = yahoo_urlencode(sfd->token);
+ sender_enc = yahoo_urlencode(sfd->who);
+ recv_enc = yahoo_urlencode(yd->user);
+
+ snprintf(url, sizeof(url),
+ "http://%s/relay?token=%s&sender=%s&recver=%s", sfd->ip_addr,
+ token_enc, sender_enc, recv_enc);
+
+ snprintf(buff, sizeof(buff), "Y=%s; T=%s", yd->cookie_y,
+ yd->cookie_t);
+
+
+ yahoo_http_get(yd->client_id, url, buff, 1, 1,
+ _yahoo_http_connected, yid_ft);
+
+ FREE(token_enc);
+ FREE(sender_enc);
+ FREE(recv_enc);
+ }
+ else if (sfd->state == FT_STATE_RECV ||
+ sfd->state == FT_STATE_RECV_START) {
+
+ unsigned char *data_begin = NULL;
+
+ if (yid->rxlen == 0)
+ yahoo_remove_active_transfer(sfd);
+
+ if (sfd->state != FT_STATE_RECV_START &&
+ (data_begin =
+ (unsigned char *)strstr((char *)yid->rxqueue,
+ "\r\n\r\n"))) {
+
+ sfd->state = FT_STATE_RECV_START;
+
+ yid->rxlen -= 4+(data_begin-yid->rxqueue)/sizeof(char);
+ data_begin += 4;
+
+ if (yid->rxlen > 0)
+ YAHOO_CALLBACK(ext_yahoo_got_ft_data)
+ (yd->client_id, data_begin,
+ yid->rxlen, sfd->data);
+ }
+ else if (sfd->state == FT_STATE_RECV_START)
+ YAHOO_CALLBACK(ext_yahoo_got_ft_data) (yd->client_id,
+ yid->rxqueue, yid->rxlen, sfd->data);
+
+ FREE(yid->rxqueue);
+ yid->rxqueue = NULL;
+ yid->rxlen = 0;
+ }
+ else if (sfd->state == FT_STATE_SEND) {
+ /* Sent file completed */
+ int len = 0;
+ char *off = strstr((char *)yid->rxqueue, "Content-Length: ");
+
+ if (off) {
+ off += 16;
+ len = atoi(off);
+ }
+
+ if (len < sfd->size)
+ YAHOO_CALLBACK(ext_yahoo_file_transfer_done)
+ (yd->client_id,
+ YAHOO_FILE_TRANSFER_FAILED, sfd->data);
+ else
+ YAHOO_CALLBACK(ext_yahoo_file_transfer_done)
+ (yd->client_id,
+ YAHOO_FILE_TRANSFER_DONE, sfd->data);
+
+ yahoo_remove_active_transfer(sfd);
+ }
}
+/* End File Transfer */
enum yahoo_status yahoo_current_status(int id)
{
struct yahoo_data *yd = find_conn_by_id(id);
- if(!yd)
+ if (!yd)
return YAHOO_STATUS_OFFLINE;
return yd->current_status;
}
-const YList * yahoo_get_buddylist(int id)
+const YList *yahoo_get_buddylist(int id)
{
struct yahoo_data *yd = find_conn_by_id(id);
- if(!yd)
+ if (!yd)
return NULL;
return yd->buddies;
}
-const YList * yahoo_get_ignorelist(int id)
+const YList *yahoo_get_ignorelist(int id)
{
struct yahoo_data *yd = find_conn_by_id(id);
- if(!yd)
+ if (!yd)
return NULL;
return yd->ignore;
}
-const YList * yahoo_get_identities(int id)
+const YList *yahoo_get_identities(int id)
{
struct yahoo_data *yd = find_conn_by_id(id);
- if(!yd)
+ if (!yd)
return NULL;
return yd->identities;
}
-const char * yahoo_get_cookie(int id, const char *which)
+const char *yahoo_get_cookie(int id, const char *which)
{
struct yahoo_data *yd = find_conn_by_id(id);
- if(!yd)
+ if (!yd)
return NULL;
- if(!strncasecmp(which, "y", 1))
+ if (!strncasecmp(which, "y", 1))
return yd->cookie_y;
- if(!strncasecmp(which, "t", 1))
+ if (!strncasecmp(which, "b", 1))
+ return yd->cookie_b;
+ if (!strncasecmp(which, "t", 1))
return yd->cookie_t;
- if(!strncasecmp(which, "c", 1))
+ if (!strncasecmp(which, "c", 1))
return yd->cookie_c;
- if(!strncasecmp(which, "login", 5))
+ if (!strncasecmp(which, "login", 5))
return yd->login_cookie;
return NULL;
}
-void yahoo_get_url_handle(int id, const char *url,
- yahoo_get_url_handle_callback callback, void *data)
-{
- struct yahoo_data *yd = find_conn_by_id(id);
- if(!yd)
- return;
-
- yahoo_get_url_fd(id, url, yd, callback, data);
-}
-
-const char * yahoo_get_profile_url( void )
+const char *yahoo_get_profile_url(void)
{
return profile_url;
}
-
diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c
index bf577496..dfd2e70f 100644
--- a/protocols/yahoo/yahoo.c
+++ b/protocols/yahoo/yahoo.c
@@ -1,7 +1,7 @@
/*
* libyahoo2 wrapper to BitlBee
*
- * Mostly Copyright 2004 Wilmer van der Gaast <wilmer@gaast.net>
+ * Mostly Copyright 2004-2010 Wilmer van der Gaast <wilmer@gaast.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -270,8 +270,32 @@ static void byahoo_keepalive( struct im_connection *ic )
static void byahoo_add_buddy( struct im_connection *ic, char *who, char *group )
{
struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data;
+ bee_user_t *bu;
- yahoo_add_buddy( yd->y2_id, who, group ? group : BYAHOO_DEFAULT_GROUP, NULL );
+ if( group && ( bu = bee_user_by_handle( ic->bee, ic, who ) ) && bu->group )
+ {
+ GSList *bgl;
+
+ /* If the person is in our list already, this is a group change. */
+ yahoo_change_buddy_group( yd->y2_id, who, bu->group->name, group );
+
+ /* No idea how often people have people in multiple groups and
+ BitlBee doesn't currently support this anyway .. but keep
+ this struct up-to-date for now. */
+ for( bgl = yd->buddygroups; bgl; bgl = bgl->next )
+ {
+ struct byahoo_buddygroups *bg = bgl->data;
+
+ if( g_strcasecmp( bg->buddy, who ) == 0 &&
+ g_strcasecmp( bg->group, bu->group->name ) == 0 )
+ {
+ g_free( bg->group );
+ bg->group = g_strdup( group );
+ }
+ }
+ }
+ else
+ yahoo_add_buddy( yd->y2_id, who, group ? group : BYAHOO_DEFAULT_GROUP, NULL );
}
static void byahoo_remove_buddy( struct im_connection *ic, char *who, char *group )
@@ -340,14 +364,14 @@ static void byahoo_auth_allow( struct im_connection *ic, const char *who )
{
struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data;
- yahoo_accept_buddy_ymsg13( yd->y2_id, NULL, who );
+ yahoo_confirm_buddy( yd->y2_id, who, 0, "" );
}
static void byahoo_auth_deny( struct im_connection *ic, const char *who )
{
struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data;
- yahoo_reject_buddy_ymsg13( yd->y2_id, NULL, who, NULL );
+ yahoo_confirm_buddy( yd->y2_id, who, 1, "" );
}
void byahoo_initmodule( )
@@ -420,7 +444,7 @@ void byahoo_connect_callback( gpointer data, gint source, b_input_condition cond
return;
}
- d->callback( d->fd, 0, d->data );
+ d->callback( NULL + d->fd, 0, d->data );
g_free( d );
}
@@ -440,7 +464,7 @@ gboolean byahoo_read_ready_callback( gpointer data, gint source, b_input_conditi
/* WTF doesn't libyahoo clean this up? */
return FALSE;
- yahoo_read_ready( d->id, d->fd, d->data );
+ yahoo_read_ready( d->id, NULL + d->fd, d->data );
return TRUE;
}
@@ -457,7 +481,7 @@ gboolean byahoo_write_ready_callback( gpointer data, gint source, b_input_condit
{
struct byahoo_write_ready_data *d = data;
- return yahoo_write_ready( d->id, d->fd, d->data );
+ return yahoo_write_ready( d->id, NULL + d->fd, d->data );
}
void ext_yahoo_login_response( int id, int succ, const char *url )
@@ -486,7 +510,7 @@ void ext_yahoo_login_response( int id, int succ, const char *url )
else
{
char *errstr;
- int allow_reconnect = TRUE;
+ int allow_reconnect = FALSE;
yd->logged_in = FALSE;
@@ -496,13 +520,15 @@ void ext_yahoo_login_response( int id, int succ, const char *url )
errstr = "Incorrect Yahoo! password";
else if( succ == YAHOO_LOGIN_LOCK )
errstr = "Yahoo! account locked";
+ else if( succ == 1236 )
+ errstr = "Yahoo! account locked or machine temporarily banned";
else if( succ == YAHOO_LOGIN_DUPL )
- {
errstr = "Logged in on a different machine or device";
- allow_reconnect = FALSE;
- }
else if( succ == YAHOO_LOGIN_SOCK )
+ {
errstr = "Socket problem";
+ allow_reconnect = TRUE;
+ }
else
errstr = "Unknown error";
@@ -605,9 +631,6 @@ void ext_yahoo_status_changed( int id, const char *who, int stat, const char *ms
state_string = "Offline";
flags = 0;
break;
- case YAHOO_STATUS_NOTIFY:
- state_string = "Notify";
- break;
}
imcb_buddy_status( ic, who, flags, state_string, msg );
@@ -616,6 +639,10 @@ void ext_yahoo_status_changed( int id, const char *who, int stat, const char *ms
imcb_buddy_times( ic, who, 0, idle );
}
+void ext_yahoo_got_buzz( int id, const char *me, const char *who, long tm )
+{
+}
+
void ext_yahoo_got_im( int id, const char *me, const char *who, const char *msg, long tm, int stat, int utf8 )
{
struct im_connection *ic = byahoo_get_ic_by_id( id );
@@ -629,15 +656,22 @@ void ext_yahoo_got_im( int id, const char *me, const char *who, const char *msg,
}
}
-void ext_yahoo_got_file( int id,
- const char *ignored,
- const char *who, const char *url, long expires, const char *msg, const char *fname, unsigned long fesize )
+void ext_yahoo_got_file( int id, const char *ignored, const char *who, const char *msg,
+ const char *fname, unsigned long fesize, char *trid )
{
struct im_connection *ic = byahoo_get_ic_by_id( id );
imcb_log( ic, "Got a file transfer (file = %s) from %s. Ignoring for now due to lack of support.", fname, who );
}
+void ext_yahoo_got_ft_data( int id, const unsigned char *in, int len, void *data )
+{
+}
+
+void ext_yahoo_file_transfer_done( int id, int result, void *data )
+{
+}
+
void ext_yahoo_typing_notify( int id, const char *ignored, const char *who, int stat )
{
struct im_connection *ic = byahoo_get_ic_by_id( id );
@@ -648,7 +682,7 @@ void ext_yahoo_typing_notify( int id, const char *ignored, const char *who, int
imcb_buddy_typing( ic, (char*) who, 0 );
}
-void ext_yahoo_system_message( int id, const char *msg )
+void ext_yahoo_system_message( int id, const char *me, const char *who, const char *msg )
{
struct im_connection *ic = byahoo_get_ic_by_id( id );
@@ -670,9 +704,10 @@ void ext_yahoo_error( int id, const char *err, int fatal, int num )
}
/* TODO: Clear up the mess of inp and d structures */
-int ext_yahoo_add_handler( int id, int fd, yahoo_input_condition cond, void *data )
+int ext_yahoo_add_handler( int id, void *fd_, yahoo_input_condition cond, void *data )
{
struct byahoo_input_data *inp = g_new0( struct byahoo_input_data, 1 );
+ int fd = (int) fd_;
if( cond == YAHOO_INPUT_READ )
{
@@ -699,12 +734,12 @@ int ext_yahoo_add_handler( int id, int fd, yahoo_input_condition cond, void *dat
else
{
g_free( inp );
- return( -1 );
+ return -1;
/* Panic... */
}
byahoo_inputs = g_slist_append( byahoo_inputs, inp );
- return( inp->h );
+ return inp->h;
}
void ext_yahoo_remove_handler( int id, int tag )
@@ -728,7 +763,7 @@ void ext_yahoo_remove_handler( int id, int tag )
b_event_remove( tag );
}
-int ext_yahoo_connect_async( int id, const char *host, int port, yahoo_connect_callback callback, void *data )
+int ext_yahoo_connect_async( int id, const char *host, int port, yahoo_connect_callback callback, void *data, int use_ssl )
{
struct byahoo_connect_callback_data *d;
int fd;
@@ -744,48 +779,41 @@ int ext_yahoo_connect_async( int id, const char *host, int port, yahoo_connect_c
d->data = data;
d->id = id;
- return( fd );
+ return fd;
}
-/* Because we don't want asynchronous connects in BitlBee, and because
- libyahoo doesn't seem to use this one anyway, this one is now defunct. */
-int ext_yahoo_connect(const char *host, int port)
+char *ext_yahoo_get_ip_addr( const char *domain )
+{
+ return NULL;
+}
+
+int ext_yahoo_write( void *fd, char *buf, int len )
{
-#if 0
- struct sockaddr_in serv_addr;
- static struct hostent *server;
- static char last_host[256];
- int servfd;
- char **p;
+ return write( (int) fd, buf, len );
+}
- if(last_host[0] || g_strcasecmp(last_host, host)!=0) {
- if(!(server = gethostbyname(host))) {
- return -1;
- }
- strncpy(last_host, host, 255);
- }
+int ext_yahoo_read( void *fd, char *buf, int len )
+{
+ return read( (int) fd, buf, len );
+}
- if((servfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
- return -1;
- }
+void ext_yahoo_close( void *fd )
+{
+ close( (int) fd );
+}
- for (p = server->h_addr_list; *p; p++)
- {
- memset(&serv_addr, 0, sizeof(serv_addr));
- serv_addr.sin_family = AF_INET;
- memcpy(&serv_addr.sin_addr.s_addr, *p, server->h_length);
- serv_addr.sin_port = htons(port);
-
- if(connect(servfd, (struct sockaddr *) &serv_addr,
- sizeof(serv_addr)) == -1) {
- return -1;
- } else {
- return servfd;
- }
- }
+void ext_yahoo_got_buddy_change_group( int id, const char *me, const char *who,
+ const char *old_group, const char *new_group )
+{
+ struct im_connection *ic = byahoo_get_ic_by_id( id );
+
+ imcb_add_buddy( ic, who, new_group );
+}
- closesocket(servfd);
-#endif
+/* Because we don't want asynchronous connects in BitlBee, and because
+ libyahoo doesn't seem to use this one anyway, this one is now defunct. */
+int ext_yahoo_connect(const char *host, int port)
+{
return -1;
}
@@ -897,7 +925,7 @@ void ext_yahoo_chat_cat_xml( int id, const char *xml )
{
}
-void ext_yahoo_chat_join( int id, const char *who, const char *room, const char *topic, YList *members, int fd )
+void ext_yahoo_chat_join( int id, const char *who, const char *room, const char *topic, YList *members, void *fd )
{
}
@@ -925,25 +953,18 @@ void ext_yahoo_chat_yahooerror( int id, const char *me )
{
}
-void ext_yahoo_contact_auth_request( int id, const char *myid, const char *who, const char *msg )
-{
- struct im_connection *ic = byahoo_get_ic_by_id( id );
-
- imcb_ask_auth( ic, who, NULL );
-}
-
void ext_yahoo_contact_added( int id, const char *myid, const char *who, const char *msg )
{
struct im_connection *ic = byahoo_get_ic_by_id( id );
- imcb_add_buddy( ic, (char*) who, NULL );
+ imcb_ask_auth( ic, who, msg );
}
void ext_yahoo_rejected( int id, const char *who, const char *msg )
{
}
-void ext_yahoo_game_notify( int id, const char *me, const char *who, int stat )
+void ext_yahoo_game_notify( int id, const char *me, const char *who, int stat, const char *msg )
{
}
@@ -988,7 +1009,7 @@ void ext_yahoo_got_webcam_image( int id, const char * who, const unsigned char *
{
}
-void ext_yahoo_got_ping( int id, const char *msg)
+void ext_yahoo_got_ping( int id, const char *msg )
{
}
diff --git a/protocols/yahoo/yahoo2.h b/protocols/yahoo/yahoo2.h
index 2184a321..589aaa5a 100644
--- a/protocols/yahoo/yahoo2.h
+++ b/protocols/yahoo/yahoo2.h
@@ -50,19 +50,18 @@ extern "C" {
#include "yahoo2_types.h"
-/* returns the socket descriptor for a given pager connection. shouldn't be needed */
-int yahoo_get_fd(int id);
+/* returns the socket descriptor object for a given pager connection. shouldn't be needed */
+ void *yahoo_get_fd(int id);
/* says how much logging to do */
/* see yahoo2_types.h for the different values */
-int yahoo_set_log_level(enum yahoo_log_level level);
-enum yahoo_log_level yahoo_get_log_level( void );
+ int yahoo_set_log_level(enum yahoo_log_level level);
+ enum yahoo_log_level yahoo_get_log_level(void);
/* these functions should be self explanatory */
/* who always means the buddy you're acting on */
/* id is the successful value returned by yahoo_init */
-
/* init returns a connection id used to identify the connection hereon */
/* or 0 on failure */
/* you must call init before calling any other function */
@@ -87,101 +86,129 @@ enum yahoo_log_level yahoo_get_log_level( void );
*
* You should set at least local_host if you intend to use webcams
*/
-int yahoo_init_with_attributes(const char *username, const char *password, ...);
+ int yahoo_init_with_attributes(const char *username,
+ const char *password, ...);
/* yahoo_init does the same as yahoo_init_with_attributes, assuming defaults
* for all attributes */
-int yahoo_init(const char *username, const char *password);
-
-
+ int yahoo_init(const char *username, const char *password);
/* release all resources held by this session */
/* you need to call yahoo_close for a session only if
* yahoo_logoff is never called for it (ie, it was never logged in) */
-void yahoo_close(int id);
+ void yahoo_close(int id);
/* login logs in to the server */
/* initial is of type enum yahoo_status. see yahoo2_types.h */
-void yahoo_login(int id, int initial);
-void yahoo_logoff(int id);
+ void yahoo_login(int id, int initial);
+ void yahoo_logoff(int id);
/* reloads status of all buddies */
-void yahoo_refresh(int id);
+ void yahoo_refresh(int id);
/* activates/deactivates an identity */
-void yahoo_set_identity_status(int id, const char * identity, int active);
+ 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);
+ void yahoo_get_list(int id);
/* download buddy contact information from your yahoo addressbook */
-void yahoo_get_yab(int id);
+ void yahoo_get_yab(int id);
/* add/modify an address book entry. if yab->dbid is set, it will */
/* modify that entry else it creates a new entry */
-void yahoo_set_yab(int id, struct yab * yab);
-void yahoo_keepalive(int id);
-void yahoo_chat_keepalive(int id);
+ void yahoo_set_yab(int id, struct yab *yab);
+ void yahoo_keepalive(int id);
+ void yahoo_chat_keepalive(int id);
/* from is the identity you're sending from. if NULL, the default is used */
/* 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, int picture);
+ void yahoo_send_im(int id, const char *from, const char *who,
+ const char *msg, int utf8, int picture);
+ void yahoo_send_buzz(int id, const char *from, const char *who);
/* 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);
+ void yahoo_send_typing(int id, const char *from, const char *who,
+ int typ);
/* used to set away/back status. */
/* away says whether the custom message is an away message or a sig */
-void yahoo_set_away(int id, enum yahoo_status state, const char *msg, int away);
-
-void yahoo_add_buddy(int id, const char *who, const char *group, const char *msg);
-void yahoo_remove_buddy(int id, const char *who, const char *group);
-void yahoo_reject_buddy(int id, const char *who, const char *msg);
-void yahoo_stealth_buddy(int id, const char *who, int unstealth);
+ void yahoo_set_away(int id, enum yahoo_status state, const char *msg,
+ int away);
+
+ void yahoo_add_buddy(int id, const char *who, const char *group,
+ const char *msg);
+ void yahoo_remove_buddy(int id, const char *who, const char *group);
+ void yahoo_confirm_buddy(int id, const char *who, int reject,
+ const char *msg);
+ void yahoo_stealth_buddy(int id, const char *who, int unstealth);
/* if unignore is true, unignore, else ignore */
-void yahoo_ignore_buddy(int id, const char *who, int unignore);
-void yahoo_change_buddy_group(int id, const char *who, const char *old_group, const char *new_group);
-void yahoo_group_rename(int id, const char *old_group, const char *new_group);
-
-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, 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);
+ void yahoo_ignore_buddy(int id, const char *who, int unignore);
+ void yahoo_change_buddy_group(int id, const char *who,
+ const char *old_group, const char *new_group);
+ void yahoo_group_rename(int id, const char *old_group,
+ const char *new_group);
+
+ 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, 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);
/* Get a list of chatrooms */
-void yahoo_get_chatrooms(int id,int chatroomid);
+ void yahoo_get_chatrooms(int id, int chatroomid);
/* join room with specified roomname and roomid */
-void yahoo_chat_logon(int id, const char *from, const char *room, const char *roomid);
+ void yahoo_chat_logon(int id, const char *from, const char *room,
+ const char *roomid);
/* Send message "msg" to room with specified roomname, msgtype is 1-normal message or 2-/me mesage */
-void yahoo_chat_message(int id, const char *from, const char *room, const char *msg, const int msgtype, const int utf8);
+ void yahoo_chat_message(int id, const char *from, const char *room,
+ const char *msg, const int msgtype, const int utf8);
/* Log off chat */
-void yahoo_chat_logoff(int id, const char *from);
+ void yahoo_chat_logoff(int id, const char *from);
/* requests a webcam feed */
/* who is the person who's webcam you would like to view */
/* if who is null, then you're the broadcaster */
-void yahoo_webcam_get_feed(int id, const char *who);
-void yahoo_webcam_close_feed(int id, const char *who);
+ void yahoo_webcam_get_feed(int id, const char *who);
+ void yahoo_webcam_close_feed(int id, const char *who);
/* sends an image when uploading */
/* image points to a JPEG-2000 image, length is the length of the image */
/* in bytes. The timestamp is the time in milliseconds since we started the */
/* webcam. */
-void yahoo_webcam_send_image(int id, unsigned char *image, unsigned int length, unsigned int timestamp);
+ void yahoo_webcam_send_image(int id, unsigned char *image,
+ unsigned int length, unsigned int timestamp);
/* this function should be called if we want to allow a user to watch the */
/* webcam. Who is the user we want to accept. */
/* Accept user (accept = 1), decline user (accept = 0) */
-void yahoo_webcam_accept_viewer(int id, const char* who, int accept);
+ void yahoo_webcam_accept_viewer(int id, const char *who, int accept);
/* send an invitation to a user to view your webcam */
-void yahoo_webcam_invite(int id, const char *who);
+ void yahoo_webcam_invite(int id, const char *who);
/* will set up a connection and initiate file transfer.
* callback will be called with the fd that you should write
* the file data to
*/
-void yahoo_send_file(int id, const char *who, const char *msg, const char *name, unsigned long size,
+ void yahoo_send_file(int id, const char *who, const char *msg,
+ const char *name, unsigned long size,
yahoo_get_fd_callback callback, void *data);
+/*
+ * Respond to a file transfer request. Be sure to provide the callback data
+ * since that is your only chance to recognize future callbacks
+ */
+ void yahoo_send_file_transfer_response(int client_id, int response,
+ char *id, void *data);
+
+
/* send a search request
*/
-void yahoo_search(int id, enum yahoo_search_type t, const char *text, enum yahoo_search_gender g, enum yahoo_search_agerange ar,
+ void yahoo_search(int id, enum yahoo_search_type t, const char *text,
+ enum yahoo_search_gender g, enum yahoo_search_agerange ar,
int photo, int yahoo_only);
/* continue last search
@@ -189,40 +216,32 @@ void yahoo_search(int id, enum yahoo_search_type t, const char *text, enum yahoo
*
* where the above three are passed to ext_yahoo_got_search_result
*/
-void yahoo_search_again(int id, int start);
-
-/* returns a socket fd to a url for downloading a file. */
-void yahoo_get_url_handle(int id, const char *url,
- yahoo_get_url_handle_callback callback, void *data);
+ void yahoo_search_again(int id, int start);
/* these should be called when input is available on a fd */
/* registered by ext_yahoo_add_handler */
/* if these return negative values, errno may be set */
-int yahoo_read_ready(int id, int fd, void *data);
-int yahoo_write_ready(int id, int fd, void *data);
+ int yahoo_read_ready(int id, void *fd, void *data);
+ int yahoo_write_ready(int id, void *fd, void *data);
/* utility functions. these do not hit the server */
-enum yahoo_status yahoo_current_status(int id);
-const YList * yahoo_get_buddylist(int id);
-const YList * yahoo_get_ignorelist(int id);
-const YList * yahoo_get_identities(int id);
+ enum yahoo_status yahoo_current_status(int id);
+ const YList *yahoo_get_buddylist(int id);
+ const YList *yahoo_get_ignorelist(int id);
+ const YList *yahoo_get_identities(int id);
/* 'which' could be y, t, c or login. This may change in later versions. */
-const char * yahoo_get_cookie(int id, const char *which);
+ const char *yahoo_get_cookie(int id, const char *which);
/* returns the url used to get user profiles - you must append the user id */
/* as of now this is http://profiles.yahoo.com/ */
/* You'll have to do urlencoding yourself, but see yahoo_httplib.h first */
-const char * yahoo_get_profile_url( void );
-
-void yahoo_buddyicon_request(int id, const char *who);
+ const char *yahoo_get_profile_url(void);
-void yahoo_accept_buddy_ymsg13(int,const char*,const char*);
-void yahoo_reject_buddy_ymsg13(int,const char*,const char*,const char*);
+ void yahoo_buddyicon_request(int id, const char *who);
#include "yahoo_httplib.h"
#ifdef __cplusplus
}
#endif
-
#endif
diff --git a/protocols/yahoo/yahoo2_callbacks.h b/protocols/yahoo/yahoo2_callbacks.h
index e2c8ea42..0dccf188 100644
--- a/protocols/yahoo/yahoo2_callbacks.h
+++ b/protocols/yahoo/yahoo2_callbacks.h
@@ -29,7 +29,6 @@
* declared in this file and defined in libyahoo2.c
*/
-
#ifndef YAHOO2_CALLBACKS_H
#define YAHOO2_CALLBACKS_H
@@ -45,25 +44,26 @@ extern "C" {
* Callback interface for libyahoo2
*/
-typedef enum {
- YAHOO_INPUT_READ = 1 << 0,
- YAHOO_INPUT_WRITE = 1 << 1,
- YAHOO_INPUT_EXCEPTION = 1 << 2
-} yahoo_input_condition;
+ typedef enum {
+ YAHOO_INPUT_READ = 1 << 0,
+ YAHOO_INPUT_WRITE = 1 << 1,
+ YAHOO_INPUT_EXCEPTION = 1 << 2
+ } yahoo_input_condition;
/*
* A callback function called when an asynchronous connect completes.
*
* Params:
- * fd - The file descriptor that has been connected, or -1 on error
+ * fd - The file descriptor object that has been connected, or NULL on
+ * error
* error - The value of errno set by the call to connect or 0 if no error
* Set both fd and error to 0 if the connect was cancelled by the
* user
* callback_data - the callback_data passed to the ext_yahoo_connect_async
* function
*/
-typedef void (*yahoo_connect_callback)(int fd, int error, void *callback_data);
-
+ typedef void (*yahoo_connect_callback) (void *fd, int error,
+ void *callback_data);
/*
* The following functions need to be implemented in the client
@@ -93,8 +93,8 @@ struct yahoo_callbacks {
* succ - enum yahoo_login_status
* url - url to reactivate account if locked
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_login_response)(int id, int succ, const char *url);
-
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_login_response) (int id, int succ,
+ const char *url);
/*
* Name: ext_yahoo_got_buddies
@@ -103,8 +103,7 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_login_response)(int id, int succ, const char
* id - the id that identifies the server connection
* buds - the buddy list
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddies)(int id, YList * buds);
-
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddies) (int id, YList *buds);
/*
* Name: ext_yahoo_got_ignore
@@ -113,8 +112,7 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddies)(int id, YList * buds);
* id - the id that identifies the server connection
* igns - the ignore list
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_got_ignore)(int id, YList * igns);
-
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_ignore) (int id, YList *igns);
/*
* Name: ext_yahoo_got_identities
@@ -123,8 +121,7 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_ignore)(int id, YList * igns);
* id - the id that identifies the server connection
* ids - the identity list
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_got_identities)(int id, YList * ids);
-
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_identities) (int id, YList *ids);
/*
* Name: ext_yahoo_got_cookies
@@ -132,8 +129,7 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_identities)(int id, YList * ids);
* Params:
* id - the id that identifies the server connection
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_got_cookies)(int id);
-
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_cookies) (int id);
/*
* Name: ext_yahoo_got_ping
@@ -142,8 +138,8 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_cookies)(int id);
* id - the id that identifies the server connection
* errormsg - optional error message
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_got_ping)(int id, const char *errormsg);
-
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_ping) (int id,
+ const char *errormsg);
/*
* Name: ext_yahoo_status_changed
@@ -158,8 +154,21 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_ping)(int id, const char *errormsg);
* mobile - this is set for mobile users/buddies
* TODO: add support for pager, chat, and game states
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_status_changed)(int id, const char *who, int stat, const char *msg, int away, int idle, int mobile);
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_status_changed) (int id,
+ const char *who, int stat, const char *msg, int away, int idle,
+ int mobile);
+/*
+ * Name: ext_yahoo_got_buzz
+ * Called when remote user sends you a buzz.
+ * Params:
+ * id - the id that identifies the server connection
+ * me - the identity the message was sent to
+ * who - the handle of the remote user
+ * tm - timestamp of message if offline
+ */
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buzz) (int id, const char *me,
+ const char *who, long tm);
/*
* Name: ext_yahoo_got_im
@@ -176,8 +185,8 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_status_changed)(int id, const char *who, int
* 5
* utf8 - whether the message is encoded as utf8 or not
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_got_im)(int id, const char *me, const char *who, const char *msg, long tm, int stat, int utf8);
-
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_im) (int id, const char *me,
+ const char *who, const char *msg, long tm, int stat, int utf8);
/*
* Name: ext_yahoo_got_conf_invite
@@ -190,8 +199,9 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_im)(int id, const char *me, const char *w
* msg - the message
* members - the initial members of the conference (null terminated list)
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_got_conf_invite)(int id, const char *me, const char *who, const char *room, const char *msg, YList *members);
-
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_conf_invite) (int id,
+ const char *me, const char *who, const char *room,
+ const char *msg, YList *members);
/*
* Name: ext_yahoo_conf_userdecline
@@ -203,8 +213,9 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_conf_invite)(int id, const char *me, cons
* room - the room
* msg - the declining message
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userdecline)(int id, const char *me, const char *who, const char *room, const char *msg);
-
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userdecline) (int id,
+ const char *me, const char *who, const char *room,
+ const char *msg);
/*
* Name: ext_yahoo_conf_userjoin
@@ -215,8 +226,8 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userdecline)(int id, const char *me, con
* who - the user who has joined
* room - the room joined
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userjoin)(int id, const char *me, const char *who, const char *room);
-
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userjoin) (int id,
+ const char *me, const char *who, const char *room);
/*
* Name: ext_yahoo_conf_userleave
@@ -227,8 +238,8 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userjoin)(int id, const char *me, const
* who - the user who has left
* room - the room left
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userleave)(int id, const char *me, const char *who, const char *room);
-
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userleave) (int id,
+ const char *me, const char *who, const char *room);
/*
* Name: ext_yahoo_chat_cat_xml
@@ -237,8 +248,8 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userleave)(int id, const char *me, const
* id - the id that identifies the server connection
* xml - ?
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_cat_xml)(int id, const char *xml);
-
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_cat_xml) (int id,
+ const char *xml);
/*
* Name: ext_yahoo_chat_join
@@ -251,10 +262,10 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_cat_xml)(int id, const char *xml);
* topic - the topic of the room, freed by library after call
* members - the initial members of the chatroom (null terminated YList
* of yahoo_chat_member's) Must be freed by the client
- * fd - the socket where the connection is coming from (for tracking)
+ * fd - the object where the connection is coming from (for tracking)
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_join)(int id, const char *me, const char *room, const char *topic, YList *members, int fd);
-
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_join) (int id, const char *me,
+ const char *room, const char *topic, YList *members, void *fd);
/*
* Name: ext_yahoo_chat_userjoin
@@ -265,8 +276,9 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_join)(int id, const char *me, const char
* room - the room joined
* who - the user who has joined, Must be freed by the client
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userjoin)(int id, const char *me, const char *room, struct yahoo_chat_member *who);
-
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userjoin) (int id,
+ const char *me, const char *room,
+ struct yahoo_chat_member *who);
/*
* Name: ext_yahoo_chat_userleave
@@ -277,8 +289,8 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userjoin)(int id, const char *me, const
* room - the room left
* who - the user who has left (Just the User ID)
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userleave)(int id, const char *me, const char *room, const char *who);
-
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userleave) (int id,
+ const char *me, const char *room, const char *who);
/*
* Name: ext_yahoo_chat_message
@@ -293,8 +305,9 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userleave)(int id, const char *me, const
* 2 = /me type message
* utf8 - whether the message is utf8 encoded or not
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_message)(int id, const char *me, const char *who, const char *room, const char *msg, int msgtype, int utf8);
-
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_message) (int id,
+ const char *me, const char *who, const char *room,
+ const char *msg, int msgtype, int utf8);
/*
*
@@ -309,8 +322,8 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_message)(int id, const char *me, const c
* Returns:
* nothing.
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_yahoologout)(int id, const char *me);
-
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_yahoologout) (int id,
+ const char *me);
/*
*
@@ -326,8 +339,8 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_yahoologout)(int id, const char *me);
* Returns:
* nothing.
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_yahooerror)(int id, const char *me);
-
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_yahooerror) (int id,
+ const char *me);
/*
* Name: ext_yahoo_conf_message
@@ -340,8 +353,9 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_yahooerror)(int id, const char *me);
* msg - the message
* utf8 - whether the message is utf8 encoded or not
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_message)(int id, const char *me, const char *who, const char *room, const char *msg, int utf8);
-
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_message) (int id,
+ const char *me, const char *who, const char *room,
+ const char *msg, int utf8);
/*
* Name: ext_yahoo_got_file
@@ -350,26 +364,42 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_message)(int id, const char *me, const c
* id - the id that identifies the server connection
* me - the identity the file was sent to
* who - the user who sent the file
- * url - the file url
- * expires - the expiry date of the file on the server (timestamp)
* msg - the message
* fname- the file name if direct transfer
* fsize- the file size if direct transfer
+ * trid - transfer id. Unique for this transfer
+ *
+ * NOTE: Subsequent callbacks for file transfer do not send all of this
+ * information again since it is wasteful. Implementations are expected to
+ * save this information and supply it as callback data when the file or
+ * confirmation is sent
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_got_file)(int id, const char *me, const char *who, const char *url, long expires, const char *msg, const char *fname, unsigned long fesize);
-
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_file) (int id, const char *me,
+ const char *who, const char *msg, const char *fname,
+ unsigned long fesize, char *trid);
/*
- * Name: ext_yahoo_contact_auth_request
- * Called when a contact wants to add you to his/her contact list
+ * Name: ext_yahoo_got_ft_data
+ * Called multiple times when parts of the file are received
* Params:
* id - the id that identifies the server connection
- * myid - the identity s/he added
- * who - who did it
- * msg - any message sent
+ * in - The data
+ * len - Length of the data
+ * data - callback data
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_contact_auth_request)(int id, const char *myid, const char *who, const char *msg);
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_ft_data) (int id,
+ const unsigned char *in, int len, void *data);
+/*
+ * Name: ext_yahoo_file_transfer_done
+ * File transfer is done
+ * Params:
+ * id - the id that identifies the server connection
+ * result - To notify if it finished successfully or with a failure
+ * data - callback data
+ */
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_file_transfer_done) (int id,
+ int result, void *data);
/*
* Name: ext_yahoo_contact_added
@@ -380,8 +410,8 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_contact_auth_request)(int id, const char *myi
* who - who was added
* msg - any message sent
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_contact_added)(int id, const char *myid, const char *who, const char *msg);
-
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_contact_added) (int id,
+ const char *myid, const char *who, const char *msg);
/*
* Name: ext_yahoo_rejected
@@ -391,8 +421,8 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_contact_added)(int id, const char *myid, cons
* who - who rejected you
* msg - any message sent
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_rejected)(int id, const char *who, const char *msg);
-
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_rejected) (int id, const char *who,
+ const char *msg);
/*
* Name: ext_yahoo_typing_notify
@@ -403,8 +433,8 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_rejected)(int id, const char *who, const char
* who - the handle of the remote user
* stat - 1 if typing, 0 if stopped typing
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_typing_notify)(int id, const char *me, const char *who, int stat);
-
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_typing_notify) (int id,
+ const char *me, const char *who, int stat);
/*
* Name: ext_yahoo_game_notify
@@ -414,9 +444,10 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_typing_notify)(int id, const char *me, const
* me - the handle of the identity the notification is sent to
* who - the handle of the remote user
* stat - 1 if game, 0 if stopped gaming
+ * msg - game description and/or other text
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_game_notify)(int id, const char *me, const char *who, int stat);
-
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_game_notify) (int id, const char *me,
+ const char *who, int stat, const char *msg);
/*
* Name: ext_yahoo_mail_notify
@@ -427,17 +458,20 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_game_notify)(int id, const char *me, const ch
* subj - the subject of the mail - NULL if only mail count
* cnt - mail count - 0 if new mail notification
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_mail_notify)(int id, const char *from, const char *subj, int cnt);
-
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_mail_notify) (int id,
+ const char *from, const char *subj, int cnt);
/*
* Name: ext_yahoo_system_message
* System message
* Params:
* id - the id that identifies the server connection
+ * me - the handle of the identity the notification is sent to
+ * who - the source of the system message (there are different types)
* msg - the message
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_system_message)(int id, const char *msg);
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_system_message) (int id,
+ const char *me, const char *who, const char *msg);
/*
* Name: ext_yahoo_got_buddyicon
@@ -449,7 +483,8 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_system_message)(int id, const char *msg);
* url - the url to use to load the icon
* checksum - the checksum of the icon content
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon)(int id, const char *me, const char *who, const char *url, int checksum);
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon) (int id,
+ const char *me, const char *who, const char *url, int checksum);
/*
* Name: ext_yahoo_got_buddyicon_checksum
@@ -460,7 +495,8 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon)(int id, const char *me, const
* who - the yahoo id of the buddy icon checksum is for
* checksum - the checksum of the icon content
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon_checksum)(int id, const char *me,const char *who, int checksum);
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon_checksum) (int id,
+ const char *me, const char *who, int checksum);
/*
* Name: ext_yahoo_got_buddyicon_request
@@ -470,7 +506,8 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon_checksum)(int id, const char *m
* me - the handle of the identity the notification is sent to
* who - the yahoo id of the buddy that requested the buddy icon
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon_request)(int id, const char *me, const char *who);
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon_request) (int id,
+ const char *me, const char *who);
/*
* Name: ext_yahoo_got_buddyicon_request
@@ -479,7 +516,8 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon_request)(int id, const char *me
* id - the id that identifies the server connection
* url - remote url, the uploaded buddy icon can be fetched from
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_buddyicon_uploaded)(int id, const char *url);
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_buddyicon_uploaded) (int id,
+ const char *url);
/*
* Name: ext_yahoo_got_webcam_image
@@ -504,11 +542,11 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_buddyicon_uploaded)(int id, const char *url);
* to transport then others. When image_size is 0 we can still receive
* a timestamp to stay in sync
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_got_webcam_image)(int id, const char * who,
- const unsigned char *image, unsigned int image_size, unsigned int real_size,
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_webcam_image) (int id,
+ const char *who, const unsigned char *image,
+ unsigned int image_size, unsigned int real_size,
unsigned int timestamp);
-
/*
* Name: ext_yahoo_webcam_invite
* Called when you get a webcam invitation
@@ -517,8 +555,8 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_webcam_image)(int id, const char * who,
* me - identity the invitation is to
* from - who the invitation is from
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite)(int id, const char *me, const char *from);
-
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite) (int id,
+ const char *me, const char *from);
/*
* Name: ext_yahoo_webcam_invite_reply
@@ -529,8 +567,8 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite)(int id, const char *me, const
* from - who the invitation response is from
* accept - 0 (decline), 1 (accept)
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite_reply)(int id, const char *me, const char *from, int accept);
-
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite_reply) (int id,
+ const char *me, const char *from, int accept);
/*
* Name: ext_yahoo_webcam_closed
@@ -544,8 +582,8 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite_reply)(int id, const char *me,
* 3 = user declines permission
* 4 = user does not have webcam online
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_closed)(int id, const char *who, int reason);
-
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_closed) (int id,
+ const char *who, int reason);
/*
* Name: ext_yahoo_got_search_result
@@ -559,8 +597,8 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_closed)(int id, const char *who, int r
* these will be freed after this function returns, so
* if you need to use the information, make a copy
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_got_search_result)(int id, int found, int start, int total, YList *contacts);
-
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_search_result) (int id,
+ int found, int start, int total, YList *contacts);
/*
* Name: ext_yahoo_error
@@ -571,8 +609,8 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_search_result)(int id, int found, int sta
* fatal- whether this error is fatal to the connection or not
* num - Which error is this
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_error)(int id, const char *err, int fatal, int num);
-
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_error) (int id, const char *err,
+ int fatal, int num);
/*
* Name: ext_yahoo_webcam_viewer
@@ -582,8 +620,8 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_error)(int id, const char *err, int fatal, in
* who - the viewer
* connect - 0=disconnect 1=connect 2=request
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_viewer)(int id, const char *who, int connect);
-
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_viewer) (int id,
+ const char *who, int connect);
/*
* Name: ext_yahoo_webcam_data_request
@@ -592,8 +630,8 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_viewer)(int id, const char *who, int c
* id - the id that identifies the server connection
* send - whether to send images or not
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_data_request)(int id, int send);
-
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_data_request) (int id,
+ int send);
/*
* Name: ext_yahoo_log
@@ -603,8 +641,7 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_data_request)(int id, int send);
* Returns:
* 0
*/
-int YAHOO_CALLBACK_TYPE(ext_yahoo_log)(const char *fmt, ...);
-
+ int YAHOO_CALLBACK_TYPE(ext_yahoo_log) (const char *fmt, ...);
/*
* Name: ext_yahoo_add_handler
@@ -613,14 +650,14 @@ int YAHOO_CALLBACK_TYPE(ext_yahoo_log)(const char *fmt, ...);
* when a YAHOO_INPUT_WRITE fd is ready.
* Params:
* id - the id that identifies the server connection
- * fd - the fd on which to listen
+ * fd - the fd object on which to listen
* cond - the condition on which to call the callback
* data - callback data to pass to yahoo_*_ready
*
* Returns: a tag to be used when removing the handler
*/
-int YAHOO_CALLBACK_TYPE(ext_yahoo_add_handler)(int id, int fd, yahoo_input_condition cond, void *data);
-
+ int YAHOO_CALLBACK_TYPE(ext_yahoo_add_handler) (int id, void *fd,
+ yahoo_input_condition cond, void *data);
/*
* Name: ext_yahoo_remove_handler
@@ -629,8 +666,7 @@ int YAHOO_CALLBACK_TYPE(ext_yahoo_add_handler)(int id, int fd, yahoo_input_condi
* id - the id that identifies the connection
* tag - the handler tag to remove
*/
-void YAHOO_CALLBACK_TYPE(ext_yahoo_remove_handler)(int id, int tag);
-
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_remove_handler) (int id, int tag);
/*
* Name: ext_yahoo_connect
@@ -641,12 +677,11 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_remove_handler)(int id, int tag);
* Returns:
* a unix file descriptor to the socket
*/
-int YAHOO_CALLBACK_TYPE(ext_yahoo_connect)(const char *host, int port);
-
+ int YAHOO_CALLBACK_TYPE(ext_yahoo_connect) (const char *host, int port);
/*
* Name: ext_yahoo_connect_async
- * Connect to a host:port asynchronously. This function should return
+ * Connect to a host:port asynchronously. This function should return
* immediately returing a tag used to identify the connection handler,
* or a pre-connect error (eg: host name lookup failure).
* Once the connect completes (successfully or unsuccessfully), callback
@@ -659,11 +694,74 @@ int YAHOO_CALLBACK_TYPE(ext_yahoo_connect)(const char *host, int port);
* port - the port to connect on
* callback - function to call when connect completes
* callback_data - data to pass to the callback function
+ * use_ssl - Whether we need an SSL connection
* Returns:
- * a unix file descriptor to the socket
+ * a tag signifying the connection attempt
+ */
+ int YAHOO_CALLBACK_TYPE(ext_yahoo_connect_async) (int id,
+ const char *host, int port, yahoo_connect_callback callback,
+ void *callback_data, int use_ssl);
+
+/*
+ * Name: ext_yahoo_get_ip_addr
+ * get IP Address for a domain name
+ * Params:
+ * domain - Domain name
+ * Returns:
+ * Newly allocated string containing the IP Address in IPv4 notation
*/
-int YAHOO_CALLBACK_TYPE(ext_yahoo_connect_async)(int id, const char *host, int port,
- yahoo_connect_callback callback, void *callback_data);
+ char *YAHOO_CALLBACK_TYPE(ext_yahoo_get_ip_addr) (const char *domain);
+
+/*
+ * Name: ext_yahoo_write
+ * Write data from the buffer into the socket for the specified connection
+ * Params:
+ * fd - the file descriptor object that identifies this connection
+ * buf - Buffer to write the data from
+ * len - Length of the data
+ * Returns:
+ * Number of bytes written or -1 for error
+ */
+ int YAHOO_CALLBACK_TYPE(ext_yahoo_write) (void *fd, char *buf, int len);
+
+/*
+ * Name: ext_yahoo_read
+ * Read data into a buffer from socket for the specified connection
+ * Params:
+ * fd - the file descriptor object that identifies this connection
+ * buf - Buffer to read the data into
+ * len - Max length to read
+ * Returns:
+ * Number of bytes read or -1 for error
+ */
+ int YAHOO_CALLBACK_TYPE(ext_yahoo_read) (void *fd, char *buf, int len);
+
+/*
+ * Name: ext_yahoo_close
+ * Close the file descriptor object and free its resources. Libyahoo2 will not
+ * use this object again.
+ * Params:
+ * fd - the file descriptor object that identifies this connection
+ * Returns:
+ * Nothing
+ */
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_close) (void *fd);
+
+/*
+ * Name: ext_yahoo_got_buddy_change_group
+ * Acknowledgement of buddy changing group
+ * Params:
+ * id: client id
+ * me: The user
+ * who: Buddy name
+ * old_group: Old group name
+ * new_group: New group name
+ * Returns:
+ * Nothing
+ */
+ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddy_change_group) (int id,
+ const char *me, const char *who, const char *old_group,
+ const char *new_group);
#ifdef USE_STRUCT_CALLBACKS
};
@@ -672,7 +770,7 @@ int YAHOO_CALLBACK_TYPE(ext_yahoo_connect_async)(int id, const char *host, int p
* if using a callback structure, call yahoo_register_callbacks
* before doing anything else
*/
-void yahoo_register_callbacks(struct yahoo_callbacks * tyc);
+void yahoo_register_callbacks(struct yahoo_callbacks *tyc);
#undef YAHOO_CALLBACK_TYPE
@@ -683,4 +781,3 @@ void yahoo_register_callbacks(struct yahoo_callbacks * tyc);
#endif
#endif
-
diff --git a/protocols/yahoo/yahoo2_types.h b/protocols/yahoo/yahoo2_types.h
index f05acb3c..bbade5d8 100644
--- a/protocols/yahoo/yahoo2_types.h
+++ b/protocols/yahoo/yahoo2_types.h
@@ -28,74 +28,175 @@
extern "C" {
#endif
-enum yahoo_status {
- YAHOO_STATUS_DISCONNECTED = -1,
- YAHOO_STATUS_AVAILABLE = 0,
- YAHOO_STATUS_BRB,
- YAHOO_STATUS_BUSY,
- YAHOO_STATUS_NOTATHOME,
- YAHOO_STATUS_NOTATDESK,
- YAHOO_STATUS_NOTINOFFICE,
- YAHOO_STATUS_ONPHONE,
- YAHOO_STATUS_ONVACATION,
- YAHOO_STATUS_OUTTOLUNCH,
- YAHOO_STATUS_STEPPEDOUT,
- YAHOO_STATUS_INVISIBLE = 12,
- YAHOO_STATUS_CUSTOM = 99,
- YAHOO_STATUS_IDLE = 999,
- YAHOO_STATUS_WEBLOGIN = 0x5a55aa55,
- YAHOO_STATUS_OFFLINE = 0x5a55aa56, /* don't ask */
- YAHOO_STATUS_NOTIFY = 0x16 /* TYPING */
-};
-#define YAHOO_STATUS_GAME 0x2 /* Games don't fit into the regular status model */
-
-enum yahoo_login_status {
- YAHOO_LOGIN_OK = 0,
- YAHOO_LOGIN_LOGOFF = 2,
- YAHOO_LOGIN_UNAME = 3,
- YAHOO_LOGIN_PASSWD = 13,
- YAHOO_LOGIN_LOCK = 14,
- YAHOO_LOGIN_DUPL = 99,
- YAHOO_LOGIN_SOCK = -1,
-};
-
-enum ypacket_status {
- YPACKET_STATUS_DISCONNECTED = -1,
- YPACKET_STATUS_DEFAULT = 0,
- YPACKET_STATUS_SERVERACK = 1,
- YPACKET_STATUS_GAME = 0x2,
- YPACKET_STATUS_AWAY = 0x4,
- YPACKET_STATUS_CONTINUED = 0x5,
- YPACKET_STATUS_INVISIBLE = 12,
- YPACKET_STATUS_NOTIFY = 0x16, /* TYPING */
- YPACKET_STATUS_WEBLOGIN = 0x5a55aa55,
- YPACKET_STATUS_OFFLINE = 0x5a55aa56
-};
-
-enum yahoo_error {
- E_UNKNOWN = -1,
- E_CONNECTION = -2,
- E_SYSTEM = -3,
- E_CUSTOM = 0,
-
- /* responses from ignore buddy */
- E_IGNOREDUP = 2,
- E_IGNORENONE = 3,
- E_IGNORECONF = 12,
-
- /* conference */
- E_CONFNOTAVAIL = 20
-};
-
-enum yahoo_log_level {
- YAHOO_LOG_NONE = 0,
- YAHOO_LOG_FATAL,
- YAHOO_LOG_ERR,
- YAHOO_LOG_WARNING,
- YAHOO_LOG_NOTICE,
- YAHOO_LOG_INFO,
- YAHOO_LOG_DEBUG
-};
+ enum yahoo_service { /* these are easier to see in hex */
+ YAHOO_SERVICE_LOGON = 1,
+ YAHOO_SERVICE_LOGOFF,
+ YAHOO_SERVICE_ISAWAY,
+ YAHOO_SERVICE_ISBACK,
+ YAHOO_SERVICE_IDLE, /* 5 (placemarker) */
+ YAHOO_SERVICE_MESSAGE,
+ YAHOO_SERVICE_IDACT,
+ YAHOO_SERVICE_IDDEACT,
+ YAHOO_SERVICE_MAILSTAT,
+ YAHOO_SERVICE_USERSTAT, /* 0xa */
+ YAHOO_SERVICE_NEWMAIL,
+ YAHOO_SERVICE_CHATINVITE,
+ YAHOO_SERVICE_CALENDAR,
+ YAHOO_SERVICE_NEWPERSONALMAIL,
+ YAHOO_SERVICE_NEWCONTACT,
+ YAHOO_SERVICE_ADDIDENT, /* 0x10 */
+ YAHOO_SERVICE_ADDIGNORE,
+ YAHOO_SERVICE_PING,
+ YAHOO_SERVICE_GOTGROUPRENAME, /* < 1, 36(old), 37(new) */
+ YAHOO_SERVICE_SYSMESSAGE = 0x14,
+ YAHOO_SERVICE_SKINNAME = 0x15,
+ YAHOO_SERVICE_PASSTHROUGH2 = 0x16,
+ YAHOO_SERVICE_CONFINVITE = 0x18,
+ YAHOO_SERVICE_CONFLOGON,
+ YAHOO_SERVICE_CONFDECLINE,
+ YAHOO_SERVICE_CONFLOGOFF,
+ YAHOO_SERVICE_CONFADDINVITE,
+ YAHOO_SERVICE_CONFMSG,
+ YAHOO_SERVICE_CHATLOGON,
+ YAHOO_SERVICE_CHATLOGOFF,
+ YAHOO_SERVICE_CHATMSG = 0x20,
+ YAHOO_SERVICE_GAMELOGON = 0x28,
+ YAHOO_SERVICE_GAMELOGOFF,
+ YAHOO_SERVICE_GAMEMSG = 0x2a,
+ YAHOO_SERVICE_FILETRANSFER = 0x46,
+ YAHOO_SERVICE_VOICECHAT = 0x4A,
+ YAHOO_SERVICE_NOTIFY,
+ YAHOO_SERVICE_VERIFY,
+ YAHOO_SERVICE_P2PFILEXFER,
+ YAHOO_SERVICE_PEERTOPEER = 0x4F, /* Checks if P2P possible */
+ YAHOO_SERVICE_WEBCAM,
+ YAHOO_SERVICE_AUTHRESP = 0x54,
+ YAHOO_SERVICE_LIST,
+ YAHOO_SERVICE_AUTH = 0x57,
+ YAHOO_SERVICE_AUTHBUDDY = 0x6d,
+ YAHOO_SERVICE_ADDBUDDY = 0x83,
+ YAHOO_SERVICE_REMBUDDY,
+ 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_Y7_PING = 0x8A,
+ YAHOO_SERVICE_CHATONLINE = 0x96, /* > 109(id), 1, 6(abcde) < 0,1 */
+ YAHOO_SERVICE_CHATGOTO,
+ YAHOO_SERVICE_CHATJOIN, /* > 1 104-room 129-1600326591 62-2 */
+ YAHOO_SERVICE_CHATLEAVE,
+ YAHOO_SERVICE_CHATEXIT = 0x9b,
+ YAHOO_SERVICE_CHATADDINVITE = 0x9d,
+ YAHOO_SERVICE_CHATLOGOUT = 0xa0,
+ YAHOO_SERVICE_CHATPING,
+ YAHOO_SERVICE_COMMENT = 0xa8,
+ YAHOO_SERVICE_GAME_INVITE = 0xb7,
+ YAHOO_SERVICE_STEALTH_PERM = 0xb9,
+ YAHOO_SERVICE_STEALTH_SESSION = 0xba,
+ YAHOO_SERVICE_AVATAR = 0xbc,
+ YAHOO_SERVICE_PICTURE_CHECKSUM = 0xbd,
+ YAHOO_SERVICE_PICTURE = 0xbe,
+ YAHOO_SERVICE_PICTURE_UPDATE = 0xc1,
+ YAHOO_SERVICE_PICTURE_UPLOAD = 0xc2,
+ YAHOO_SERVICE_YAB_UPDATE = 0xc4,
+ YAHOO_SERVICE_Y6_VISIBLE_TOGGLE = 0xc5, /* YMSG13, key 13: 2 = invisible, 1 = visible */
+ YAHOO_SERVICE_Y6_STATUS_UPDATE = 0xc6, /* YMSG13 */
+ YAHOO_SERVICE_PICTURE_STATUS = 0xc7, /* YMSG13, key 213: 0 = none, 1 = avatar, 2 = picture */
+ YAHOO_SERVICE_VERIFY_ID_EXISTS = 0xc8,
+ YAHOO_SERVICE_AUDIBLE = 0xd0,
+ YAHOO_SERVICE_Y7_PHOTO_SHARING = 0xd2,
+ YAHOO_SERVICE_Y7_CONTACT_DETAILS = 0xd3, /* YMSG13 */
+ YAHOO_SERVICE_Y7_CHAT_SESSION = 0xd4,
+ YAHOO_SERVICE_Y7_AUTHORIZATION = 0xd6, /* YMSG13 */
+ YAHOO_SERVICE_Y7_FILETRANSFER = 0xdc, /* YMSG13 */
+ YAHOO_SERVICE_Y7_FILETRANSFERINFO, /* YMSG13 */
+ YAHOO_SERVICE_Y7_FILETRANSFERACCEPT, /* YMSG13 */
+ YAHOO_SERVICE_Y7_MINGLE = 0xe1, /* YMSG13 */
+ YAHOO_SERVICE_Y7_CHANGE_GROUP = 0xe7, /* YMSG13 */
+ YAHOO_SERVICE_MYSTERY = 0xef, /* Don't know what this is for */
+ YAHOO_SERVICE_Y8_STATUS = 0xf0, /* YMSG15 */
+ YAHOO_SERVICE_Y8_LIST = 0Xf1, /* YMSG15 */
+ YAHOO_SERVICE_MESSAGE_CONFIRM = 0xfb,
+ YAHOO_SERVICE_WEBLOGIN = 0x0226,
+ YAHOO_SERVICE_SMS_MSG = 0x02ea
+ };
+
+ enum yahoo_status {
+ YAHOO_STATUS_AVAILABLE = 0,
+ YAHOO_STATUS_BRB,
+ YAHOO_STATUS_BUSY,
+ YAHOO_STATUS_NOTATHOME,
+ YAHOO_STATUS_NOTATDESK,
+ YAHOO_STATUS_NOTINOFFICE,
+ YAHOO_STATUS_ONPHONE,
+ YAHOO_STATUS_ONVACATION,
+ YAHOO_STATUS_OUTTOLUNCH,
+ YAHOO_STATUS_STEPPEDOUT,
+ YAHOO_STATUS_INVISIBLE = 12,
+ YAHOO_STATUS_CUSTOM = 99,
+ YAHOO_STATUS_IDLE = 999,
+ YAHOO_STATUS_OFFLINE = 0x5a55aa56 /* don't ask */
+ };
+
+ enum ypacket_status {
+ YPACKET_STATUS_DISCONNECTED = -1,
+ YPACKET_STATUS_DEFAULT = 0,
+ YPACKET_STATUS_SERVERACK = 1,
+ YPACKET_STATUS_GAME = 0x2,
+ YPACKET_STATUS_AWAY = 0x4,
+ YPACKET_STATUS_CONTINUED = 0x5,
+ YPACKET_STATUS_INVISIBLE = 12,
+ YPACKET_STATUS_NOTIFY = 0x16, /* TYPING */
+ YPACKET_STATUS_WEBLOGIN = 0x5a55aa55,
+ YPACKET_STATUS_OFFLINE = 0x5a55aa56
+ };
+
+#define YAHOO_STATUS_GAME 0x2 /* Games don't fit into the regular status model */
+
+ enum yahoo_login_status {
+ YAHOO_LOGIN_OK = 0,
+ YAHOO_LOGIN_LOGOFF = 1,
+ YAHOO_LOGIN_UNAME = 3,
+ YAHOO_LOGIN_PASSWD = 13,
+ YAHOO_LOGIN_LOCK = 14,
+ YAHOO_LOGIN_DUPL = 99,
+ YAHOO_LOGIN_SOCK = -1,
+ YAHOO_LOGIN_UNKNOWN = 999
+ };
+
+ enum yahoo_error {
+ E_UNKNOWN = -1,
+ E_CONNECTION = -2,
+ E_SYSTEM = -3,
+ E_CUSTOM = 0,
+
+ /* responses from ignore buddy */
+ E_IGNOREDUP = 2,
+ E_IGNORENONE = 3,
+ E_IGNORECONF = 12,
+
+ /* conference */
+ E_CONFNOTAVAIL = 20
+ };
+
+ enum yahoo_log_level {
+ YAHOO_LOG_NONE = 0,
+ YAHOO_LOG_FATAL,
+ YAHOO_LOG_ERR,
+ YAHOO_LOG_WARNING,
+ YAHOO_LOG_NOTICE,
+ YAHOO_LOG_INFO,
+ YAHOO_LOG_DEBUG
+ };
+
+ enum yahoo_file_transfer {
+ YAHOO_FILE_TRANSFER_INIT = 1,
+ YAHOO_FILE_TRANSFER_ACCEPT = 3,
+ YAHOO_FILE_TRANSFER_REJECT = 4,
+ YAHOO_FILE_TRANSFER_DONE = 5,
+ YAHOO_FILE_TRANSFER_RELAY,
+ YAHOO_FILE_TRANSFER_FAILED,
+ YAHOO_FILE_TRANSFER_UNKNOWN
+ };
#define YAHOO_PROTO_VER 0x0010
@@ -120,171 +221,176 @@ enum yahoo_log_level {
#define YAHOO_STYLE_URLON "\033[lm"
#define YAHOO_STYLE_URLOFF "\033[xlm"
-enum yahoo_connection_type {
- YAHOO_CONNECTION_PAGER=0,
- YAHOO_CONNECTION_FT,
- YAHOO_CONNECTION_YAB,
- YAHOO_CONNECTION_WEBCAM_MASTER,
- YAHOO_CONNECTION_WEBCAM,
- YAHOO_CONNECTION_CHATCAT,
- YAHOO_CONNECTION_SEARCH,
- YAHOO_CONNECTION_AUTH,
-};
-
-enum yahoo_webcam_direction_type {
- YAHOO_WEBCAM_DOWNLOAD=0,
- YAHOO_WEBCAM_UPLOAD
-};
-
-enum yahoo_stealth_visibility_type {
- YAHOO_STEALTH_DEFAULT = 0,
- YAHOO_STEALTH_ONLINE,
- YAHOO_STEALTH_PERM_OFFLINE
-};
+ enum yahoo_connection_type {
+ YAHOO_CONNECTION_PAGER = 0,
+ YAHOO_CONNECTION_FT,
+ YAHOO_CONNECTION_YAB,
+ YAHOO_CONNECTION_WEBCAM_MASTER,
+ YAHOO_CONNECTION_WEBCAM,
+ YAHOO_CONNECTION_CHATCAT,
+ YAHOO_CONNECTION_SEARCH,
+ YAHOO_CONNECTION_AUTH
+ };
+
+ enum yahoo_webcam_direction_type {
+ YAHOO_WEBCAM_DOWNLOAD = 0,
+ YAHOO_WEBCAM_UPLOAD
+ };
+
+ enum yahoo_stealth_visibility_type {
+ YAHOO_STEALTH_DEFAULT = 0,
+ YAHOO_STEALTH_ONLINE,
+ YAHOO_STEALTH_PERM_OFFLINE
+ };
/* chat member attribs */
#define YAHOO_CHAT_MALE 0x8000
#define YAHOO_CHAT_FEMALE 0x10000
+#define YAHOO_CHAT_FEMALE 0x10000
#define YAHOO_CHAT_DUNNO 0x400
#define YAHOO_CHAT_WEBCAM 0x10
-enum yahoo_webcam_conn_type { Y_WCM_DIALUP, Y_WCM_DSL, Y_WCM_T1 };
-
-struct yahoo_webcam {
- int direction; /* Uploading or downloading */
- int conn_type; /* 0=Dialup, 1=DSL/Cable, 2=T1/Lan */
-
- char *user; /* user we are viewing */
- char *server; /* webcam server to connect to */
- int port; /* webcam port to connect on */
- char *key; /* key to connect to the server with */
- char *description; /* webcam description */
- char *my_ip; /* own ip number */
-};
-
-struct yahoo_webcam_data {
- unsigned int data_size;
- unsigned int to_read;
- unsigned int timestamp;
- unsigned char packet_type;
-};
-
-struct yahoo_data {
- char *user;
- char *password;
-
- char *cookie_y;
- char *cookie_t;
- char *cookie_c;
- char *login_cookie;
-
- YList *buddies;
- YList *ignore;
- YList *identities;
- char *login_id;
-
- int current_status;
- int initial_status;
- int logged_in;
-
- int session_id;
-
- int client_id;
-
- char *rawbuddylist;
- char *ignorelist;
-
- void *server_settings;
-
- struct yahoo_process_status_entry *half_user;
-};
-
-struct yab {
- char *id;
- char *fname;
- char *lname;
- char *nname;
- char *email;
- char *hphone;
- char *wphone;
- char *mphone;
- int dbid;
-};
-
-struct yahoo_buddy {
- char *group;
- char *id;
- char *real_name;
- struct yab *yab_entry;
-};
-
-enum yahoo_search_type {
- YAHOO_SEARCH_KEYWORD = 0,
- YAHOO_SEARCH_YID,
- YAHOO_SEARCH_NAME
-};
-
-enum yahoo_search_gender {
- YAHOO_GENDER_NONE = 0,
- YAHOO_GENDER_MALE,
- YAHOO_GENDER_FEMALE
-};
-
-enum yahoo_search_agerange {
- YAHOO_AGERANGE_NONE = 0
-};
-
-struct yahoo_found_contact {
- char *id;
- char *gender;
- char *location;
- int age;
- int online;
-};
+ enum yahoo_webcam_conn_type { Y_WCM_DIALUP, Y_WCM_DSL, Y_WCM_T1 };
+
+ struct yahoo_webcam {
+ int direction; /* Uploading or downloading */
+ int conn_type; /* 0=Dialup, 1=DSL/Cable, 2=T1/Lan */
+
+ char *user; /* user we are viewing */
+ char *server; /* webcam server to connect to */
+ int port; /* webcam port to connect on */
+ char *key; /* key to connect to the server with */
+ char *description; /* webcam description */
+ char *my_ip; /* own ip number */
+ };
+
+ struct yahoo_webcam_data {
+ unsigned int data_size;
+ unsigned int to_read;
+ unsigned int timestamp;
+ unsigned char packet_type;
+ };
+
+ struct yahoo_data {
+ char *user;
+ char *password;
+
+ char *cookie_y;
+ char *cookie_t;
+ char *cookie_c;
+ char *cookie_b;
+ char *login_cookie;
+ char *crumb;
+ char *seed;
+
+ YList *buddies;
+ YList *ignore;
+ YList *identities;
+ char *login_id;
+
+ int current_status;
+ int initial_status;
+ int logged_in;
+
+ int session_id;
+
+ int client_id;
+
+ char *rawbuddylist;
+ char *ignorelist;
+
+ void *server_settings;
+
+ struct yahoo_process_status_entry *half_user;
+ };
+
+ struct yab {
+ int yid;
+ char *id;
+ char *fname;
+ char *lname;
+ char *nname;
+ char *email;
+ char *hphone;
+ char *wphone;
+ char *mphone;
+ int dbid;
+ };
+
+ struct yahoo_buddy {
+ char *group;
+ char *id;
+ char *real_name;
+ struct yab *yab_entry;
+ };
+
+ enum yahoo_search_type {
+ YAHOO_SEARCH_KEYWORD = 0,
+ YAHOO_SEARCH_YID,
+ YAHOO_SEARCH_NAME
+ };
+
+ enum yahoo_search_gender {
+ YAHOO_GENDER_NONE = 0,
+ YAHOO_GENDER_MALE,
+ YAHOO_GENDER_FEMALE
+ };
+
+ enum yahoo_search_agerange {
+ YAHOO_AGERANGE_NONE = 0
+ };
+
+ struct yahoo_found_contact {
+ char *id;
+ char *gender;
+ char *location;
+ int age;
+ int online;
+ };
/*
* Function pointer to be passed to http get/post and send file
*/
-typedef void (*yahoo_get_fd_callback)(int id, int fd, int error, void *data);
+ typedef void (*yahoo_get_fd_callback) (int id, void *fd, int error,
+ void *data);
/*
* Function pointer to be passed to yahoo_get_url_handle
*/
-typedef void (*yahoo_get_url_handle_callback)(int id, int fd, int error,
- const char *filename, unsigned long size, void *data);
-
-
-struct yahoo_chat_member {
- char *id;
- int age;
- int attribs;
- char *alias;
- char *location;
-};
-
-struct yahoo_process_status_entry {
- char *name; /* 7 name */
- int state; /* 10 state */
- int flags; /* 13 flags, bit 0 = pager, bit 1 = chat, bit 2 = game */
- int mobile; /* 60 mobile */
- char *msg; /* 19 custom status message */
- int away; /* 47 away (or invisible) */
- int buddy_session; /* 11 state */
- int f17; /* 17 in chat? then what about flags? */
- int idle; /* 137 seconds idle */
- int f138; /* 138 state */
- char *f184; /* 184 state */
- int f192; /* 192 state */
- int f10001; /* 10001 state */
- int f10002; /* 10002 state */
- int f198; /* 198 state */
- char *f197; /* 197 state */
- char *f205; /* 205 state */
- int f213; /* 213 state */
-};
+ typedef void (*yahoo_get_url_handle_callback) (int id, void *fd,
+ int error, const char *filename, unsigned long size,
+ void *data);
+
+ struct yahoo_chat_member {
+ char *id;
+ int age;
+ int attribs;
+ char *alias;
+ char *location;
+ };
+
+ struct yahoo_process_status_entry {
+ char *name; /* 7 name */
+ int state; /* 10 state */
+ int flags; /* 13 flags, bit 0 = pager, bit 1 = chat, bit 2 = game */
+ int mobile; /* 60 mobile */
+ char *msg; /* 19 custom status message */
+ int away; /* 47 away (or invisible) */
+ int buddy_session; /* 11 state */
+ int f17; /* 17 in chat? then what about flags? */
+ int idle; /* 137 seconds idle */
+ int f138; /* 138 state */
+ char *f184; /* 184 state */
+ int f192; /* 192 state */
+ int f10001; /* 10001 state */
+ int f10002; /* 10002 state */
+ int f198; /* 198 state */
+ char *f197; /* 197 state */
+ char *f205; /* 205 state */
+ int f213; /* 213 state */
+ };
#ifdef __cplusplus
}
#endif
-
#endif
diff --git a/protocols/yahoo/yahoo_fn.h b/protocols/yahoo/yahoo_fn.h
index 3f79f524..5400e5d0 100644
--- a/protocols/yahoo/yahoo_fn.h
+++ b/protocols/yahoo/yahoo_fn.h
@@ -18,16 +18,15 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#define IDENT 1 /* identify function */
-#define XOR 2 /* xor with arg1 */
-#define MULADD 3 /* multipy by arg1 then add arg2 */
-#define LOOKUP 4 /* lookup each byte in the table pointed to by arg1 */
-#define BITFLD 5 /* reorder bits according to table pointed to by arg1 */
+#define IDENT 1 /* identify function */
+#define XOR 2 /* xor with arg1 */
+#define MULADD 3 /* multipy by arg1 then add arg2 */
+#define LOOKUP 4 /* lookup each byte in the table pointed to by arg1 */
+#define BITFLD 5 /* reorder bits according to table pointed to by arg1 */
-struct yahoo_fn
-{
- int type;
+struct yahoo_fn {
+ int type;
long arg1, arg2;
};
-int yahoo_xfrm( int table, int depth, int seed );
+int yahoo_xfrm(int table, int depth, int seed);
diff --git a/protocols/yahoo/yahoo_httplib.c b/protocols/yahoo/yahoo_httplib.c
index 1b084992..6bb8923d 100644
--- a/protocols/yahoo/yahoo_httplib.c
+++ b/protocols/yahoo/yahoo_httplib.c
@@ -29,14 +29,13 @@
# define strchr index
# define strrchr rindex
# endif
-char *strchr (), *strrchr ();
+char *strchr(), *strrchr();
# if !HAVE_MEMCPY
# define memcpy(d, s, n) bcopy ((s), (d), (n))
# define memmove(d, s, n) bcopy ((s), (d), (n))
# endif
#endif
-
#include <errno.h>
#ifndef _WIN32
#include <unistd.h>
@@ -62,7 +61,7 @@ extern struct yahoo_callbacks *yc;
extern enum yahoo_log_level log_level;
-int yahoo_tcp_readline(char *ptr, int maxlen, int fd)
+int yahoo_tcp_readline(char *ptr, int maxlen, void *fd)
{
int n, rc;
char c;
@@ -70,11 +69,11 @@ int yahoo_tcp_readline(char *ptr, int maxlen, int fd)
for (n = 1; n < maxlen; n++) {
do {
- rc = read(fd, &c, 1);
- } while(rc == -1 && (errno == EINTR || errno == EAGAIN)); /* this is bad - it should be done asynchronously */
+ rc = YAHOO_CALLBACK(ext_yahoo_read) (fd, &c, 1);
+ } while (rc == -1 && (errno == EINTR || errno == EAGAIN)); /* this is bad - it should be done asynchronously */
if (rc == 1) {
- if(c == '\r') /* get rid of \r */
+ if (c == '\r') /* get rid of \r */
continue;
*ptr = c;
if (c == '\n')
@@ -82,9 +81,9 @@ int yahoo_tcp_readline(char *ptr, int maxlen, int fd)
ptr++;
} else if (rc == 0) {
if (n == 1)
- return (0); /* EOF, no data */
+ return (0); /* EOF, no data */
else
- break; /* EOF, w/ data */
+ break; /* EOF, w/ data */
} else {
return -1;
}
@@ -95,12 +94,12 @@ int yahoo_tcp_readline(char *ptr, int maxlen, int fd)
}
static int url_to_host_port_path(const char *url,
- char *host, int *port, char *path)
+ char *host, int *port, char *path, int *ssl)
{
- char *urlcopy=NULL;
- char *slash=NULL;
- char *colon=NULL;
-
+ char *urlcopy = NULL;
+ char *slash = NULL;
+ char *colon = NULL;
+
/*
* http://hostname
* http://hostname/
@@ -110,10 +109,14 @@ static int url_to_host_port_path(const char *url,
* http://hostname:port/
* http://hostname:port/path
* http://hostname:port/path:foo
+ * and https:// variants of the above
*/
- if(strstr(url, "http://") == url) {
- urlcopy = strdup(url+7);
+ if (strstr(url, "http://") == url) {
+ urlcopy = strdup(url + 7);
+ } else if (strstr(url, "https://") == url) {
+ urlcopy = strdup(url + 8);
+ *ssl = 1;
} else {
WARNING(("Weird url - unknown protocol: %s", url));
return 0;
@@ -122,14 +125,17 @@ static int url_to_host_port_path(const char *url,
slash = strchr(urlcopy, '/');
colon = strchr(urlcopy, ':');
- if(!colon || (slash && slash < colon)) {
- *port = 80;
+ if (!colon || (slash && slash < colon)) {
+ if (*ssl)
+ *port = 443;
+ else
+ *port = 80;
} else {
*colon = 0;
- *port = atoi(colon+1);
+ *port = atoi(colon + 1);
}
- if(!slash) {
+ if (!slash) {
strcpy(path, "/");
} else {
strcpy(path, slash);
@@ -137,7 +143,7 @@ static int url_to_host_port_path(const char *url,
}
strcpy(host, urlcopy);
-
+
FREE(urlcopy);
return 1;
@@ -145,135 +151,135 @@ static int url_to_host_port_path(const char *url,
static int isurlchar(unsigned char c)
{
- return (isalnum(c) || '-' == c || '_' == c);
+ return (isalnum(c));
}
char *yahoo_urlencode(const char *instr)
{
- int ipos=0, bpos=0;
+ int ipos = 0, bpos = 0;
char *str = NULL;
int len = strlen(instr);
- if(!(str = y_new(char, 3*len + 1) ))
- return "";
+ if (!(str = y_new(char, 3 *len + 1)))
+ return "";
- while(instr[ipos]) {
- while(isurlchar(instr[ipos]))
+ while (instr[ipos]) {
+ while (isurlchar(instr[ipos]))
str[bpos++] = instr[ipos++];
- if(!instr[ipos])
+ if (!instr[ipos])
break;
-
- snprintf(&str[bpos], 4, "%%%.2x", instr[ipos]);
- bpos+=3;
+
+ snprintf(&str[bpos], 4, "%%%02x", instr[ipos] & 0xff);
+ bpos += 3;
ipos++;
}
- str[bpos]='\0';
+ str[bpos] = '\0';
/* free extra alloc'ed mem. */
len = strlen(str);
- str = y_renew(char, str, len+1);
+ str = y_renew(char, str, len + 1);
return (str);
}
char *yahoo_urldecode(const char *instr)
{
- int ipos=0, bpos=0;
+ int ipos = 0, bpos = 0;
char *str = NULL;
- char entity[3]={0,0,0};
+ char entity[3] = { 0, 0, 0 };
unsigned dec;
int len = strlen(instr);
- if(!(str = y_new(char, len+1) ))
- return "";
+ if (!(str = y_new(char, len + 1)))
+ return "";
- while(instr[ipos]) {
- while(instr[ipos] && instr[ipos]!='%')
- if(instr[ipos]=='+') {
- str[bpos++]=' ';
+ while (instr[ipos]) {
+ while (instr[ipos] && instr[ipos] != '%')
+ if (instr[ipos] == '+') {
+ str[bpos++] = ' ';
ipos++;
} else
str[bpos++] = instr[ipos++];
- if(!instr[ipos])
+ if (!instr[ipos])
break;
-
- if(instr[ipos+1] && instr[ipos+2]) {
+
+ if (instr[ipos + 1] && instr[ipos + 2]) {
ipos++;
- entity[0]=instr[ipos++];
- entity[1]=instr[ipos++];
+ entity[0] = instr[ipos++];
+ entity[1] = instr[ipos++];
sscanf(entity, "%2x", &dec);
str[bpos++] = (char)dec;
} else {
str[bpos++] = instr[ipos++];
}
}
- str[bpos]='\0';
+ str[bpos] = '\0';
/* free extra alloc'ed mem. */
len = strlen(str);
- str = y_renew(char, str, len+1);
+ str = y_renew(char, str, len + 1);
return (str);
}
char *yahoo_xmldecode(const char *instr)
{
- int ipos=0, bpos=0, epos=0;
+ int ipos = 0, bpos = 0, epos = 0;
char *str = NULL;
- char entity[4]={0,0,0,0};
- char *entitymap[5][2]={
- {"amp;", "&"},
+ char entity[4] = { 0, 0, 0, 0 };
+ char *entitymap[5][2] = {
+ {"amp;", "&"},
{"quot;", "\""},
- {"lt;", "<"},
- {"gt;", "<"},
+ {"lt;", "<"},
+ {"gt;", "<"},
{"nbsp;", " "}
};
unsigned dec;
int len = strlen(instr);
- if(!(str = y_new(char, len+1) ))
- return "";
+ if (!(str = y_new(char, len + 1)))
+ return "";
- while(instr[ipos]) {
- while(instr[ipos] && instr[ipos]!='&')
- if(instr[ipos]=='+') {
- str[bpos++]=' ';
+ 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])
+ if (!instr[ipos] || !instr[ipos + 1])
break;
ipos++;
- if(instr[ipos] == '#') {
+ if (instr[ipos] == '#') {
ipos++;
- epos=0;
- while(instr[ipos] != ';')
- entity[epos++]=instr[ipos++];
+ epos = 0;
+ 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];
+ 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';
+ str[bpos] = '\0';
/* free extra alloc'ed mem. */
len = strlen(str);
- str = y_renew(char, str, len+1);
+ str = y_renew(char, str, len + 1);
return (str);
}
-typedef void (*http_connected)(int id, int fd, int error);
+typedef void (*http_connected) (int id, void *fd, int error);
struct callback_data {
int id;
@@ -282,150 +288,117 @@ struct callback_data {
void *user_data;
};
-static void connect_complete(int fd, int error, void *data)
+static void connect_complete(void *fd, int error, void *data)
{
struct callback_data *ccd = data;
- if(error == 0 && fd > 0)
- write(fd, ccd->request, strlen(ccd->request));
- FREE(ccd->request);
+ if (error == 0)
+ YAHOO_CALLBACK(ext_yahoo_write) (fd, ccd->request,
+ strlen(ccd->request));
+ free(ccd->request);
ccd->callback(ccd->id, fd, error, ccd->user_data);
FREE(ccd);
}
-static void yahoo_send_http_request(int id, char *host, int port, char *request,
- yahoo_get_fd_callback callback, void *data)
+static void yahoo_send_http_request(int id, char *host, int port, char *request,
+ yahoo_get_fd_callback callback, void *data, int use_ssl)
{
- struct callback_data *ccd=y_new0(struct callback_data, 1);
+ struct callback_data *ccd = y_new0(struct callback_data, 1);
ccd->callback = callback;
ccd->id = id;
ccd->request = strdup(request);
ccd->user_data = data;
-
- YAHOO_CALLBACK(ext_yahoo_connect_async)(id, host, port, connect_complete, ccd);
+
+ YAHOO_CALLBACK(ext_yahoo_connect_async) (id, host, port,
+ connect_complete, ccd, use_ssl);
}
-void yahoo_http_post(int id, const char *url, const char *cookies, long content_length,
- yahoo_get_fd_callback callback, void *data)
+void yahoo_http_post(int id, const char *url, const char *cookies,
+ long content_length, yahoo_get_fd_callback callback, void *data)
{
char host[255];
int port = 80;
char path[255];
char buff[1024];
-
- if(!url_to_host_port_path(url, host, &port, path))
- return;
+ int ssl = 0;
- snprintf(buff, sizeof(buff),
- "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,
- cookies);
+ if (!url_to_host_port_path(url, host, &port, path, &ssl))
+ return;
- yahoo_send_http_request(id, host, port, buff, callback, data);
+ /* thanks to kopete dumpcap */
+ snprintf(buff, sizeof(buff),
+ "POST %s HTTP/1.1\r\n"
+ "Cookie: %s\r\n"
+ "User-Agent: Mozilla/5.0\r\n"
+ "Host: %s\r\n"
+ "Content-Length: %ld\r\n"
+ "Cache-Control: no-cache\r\n"
+ "\r\n", path, cookies, host, content_length);
+
+ yahoo_send_http_request(id, host, port, buff, callback, data, ssl);
}
-void yahoo_http_get(int id, const char *url, const char *cookies,
- yahoo_get_fd_callback callback, void *data)
+void yahoo_http_get(int id, const char *url, const char *cookies, int http11,
+ int keepalive, yahoo_get_fd_callback callback, void *data)
{
char host[255];
int port = 80;
char path[255];
- char buff[1024];
-
- if(!url_to_host_port_path(url, host, &port, path))
- return;
+ char buff[2048];
+ char cookiebuff[1024];
+ int ssl = 0;
- snprintf(buff, sizeof(buff),
- "GET %s HTTP/1.0\r\n"
- "Host: %s:%d\r\n"
- "User-Agent: Mozilla/4.5 [en] (" PACKAGE "/" VERSION ")\r\n"
- "Cookie: %s\r\n"
- "\r\n",
- path, host, port, cookies);
+ if (!url_to_host_port_path(url, host, &port, path, &ssl))
+ return;
- yahoo_send_http_request(id, host, port, buff, callback, data);
+ /* Allow cases when we don't need to send a cookie */
+ if (cookies)
+ snprintf(cookiebuff, sizeof(cookiebuff), "Cookie: %s\r\n",
+ cookies);
+ else
+ cookiebuff[0] = '\0';
+
+ snprintf(buff, sizeof(buff),
+ "GET %s HTTP/1.%s\r\n"
+ "%sHost: %s\r\n"
+ "User-Agent: Mozilla/4.5 [en] (" PACKAGE "/" VERSION ")\r\n"
+ "Accept: */*\r\n"
+ "%s" "\r\n", path, http11?"1":"0", cookiebuff, host,
+ keepalive? "Connection: Keep-Alive\r\n":"Connection: close\r\n");
+
+ yahoo_send_http_request(id, host, port, buff, callback, data, ssl);
}
-struct url_data {
- yahoo_get_url_handle_callback callback;
- void *user_data;
-};
-
-static void yahoo_got_url_fd(int id, int fd, int error, void *data)
+void yahoo_http_head(int id, const char *url, const char *cookies, int len,
+ char *payload, yahoo_get_fd_callback callback, void *data)
{
- char *tmp=NULL;
- char buff[1024];
- unsigned long filesize=0;
- char *filename=NULL;
- int n;
-
- struct url_data *ud = data;
+ char host[255];
+ int port = 80;
+ char path[255];
+ char buff[2048];
+ char cookiebuff[1024];
+ int ssl = 0;
- if(error || fd < 0) {
- ud->callback(id, fd, error, filename, filesize, ud->user_data);
- FREE(ud);
+ if (!url_to_host_port_path(url, host, &port, path, &ssl))
return;
- }
-
- while((n=yahoo_tcp_readline(buff, sizeof(buff), fd)) > 0) {
- LOG(("Read:%s:\n", buff));
- if(!strcmp(buff, ""))
- break;
-
- if( !strncasecmp(buff, "Content-length:",
- strlen("Content-length:")) ) {
- tmp = strrchr(buff, ' ');
- if(tmp)
- filesize = atol(tmp);
- }
-
- if( !strncasecmp(buff, "Content-disposition:",
- strlen("Content-disposition:")) ) {
- tmp = strstr(buff, "name=");
- if(tmp) {
- tmp+=strlen("name=");
- if(tmp[0] == '"') {
- char *tmp2;
- tmp++;
- tmp2 = strchr(tmp, '"');
- if(tmp2)
- *tmp2 = '\0';
- } else {
- char *tmp2;
- tmp2 = strchr(tmp, ';');
- if(!tmp2)
- tmp2 = strchr(tmp, '\r');
- if(!tmp2)
- tmp2 = strchr(tmp, '\n');
- if(tmp2)
- *tmp2 = '\0';
- }
- filename = strdup(tmp);
- }
- }
- }
-
- LOG(("n == %d\n", n));
- LOG(("Calling callback, filename:%s, size: %ld\n", filename, filesize));
- ud->callback(id, fd, error, filename, filesize, ud->user_data);
- FREE(ud);
- FREE(filename);
-}
-
-void yahoo_get_url_fd(int id, const char *url, const struct yahoo_data *yd,
- yahoo_get_url_handle_callback callback, void *data)
-{
- char buff[1024];
- struct url_data *ud = y_new0(struct url_data, 1);
- snprintf(buff, sizeof(buff), "Y=%s; T=%s", yd->cookie_y, yd->cookie_t);
- ud->callback = callback;
- ud->user_data = data;
- yahoo_http_get(id, url, buff, yahoo_got_url_fd, ud);
+ /* Allow cases when we don't need to send a cookie */
+ if (cookies)
+ snprintf(cookiebuff, sizeof(cookiebuff), "Cookie: %s\r\n",
+ cookies);
+ else
+ cookiebuff[0] = '\0';
+
+ snprintf(buff, sizeof(buff),
+ "HEAD %s HTTP/1.0\r\n"
+ "Accept: */*\r\n"
+ "Host: %s:%d\r\n"
+ "User-Agent: Mozilla/4.5 [en] (" PACKAGE "/" VERSION ")\r\n"
+ "%s"
+ "Content-Length: %d\r\n"
+ "Cache-Control: no-cache\r\n"
+ "\r\n%s", path, host, port, cookiebuff, len,
+ payload?payload:"");
+
+ yahoo_send_http_request(id, host, port, buff, callback, data, ssl);
}
diff --git a/protocols/yahoo/yahoo_httplib.h b/protocols/yahoo/yahoo_httplib.h
index fd28ad48..ab699b20 100644
--- a/protocols/yahoo/yahoo_httplib.h
+++ b/protocols/yahoo/yahoo_httplib.h
@@ -28,21 +28,21 @@ extern "C" {
#include "yahoo2_types.h"
-char *yahoo_urlencode(const char *instr);
-char *yahoo_urldecode(const char *instr);
-char *yahoo_xmldecode(const char *instr);
-
-int yahoo_tcp_readline(char *ptr, int maxlen, int fd);
-void yahoo_http_post(int id, const char *url, const char *cookies, long size,
- yahoo_get_fd_callback callback, void *data);
-void yahoo_http_get(int id, const char *url, const char *cookies,
- yahoo_get_fd_callback callback, void *data);
-void yahoo_get_url_fd(int id, const char *url, const struct yahoo_data *yd,
- yahoo_get_url_handle_callback callback, void *data);
-
+ char *yahoo_urlencode(const char *instr);
+ char *yahoo_urldecode(const char *instr);
+ char *yahoo_xmldecode(const char *instr);
+
+ int yahoo_tcp_readline(char *ptr, int maxlen, void *fd);
+ void yahoo_http_post(int id, const char *url, const char *cookies,
+ long size, yahoo_get_fd_callback callback, void *data);
+ void yahoo_http_get(int id, const char *url, const char *cookies,
+ int http11, int keepalive, yahoo_get_fd_callback callback,
+ void *data);
+ void yahoo_http_head(int id, const char *url, const char *cookies,
+ int size, char *payload, yahoo_get_fd_callback callback,
+ void *data);
#ifdef __cplusplus
}
#endif
-
#endif
diff --git a/protocols/yahoo/yahoo_list.h b/protocols/yahoo/yahoo_list.h
index 0d335acd..c2e5ad18 100644
--- a/protocols/yahoo/yahoo_list.h
+++ b/protocols/yahoo/yahoo_list.h
@@ -23,7 +23,7 @@
#ifndef __YLIST_H__
#define __YLIST_H__
-/* GLib has linked list already, so I don't see why libyahoo2 has to copy this... */
+/* BitlBee already uses GLib so use it. */
typedef GList YList;
diff --git a/protocols/yahoo/yahoo_util.c b/protocols/yahoo/yahoo_util.c
index 5375205f..33a12674 100644
--- a/protocols/yahoo/yahoo_util.c
+++ b/protocols/yahoo/yahoo_util.c
@@ -35,12 +35,12 @@ char *strchr (), *strrchr ();
#include "yahoo_util.h"
-char * y_string_append(char * string, char * append)
+char *y_string_append(char *string, char *append)
{
int size = strlen(string) + strlen(append) + 1;
- char * new_string = y_renew(char, string, size);
+ char *new_string = y_renew(char, string, size);
- if(new_string == NULL) {
+ if (new_string == NULL) {
new_string = y_new(char, size);
strcpy(new_string, string);
FREE(string);
diff --git a/protocols/yahoo/yahoo_util.h b/protocols/yahoo/yahoo_util.h
index 0046fe16..8cb721c1 100644
--- a/protocols/yahoo/yahoo_util.h
+++ b/protocols/yahoo/yahoo_util.h
@@ -60,17 +60,19 @@
# define y_new0(type, n) (type *)calloc((n), sizeof(type))
# define y_renew(type, mem, n) (type *)realloc(mem, n)
-void * y_memdup(const void * addr, int n);
-char ** y_strsplit(char * str, char * sep, int nelem);
-void y_strfreev(char ** vector);
+void *y_memdup(const void *addr, int n);
+char **y_strsplit(char *str, char *sep, int nelem);
+void y_strfreev(char **vector);
-int strncasecmp(const char * s1, const char * s2, size_t n);
-int strcasecmp(const char * s1, const char * s2);
+#ifndef _WIN32
+int strncasecmp(const char *s1, const char *s2, size_t n);
+int strcasecmp(const char *s1, const char *s2);
-char * strdup(const char *s);
+char *strdup(const char *s);
int snprintf(char *str, size_t size, const char *format, ...);
int vsnprintf(char *str, size_t size, const char *format, va_list ap);
+#endif
#endif
@@ -94,9 +96,9 @@ int vsnprintf(char *str, size_t size, const char *format, va_list ap);
* The following three functions return newly allocated memory.
* You must free it yourself
*/
-char * y_string_append(char * str, char * append);
-char * y_str_to_utf8(const char * in);
-char * y_utf8_to_str(const char * in);
+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