| 956 | | - (NSMutableDictionary *)users { |
|---|
| 957 | | return _shownUsers; |
|---|
| 958 | | } |
|---|
| 959 | | |
|---|
| 960 | | |
|---|
| 961 | | |
|---|
| 962 | | - (unsigned int)cid { |
|---|
| 963 | | return _cid; |
|---|
| 964 | | } |
|---|
| 965 | | |
|---|
| 966 | | |
|---|
| 967 | | |
|---|
| 968 | | - (BOOL)canGetInfo { |
|---|
| 969 | | return ([_userListTableView selectedRow] >= 0) && [[_connection account] getUserInfo]; |
|---|
| 970 | | } |
|---|
| 971 | | |
|---|
| 972 | | |
|---|
| 973 | | |
|---|
| 974 | | #pragma mark - |
|---|
| 975 | | |
|---|
| 976 | | - (IBAction)sendPrivateMessage:(id)sender { |
|---|
| 977 | | NSNumber *key; |
|---|
| 978 | | WCUser *user; |
|---|
| 979 | | WCMessage *message; |
|---|
| 980 | | int row; |
|---|
| 981 | | |
|---|
| 982 | | // --- get row |
|---|
| 983 | | row = [_userListTableView selectedRow]; |
|---|
| 984 | | |
|---|
| 985 | | if(row < 0) |
|---|
| 986 | | return; |
|---|
| 987 | | |
|---|
| 988 | | // --- get user |
|---|
| 989 | | key = [_sortedUsers objectAtIndex:row]; |
|---|
| 990 | | user = [_shownUsers objectForKey:key]; |
|---|
| 991 | | |
|---|
| 992 | | // --- create a message |
|---|
| 993 | | message = [[WCMessage alloc] initWithType:WCMessageTypeTo]; |
|---|
| 994 | | [message setRead:YES]; |
|---|
| 995 | | [message setUser:user]; |
|---|
| 996 | | [message setDate:[NSDate date]]; |
|---|
| 997 | | |
|---|
| 998 | | // --- send message to user |
|---|
| 999 | | [(WCSendMessage *) [WCSendMessage alloc] initWithConnection:_connection message:message]; |
|---|
| 1000 | | |
|---|
| 1001 | | [message release]; |
|---|
| 1002 | | } |
|---|
| 1003 | | |
|---|
| 1004 | | |
|---|
| 1005 | | |
|---|
| 1006 | | - (IBAction)info:(id)sender { |
|---|
| 1007 | | NSNumber *key; |
|---|
| 1008 | | WCUser *user; |
|---|
| 1009 | | int row; |
|---|
| 1010 | | |
|---|
| 1011 | | // --- get row |
|---|
| 1012 | | row = [_userListTableView selectedRow]; |
|---|
| 1013 | | |
|---|
| 1014 | | if(row < 0) |
|---|
| 1015 | | return; |
|---|
| 1016 | | |
|---|
| 1017 | | // --- get user |
|---|
| 1018 | | key = [_sortedUsers objectAtIndex:row]; |
|---|
| 1019 | | user = [_shownUsers objectForKey:key]; |
|---|
| 1020 | | |
|---|
| 1021 | | // --- create a user info window |
|---|
| 1022 | | [[WCUserInfo alloc] initWithConnection:_connection user:user]; |
|---|
| 1023 | | } |
|---|
| 1024 | | |
|---|
| 1025 | | |
|---|
| 1026 | | |
|---|
| 1027 | | - (IBAction)ignore:(id)sender { |
|---|
| 1028 | | NSMutableArray *ignores; |
|---|
| 1029 | | NSDictionary *ignore; |
|---|
| 1030 | | NSNumber *key; |
|---|
| 1031 | | WCUser *user; |
|---|
| 1032 | | int row; |
|---|
| 1033 | | |
|---|
| 1034 | | // --- get row |
|---|
| 1035 | | row = [_userListTableView selectedRow]; |
|---|
| 1036 | | |
|---|
| 1037 | | if(row < 0) |
|---|
| 1038 | | return; |
|---|
| 1039 | | |
|---|
| 1040 | | // --- get user |
|---|
| 1041 | | key = [_sortedUsers objectAtIndex:row]; |
|---|
| 1042 | | user = [_shownUsers objectForKey:key]; |
|---|
| 1043 | | |
|---|
| 1044 | | if([user ignore]) |
|---|
| 1045 | | return; |
|---|
| 1046 | | |
|---|
| 1047 | | // --- create mutable ignores |
|---|
| 1048 | | ignores = [NSMutableArray arrayWithArray:[WCSettings objectForKey:WCIgnoredUsers]]; |
|---|
| 1049 | | |
|---|
| 1050 | | // --- create new ignore |
|---|
| 1051 | | ignore = [NSDictionary dictionaryWithObjectsAndKeys: |
|---|
| 1052 | | [user nick], @"Nick", |
|---|
| 1053 | | [user login], @"Login", |
|---|
| 1054 | | [user address], @"Address", |
|---|
| 1055 | | NULL]; |
|---|
| 1056 | | |
|---|
| 1057 | | // --- add to ignores |
|---|
| 1058 | | [ignores addObject:ignore]; |
|---|
| 1059 | | |
|---|
| 1060 | | // --- set new ignores |
|---|
| 1061 | | [WCSettings setObject:[NSArray arrayWithArray:ignores] forKey:WCIgnoredUsers]; |
|---|
| 1062 | | |
|---|
| 1063 | | // --- post reload table notification |
|---|
| 1064 | | [[NSNotificationCenter defaultCenter] |
|---|
| 1065 | | postNotificationName:WCChatShouldReloadListing |
|---|
| 1066 | | object:NULL]; |
|---|
| 1067 | | } |
|---|
| 1068 | | |
|---|
| 1069 | | |
|---|
| 1070 | | - (IBAction)unignore:(id)sender { |
|---|
| 1071 | | NSMutableArray *ignores; |
|---|
| 1072 | | NSDictionary *ignore; |
|---|
| 1073 | | NSEnumerator *enumerator; |
|---|
| 1074 | | NSNumber *key; |
|---|
| 1075 | | WCUser *user; |
|---|
| 1076 | | BOOL nick, login, address; |
|---|
| 1077 | | int row; |
|---|
| 1078 | | |
|---|
| 1079 | | // --- get row |
|---|
| 1080 | | row = [_userListTableView selectedRow]; |
|---|
| 1081 | | |
|---|
| 1082 | | if(row < 0) |
|---|
| 1083 | | return; |
|---|
| 1084 | | |
|---|
| 1085 | | // --- get user |
|---|
| 1086 | | key = [_sortedUsers objectAtIndex:row]; |
|---|
| 1087 | | user = [_shownUsers objectForKey:key]; |
|---|
| 1088 | | |
|---|
| 1089 | | if(![user ignore]) |
|---|
| 1090 | | return; |
|---|
| 1091 | | |
|---|
| 1092 | | // --- create mutable ignores |
|---|
| 1093 | | ignores = [NSMutableArray arrayWithArray:[WCSettings objectForKey:WCIgnoredUsers]]; |
|---|
| 1094 | | |
|---|
| 1095 | | // --- while the user is still ignored, loop over all ignores and remove |
|---|
| 1096 | | // any that matches |
|---|
| 1097 | | while([user ignore]) { |
|---|
| 1098 | | enumerator = [ignores objectEnumerator]; |
|---|
| 1099 | | |
|---|
| 1100 | | while((ignore = [enumerator nextObject])) { |
|---|
| 1101 | | nick = login = address = NO; |
|---|
| 1102 | | |
|---|
| 1103 | | if([[ignore objectForKey:@"Nick"] isEqualToString:[user nick]] || |
|---|
| 1104 | | [[ignore objectForKey:@"Nick"] isEqualToString:@""]) |
|---|
| 1105 | | nick = YES; |
|---|
| 1106 | | |
|---|
| 1107 | | if([[ignore objectForKey:@"Login"] isEqualToString:[user login]] || |
|---|
| 1108 | | [[ignore objectForKey:@"Login"] isEqualToString:@""]) |
|---|
| 1109 | | login = YES; |
|---|
| 1110 | | |
|---|
| 1111 | | if([[ignore objectForKey:@"Address"] isEqualToString:[user address]] || |
|---|
| 1112 | | [[ignore objectForKey:@"Address"] isEqualToString:@""]) |
|---|
| 1113 | | address = YES; |
|---|
| 1114 | | |
|---|
| 1115 | | if(nick && login && address) { |
|---|
| 1116 | | // --- remove |
|---|
| 1117 | | [ignores removeObject:ignore]; |
|---|
| 1118 | | |
|---|
| 1119 | | // --- set new ignores |
|---|
| 1120 | | [WCSettings setObject:[NSArray arrayWithArray:ignores] forKey:WCIgnoredUsers]; |
|---|
| 1121 | | } |
|---|
| 1122 | | } |
|---|
| 1123 | | } |
|---|
| 1124 | | |
|---|
| 1125 | | // --- post reload table notification |
|---|
| 1126 | | [[NSNotificationCenter defaultCenter] |
|---|
| 1127 | | postNotificationName:WCChatShouldReloadListing |
|---|
| 1128 | | object:NULL]; |
|---|
| 1129 | | } |
|---|
| 1130 | | |
|---|
| 1131 | | |
|---|
| 1132 | | |
|---|
| 1133 | | #pragma mark - |
|---|
| 1134 | | |
|---|
| | 1112 | } |
|---|
| | 1113 | |
|---|
| | 1114 | |
|---|
| | 1115 | |
|---|
| | 1116 | |
|---|
| | 1117 | #pragma mark - |
|---|
| | 1118 | |
|---|
| | 1119 | - (NSMutableDictionary *)users { |
|---|
| | 1120 | return _shownUsers; |
|---|
| | 1121 | } |
|---|
| | 1122 | |
|---|
| | 1123 | |
|---|
| | 1124 | |
|---|
| | 1125 | - (unsigned int)numberOfUsers { |
|---|
| | 1126 | return [_shownUsers count]; |
|---|
| | 1127 | } |
|---|
| | 1128 | |
|---|
| | 1129 | |
|---|
| | 1130 | |
|---|
| | 1131 | - (unsigned int)numberOfActiveUsers { |
|---|
| | 1132 | NSEnumerator *enumerator; |
|---|
| | 1133 | WCUser *each; |
|---|
| | 1134 | unsigned int active = 0; |
|---|
| | 1135 | |
|---|
| | 1136 | enumerator = [_shownUsers objectEnumerator]; |
|---|
| | 1137 | |
|---|
| | 1138 | while((each = [enumerator nextObject])) { |
|---|
| | 1139 | if(![each idle]) |
|---|
| | 1140 | active++; |
|---|
| | 1141 | } |
|---|
| | 1142 | |
|---|
| | 1143 | return active; |
|---|
| | 1144 | } |
|---|
| | 1145 | |
|---|
| | 1146 | |
|---|
| | 1147 | |
|---|
| | 1148 | - (unsigned int)cid { |
|---|
| | 1149 | return _cid; |
|---|
| | 1150 | } |
|---|
| | 1151 | |
|---|
| | 1152 | |
|---|
| | 1153 | |
|---|
| | 1154 | - (BOOL)canGetInfo { |
|---|
| | 1155 | return ([_userListTableView selectedRow] >= 0) && [[_connection account] getUserInfo]; |
|---|
| | 1156 | } |
|---|
| | 1157 | |
|---|
| | 1158 | |
|---|
| | 1159 | |
|---|
| | 1160 | #pragma mark - |
|---|
| | 1161 | |
|---|
| | 1162 | - (IBAction)sendPrivateMessage:(id)sender { |
|---|
| | 1163 | NSNumber *key; |
|---|
| | 1164 | WCUser *user; |
|---|
| | 1165 | WCMessage *message; |
|---|
| | 1166 | int row; |
|---|
| | 1167 | |
|---|
| | 1168 | // --- get row |
|---|
| | 1169 | row = [_userListTableView selectedRow]; |
|---|
| | 1170 | |
|---|
| | 1171 | if(row < 0) |
|---|
| | 1172 | return; |
|---|
| | 1173 | |
|---|
| | 1174 | // --- get user |
|---|
| | 1175 | key = [_sortedUsers objectAtIndex:row]; |
|---|
| | 1176 | user = [_shownUsers objectForKey:key]; |
|---|
| | 1177 | |
|---|
| | 1178 | // --- create a message |
|---|
| | 1179 | message = [[WCMessage alloc] initWithType:WCMessageTypeTo]; |
|---|
| | 1180 | [message setRead:YES]; |
|---|
| | 1181 | [message setUser:user]; |
|---|
| | 1182 | [message setDate:[NSDate date]]; |
|---|
| | 1183 | |
|---|
| | 1184 | // --- send message to user |
|---|
| | 1185 | [(WCSendMessage *) [WCSendMessage alloc] initWithConnection:_connection message:message]; |
|---|
| | 1186 | |
|---|
| | 1187 | [message release]; |
|---|
| | 1188 | } |
|---|
| | 1189 | |
|---|
| | 1190 | |
|---|
| | 1191 | |
|---|
| | 1192 | - (IBAction)info:(id)sender { |
|---|
| | 1193 | NSNumber *key; |
|---|
| | 1194 | WCUser *user; |
|---|
| | 1195 | int row; |
|---|
| | 1196 | |
|---|
| | 1197 | // --- get row |
|---|
| | 1198 | row = [_userListTableView selectedRow]; |
|---|
| | 1199 | |
|---|
| | 1200 | if(row < 0) |
|---|
| | 1201 | return; |
|---|
| | 1202 | |
|---|
| | 1203 | // --- get user |
|---|
| | 1204 | key = [_sortedUsers objectAtIndex:row]; |
|---|
| | 1205 | user = [_shownUsers objectForKey:key]; |
|---|
| | 1206 | |
|---|
| | 1207 | // --- create a user info window |
|---|
| | 1208 | [[WCUserInfo alloc] initWithConnection:_connection user:user]; |
|---|
| | 1209 | } |
|---|
| | 1210 | |
|---|
| | 1211 | |
|---|
| | 1212 | |
|---|
| | 1213 | - (IBAction)ignore:(id)sender { |
|---|
| | 1214 | NSMutableArray *ignores; |
|---|
| | 1215 | NSDictionary *ignore; |
|---|
| | 1216 | NSNumber *key; |
|---|
| | 1217 | WCUser *user; |
|---|
| | 1218 | int row; |
|---|
| | 1219 | |
|---|
| | 1220 | // --- get row |
|---|
| | 1221 | row = [_userListTableView selectedRow]; |
|---|
| | 1222 | |
|---|
| | 1223 | if(row < 0) |
|---|
| | 1224 | return; |
|---|
| | 1225 | |
|---|
| | 1226 | // --- get user |
|---|
| | 1227 | key = [_sortedUsers objectAtIndex:row]; |
|---|
| | 1228 | user = [_shownUsers objectForKey:key]; |
|---|
| | 1229 | |
|---|
| | 1230 | if([user ignore]) |
|---|
| | 1231 | return; |
|---|
| | 1232 | |
|---|
| | 1233 | // --- create mutable ignores |
|---|
| | 1234 | ignores = [NSMutableArray arrayWithArray:[WCSettings objectForKey:WCIgnoredUsers]]; |
|---|
| | 1235 | |
|---|
| | 1236 | // --- create new ignore |
|---|
| | 1237 | ignore = [NSDictionary dictionaryWithObjectsAndKeys: |
|---|
| | 1238 | [user nick], @"Nick", |
|---|
| | 1239 | [user login], @"Login", |
|---|
| | 1240 | [user address], @"Address", |
|---|
| | 1241 | NULL]; |
|---|
| | 1242 | |
|---|
| | 1243 | // --- add to ignores |
|---|
| | 1244 | [ignores addObject:ignore]; |
|---|
| | 1245 | |
|---|
| | 1246 | // --- set new ignores |
|---|
| | 1247 | [WCSettings setObject:[NSArray arrayWithArray:ignores] forKey:WCIgnoredUsers]; |
|---|
| | 1248 | |
|---|
| | 1249 | // --- post reload table notification |
|---|
| | 1250 | [[NSNotificationCenter defaultCenter] |
|---|
| | 1251 | postNotificationName:WCChatShouldReloadListing |
|---|
| | 1252 | object:NULL]; |
|---|
| | 1253 | } |
|---|
| | 1254 | |
|---|
| | 1255 | |
|---|
| | 1256 | |
|---|
| | 1257 | - (IBAction)unignore:(id)sender { |
|---|
| | 1258 | NSMutableArray *ignores; |
|---|
| | 1259 | NSDictionary *ignore; |
|---|
| | 1260 | NSEnumerator *enumerator; |
|---|
| | 1261 | NSNumber *key; |
|---|
| | 1262 | WCUser *user; |
|---|
| | 1263 | BOOL nick, login, address; |
|---|
| | 1264 | int row; |
|---|
| | 1265 | |
|---|
| | 1266 | // --- get row |
|---|
| | 1267 | row = [_userListTableView selectedRow]; |
|---|
| | 1268 | |
|---|
| | 1269 | if(row < 0) |
|---|
| | 1270 | return; |
|---|
| | 1271 | |
|---|
| | 1272 | // --- get user |
|---|
| | 1273 | key = [_sortedUsers objectAtIndex:row]; |
|---|
| | 1274 | user = [_shownUsers objectForKey:key]; |
|---|
| | 1275 | |
|---|
| | 1276 | if(![user ignore]) |
|---|
| | 1277 | return; |
|---|
| | 1278 | |
|---|
| | 1279 | // --- create mutable ignores |
|---|
| | 1280 | ignores = [NSMutableArray arrayWithArray:[WCSettings objectForKey:WCIgnoredUsers]]; |
|---|
| | 1281 | |
|---|
| | 1282 | // --- while the user is still ignored, loop over all ignores and remove |
|---|
| | 1283 | // any that matches |
|---|
| | 1284 | while([user ignore]) { |
|---|
| | 1285 | enumerator = [ignores objectEnumerator]; |
|---|
| | 1286 | |
|---|
| | 1287 | while((ignore = [enumerator nextObject])) { |
|---|
| | 1288 | nick = login = address = NO; |
|---|
| | 1289 | |
|---|
| | 1290 | if([[ignore objectForKey:@"Nick"] isEqualToString:[user nick]] || |
|---|
| | 1291 | [[ignore objectForKey:@"Nick"] isEqualToString:@""]) |
|---|
| | 1292 | nick = YES; |
|---|
| | 1293 | |
|---|
| | 1294 | if([[ignore objectForKey:@"Login"] isEqualToString:[user login]] || |
|---|
| | 1295 | [[ignore objectForKey:@"Login"] isEqualToString:@""]) |
|---|
| | 1296 | login = YES; |
|---|
| | 1297 | |
|---|
| | 1298 | if([[ignore objectForKey:@"Address"] isEqualToString:[user address]] || |
|---|
| | 1299 | [[ignore objectForKey:@"Address"] isEqualToString:@""]) |
|---|
| | 1300 | address = YES; |
|---|
| | 1301 | |
|---|
| | 1302 | if(nick && login && address) { |
|---|
| | 1303 | // --- remove |
|---|
| | 1304 | [ignores removeObject:ignore]; |
|---|
| | 1305 | |
|---|
| | 1306 | // --- set new ignores |
|---|
| | 1307 | [WCSettings setObject:[NSArray arrayWithArray:ignores] forKey:WCIgnoredUsers]; |
|---|
| | 1308 | } |
|---|
| | 1309 | } |
|---|
| | 1310 | } |
|---|
| | 1311 | |
|---|
| | 1312 | // --- post reload table notification |
|---|
| | 1313 | [[NSNotificationCenter defaultCenter] |
|---|
| | 1314 | postNotificationName:WCChatShouldReloadListing |
|---|
| | 1315 | object:NULL]; |
|---|