aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/twitter/twitter.c
diff options
context:
space:
mode:
authorMarius Halden <marius.h@lden.org>2015-11-08 16:46:16 +0100
committerMarius Halden <marius.h@lden.org>2016-07-20 15:13:52 +0200
commit1deca055c89a52125f6a14bca40fcf4e8004be23 (patch)
treeaaa54b00a30a50a2a57a0c2303f1942fb3416cef /protocols/twitter/twitter.c
parentf60dc5cb68ac91df714f01ef61ba819eeac584aa (diff)
Add support for long tweet ids
Diffstat (limited to 'protocols/twitter/twitter.c')
-rw-r--r--protocols/twitter/twitter.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/protocols/twitter/twitter.c b/protocols/twitter/twitter.c
index b2039171..fa66fbe9 100644
--- a/protocols/twitter/twitter.c
+++ b/protocols/twitter/twitter.c
@@ -528,6 +528,15 @@ static char *set_eval_mode(set_t * set, char *value)
}
}
+static char *set_eval_long_ids(set_t * set, char *value)
+{
+ int len = atoi(value);
+ if (len >= 1 || len <= 4)
+ return value;
+
+ return SET_INVALID;
+}
+
static void twitter_init(account_t * acc)
{
set_t *s;
@@ -572,6 +581,9 @@ 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", "2", set_eval_long_ids, acc);
+ s->flags |= ACC_SET_OFFLINE_ONLY;
+
s = set_add(&acc->set, "_last_tweet", "0", NULL, acc);
s->flags |= SET_HIDDEN | SET_NOSAVE;
@@ -592,6 +604,7 @@ static void twitter_login(account_t * acc)
char name[strlen(acc->user) + 9];
url_t url;
char *s;
+ size_t i;
if (!url_set(&url, set_getstr(&ic->acc->set, "base_url")) ||
(url.proto != PROTO_HTTP && url.proto != PROTO_HTTPS)) {
@@ -649,7 +662,14 @@ 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->id_length = set_getint(&ic->acc->set, "long_ids");
+ td->log_length = 0;
+ for (i = 0; i < td->id_length; i++) {
+ td->log_length = (td->log_length << 4) + 0x0F;
+ }
+ td->log_length += 1;
+
+ td->log = g_new0(struct twitter_log_data, td->log_length);
td->log_id = -1;
s = set_getstr(&ic->acc->set, "mode");
@@ -894,7 +914,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)) {