| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | #import "DCPurpleZephyrJoinChatViewController.h" |
| 18 | #import "DCJoinChatWindowController.h" |
| 19 | #import <Adium/AIAccount.h> |
| 20 | |
| 21 | @interface DCPurpleZephyrJoinChatViewController (PRIVATE) |
| 22 | - (void)validateEnteredText; |
| 23 | @end |
| 24 | |
| 25 | @implementation DCPurpleZephyrJoinChatViewController |
| 26 | |
| 27 | - (NSString *)nibName |
| 28 | { |
| 29 | return @"DCPurpleZephyrJoinChatView"; |
| 30 | } |
| 31 | |
| 32 | - (void)configureForAccount:(AIAccount *)inAccount |
| 33 | { |
| 34 | [self validateEnteredText]; |
| 35 | |
| 36 | [[view window] makeFirstResponder:textField_class]; |
| 37 | |
| 38 | [super configureForAccount:inAccount]; |
| 39 | } |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | - (void)joinChatWithAccount:(AIAccount *)inAccount |
| 47 | { |
| 48 | NSString *class; |
| 49 | NSString *instance; |
| 50 | NSString *recipient; |
| 51 | NSDictionary *chatCreationInfo; |
| 52 | |
| 53 | class = [textField_class stringValue]; |
| 54 | instance = [textField_instance stringValue]; |
| 55 | recipient = [textField_recipient stringValue]; |
| 56 | |
| 57 | if (!instance || ![instance length]) instance = @"*"; |
| 58 | if (!recipient || ![recipient length]) recipient = @"*"; |
| 59 | |
| 60 | if (class && [class length]) { |
| 61 | NSString *name; |
| 62 | |
| Value stored to 'chatCreationInfo' is never read |
| 63 | chatCreationInfo = [NSMutableDictionary dictionaryWithObject:class |
| 64 | forKey:@"class"]; |
| 65 | |
| 66 | |
| 67 | chatCreationInfo = [NSDictionary dictionaryWithObjectsAndKeys:class,@"class",instance,@"instance",recipient,@"recipient",nil0]; |
| 68 | |
| 69 | name = [NSString stringWithFormat:@"%@,%@,%@",class,instance,recipient]; |
| 70 | |
| 71 | [self doJoinChatWithName:name |
| 72 | onAccount:inAccount |
| 73 | chatCreationInfo:chatCreationInfo |
| 74 | invitingContacts:nil0 |
| 75 | withInvitationMessage:nil0]; |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | |
| 80 | - (void)controlTextDidChange:(NSNotification *)notification |
| 81 | { |
| 82 | if ([notification object] == textField_class) { |
| 83 | [self validateEnteredText]; |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | - (void)validateEnteredText |
| 88 | { |
| 89 | NSString *class = [textField_class stringValue]; |
| 90 | BOOL enabled = NO( BOOL ) 0; |
| 91 | |
| 92 | if (class && [class length]) { |
| 93 | enabled = YES( BOOL ) 1; |
| 94 | } |
| 95 | |
| 96 | if (delegate) |
| 97 | [(DCJoinChatWindowController *)delegate setJoinChatEnabled:enabled]; |
| 98 | } |
| 99 | |
| 100 | @end |