diff options
-rw-r--r-- | protocols/twitter/twitter.c | 10 | ||||
-rw-r--r-- | protocols/twitter/twitter_lib.c | 39 |
2 files changed, 12 insertions, 37 deletions
diff --git a/protocols/twitter/twitter.c b/protocols/twitter/twitter.c index fb7acc12..d4e2ce3e 100644 --- a/protocols/twitter/twitter.c +++ b/protocols/twitter/twitter.c @@ -35,8 +35,8 @@ gboolean twitter_main_loop(gpointer data, gint fd, b_input_condition cond) struct im_connection *ic = data; // Check if we are still logged in... // We are logged in if the flag says so and the connection is still in the connections list. - if ((ic->flags & OPT_LOGGED_IN) != OPT_LOGGED_IN - && !g_slist_find( twitter_connections, ic )) + if (!g_slist_find( twitter_connections, ic ) || + (ic->flags & OPT_LOGGED_IN) != OPT_LOGGED_IN) return 0; // If the user uses multiple private message windows we need to get the @@ -68,13 +68,15 @@ static void twitter_login( account_t *acc ) struct im_connection *ic = imcb_new( acc ); struct twitter_data *td = g_new0( struct twitter_data, 1 ); + twitter_connections = g_slist_append( twitter_connections, ic ); + td->user = acc->user; td->pass = acc->pass; td->home_timeline_id = 0; ic->proto_data = td; - imcb_log( ic, "Connecting to twitter" ); + imcb_log( ic, "Connecting to Twitter" ); imcb_connected(ic); // Run this once. After this queue the main loop function. @@ -83,8 +85,6 @@ static void twitter_login( account_t *acc ) // Queue the main_loop // Save the return value, so we can remove the timeout on logout. td->main_loop_id = b_timeout_add(60000, twitter_main_loop, ic); - - twitter_connections = g_slist_append( twitter_connections, ic ); } /** diff --git a/protocols/twitter/twitter_lib.c b/protocols/twitter/twitter_lib.c index 53cbe643..50f614a7 100644 --- a/protocols/twitter/twitter_lib.c +++ b/protocols/twitter/twitter_lib.c @@ -36,8 +36,6 @@ #define TXL_USER 2 #define TXL_ID 3 -static void twitter_imcb_chat_msg( struct groupchat *c, char *who, char *msg, uint32_t flags, time_t sent_at ); - struct twitter_xml_list { int type; int next_cursor; @@ -100,7 +98,7 @@ static void txl_free(struct twitter_xml_list *txl) static void twitter_add_buddy(struct im_connection *ic, char *name) { // Check if the buddy is allready in the buddy list. - if (!user_findhandle( ic, name )) + if (!imcb_find_buddy( ic, name )) { // The buddy is not in the list, add the buddy and set the status to logged in. imcb_add_buddy( ic, name, NULL ); @@ -408,8 +406,13 @@ static void twitter_groupchat(struct im_connection *ic, GSList *list) { status = l->data; twitter_add_buddy(ic, status->user->screen_name); + // Say it! - twitter_imcb_chat_msg (gc, status->user->screen_name, status->text, 0, 0 ); + if (g_strcasecmp(td->user, status->user->screen_name) == 0) + imcb_chat_log (gc, "Your Tweet: %s", status->text); + else + imcb_chat_msg (gc, status->user->screen_name, status->text, 0, 0 ); + // Update the home_timeline_id to hold the highest id, so that by the next request // we won't pick up the updates allready in the list. td->home_timeline_id = td->home_timeline_id < status->id ? status->id : td->home_timeline_id; @@ -596,31 +599,3 @@ void twitter_direct_messages_new(struct im_connection *ic, char *who, char *msg) // g_free(args[1]); // g_free(args[3]); } - - -/** - * This function "overwrites" the imcb_chat_msg function. Because in the original the logged in user is filtered out. - */ -static void twitter_imcb_chat_msg( struct groupchat *c, char *who, char *msg, uint32_t flags, time_t sent_at ) -{ - struct im_connection *ic = c->ic; - char *wrapped; - user_t *u; - - u = user_findhandle( ic, who ); - if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) - || ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) ) - strip_html( msg ); - - wrapped = word_wrap( msg, 425 ); - if( c && u ) - { - irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, "", wrapped ); - } - else - { - imcb_log( ic, "Message from/to conversation %s@%p (unknown conv/user): %s", who, c, wrapped ); - } - g_free( wrapped ); -} - |