diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2012-11-25 13:11:19 +0000 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2012-11-25 13:11:19 +0000 |
commit | 96dd574444f2c99bb0a82b2c354804f03e306f23 (patch) | |
tree | 4f1de4f9dcf6c27b5427016d5b846f68217bb3f4 | |
parent | 2cd8540c1076c3d0423abb1927bd47fdcbfbd382 (diff) |
s/twitter_msg/twitter_log/ and use it in a few more places.
-rw-r--r-- | protocols/twitter/twitter.c | 41 | ||||
-rw-r--r-- | protocols/twitter/twitter.h | 14 | ||||
-rw-r--r-- | protocols/twitter/twitter_lib.c | 4 |
3 files changed, 37 insertions, 22 deletions
diff --git a/protocols/twitter/twitter.c b/protocols/twitter/twitter.c index d6cc89f1..ee410abc 100644 --- a/protocols/twitter/twitter.c +++ b/protocols/twitter/twitter.c @@ -3,7 +3,7 @@ * BitlBee - An IRC to IM gateway * * Simple module to facilitate twitter functionality. * * * -* Copyright 2009 Geert Mulders <g.c.w.m.mulders@gmail.com> * +* Copyright 2009-2010 Geert Mulders <g.c.w.m.mulders@gmail.com> * * Copyright 2010-2012 Wilmer van der Gaast <wilmer@gaast.net> * * * * This library is free software; you can redistribute it and/or * @@ -29,17 +29,7 @@ #include "twitter_lib.h" #include "url.h" -#define twitter_msg( ic, fmt... ) \ - do { \ - struct twitter_data *td = ic->proto_data; \ - if( td->timeline_gc ) \ - imcb_chat_log( td->timeline_gc, fmt ); \ - else \ - imcb_log( ic, fmt ); \ - } while( 0 ); - GSList *twitter_connections = NULL; - /** * Main loop function */ @@ -244,7 +234,7 @@ static gboolean twitter_length_check(struct im_connection *ic, gchar * msg) if (max == 0 || (len = g_utf8_strlen(msg, -1) + url_len_diff) <= max) return TRUE; - imcb_error(ic, "Maximum message length exceeded: %d > %d", len, max); + twitter_log(ic, "Maximum message length exceeded: %d > %d", len, max); return FALSE; } @@ -560,7 +550,7 @@ static void twitter_handle_command(struct im_connection *ic, char *message) twitter_status_destroy(ic, id); } else - twitter_msg(ic, "Could not undo last action"); + twitter_log(ic, "Could not undo last action"); g_free(cmds); return; @@ -569,7 +559,7 @@ static void twitter_handle_command(struct im_connection *ic, char *message) if ((id = twitter_message_id_from_command_arg(ic, td, cmd[1]))) { twitter_favourite_tweet(ic, id); } else { - twitter_msg(ic, "Please provide a message ID or username."); + twitter_log(ic, "Please provide a message ID or username."); } g_free(cmds); return; @@ -606,7 +596,7 @@ static void twitter_handle_command(struct im_connection *ic, char *message) if (id) twitter_status_retweet(ic, id); else - twitter_msg(ic, "User `%s' does not exist or didn't " + twitter_log(ic, "User `%s' does not exist or didn't " "post any statuses recently", cmd[1]); g_free(cmds); @@ -637,7 +627,7 @@ static void twitter_handle_command(struct im_connection *ic, char *message) } if (!id || !bu) { - twitter_msg(ic, "User `%s' does not exist or didn't " + twitter_log(ic, "User `%s' does not exist or didn't " "post any statuses recently", cmd[1]); g_free(cmds); return; @@ -684,6 +674,25 @@ static void twitter_handle_command(struct im_connection *ic, char *message) g_free(cmds); } +void twitter_log(struct im_connection *ic, char *format, ... ) +{ + struct twitter_data *td = ic->proto_data; + va_list params; + char *text; + + va_start(params, format); + text = g_strdup_vprintf(format, params); + va_end(params); + + if (td->timeline_gc) + imcb_chat_log(td->timeline_gc, "%s", text); + else + imcb_log(ic, "%s", text); + + g_free(text); +} + + void twitter_initmodule() { struct prpl *ret = g_new0(struct prpl, 1); diff --git a/protocols/twitter/twitter.h b/protocols/twitter/twitter.h index f2afb754..108d20b3 100644 --- a/protocols/twitter/twitter.h +++ b/protocols/twitter/twitter.h @@ -3,7 +3,8 @@ * BitlBee - An IRC to IM gateway * * Simple module to facilitate twitter functionality. * * * -* Copyright 2009 Geert Mulders <g.c.w.m.mulders@gmail.com> * +* Copyright 2009-2010 Geert Mulders <g.c.w.m.mulders@gmail.com> * +* Copyright 2010-2012 Wilmer van der Gaast <wilmer@gaast.net> * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * @@ -34,10 +35,13 @@ typedef enum { - TWITTER_HAVE_FRIENDS = 1, + TWITTER_HAVE_FRIENDS = 0x00001, + TWITTER_MODE_ONE = 0x00002, + TWITTER_MODE_MANY = 0x00004, + TWITTER_MODE_CHAT = 0x00008, TWITTER_DOING_TIMELINE = 0x10000, - TWITTER_GOT_TIMELINE = 0x20000, - TWITTER_GOT_MENTIONS = 0x40000, + TWITTER_GOT_TIMELINE = 0x20000, + TWITTER_GOT_MENTIONS = 0x40000, } twitter_flags_t; struct twitter_log_data; @@ -99,4 +103,6 @@ void twitter_login_finish( struct im_connection *ic ); struct http_request; char *twitter_parse_error( struct http_request *req ); +void twitter_log(struct im_connection *ic, char *format, ... ); + #endif //_TWITTER_H diff --git a/protocols/twitter/twitter_lib.c b/protocols/twitter/twitter_lib.c index 676d804d..f358b307 100644 --- a/protocols/twitter/twitter_lib.c +++ b/protocols/twitter/twitter_lib.c @@ -219,8 +219,8 @@ static json_value *twitter_parse_response(struct im_connection *ic, struct http_ } else if (req->status_code != 200) { // It didn't go well, output the error and return. if (!periodic || logging_in || ++td->http_fails >= 5) - imcb_error(ic, "Could not retrieve %s: %s", - path, twitter_parse_error(req)); + twitter_log(ic, "Error: Could not retrieve %s: %s", + path, twitter_parse_error(req)); if (logging_in) imc_logout(ic, TRUE); |