| 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.17 |
#import "ComposeController.h" |
| 13 |
|
|
#import "TextFormatter.h" |
| 14 |
|
|
#import "LineTextFormatter.h" |
| 15 |
|
|
#import "MailTextFormatManager.h" |
| 16 |
footashida |
1.16 |
|
| 17 |
footashida |
1.1 |
@implementation MainController |
| 18 |
footashida |
1.13 |
-(void)setupToolbar{ |
| 19 |
footashida |
1.1 |
NSToolbar *toolbar; |
| 20 |
footashida |
1.2 |
MainToolbarSource *mainToolbarSource; |
| 21 |
footashida |
1.5 |
toolbar = [[NSToolbar alloc] initWithIdentifier:@"MainToolBar"]; |
| 22 |
footashida |
1.2 |
mainToolbarSource = [[MainToolbarSource alloc] initWithController:self]; |
| 23 |
|
|
[toolbar setDelegate:mainToolbarSource]; |
| 24 |
footashida |
1.1 |
[window setToolbar:toolbar]; |
| 25 |
|
|
[toolbar release]; |
| 26 |
|
|
|
| 27 |
footashida |
1.13 |
} |
| 28 |
|
|
-(void)awakeFromNib{ |
| 29 |
|
|
MailBoxOutlineDataSource *ds; |
| 30 |
footashida |
1.16 |
NSView *addressBookView; |
| 31 |
footashida |
1.13 |
|
| 32 |
|
|
[window center]; |
| 33 |
|
|
mailBoxManager = [[DUMMailBoxManager alloc] init]; |
| 34 |
|
|
ds = [[MailBoxOutlineDataSource alloc] |
| 35 |
|
|
initWithMailBoxManager:mailBoxManager]; |
| 36 |
|
|
[folderTree setDataSource:ds]; |
| 37 |
|
|
[self setupToolbar]; |
| 38 |
footashida |
1.17 |
// addressBookView = [[[self addressBookController] addressBookView] retain]; |
| 39 |
|
|
// [addressBookDrawer setContentView:addressBookView]; |
| 40 |
|
|
composeControllers = [[NSMutableArray alloc] init]; |
| 41 |
footashida |
1.1 |
|
| 42 |
footashida |
1.17 |
[[mailContents textStorage] setDelegate:self]; |
| 43 |
|
|
mailTextFormatManager = [[MailTextFormatManager alloc] init]; |
| 44 |
|
|
[mailTextFormatManager addHeaderTextFormatter: |
| 45 |
|
|
[[TextFormatter alloc] initWithName:@"default" |
| 46 |
|
|
pattern:@"" |
| 47 |
|
|
foregroundColor:[NSColor blackColor] |
| 48 |
|
|
backgroundColor:[NSColor whiteColor] |
| 49 |
|
|
font:[NSFont fontWithName:@"HiraKakuPro-W3" size:13.0]]]; |
| 50 |
|
|
[mailTextFormatManager addContentsTextFormatter: |
| 51 |
|
|
[[TextFormatter alloc] initWithName:@"default" |
| 52 |
|
|
pattern:@"" |
| 53 |
|
|
foregroundColor:[NSColor blackColor] |
| 54 |
|
|
backgroundColor:[NSColor whiteColor] |
| 55 |
|
|
font:[NSFont fontWithName:@"HiraKakuPro-W3" size:12.0]]]; |
| 56 |
|
|
|
| 57 |
|
|
[mailTextFormatManager addContentsTextFormatter: |
| 58 |
|
|
[[LineTextFormatter alloc] initWithName:@"inyo" |
| 59 |
|
|
pattern:@">" |
| 60 |
|
|
foregroundColor:[NSColor colorWithCalibratedRed:0.0 |
| 61 |
|
|
green:0.8 |
| 62 |
|
|
blue:0.48 |
| 63 |
|
|
alpha:1.0] |
| 64 |
|
|
backgroundColor:[NSColor whiteColor] |
| 65 |
|
|
font:[NSFont fontWithName:@"HiraKakuPro-W3" size:12.0]]]; |
| 66 |
|
|
|
| 67 |
footashida |
1.1 |
} |
| 68 |
footashida |
1.15 |
-(void)dealloc{ |
| 69 |
|
|
[window release]; |
| 70 |
|
|
[searchWindow release]; |
| 71 |
|
|
[mailList release]; |
| 72 |
|
|
[folderTree release]; |
| 73 |
|
|
[mailContents release]; |
| 74 |
|
|
[mailBoxManager release]; |
| 75 |
|
|
[prefController release]; |
| 76 |
|
|
[addressbookController release]; |
| 77 |
footashida |
1.17 |
[mailTextFormatManager release]; |
| 78 |
footashida |
1.15 |
[super dealloc]; |
| 79 |
|
|
} |
| 80 |
footashida |
1.17 |
-(BOOL)windowShouldClose:(id)sender{ |
| 81 |
|
|
NSLog(@"window close!"); |
| 82 |
|
|
[composeControllers removeObject:[sender windowController]]; |
| 83 |
|
|
return YES; |
| 84 |
|
|
} |
| 85 |
footashida |
1.1 |
- (void)applicationDidFinishLaunching:(NSNotification*)notif |
| 86 |
|
|
{ |
| 87 |
|
|
NSTableColumn* tableColumn; |
| 88 |
|
|
IconedCell* iconedCell; |
| 89 |
|
|
// �t�H���_�c���[���A�A�C�R��+�������\���������������ACell�����X���s���B |
| 90 |
|
|
tableColumn = [folderTree tableColumnWithIdentifier:@"folderview"]; |
| 91 |
|
|
iconedCell = [[[IconedCell alloc] init] autorelease]; |
| 92 |
|
|
[tableColumn setDataCell:iconedCell]; |
| 93 |
|
|
} |
| 94 |
|
|
-(IBAction)createNewMessage:(id)sender{ |
| 95 |
footashida |
1.17 |
ComposeController *controller = [[ComposeController alloc] init]; |
| 96 |
|
|
[controller setAddressBookController:[self addressBookController]]; |
| 97 |
|
|
[[self addressBookController] setComposeController:controller]; |
| 98 |
|
|
[controller createNewMessageWithHeader:nil contents:nil]; |
| 99 |
|
|
[composeControllers addObject:controller]; |
| 100 |
|
|
[controller release]; |
| 101 |
|
|
|
| 102 |
footashida |
1.1 |
} |
| 103 |
footashida |
1.2 |
-(IBAction)showPreference:(id)sender{ |
| 104 |
footashida |
1.12 |
if(prefController == nil){ |
| 105 |
|
|
prefController = [[PreferenceController alloc] init]; |
| 106 |
footashida |
1.3 |
} |
| 107 |
footashida |
1.12 |
[prefController showWindow:self]; |
| 108 |
footashida |
1.1 |
} |
| 109 |
footashida |
1.9 |
-(IBAction)createRule:(id)sender{ |
| 110 |
|
|
[self showPreference:self]; |
| 111 |
footashida |
1.12 |
[prefController selectPreferenceTabWithName:@"rule_tab"]; |
| 112 |
|
|
} |
| 113 |
|
|
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item{ |
| 114 |
|
|
MailBoxTableDataSource *ds; |
| 115 |
|
|
|
| 116 |
|
|
if([mailList dataSource] == nil){ |
| 117 |
|
|
ds = [[MailBoxTableDataSource alloc] initWithMailBox:item]; |
| 118 |
|
|
[mailList setDataSource:ds]; |
| 119 |
|
|
}else{ |
| 120 |
|
|
ds = [mailList dataSource]; |
| 121 |
|
|
[ds changeMailBox:item]; |
| 122 |
|
|
} |
| 123 |
|
|
[mailList reloadData]; |
| 124 |
footashida |
1.13 |
return YES; |
| 125 |
|
|
} |
| 126 |
|
|
- (BOOL)tableView:(NSTableView *)aTableView shouldSelectRow:(int)rowIndex{ |
| 127 |
|
|
MailBoxTableDataSource *ds; |
| 128 |
|
|
DUMMailBox *selectedMailBox; |
| 129 |
|
|
DUMMail *mail; |
| 130 |
footashida |
1.17 |
NSAttributedString *headerString; |
| 131 |
|
|
NSAttributedString *contentsString; |
| 132 |
|
|
NSTextStorage *textStorage; |
| 133 |
footashida |
1.13 |
|
| 134 |
|
|
ds = [aTableView dataSource]; |
| 135 |
|
|
selectedMailBox = [ds mailBox]; |
| 136 |
|
|
mail = [selectedMailBox mailAtIndex:rowIndex]; |
| 137 |
footashida |
1.17 |
headerString = [mailTextFormatManager formatHeader:[mail headerText]]; |
| 138 |
|
|
contentsString = [mailTextFormatManager formatContents:[mail content]]; |
| 139 |
|
|
textStorage = [mailContents textStorage]; |
| 140 |
|
|
[textStorage beginEditing]; |
| 141 |
|
|
[textStorage deleteCharactersInRange:NSMakeRange(0, [textStorage length])]; |
| 142 |
|
|
[textStorage appendAttributedString:headerString]; |
| 143 |
|
|
[textStorage appendAttributedString:contentsString]; |
| 144 |
|
|
[textStorage endEditing]; |
| 145 |
footashida |
1.15 |
[mail setIsUnread:NO]; |
| 146 |
|
|
[folderTree reloadData]; |
| 147 |
footashida |
1.12 |
return YES; |
| 148 |
footashida |
1.14 |
} |
| 149 |
footashida |
1.17 |
//-(IBAction)showAddressBook{ |
| 150 |
|
|
// [addressBookDrawer toggle:self]; |
| 151 |
|
|
//} |
| 152 |
footashida |
1.16 |
-(AddressBookController *)addressBookController{ |
| 153 |
footashida |
1.14 |
if(addressbookController == nil){ |
| 154 |
|
|
addressbookController |
| 155 |
|
|
= [[AddressBookController alloc] init]; |
| 156 |
|
|
} |
| 157 |
footashida |
1.16 |
[addressbookController window]; |
| 158 |
|
|
return addressbookController; |
| 159 |
footashida |
1.9 |
} |
| 160 |
footashida |
1.17 |
@end |