Changeset 5f8ab6a9 for protocols/nogaim.c
- Timestamp:
- 2010-06-03T10:41:03Z (14 years ago)
- Branches:
- master
- Children:
- 814aa52
- Parents:
- 3f81999 (diff), f9928cb (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/nogaim.c
r3f81999 r5f8ab6a9 2 2 * BitlBee -- An IRC to other IM-networks gateway * 3 3 * * 4 * Copyright 2002-20 06Wilmer van der Gaast and others *4 * Copyright 2002-2010 Wilmer van der Gaast and others * 5 5 \********************************************************************/ 6 6 … … 33 33 34 34 #define BITLBEE_CORE 35 #include <ctype.h> 36 35 37 #include "nogaim.h" 36 #include <ctype.h>38 #include "chat.h" 37 39 38 40 static int remove_chat_buddy_silent( struct groupchat *b, const char *handle ); … … 96 98 void register_protocol (struct prpl *p) 97 99 { 98 protocols = g_list_append(protocols, p); 100 int i; 101 gboolean refused = global.conf->protocols != NULL; 102 103 for (i = 0; global.conf->protocols && global.conf->protocols[i]; i++) 104 { 105 if (g_strcasecmp(p->name, global.conf->protocols[i]) == 0) 106 refused = FALSE; 107 } 108 109 if (refused) 110 log_message(LOGLVL_WARNING, "Protocol %s disabled\n", p->name); 111 else 112 protocols = g_list_append(protocols, p); 99 113 } 100 114 … … 266 280 ic->flags |= OPT_LOGGED_IN; 267 281 268 /* Also necessary when we're not away, at least for some of the 269 protocols. */ 270 imc_set_away( ic, u->away ); 282 /* Necessary to send initial presence status, even if we're not away. */ 283 imc_away_send_update( ic ); 271 284 272 285 /* Apparently we're connected successfully, so reset the … … 370 383 /* list.c */ 371 384 372 void imcb_add_buddy( struct im_connection *ic, c har *handle,char *group )385 void imcb_add_buddy( struct im_connection *ic, const char *handle, const char *group ) 373 386 { 374 387 user_t *u; … … 444 457 } 445 458 446 void imcb_rename_buddy( struct im_connection *ic, c har *handle,char *realname )459 void imcb_rename_buddy( struct im_connection *ic, const char *handle, const char *realname ) 447 460 { 448 461 user_t *u = user_findhandle( ic, handle ); 462 char *set; 449 463 450 464 if( !u || !realname ) return; … … 459 473 imcb_log( ic, "User `%s' changed name to `%s'", u->nick, u->realname ); 460 474 } 461 } 462 463 void imcb_remove_buddy( struct im_connection *ic, char *handle, char *group ) 475 476 set = set_getstr( &ic->acc->set, "nick_source" ); 477 if( strcmp( set, "handle" ) != 0 ) 478 { 479 char *name = g_strdup( realname ); 480 481 if( strcmp( set, "first_name" ) == 0 ) 482 { 483 int i; 484 for( i = 0; name[i] && !isspace( name[i] ); i ++ ) {} 485 name[i] = '\0'; 486 } 487 488 imcb_buddy_nick_hint( ic, handle, name ); 489 490 g_free( name ); 491 } 492 } 493 494 void imcb_remove_buddy( struct im_connection *ic, const char *handle, char *group ) 464 495 { 465 496 user_t *u; … … 471 502 /* Mainly meant for ICQ (and now also for Jabber conferences) to allow IM 472 503 modules to suggest a nickname for a handle. */ 473 void imcb_buddy_nick_hint( struct im_connection *ic, c har *handle,char *nick )504 void imcb_buddy_nick_hint( struct im_connection *ic, const char *handle, const char *nick ) 474 505 { 475 506 user_t *u = user_findhandle( ic, handle ); … … 616 647 oo = u->online; 617 648 618 if( u->away ) 619 { 620 g_free( u->away ); 621 u->away = NULL; 622 } 649 g_free( u->away ); 650 g_free( u->status_msg ); 651 u->away = u->status_msg = NULL; 623 652 624 653 if( ( flags & OPT_LOGGED_IN ) && !u->online ) … … 658 687 } 659 688 } 660 /* else waste_any_state_information_for_now(); */ 689 else 690 { 691 u->status_msg = g_strdup( message ); 692 } 661 693 662 694 /* LISPy... */ … … 692 724 } 693 725 694 void imcb_buddy_msg( struct im_connection *ic, c har *handle, char *msg, uint32_t flags, time_t sent_at )726 void imcb_buddy_msg( struct im_connection *ic, const char *handle, char *msg, uint32_t flags, time_t sent_at ) 695 727 { 696 728 irc_t *irc = ic->irc; … … 833 865 } 834 866 835 void imcb_chat_msg( struct groupchat *c, c har *who, char *msg, uint32_t flags, time_t sent_at )867 void imcb_chat_msg( struct groupchat *c, const char *who, char *msg, uint32_t flags, time_t sent_at ) 836 868 { 837 869 struct im_connection *ic = c->ic; … … 905 937 /* buddy_chat.c */ 906 938 907 void imcb_chat_add_buddy( struct groupchat *b, c har *handle )939 void imcb_chat_add_buddy( struct groupchat *b, const char *handle ) 908 940 { 909 941 user_t *u = user_findhandle( b->ic, handle ); … … 940 972 941 973 /* This function is one BIG hack... :-( EREWRITE */ 942 void imcb_chat_remove_buddy( struct groupchat *b, c har *handle,char *reason )974 void imcb_chat_remove_buddy( struct groupchat *b, const char *handle, const char *reason ) 943 975 { 944 976 user_t *u; … … 1026 1058 } 1027 1059 1028 static char *imc_away_alias_find( GList *gcm, char *away ); 1029 1030 int imc_set_away( struct im_connection *ic, char *away ) 1031 { 1032 GList *m, *ms; 1033 char *s; 1034 1035 if( !away ) away = ""; 1036 ms = m = ic->acc->prpl->away_states( ic ); 1037 1038 while( m ) 1039 { 1040 if( *away ) 1041 { 1042 if( g_strncasecmp( m->data, away, strlen( m->data ) ) == 0 ) 1043 break; 1044 } 1045 else 1046 { 1047 if( g_strcasecmp( m->data, "Available" ) == 0 ) 1048 break; 1049 if( g_strcasecmp( m->data, "Online" ) == 0 ) 1050 break; 1051 } 1052 m = m->next; 1053 } 1054 1055 if( m ) 1056 { 1057 ic->acc->prpl->set_away( ic, m->data, *away ? away : NULL ); 1058 } 1059 else 1060 { 1061 s = imc_away_alias_find( ms, away ); 1062 if( s ) 1063 { 1064 ic->acc->prpl->set_away( ic, s, away ); 1065 if( set_getbool( &ic->irc->set, "debug" ) ) 1066 imcb_log( ic, "Setting away state to %s", s ); 1067 } 1068 else 1069 ic->acc->prpl->set_away( ic, GAIM_AWAY_CUSTOM, away ); 1070 } 1071 1072 return( 1 ); 1060 static char *imc_away_state_find( GList *gcm, char *away, char **message ); 1061 1062 int imc_away_send_update( struct im_connection *ic ) 1063 { 1064 char *away, *msg = NULL; 1065 1066 away = set_getstr( &ic->acc->set, "away" ) ? 1067 : set_getstr( &ic->irc->set, "away" ); 1068 if( away && *away ) 1069 { 1070 GList *m = ic->acc->prpl->away_states( ic ); 1071 msg = ic->acc->flags & ACC_FLAG_AWAY_MESSAGE ? away : NULL; 1072 away = imc_away_state_find( m, away, &msg ) ? : m->data; 1073 } 1074 else if( ic->acc->flags & ACC_FLAG_STATUS_MESSAGE ) 1075 { 1076 away = NULL; 1077 msg = set_getstr( &ic->acc->set, "status" ) ? 1078 : set_getstr( &ic->irc->set, "status" ); 1079 } 1080 1081 ic->acc->prpl->set_away( ic, away, msg ); 1082 1083 return 1; 1073 1084 } 1074 1085 … … 1085 1096 }; 1086 1097 1087 static char *imc_away_ alias_find( GList *gcm, char *away)1098 static char *imc_away_state_find( GList *gcm, char *away, char **message ) 1088 1099 { 1089 1100 GList *m; 1090 1101 int i, j; 1091 1102 1103 for( m = gcm; m; m = m->next ) 1104 if( g_strncasecmp( m->data, away, strlen( m->data ) ) == 0 ) 1105 { 1106 /* At least the Yahoo! module works better if message 1107 contains no data unless it adds something to what 1108 we have in state already. */ 1109 if( strlen( m->data ) == strlen( away ) ) 1110 *message = NULL; 1111 1112 return m->data; 1113 } 1114 1092 1115 for( i = 0; *imc_away_alias_list[i]; i ++ ) 1093 1116 { 1117 int keep_message; 1118 1094 1119 for( j = 0; imc_away_alias_list[i][j]; j ++ ) 1095 1120 if( g_strncasecmp( away, imc_away_alias_list[i][j], strlen( imc_away_alias_list[i][j] ) ) == 0 ) 1121 { 1122 keep_message = strlen( away ) != strlen( imc_away_alias_list[i][j] ); 1096 1123 break; 1124 } 1097 1125 1098 1126 if( !imc_away_alias_list[i][j] ) /* If we reach the end, this row */ … … 1102 1130 for( j = 0; imc_away_alias_list[i][j]; j ++ ) 1103 1131 { 1104 m = gcm; 1105 while( m ) 1106 { 1132 for( m = gcm; m; m = m->next ) 1107 1133 if( g_strcasecmp( imc_away_alias_list[i][j], m->data ) == 0 ) 1108 return( imc_away_alias_list[i][j] ); 1109 m = m->next; 1110 } 1111 } 1112 } 1113 1114 return( NULL ); 1134 { 1135 if( !keep_message ) 1136 *message = NULL; 1137 1138 return imc_away_alias_list[i][j]; 1139 } 1140 } 1141 1142 /* No need to look further, apparently this state doesn't 1143 have any good alias for this protocol. */ 1144 break; 1145 } 1146 1147 return NULL; 1115 1148 } 1116 1149
Note: See TracChangeset
for help on using the changeset viewer.