From 316409d56f5b50e0c6bf170574c64195f44422b0 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Wed, 3 Apr 2013 00:23:49 -0700 Subject: Cleaned example --- .../macExample.xcodeproj/project.pbxproj | 47 +- example/mac/macExample/macExample/AppDelegate.h | 15 +- example/mac/macExample/macExample/AppDelegate.m | 114 +++- .../macExample/MCTMsgListViewController.h | 4 +- .../macExample/MCTMsgListViewController.m | 10 +- .../macExample/macExample/MCTMsgViewController.h | 2 +- .../macExample/macExample/MCTMsgViewController.m | 2 +- .../macExample/macExample/en.lproj/MainMenu.xib | 661 ++++++++------------- .../macExample/macExample/macExample-Info.plist | 2 +- example/mac/macExample/macExample/main.mm | 2 +- 10 files changed, 406 insertions(+), 453 deletions(-) (limited to 'example/mac') diff --git a/example/mac/macExample/macExample.xcodeproj/project.pbxproj b/example/mac/macExample/macExample.xcodeproj/project.pbxproj index 81392995..85a34d62 100644 --- a/example/mac/macExample/macExample.xcodeproj/project.pbxproj +++ b/example/mac/macExample/macExample.xcodeproj/project.pbxproj @@ -10,6 +10,7 @@ C64FF38416AF97F400F8C162 /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = C64FF38316AF97F400F8C162 /* main.mm */; }; C6BD2873170BC5C500A91AC1 /* MCOCIDURLProtocol.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6BD2870170BC5C500A91AC1 /* MCOCIDURLProtocol.mm */; }; C6BD2874170BC5C500A91AC1 /* MCOMessageView.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6BD2872170BC5C500A91AC1 /* MCOMessageView.mm */; }; + C6BD28B4170BDFE500A91AC1 /* MailCore2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C6BD28B3170BDFE500A91AC1 /* MailCore2.framework */; }; C6D42BB616ABB39A002BB4F9 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C6D42BB516ABB39A002BB4F9 /* Cocoa.framework */; }; C6D42BC916ABB39A002BB4F9 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = C6D42BC816ABB39A002BB4F9 /* AppDelegate.m */; }; C6D42BCC16ABB39A002BB4F9 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = C6D42BCA16ABB39A002BB4F9 /* MainMenu.xib */; }; @@ -54,6 +55,13 @@ remoteGlobalIDString = C64EA536169E772200778456; remoteInfo = mailcore2; }; + C6BD28B2170BDFE500A91AC1 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = C6BD2877170BC8ED00A91AC1 /* mailcore2.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = C6BD288D170BD71100A91AC1; + remoteInfo = "mailcore osx"; + }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ @@ -84,6 +92,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + C6BD28B4170BDFE500A91AC1 /* MailCore2.framework in Frameworks */, C6D42BE516ABB511002BB4F9 /* WebKit.framework in Frameworks */, C6D42BB616ABB39A002BB4F9 /* Cocoa.framework in Frameworks */, ); @@ -135,6 +144,7 @@ C6BD2881170BC8ED00A91AC1 /* libmailcore2-ios.a */, C6BD2883170BC8ED00A91AC1 /* tests */, C6BD2885170BC8ED00A91AC1 /* test-ios.app */, + C6BD28B3170BDFE500A91AC1 /* MailCore2.framework */, ); name = Products; sourceTree = ""; @@ -284,6 +294,13 @@ remoteRef = C6BD2884170BC8ED00A91AC1 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; + C6BD28B3170BDFE500A91AC1 /* MailCore2.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = MailCore2.framework; + remoteRef = C6BD28B2170BDFE500A91AC1 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; /* End PBXReferenceProxy section */ /* Begin PBXResourcesBuildPhase section */ @@ -402,21 +419,6 @@ "$(SRCROOT)/../../../Externals/icu4c/lib", "$(SRCROOT)/../../../Externals/ctemplate/lib", ); - OTHER_LDFLAGS = ( - "-ObjC", - "-letpan", - "-licudata", - "-licui18n", - "-licuuc", - "-lxml2", - "-lssl", - "-lcrypto", - "-lsasl2", - "-liconv", - "-lctemplate", - "-ltidy", - "-lmailcore2", - ); PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; }; @@ -440,21 +442,6 @@ "$(SRCROOT)/../../../Externals/icu4c/lib", "$(SRCROOT)/../../../Externals/ctemplate/lib", ); - OTHER_LDFLAGS = ( - "-ObjC", - "-letpan", - "-licudata", - "-licui18n", - "-licuuc", - "-lxml2", - "-lssl", - "-lcrypto", - "-lsasl2", - "-liconv", - "-lctemplate", - "-ltidy", - "-lmailcore2", - ); PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; }; diff --git a/example/mac/macExample/macExample/AppDelegate.h b/example/mac/macExample/macExample/AppDelegate.h index a47dfbad..1d0ba332 100644 --- a/example/mac/macExample/macExample/AppDelegate.h +++ b/example/mac/macExample/macExample/AppDelegate.h @@ -8,8 +8,19 @@ #import -@interface AppDelegate : NSObject +@class MCTMsgListViewController; -@property (assign) IBOutlet NSWindow *window; +@interface AppDelegate : NSObject { + IBOutlet NSButton * _loginButton; + IBOutlet NSButton * _cancelButton; + IBOutlet NSTextField * _loginTextField; + IBOutlet NSTextField * _passwordTextField; + IBOutlet NSProgressIndicator * _progressView; + IBOutlet MCTMsgListViewController * _msgListViewController; + IBOutlet NSWindow * _accountWindow; +} + +- (IBAction) accountLogin:(id)sender; +- (IBAction) accountCancel:(id)sender; @end diff --git a/example/mac/macExample/macExample/AppDelegate.m b/example/mac/macExample/macExample/AppDelegate.m index 8f89fe10..12c744e8 100644 --- a/example/mac/macExample/macExample/AppDelegate.m +++ b/example/mac/macExample/macExample/AppDelegate.m @@ -8,16 +8,122 @@ #import "AppDelegate.h" -@implementation AppDelegate +#import -- (void)dealloc +#import "MCTMsgListViewController.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate { + MCOIMAPSession * _session; + MCOIMAPOperation * _checkOp; +} + +- (void) dealloc { [super dealloc]; } -- (void)applicationDidFinishLaunching:(NSNotification *)aNotification +- (void) awakeFromNib +{ + [_loginTextField setDelegate:self]; + [_passwordTextField setDelegate:self]; +} + +- (void) applicationDidFinishLaunching:(NSNotification *)aNotification +{ + [self _updateState]; + + NSString * login = [[NSUserDefaults standardUserDefaults] stringForKey:@"Login"]; + NSString * password = [[NSUserDefaults standardUserDefaults] stringForKey:@"Password"]; + + if (([login length] == 0) || ([password length] == 0)) { + [_accountWindow makeKeyAndOrderFront:nil]; + } + else { + [_loginTextField setStringValue:login]; + [_passwordTextField setStringValue:password]; + } +} + +- (void) accountLogin:(id)sender +{ + NSString * login = [_loginTextField stringValue]; + NSString * password = [_passwordTextField stringValue]; + + NSLog(@"try login"); + _session = [[MCOIMAPSession alloc] init]; + [_session setHostname:@"imap.gmail.com"]; + [_session setPort:993]; + [_session setUsername:login]; + [_session setPassword:password]; + [_session setConnectionType:MCOConnectionTypeTLS]; + _checkOp = [[_session checkAccountOperation] retain]; + NSLog(@"start op"); + [_checkOp start:^(NSError * error) { + [_accountWindow orderOut:nil]; + + NSString * login = [_loginTextField stringValue]; + NSString * password = [_passwordTextField stringValue]; + [[NSUserDefaults standardUserDefaults] setObject:login forKey:@"Login"]; + [[NSUserDefaults standardUserDefaults] setObject:password forKey:@"Password"]; + + [_checkOp release]; + _checkOp = nil; + [_session release]; + _session = nil; + + [self _updateState]; + + NSLog(@"op done %@", error); + + [_msgListViewController connect]; + }]; + + [self _updateState]; +} + +- (void) accountCancel:(id)sender +{ + [_checkOp cancel]; + [_checkOp release]; + _checkOp = nil; + [_session release]; + _session = nil; + + [self _updateState]; +} + +- (void) _updateState +{ + if (_checkOp == nil) { + [_loginTextField setEnabled:YES]; + [_passwordTextField setEnabled:YES]; + NSString * login = [_loginTextField stringValue]; + NSString * password = [_passwordTextField stringValue]; + if (([login length] > 0) && ([password length] > 0)) { + [_loginButton setEnabled:YES]; + } + else { + [_loginButton setEnabled:NO]; + } + [_cancelButton setEnabled:NO]; + [_progressView stopAnimation:nil]; + } + else { + [_loginTextField setEnabled:NO]; + [_passwordTextField setEnabled:NO]; + [_loginButton setEnabled:NO]; + [_cancelButton setEnabled:YES]; + [_progressView startAnimation:nil]; + } +} + +- (void) controlTextDidChange:(NSNotification *)aNotification { - // Insert code here to initialize your application + [self _updateState]; } @end diff --git a/example/mac/macExample/macExample/MCTMsgListViewController.h b/example/mac/macExample/macExample/MCTMsgListViewController.h index fbd76411..4730e4fc 100644 --- a/example/mac/macExample/macExample/MCTMsgListViewController.h +++ b/example/mac/macExample/macExample/MCTMsgListViewController.h @@ -7,7 +7,7 @@ // #import -#include +#include @class MCTMsgViewController; @@ -19,4 +19,6 @@ NSArray * _messages; } +- (void) connect; + @end diff --git a/example/mac/macExample/macExample/MCTMsgListViewController.m b/example/mac/macExample/macExample/MCTMsgListViewController.m index b2275686..b49d61eb 100644 --- a/example/mac/macExample/macExample/MCTMsgListViewController.m +++ b/example/mac/macExample/macExample/MCTMsgListViewController.m @@ -8,12 +8,11 @@ #import "MCTMsgListViewController.h" -#include +#include #import "MCTMsgViewController.h" #define FOLDER @"INBOX" -//#define FOLDER @"[Gmail]/All Mail" @interface MCTMsgListViewController () @@ -22,11 +21,18 @@ @implementation MCTMsgListViewController - (void) awakeFromNib +{ + [self connect]; +} + +- (void) connect { [_msgViewController setFolder:FOLDER]; NSString * login = [[NSUserDefaults standardUserDefaults] stringForKey:@"Login"]; NSString * password = [[NSUserDefaults standardUserDefaults] stringForKey:@"Password"]; + if (([login length] == 0) || ([password length] == 0)) + return; _session = [[MCOIMAPSession alloc] init]; [_session setHostname:@"imap.gmail.com"]; diff --git a/example/mac/macExample/macExample/MCTMsgViewController.h b/example/mac/macExample/macExample/MCTMsgViewController.h index a7bc0168..b620a24e 100644 --- a/example/mac/macExample/macExample/MCTMsgViewController.h +++ b/example/mac/macExample/macExample/MCTMsgViewController.h @@ -8,7 +8,7 @@ #import -#include +#include @class MCOMessageView; @class MCOIMAPAsyncSession; diff --git a/example/mac/macExample/macExample/MCTMsgViewController.m b/example/mac/macExample/macExample/MCTMsgViewController.m index 2f8dea38..6af399b5 100644 --- a/example/mac/macExample/macExample/MCTMsgViewController.m +++ b/example/mac/macExample/macExample/MCTMsgViewController.m @@ -41,7 +41,7 @@ [_message release]; _message = [message retain]; - if (0) { + if (![[NSUserDefaults standardUserDefaults] boolForKey:@"FetchFullMessageEnabled"]) { [_messageView setDelegate:self]; [_messageView setFolder:_folder]; [_messageView setMessage:message]; diff --git a/example/mac/macExample/macExample/en.lproj/MainMenu.xib b/example/mac/macExample/macExample/en.lproj/MainMenu.xib index a34a5ae2..a73aaf60 100644 --- a/example/mac/macExample/macExample/en.lproj/MainMenu.xib +++ b/example/mac/macExample/macExample/en.lproj/MainMenu.xib @@ -11,10 +11,13 @@ 3084 + NSButton + NSButtonCell NSCustomObject NSCustomView NSMenu NSMenuItem + NSProgressIndicator NSScrollView NSScroller NSSecureTextField @@ -51,7 +54,7 @@ - testUI + macExample 1048576 2147483647 @@ -65,11 +68,11 @@ submenuAction: - testUI + macExample - About testUI + About macExample 2147483647 @@ -134,7 +137,7 @@ - Hide testUI + Hide macExample h 1048576 2147483647 @@ -195,15 +198,6 @@ File - - - New - n - 1048576 - 2147483647 - - - Account... @@ -212,39 +206,13 @@ - - - Open… - o - 1048576 - 2147483647 - - - - + - Open Recent + Fetch Full Message - 1048576 2147483647 - submenuAction: - - Open Recent - - - - Clear Menu - - 1048576 - 2147483647 - - - - - _NSRecentDocumentsMenu - @@ -266,53 +234,6 @@ - - - Save… - s - 1048576 - 2147483647 - - - - - - Revert to Saved - - 2147483647 - - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Page Setup... - P - 1179648 - 2147483647 - - - - - - - Print… - p - 1048576 - 2147483647 - - - @@ -1195,39 +1116,6 @@ - - - View - - 1048576 - 2147483647 - - - submenuAction: - - View - - - - Show Toolbar - t - 1572864 - 2147483647 - - - - - - Customize Toolbar… - - 1048576 - 2147483647 - - - - - - Window @@ -1295,7 +1183,7 @@ - testUI Help + macExample Help ? 1048576 2147483647 @@ -1335,8 +1223,7 @@ 256 {192, 477} - - + _NS:13 YES NO @@ -1346,7 +1233,6 @@ 256 {192, 17} - _NS:16 @@ -1447,7 +1333,6 @@ {{1, 17}, {192, 477}} - _NS:11 @@ -1459,7 +1344,6 @@ -2147483392 {{224, 17}, {15, 102}} - _NS:58 NO @@ -1473,7 +1357,6 @@ -2147483392 {{1, 478}, {335, 16}} - _NS:60 NO @@ -1491,7 +1374,6 @@ {{1, 0}, {192, 17}} - _NS:15 @@ -1501,8 +1383,7 @@ {{-1, -1}, {194, 495}} - - + _NS:9 133682 @@ -1519,14 +1400,13 @@ 274 {{201, 0}, {567, 493}} - + _NS:9 MCOMessageView {768, 493} - {{0, 0}, {1366, 746}} @@ -1536,20 +1416,20 @@ 3 2 - {{505, 474}, {385, 94}} + {{505, 474}, {409, 123}} 611845120 Account NSWindow - + 256 268 - {{116, 52}, {249, 22}} + {{116, 81}, {249, 22}} _NS:9 @@ -1580,7 +1460,7 @@ 268 - {{72, 55}, {39, 17}} + {{72, 84}, {39, 17}} _NS:1535 @@ -1605,7 +1485,7 @@ 268 - {{47, 23}, {64, 17}} + {{47, 52}, {64, 17}} _NS:1535 @@ -1625,8 +1505,9 @@ 268 - {{116, 20}, {249, 22}} + {{116, 49}, {249, 22}} + _NS:9 YES @@ -1645,8 +1526,67 @@ NO + + + 268 + {{296, 13}, {75, 32}} + + + _NS:9 + YES + + 67108864 + 134217728 + Login + + _NS:9 + + -2038284288 + 129 + + DQ + 200 + 25 + + NO + + + + 268 + {{214, 13}, {82, 32}} + + + _NS:9 + YES + + 67108864 + 134217728 + Cancel + + _NS:9 + + -2038284288 + 129 + + Gw + 200 + 25 + + NO + + + + 268 + {{373, 22}, {16, 16}} + + + _NS:945 + 28938 + 100 + - {385, 94} + {409, 123} + _NS:20 @@ -1708,30 +1648,6 @@ 39 - - - print: - - - - 86 - - - - runPageLayout: - - - - 87 - - - - clearRecentDocuments: - - - - 127 - performClose: @@ -1892,38 +1808,6 @@ 357 - - - saveDocument: - - - - 362 - - - - revertDocumentToSaved: - - - - 364 - - - - runToolbarCustomizationPalette: - - - - 365 - - - - toggleToolbarShown: - - - - 366 - hide: @@ -1948,22 +1832,6 @@ 370 - - - newDocument: - - - - 373 - - - - openDocument: - - - - 374 - raiseBaseline: @@ -2348,6 +2216,118 @@ 532 + + + loginTextField + + + + 634 + + + + passwordTextField + + + + 635 + + + + cancelButton + + + + 636 + + + + loginButton + + + + 637 + + + + progressView + + + + 638 + + + + _loginTextField + + + + 639 + + + + _passwordTextField + + + + 640 + + + + _loginButton + + + + 641 + + + + _cancelButton + + + + 642 + + + + _progressView + + + + 643 + + + + _msgListViewController + + + + 644 + + + + _accountWindow + + + + 645 + + + + accountCancel: + + + + 652 + + + + accountLogin: + + + + 653 + dataSource @@ -2397,36 +2377,28 @@ 622 - - value: values.Login - - - - - - value: values.Login - value - values.Login - 2 - + + initialFirstResponder + + - 625 + 654 - value: values.Password - + value: values.FetchFullMessageEnabled + - + - value: values.Password + value: values.FetchFullMessageEnabled value - values.Password + values.FetchFullMessageEnabled 2 - 626 + 648 @@ -2463,7 +2435,6 @@ - @@ -2505,53 +2476,13 @@ 81 - - - - - - - - + - - 75 - - - - - 78 - - - - - 72 - - - - - 82 - - - - - 124 - - - - - - - - 77 - - - 73 @@ -2562,29 +2493,6 @@ - - 112 - - - - - 74 - - - - - 125 - - - - - - - - 126 - - - 205 @@ -2846,33 +2754,6 @@ - - 295 - - - - - - - - 296 - - - - - - - - - 297 - - - - - 298 - - - 211 @@ -3515,6 +3396,9 @@ + + + @@ -3575,16 +3459,48 @@ + + 627 + + + + + + + + 628 + + + + + 629 + + + + + + + + 630 + + + + + 631 + + + + + 646 + + + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -3628,10 +3544,6 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -3750,15 +3662,15 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -3766,80 +3678,9 @@ - 626 - - - - - AppDelegate - NSObject - - window - NSWindow - - - window - - window - NSWindow - - - - IBProjectSource - ./Classes/AppDelegate.h - - - - MCOMessageView - NSView - - IBProjectSource - ./Classes/MCOMessageView.h - - - - MCTMsgListViewController - NSViewController - - MCTMsgViewController - NSTableView - - - - _msgViewController - MCTMsgViewController - - - _tableView - NSTableView - - - - IBProjectSource - ./Classes/MCTMsgListViewController.h - - - - MCTMsgViewController - NSViewController - - _messageView - MCOMessageView - - - _messageView - - _messageView - MCOMessageView - - - - IBProjectSource - ./Classes/MCTMsgViewController.h - - - + 654 + 0 IBCocoaFramework YES diff --git a/example/mac/macExample/macExample/macExample-Info.plist b/example/mac/macExample/macExample/macExample-Info.plist index 7b990dc4..39e003f6 100644 --- a/example/mac/macExample/macExample/macExample-Info.plist +++ b/example/mac/macExample/macExample/macExample-Info.plist @@ -9,7 +9,7 @@ CFBundleIconFile CFBundleIdentifier - org.mailcore.${PRODUCT_NAME:rfc1034identifier} + com.libmailcore.${PRODUCT_NAME:rfc1034identifier} CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/example/mac/macExample/macExample/main.mm b/example/mac/macExample/macExample/main.mm index be0c2229..9572234a 100644 --- a/example/mac/macExample/macExample/main.mm +++ b/example/mac/macExample/macExample/main.mm @@ -7,7 +7,7 @@ // #import -#include +#include #include int main(int argc, char *argv[]) -- cgit v1.2.3