aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/twitter/twitter.c
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/twitter/twitter.c')
-rw-r--r--protocols/twitter/twitter.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/protocols/twitter/twitter.c b/protocols/twitter/twitter.c
index db61ba7c..4626cf55 100644
--- a/protocols/twitter/twitter.c
+++ b/protocols/twitter/twitter.c
@@ -157,8 +157,13 @@ static const struct oauth_service *get_oauth_service(struct im_connection *ic)
static void twitter_oauth_start(struct im_connection *ic)
{
struct twitter_data *td = ic->proto_data;
+ const char *url = set_getstr(&ic->acc->set, "base_url");
imcb_log(ic, "Requesting OAuth request token");
+
+ if (!strstr(url, "twitter.com") && !strstr(url, "identi.ca"))
+ imcb_log(ic, "Warning: OAuth only works with identi.ca and "
+ "Twitter.");
td->oauth_info = oauth_request_token(get_oauth_service(ic), twitter_oauth_callback, ic);
@@ -177,7 +182,7 @@ static gboolean twitter_oauth_callback(struct oauth_info *info)
td = ic->proto_data;
if (info->stage == OAUTH_REQUEST_TOKEN) {
- char name[strlen(ic->acc->user) + 9], *msg;
+ char *name, *msg;
if (info->request_token == NULL) {
imcb_error(ic, "OAuth error: %s", twitter_parse_error(info->http));
@@ -185,11 +190,12 @@ static gboolean twitter_oauth_callback(struct oauth_info *info)
return FALSE;
}
- sprintf(name, "%s_%s", td->prefix, ic->acc->user);
+ name = g_strdup_printf("%s_%s", td->prefix, ic->acc->user);
msg = g_strdup_printf("To finish OAuth authentication, please visit "
"%s and respond with the resulting PIN code.",
info->auth_url);
imcb_buddy_msg(ic, name, msg, 0, 0);
+ g_free(name);
g_free(msg);
} else if (info->stage == OAUTH_ACCESS_TOKEN) {
const char *sn;
@@ -282,13 +288,16 @@ static void twitter_init(account_t * acc)
set_t *s;
char *def_url;
char *def_tul;
+ char *def_mentions;
if (strcmp(acc->prpl->name, "twitter") == 0) {
def_url = TWITTER_API_URL;
def_tul = "20";
+ def_mentions = "true";
} else { /* if( strcmp( acc->prpl->name, "identica" ) == 0 ) */
def_url = IDENTICA_API_URL;
def_tul = "0";
+ def_mentions = "false";
}
s = set_add(&acc->set, "auto_reply_timeout", "10800", set_eval_int, acc);
@@ -301,7 +310,7 @@ static void twitter_init(account_t * acc)
s = set_add(&acc->set, "fetch_interval", "60", set_eval_int, acc);
s->flags |= ACC_SET_OFFLINE_ONLY;
- s = set_add(&acc->set, "fetch_mentions", "true", set_eval_bool, acc);
+ s = set_add(&acc->set, "fetch_mentions", def_mentions, set_eval_bool, acc);
s = set_add(&acc->set, "message_length", "140", set_eval_int, acc);