Skip to content

Commit

Permalink
Shows channel keys in valid form
Browse files Browse the repository at this point in the history
issue #24
  • Loading branch information
youknowone committed May 16, 2012
1 parent 196dd73 commit 7b49fac
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions Mac/Sources/NetworkWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,18 @@
@interface OneChannel : NSObject
{
@public
NSString *name;
NSString *key;
NSString *_name;
NSString *_key;
}
@property(nonatomic,retain) NSString *name, *key;

- (id)initWithChannelName:(NSString *)name;
+ (OneChannel *)channelWithName:(NSString *)name;

@end

@implementation OneChannel
@synthesize name, key;
@synthesize name=_name, key=_key;

- (void) dealloc
{
Expand All @@ -71,10 +72,16 @@ - (void) dealloc
[super dealloc];
}

+ (OneChannel *) channelWithName:(NSString *)aName {
OneChannel *channel = [[self alloc] init];
channel.name = aName;
return [channel autorelease];
- (id)initWithChannelName:(NSString *)name {
self = [super init];
if (self != nil) {
self.name = name;
}
return self;
}

+ (OneChannel *) channelWithName:(NSString *)name {
return [[[self alloc] initWithChannelName:name] autorelease];
}

@end
Expand Down Expand Up @@ -264,7 +271,7 @@ - (void) resetAutojoin
// First, the channels with keys
for ( OneChannel *channel in channels )
{
NSString *key = channel->key;
NSString *key = channel->_key;
if (key && [key length])
{
if ([ircNetChannels length])
Expand All @@ -273,21 +280,21 @@ - (void) resetAutojoin
[ircNetKeys appendString:@","];
}

[ircNetChannels appendString:channel->name];
[ircNetChannels appendString:channel->_name];
[ircNetKeys appendString:key];
}
}

// and then the channels without keys
for ( OneChannel *channel in channels )
{
NSString *key = channel->key;
NSString *key = channel->_key;
if ( !key || [key length] == 0)
{
if ([ircNetChannels length])
[ircNetChannels appendString:@","];

[ircNetChannels appendString:channel->name];
[ircNetChannels appendString:channel->_name];
}
}

Expand Down Expand Up @@ -351,10 +358,11 @@ - (void) parseAutojoin {
//
// <channel>{,<channel>} [<key>{,<key>}]
NSString *autojoins = [NSString stringWithUTF8String:autojoin];
NSArray *autojoinParts = [autojoins componentsSeparatedByString:@" \t\n"];
NSArray *autojoinParts = [autojoins componentsSeparatedByString:@" "];

NSString *channelsString = [autojoinParts objectAtIndex:0];
NSString *keysString = [autojoinParts count]>1 ? [autojoinParts objectAtIndex:1] : @"";
keysString = [keysString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];

for ( NSString *channelName in [channelsString componentsSeparatedByString:@","] ) {
[channels addObject:[OneChannel channelWithName:channelName]];
Expand Down Expand Up @@ -924,8 +932,8 @@ - (id) tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableCol
OneChannel *channel = [network->channels objectAtIndex:rowIndex];
switch (column)
{
case 0: return channel->name;
case 1: return channel->key;
case 0: return channel->_name;
case 1: return channel->_key;
}
}
else if (aTableView == networkCommandTableView)
Expand Down

0 comments on commit 7b49fac

Please sign in to comment.