From 65e2ce1ffdead577ed90148d33e36794136b3232 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 29 Nov 2005 00:27:09 +0100 Subject: Disable plugin support by default, support compilation with non-C99 compilers. --- protocols/nogaim.c | 62 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 26 deletions(-) (limited to 'protocols') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 474b91b2..7eb0446e 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -54,6 +54,7 @@ static int remove_chat_buddy_silent( struct conversation *b, char *handle ); GSList *connections; +#ifdef WITH_PLUGINS gboolean load_plugin(char *path) { void (*init_function) (void); @@ -75,6 +76,34 @@ gboolean load_plugin(char *path) return TRUE; } +void load_plugins(void) +{ + GDir *dir; + GError *error = NULL; + + dir = g_dir_open(PLUGINDIR, 0, &error); + + if (dir) { + const gchar *entry; + char *path; + + while ((entry = g_dir_read_name(dir))) { + path = g_build_filename(PLUGINDIR, entry, NULL); + if(!path) { + log_message(LOGLVL_WARNING, "Can't build path for %s\n", entry); + continue; + } + + load_plugin(path); + + g_free(path); + } + + g_dir_close(dir); + } +} +#endif + /* nogaim.c */ GList *protocols = NULL; @@ -100,49 +129,30 @@ struct prpl *find_protocol(const char *name) /* nogaim.c */ void nogaim_init() { - GDir *dir; - GError *error = NULL; + extern void msn_init(); + extern void oscar_init(); + extern void byahoo_init(); + extern void jabber_init(); #ifdef WITH_MSN - extern void msn_init(); msn_init(); #endif #ifdef WITH_OSCAR - extern void oscar_init(); oscar_init(); #endif #ifdef WITH_YAHOO - extern void byahoo_init(); byahoo_init(); #endif #ifdef WITH_JABBER - extern void jabber_init(); jabber_init(); #endif - dir = g_dir_open(PLUGINDIR, 0, &error); - - if (dir) { - const gchar *entry; - char *path; - - while ((entry = g_dir_read_name(dir))) { - path = g_build_filename(PLUGINDIR, entry, NULL); - if(!path) { - log_message(LOGLVL_WARNING, "Can't build path for %s\n", entry); - continue; - } - - load_plugin(path); - - g_free(path); - } - - g_dir_close(dir); - } +#ifdef WITH_PLUGINS + load_plugins(); +#endif } GSList *get_connections() { return connections; } -- cgit v1.2.3 From c7cf9d6f811e299c3659350c6bd21c75ba249de5 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 29 Nov 2005 01:43:15 +0100 Subject: This should fix a crash bug in Jabber module (NULL pointer dereference on broken Jabber/SSL connections). --- protocols/jabber/jabber.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'protocols') diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index d8d77a36..b6fca9b2 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -545,6 +545,11 @@ static void gjab_connected_ssl(gpointer data, void *source, GaimInputCondition c struct jabber_data *jd; gjconn gjc; + if (source == NULL) { + STATE_EVT(JCONN_STATE_OFF) + return; + } + if (!g_slist_find(get_connections(), gc)) { ssl_disconnect(source); return; @@ -553,11 +558,6 @@ static void gjab_connected_ssl(gpointer data, void *source, GaimInputCondition c jd = gc->proto_data; gjc = jd->gjc; - if (source == NULL) { - STATE_EVT(JCONN_STATE_OFF) - return; - } - gjab_connected(data, gjc->fd, cond); } -- cgit v1.2.3 From 500a1b60d3dd0565d215721e0db7ec7da2dec2e0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 29 Nov 2005 02:02:09 +0100 Subject: Remove references to file transfers --- protocols/nogaim.h | 30 ------------------------------ 1 file changed, 30 deletions(-) (limited to 'protocols') diff --git a/protocols/nogaim.h b/protocols/nogaim.h index 3d5006d9..b34fa2da 100644 --- a/protocols/nogaim.h +++ b/protocols/nogaim.h @@ -159,25 +159,6 @@ struct aim_user { irc_t *irc; }; -struct ft -{ - const char *filename; - - /* Total number of bytes in file */ - size_t total_bytes; - - /* Current number of bytes received */ - size_t cur_bytes; -}; - -struct ft_request -{ - const char *filename; - struct gaim_connection *gc; -}; - -typedef void (*ft_recv_handler) (struct ft *, void *data, size_t len); - struct prpl { int options; const char *name; @@ -233,11 +214,6 @@ struct prpl { /* change a buddy's group on a server list/roster */ void (* group_buddy) (struct gaim_connection *, char *who, char *old_group, char *new_group); - /* file transfers */ - struct ft_send_req *(* req_send_file) (struct gaim_connection *, const char *file); - void (* send_file_part) (struct gaim_connection *, struct ft*, void *data, size_t length); - void (* accept_recv_file) (struct gaim_connection *, struct ft*, ft_recv_handler); - void (* buddy_free) (struct buddy *); char *(* get_status_string) (struct gaim_connection *gc, int stat); @@ -325,12 +301,6 @@ G_MODULE_EXPORT void strip_html( char *msg ); G_MODULE_EXPORT char * escape_html(const char *html); G_MODULE_EXPORT void info_string_append(GString *str, char *newline, char *name, char *value); -/* file transfers */ -G_MODULE_EXPORT void ft_progress( struct ft *, int); -G_MODULE_EXPORT void ft_incoming( struct ft_request * ); -G_MODULE_EXPORT void ft_accepted( struct ft_request *, struct ft *); -G_MODULE_EXPORT void ft_denied( struct ft_request *, const char *reason); - /* prefs.c */ G_MODULE_EXPORT void build_block_list(); G_MODULE_EXPORT void build_allow_list(); -- cgit v1.2.3 From c3c2e1403287380e5e9d520900f761bbfa738b9f Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 30 Nov 2005 13:12:25 +0100 Subject: Got rid of the config.h includes in IM-code. Now that HAVE_CONFIG_H is defined, they started to cause problems. --- protocols/jabber/jabber.c | 4 ---- protocols/yahoo/crypt.c | 4 ---- protocols/yahoo/libyahoo2.c | 4 ---- protocols/yahoo/yahoo_httplib.c | 4 ---- protocols/yahoo/yahoo_util.c | 4 ---- 5 files changed, 20 deletions(-) (limited to 'protocols') diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index b6fca9b2..0379e2d3 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -21,10 +21,6 @@ * */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - #ifndef _WIN32 #include #endif diff --git a/protocols/yahoo/crypt.c b/protocols/yahoo/crypt.c index 00eed70b..5122e3af 100644 --- a/protocols/yahoo/crypt.c +++ b/protocols/yahoo/crypt.c @@ -22,10 +22,6 @@ * already had. isn't that lovely. people should just use linux or * freebsd, crypt works properly on those systems. i hate solaris */ -#if HAVE_CONFIG_H -# include -#endif - #if HAVE_STRING_H # include #elif HAVE_STRINGS_H diff --git a/protocols/yahoo/libyahoo2.c b/protocols/yahoo/libyahoo2.c index 62ceb0af..c691f18b 100644 --- a/protocols/yahoo/libyahoo2.c +++ b/protocols/yahoo/libyahoo2.c @@ -43,10 +43,6 @@ * */ -#if HAVE_CONFIG_H -# include -#endif - #ifndef _WIN32 #include #endif diff --git a/protocols/yahoo/yahoo_httplib.c b/protocols/yahoo/yahoo_httplib.c index 41e31a23..dbbe2a84 100644 --- a/protocols/yahoo/yahoo_httplib.c +++ b/protocols/yahoo/yahoo_httplib.c @@ -19,10 +19,6 @@ * */ -#if HAVE_CONFIG_H -# include -#endif - #include #include diff --git a/protocols/yahoo/yahoo_util.c b/protocols/yahoo/yahoo_util.c index cb155e3c..3c99cf44 100644 --- a/protocols/yahoo/yahoo_util.c +++ b/protocols/yahoo/yahoo_util.c @@ -19,10 +19,6 @@ * */ -#if HAVE_CONFIG_H -# include -#endif - #if STDC_HEADERS # include #else -- cgit v1.2.3 From 6caa56ab8e53f3b954da2ad1bbc779bfba1737ed Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 30 Nov 2005 14:36:59 +0100 Subject: Renamed no_one_calls in proxy.c to something that makes more sense to me. --- protocols/proxy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'protocols') diff --git a/protocols/proxy.c b/protocols/proxy.c index 59b480f4..fb87e356 100644 --- a/protocols/proxy.c +++ b/protocols/proxy.c @@ -123,7 +123,7 @@ static gboolean gaim_io_invoke(GIOChannel *source, GIOCondition condition, gpoin return TRUE; } -static void no_one_calls(gpointer data, gint source, GaimInputCondition cond) +static void gaim_io_connected(gpointer data, gint source, GaimInputCondition cond) { struct PHB *phb = data; unsigned int len; @@ -172,7 +172,7 @@ static int proxy_connect_none(char *host, unsigned short port, struct PHB *phb) if (connect(fd, (struct sockaddr *)sin, sizeof(*sin)) < 0) { if (sockerr_again()) { - phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, no_one_calls, phb); + phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, gaim_io_connected, phb); phb->fd = fd; } else { closesocket(fd); -- cgit v1.2.3 From 7c2d798b79041108ae71f86e7dbfdf9bf984dcb0 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 1 Dec 2005 12:52:25 +0100 Subject: jabber.c:542: warning: `gjc' might be used uninitialized in this function --- protocols/jabber/jabber.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'protocols') diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index 0379e2d3..16755d99 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -541,6 +541,9 @@ static void gjab_connected_ssl(gpointer data, void *source, GaimInputCondition c struct jabber_data *jd; gjconn gjc; + jd = gc->proto_data; + gjc = jd->gjc; + if (source == NULL) { STATE_EVT(JCONN_STATE_OFF) return; @@ -551,9 +554,6 @@ static void gjab_connected_ssl(gpointer data, void *source, GaimInputCondition c return; } - jd = gc->proto_data; - gjc = jd->gjc; - gjab_connected(data, gjc->fd, cond); } -- cgit v1.2.3 From 626b446e0a4f10fbcf38661013a592bcd3193e08 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 2 Dec 2005 12:30:03 +0100 Subject: The Jabber module now only accepts a limited range of ports (5222 and 5223), so it can't be abused as a portscanner. Thanks to Peter van Dijk (Habbie) for the report. --- protocols/jabber/jabber.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'protocols') diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index 16755d99..e7703b44 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -589,6 +589,11 @@ static void gjab_start(gjconn gjc) port = DEFAULT_PORT; else if (port == -1 && ssl) port = DEFAULT_PORT_SSL; + else if (port != 5222 && port != 5223) { + serv_got_crap(GJ_GC(gjc), "Only port numbers 5222 and 5223 are allowed for Jabber connections."); + STATE_EVT(JCONN_STATE_OFF) + return; + } if (server == NULL) server = g_strdup(gjc->user->server); -- cgit v1.2.3 From 027d2ebf750a011bf544f7d279cfb706594e5d05 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 2 Dec 2005 12:43:47 +0100 Subject: Modified CHANGES, and extended the allowed port range a bit. --- protocols/jabber/jabber.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'protocols') diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index e7703b44..535607e6 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -54,6 +54,8 @@ #define DEFAULT_GROUPCHAT "conference.jabber.org" #define DEFAULT_PORT 5222 #define DEFAULT_PORT_SSL 5223 +#define JABBER_PORT_MIN 5220 +#define JABBER_PORT_MAX 5229 #define JABBER_GROUP "Friends" @@ -589,8 +591,8 @@ static void gjab_start(gjconn gjc) port = DEFAULT_PORT; else if (port == -1 && ssl) port = DEFAULT_PORT_SSL; - else if (port != 5222 && port != 5223) { - serv_got_crap(GJ_GC(gjc), "Only port numbers 5222 and 5223 are allowed for Jabber connections."); + else if (port < JABBER_PORT_MIN || port > JABBER_PORT_MAX) { + serv_got_crap(GJ_GC(gjc), "For security reasons, the Jabber port number must be in the %d-%d range.", JABBER_PORT_MIN, JABBER_PORT_MAX); STATE_EVT(JCONN_STATE_OFF) return; } -- cgit v1.2.3 From f1df064766075ac2f36fb4027a4a683964f3be9a Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 3 Dec 2005 00:41:57 +0100 Subject: Oops... A very small typo caused very weird problems in the line splitting code. --- protocols/nogaim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'protocols') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 101cbb14..d0676201 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -665,7 +665,7 @@ void serv_got_im( struct gaim_connection *gc, char *handle, char *msg, guint32 f /* If there's a newline/space in this string, split up there, looks a bit prettier. */ - if( ( nl = strrchr( msg, '\n' ) ) || ( nl = strchr( msg, ' ' ) ) ) + if( ( nl = strrchr( msg, '\n' ) ) || ( nl = strrchr( msg, ' ' ) ) ) { msg[425] = tmp; tmp = *nl; -- cgit v1.2.3 From 25d1be7fbfe217b756861b4306ff7a5ae77becb1 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 4 Dec 2005 01:48:57 +0100 Subject: do_error_dialog shouldn't do NULL dereferences anymore, and TYPING notifications are always direct PRIVMSGs. --- protocols/nogaim.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'protocols') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index d0676201..5fbe00ab 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -380,7 +380,14 @@ void signoff( struct gaim_connection *gc ) void do_error_dialog( struct gaim_connection *gc, char *msg, char *title ) { - serv_got_crap( gc, "Error: %s", msg ); + if( msg && title ) + serv_got_crap( gc, "Error: %s: %s", title, msg ); + else if( msg ) + serv_got_crap( gc, "Error: %s", msg ); + else if( title ) + serv_got_crap( gc, "Error: %s", title ); + else + serv_got_crap( gc, "Error" ); } void do_ask_dialog( struct gaim_connection *gc, char *msg, void *data, void *doit, void *dont ) @@ -697,7 +704,7 @@ void serv_got_typing( struct gaim_connection *gc, char *handle, int timeout ) return; if( ( u = user_findhandle( gc, handle ) ) ) - irc_msgfrom( gc->irc, u->nick, "\1TYPING 1\1" ); + irc_privmsg( gc->irc, u, "PRIVMSG", gc->irc->nick, NULL, "\1TYPING \1" ); } void serv_got_chat_left( struct gaim_connection *gc, int id ) -- cgit v1.2.3 From e7f46c56ffa29c6f8f4917c5f367a61706758e2a Mon Sep 17 00:00:00 2001 From: Matt Sparks Date: Sun, 4 Dec 2005 06:58:41 -0600 Subject: Implements solution to typing notifications in ticket #45 --- protocols/msn/sb.c | 2 +- protocols/nogaim.c | 16 +++++++++++++--- protocols/nogaim.h | 2 +- protocols/oscar/oscar.c | 18 ++++++++++++++---- protocols/yahoo/yahoo.c | 10 ++++++++-- 5 files changed, 37 insertions(+), 11 deletions(-) (limited to 'protocols') diff --git a/protocols/msn/sb.c b/protocols/msn/sb.c index 793a881e..2f4d05d5 100644 --- a/protocols/msn/sb.c +++ b/protocols/msn/sb.c @@ -643,7 +643,7 @@ static int msn_sb_message( gpointer data, char *msg, int msglen, char **cmd, int if( who ) { - serv_got_typing( gc, who, 5 ); + serv_got_typing( gc, who, 5, 1 ); g_free( who ); } diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 5fbe00ab..34dfb2c3 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -696,15 +696,25 @@ void serv_got_im( struct gaim_connection *gc, char *handle, char *msg, guint32 f irc_msgfrom( irc, u->nick, msg ); } -void serv_got_typing( struct gaim_connection *gc, char *handle, int timeout ) +void serv_got_typing( struct gaim_connection *gc, char *handle, int timeout, int type ) { user_t *u; if( !set_getint( gc->irc, "typing_notice" ) ) return; - if( ( u = user_findhandle( gc, handle ) ) ) - irc_privmsg( gc->irc, u, "PRIVMSG", gc->irc->nick, NULL, "\1TYPING \1" ); + if( ( u = user_findhandle( gc, handle ) ) ) { + /* If type is: + * 0: user has stopped typing + * 1: user is actively typing + * 2: user has entered text, but is not actively typing + */ + if (type == 0 || type == 1 || type == 2) { + char buf[256]; + g_snprintf(buf, 256, "\1TYPING %d\1", type); + irc_privmsg( gc->irc, u, "PRIVMSG", gc->irc->nick, NULL, buf ); + } + } } void serv_got_chat_left( struct gaim_connection *gc, int id ) diff --git a/protocols/nogaim.h b/protocols/nogaim.h index 5fc9aca5..829a96c0 100644 --- a/protocols/nogaim.h +++ b/protocols/nogaim.h @@ -299,7 +299,7 @@ G_MODULE_EXPORT void show_got_added( struct gaim_connection *gc, char *id, char /* server.c */ G_MODULE_EXPORT void serv_got_update( struct gaim_connection *gc, char *handle, int loggedin, int evil, time_t signon, time_t idle, int type, guint caps ); G_MODULE_EXPORT void serv_got_im( struct gaim_connection *gc, char *handle, char *msg, guint32 flags, time_t mtime, gint len ); -G_MODULE_EXPORT void serv_got_typing( struct gaim_connection *gc, char *handle, int timeout ); +G_MODULE_EXPORT void serv_got_typing( struct gaim_connection *gc, char *handle, int timeout, int type ); G_MODULE_EXPORT void serv_got_chat_invite( struct gaim_connection *gc, char *handle, char *who, char *msg, GList *data ); G_MODULE_EXPORT struct conversation *serv_got_joined_chat( struct gaim_connection *gc, int id, char *handle ); G_MODULE_EXPORT void serv_got_chat_in( struct gaim_connection *gc, int id, char *who, int whisper, char *msg, time_t mtime ); diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c index 76d61b13..76599d8c 100644 --- a/protocols/oscar/oscar.c +++ b/protocols/oscar/oscar.c @@ -2442,10 +2442,20 @@ int gaim_parsemtn(aim_session_t *sess, aim_frame_t *fr, ...) sn = va_arg(ap, char*); type2 = va_arg(ap, int); va_end(ap); - - if(type2 == 0x0001 || type2 == 0x0002) - serv_got_typing(gc, sn, 0); - + + if(type2 == 0x0002) { + /* User is typing */ + serv_got_typing(gc, sn, 0, 1); + } + else if (type2 == 0x0001) { + /* User has typed something, but is not actively typing (stale) */ + serv_got_typing(gc, sn, 0, 2); + } + else { + /* User has stopped typing */ + serv_got_typing(gc, sn, 0, 0); + } + return 1; } diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index d7f7d1dc..74d468eb 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -640,8 +640,14 @@ void ext_yahoo_got_file( int id, char *who, char *url, long expires, char *msg, void ext_yahoo_typing_notify( int id, char *who, int stat ) { struct gaim_connection *gc = byahoo_get_gc_by_id( id ); - - serv_got_typing( gc, who, 1 ); + if (stat == 1) { + /* User is typing */ + serv_got_typing( gc, who, 1, 1 ); + } + else { + /* User stopped typing */ + serv_got_typing( gc, who, 1, 0 ); + } } void ext_yahoo_system_message( int id, char *msg ) -- cgit v1.2.3 From d636233a518fbe46264230866d4b8ea463f1474e Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 4 Dec 2005 16:12:32 +0100 Subject: Oops... :-( --- protocols/nogaim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'protocols') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 5fbe00ab..3ab4737e 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -704,7 +704,7 @@ void serv_got_typing( struct gaim_connection *gc, char *handle, int timeout ) return; if( ( u = user_findhandle( gc, handle ) ) ) - irc_privmsg( gc->irc, u, "PRIVMSG", gc->irc->nick, NULL, "\1TYPING \1" ); + irc_privmsg( gc->irc, u, "PRIVMSG", gc->irc->nick, NULL, "\1TYPING 1\1" ); } void serv_got_chat_left( struct gaim_connection *gc, int id ) -- cgit v1.2.3 From b8ef1b1aacfa2f407b6245174a06a67fa2f114af Mon Sep 17 00:00:00 2001 From: Nelson Elhage Date: Sun, 4 Dec 2005 14:32:14 -0500 Subject: Merging the Hanji groupchat patch --- protocols/oscar/aim.h | 6 ++ protocols/oscar/chat.c | 25 ------- protocols/oscar/im.c | 26 ++++++++ protocols/oscar/oscar.c | 168 ++++++++++++++++++++++++++++++++++++++++++++---- protocols/oscar/tlv.c | 25 +++++++ 5 files changed, 213 insertions(+), 37 deletions(-) (limited to 'protocols') diff --git a/protocols/oscar/aim.h b/protocols/oscar/aim.h index f7bf1a8e..24cd7730 100644 --- a/protocols/oscar/aim.h +++ b/protocols/oscar/aim.h @@ -465,6 +465,7 @@ int aim_addtlvtochain_availmsg(aim_tlvlist_t **list, const guint16 type, const c int aim_addtlvtochain_raw(aim_tlvlist_t **list, const guint16 t, const guint16 l, const guint8 *v); int aim_addtlvtochain_caps(aim_tlvlist_t **list, const guint16 t, const guint32 caps); int aim_addtlvtochain_noval(aim_tlvlist_t **list, const guint16 type); +int aim_addtlvtochain_chatroom(aim_tlvlist_t **list, guint16 type, guint16 exchange, const char *roomname, guint16 instance); int aim_addtlvtochain_userinfo(aim_tlvlist_t **list, guint16 type, aim_userinfo_t *ui); int aim_addtlvtochain_frozentlvlist(aim_tlvlist_t **list, guint16 type, aim_tlvlist_t **tl); int aim_counttlvchain(aim_tlvlist_t **list); @@ -571,6 +572,11 @@ struct aim_chat_roominfo { unsigned short instance; }; +struct aim_chat_invitation { + struct gaim_connection * gc; + char * name; + guint8 exchange; +}; #define AIM_VISIBILITYCHANGE_PERMITADD 0x05 #define AIM_VISIBILITYCHANGE_PERMITREMOVE 0x06 diff --git a/protocols/oscar/chat.c b/protocols/oscar/chat.c index 60aabc79..033c2577 100644 --- a/protocols/oscar/chat.c +++ b/protocols/oscar/chat.c @@ -183,31 +183,6 @@ int aim_chat_send_im(aim_session_t *sess, aim_conn_t *conn, guint16 flags, const return 0; } -static int aim_addtlvtochain_chatroom(aim_tlvlist_t **list, guint16 type, guint16 exchange, const char *roomname, guint16 instance) -{ - guint8 *buf; - int buflen; - aim_bstream_t bs; - - buflen = 2 + 1 + strlen(roomname) + 2; - - if (!(buf = g_malloc(buflen))) - return 0; - - aim_bstream_init(&bs, buf, buflen); - - aimbs_put16(&bs, exchange); - aimbs_put8(&bs, strlen(roomname)); - aimbs_putraw(&bs, (guint8 *)roomname, strlen(roomname)); - aimbs_put16(&bs, instance); - - aim_addtlvtochain_raw(list, type, aim_bstream_curpos(&bs), buf); - - g_free(buf); - - return 0; -} - /* * Join a room of name roomname. This is the first step to joining an * already created room. It's basically a Service Request for diff --git a/protocols/oscar/im.c b/protocols/oscar/im.c index 085687e0..c829d409 100644 --- a/protocols/oscar/im.c +++ b/protocols/oscar/im.c @@ -1368,6 +1368,30 @@ static int incomingim_ch1(aim_session_t *sess, aim_module_t *mod, aim_frame_t *r return ret; } + +static void incomingim_ch2_chat_free(aim_session_t *sess, struct aim_incomingim_ch2_args *args) +{ + + /* XXX aim_chat_roominfo_free() */ + g_free(args->info.chat.roominfo.name); + + return; +} + +static void incomingim_ch2_chat(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args, aim_bstream_t *servdata) +{ + + /* + * Chat room info. + */ + if (servdata) + aim_chat_readroominfo(servdata, &args->info.chat.roominfo); + + args->destructor = (void *)incomingim_ch2_chat_free; + + return; +} + static void incomingim_ch2_icqserverrelay_free(aim_session_t *sess, struct aim_incomingim_ch2_args *args) { @@ -1616,6 +1640,8 @@ static int incomingim_ch2(aim_session_t *sess, aim_module_t *mod, aim_frame_t *r if (args.reqclass & AIM_CAPS_ICQSERVERRELAY) incomingim_ch2_icqserverrelay(sess, mod, rx, snac, userinfo, &args, sdbsptr); + else if (args.reqclass & AIM_CAPS_CHAT) + incomingim_ch2_chat(sess, mod, rx, snac, userinfo, &args, sdbsptr); if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c index 76d61b13..15844479 100644 --- a/protocols/oscar/oscar.c +++ b/protocols/oscar/oscar.c @@ -61,7 +61,7 @@ /* Don't know if support for UTF8 is really working. For now it's UTF16 here. static int gaim_caps = AIM_CAPS_UTF8; */ -static int gaim_caps = AIM_CAPS_INTEROP | AIM_CAPS_ICHAT | AIM_CAPS_ICQSERVERRELAY; +static int gaim_caps = AIM_CAPS_INTEROP | AIM_CAPS_ICHAT | AIM_CAPS_ICQSERVERRELAY | AIM_CAPS_CHAT; static guint8 gaim_features[] = {0x01, 0x01, 0x01, 0x02}; struct oscar_data { @@ -155,7 +155,6 @@ static char *extract_name(const char *name) { return tmp; } -#if 0 static struct chat_connection *find_oscar_chat(struct gaim_connection *gc, int id) { GSList *g = ((struct oscar_data *)gc->proto_data)->oscar_chats; struct chat_connection *c = NULL; @@ -170,7 +169,7 @@ static struct chat_connection *find_oscar_chat(struct gaim_connection *gc, int i return c; } -#endif + static struct chat_connection *find_oscar_chat_by_conn(struct gaim_connection *gc, aim_conn_t *conn) { @@ -1075,14 +1074,15 @@ static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_ return 1; } +void oscar_accept_chat(gpointer w, struct aim_chat_invitation * inv); +void oscar_reject_chat(gpointer w, struct aim_chat_invitation * inv); + static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { -#if 0 struct gaim_connection *gc = sess->aux_data; -#endif if (args->status != AIM_RENDEZVOUS_PROPOSE) return 1; -#if 0 + if (args->reqclass & AIM_CAPS_CHAT) { char *name = extract_name(args->info.chat.roominfo.name); int *exch = g_new0(int, 1); @@ -1090,15 +1090,23 @@ static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_ m = g_list_append(m, g_strdup(name ? name : args->info.chat.roominfo.name)); *exch = args->info.chat.roominfo.exchange; m = g_list_append(m, exch); - serv_got_chat_invite(gc, - name ? name : args->info.chat.roominfo.name, - userinfo->sn, - (char *)args->msg, - m); + + char txt[1024]; + + g_snprintf( txt, 1024, "Got an invitation to chatroom %s from %s: %s", name, userinfo->sn, args->msg ); + + struct aim_chat_invitation * inv = g_new0(struct aim_chat_invitation, 1); + + inv->gc = gc; + inv->exchange = *exch; + inv->name = g_strdup(name); + + do_ask_dialog( gc, txt, inv, oscar_accept_chat, oscar_reject_chat); + if (name) g_free(name); } -#endif + return 1; } @@ -2483,6 +2491,138 @@ int oscar_send_typing(struct gaim_connection *gc, char * who, int typing) return( aim_im_sendmtn(od->sess, 1, who, typing ? 0x0002 : 0x0000) ); } +int oscar_chat_send(struct gaim_connection * gc, int id, char *message) +{ + struct oscar_data * od = (struct oscar_data*)gc->proto_data; + struct chat_connection * ccon; + + if(!(ccon = find_oscar_chat(gc, id))) + return -1; + + int ret; + guint8 len = strlen(message); + char *s; + + for (s = message; *s; s++) + if (*s & 128) + break; + + /* Message contains high ASCII chars, time for some translation! */ + if (*s) { + s = g_malloc(BUF_LONG); + /* Try if we can put it in an ISO8859-1 string first. + If we can't, fall back to UTF16. */ + if ((ret = do_iconv("UTF-8", "ISO8859-1", message, s, len, BUF_LONG)) >= 0) { + len = ret; + } else if ((ret = do_iconv("UTF-8", "UNICODEBIG", message, s, len, BUF_LONG)) >= 0) { + len = ret; + } else { + /* OOF, translation failed... Oh well.. */ + g_free( s ); + s = message; + } + } else { + s = message; + } + + ret = aim_chat_send_im(od->sess, ccon->conn, AIM_CHATFLAGS_NOREFLECT, s, len); + + if (s != message) { + g_free(s); + } + + return (ret >= 0); +} + +void oscar_chat_invite(struct gaim_connection * gc, int id, char *message, char *who) +{ + struct oscar_data * od = (struct oscar_data *)gc->proto_data; + struct chat_connection *ccon = find_oscar_chat(gc, id); + + if (ccon == NULL) + return; + + aim_chat_invite(od->sess, od->conn, who, message ? message : "", + ccon->exchange, ccon->name, 0x0); +} + +void oscar_chat_kill(struct gaim_connection *gc, struct chat_connection *cc) +{ + struct oscar_data *od = (struct oscar_data *)gc->proto_data; + + /* Notify the conversation window that we've left the chat */ + serv_got_chat_left(gc, cc->id); + + /* Destroy the chat_connection */ + od->oscar_chats = g_slist_remove(od->oscar_chats, cc); + if (cc->inpa > 0) + gaim_input_remove(cc->inpa); + aim_conn_kill(od->sess, &cc->conn); + g_free(cc->name); + g_free(cc->show); + g_free(cc); +} + +void oscar_chat_leave(struct gaim_connection * gc, int id) +{ + struct chat_connection * ccon = find_oscar_chat(gc, id); + + if(ccon == NULL) + return; + + oscar_chat_kill(gc, ccon); +} + +int oscar_chat_join(struct gaim_connection * gc, char * name) +{ + struct oscar_data * od = (struct oscar_data *)gc->proto_data; + + aim_conn_t * cur; + + if((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { + + return (aim_chatnav_createroom(od->sess, cur, name, 4) == 0); + + } else { + struct create_room * cr = g_new0(struct create_room, 1); + cr->exchange = 4; + cr->name = g_strdup(name); + od->create_rooms = g_slist_append(od->create_rooms, cr); + aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); + return 1; + } +} + +int oscar_chat_open(struct gaim_connection * gc, char *who) +{ + struct oscar_data * od = (struct oscar_data *)gc->proto_data; + + static int chat_id = 0; + char * chatname = g_new0(char, strlen(gc->username)+4); + g_snprintf(chatname, strlen(gc->username) + 4, "%s%d", gc->username, chat_id++); + + int ret = oscar_chat_join(gc, chatname); + + aim_chat_invite(od->sess, od->conn, who, "", 4, chatname, 0x0); + + g_free(chatname); + + return ret; +} + +void oscar_accept_chat(gpointer w, struct aim_chat_invitation * inv) +{ + oscar_chat_join(inv->gc, inv->name); + g_free(inv->name); + g_free(inv); +} + +void oscar_reject_chat(gpointer w, struct aim_chat_invitation * inv) +{ + g_free(inv->name); + g_free(inv); +} + static struct prpl *my_protocol = NULL; void oscar_init(struct prpl *ret) { @@ -2496,6 +2636,10 @@ void oscar_init(struct prpl *ret) { ret->get_away = oscar_get_away; ret->add_buddy = oscar_add_buddy; ret->remove_buddy = oscar_remove_buddy; + ret->chat_send = oscar_chat_send; + ret->chat_invite = oscar_chat_invite; + ret->chat_leave = oscar_chat_leave; + ret->chat_open = oscar_chat_open; ret->add_permit = oscar_add_permit; ret->add_deny = oscar_add_deny; ret->rem_permit = oscar_rem_permit; diff --git a/protocols/oscar/tlv.c b/protocols/oscar/tlv.c index 11b89758..9d827caf 100644 --- a/protocols/oscar/tlv.c +++ b/protocols/oscar/tlv.c @@ -339,6 +339,31 @@ int aim_addtlvtochain_frozentlvlist(aim_tlvlist_t **list, guint16 type, aim_tlvl return buflen; } +int aim_addtlvtochain_chatroom(aim_tlvlist_t **list, guint16 type, guint16 exchange, const char *roomname, guint16 instance) +{ + guint8 *buf; + int buflen; + aim_bstream_t bs; + + buflen = 2 + 1 + strlen(roomname) + 2; + + if (!(buf = g_malloc(buflen))) + return 0; + + aim_bstream_init(&bs, buf, buflen); + + aimbs_put16(&bs, exchange); + aimbs_put8(&bs, strlen(roomname)); + aimbs_putraw(&bs, (guint8 *)roomname, strlen(roomname)); + aimbs_put16(&bs, instance); + + aim_addtlvtochain_raw(list, type, aim_bstream_curpos(&bs), buf); + + g_free(buf); + + return 0; +} + /** * aim_writetlvchain - Write a TLV chain into a data buffer. * @buf: Destination buffer -- cgit v1.2.3 From c3ffa45876c584d3e86c0796f2210538bcebc377 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 6 Dec 2005 22:55:09 +0100 Subject: Add some const --- protocols/proxy.c | 22 ++++++---------------- protocols/proxy.h | 2 +- 2 files changed, 7 insertions(+), 17 deletions(-) (limited to 'protocols') diff --git a/protocols/proxy.c b/protocols/proxy.c index fb87e356..0546f2d7 100644 --- a/protocols/proxy.c +++ b/protocols/proxy.c @@ -49,16 +49,6 @@ #define GAIM_WRITE_COND (G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL) #define GAIM_ERR_COND (G_IO_HUP | G_IO_ERR | G_IO_NVAL) -/*FIXME* - #ifndef _WIN32 - if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { - closesocket(fd); - g_free(phb); - return -1; - } - fcntl(fd, F_SETFL, 0); -#endif*/ - char proxyhost[128] = ""; int proxyport = 0; int proxytype = PROXY_NONE; @@ -82,7 +72,7 @@ typedef struct _GaimIOClosure { -static struct sockaddr_in *gaim_gethostbyname(char *host, int port) +static struct sockaddr_in *gaim_gethostbyname(const char *host, int port) { static struct sockaddr_in sin; @@ -153,7 +143,7 @@ static void gaim_io_connected(gpointer data, gint source, GaimInputCondition con } } -static int proxy_connect_none(char *host, unsigned short port, struct PHB *phb) +static int proxy_connect_none(const char *host, unsigned short port, struct PHB *phb) { struct sockaddr_in *sin; int fd = -1; @@ -280,7 +270,7 @@ static void http_canwrite(gpointer data, gint source, GaimInputCondition cond) phb->inpa = gaim_input_add(source, GAIM_INPUT_READ, http_canread, phb); } -static int proxy_connect_http(char *host, unsigned short port, struct PHB *phb) +static int proxy_connect_http(const char *host, unsigned short port, struct PHB *phb) { phb->host = g_strdup(host); phb->port = port; @@ -364,7 +354,7 @@ static void s4_canwrite(gpointer data, gint source, GaimInputCondition cond) phb->inpa = gaim_input_add(source, GAIM_INPUT_READ, s4_canread, phb); } -static int proxy_connect_socks4(char *host, unsigned short port, struct PHB *phb) +static int proxy_connect_socks4(const char *host, unsigned short port, struct PHB *phb) { phb->host = g_strdup(host); phb->port = port; @@ -546,7 +536,7 @@ static void s5_canwrite(gpointer data, gint source, GaimInputCondition cond) phb->inpa = gaim_input_add(source, GAIM_INPUT_READ, s5_canread, phb); } -static int proxy_connect_socks5(char *host, unsigned short port, struct PHB *phb) +static int proxy_connect_socks5(const char *host, unsigned short port, struct PHB *phb) { phb->host = g_strdup(host); phb->port = port; @@ -587,7 +577,7 @@ void gaim_input_remove(gint tag) g_source_remove(tag); } -int proxy_connect(char *host, int port, GaimInputFunction func, gpointer data) +int proxy_connect(const char *host, int port, GaimInputFunction func, gpointer data) { struct PHB *phb; diff --git a/protocols/proxy.h b/protocols/proxy.h index 7c34fc40..47c966d2 100644 --- a/protocols/proxy.h +++ b/protocols/proxy.h @@ -55,6 +55,6 @@ typedef void (*GaimInputFunction)(gpointer, gint, GaimInputCondition); G_MODULE_EXPORT gint gaim_input_add(int, GaimInputCondition, GaimInputFunction, gpointer); G_MODULE_EXPORT void gaim_input_remove(gint); -G_MODULE_EXPORT int proxy_connect(char *host, int port, GaimInputFunction func, gpointer data); +G_MODULE_EXPORT int proxy_connect(const char *host, int port, GaimInputFunction func, gpointer data); #endif /* _PROXY_H_ */ -- cgit v1.2.3 From 11e090b246a86deb7b882217772b90fc52d7e4f6 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 15 Dec 2005 10:14:38 +0100 Subject: Moved variable declarations to the right place to make older compilers happy. --- protocols/oscar/oscar.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'protocols') diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c index 240bab14..488e80d1 100644 --- a/protocols/oscar/oscar.c +++ b/protocols/oscar/oscar.c @@ -1087,16 +1087,15 @@ static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_ char *name = extract_name(args->info.chat.roominfo.name); int *exch = g_new0(int, 1); GList *m = NULL; + char txt[1024]; + struct aim_chat_invitation * inv = g_new0(struct aim_chat_invitation, 1); + m = g_list_append(m, g_strdup(name ? name : args->info.chat.roominfo.name)); *exch = args->info.chat.roominfo.exchange; m = g_list_append(m, exch); - char txt[1024]; - g_snprintf( txt, 1024, "Got an invitation to chatroom %s from %s: %s", name, userinfo->sn, args->msg ); - struct aim_chat_invitation * inv = g_new0(struct aim_chat_invitation, 1); - inv->gc = gc; inv->exchange = *exch; inv->name = g_strdup(name); @@ -2505,13 +2504,12 @@ int oscar_chat_send(struct gaim_connection * gc, int id, char *message) { struct oscar_data * od = (struct oscar_data*)gc->proto_data; struct chat_connection * ccon; - - if(!(ccon = find_oscar_chat(gc, id))) - return -1; - int ret; guint8 len = strlen(message); char *s; + + if(!(ccon = find_oscar_chat(gc, id))) + return -1; for (s = message; *s; s++) if (*s & 128) @@ -2606,12 +2604,13 @@ int oscar_chat_join(struct gaim_connection * gc, char * name) int oscar_chat_open(struct gaim_connection * gc, char *who) { struct oscar_data * od = (struct oscar_data *)gc->proto_data; - + int ret; static int chat_id = 0; char * chatname = g_new0(char, strlen(gc->username)+4); + g_snprintf(chatname, strlen(gc->username) + 4, "%s%d", gc->username, chat_id++); - int ret = oscar_chat_join(gc, chatname); + ret = oscar_chat_join(gc, chatname); aim_chat_invite(od->sess, od->conn, who, "", 4, chatname, 0x0); -- cgit v1.2.3