Changeset 34fbbf9
- Timestamp:
- 2010-03-06T18:22:20Z (15 years ago)
- Branches:
- master
- Children:
- 58adb7e
- Parents:
- be915f5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/nogaim.c
rbe915f5 r34fbbf9 1070 1070 } 1071 1071 1072 static char *imc_away_ alias_find( GList *gcm, char *away);1072 static char *imc_away_state_find( GList *gcm, char *away, char **message ); 1073 1073 1074 1074 int imc_set_away( struct im_connection *ic, char *away ) 1075 1075 { 1076 GList *m, *ms; 1077 char *s; 1078 1079 if( !away ) away = ""; 1080 ms = m = ic->acc->prpl->away_states( ic ); 1081 1082 while( m ) 1083 { 1084 if( *away ) 1085 { 1086 if( g_strncasecmp( m->data, away, strlen( m->data ) ) == 0 ) 1087 break; 1088 } 1089 else 1090 { 1091 if( g_strcasecmp( m->data, "Available" ) == 0 ) 1092 break; 1093 if( g_strcasecmp( m->data, "Online" ) == 0 ) 1094 break; 1095 } 1096 m = m->next; 1097 } 1098 1099 if( m ) 1100 { 1101 ic->acc->prpl->set_away( ic, m->data, *away ? away : NULL ); 1102 } 1103 else 1104 { 1105 s = imc_away_alias_find( ms, away ); 1106 if( s ) 1107 { 1108 ic->acc->prpl->set_away( ic, s, away ); 1109 if( set_getbool( &ic->irc->set, "debug" ) ) 1110 imcb_log( ic, "Setting away state to %s", s ); 1111 } 1112 else 1113 ic->acc->prpl->set_away( ic, GAIM_AWAY_CUSTOM, away ); 1114 } 1115 1116 return( 1 ); 1076 char *s = NULL, *msg = away; 1077 1078 if( away && *away ) 1079 { 1080 GList *m = ic->acc->prpl->away_states( ic ); 1081 s = imc_away_state_find( m, away, &msg ) ? : m->data; 1082 } 1083 1084 if( set_getbool( &ic->irc->set, "debug" ) ) 1085 imcb_log( ic, "Setting away state to %s", s ); 1086 1087 ic->acc->prpl->set_away( ic, s, ic->acc->flags & ACC_FLAG_AWAY_MESSAGE ? msg : NULL ); 1088 1089 return 1; 1117 1090 } 1118 1091 … … 1129 1102 }; 1130 1103 1131 static char *imc_away_ alias_find( GList *gcm, char *away)1104 static char *imc_away_state_find( GList *gcm, char *away, char **message ) 1132 1105 { 1133 1106 GList *m; 1134 1107 int i, j; 1135 1108 1109 for( m = gcm; m; m = m->next ) 1110 if( g_strncasecmp( m->data, away, strlen( m->data ) ) == 0 ) 1111 { 1112 /* At least the Yahoo! module works better if message 1113 contains no data unless it adds something to what 1114 we have in state already. */ 1115 if( strlen( m->data ) == strlen( away ) ) 1116 *message = NULL; 1117 1118 return m->data; 1119 } 1120 1136 1121 for( i = 0; *imc_away_alias_list[i]; i ++ ) 1137 1122 { 1123 int keep_message; 1124 1138 1125 for( j = 0; imc_away_alias_list[i][j]; j ++ ) 1139 1126 if( g_strncasecmp( away, imc_away_alias_list[i][j], strlen( imc_away_alias_list[i][j] ) ) == 0 ) 1127 { 1128 keep_message = strlen( away ) != strlen( imc_away_alias_list[i][j] ); 1140 1129 break; 1130 } 1141 1131 1142 1132 if( !imc_away_alias_list[i][j] ) /* If we reach the end, this row */ … … 1146 1136 for( j = 0; imc_away_alias_list[i][j]; j ++ ) 1147 1137 { 1148 m = gcm; 1149 while( m ) 1150 { 1138 for( m = gcm; m; m = m->next ) 1151 1139 if( g_strcasecmp( imc_away_alias_list[i][j], m->data ) == 0 ) 1152 return( imc_away_alias_list[i][j] ); 1153 m = m->next; 1154 } 1155 } 1156 } 1157 1158 return( NULL ); 1140 { 1141 if( !keep_message ) 1142 *message = NULL; 1143 1144 return imc_away_alias_list[i][j]; 1145 } 1146 } 1147 1148 /* No need to look further, apparently this state doesn't 1149 have any good alias for this protocol. */ 1150 break; 1151 } 1152 1153 return NULL; 1159 1154 } 1160 1155
Note: See TracChangeset
for help on using the changeset viewer.