Changeset ffcdf13 for protocols/twitter
- Timestamp:
- 2010-07-17T15:06:56Z (14 years ago)
- Branches:
- master
- Children:
- 5c18a76
- Parents:
- 0d691ea
- Location:
- protocols/twitter
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/twitter/twitter.c
r0d691ea rffcdf13 119 119 } 120 120 121 sprintf( name, " twitter_%s", ic->acc->user );121 sprintf( name, "%s_%s", td->prefix, 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.", … … 172 172 { 173 173 set_t *s; 174 175 s = set_add( &acc->set, "base_url", TWITTER_API_URL, NULL, acc ); 174 char *def_url; 175 char *def_oauth; 176 177 if( strcmp( acc->prpl->name, "twitter" ) == 0 ) 178 { 179 def_url = TWITTER_API_URL; 180 def_oauth = "true"; 181 } 182 else /* if( strcmp( acc->prpl->name, "identica" ) == 0 ) */ 183 { 184 def_url = IDENTICA_API_URL; 185 def_oauth = "false"; 186 } 187 188 s = set_add( &acc->set, "base_url", def_url, NULL, acc ); 176 189 s->flags |= ACC_SET_OFFLINE_ONLY; 177 190 … … 181 194 s->flags |= ACC_SET_OFFLINE_ONLY; 182 195 183 s = set_add( &acc->set, "oauth", "true", set_eval_bool, acc );196 s = set_add( &acc->set, "oauth", def_oauth, set_eval_bool, acc ); 184 197 } 185 198 … … 214 227 else 215 228 td->url_path = g_strdup( "" ); 229 if( g_str_has_suffix( url.host, ".com" ) ) 230 td->prefix = g_strndup( url.host, strlen( url.host ) - 4 ); 231 else 232 td->prefix = g_strdup( url.host ); 216 233 217 234 td->user = acc->user; … … 219 236 td->oauth_info = oauth_from_string( acc->pass, &twitter_oauth ); 220 237 221 sprintf( name, " twitter_%s", acc->user );238 sprintf( name, "%s_%s", td->prefix, acc->user ); 222 239 imcb_add_buddy( ic, name, NULL ); 223 240 imcb_buddy_status( ic, name, OPT_LOGGED_IN, NULL, NULL ); … … 247 264 { 248 265 oauth_info_free( td->oauth_info ); 266 g_free( td->prefix ); 249 267 g_free( td->url_host ); 250 268 g_free( td->url_path ); … … 262 280 { 263 281 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) 282 int plen = strlen( td->prefix ); 283 284 if (g_strncasecmp(who, td->prefix, plen) == 0 && who[plen] == '_' && 285 g_strcasecmp(who + plen + 1, ic->acc->user) == 0) 267 286 { 268 287 if( set_getbool( &ic->acc->set, "oauth" ) && … … 416 435 ret->send_typing = twitter_send_typing; 417 436 ret->handle_cmp = g_strcasecmp; 418 437 438 register_protocol(ret); 439 440 /* And an identi.ca variant: */ 441 ret = g_memdup(ret, sizeof(struct prpl)); 442 ret->name = "identica"; 419 443 register_protocol(ret); 420 444 … … 422 446 twitter_connections = NULL; 423 447 } 424 -
protocols/twitter/twitter.h
r0d691ea rffcdf13 53 53 char *url_host; 54 54 char *url_path; 55 56 char *prefix; /* Used to generate contact + channel name. */ 55 57 }; 56 58 -
protocols/twitter/twitter_lib.c
r0d691ea rffcdf13 459 459 td->home_timeline_gc = gc = imcb_chat_new( ic, "home/timeline" ); 460 460 461 name_hint = g_strdup_printf( " Twitter_%s", ic->acc->user );461 name_hint = g_strdup_printf( "%s_%s", td->prefix, ic->acc->user ); 462 462 imcb_chat_name_hint( gc, name_hint ); 463 463 g_free( name_hint ); … … 519 519 if( mode_one ) 520 520 { 521 g_snprintf( from, sizeof( from ) - 1, " twitter_%s", ic->acc->user );521 g_snprintf( from, sizeof( from ) - 1, "%s_%s", td->prefix, ic->acc->user ); 522 522 from[MAX_STRING-1] = '\0'; 523 523 } -
protocols/twitter/twitter_lib.h
r0d691ea rffcdf13 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 */
Note: See TracChangeset
for help on using the changeset viewer.