Skip to content

Instantly share code, notes, and snippets.

@ccgus ccgus/gist:292136
Created Feb 1, 2010

Embed
What would you like to do?
//
// 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
You can’t perform that action at this time.