William Bowling is sharing code with you

Bitbucket is a code hosting site. Unlimited public and private repositories. Free for small teams.

Don't show this again

wbowling / adium (fork of adium / adium)

Fork of Adium for patches/improvements

Clone this repository (size: 338.7 MB): HTTPS / SSH
hg clone https://bitbucket.org/wbowling/adium
hg clone ssh://hg@bitbucket.org/wbowling/adium

adium / Plugins / Purple Service / ESIRCJoinChatViewController.m

//
//  ESIRCJoinChatViewController.m
//  Adium
//
//  Created by Evan Schoenberg on 3/4/06.
//

#import "ESIRCJoinChatViewController.h"

@interface ESIRCJoinChatViewController ()
- (void)validateEnteredText;
@end

@interface NSObject (JointChatViewDelegate)
- (void)setJoinChatEnabled:(BOOL)enabled;
@end

@implementation ESIRCJoinChatViewController
- (NSString *)nibName
{
        return @"ESIRCJoinChatView";
}

- (void)configureForAccount:(AIAccount *)inAccount
{
        [super configureForAccount:inAccount];
        
        [[view window] makeFirstResponder:textField_channel];
        [self validateEnteredText];
}

- (void)joinChatWithAccount:(AIAccount *)inAccount
{       
        NSString                        *channel;
        NSMutableDictionary     *chatCreationInfo;
        
        //Obtain room and exchange from the view
        channel = [textField_channel stringValue];
        
        if (channel && [channel length]) {
                //The chatCreationInfo has keys corresponding to the GHashTable keys and values to match them.
                chatCreationInfo = [NSMutableDictionary dictionaryWithObject:channel
                                                                                                                          forKey:@"channel"];
                
                NSString *password = [textField_password stringValue];
                if (password && [password length]) {
                        [chatCreationInfo setObject:password
                                                                 forKey:@"password"];
                }

                [self doJoinChatWithName:channel
                                           onAccount:inAccount
                                chatCreationInfo:chatCreationInfo
                                invitingContacts:nil
                   withInvitationMessage:nil];
                
        } else {
                NSLog(@"Error: No channel specified.");
        }
        
}

//Entered text is changing
- (void)controlTextDidChange:(NSNotification *)notification
{
        if ([notification object] == textField_channel) {
                [self validateEnteredText];
        }
}

- (void)validateEnteredText
{
        if (delegate && [delegate respondsToSelector:@selector(setJoinChatEnabled:)]) {
                NSString        *channel = [textField_channel stringValue];

                [delegate setJoinChatEnabled:(channel && [channel length])];
        }
}

@end