- Timestamp:
- 2010-04-14T09:27:50Z (15 years ago)
- Branches:
- master
- Children:
- d33679e
- Parents:
- 81186cab (diff), 156bbd7 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- protocols
- Files:
-
- 7 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/jabber_util.c
r81186cab r21c87a7 671 671 time_t jabber_get_timestamp( struct xt_node *xt ) 672 672 { 673 struct tm tp, utc;674 673 struct xt_node *c; 675 time_t res, tres;676 674 char *s = NULL; 675 struct tm tp; 677 676 678 677 for( c = xt->children; ( c = xt_find_node( c, "x" ) ); c = c->next ) … … 692 691 tp.tm_year -= 1900; 693 692 tp.tm_mon --; 694 tp.tm_isdst = -1; /* GRRRRRRRRRRR */ 695 696 res = mktime( &tp ); 697 /* Problem is, mktime() just gave us the GMT timestamp for the 698 given local time... While the given time WAS NOT local. So 699 we should fix this now. 700 701 Now I could choose between messing with environment variables 702 (kludgy) or using timegm() (not portable)... Or doing the 703 following, which I actually prefer... */ 704 gmtime_r( &res, &utc ); 705 utc.tm_isdst = -1; /* Once more: GRRRRRRRRRRRRRRRRRR!!! */ 706 if( utc.tm_hour == tp.tm_hour && utc.tm_min == tp.tm_min ) 707 /* Sweet! We're in UTC right now... */ 708 return res; 709 710 tres = mktime( &utc ); 711 res += res - tres; 712 713 /* Yes, this is a hack. And it will go wrong around DST changes. 714 BUT this is more likely to be threadsafe than messing with 715 environment variables, and possibly more portable... */ 716 717 return res; 693 694 return mktime_utc( &tp ); 718 695 } 719 696 -
protocols/jabber/message.c
r81186cab r21c87a7 80 80 if( type && strcmp( type, "headline" ) == 0 ) 81 81 { 82 c = xt_find_node( node->children, "subject" );83 g_string_append_printf( fullmsg, "Headline: %s\n", c && c->text_len > 0 ? c->text : "");82 if( ( c = xt_find_node( node->children, "subject" ) ) && c->text_len > 0 ) 83 g_string_append_printf( fullmsg, "Headline: %s\n", c->text ); 84 84 85 85 /* <x xmlns="jabber:x:oob"><url>http://....</url></x> can contain a URL, it seems. */ -
protocols/msn/msn.c
r81186cab r21c87a7 31 31 GSList *msn_switchboards; 32 32 33 static char * msn_set_display_name( set_t *set, char *value );33 static char *set_eval_display_name( set_t *set, char *value ); 34 34 35 35 static void msn_init( account_t *acc ) 36 36 { 37 set_t *s; 38 39 s = set_add( &acc->set, "display_name", NULL, msn_set_display_name, acc ); 40 s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY; 41 42 s = set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc ); 37 set_add( &acc->set, "display_name", NULL, set_eval_display_name, acc ); 38 set_add( &acc->set, "local_display_name", "false", set_eval_bool, acc ); 39 set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc ); 43 40 } 44 41 … … 173 170 static void msn_set_my_name( struct im_connection *ic, char *info ) 174 171 { 175 msn_set_display_name( set_find( &ic->acc->set, "display_name" ), info );172 msn_set_display_name( ic, info ); 176 173 } 177 174 … … 289 286 } 290 287 291 static char * msn_set_display_name( set_t *set, char *value )288 static char *set_eval_display_name( set_t *set, char *value ) 292 289 { 293 290 account_t *acc = set->data; 294 291 struct im_connection *ic = acc->ic; 295 struct msn_data *md; 296 char buf[1024], *fn; 297 298 /* Double-check. */ 292 293 /* Allow any name if we're offline. */ 299 294 if( ic == NULL ) 300 return NULL; 301 302 md = ic->proto_data; 295 return value; 303 296 304 297 if( strlen( value ) > 129 ) … … 307 300 return NULL; 308 301 } 309 310 fn = msn_http_encode( value );311 312 g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, ic->acc->user, fn );313 msn_write( ic, buf, strlen( buf ) );314 g_free( fn );315 302 316 303 /* Returning NULL would be better, because the server still has to 317 304 confirm the name change. However, it looks a bit confusing to the 318 305 user. */ 319 return value;306 return msn_set_display_name( ic, value ) ? value : NULL; 320 307 } 321 308 -
protocols/msn/msn.h
r81186cab r21c87a7 162 162 char *msn_http_encode( const char *input ); 163 163 void msn_msgq_purge( struct im_connection *ic, GSList **list ); 164 gboolean msn_set_display_name( struct im_connection *ic, const char *rawname ); 164 165 165 166 /* tables.c */ -
protocols/msn/msn_util.c
r81186cab r21c87a7 38 38 imcb_error( ic, "Short write() to main server" ); 39 39 imc_logout( ic, TRUE ); 40 return ( 0 );41 } 42 43 return ( 1 );40 return 0; 41 } 42 43 return 1; 44 44 } 45 45 … … 376 376 g_string_free( ret, TRUE ); 377 377 } 378 379 gboolean msn_set_display_name( struct im_connection *ic, const char *rawname ) 380 { 381 char *fn = msn_http_encode( rawname ); 382 struct msn_data *md = ic->proto_data; 383 char buf[1024]; 384 385 g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, ic->acc->user, fn ); 386 g_free( fn ); 387 388 return msn_write( ic, buf, strlen( buf ) ) != 0; 389 } -
protocols/msn/ns.c
r81186cab r21c87a7 35 35 36 36 static void msn_auth_got_passport_token( struct msn_auth_data *mad ); 37 static gboolean msn_ns_got_display_name( struct im_connection *ic, char *name ); 37 38 38 39 gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond ) … … 231 232 else if( num_parts >= 7 && strcmp( cmd[2], "OK" ) == 0 ) 232 233 { 233 set_t *s;234 235 234 if( num_parts == 7 ) 236 { 237 http_decode( cmd[4] ); 238 239 strncpy( ic->displayname, cmd[4], sizeof( ic->displayname ) ); 240 ic->displayname[sizeof(ic->displayname)-1] = 0; 241 242 if( ( s = set_find( &ic->acc->set, "display_name" ) ) ) 243 { 244 g_free( s->value ); 245 s->value = g_strdup( cmd[4] ); 246 } 247 } 235 msn_ns_got_display_name( ic, cmd[4] ); 248 236 else 249 {250 237 imcb_log( ic, "Warning: Friendly name in server response was corrupted" ); 251 }252 238 253 239 imcb_log( ic, "Authenticated, getting buddy list" ); … … 567 553 return( 0 ); 568 554 } 555 #if 0 556 /* Discard this one completely for now since I don't care about the ack 557 and since MSN servers can apparently screw up the formatting. */ 569 558 else if( strcmp( cmd[0], "REA" ) == 0 ) 570 559 { … … 597 586 } 598 587 } 588 #endif 599 589 else if( strcmp( cmd[0], "IPG" ) == 0 ) 600 590 { … … 746 736 } 747 737 } 738 739 static gboolean msn_ns_got_display_name( struct im_connection *ic, char *name ) 740 { 741 set_t *s; 742 743 if( ( s = set_find( &ic->acc->set, "display_name" ) ) == NULL ) 744 return FALSE; /* Shouldn't happen.. */ 745 746 http_decode( name ); 747 748 if( s->value && strcmp( s->value, name ) == 0 ) 749 { 750 return TRUE; 751 /* The names match, nothing to worry about. */ 752 } 753 else if( s->value != NULL && 754 ( strcmp( name, ic->acc->user ) == 0 || 755 set_getbool( &ic->acc->set, "local_display_name" ) ) ) 756 { 757 /* The server thinks our display name is our e-mail address 758 which is probably wrong, or the user *wants* us to do this: 759 Always use the locally set display_name. */ 760 return msn_set_display_name( ic, s->value ); 761 } 762 else 763 { 764 if( s->value && *s->value ) 765 imcb_log( ic, "BitlBee thinks your display name is `%s' but " 766 "the MSN server says it's `%s'. Using the MSN " 767 "server's name. Set local_display_name to true " 768 "to use the local name.", s->value, name ); 769 770 if( g_utf8_validate( name, -1, NULL ) ) 771 { 772 g_free( s->value ); 773 s->value = g_strdup( name ); 774 } 775 else 776 { 777 imcb_log( ic, "Warning: Friendly name in server response was corrupted" ); 778 } 779 780 return TRUE; 781 } 782 } -
protocols/nogaim.c
r81186cab r21c87a7 127 127 extern void byahoo_initmodule(); 128 128 extern void jabber_initmodule(); 129 extern void twitter_initmodule(); 129 130 130 131 #ifdef WITH_MSN … … 142 143 #ifdef WITH_JABBER 143 144 jabber_initmodule(); 145 #endif 146 147 #ifdef WITH_TWITTER 148 twitter_initmodule(); 144 149 #endif 145 150 … … 560 565 } 561 566 567 void imcb_chat_name_hint( struct groupchat *c, const char *name ) 568 { 569 #if 0 570 if( !c->joined ) 571 { 572 struct im_connection *ic = c->ic; 573 char stripped[MAX_NICK_LENGTH+1], *full_name; 574 575 strncpy( stripped, name, MAX_NICK_LENGTH ); 576 stripped[MAX_NICK_LENGTH] = '\0'; 577 nick_strip( stripped ); 578 if( set_getbool( &ic->irc->set, "lcnicks" ) ) 579 nick_lc( stripped ); 580 581 full_name = g_strdup_printf( "&%s", stripped ); 582 583 if( stripped[0] && 584 nick_cmp( stripped, ic->irc->channel + 1 ) != 0 && 585 irc_chat_by_channel( ic->irc, full_name ) == NULL ) 586 { 587 g_free( c->channel ); 588 c->channel = full_name; 589 } 590 else 591 { 592 g_free( full_name ); 593 } 594 } 595 #endif 596 } 597 562 598 void imcb_chat_free( struct groupchat *c ) 563 599 { … … 623 659 if( c && u ) 624 660 { 625 irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, "", wrapped ); 661 char *ts = NULL; 662 if( set_getbool( &ic->irc->set, "display_timestamps" ) ) 663 ts = format_timestamp( ic->irc, sent_at ); 664 irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, ts ? : "", wrapped ); 665 g_free( ts ); 626 666 } 627 667 else … … 826 866 #endif 827 867 828 829 830 868 /* The plan is to not allow straight calls to prpl functions anymore, but do 831 869 them all from some wrappers. We'll start to define some down here: */ … … 852 890 { 853 891 char *away, *msg = NULL; 892 893 if( ic->acc->prpl->away_states == NULL || 894 ic->acc->prpl->set_away == NULL ) 895 return 0; 854 896 855 897 away = set_getstr( &ic->acc->set, "away" ) ? -
protocols/nogaim.h
r81186cab r21c87a7 299 299 * user, too. */ 300 300 G_MODULE_EXPORT struct groupchat *imcb_chat_new( struct im_connection *ic, const char *handle ); 301 G_MODULE_EXPORT void imcb_chat_name_hint( struct groupchat *c, const char *name ); 301 302 G_MODULE_EXPORT void imcb_chat_add_buddy( struct groupchat *b, const char *handle ); 302 303 /* To remove a handle from a group chat. Reason can be NULL. */
Note: See TracChangeset
for help on using the changeset viewer.