Changes in protocols/nogaim.c [449a51d:fa295e36]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/nogaim.c
r449a51d rfa295e36 2 2 * BitlBee -- An IRC to other IM-networks gateway * 3 3 * * 4 * Copyright 2002-20 10Wilmer van der Gaast and others *4 * Copyright 2002-2006 Wilmer van der Gaast and others * 5 5 \********************************************************************/ 6 6 … … 33 33 34 34 #define BITLBEE_CORE 35 #include "nogaim.h" 35 36 #include <ctype.h> 36 37 #include "nogaim.h"38 #include "chat.h"39 37 40 38 static int remove_chat_buddy_silent( struct groupchat *b, const char *handle ); … … 98 96 void register_protocol (struct prpl *p) 99 97 { 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); 98 protocols = g_list_append(protocols, p); 113 99 } 114 100 … … 280 266 ic->flags |= OPT_LOGGED_IN; 281 267 282 /* Necessary to send initial presence status, even if we're not away. */ 283 imc_away_send_update( ic ); 268 /* Also necessary when we're not away, at least for some of the 269 protocols. */ 270 imc_set_away( ic, u->away ); 284 271 285 272 /* Apparently we're connected successfully, so reset the … … 383 370 /* list.c */ 384 371 385 void imcb_add_buddy( struct im_connection *ic, c onst char *handle, constchar *group )372 void imcb_add_buddy( struct im_connection *ic, char *handle, char *group ) 386 373 { 387 374 user_t *u; … … 457 444 } 458 445 459 void imcb_rename_buddy( struct im_connection *ic, c onst char *handle, constchar *realname )446 void imcb_rename_buddy( struct im_connection *ic, char *handle, char *realname ) 460 447 { 461 448 user_t *u = user_findhandle( ic, handle ); 462 char *set;463 449 464 450 if( !u || !realname ) return; … … 473 459 imcb_log( ic, "User `%s' changed name to `%s'", u->nick, u->realname ); 474 460 } 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 ) 461 } 462 463 void imcb_remove_buddy( struct im_connection *ic, char *handle, char *group ) 495 464 { 496 465 user_t *u; … … 502 471 /* Mainly meant for ICQ (and now also for Jabber conferences) to allow IM 503 472 modules to suggest a nickname for a handle. */ 504 void imcb_buddy_nick_hint( struct im_connection *ic, c onst char *handle, constchar *nick )473 void imcb_buddy_nick_hint( struct im_connection *ic, char *handle, char *nick ) 505 474 { 506 475 user_t *u = user_findhandle( ic, handle ); … … 647 616 oo = u->online; 648 617 649 g_free( u->away ); 650 g_free( u->status_msg ); 651 u->away = u->status_msg = NULL; 618 if( u->away ) 619 { 620 g_free( u->away ); 621 u->away = NULL; 622 } 652 623 653 624 if( ( flags & OPT_LOGGED_IN ) && !u->online ) … … 687 658 } 688 659 } 689 else 690 { 691 u->status_msg = g_strdup( message ); 692 } 660 /* else waste_any_state_information_for_now(); */ 693 661 694 662 /* LISPy... */ … … 715 683 } 716 684 717 void imcb_buddy_msg( struct im_connection *ic, c onst char *handle, char *msg, uint32_t flags, time_t sent_at )685 void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, uint32_t flags, time_t sent_at ) 718 686 { 719 687 irc_t *irc = ic->irc; … … 848 816 } 849 817 850 void imcb_chat_msg( struct groupchat *c, c onst char *who, char *msg, uint32_t flags, time_t sent_at )818 void imcb_chat_msg( struct groupchat *c, char *who, char *msg, uint32_t flags, time_t sent_at ) 851 819 { 852 820 struct im_connection *ic = c->ic; … … 920 888 /* buddy_chat.c */ 921 889 922 void imcb_chat_add_buddy( struct groupchat *b, c onst char *handle )890 void imcb_chat_add_buddy( struct groupchat *b, char *handle ) 923 891 { 924 892 user_t *u = user_findhandle( b->ic, handle ); … … 955 923 956 924 /* This function is one BIG hack... :-( EREWRITE */ 957 void imcb_chat_remove_buddy( struct groupchat *b, c onst char *handle, constchar *reason )925 void imcb_chat_remove_buddy( struct groupchat *b, char *handle, char *reason ) 958 926 { 959 927 user_t *u; … … 1100 1068 } 1101 1069 1102 static char *imc_away_state_find( GList *gcm, char *away, char **message ); 1103 1104 int imc_away_send_update( struct im_connection *ic ) 1105 { 1106 char *away, *msg = NULL; 1107 1108 away = set_getstr( &ic->acc->set, "away" ) ? 1109 : set_getstr( &ic->irc->set, "away" ); 1110 if( away && *away ) 1111 { 1112 GList *m = ic->acc->prpl->away_states( ic ); 1113 msg = ic->acc->flags & ACC_FLAG_AWAY_MESSAGE ? away : NULL; 1114 away = imc_away_state_find( m, away, &msg ) ? : m->data; 1115 } 1116 else if( ic->acc->flags & ACC_FLAG_STATUS_MESSAGE ) 1117 { 1118 away = NULL; 1119 msg = set_getstr( &ic->acc->set, "status" ) ? 1120 : set_getstr( &ic->irc->set, "status" ); 1121 } 1122 1123 ic->acc->prpl->set_away( ic, away, msg ); 1124 1125 return 1; 1070 static char *imc_away_alias_find( GList *gcm, char *away ); 1071 1072 int imc_set_away( struct im_connection *ic, char *away ) 1073 { 1074 GList *m, *ms; 1075 char *s; 1076 1077 if( !away ) away = ""; 1078 ms = m = ic->acc->prpl->away_states( ic ); 1079 1080 while( m ) 1081 { 1082 if( *away ) 1083 { 1084 if( g_strncasecmp( m->data, away, strlen( m->data ) ) == 0 ) 1085 break; 1086 } 1087 else 1088 { 1089 if( g_strcasecmp( m->data, "Available" ) == 0 ) 1090 break; 1091 if( g_strcasecmp( m->data, "Online" ) == 0 ) 1092 break; 1093 } 1094 m = m->next; 1095 } 1096 1097 if( m ) 1098 { 1099 ic->acc->prpl->set_away( ic, m->data, *away ? away : NULL ); 1100 } 1101 else 1102 { 1103 s = imc_away_alias_find( ms, away ); 1104 if( s ) 1105 { 1106 ic->acc->prpl->set_away( ic, s, away ); 1107 if( set_getbool( &ic->irc->set, "debug" ) ) 1108 imcb_log( ic, "Setting away state to %s", s ); 1109 } 1110 else 1111 ic->acc->prpl->set_away( ic, GAIM_AWAY_CUSTOM, away ); 1112 } 1113 1114 return( 1 ); 1126 1115 } 1127 1116 … … 1138 1127 }; 1139 1128 1140 static char *imc_away_ state_find( GList *gcm, char *away, char **message)1129 static char *imc_away_alias_find( GList *gcm, char *away ) 1141 1130 { 1142 1131 GList *m; 1143 1132 int i, j; 1144 1133 1145 for( m = gcm; m; m = m->next )1146 if( g_strncasecmp( m->data, away, strlen( m->data ) ) == 0 )1147 {1148 /* At least the Yahoo! module works better if message1149 contains no data unless it adds something to what1150 we have in state already. */1151 if( strlen( m->data ) == strlen( away ) )1152 *message = NULL;1153 1154 return m->data;1155 }1156 1157 1134 for( i = 0; *imc_away_alias_list[i]; i ++ ) 1158 1135 { 1159 int keep_message;1160 1161 1136 for( j = 0; imc_away_alias_list[i][j]; j ++ ) 1162 1137 if( g_strncasecmp( away, imc_away_alias_list[i][j], strlen( imc_away_alias_list[i][j] ) ) == 0 ) 1163 {1164 keep_message = strlen( away ) != strlen( imc_away_alias_list[i][j] );1165 1138 break; 1166 }1167 1139 1168 1140 if( !imc_away_alias_list[i][j] ) /* If we reach the end, this row */ … … 1172 1144 for( j = 0; imc_away_alias_list[i][j]; j ++ ) 1173 1145 { 1174 for( m = gcm; m; m = m->next ) 1146 m = gcm; 1147 while( m ) 1148 { 1175 1149 if( g_strcasecmp( imc_away_alias_list[i][j], m->data ) == 0 ) 1176 { 1177 if( !keep_message ) 1178 *message = NULL; 1179 1180 return imc_away_alias_list[i][j]; 1181 } 1182 } 1183 1184 /* No need to look further, apparently this state doesn't 1185 have any good alias for this protocol. */ 1186 break; 1187 } 1188 1189 return NULL; 1150 return( imc_away_alias_list[i][j] ); 1151 m = m->next; 1152 } 1153 } 1154 } 1155 1156 return( NULL ); 1190 1157 } 1191 1158
Note: See TracChangeset
for help on using the changeset viewer.