Skip to content

Commit 7441951

Browse files
committed
Update project for Xcode 4.
1 parent afbaa61 commit 7441951

22 files changed

+2745
-3613
lines changed

.gitignore

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,39 @@
1-
build/
1+
# Mac OS X Finder and whatnot
22
.DS_Store
33
*.psd
4-
*.pages
5-
**/*.pbxuser
6-
*.mode2v3
4+
5+
# Sparkle distribution Private Key (Don't check me in!)
6+
dsa_priv.pem
7+
8+
# XCode (and ancestors) per-user config (very noisy, and not relevant)
9+
*.mode1
710
*.mode1v3
8-
**/*.perspectivev*
11+
*.mode2v3
12+
*.perspective
13+
*.perspectivev3
14+
*.pbxuser
15+
Documentation/Generated
16+
doxygenWarnings.txt
17+
*.xcodeproj/xcuserdata/*.xcuserdatad
18+
*.xcodeproj/project.xcworkspace/xcuserdata/*.xcuserdatad
19+
20+
# Generated files
21+
VersionX-revision.h
22+
23+
# build products
24+
build/
25+
*.[oa]
26+
27+
# Other source repository archive directories (protects when importing)
28+
.hg
29+
.svn
30+
CVS
31+
32+
# automatic backup files
33+
*~.nib
34+
*.swp
35+
*~
36+
*(Autosaved).rtfd/
37+
Backup[ ]of[ ]*.pages/
38+
Backup[ ]of[ ]*.key/
39+
Backup[ ]of[ ]*.numbers/
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//
2+
// BWSheetController.h
3+
// BWToolkit
4+
//
5+
// Created by Brandon Walkin (www.brandonwalkin.com)
6+
// All code is provided under the New BSD license.
7+
//
8+
9+
#import <Cocoa/Cocoa.h>
10+
11+
@interface BWSheetController : NSObject
12+
{
13+
NSWindow *sheet;
14+
NSWindow *parentWindow;
15+
id delegate;
16+
}
17+
18+
@property (nonatomic, retain) IBOutlet NSWindow *sheet, *parentWindow;
19+
@property (nonatomic, retain) IBOutlet id delegate;
20+
21+
- (IBAction)openSheet:(id)sender;
22+
- (IBAction)closeSheet:(id)sender;
23+
- (IBAction)messageDelegateAndCloseSheet:(id)sender;
24+
25+
// The optional delegate should implement the method:
26+
// - (BOOL)shouldCloseSheet:(id)sender
27+
// Return YES if you want the sheet to close after the button click, NO if it shouldn't close. The sender
28+
// object is the button that requested the close. This is helpful because in the event that there are multiple buttons
29+
// hooked up to the messageDelegateAndCloseSheet: method, you can distinguish which button called the method.
30+
31+
@end
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
//
2+
// BWSheetController.m
3+
// BWToolkit
4+
//
5+
// Created by Brandon Walkin (www.brandonwalkin.com)
6+
// All code is provided under the New BSD license.
7+
//
8+
9+
#import "BWSheetController.h"
10+
//#import "NSWindow-NSTimeMachineSupport.h"
11+
12+
@implementation BWSheetController
13+
14+
@synthesize parentWindow, sheet, delegate;
15+
16+
- (void)awakeFromNib
17+
{
18+
// Hack so the sheet doesn't appear at launch in Cocoa Simulator (or in the actual app if "Visible at Launch" is checked)
19+
[sheet setAlphaValue:0];
20+
[sheet performSelector:@selector(orderOut:) withObject:nil afterDelay:0];
21+
22+
// If the sheet has a toolbar or a bottom bar, make sure those elements can't move the window (private API)
23+
if ([sheet respondsToSelector:@selector(setMovable:)])
24+
[sheet setMovable:NO];
25+
}
26+
27+
- (id)initWithCoder:(NSCoder *)decoder;
28+
{
29+
if ((self = [super init]) != nil)
30+
{
31+
NSWindowController *tempSheetController = [decoder decodeObjectForKey:@"BWSCSheet"];
32+
NSWindowController *tempParentWindowController = [decoder decodeObjectForKey:@"BWSCParentWindow"];
33+
34+
sheet = [tempSheetController window];
35+
parentWindow = [tempParentWindowController window];
36+
}
37+
return self;
38+
}
39+
40+
- (void)encodeWithCoder:(NSCoder*)coder
41+
{
42+
NSWindowController *tempSheetController = [[[NSWindowController alloc] initWithWindow:sheet] autorelease];
43+
NSWindowController *tempParentWindowController = [[[NSWindowController alloc] initWithWindow:parentWindow] autorelease];
44+
45+
[coder encodeObject:tempSheetController forKey:@"BWSCSheet"];
46+
[coder encodeObject:tempParentWindowController forKey:@"BWSCParentWindow"];
47+
}
48+
49+
- (IBAction)openSheet:(id)sender
50+
{
51+
[sheet setAlphaValue:1];
52+
[NSApp beginSheet:sheet modalForWindow:parentWindow modalDelegate:nil didEndSelector:nil contextInfo:nil];
53+
}
54+
55+
- (IBAction)closeSheet:(id)sender
56+
{
57+
[sheet orderOut:nil];
58+
[NSApp endSheet:sheet];
59+
}
60+
61+
- (IBAction)messageDelegateAndCloseSheet:(id)sender
62+
{
63+
if (delegate != nil && [delegate respondsToSelector:@selector(shouldCloseSheet:)])
64+
{
65+
if ([delegate performSelector:@selector(shouldCloseSheet:) withObject:sender])
66+
[self closeSheet:self];
67+
}
68+
else
69+
{
70+
[self closeSheet:self];
71+
}
72+
}
73+
74+
75+
@end

Classes/Controllers/MainController.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#import "KBHostmasksData.h"
1616
#import "KBLuaActionsData.h"
1717
#import "KBAutojoinData.h"
18-
#import "KBTextField.h"
18+
#import "KBSTextField.h"
1919

2020

2121
@interface MainController : NSObject {
@@ -27,7 +27,7 @@
2727
IBOutlet NSButton *nicknameAsTrigger;
2828
IBOutlet NSButton *rejoinKickedRooms;
2929
IBOutlet NSMenuItem *debugMenuItem;
30-
IBOutlet KBTextField *commandField;
30+
IBOutlet KBSTextField *commandField;
3131

3232
IBOutlet NSTextView *serverOutput;
3333
IBOutlet NSProgressIndicator *activityIndicator;

Classes/Controllers/MainController.m

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ @implementation MainController
2929
// Connect to or disconnect IRC connection
3030
- (IBAction)toggleIrcConnection:(id)sender
3131
{
32-
if (![ircConnection isConnected]) {
32+
if (![ircConnection isConnected]) {
33+
// Check if for valid irc login, create a random one if needed
34+
if ([settings.username length] == 0) {
35+
NSString *randomUser = [NSString stringWithFormat:@"Serty%i%i%i",arc4random() % 10,arc4random() % 10,arc4random() % 10];
36+
[settings setUsername:randomUser];
37+
}
38+
3339
// Get connection data
3440
NSArray *connectionArray = [[serverAddress stringValue] componentsSeparatedByString:@":"];
3541
NSString *ircServer;
@@ -62,6 +68,7 @@ - (IBAction)toggleIrcConnection:(id)sender
6268
[serverAddress setEnabled:NO];
6369
[mainView selectTabViewItemAtIndex:1];
6470
[ircConnection connectToIRC:[connectionData objectAtIndex:4] port:[[connectionData objectAtIndex:5] intValue]];
71+
[self logMessage:@"Establishing connection to server" type:1];
6572
}
6673
else {
6774
[activityIndicator startAnimation:self];
@@ -84,7 +91,7 @@ - (IBAction)parseCommand:(id)sender
8491
return;
8592
}
8693
if (![ircConnection isConnected]) {
87-
[self logMessage:@"IRCBot - No IRC Connection\n› Type help for help\n" type:1];
94+
[self logMessage:@"No IRC Connection\n› Type help for help\n" type:1];
8895
[commandField setStringValue:@""];
8996
return;
9097
}
@@ -114,7 +121,7 @@ - (IBAction)parseCommand:(id)sender
114121
}
115122
}
116123
else {
117-
[self logMessage:@"IRCBot - Invalid Command\n› Type help for help" type:4];
124+
[self logMessage:@"Invalid Command\n› Type help for help" type:4];
118125
}
119126

120127
[commandField addPopUpItemWithTitle:commandString];
@@ -165,7 +172,7 @@ - (void)awakeFromNib
165172
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
166173
{
167174
if (!(ircConnection = [[IRCConnection alloc] initWithDelegate:self]))
168-
[self logMessage:@"IRCBot - IRCConnection Allocation Error" type:1];
175+
[self logMessage:@"IRCConnection Allocation Error" type:1];
169176

170177
lua = [[LuaController alloc] init];
171178
[lua setParentClass:self];
@@ -176,7 +183,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
176183
[commandField setDisplaysMenu:YES];
177184

178185
[self refreshConnectionData];
179-
[self logMessage:@"Welcome to IRCBot\n For help type help.\n" type:4];
186+
[self logMessage:@"Welcome to IRCBot -- For help type help.\n" type:4];
180187
}
181188

182189
// Application should quit but server is still connected
@@ -256,7 +263,7 @@ - (void)pingAlive:(NSString *)server
256263
- (void)joinRoom:(NSString *)aRoom
257264
{
258265
if ([aRoom hasPrefix:@"#"]) {
259-
[self logMessage:@"IRCBot - Joining Room" type:1];
266+
[self logMessage:@"Joining Room" type:1];
260267
NSString* joinMessage = [NSString stringWithFormat:@"JOIN %@ \r\n", aRoom];
261268
[ircConnection sendRawString:joinMessage logAs:2];
262269
[rooms addRoom:aRoom];
@@ -266,7 +273,7 @@ - (void)joinRoom:(NSString *)aRoom
266273
- (void)partRoom:(NSString *)aRoom
267274
{
268275
if ([aRoom hasPrefix:@"#"]) {
269-
[self logMessage:@"IRCBot - Parting Room" type:1];
276+
[self logMessage:@"Parting Room" type:1];
270277
NSString* partMessage = [NSString stringWithFormat:@"PART %@ \r\n", aRoom];
271278
[ircConnection sendRawString:partMessage logAs:2];
272279
[rooms setStatus:@"None" forRoom:aRoom];
@@ -276,7 +283,7 @@ - (void)partRoom:(NSString *)aRoom
276283
- (void)authUser:(NSString *)aUsername pass:(NSString *)aPassword nick:(NSString *)aNick realName:(NSString *)aName
277284
{
278285
// Create auth messages
279-
[self logMessage:@"IRCBot - Authenticating User" type:1];
286+
[self logMessage:@"Authenticating User" type:1];
280287
NSString *userMessage, *passMessage, *nickMessage, *nickServMessage;
281288

282289
userMessage = [NSString stringWithFormat:@"USER %@ %@ %@ \r\n", aUsername, @" 0 * :", aName];
@@ -294,7 +301,7 @@ - (void)authUser:(NSString *)aUsername pass:(NSString *)aPassword nick:(NSString
294301
[ircConnection sendMessage:nickServMessage To:@"NickServ" logAs:2];
295302
}
296303
else {
297-
[self logMessage:@"IRCBot - No password specified!" type:1];
304+
[self logMessage:@"No password specified!" type:1];
298305
}
299306
}
300307

@@ -305,7 +312,7 @@ - (void)parseServerOutput:(NSString *)input type:(NSString *)type
305312
NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease];
306313
[formatter setDateFormat:@"hh:mm"];
307314
NSString *time = [formatter stringFromDate:[NSDate date]];
308-
[self logMessage:[NSString stringWithFormat:@"%@ %@ %@",time,type,input] type:0];
315+
[self logMessage:[NSString stringWithFormat:@"%@ [%@] %@",time,type,input] type:0];
309316
}
310317
else
311318
[self logMessage:[NSString stringWithFormat:@"%@",input] type:0];
@@ -356,7 +363,7 @@ - (void)parseServerOutput:(NSString *)input type:(NSString *)type
356363
NSRange tempRange = [[tempArray objectAtIndex:1] rangeOfString:[connectionData objectAtIndex:2]];
357364
NSString *room = [[tempArray objectAtIndex:1] substringWithRange:NSMakeRange(0,tempRange.location-1)];
358365
NSString *reason = [[tempArray objectAtIndex:1] substringFromIndex:tempRange.location+tempRange.length+2];
359-
[self logMessage:[NSString stringWithFormat:@"IRCBot - You have just been kicked from:%@ reason:%@",room,reason] type:1];
366+
[self logMessage:[NSString stringWithFormat:@"You have just been kicked from:%@ reason:%@",room,reason] type:1];
360367
[rooms setStatus:@"Warning" forRoom:room];
361368

362369
if ([rejoinKickedRooms state]) {
@@ -426,31 +433,31 @@ - (void)logMessage:(NSString *)message type:(int)type
426433
[secureMessage replaceCharactersInRange:[secureMessage rangeOfString:[connectionData objectAtIndex:1]] withString:@"******"];
427434

428435
// Get the length of the textview contents
429-
NSRange theEnd=NSMakeRange([[serverOutput string] length],0);
436+
NSRange theEnd = NSMakeRange([[serverOutput string] length],0);
430437

431438
NSMutableString *formatedMessage;
432-
NSColor *textColor;
439+
NSColor *textColor;
433440
NSFont *textFont = [NSFont fontWithName:@"Menlo" size:12.0];
434441

435442
// Setup color of string depending on type
436443
if (type == 1) {
437-
textColor = [NSColor colorWithCalibratedRed:0.35 green:0.00 blue:0.00 alpha:1.00];
444+
textColor = [NSColor colorWithCalibratedRed:0.35 green:0.00 blue:0.00 alpha:1.00]; // Red -- Notice
438445
formatedMessage = [NSString stringWithFormat:@"%@\n",secureMessage];
439446
}
440447
else if (type == 2) {
441-
textColor = [NSColor colorWithCalibratedRed:0.00 green:0.00 blue:0.35 alpha:1.00];
448+
textColor = [NSColor colorWithCalibratedRed:0.00 green:0.00 blue:0.35 alpha:1.00]; // Blue -- Status
442449
formatedMessage = [NSString stringWithFormat:@"%@",secureMessage];
443450
}
444451
else if (type == 3) {
445-
textColor = [NSColor colorWithCalibratedRed:0.15 green:0.30 blue:0.00 alpha:1.00];
452+
textColor = [NSColor colorWithCalibratedRed:0.15 green:0.30 blue:0.00 alpha:1.00]; // Green -- Activity
446453
formatedMessage = [NSString stringWithFormat:@"%@",secureMessage];
447454
}
448455
else if (type == 4) {
449-
textColor = [NSColor colorWithCalibratedRed:0.24 green:0.00 blue:0.30 alpha:1.00];
456+
textColor = [NSColor colorWithCalibratedRed:0.24 green:0.00 blue:0.30 alpha:1.00]; // Purple -- Info
450457
formatedMessage = [NSString stringWithFormat:@"%@\n",secureMessage];
451458
}
452459
else {
453-
textColor = [NSColor blackColor];
460+
textColor = [NSColor blackColor]; // Black
454461
formatedMessage = [NSString stringWithFormat:@"%@\n",secureMessage];
455462
}
456463

@@ -496,7 +503,7 @@ - (void)didConnectToHost:(NSString *)host port:(UInt16)port
496503

497504
- (void)didDissconect
498505
{
499-
[self logMessage:@"IRCBot - Socket disconnected\n" type:1];
506+
[self logMessage:@"Socket disconnected\n" type:1];
500507

501508
// Stop activity indicator and disable and enable all relevant controls
502509
[activityIndicator stopAnimation:self];
@@ -505,7 +512,6 @@ - (void)didDissconect
505512
[connectionButton setEnabled:YES];
506513
[connectionButton setTitle:@"Connect"];
507514
[mainView selectTabViewItemAtIndex:0];
508-
[self clearLog:nil];
509515
}
510516

511517

Classes/Data/KBAutojoinData.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,14 @@ - (void)addRoom:(NSString *)room autojoin:(BOOL)autojoin
4444

4545
- (void)removeRoom:(NSString *)room
4646
{
47-
47+
// Untested
48+
int index;
49+
for (index = 0; [self.autojoinArray count] > index; index++) {
50+
if ([[[self.autojoinArray objectAtIndex:index] objectAtIndex:0] isEqualToString:room]) {
51+
[self.autojoinArray removeObjectAtIndex:index];
52+
return;
53+
}
54+
}
4855
}
4956

5057
- (void)clearData

Classes/Data/KBHostmasksData.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#import <Cocoa/Cocoa.h>
1010
#import "RegexKitLite.h"
11+
#import "BWSheetController.h"
1112

1213
@interface KBHostmasksData : NSObject {
1314
int userIndex;

Classes/Data/KBHostmasksData.m

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,10 @@ - (void)clearData
116116

117117
- (BOOL)getAuthForHostmask:(NSString *)hostmask
118118
{
119-
int index;
120119
for (NSArray *hostmaskData in self.hostmaskArray) {
121120
NSString *tempHostmask = [hostmaskData objectAtIndex:0];
122121
BOOL blocked = [[hostmaskData objectAtIndex:1] intValue];
123-
if ([tempHostmask isMatchedByRegex:hostmask] && !blocked) {
122+
if ([hostmask isMatchedByRegex:tempHostmask] && !blocked) {
124123
return YES;
125124
}
126125
}
@@ -149,7 +148,7 @@ - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColum
149148

150149
- (void)tableViewSelectionDidChange:(NSNotification *)notification
151150
{
152-
if ([hostmaskView selectedRow] == -1 || [hostmaskView selectedRow] == 0)
151+
if ([hostmaskView selectedRow] == -1)
153152
[removeHostmaskButton setEnabled:NO];
154153
else
155154
[removeHostmaskButton setEnabled:YES];

Classes/Data/KBLuaActionsData.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#import <Cocoa/Cocoa.h>
1010
#import "KBLuaAction.h"
11+
#import "BWSheetController.h"
1112

1213
@interface KBLuaActionsData : NSObject {
1314
int actionIndex;

0 commit comments

Comments
 (0)