diff options
| -rw-r--r-- | lib/http_client.h | 2 | ||||
| -rw-r--r-- | protocols/twitter/twitter_http.c | 9 | ||||
| -rw-r--r-- | protocols/twitter/twitter_http.h | 8 | ||||
| -rw-r--r-- | protocols/twitter/twitter_lib.c | 16 | 
4 files changed, 30 insertions, 5 deletions
| diff --git a/lib/http_client.h b/lib/http_client.h index 48b711a4..e2c0319a 100644 --- a/lib/http_client.h +++ b/lib/http_client.h @@ -41,6 +41,8 @@ typedef enum http_client_flags  {  	HTTPC_STREAMING = 1,  	HTTPC_EOF = 2, +	 +	/* Let's reserve 0x1000000+ for lib users. */  } http_client_flags_t;  /* Your callback function should look like this: */ diff --git a/protocols/twitter/twitter_http.c b/protocols/twitter/twitter_http.c index 216dad9e..0f1ab518 100644 --- a/protocols/twitter/twitter_http.c +++ b/protocols/twitter/twitter_http.c @@ -134,6 +134,15 @@ struct http_request *twitter_http(struct im_connection *ic, char *url_string, ht  	return ret;  } +struct http_request *twitter_http_f(struct im_connection *ic, char *url_string, http_input_function func, +		                    gpointer data, int is_post, char **arguments, int arguments_len, twitter_http_flags_t flags) +{ +	struct http_request *ret = twitter_http(ic, url_string, func, data, is_post, arguments, arguments_len); +	if (ret) +		ret->flags |= flags; +	return ret; +} +  static char *twitter_url_append(char *url, char *key, char *value)  {  	char *key_encoded = g_strndup(key, 3 * strlen(key)); diff --git a/protocols/twitter/twitter_http.h b/protocols/twitter/twitter_http.h index 02a7ea43..09ef350c 100644 --- a/protocols/twitter/twitter_http.h +++ b/protocols/twitter/twitter_http.h @@ -27,10 +27,18 @@  #include "nogaim.h"  #include "http_client.h" +typedef enum { +	/* With this set, twitter_http_post() will post a generic confirmation +	   message to the user. */ +	TWITTER_HTTP_USER_ACK = 0x1000000, +} twitter_http_flags_t; +  struct oauth_info;  struct http_request *twitter_http(struct im_connection *ic, char *url_string, http_input_function func,                                    gpointer data, int is_post, char** arguments, int arguments_len); +struct http_request *twitter_http_f(struct im_connection *ic, char *url_string, http_input_function func, +                                    gpointer data, int is_post, char** arguments, int arguments_len, twitter_http_flags_t flags);  #endif //_TWITTER_HTTP_H diff --git a/protocols/twitter/twitter_lib.c b/protocols/twitter/twitter_lib.c index f4c81e0c..c7041a68 100644 --- a/protocols/twitter/twitter_lib.c +++ b/protocols/twitter/twitter_lib.c @@ -1166,6 +1166,9 @@ static void twitter_http_post(struct http_request *req)  	}  	json_value_free(parsed); +	 +	if (req->flags & TWITTER_HTTP_USER_ACK) +		twitter_log(ic, "Command processed successfully");  }  /** @@ -1212,7 +1215,8 @@ void twitter_status_destroy(struct im_connection *ic, guint64 id)  	char *url;  	url = g_strdup_printf("%s%llu%s", TWITTER_STATUS_DESTROY_URL,  	                      (unsigned long long) id, ".json"); -	twitter_http(ic, url, twitter_http_post, ic, 1, NULL, 0); +	twitter_http_f(ic, url, twitter_http_post, ic, 1, NULL, 0, +	               TWITTER_HTTP_USER_ACK);  	g_free(url);  } @@ -1221,7 +1225,8 @@ void twitter_status_retweet(struct im_connection *ic, guint64 id)  	char *url;  	url = g_strdup_printf("%s%llu%s", TWITTER_STATUS_RETWEET_URL,  	                      (unsigned long long) id, ".json"); -	twitter_http(ic, url, twitter_http_post, ic, 1, NULL, 0); +	twitter_http_f(ic, url, twitter_http_post, ic, 1, NULL, 0, +	               TWITTER_HTTP_USER_ACK);  	g_free(url);  } @@ -1235,8 +1240,8 @@ void twitter_report_spam(struct im_connection *ic, char *screen_name)  		NULL,  	};  	args[1] = screen_name; -	twitter_http(ic, TWITTER_REPORT_SPAM_URL, twitter_http_post, -	             ic, 1, args, 2); +	twitter_http_f(ic, TWITTER_REPORT_SPAM_URL, twitter_http_post, +	               ic, 1, args, 2, TWITTER_HTTP_USER_ACK);  }  /** @@ -1247,6 +1252,7 @@ void twitter_favourite_tweet(struct im_connection *ic, guint64 id)  	char *url;  	url = g_strdup_printf("%s%llu%s", TWITTER_FAVORITE_CREATE_URL,  	                      (unsigned long long) id, ".json"); -	twitter_http(ic, url, twitter_http_post, ic, 1, NULL, 0); +	twitter_http_f(ic, url, twitter_http_post, ic, 1, NULL, 0, +	               TWITTER_HTTP_USER_ACK);  	g_free(url);  } | 
