aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/twitter
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/twitter')
-rw-r--r--protocols/twitter/twitter.c9
-rw-r--r--protocols/twitter/twitter.h6
-rw-r--r--protocols/twitter/twitter_lib.c24
3 files changed, 29 insertions, 10 deletions
diff --git a/protocols/twitter/twitter.c b/protocols/twitter/twitter.c
index b619b1e5..41ab8467 100644
--- a/protocols/twitter/twitter.c
+++ b/protocols/twitter/twitter.c
@@ -575,6 +575,8 @@ static void twitter_init(account_t * acc)
s = set_add(&acc->set, "strip_newlines", "false", set_eval_bool, acc);
+ s = set_add(&acc->set, "long_ids", "false", set_eval_bool, acc);
+
s = set_add(&acc->set, "_last_tweet", "0", NULL, acc);
s->flags |= SET_HIDDEN | SET_NOSAVE;
@@ -652,7 +654,10 @@ static void twitter_login(account_t * acc)
imcb_add_buddy(ic, name, NULL);
imcb_buddy_status(ic, name, OPT_LOGGED_IN, NULL, NULL);
- td->log = g_new0(struct twitter_log_data, TWITTER_LOG_LENGTH);
+ td->long_ids = set_getbool(&ic->acc->set, "long_ids");
+ td->log_length = (td->long_ids) ? TWITTER_LONG_LOG_LENGTH : TWITTER_SHORT_LOG_LENGTH;
+
+ td->log = g_new0(struct twitter_log_data, td->log_length);
td->log_id = -1;
s = set_getstr(&ic->acc->set, "mode");
@@ -891,7 +896,7 @@ static guint64 twitter_message_id_from_command_arg(struct im_connection *ic, cha
if (arg[0] == '#') {
arg++;
}
- if (parse_int64(arg, 16, &id) && id < TWITTER_LOG_LENGTH) {
+ if (parse_int64(arg, 16, &id) && id < td->log_length) {
bu = td->log[id].bu;
id = td->log[id].id;
} else if (parse_int64(arg, 10, &id)) {
diff --git a/protocols/twitter/twitter.h b/protocols/twitter/twitter.h
index 5a1a4f63..3978c6fc 100644
--- a/protocols/twitter/twitter.h
+++ b/protocols/twitter/twitter.h
@@ -82,6 +82,9 @@ struct twitter_data {
/* set show_ids */
struct twitter_log_data *log;
int log_id;
+
+ gboolean long_ids;
+ int log_length;
};
#define TWITTER_FILTER_UPDATE_WAIT 3000
@@ -97,7 +100,8 @@ struct twitter_user_data {
time_t last_time;
};
-#define TWITTER_LOG_LENGTH 256
+#define TWITTER_SHORT_LOG_LENGTH 256
+#define TWITTER_LONG_LOG_LENGTH (256 * 256)
struct twitter_log_data {
guint64 id;
/* DANGER: bu can be a dead pointer. Check it first.
diff --git a/protocols/twitter/twitter_lib.c b/protocols/twitter/twitter_lib.c
index 40adb992..be3201a9 100644
--- a/protocols/twitter/twitter_lib.c
+++ b/protocols/twitter/twitter_lib.c
@@ -673,7 +673,7 @@ static char *twitter_msg_add_id(struct im_connection *ic,
if (txs->reply_to) {
int i;
- for (i = 0; i < TWITTER_LOG_LENGTH; i++) {
+ for (i = 0; i < td->log_length; i++) {
if (td->log[i].id == txs->reply_to) {
reply_to = i;
break;
@@ -691,7 +691,7 @@ static char *twitter_msg_add_id(struct im_connection *ic,
}
}
- td->log_id = (td->log_id + 1) % TWITTER_LOG_LENGTH;
+ td->log_id = (td->log_id + 1) % td->log_length;
td->log[td->log_id].id = txs->id;
td->log[td->log_id].bu = bee_user_by_handle(ic->bee, ic, txs->user->screen_name);
@@ -706,11 +706,21 @@ static char *twitter_msg_add_id(struct im_connection *ic,
if (set_getbool(&ic->acc->set, "show_ids")) {
if (reply_to != -1) {
- return g_strdup_printf("\002[\002%02x->%02x\002]\002 %s%s",
- td->log_id, reply_to, prefix, txs->text);
+ if (td->long_ids) {
+ return g_strdup_printf("\002[\002%04x->%04x\002]\002 %s%s",
+ td->log_id, reply_to, prefix, txs->text);
+ } else {
+ return g_strdup_printf("\002[\002%02x->%02x\002]\002 %s%s",
+ td->log_id, reply_to, prefix, txs->text);
+ }
} else {
- return g_strdup_printf("\002[\002%02x\002]\002 %s%s",
- td->log_id, prefix, txs->text);
+ if (td->long_ids) {
+ return g_strdup_printf("\002[\002%04x\002]\002 %s%s",
+ td->log_id, prefix, txs->text);
+ } else {
+ return g_strdup_printf("\002[\002%02x\002]\002 %s%s",
+ td->log_id, prefix, txs->text);
+ }
}
} else {
if (*prefix) {
@@ -961,7 +971,7 @@ static gboolean twitter_stream_handle_status(struct im_connection *ic, struct tw
struct twitter_data *td = ic->proto_data;
int i;
- for (i = 0; i < TWITTER_LOG_LENGTH; i++) {
+ for (i = 0; i < td->log_length; i++) {
if (td->log[i].id == txs->id) {
/* Got a duplicate (RT, probably). Drop it. */
return TRUE;