| 1 |
footashida |
1.1 |
#import "MainController.h" |
| 2 |
footashida |
1.12 |
#import "MailBoxOutlineDataSource.h" |
| 3 |
footashida |
1.2 |
#import "MainToolbarSource.h" |
| 4 |
footashida |
1.1 |
#import "IconedCell.h" |
| 5 |
footashida |
1.2 |
#import "ComposeToolbarSource.h" |
| 6 |
footashida |
1.12 |
#import "PreferenceController.h" |
| 7 |
|
|
#import "DUMMailBoxManager.h" |
| 8 |
|
|
#import "MailBoxTableDataSource.h" |
| 9 |
footashida |
1.13 |
#import "DUMMail.h" |
| 10 |
|
|
#import "DUMMailBox.h" |
| 11 |
footashida |
1.14 |
#import "AddressBookController.h" |
| 12 |
footashida |
1.16 |
|
| 13 |
footashida |
1.1 |
@implementation MainController |
| 14 |
footashida |
1.13 |
-(void)setupToolbar{ |
| 15 |
footashida |
1.1 |
NSToolbar *toolbar; |
| 16 |
footashida |
1.2 |
MainToolbarSource *mainToolbarSource; |
| 17 |
|
|
ComposeToolbarSource *composeToolbarSource; |
| 18 |
footashida |
1.5 |
toolbar = [[NSToolbar alloc] initWithIdentifier:@"MainToolBar"]; |
| 19 |
footashida |
1.2 |
mainToolbarSource = [[MainToolbarSource alloc] initWithController:self]; |
| 20 |
|
|
[toolbar setDelegate:mainToolbarSource]; |
| 21 |
footashida |
1.1 |
[window setToolbar:toolbar]; |
| 22 |
|
|
[toolbar release]; |
| 23 |
|
|
|
| 24 |
footashida |
1.5 |
toolbar = [[NSToolbar alloc] initWithIdentifier:@"ComposeToolBar"]; |
| 25 |
footashida |
1.2 |
composeToolbarSource = [[ComposeToolbarSource alloc] initWithController:self]; |
| 26 |
|
|
[toolbar setDelegate:composeToolbarSource]; |
| 27 |
footashida |
1.1 |
[composeWindow setToolbar:toolbar]; |
| 28 |
|
|
[toolbar release]; |
| 29 |
footashida |
1.13 |
} |
| 30 |
|
|
-(void)awakeFromNib{ |
| 31 |
|
|
MailBoxOutlineDataSource *ds; |
| 32 |
footashida |
1.16 |
NSView *addressBookView; |
| 33 |
footashida |
1.13 |
|
| 34 |
|
|
[window center]; |
| 35 |
|
|
mailBoxManager = [[DUMMailBoxManager alloc] init]; |
| 36 |
|
|
ds = [[MailBoxOutlineDataSource alloc] |
| 37 |
|
|
initWithMailBoxManager:mailBoxManager]; |
| 38 |
|
|
[folderTree setDataSource:ds]; |
| 39 |
|
|
|
| 40 |
|
|
[self setupToolbar]; |
| 41 |
|
|
|
| 42 |
footashida |
1.1 |
|
| 43 |
footashida |
1.16 |
addressBookView = [[[self addressBookController] addressBookView] retain]; |
| 44 |
|
|
[addressBookDrawer setContentView:addressBookView]; |
| 45 |
footashida |
1.1 |
} |
| 46 |
footashida |
1.15 |
-(void)dealloc{ |
| 47 |
|
|
[window release]; |
| 48 |
|
|
[composeWindow release]; |
| 49 |
|
|
[searchWindow release]; |
| 50 |
|
|
[mailList release]; |
| 51 |
|
|
[folderTree release]; |
| 52 |
|
|
[mailContents release]; |
| 53 |
|
|
[mailBoxManager release]; |
| 54 |
|
|
[prefController release]; |
| 55 |
|
|
[addressbookController release]; |
| 56 |
|
|
[super dealloc]; |
| 57 |
|
|
} |
| 58 |
footashida |
1.1 |
- (void)applicationDidFinishLaunching:(NSNotification*)notif |
| 59 |
|
|
{ |
| 60 |
|
|
NSTableColumn* tableColumn; |
| 61 |
|
|
IconedCell* iconedCell; |
| 62 |
|
|
// �t�H���_�c���[���A�A�C�R��+�������\���������������ACell�����X���s���B |
| 63 |
|
|
tableColumn = [folderTree tableColumnWithIdentifier:@"folderview"]; |
| 64 |
|
|
iconedCell = [[[IconedCell alloc] init] autorelease]; |
| 65 |
|
|
[tableColumn setDataCell:iconedCell]; |
| 66 |
|
|
} |
| 67 |
|
|
-(IBAction)createNewMessage:(id)sender{ |
| 68 |
|
|
[composeWindow makeKeyAndOrderFront:nil]; |
| 69 |
|
|
} |
| 70 |
footashida |
1.2 |
-(IBAction)showPreference:(id)sender{ |
| 71 |
footashida |
1.12 |
if(prefController == nil){ |
| 72 |
|
|
prefController = [[PreferenceController alloc] init]; |
| 73 |
footashida |
1.3 |
} |
| 74 |
footashida |
1.12 |
[prefController showWindow:self]; |
| 75 |
footashida |
1.1 |
} |
| 76 |
footashida |
1.9 |
-(IBAction)createRule:(id)sender{ |
| 77 |
|
|
[self showPreference:self]; |
| 78 |
footashida |
1.12 |
[prefController selectPreferenceTabWithName:@"rule_tab"]; |
| 79 |
|
|
} |
| 80 |
|
|
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item{ |
| 81 |
|
|
MailBoxTableDataSource *ds; |
| 82 |
|
|
|
| 83 |
|
|
if([mailList dataSource] == nil){ |
| 84 |
|
|
ds = [[MailBoxTableDataSource alloc] initWithMailBox:item]; |
| 85 |
|
|
[mailList setDataSource:ds]; |
| 86 |
|
|
}else{ |
| 87 |
|
|
ds = [mailList dataSource]; |
| 88 |
|
|
[ds changeMailBox:item]; |
| 89 |
|
|
} |
| 90 |
|
|
[mailList reloadData]; |
| 91 |
footashida |
1.13 |
return YES; |
| 92 |
|
|
} |
| 93 |
|
|
- (BOOL)tableView:(NSTableView *)aTableView shouldSelectRow:(int)rowIndex{ |
| 94 |
|
|
MailBoxTableDataSource *ds; |
| 95 |
|
|
DUMMailBox *selectedMailBox; |
| 96 |
|
|
DUMMail *mail; |
| 97 |
|
|
NSString *text; |
| 98 |
|
|
|
| 99 |
|
|
ds = [aTableView dataSource]; |
| 100 |
|
|
selectedMailBox = [ds mailBox]; |
| 101 |
|
|
mail = [selectedMailBox mailAtIndex:rowIndex]; |
| 102 |
footashida |
1.16 |
text = [NSString stringWithFormat:@"%@\r\n\r\n%@", |
| 103 |
|
|
[mail headerText], |
| 104 |
|
|
[mail content]]; |
| 105 |
|
|
[mailContents |
| 106 |
|
|
replaceCharactersInRange: |
| 107 |
|
|
NSMakeRange(0, [[mailContents string] length]) |
| 108 |
|
|
withString:text]; |
| 109 |
footashida |
1.15 |
[mail setIsUnread:NO]; |
| 110 |
|
|
[folderTree reloadData]; |
| 111 |
footashida |
1.12 |
return YES; |
| 112 |
footashida |
1.14 |
} |
| 113 |
|
|
-(IBAction)showAddressBook{ |
| 114 |
footashida |
1.16 |
[addressBookDrawer toggle:self]; |
| 115 |
|
|
// if(addressbookController == nil){ |
| 116 |
|
|
// addressbookController |
| 117 |
|
|
// = [[AddressBookController alloc] init]; |
| 118 |
|
|
// } |
| 119 |
|
|
// [addressbookController showWindow:self]; |
| 120 |
|
|
} |
| 121 |
|
|
-(AddressBookController *)addressBookController{ |
| 122 |
footashida |
1.14 |
if(addressbookController == nil){ |
| 123 |
|
|
addressbookController |
| 124 |
|
|
= [[AddressBookController alloc] init]; |
| 125 |
|
|
} |
| 126 |
footashida |
1.16 |
[addressbookController window]; |
| 127 |
|
|
return addressbookController; |
| 128 |
footashida |
1.9 |
} |
| 129 |
footashida |
1.1 |
@end |