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 againadium / Plugins / Purple Service / ESPurpleZephyrAccountViewController.m
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | /*
* Adium is the legal property of its developers, whose names are listed in the copyright file included
* with this source distribution.
*
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU
* General Public License as published by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program; if not,
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#import "ESPurpleZephyrAccountViewController.h"
#import "ESPurpleZephyrAccount.h"
#import <Adium/AIAccount.h>
@implementation ESPurpleZephyrAccountViewController
- (NSString *)nibName{
return @"ESPurpleZephyrAccountView";
}
/*!
* @brief Update control enabledness based on current state.
*/
- (void)updateControlAvailability
{
BOOL selection = ([tableView_servers selectedRow] != -1);
[minus_servers setEnabled:selection];
}
//Configure our controls
- (void)configureForAccount:(AIAccount *)inAccount
{
[super configureForAccount:inAccount];
[checkBox_exportAnyone setState:[[account preferenceForKey:KEY_ZEPHYR_EXPORT_ANYONE group:GROUP_ACCOUNT_STATUS] boolValue]];
[checkBox_exportSubs setState:[[account preferenceForKey:KEY_ZEPHYR_EXPORT_SUBS group:GROUP_ACCOUNT_STATUS] boolValue]];
[checkBox_launchZhm setState:[[account preferenceForKey:KEY_ZEPHYR_LAUNCH_ZHM group:GROUP_ACCOUNT_STATUS] boolValue]];
[textField_exposure setStringValue:[account preferenceForKey:KEY_ZEPHYR_EXPOSURE group:GROUP_ACCOUNT_STATUS]];
[textField_encoding setStringValue:[account preferenceForKey:KEY_ZEPHYR_ENCODING group:GROUP_ACCOUNT_STATUS]];
[self updateControlAvailability];
}
- (IBAction)changedPreference:(id)sender
{
if (sender == checkBox_exportAnyone) {
[account setPreference:[NSNumber numberWithBool:[sender state]]
forKey:KEY_ZEPHYR_EXPORT_ANYONE
group:GROUP_ACCOUNT_STATUS];
} else if (sender == checkBox_exportSubs) {
[account setPreference:[NSNumber numberWithBool:[sender state]]
forKey:KEY_ZEPHYR_EXPORT_SUBS
group:GROUP_ACCOUNT_STATUS];
} else if (sender == checkBox_launchZhm) {
[account setPreference:[NSNumber numberWithBool:[sender state]]
forKey:KEY_ZEPHYR_LAUNCH_ZHM
group:GROUP_ACCOUNT_STATUS];
} else if (sender == textField_exposure) {
NSString *exposure = [sender stringValue];
[account setPreference:([exposure length] ? exposure : nil)
forKey:KEY_ZEPHYR_EXPOSURE
group:GROUP_ACCOUNT_STATUS];
} else if (sender == textField_encoding) {
NSString *encoding = [sender stringValue];
[account setPreference:([encoding length] ? encoding : nil)
forKey:KEY_ZEPHYR_ENCODING
group:GROUP_ACCOUNT_STATUS];
} else {
[super changedPreference:sender];
}
}
// We are the data source for the table we use to show server names
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
{
NSArray *ray = [account preferenceForKey:KEY_ZEPHYR_SERVERS group:GROUP_ACCOUNT_STATUS];
NSParameterAssert(rowIndex >= 0 && rowIndex < [ray count]);
return [ray objectAtIndex:rowIndex];
}
- (void)tableView:(NSTableView *)aTableView setObjectValue:anObject forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
{
NSMutableArray *ray = [[account preferenceForKey:KEY_ZEPHYR_SERVERS group:GROUP_ACCOUNT_STATUS] mutableCopy];
NSParameterAssert(rowIndex >= 0 && rowIndex < [ray count]);
[ray replaceObjectAtIndex:rowIndex withObject:anObject];
[account setPreference:ray
forKey:KEY_ZEPHYR_SERVERS
group:GROUP_ACCOUNT_STATUS];
[ray release];
}
- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
{
return [[account preferenceForKey:KEY_ZEPHYR_SERVERS group:GROUP_ACCOUNT_STATUS] count];
}
/*!
* @brief Add a new server to the list of servers.
*/
- (IBAction)addRowToServerList:(id)sender {
NSArray *ray = [[account preferenceForKey:KEY_ZEPHYR_SERVERS group:GROUP_ACCOUNT_STATUS] retain];
[account setPreference:[ray arrayByAddingObject:@""]
forKey:KEY_ZEPHYR_SERVERS
group:GROUP_ACCOUNT_STATUS];
[tableView_servers reloadData];
[tableView_servers selectRowIndexes:[NSIndexSet indexSetWithIndex:[ray count]] byExtendingSelection:NO];
[tableView_servers editColumn:0 row:[ray count] withEvent:nil select:YES];
[ray release];
}
/*!
* @brief Remove the selected row from the list of servers.
*/
- (IBAction)removeSelectedRowFromServerList:(id)sender {
NSInteger idx = [tableView_servers selectedRow];
if (idx != -1) {
NSMutableArray *ray = [[account preferenceForKey:KEY_ZEPHYR_SERVERS group:GROUP_ACCOUNT_STATUS] mutableCopy];
[ray removeObjectAtIndex:idx];
[account setPreference:ray
forKey:KEY_ZEPHYR_SERVERS
group:GROUP_ACCOUNT_STATUS];
[ray release];
[tableView_servers reloadData];
}
}
/*!
* @brief Selection change
*/
- (void)tableViewSelectionDidChange:(NSNotification *)notification
{
[self updateControlAvailability];
}
@end
|