=== modified file 'protocols/twitter/Makefile'
|
|
|
23 | 23 | lcov: check |
24 | 24 | gcov: |
25 | 25 | gcov *.c |
26 | | |
| 26 | |
27 | 27 | .PHONY: all clean distclean |
28 | 28 | |
29 | 29 | clean: |
… |
… |
|
42 | 42 | twitter_mod.o: $(objects) |
43 | 43 | @echo '*' Linking twitter_mod.o |
44 | 44 | @$(LD) $(LFLAGS) $(objects) -o twitter_mod.o |
45 | | |
46 | | |
=== modified file 'protocols/twitter/twitter.c'
|
|
|
118 | 118 | return FALSE; |
119 | 119 | } |
120 | 120 | |
121 | | sprintf( name, "twitter_%s", ic->acc->user ); |
| 121 | sprintf( name, "%s_%s", td->host, ic->acc->user ); |
122 | 122 | msg = g_strdup_printf( "To finish OAuth authentication, please visit " |
123 | 123 | "%s and respond with the resulting PIN code.", |
124 | 124 | info->auth_url ); |
… |
… |
|
183 | 183 | s = set_add( &acc->set, "oauth", "true", set_eval_bool, acc ); |
184 | 184 | } |
185 | 185 | |
| 186 | static void identica_init( account_t *acc ) |
| 187 | { |
| 188 | set_t *s; |
| 189 | |
| 190 | s = set_add( &acc->set, "base_url", IDENTICA_API_URL, NULL, acc ); |
| 191 | s->flags |= ACC_SET_OFFLINE_ONLY; |
| 192 | |
| 193 | s = set_add( &acc->set, "message_length", "140", set_eval_int, acc ); |
| 194 | |
| 195 | s = set_add( &acc->set, "mode", "one", set_eval_mode, acc ); |
| 196 | s->flags |= ACC_SET_OFFLINE_ONLY; |
| 197 | |
| 198 | s = set_add( &acc->set, "oauth", "false", set_eval_bool, acc ); |
| 199 | } |
| 200 | |
186 | 201 | /** |
187 | 202 | * Login method. Since the twitter API works with seperate HTTP request we |
188 | 203 | * only save the user and pass to the twitter_data object. |
… |
… |
|
213 | 228 | td->url_path = g_strdup( url.file ); |
214 | 229 | else |
215 | 230 | td->url_path = g_strdup( "" ); |
| 231 | if( g_str_has_suffix( url.host, ".com" ) ) |
| 232 | td->host = g_strndup ( url.host, strlen( url.host ) - 4 ); |
| 233 | else |
| 234 | td->host = g_strdup ( url.host ); |
216 | 235 | |
217 | 236 | td->user = acc->user; |
218 | 237 | if( strstr( acc->pass, "oauth_token=" ) ) |
219 | 238 | td->oauth_info = oauth_from_string( acc->pass, &twitter_oauth ); |
220 | 239 | |
221 | | sprintf( name, "twitter_%s", acc->user ); |
| 240 | sprintf( name, "%s_%s", td->host, acc->user ); |
222 | 241 | imcb_add_buddy( ic, name, NULL ); |
223 | 242 | imcb_buddy_status( ic, name, OPT_LOGGED_IN, NULL, NULL ); |
224 | 243 | |
… |
… |
|
246 | 265 | if( td ) |
247 | 266 | { |
248 | 267 | oauth_info_free( td->oauth_info ); |
| 268 | g_free( td->host ); |
249 | 269 | g_free( td->url_host ); |
250 | 270 | g_free( td->url_path ); |
251 | 271 | g_free( td->pass ); |
… |
… |
|
261 | 281 | static int twitter_buddy_msg( struct im_connection *ic, char *who, char *message, int away ) |
262 | 282 | { |
263 | 283 | struct twitter_data *td = ic->proto_data; |
264 | | |
265 | | if (g_strncasecmp(who, "twitter_", 8) == 0 && |
266 | | g_strcasecmp(who + 8, ic->acc->user) == 0) |
| 284 | gchar** s = g_strsplit(who, "_", 2); /* who has a value of "twitter.com_nick" */ |
| 285 | if (NULL != s && |
| 286 | g_strcasecmp(s[0], td->host) == 0 && |
| 287 | g_strcasecmp(s[1], ic->acc->user) == 0) |
267 | 288 | { |
268 | 289 | if( set_getbool( &ic->acc->set, "oauth" ) && |
269 | 290 | td->oauth_info && td->oauth_info->token == NULL ) |
… |
… |
|
418 | 439 | |
419 | 440 | register_protocol(ret); |
420 | 441 | |
| 442 | ret = g_new0(struct prpl, 1); |
| 443 | |
| 444 | ret->name = "identica"; |
| 445 | ret->login = twitter_login; |
| 446 | ret->init = identica_init; |
| 447 | ret->logout = twitter_logout; |
| 448 | ret->buddy_msg = twitter_buddy_msg; |
| 449 | ret->get_info = twitter_get_info; |
| 450 | ret->set_my_name = twitter_set_my_name; |
| 451 | ret->add_buddy = twitter_add_buddy; |
| 452 | ret->remove_buddy = twitter_remove_buddy; |
| 453 | ret->chat_msg = twitter_chat_msg; |
| 454 | ret->chat_invite = twitter_chat_invite; |
| 455 | ret->chat_leave = twitter_chat_leave; |
| 456 | ret->chat_with = twitter_chat_with; |
| 457 | ret->keepalive = twitter_keepalive; |
| 458 | ret->add_permit = twitter_add_permit; |
| 459 | ret->rem_permit = twitter_rem_permit; |
| 460 | ret->add_deny = twitter_add_deny; |
| 461 | ret->rem_deny = twitter_rem_deny; |
| 462 | ret->send_typing = twitter_send_typing; |
| 463 | ret->handle_cmp = g_strcasecmp; |
| 464 | |
| 465 | register_protocol(ret); |
| 466 | |
421 | 467 | // Initialise the twitter_connections GSList. |
422 | 468 | twitter_connections = NULL; |
423 | 469 | } |
424 | | |
=== modified file 'protocols/twitter/twitter.h'
|
|
|
52 | 52 | int url_port; |
53 | 53 | char *url_host; |
54 | 54 | char *url_path; |
| 55 | char *host; |
55 | 56 | }; |
56 | 57 | |
57 | 58 | /** |
=== modified file 'protocols/twitter/twitter_lib.c'
|
|
|
446 | 446 | |
447 | 447 | td->home_timeline_gc = gc = imcb_chat_new( ic, "home/timeline" ); |
448 | 448 | |
449 | | name_hint = g_strdup_printf( "Twitter_%s", ic->acc->user ); |
| 449 | name_hint = g_strdup_printf( "%s_%s", td->host, ic->acc->user ); |
450 | 450 | imcb_chat_name_hint( gc, name_hint ); |
451 | 451 | g_free( name_hint ); |
452 | 452 | } |
… |
… |
|
503 | 503 | |
504 | 504 | if( mode_one ) |
505 | 505 | { |
506 | | g_snprintf( from, sizeof( from ) - 1, "twitter_%s", ic->acc->user ); |
| 506 | g_snprintf( from, sizeof( from ) - 1, "%s_%s", td->host, ic->acc->user ); |
507 | 507 | from[MAX_STRING-1] = '\0'; |
508 | 508 | } |
509 | 509 | |
… |
… |
|
735 | 735 | args[0] = "screen_name"; |
736 | 736 | args[1] = who; |
737 | 737 | twitter_http(ic, create ? TWITTER_FRIENDSHIPS_CREATE_URL : TWITTER_FRIENDSHIPS_DESTROY_URL, twitter_http_post, ic, 1, args, 2); |
738 | | } |
739 | | No newline at end of file |
| 738 | } |
=== modified file 'protocols/twitter/twitter_lib.h'
|
|
|
29 | 29 | #include "twitter_http.h" |
30 | 30 | |
31 | 31 | #define TWITTER_API_URL "http://twitter.com" |
| 32 | #define IDENTICA_API_URL "http://identi.ca/api" |
32 | 33 | |
33 | 34 | /* Status URLs */ |
34 | 35 | #define TWITTER_STATUS_UPDATE_URL "/statuses/update.xml" |