Skip to content

Instantly share code, notes, and snippets.

@ccgus
Created February 1, 2010 22:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ccgus/292136 to your computer and use it in GitHub Desktop.
Save ccgus/292136 to your computer and use it in GitHub Desktop.
//
// LBIMAPTestAppDelegate.m
// LBIMAPTest
//
// Created by August Mueller on 1/29/10.
// Copyright 2010 Flying Meat Inc. All rights reserved.
//
#import "LBIMAPTestAppDelegate.h"
#import "IPAddress.h"
@implementation LBIMAPTestAppDelegate
@synthesize window;
- (void)quit {
[connection logoutWithBlock:^(BOOL success, NSError *arg2) {
if (success) {
[connection release];
connection = nil;
NSLog(@"ALL DONE");
}
else {
NSLog(@"LOGOUT WAS BORKED!");
}
[NSApp terminate:self];
}];
}
- (void)listMailboxes {
[connection listSubscribedMailboxesWithBock:^(BOOL success, NSError *arg2) {
debug(@"got mailboxes!");
NSArray *theList = [connection fetchedMailboxes];
for (NSDictionary *mailboxInfo in theList) {
debug(@"mailboxInfo: %@", mailboxInfo);
}
[connection selectMailbox:@"INBOX" block:^(BOOL success, NSError *arg2) {
debug(@"select worked!");
[self quit];
}];
}];
}
-(void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
IPAddress *addr = [IPAddress addressWithHostname:@"172.16.66.130" port:143];
connection = [[LBIMAPConnection alloc] initToAddress:addr];
[connection setDebugOutput:YES];
[connection connectUsingBlock:^(BOOL arg1, NSError *arg2) {
[connection loginWithUsername:@"gus" password:@"password" block:^(BOOL success, NSError *arg2) {
if (success) {
debug(@"woot!");
[self listMailboxes];
}
else {
debug(@"well shit.");
}
}];
}];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment