diff options
author | Marius Halden <marius.h@lden.org> | 2016-07-20 17:35:03 +0200 |
---|---|---|
committer | Marius Halden <marius.h@lden.org> | 2016-07-20 17:35:03 +0200 |
commit | 3e9c5977fcae168218e66b1fb6a503713ed0500a (patch) | |
tree | 8582c2fe23d22dd1519957ed0061e04f56fb590d /protocols | |
parent | f10e02c3db78cb1ebeef559c8094048904b7ec6c (diff) | |
parent | 1deca055c89a52125f6a14bca40fcf4e8004be23 (diff) |
Merge branch 'twitter_log' into patched-master
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/twitter/twitter.c | 20 | ||||
-rw-r--r-- | protocols/twitter/twitter.h | 4 | ||||
-rw-r--r-- | protocols/twitter/twitter_lib.c | 23 |
3 files changed, 23 insertions, 24 deletions
diff --git a/protocols/twitter/twitter.c b/protocols/twitter/twitter.c index 9017d3b3..b8e31035 100644 --- a/protocols/twitter/twitter.c +++ b/protocols/twitter/twitter.c @@ -552,6 +552,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; @@ -596,7 +605,7 @@ 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, "long_ids", "2", set_eval_long_ids, acc); s->flags |= ACC_SET_OFFLINE_ONLY; s = set_add(&acc->set, "channel_name", NULL, set_eval_channel_name, acc); @@ -622,6 +631,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)) { @@ -679,8 +689,12 @@ static void twitter_login(account_t * acc) imcb_add_buddy(ic, name, NULL); imcb_buddy_status(ic, name, OPT_LOGGED_IN, NULL, NULL); - 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->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->filter_log = g_new0(struct twitter_log_data, td->log_length); diff --git a/protocols/twitter/twitter.h b/protocols/twitter/twitter.h index 61afa4bb..6b7c0c0c 100644 --- a/protocols/twitter/twitter.h +++ b/protocols/twitter/twitter.h @@ -89,7 +89,7 @@ struct twitter_data { struct twitter_log_data *filter_log; int filter_log_id; - gboolean long_ids; + int id_length; int log_length; }; @@ -106,8 +106,6 @@ struct twitter_user_data { time_t last_time; }; -#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 bffd61aa..a1e969a1 100644 --- a/protocols/twitter/twitter_lib.c +++ b/protocols/twitter/twitter_lib.c @@ -835,25 +835,12 @@ static char *twitter_msg_add_id(struct im_connection *ic, if (set_getbool(&ic->acc->set, "show_ids")) { if (reply_to != -1) { - if (td->long_ids) { - return g_strdup_printf("\002[\002%04x->%04x\002]\002 %s%s", - txs->from_filter ? td->filter_log_id : td->log_id, - reply_to, prefix, txs->text); - } else { - return g_strdup_printf("\002[\002%02x->%02x\002]\002 %s%s", - txs->from_filter ? td->filter_log_id : td->log_id, - reply_to, prefix, txs->text); - } + return g_strdup_printf("\002[\002%0*x->%0*x\002]\002 %s%s", + td->id_length, td->log_id, td->id_length, + reply_to, prefix, txs->text); } else { - if (td->long_ids) { - return g_strdup_printf("\002[\002%04x\002]\002 %s%s", - txs->from_filter ? td->filter_log_id : td->log_id, - prefix, txs->text); - } else { - return g_strdup_printf("\002[\002%02x\002]\002 %s%s", - txs->from_filter ? td->filter_log_id : td->log_id, - prefix, txs->text); - } + return g_strdup_printf("\002[\002%0*x\002]\002 %s%s", + td->id_length, td->log_id, prefix, txs->text); } } else { if (*prefix) { |