Skip to content

Commit

Permalink
Add support for MobileMe accounts and iCal subscribed calendars. Cred…
Browse files Browse the repository at this point in the history
…it: David Barroso.
  • Loading branch information
nst committed Jan 5, 2010
1 parent 6deef4e commit 9c2b483
Show file tree
Hide file tree
Showing 8 changed files with 458 additions and 1,389 deletions.
2 changes: 2 additions & 0 deletions Classes/SPEmailAccount.h
Expand Up @@ -18,6 +18,7 @@
NSString *hostname;
NSString *username;
NSString *displayName;
NSMutableArray *calendars;
}

@property (nonatomic, retain) NSString *fullname;
Expand All @@ -26,6 +27,7 @@
@property (nonatomic, retain) NSString *hostname;
@property (nonatomic, retain) NSString *username;
@property (nonatomic, retain) NSString *displayName;
@property (nonatomic, retain) NSArray *calendars;

+ (SPEmailAccount *)accountWithDictionary:(NSDictionary *)d;
- (NSArray *)infoArray;
Expand Down
5 changes: 5 additions & 0 deletions Classes/SPEmailAccount.m
Expand Up @@ -18,6 +18,7 @@ @implementation SPEmailAccount
@synthesize hostname;
@synthesize username;
@synthesize displayName;
@synthesize calendars;

- (void)dealloc {
[fullname release];
Expand All @@ -44,6 +45,10 @@ - (NSArray *)infoArray {
for (id emailAddress in emails)
[a addObject:[NSString stringWithFormat:@"Email: %@", emailAddress]];
}
if (calendars) {
for (id calendar in calendars)
[a addObject:[NSString stringWithFormat:@"Calendar URL: %@", calendar]];
}

return a;
}
Expand Down
17 changes: 17 additions & 0 deletions Classes/SPEmailMobileMeAccount.h
@@ -0,0 +1,17 @@
//
// SPEmailMobileMeAccount.h
// SpyPhone
//
// Created by Nicolas Seriot on 11/20/09.
// Copyright 2009.
// Licensed under GPL 2.0 http://www.gnu.org/licenses/gpl-2.0.txt
//

#import "SPEmailAccount.h"


@interface SPEmailMobileMeAccount : SPEmailAccount {

}

@end
36 changes: 36 additions & 0 deletions Classes/SPEmailMobileMeAccount.m
@@ -0,0 +1,36 @@
//
// SPEmailMobileMeAccount.m
// SpyPhone
//
// Created by Nicolas Seriot on 11/20/09.
// Copyright 2009.
// Licensed under GPL 2.0 http://www.gnu.org/licenses/gpl-2.0.txt
//

#import "SPEmailMobileMeAccount.h"


@implementation SPEmailMobileMeAccount

+ (SPEmailAccount *)accountWithDictionary:(NSDictionary *)d {
SPEmailMobileMeAccount *account = [[SPEmailMobileMeAccount alloc] init];

account.type = [d valueForKey:@"Short Type String"];
account.fullname = [d valueForKey:@"FullUserName"];
account.emails = [d valueForKey:@"EmailAddresses"];
account.username = [d valueForKey:@"Username"];
account.displayName = [d valueForKey:@"DisplayName"];

NSMutableArray *theCalendars = [NSMutableArray array];
NSDictionary *calendars = [d valueForKey:@"Subscribed Calendars"];
if (calendars) {
for(id calendarItem in [calendars allValues]) {
[theCalendars addObject:[calendarItem valueForKey:@"com.apple.ical.urlsubscribe.url"]];
}

account.calendars = theCalendars;
}
return [account autorelease];
}

@end
12 changes: 7 additions & 5 deletions Classes/SPSourceEmailTVC.m
Expand Up @@ -14,6 +14,7 @@
#import "SPEmailIToolsAccount.h"
#import "SPEmailGmailAccount.h"
#import "SPEmailIMAPAccount.h"
#import "SPEmailMobileMeAccount.h"

@implementation SPSourceEmailTVC

Expand Down Expand Up @@ -44,11 +45,12 @@ - (void)loadData {
NSArray *accounts = [d valueForKey:@"Accounts"];
for(NSDictionary *account in accounts) {
NSString *classValue = [account valueForKey:@"Class"];
if([classValue isEqualToString:@"ASAccount"]) [accountsFound addObject:[SPEmailASAccount accountWithDictionary:account]];
if([classValue isEqualToString:@"POPAccount"]) [accountsFound addObject:[SPEmailPOPAccount accountWithDictionary:account]];
if([classValue isEqualToString:@"iToolsAccount"]) [accountsFound addObject:[SPEmailIToolsAccount accountWithDictionary:account]];
if([classValue isEqualToString:@"GmailAccount"]) [accountsFound addObject:[SPEmailGmailAccount accountWithDictionary:account]];
if([classValue isEqualToString:@"IMAPAccount"]) [accountsFound addObject:[SPEmailIMAPAccount accountWithDictionary:account]];
if([classValue isEqualToString:@"ASAccount"]) [accountsFound addObject:[SPEmailASAccount accountWithDictionary:account]];
if([classValue isEqualToString:@"POPAccount"]) [accountsFound addObject:[SPEmailPOPAccount accountWithDictionary:account]];
if([classValue isEqualToString:@"iToolsAccount"]) [accountsFound addObject:[SPEmailIToolsAccount accountWithDictionary:account]];
if([classValue isEqualToString:@"GmailAccount"]) [accountsFound addObject:[SPEmailGmailAccount accountWithDictionary:account]];
if([classValue isEqualToString:@"IMAPAccount"]) [accountsFound addObject:[SPEmailIMAPAccount accountWithDictionary:account]];
if([classValue isEqualToString:@"MobileMeAccount"]) [accountsFound addObject:[SPEmailMobileMeAccount accountWithDictionary:account]];
}

for(SPEmailAccount *account in accountsFound) {
Expand Down

0 comments on commit 9c2b483

Please sign in to comment.