From e046390da36e369c94af607fdedfe7b9f99d9e47 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 11 Oct 2009 00:25:54 +0100 Subject: Make purple use BitlBee's event handling API. Since the APIs never really diverged too much this is fairly transparent. I did rename and redefine GAIM_INPUT_* variables to really make it work without adding another stupid layer in between. One problem left, the new libpurple input API doesn't care about return values. Fixing that in the next CL. --- protocols/oscar/oscar.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'protocols/oscar') diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c index 1118c26d..06b8100f 100644 --- a/protocols/oscar/oscar.c +++ b/protocols/oscar/oscar.c @@ -290,7 +290,7 @@ static gboolean oscar_callback(gpointer data, gint source, odata = (struct oscar_data *)ic->proto_data; - if (condition & GAIM_INPUT_READ) { + if (condition & B_EV_IO_READ) { if (aim_get_command(odata->sess, conn) >= 0) { aim_rxdispatch(odata->sess); if (odata->killme) @@ -362,7 +362,7 @@ static gboolean oscar_login_connect(gpointer data, gint source, b_input_conditio } aim_conn_completeconnect(sess, conn); - ic->inpa = b_input_add(conn->fd, GAIM_INPUT_READ, + ic->inpa = b_input_add(conn->fd, B_EV_IO_READ, oscar_callback, conn); return FALSE; @@ -486,7 +486,7 @@ static gboolean oscar_bos_connect(gpointer data, gint source, b_input_condition } aim_conn_completeconnect(sess, bosconn); - ic->inpa = b_input_add(bosconn->fd, GAIM_INPUT_READ, + ic->inpa = b_input_add(bosconn->fd, B_EV_IO_READ, oscar_callback, bosconn); imcb_log(ic, _("Connection established, cookie sent")); @@ -662,7 +662,7 @@ static gboolean straight_to_hell(gpointer data, gint source, b_input_condition c write(pos->fd, buf, strlen(buf)); if (pos->modname) g_free(pos->modname); - pos->inpa = b_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); + pos->inpa = b_input_add(pos->fd, B_EV_IO_READ, damn_you, pos); return FALSE; } @@ -831,7 +831,7 @@ static gboolean oscar_chatnav_connect(gpointer data, gint source, b_input_condit } aim_conn_completeconnect(sess, tstconn); - odata->cnpa = b_input_add(tstconn->fd, GAIM_INPUT_READ, + odata->cnpa = b_input_add(tstconn->fd, B_EV_IO_READ, oscar_callback, tstconn); return FALSE; @@ -859,7 +859,7 @@ static gboolean oscar_auth_connect(gpointer data, gint source, b_input_condition } aim_conn_completeconnect(sess, tstconn); - odata->paspa = b_input_add(tstconn->fd, GAIM_INPUT_READ, + odata->paspa = b_input_add(tstconn->fd, B_EV_IO_READ, oscar_callback, tstconn); return FALSE; @@ -895,7 +895,7 @@ static gboolean oscar_chat_connect(gpointer data, gint source, b_input_condition aim_conn_completeconnect(sess, ccon->conn); ccon->inpa = b_input_add(tstconn->fd, - GAIM_INPUT_READ, + B_EV_IO_READ, oscar_callback, tstconn); odata->oscar_chats = g_slist_append(odata->oscar_chats, ccon); -- cgit v1.2.3 From 81e04e162bdc4517b2f357fd16dfd76f68245464 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 31 Mar 2010 22:32:25 -0400 Subject: nogaim.c is close to doing something useful again without speaking any IRC itself. --- protocols/oscar/oscar.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'protocols/oscar') diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c index e0c32257..a5ca1ac8 100644 --- a/protocols/oscar/oscar.c +++ b/protocols/oscar/oscar.c @@ -1189,8 +1189,7 @@ static void gaim_icq_authgrant(void *data_) { message = 0; aim_ssi_auth_reply(od->sess, od->conn, uin, 1, ""); // aim_send_im_ch4(od->sess, uin, AIM_ICQMSG_AUTHGRANTED, &message); - if(imcb_find_buddy(data->ic, uin) == NULL) - imcb_ask_add(data->ic, uin, NULL); + imcb_ask_add(data->ic, uin, NULL); g_free(uin); g_free(data); @@ -1951,11 +1950,13 @@ static void oscar_get_info(struct im_connection *g, char *name) { static void oscar_get_away(struct im_connection *g, char *who) { struct oscar_data *odata = (struct oscar_data *)g->proto_data; if (odata->icq) { + /** FIXME(wilmer): Hmm, lost the ability to get away msgs here, do we care to get that back? struct buddy *budlight = imcb_find_buddy(g, who); if (budlight) if ((budlight->uc & 0xff80) >> 7) if (budlight->caps & AIM_CAPS_ICQSERVERRELAY) aim_send_im_ch2_geticqmessage(odata->sess, who, (budlight->uc & 0xff80) >> 7); + */ } else aim_getinfo(odata->sess, odata->conn, who, AIM_GETINFO_AWAYMESSAGE); } @@ -2093,7 +2094,7 @@ static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { switch (curitem->type) { case 0x0000: /* Buddy */ - if ((curitem->name) && (!imcb_find_buddy(ic, nrm))) { + if ((curitem->name) && (!imcb_buddy_by_handle(ic, nrm))) { char *realname = NULL; if (curitem->data && aim_gettlv(curitem->data, 0x0131, 1)) -- cgit v1.2.3 From 75610c3b53a68451d9eaf40fdc8a5e6419a13339 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 9 May 2010 01:40:54 +0100 Subject: Fixed up OSCAR to work with the new way of setting up groupchats. --- protocols/oscar/oscar.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'protocols/oscar') diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c index a5ca1ac8..de594eee 100644 --- a/protocols/oscar/oscar.c +++ b/protocols/oscar/oscar.c @@ -798,7 +798,9 @@ static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { chatcon = find_oscar_chat_by_conn(ic, fr->conn); chatcon->id = id; - chatcon->cnv = imcb_chat_new(ic, chatcon->show); + chatcon->cnv = bee_chat_by_title(ic->bee, ic, chatcon->show); + if (chatcon->cnv == NULL) + chatcon->cnv = imcb_chat_new(ic, chatcon->show); chatcon->cnv->data = chatcon; return 1; @@ -2650,9 +2652,13 @@ struct groupchat *oscar_chat_with(struct im_connection * ic, char *who) struct groupchat *ret; static int chat_id = 0; char * chatname; + struct groupchat *c; - chatname = g_strdup_printf("%s%d", ic->acc->user, chat_id++); - + chatname = g_strdup_printf("%s%s_%d", isdigit(*ic->acc->user) ? "icq_" : "", + ic->acc->user, chat_id++); + + c = imcb_chat_new(ic, chatname); + ret = oscar_chat_join(ic, chatname, NULL, NULL); aim_chat_invite(od->sess, od->conn, who, "", 4, chatname, 0x0); -- cgit v1.2.3 From e5abfd413a797b268db0b107d0748eb7e40da431 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 9 May 2010 12:26:57 +0100 Subject: Safety check for yesterday's fixes: Double-check that a groupchat struct isn't claimed already. --- protocols/oscar/oscar.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'protocols/oscar') diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c index 2d07f912..94dd876e 100644 --- a/protocols/oscar/oscar.c +++ b/protocols/oscar/oscar.c @@ -786,6 +786,7 @@ static int gaim_parse_logout(aim_session_t *sess, aim_frame_t *fr, ...) { static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { struct im_connection *ic = sess->aux_data; struct chat_connection *chatcon; + struct groupchat *c = NULL; static int id = 1; aim_conn_addhandler(sess, fr->conn, 0x000e, 0x0001, gaim_parse_genericerr, 0); @@ -798,8 +799,11 @@ static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { chatcon = find_oscar_chat_by_conn(ic, fr->conn); chatcon->id = id; - chatcon->cnv = bee_chat_by_title(ic->bee, ic, chatcon->show); - if (chatcon->cnv == NULL) + + c = bee_chat_by_title(ic->bee, ic, chatcon->show); + if (c && !c->data) + chatcon->cnv = c; + else chatcon->cnv = imcb_chat_new(ic, chatcon->show); chatcon->cnv->data = chatcon; -- cgit v1.2.3 From 5a673f32c7bdf10cec2e0ccabce605ec9c12859e Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 9 May 2010 14:04:45 +0100 Subject: Pick up buddy group information from OSCAR server-side contact list. --- protocols/oscar/oscar.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'protocols/oscar') diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c index 94dd876e..fa710ece 100644 --- a/protocols/oscar/oscar.c +++ b/protocols/oscar/oscar.c @@ -254,8 +254,6 @@ static char *normalize(const char *s) g_return_val_if_fail((s != NULL), NULL); u = t = g_strdup(s); - - strcpy(t, s); g_strdown(t); while (*t && (x < BUF_LEN - 1)) { @@ -2089,7 +2087,7 @@ static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { struct im_connection *ic = sess->aux_data; - struct aim_ssi_item *curitem; + struct aim_ssi_item *curitem, *curgroup; int tmp; char *nrm; @@ -2105,8 +2103,8 @@ static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { if (curitem->data && aim_gettlv(curitem->data, 0x0131, 1)) realname = aim_gettlv_str(curitem->data, 0x0131, 1); - - imcb_add_buddy(ic, nrm, NULL); + + imcb_add_buddy(ic, nrm, curgroup->gid == curitem->gid ? curgroup->name : NULL); if (realname) { imcb_buddy_nick_hint(ic, nrm, realname); @@ -2116,6 +2114,10 @@ static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { } break; + case 0x0001: /* Group */ + curgroup = curitem; + break; + case 0x0002: /* Permit buddy */ if (curitem->name) { GSList *list; -- cgit v1.2.3 From f60079b74053a53da3720b992c603fddf75ff1dd Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 25 May 2010 23:26:54 +0100 Subject: Allow one to run the configure script from a different directory and put all build files in there. I need this to properly make Debian package variants (i.e. libpurple and native). --- protocols/oscar/Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'protocols/oscar') diff --git a/protocols/oscar/Makefile b/protocols/oscar/Makefile index 2792f22a..0ec7436b 100644 --- a/protocols/oscar/Makefile +++ b/protocols/oscar/Makefile @@ -7,6 +7,10 @@ ### DEFINITIONS -include ../../Makefile.settings +ifdef SRCDIR +SRCDIR := $(SRCDIR)protocols/oscar/ +CFLAGS += -I$(SRCDIR) +endif # [SH] Program variables objects = admin.o auth.o bos.o buddylist.o chat.o chatnav.o conn.o icq.o im.o info.o misc.o msgcookie.o rxhandlers.o rxqueue.o search.o service.o snac.o ssi.o stats.o tlv.o txqueue.o oscar_util.o oscar.o @@ -32,7 +36,7 @@ distclean: clean $(objects): ../../Makefile.settings Makefile -$(objects): %.o: %.c +$(objects): %.o: $(SRCDIR)%.c @echo '*' Compiling $< @$(CC) -c $(CFLAGS) $< -o $@ -- cgit v1.2.3 From 56699f009a608ecff3a247a08b3d0105a5e17153 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 7 Jun 2010 16:11:09 +0100 Subject: Show idle + login time info in /WHOIS (if available). --- protocols/oscar/oscar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'protocols/oscar') diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c index f5b5c114..acae6433 100644 --- a/protocols/oscar/oscar.c +++ b/protocols/oscar/oscar.c @@ -937,7 +937,7 @@ static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) { tmp = normalize(info->sn); imcb_buddy_status(ic, tmp, flags, state_string, NULL); - /* imcb_buddy_times(ic, tmp, signon, time_idle); */ + imcb_buddy_times(ic, tmp, signon, time_idle); return 1; -- cgit v1.2.3 From e43736627ab8fa174352ba6a0122a6dade08a8d7 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 17 Jul 2010 00:55:53 +0100 Subject: Fix possible crash on trying to use half-created OSCAR chatrooms. --- protocols/oscar/oscar.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'protocols/oscar') diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c index 9a9f2999..11539852 100644 --- a/protocols/oscar/oscar.c +++ b/protocols/oscar/oscar.c @@ -2430,7 +2430,8 @@ void oscar_chat_msg(struct groupchat *c, char *message, int msgflags) guint16 flags; char *s; - ccon = c->data; + if (!(ccon = c->data)) + return; for (s = message; *s; s++) if (*s & 128) @@ -2471,7 +2472,10 @@ void oscar_chat_invite(struct groupchat *c, char *who, char *message) { struct im_connection *ic = c->ic; struct oscar_data * od = (struct oscar_data *)ic->proto_data; - struct chat_connection *ccon = c->data; + struct chat_connection *ccon; + + if (!(ccon = c->data)) + return; aim_chat_invite(od->sess, od->conn, who, message ? message : "", ccon->exchange, ccon->name, 0x0); @@ -2496,6 +2500,8 @@ void oscar_chat_kill(struct im_connection *ic, struct chat_connection *cc) void oscar_chat_leave(struct groupchat *c) { + if (!c->data) + return; oscar_chat_kill(c->ic, c->data); } @@ -2527,12 +2533,16 @@ struct groupchat *oscar_chat_with(struct im_connection * ic, char *who) struct oscar_data * od = (struct oscar_data *)ic->proto_data; struct groupchat *ret; static int chat_id = 0; - char * chatname; + char * chatname, *s; struct groupchat *c; chatname = g_strdup_printf("%s%s%d", isdigit(*ic->acc->user) ? "icq" : "", ic->acc->user, chat_id++); + for (s = chatname; *s; s ++) + if (!isalnum(*s)) + *s = '0'; + c = imcb_chat_new(ic, chatname); ret = oscar_chat_join(ic, chatname, NULL, NULL); aim_chat_invite(od->sess, od->conn, who, "", 4, chatname, 0x0); -- cgit v1.2.3 From 03f38289e15c27b93f8fdecf22a03353e4d01096 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 24 Jul 2010 16:06:22 +0200 Subject: Adding protocol-specific chatroom settings. First one to use this: AIM chatrooms to use exchange numbers other than 4. --- protocols/oscar/oscar.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'protocols/oscar') diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c index 11539852..fdf0d82c 100644 --- a/protocols/oscar/oscar.c +++ b/protocols/oscar/oscar.c @@ -2505,7 +2505,8 @@ void oscar_chat_leave(struct groupchat *c) oscar_chat_kill(c->ic, c->data); } -struct groupchat *oscar_chat_join(struct im_connection * ic, const char * room, const char * nick, const char * password ) +struct groupchat *oscar_chat_join_internal(struct im_connection *ic, const char *room, + const char *nick, const char *password, int exchange_number) { struct oscar_data * od = (struct oscar_data *)ic->proto_data; aim_conn_t * cur; @@ -2513,13 +2514,13 @@ struct groupchat *oscar_chat_join(struct im_connection * ic, const char * room, if((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { int st; - st = aim_chatnav_createroom(od->sess, cur, room, 4); + st = aim_chatnav_createroom(od->sess, cur, room, exchange_number); return NULL; } else { struct create_room * cr = g_new0(struct create_room, 1); - cr->exchange = 4; + cr->exchange = exchange_number; cr->name = g_strdup(room); od->create_rooms = g_slist_append(od->create_rooms, cr); aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); @@ -2528,6 +2529,12 @@ struct groupchat *oscar_chat_join(struct im_connection * ic, const char * room, } } +struct groupchat *oscar_chat_join(struct im_connection *ic, const char *room, + const char *nick, const char *password, set_t **sets) +{ + return oscar_chat_join_internal(ic, room, nick, password, set_getint(sets, "exchange_number")); +} + struct groupchat *oscar_chat_with(struct im_connection * ic, char *who) { struct oscar_data * od = (struct oscar_data *)ic->proto_data; @@ -2544,7 +2551,7 @@ struct groupchat *oscar_chat_with(struct im_connection * ic, char *who) *s = '0'; c = imcb_chat_new(ic, chatname); - ret = oscar_chat_join(ic, chatname, NULL, NULL); + ret = oscar_chat_join_internal(ic, chatname, NULL, NULL, 4); aim_chat_invite(od->sess, od->conn, who, "", 4, chatname, 0x0); g_free(chatname); @@ -2556,7 +2563,7 @@ void oscar_accept_chat(void *data) { struct aim_chat_invitation * inv = data; - oscar_chat_join(inv->ic, inv->name, NULL, NULL); + oscar_chat_join_internal(inv->ic, inv->name, NULL, NULL, 4); g_free(inv->name); g_free(inv); } @@ -2569,6 +2576,16 @@ void oscar_reject_chat(void *data) g_free(inv); } +void oscar_chat_add_settings(account_t *acc, set_t **head) +{ + set_add(head, "exchange_number", "4", set_eval_int, NULL); +} + +void oscar_chat_free_settings(account_t *acc, set_t **head) +{ + set_del(head, "exchange_number"); +} + void oscar_initmodule() { struct prpl *ret = g_new0(struct prpl, 1); @@ -2589,6 +2606,8 @@ void oscar_initmodule() ret->chat_leave = oscar_chat_leave; ret->chat_with = oscar_chat_with; ret->chat_join = oscar_chat_join; + ret->chat_add_settings = oscar_chat_add_settings; + ret->chat_free_settings = oscar_chat_free_settings; ret->add_permit = oscar_add_permit; ret->add_deny = oscar_add_deny; ret->rem_permit = oscar_rem_permit; -- cgit v1.2.3 From 7989d40d5b9c8f05b38e7b07ab7e91335e717309 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 24 Jul 2010 16:19:44 +0200 Subject: Fixing chat_join() for OSCAR to return a struct groupchat* right away, without this we end up creating a #chat_000. --- protocols/oscar/oscar.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'protocols/oscar') diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c index fdf0d82c..0310a27e 100644 --- a/protocols/oscar/oscar.c +++ b/protocols/oscar/oscar.c @@ -2509,6 +2509,7 @@ struct groupchat *oscar_chat_join_internal(struct im_connection *ic, const char const char *nick, const char *password, int exchange_number) { struct oscar_data * od = (struct oscar_data *)ic->proto_data; + struct groupchat *ret = imcb_chat_new(ic, room); aim_conn_t * cur; if((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { @@ -2516,7 +2517,7 @@ struct groupchat *oscar_chat_join_internal(struct im_connection *ic, const char st = aim_chatnav_createroom(od->sess, cur, room, exchange_number); - return NULL; + return ret; } else { struct create_room * cr = g_new0(struct create_room, 1); @@ -2525,7 +2526,7 @@ struct groupchat *oscar_chat_join_internal(struct im_connection *ic, const char od->create_rooms = g_slist_append(od->create_rooms, cr); aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); - return NULL; + return ret; } } -- cgit v1.2.3