aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/oscar
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/oscar')
-rw-r--r--protocols/oscar/aim.h13
-rw-r--r--protocols/oscar/oscar.c109
2 files changed, 82 insertions, 40 deletions
diff --git a/protocols/oscar/aim.h b/protocols/oscar/aim.h
index 9516996c..d1fc602a 100644
--- a/protocols/oscar/aim.h
+++ b/protocols/oscar/aim.h
@@ -143,6 +143,17 @@ struct client_info_s {
"en", \
}
+#define AIM_CLIENTINFO_KNOWNGOOD_5_1_3036 { \
+ "AOL Instant Messenger, version 5.1.3036/WIN32", \
+ 0x0109, \
+ 0x0005, \
+ 0x0001, \
+ 0x0000, \
+ 0x0bdc, \
+ "us", \
+ "en", \
+}
+
/*
* I would make 4.1.2010 the default, but they seem to have found
* an alternate way of breaking that one.
@@ -151,7 +162,7 @@ struct client_info_s {
* memory test, which may require you to have a WinAIM binary laying
* around. (see login.c::memrequest())
*/
-#define AIM_CLIENTINFO_KNOWNGOOD AIM_CLIENTINFO_KNOWNGOOD_3_5_1670
+#define AIM_CLIENTINFO_KNOWNGOOD AIM_CLIENTINFO_KNOWNGOOD_5_1_3036
#ifndef TRUE
#define TRUE 1
diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c
index 36e03166..f0e65f9a 100644
--- a/protocols/oscar/oscar.c
+++ b/protocols/oscar/oscar.c
@@ -90,7 +90,7 @@ struct oscar_data {
GSList *oscar_chats;
- gboolean killme;
+ gboolean killme, no_reconnect;
gboolean icq;
GSList *evilhack;
@@ -180,6 +180,7 @@ static struct chat_connection *find_oscar_chat_by_conn(struct im_connection *ic,
static int gaim_parse_auth_resp (aim_session_t *, aim_frame_t *, ...);
static int gaim_parse_login (aim_session_t *, aim_frame_t *, ...);
+static int gaim_parse_logout (aim_session_t *, aim_frame_t *, ...);
static int gaim_handle_redirect (aim_session_t *, aim_frame_t *, ...);
static int gaim_parse_oncoming (aim_session_t *, aim_frame_t *, ...);
static int gaim_parse_offgoing (aim_session_t *, aim_frame_t *, ...);
@@ -293,7 +294,7 @@ static gboolean oscar_callback(gpointer data, gint source,
if (aim_get_command(odata->sess, conn) >= 0) {
aim_rxdispatch(odata->sess);
if (odata->killme)
- imc_logout(ic, TRUE);
+ imc_logout(ic, !odata->no_reconnect);
} else {
if ((conn->type == AIM_CONN_TYPE_BOS) ||
!(aim_getconn_type(odata->sess, AIM_CONN_TYPE_BOS))) {
@@ -378,6 +379,8 @@ static void oscar_init(account_t *acc)
s = set_add( &acc->set, "web_aware", "false", set_eval_bool, acc );
s->flags |= ACC_SET_OFFLINE_ONLY;
}
+
+ acc->flags |= ACC_FLAG_AWAY_MESSAGE;
}
static void oscar_login(account_t *acc) {
@@ -519,6 +522,7 @@ static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) {
break;
case 0x18:
/* connecting too frequently */
+ od->no_reconnect = TRUE;
imcb_error(ic, _("You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer."));
break;
case 0x1c:
@@ -571,6 +575,7 @@ static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) {
aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_SRVACK, gaim_ssi_parseack, 0);
aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parseaiminfo, 0);
aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parsemtn, 0);
+ aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_parse_logout, 0);
((struct oscar_data *)ic->proto_data)->conn = bosconn;
for (i = 0; i < (int)strlen(info->bosip); i++) {
@@ -750,6 +755,30 @@ static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) {
return 1;
}
+static int gaim_parse_logout(aim_session_t *sess, aim_frame_t *fr, ...) {
+ struct im_connection *ic = sess->aux_data;
+ struct oscar_data *odata = ic->proto_data;
+ int code;
+ va_list ap;
+
+ va_start(ap, fr);
+ code = va_arg(ap, int);
+ va_end(ap);
+
+ imcb_error( ic, "Connection aborted by server: %s", code == 1 ?
+ "someone else logged in with your account" :
+ "unknown reason" );
+
+ /* Tell BitlBee to disable auto_reconnect if code == 1, since that
+ means a concurrent login somewhere else. */
+ odata->no_reconnect = code == 1;
+
+ /* DO NOT log out here! Just tell the callback to do it. */
+ odata->killme = TRUE;
+
+ return 1;
+}
+
static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) {
struct im_connection *ic = sess->aux_data;
struct chat_connection *chatcon;
@@ -1924,6 +1953,8 @@ static void oscar_get_away(struct im_connection *g, char *who) {
static void oscar_set_away_aim(struct im_connection *ic, struct oscar_data *od, const char *state, const char *message)
{
+ if (state == NULL)
+ state = "";
if (!g_strcasecmp(state, _("Visible"))) {
aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_NORMAL);
@@ -1931,15 +1962,16 @@ static void oscar_set_away_aim(struct im_connection *ic, struct oscar_data *od,
} else if (!g_strcasecmp(state, _("Invisible"))) {
aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_INVISIBLE);
return;
- } /* else... */
+ } else if (message == NULL) {
+ message = state;
+ }
if (od->rights.maxawaymsglen == 0)
imcb_error(ic, "oscar_set_away_aim called before locate rights received");
aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_NORMAL);
- if (ic->away)
- g_free(ic->away);
+ g_free(ic->away);
ic->away = NULL;
if (!message) {
@@ -1959,55 +1991,53 @@ static void oscar_set_away_aim(struct im_connection *ic, struct oscar_data *od,
static void oscar_set_away_icq(struct im_connection *ic, struct oscar_data *od, const char *state, const char *message)
{
- const char *msg = NULL;
+ const char *msg = NULL;
gboolean no_message = FALSE;
/* clean old states */
- if (ic->away) {
- g_free(ic->away);
- ic->away = NULL;
- }
+ g_free(ic->away);
+ ic->away = NULL;
od->sess->aim_icq_state = 0;
/* if no message, then use an empty message */
- if (message) {
- msg = message;
- } else {
- msg = "";
+ if (message) {
+ msg = message;
+ } else {
+ msg = "";
no_message = TRUE;
- }
+ }
- if (!g_strcasecmp(state, "Online")) {
+ if (state == NULL) {
aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_NORMAL);
} else if (!g_strcasecmp(state, "Away")) {
aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_AWAY);
- ic->away = g_strdup(msg);
+ ic->away = g_strdup(msg);
od->sess->aim_icq_state = AIM_MTYPE_AUTOAWAY;
} else if (!g_strcasecmp(state, "Do Not Disturb")) {
aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY);
- ic->away = g_strdup(msg);
+ ic->away = g_strdup(msg);
od->sess->aim_icq_state = AIM_MTYPE_AUTODND;
} else if (!g_strcasecmp(state, "Not Available")) {
aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY);
- ic->away = g_strdup(msg);
+ ic->away = g_strdup(msg);
od->sess->aim_icq_state = AIM_MTYPE_AUTONA;
} else if (!g_strcasecmp(state, "Occupied")) {
aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY);
- ic->away = g_strdup(msg);
+ ic->away = g_strdup(msg);
od->sess->aim_icq_state = AIM_MTYPE_AUTOBUSY;
} else if (!g_strcasecmp(state, "Free For Chat")) {
aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_CHAT);
- ic->away = g_strdup(msg);
+ ic->away = g_strdup(msg);
od->sess->aim_icq_state = AIM_MTYPE_AUTOFFC;
} else if (!g_strcasecmp(state, "Invisible")) {
aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_INVISIBLE);
- ic->away = g_strdup(msg);
- } else if (!g_strcasecmp(state, GAIM_AWAY_CUSTOM)) {
+ ic->away = g_strdup(msg);
+ } else {
if (no_message) {
aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_NORMAL);
} else {
aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_AWAY);
- ic->away = g_strdup(msg);
+ ic->away = g_strdup(msg);
od->sess->aim_icq_state = AIM_MTYPE_AUTOAWAY;
}
}
@@ -2019,7 +2049,7 @@ static void oscar_set_away(struct im_connection *ic, char *state, char *message)
{
struct oscar_data *od = (struct oscar_data *)ic->proto_data;
- oscar_set_away_aim(ic, od, state, message);
+ oscar_set_away_aim(ic, od, state, message);
if (od->icq)
oscar_set_away_icq(ic, od, state, message);
@@ -2251,20 +2281,21 @@ static void oscar_rem_deny(struct im_connection *ic, char *who) {
static GList *oscar_away_states(struct im_connection *ic)
{
struct oscar_data *od = ic->proto_data;
- GList *m = NULL;
- if (!od->icq)
- return g_list_append(m, GAIM_AWAY_CUSTOM);
-
- m = g_list_append(m, "Online");
- m = g_list_append(m, "Away");
- m = g_list_append(m, "Do Not Disturb");
- m = g_list_append(m, "Not Available");
- m = g_list_append(m, "Occupied");
- m = g_list_append(m, "Free For Chat");
- m = g_list_append(m, "Invisible");
-
- return m;
+ if (od->icq) {
+ static GList *m = NULL;
+ m = g_list_append(m, "Away");
+ m = g_list_append(m, "Do Not Disturb");
+ m = g_list_append(m, "Not Available");
+ m = g_list_append(m, "Occupied");
+ m = g_list_append(m, "Free For Chat");
+ m = g_list_append(m, "Invisible");
+ return m;
+ } else {
+ static GList *m = NULL;
+ m = g_list_append(m, "Away");
+ return m;
+ }
}
static int gaim_icqinfo(aim_session_t *sess, aim_frame_t *fr, ...)
@@ -2580,7 +2611,7 @@ void oscar_chat_leave(struct groupchat *c)
oscar_chat_kill(c->ic, c->data);
}
-struct groupchat *oscar_chat_join(struct im_connection * ic, char * room, char * nick, char * password )
+struct groupchat *oscar_chat_join(struct im_connection * ic, const char * room, const char * nick, const char * password )
{
struct oscar_data * od = (struct oscar_data *)ic->proto_data;
aim_conn_t * cur;