Updated to new version of MGMURLConnection to fix issues with quitting causing a crash, fixed issues with downloading voicemail, fixed issue with recordings not stopping when you hangup, updated the way delegates work with MGMInbox and MGMInstance.

This commit is contained in:
GRMrGecko 2011-02-24 11:24:19 -06:00
parent 7fdf9035a7
commit 62db28f9aa
49 changed files with 594 additions and 932 deletions

View File

@ -136,13 +136,9 @@ const int MGMCMaxResults = 10;
return; return;
isUpdating = YES; isUpdating = YES;
[updateLock lock]; [updateLock lock];
NSFileManager<NSFileManagerProtocol> *manager = [NSFileManager defaultManager]; NSFileManager *manager = [NSFileManager defaultManager];
if ([manager fileExistsAtPath:[[user supportPath] stringByAppendingPathComponent:MGMCUpdateDB]]) { if ([manager fileExistsAtPath:[[user supportPath] stringByAppendingPathComponent:MGMCUpdateDB]])
if ([manager respondsToSelector:@selector(removeFileAtPath:handler:)]) [manager removeItemAtPath:[[user supportPath] stringByAppendingPathComponent:MGMCUpdateDB]];
[manager removeFileAtPath:[[user supportPath] stringByAppendingPathComponent:MGMCUpdateDB] handler:nil];
else
[manager removeItemAtPath:[[user supportPath] stringByAppendingPathComponent:MGMCUpdateDB] error:nil];
}
updateConnection = [[MGMLiteConnection connectionWithPath:[[user supportPath] stringByAppendingPathComponent:MGMCUpdateDB]] retain]; updateConnection = [[MGMLiteConnection connectionWithPath:[[user supportPath] stringByAppendingPathComponent:MGMCUpdateDB]] retain];
if (updateConnection==nil) { if (updateConnection==nil) {
[self contactsError:nil]; [self contactsError:nil];
@ -217,17 +213,10 @@ const int MGMCMaxResults = 10;
- (void)updated { - (void)updated {
[updateLock lock]; [updateLock lock];
[self setContactsConnection:nil]; [self setContactsConnection:nil];
NSFileManager<NSFileManagerProtocol> *manager = [NSFileManager defaultManager]; NSFileManager *manager = [NSFileManager defaultManager];
if ([manager fileExistsAtPath:[[user supportPath] stringByAppendingPathComponent:MGMCContactsDB]]) { if ([manager fileExistsAtPath:[[user supportPath] stringByAppendingPathComponent:MGMCContactsDB]])
if ([manager respondsToSelector:@selector(removeFileAtPath:handler:)]) [manager removeItemAtPath:[[user supportPath] stringByAppendingPathComponent:MGMCContactsDB]];
[manager removeFileAtPath:[[user supportPath] stringByAppendingPathComponent:MGMCContactsDB] handler:nil]; [manager moveItemAtPath:[[user supportPath] stringByAppendingPathComponent:MGMCUpdateDB] toPath:[[user supportPath] stringByAppendingPathComponent:MGMCContactsDB]];
else
[manager removeItemAtPath:[[user supportPath] stringByAppendingPathComponent:MGMCContactsDB] error:nil];
}
if ([manager respondsToSelector:@selector(movePath:toPath:handler:)] )
[manager movePath:[[user supportPath] stringByAppendingPathComponent:MGMCUpdateDB] toPath:[[user supportPath] stringByAppendingPathComponent:MGMCContactsDB] handler:nil];
else
[manager moveItemAtPath:[[user supportPath] stringByAppendingPathComponent:MGMCUpdateDB] toPath:[[user supportPath] stringByAppendingPathComponent:MGMCContactsDB] error:nil];
[self setContactsConnection:[MGMLiteConnection connectionWithPath:[[user supportPath] stringByAppendingPathComponent:MGMCContactsDB]]]; [self setContactsConnection:[MGMLiteConnection connectionWithPath:[[user supportPath] stringByAppendingPathComponent:MGMCContactsDB]]];
[updateLock unlock]; [updateLock unlock];
isUpdating = NO; isUpdating = NO;

View File

@ -38,7 +38,7 @@ extern NSString * const MGMGCUseragent;
NSTimer *releaseTimer; NSTimer *releaseTimer;
} }
- (id)initWithDelegate:(id)theDelegate; - (id)initWithDelegate:(id)theDelegate;
+ (NSDictionary *)dictionaryWithData:(NSData *)theData; + (NSDictionary *)dictionaryWithString:(NSString *)theString;
- (MGMUser *)user; - (MGMUser *)user;
- (void)getContacts:(id)sender; - (void)getContacts:(id)sender;
- (void)parseContact; - (void)parseContact;

View File

@ -37,14 +37,18 @@ const BOOL MGMGoogleContactsInvisible = YES;
NSURLCredential *credentials = [NSURLCredential credentialWithUser:username password:[user password] persistence:NSURLCredentialPersistenceForSession]; NSURLCredential *credentials = [NSURLCredential credentialWithUser:username password:[user password] persistence:NSURLCredentialPersistenceForSession];
connectionManager = [[MGMURLConnectionManager managerWithCookieStorage:[user cookieStorage]] retain]; connectionManager = [[MGMURLConnectionManager managerWithCookieStorage:[user cookieStorage]] retain];
[connectionManager setCredentials:credentials]; [connectionManager setCredentials:credentials];
[connectionManager setCustomUseragent:MGMGCUseragent]; [connectionManager setUserAgent:MGMGCUseragent];
isAuthenticating = YES; isAuthenticating = YES;
afterAuthentication = [NSMutableArray new]; afterAuthentication = [NSMutableArray new];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:MGMGCAuthenticationURL] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:15.0]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:MGMGCAuthenticationURL] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:15.0];
[request setHTTPMethod:MGMPostMethod]; [request setHTTPMethod:MGMPostMethod];
[request setValue:MGMURLForm forHTTPHeaderField:MGMContentType]; [request setValue:MGMURLForm forHTTPHeaderField:MGMContentType];
[request setHTTPBody:[[NSString stringWithFormat:MGMGCAuthenticationBody, [username addPercentEscapes], [[user password] addPercentEscapes]] dataUsingEncoding:NSUTF8StringEncoding]]; [request setHTTPBody:[[NSString stringWithFormat:MGMGCAuthenticationBody, [username addPercentEscapes], [[user password] addPercentEscapes]] dataUsingEncoding:NSUTF8StringEncoding]];
[connectionManager connectionWithRequest:request delegate:self didFailWithError:@selector(authentication:didFailWithError:) didFinish:@selector(authenticationDidFinish:) invisible:MGMGoogleContactsInvisible object:nil]; MGMURLBasicHandler *handler = [MGMURLBasicHandler handlerWithRequest:request delegate:self];
[handler setFailWithError:@selector(authentication:didFailWithError:)];
[handler setFinish:@selector(authenticationDidFinish:)];
[handler setInvisible:MGMGoogleContactsInvisible];
[connectionManager addHandler:handler];
} }
return self; return self;
} }
@ -59,12 +63,11 @@ const BOOL MGMGoogleContactsInvisible = YES;
[contactPhoto release]; [contactPhoto release];
[super dealloc]; [super dealloc];
} }
- (void)authentication:(NSDictionary *)theInfo didFailWithError:(NSError *)theError { - (void)authentication:(MGMURLBasicHandler *)theHandler didFailWithError:(NSError *)theError {
NSLog(@"MGMGoogleContacts Error: %@", theError); NSLog(@"MGMGoogleContacts Error: %@", theError);
} }
+ (NSDictionary *)dictionaryWithData:(NSData *)theData { + (NSDictionary *)dictionaryWithString:(NSString *)theString {
NSString *string = [[NSString alloc] initWithData:theData encoding:NSUTF8StringEncoding]; NSArray *values = [theString componentsSeparatedByString:@"\n"];
NSArray *values = [string componentsSeparatedByString:@"\n"];
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary]; NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
for (int i=0; i<[values count]; i++) { for (int i=0; i<[values count]; i++) {
if (![[values objectAtIndex:i] isEqual:@""]) { if (![[values objectAtIndex:i] isEqual:@""]) {
@ -75,11 +78,10 @@ const BOOL MGMGoogleContactsInvisible = YES;
[dictionary setObject:value forKey:key]; [dictionary setObject:value forKey:key];
} }
} }
[string release];
return dictionary; return dictionary;
} }
- (void)authenticationDidFinish:(NSDictionary *)theInfo { - (void)authenticationDidFinish:(MGMURLBasicHandler *)theHandler {
NSDictionary *info = [MGMGoogleContacts dictionaryWithData:[theInfo objectForKey:MGMConnectionData]]; NSDictionary *info = [MGMGoogleContacts dictionaryWithString:[theHandler string]];
[authenticationString release]; [authenticationString release];
authenticationString = [[NSString stringWithFormat:@"GoogleLogin auth=%@", [info objectForKey:@"Auth"]] retain]; authenticationString = [[NSString stringWithFormat:@"GoogleLogin auth=%@", [info objectForKey:@"Auth"]] retain];
isAuthenticating = NO; isAuthenticating = NO;
@ -123,32 +125,36 @@ const BOOL MGMGoogleContactsInvisible = YES;
contactsSender = sender; contactsSender = sender;
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:MGMGCContactsURL] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60.0]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:MGMGCContactsURL] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60.0];
[request setValue:authenticationString forHTTPHeaderField:MGMGCAuthorization]; [request setValue:authenticationString forHTTPHeaderField:MGMGCAuthorization];
[connectionManager connectionWithRequest:request delegate:self didFailWithError:@selector(contacts:didFailWithError:) didFinish:@selector(contactsDidFinish:) invisible:MGMGoogleContactsInvisible object:nil]; MGMURLBasicHandler *handler = [MGMURLBasicHandler handlerWithRequest:request delegate:self];
[handler setFailWithError:@selector(contacts:didFailWithError:)];
[handler setFinish:@selector(contactsDidFinish:)];
[handler setInvisible:MGMGoogleContactsInvisible];
[connectionManager addHandler:handler];
} }
- (void)contacts:(NSDictionary *)theInfo didFailWithError:(NSError *)theError { - (void)contacts:(MGMURLBasicHandler *)theHandler didFailWithError:(NSError *)theError {
gettingContacts = NO; gettingContacts = NO;
NSLog(@"MGMGoogleContacts Error: %@", theError); NSLog(@"MGMGoogleContacts Error: %@", theError);
if ([contactsSender respondsToSelector:@selector(contactsError:)]) [contactsSender contactsError:theError]; if ([contactsSender respondsToSelector:@selector(contactsError:)]) [contactsSender contactsError:theError];
} }
- (void)contactsDidFinish:(NSDictionary *)theInfo { - (void)contactsDidFinish:(MGMURLBasicHandler *)theHandler {
[releaseTimer invalidate]; [releaseTimer invalidate];
[releaseTimer release]; [releaseTimer release];
releaseTimer = nil; releaseTimer = nil;
[contacts release]; [contacts release];
contacts = [NSMutableArray new]; contacts = [NSMutableArray new];
MGMXMLElement *XML = [(MGMXMLDocument *)[[[MGMXMLDocument alloc] initWithData:[theInfo objectForKey:MGMConnectionData] options:MGMXMLDocumentTidyXML error:nil] autorelease] rootElement]; MGMXMLElement *XML = [(MGMXMLDocument *)[[[MGMXMLDocument alloc] initWithData:[theHandler data] options:MGMXMLDocumentTidyXML error:nil] autorelease] rootElement];
contactEntries = [[XML elementsForName:@"entry"] retain]; contactEntries = [[XML elementsForName:@"entry"] retain];
contactsIndex=0; contactsIndex=0;
[self continueContacts]; [self continueContacts];
} }
- (void)photo:(NSDictionary *)theInfo didFailWithError:(NSError *)theError { - (void)photo:(MGMURLBasicHandler *)theHandler didFailWithError:(NSError *)theError {
NSLog(@"MGMGoogleContacts Photo Error: %@", theError); NSLog(@"MGMGoogleContacts Photo Error: %@", theError);
[self parseContact]; [self parseContact];
contactsIndex++; contactsIndex++;
[self continueContacts]; [self continueContacts];
} }
- (void)photoDidFinish:(NSDictionary *)theInfo { - (void)photoDidFinish:(MGMURLBasicHandler *)theHandler {
contactPhoto = [[theInfo objectForKey:MGMConnectionData] retain]; contactPhoto = [[theHandler data] retain];
[self parseContact]; [self parseContact];
contactsIndex++; contactsIndex++;
[self continueContacts]; [self continueContacts];
@ -222,7 +228,10 @@ const BOOL MGMGoogleContactsInvisible = YES;
NSString *url = [[[links objectAtIndex:i] attributeForName:@"href"] stringValue]; NSString *url = [[[links objectAtIndex:i] attributeForName:@"href"] stringValue];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60.0]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60.0];
[request setValue:authenticationString forHTTPHeaderField:MGMGCAuthorization]; [request setValue:authenticationString forHTTPHeaderField:MGMGCAuthorization];
[connectionManager connectionWithRequest:request delegate:self didFailWithError:@selector(photo:didFailWithError:) didFinish:@selector(photoDidFinish:) invisible:YES object:nil]; MGMURLBasicHandler *handler = [MGMURLBasicHandler handlerWithRequest:request delegate:self];
[handler setFailWithError:@selector(photo:didFailWithError:)];
[handler setFinish:@selector(photoDidFinish:)];
[connectionManager addHandler:handler];
loadingPhoto = YES; loadingPhoto = YES;
break; break;
} }
@ -276,14 +285,18 @@ const BOOL MGMGoogleContactsInvisible = YES;
groupsSender = sender; groupsSender = sender;
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:MGMGCGroupsURL]]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:MGMGCGroupsURL]];
[request setValue:authenticationString forHTTPHeaderField:MGMGCAuthorization]; [request setValue:authenticationString forHTTPHeaderField:MGMGCAuthorization];
[connectionManager connectionWithRequest:request delegate:self didFailWithError:@selector(groups:didFailWithError:) didFinish:@selector(groupsDidFinish:) invisible:MGMGoogleContactsInvisible object:nil]; MGMURLBasicHandler *handler = [MGMURLBasicHandler handlerWithRequest:request delegate:self];
[handler setFailWithError:@selector(groups:didFailWithError:)];
[handler setFinish:@selector(groupsDidFinish:)];
[handler setInvisible:MGMGoogleContactsInvisible];
[connectionManager addHandler:handler];
} }
- (void)groups:(NSDictionary *)theInfo didFailWithError:(NSError *)theError { - (void)groups:(MGMURLBasicHandler *)theHandler didFailWithError:(NSError *)theError {
gettingGroups = NO; gettingGroups = NO;
NSLog(@"MGMGoogleContacts Error: %@", theError); NSLog(@"MGMGoogleContacts Error: %@", theError);
} }
- (void)groupsDidFinish:(NSDictionary *)theInfo { - (void)groupsDidFinish:(MGMURLBasicHandler *)theHandler {
MGMXMLElement *XML = [(MGMXMLDocument *)[[[MGMXMLDocument alloc] initWithData:[theInfo objectForKey:MGMConnectionData] options:MGMXMLDocumentTidyXML error:nil] autorelease] rootElement]; MGMXMLElement *XML = [(MGMXMLDocument *)[[[MGMXMLDocument alloc] initWithData:[theHandler data] options:MGMXMLDocumentTidyXML error:nil] autorelease] rootElement];
NSLog(@"%@", XML); NSLog(@"%@", XML);
gettingGroups = NO; gettingGroups = NO;
} }

View File

@ -59,17 +59,3 @@ NSComparisonResult dateSort(NSDictionary *info1, NSDictionary *info2, void *cont
- (NSData *)resizeTo:(NSSize)theSize; - (NSData *)resizeTo:(NSSize)theSize;
#endif #endif
@end @end
@protocol NSFileManagerProtocol <NSObject>
- (BOOL)createDirectoryAtPath:(NSString *)path withIntermediateDirectories:(BOOL)createIntermediates attributes:(NSDictionary *)attributes error:(NSError **)error;
- (BOOL)createDirectoryAtPath:(NSString *)path attributes:(NSDictionary *)attributes;
- (BOOL)removeItemAtPath:(NSString *)path error:(NSError **)error;
- (BOOL)removeFileAtPath:(NSString *)path handler:(id)handler;
- (BOOL)copyItemAtPath:(NSString *)srcPath toPath:(NSString *)dstPath error:(NSError **)error;
- (BOOL)copyPath:(NSString *)source toPath:(NSString *)destination handler:(id)handler;
- (BOOL)moveItemAtPath:(NSString *)srcPath toPath:(NSString *)dstPath error:(NSError **)error;
- (BOOL)movePath:(NSString *)source toPath:(NSString *)destination handler:(id)handler;
@end

View File

@ -0,0 +1,43 @@
//
// MGMDelegateInfo.h
// VoiceBase
//
// Created by Mr. Gecko on 2/23/11.
// Copyright (c) 2011 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/
//
#import <Foundation/Foundation.h>
@interface MGMDelegateInfo : NSObject {
id delegate;
SEL receiveInfo;
SEL finish;
SEL failWithError;
NSArray *entries;
NSArray *phoneNumbers;
NSString *phone;
NSString *message;
NSString *identifier;
}
+ (id)info;
+ (id)infoWithDelegate:(id)theDelegate;
- (id)initWithDelegate:(id)theDelegate;
- (void)setDelegate:(id)theDelegate;
- (id)delegate;
- (void)setReceiveInfo:(SEL)didReceiveInfo;
- (SEL)receiveInfo;
- (void)setFinish:(SEL)didFinish;
- (SEL)finish;
- (void)setFailWithError:(SEL)didFailWithError;
- (SEL)failWithError;
- (void)setEntries:(NSArray *)theEntries;
- (NSArray *)entries;
- (void)setPhoneNumbers:(NSArray *)thePhoneNumbers;
- (NSArray *)phoneNumbers;
- (void)setPhone:(NSString *)thePhone;
- (NSString *)phone;
- (void)setMessage:(NSString *)theMessage;
- (NSString *)message;
- (void)setIdentifier:(NSString *)theIdentifier;
- (NSString *)identifier;
@end

View File

@ -0,0 +1,91 @@
//
// MGMDelegateInfo.m
// VoiceBase
//
// Created by Mr. Gecko on 2/23/11.
// Copyright (c) 2011 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/
//
#import "MGMDelegateInfo.h"
@implementation MGMDelegateInfo
+ (id)info {
return [[[self alloc] init] autorelease];
}
+ (id)infoWithDelegate:(id)theDelegate {
return [[[self alloc] initWithDelegate:theDelegate] autorelease];
}
- (id)initWithDelegate:(id)theDelegate {
if ((self = [super init])) {
delegate = theDelegate;
}
return self;
}
- (void)dealloc {
[entries release];
[phoneNumbers release];
[phone release];
[message release];
[identifier release];
[super dealloc];
}
- (void)setDelegate:(id)theDelegate {
delegate = theDelegate;
}
- (id)delegate {
return delegate;
}
- (void)setReceiveInfo:(SEL)didReceiveInfo {
receiveInfo = didReceiveInfo;
}
- (SEL)receiveInfo {
return receiveInfo;
}
- (void)setFinish:(SEL)didFinish {
finish = didFinish;
}
- (SEL)finish {
return finish;
}
- (void)setFailWithError:(SEL)didFailWithError {
failWithError = didFailWithError;
}
- (SEL)failWithError {
return failWithError;
}
- (void)setEntries:(NSArray *)theEntries {
[entries release];
entries = [theEntries retain];
}
- (NSArray *)entries {
return entries;
}
- (void)setPhoneNumbers:(NSArray *)thePhoneNumbers {
[phoneNumbers release];
phoneNumbers = [thePhoneNumbers retain];
}
- (NSArray *)phoneNumbers {
return phoneNumbers;
}
- (void)setPhone:(NSString *)thePhone {
[phone release];
phone = [thePhone retain];
}
- (NSString *)phone {
return phone;
}
- (void)setMessage:(NSString *)theMessage {
[message release];
message = [theMessage retain];
}
- (NSString *)message {
return message;
}
- (void)setIdentifier:(NSString *)theIdentifier {
[identifier release];
identifier = [theIdentifier retain];
}
- (NSString *)identifier {
return identifier;
}
@end

View File

@ -12,18 +12,10 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#endif #endif
@class MGMInstance, MGMURLConnectionManager; @class MGMDelegateInfo, MGMInstance, MGMURLConnectionManager;
#define MGMInboxDebug 0 #define MGMInboxDebug 0
extern NSString * const MGMIDelegate;
extern NSString * const MGMIDidReceiveInfo;
extern NSString * const MGMIDidFinish;
extern NSString * const MGMIDidFailWithError;
extern NSString * const MGMIEntries;
extern NSString * const MGMIPhoneNumbers;
extern NSString * const MGMIMessage;
extern NSString * const MGMIVoiceMailDownloadURL; extern NSString * const MGMIVoiceMailDownloadURL;
extern NSString * const MGMIPhoneNumber; extern NSString * const MGMIPhoneNumber;
@ -89,7 +81,7 @@ extern const int MGMISMSOutType;
- (void)getMissedCallsForPage:(int)thePage delegate:(id)theDelegate; - (void)getMissedCallsForPage:(int)thePage delegate:(id)theDelegate;
- (void)getMissedCallsForPage:(int)thePage delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didReceiveInfo:(SEL)didReceiveInfo; - (void)getMissedCallsForPage:(int)thePage delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didReceiveInfo:(SEL)didReceiveInfo;
- (void)retrieveURL:(NSString *)theURL page:(int)thePage info:(NSDictionary *)theInfo; - (void)retrieveURL:(NSString *)theURL page:(int)thePage info:(MGMDelegateInfo *)theInfo;
- (NSDictionary *)parseMessageWithHTML:(NSString *)theHTML info:(NSDictionary *)theInfo; - (NSDictionary *)parseMessageWithHTML:(NSString *)theHTML info:(NSDictionary *)theInfo;
- (void)deleteEntriesForever:(NSArray *)theEntries delegate:(id)theDelegate; - (void)deleteEntriesForever:(NSArray *)theEntries delegate:(id)theDelegate;

View File

@ -7,19 +7,12 @@
// //
#import "MGMInbox.h" #import "MGMInbox.h"
#import "MGMDelegateInfo.h"
#import "MGMInstance.h" #import "MGMInstance.h"
#import "MGMAddons.h" #import "MGMAddons.h"
#import "MGMXML.h" #import "MGMXML.h"
#import <MGMUsers/MGMUsers.h> #import <MGMUsers/MGMUsers.h>
NSString * const MGMIDelegate = @"delegate";
NSString * const MGMIDidReceiveInfo = @"didReceiveInfo";
NSString * const MGMIDidFinish = @"didFinish";
NSString * const MGMIDidFailWithError = @"didFailWithError";
NSString * const MGMIEntries = @"entries";
NSString * const MGMIPhoneNumbers = @"phoneNumbers";
NSString * const MGMIMessage = @"message";
NSString * const MGMIInboxURL = @"https://www.google.com/voice/inbox/recent/"; NSString * const MGMIInboxURL = @"https://www.google.com/voice/inbox/recent/";
NSString * const MGMIStarredURL = @"https://www.google.com/voice/inbox/recent/starred/"; NSString * const MGMIStarredURL = @"https://www.google.com/voice/inbox/recent/starred/";
NSString * const MGMIStarURL = @"https://www.google.com/voice/inbox/star/"; NSString * const MGMIStarURL = @"https://www.google.com/voice/inbox/star/";
@ -93,12 +86,9 @@ const BOOL MGMInboxInvisible = YES;
[self getInboxForPage:thePage delegate:theDelegate didFailWithError:@selector(inbox:didFailWithError:instance:) didReceiveInfo:@selector(inboxGotInfo:instance:)]; [self getInboxForPage:thePage delegate:theDelegate didFailWithError:@selector(inbox:didFailWithError:instance:) didReceiveInfo:@selector(inboxGotInfo:instance:)];
} }
- (void)getInboxForPage:(int)thePage delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didReceiveInfo:(SEL)didReceiveInfo { - (void)getInboxForPage:(int)thePage delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didReceiveInfo:(SEL)didReceiveInfo {
NSMutableDictionary *info = [NSMutableDictionary dictionary]; MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setObject:theDelegate forKey:MGMIDelegate]; [info setReceiveInfo:didReceiveInfo];
if (didReceiveInfo!=NULL) [info setFailWithError:didFailWithError];
[info setObject:NSStringFromSelector(didReceiveInfo) forKey:MGMIDidReceiveInfo];
if (didFailWithError!=NULL)
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
[self retrieveURL:MGMIInboxURL page:thePage info:info]; [self retrieveURL:MGMIInboxURL page:thePage info:info];
} }
@ -106,12 +96,9 @@ const BOOL MGMInboxInvisible = YES;
[self getStarredForPage:thePage delegate:theDelegate didFailWithError:@selector(inbox:didFailWithError:instance:) didReceiveInfo:@selector(inboxGotInfo:instance:)]; [self getStarredForPage:thePage delegate:theDelegate didFailWithError:@selector(inbox:didFailWithError:instance:) didReceiveInfo:@selector(inboxGotInfo:instance:)];
} }
- (void)getStarredForPage:(int)thePage delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didReceiveInfo:(SEL)didReceiveInfo { - (void)getStarredForPage:(int)thePage delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didReceiveInfo:(SEL)didReceiveInfo {
NSMutableDictionary *info = [NSMutableDictionary dictionary]; MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setObject:theDelegate forKey:MGMIDelegate]; [info setReceiveInfo:didReceiveInfo];
if (didReceiveInfo!=NULL) [info setFailWithError:didFailWithError];
[info setObject:NSStringFromSelector(didReceiveInfo) forKey:MGMIDidReceiveInfo];
if (didFailWithError!=NULL)
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
[self retrieveURL:MGMIStarredURL page:thePage info:info]; [self retrieveURL:MGMIStarredURL page:thePage info:info];
} }
@ -119,12 +106,9 @@ const BOOL MGMInboxInvisible = YES;
[self getSpamForPage:thePage delegate:theDelegate didFailWithError:@selector(inbox:didFailWithError:instance:) didReceiveInfo:@selector(inboxGotInfo:instance:)]; [self getSpamForPage:thePage delegate:theDelegate didFailWithError:@selector(inbox:didFailWithError:instance:) didReceiveInfo:@selector(inboxGotInfo:instance:)];
} }
- (void)getSpamForPage:(int)thePage delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didReceiveInfo:(SEL)didReceiveInfo { - (void)getSpamForPage:(int)thePage delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didReceiveInfo:(SEL)didReceiveInfo {
NSMutableDictionary *info = [NSMutableDictionary dictionary]; MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setObject:theDelegate forKey:MGMIDelegate]; [info setReceiveInfo:didReceiveInfo];
if (didReceiveInfo!=NULL) [info setFailWithError:didFailWithError];
[info setObject:NSStringFromSelector(didReceiveInfo) forKey:MGMIDidReceiveInfo];
if (didFailWithError!=NULL)
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
[self retrieveURL:MGMISpamURL page:thePage info:info]; [self retrieveURL:MGMISpamURL page:thePage info:info];
} }
@ -132,12 +116,10 @@ const BOOL MGMInboxInvisible = YES;
[self getTrashForPage:thePage delegate:theDelegate didFailWithError:@selector(inbox:didFailWithError:instance:) didReceiveInfo:@selector(inboxGotInfo:instance:)]; [self getTrashForPage:thePage delegate:theDelegate didFailWithError:@selector(inbox:didFailWithError:instance:) didReceiveInfo:@selector(inboxGotInfo:instance:)];
} }
- (void)getTrashForPage:(int)thePage delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didReceiveInfo:(SEL)didReceiveInfo { - (void)getTrashForPage:(int)thePage delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didReceiveInfo:(SEL)didReceiveInfo {
NSMutableDictionary *info = [NSMutableDictionary dictionary]; MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setObject:theDelegate forKey:MGMIDelegate]; [info setDelegate:theDelegate];
if (didReceiveInfo!=NULL) [info setReceiveInfo:didReceiveInfo];
[info setObject:NSStringFromSelector(didReceiveInfo) forKey:MGMIDidReceiveInfo]; [info setFailWithError:didFailWithError];
if (didFailWithError!=NULL)
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
[self retrieveURL:MGMITrashURL page:thePage info:info]; [self retrieveURL:MGMITrashURL page:thePage info:info];
} }
@ -145,12 +127,9 @@ const BOOL MGMInboxInvisible = YES;
[self getVoicemailForPage:thePage delegate:theDelegate didFailWithError:@selector(inbox:didFailWithError:instance:) didReceiveInfo:@selector(inboxGotInfo:instance:)]; [self getVoicemailForPage:thePage delegate:theDelegate didFailWithError:@selector(inbox:didFailWithError:instance:) didReceiveInfo:@selector(inboxGotInfo:instance:)];
} }
- (void)getVoicemailForPage:(int)thePage delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didReceiveInfo:(SEL)didReceiveInfo { - (void)getVoicemailForPage:(int)thePage delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didReceiveInfo:(SEL)didReceiveInfo {
NSMutableDictionary *info = [NSMutableDictionary dictionary]; MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setObject:theDelegate forKey:MGMIDelegate]; [info setReceiveInfo:didReceiveInfo];
if (didReceiveInfo!=NULL) [info setFailWithError:didFailWithError];
[info setObject:NSStringFromSelector(didReceiveInfo) forKey:MGMIDidReceiveInfo];
if (didFailWithError!=NULL)
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
[self retrieveURL:MGMIVoiceMailURL page:thePage info:info]; [self retrieveURL:MGMIVoiceMailURL page:thePage info:info];
} }
@ -158,12 +137,9 @@ const BOOL MGMInboxInvisible = YES;
[self getSMSForPage:thePage delegate:theDelegate didFailWithError:@selector(inbox:didFailWithError:instance:) didReceiveInfo:@selector(inboxGotInfo:instance:)]; [self getSMSForPage:thePage delegate:theDelegate didFailWithError:@selector(inbox:didFailWithError:instance:) didReceiveInfo:@selector(inboxGotInfo:instance:)];
} }
- (void)getSMSForPage:(int)thePage delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didReceiveInfo:(SEL)didReceiveInfo { - (void)getSMSForPage:(int)thePage delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didReceiveInfo:(SEL)didReceiveInfo {
NSMutableDictionary *info = [NSMutableDictionary dictionary]; MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setObject:theDelegate forKey:MGMIDelegate]; [info setReceiveInfo:didReceiveInfo];
if (didReceiveInfo!=NULL) [info setFailWithError:didFailWithError];
[info setObject:NSStringFromSelector(didReceiveInfo) forKey:MGMIDidReceiveInfo];
if (didFailWithError!=NULL)
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
[self retrieveURL:MGMISMSURL page:thePage info:info]; [self retrieveURL:MGMISMSURL page:thePage info:info];
} }
@ -171,12 +147,9 @@ const BOOL MGMInboxInvisible = YES;
[self getRecordedCallsForPage:thePage delegate:theDelegate didFailWithError:@selector(inbox:didFailWithError:instance:) didReceiveInfo:@selector(inboxGotInfo:instance:)]; [self getRecordedCallsForPage:thePage delegate:theDelegate didFailWithError:@selector(inbox:didFailWithError:instance:) didReceiveInfo:@selector(inboxGotInfo:instance:)];
} }
- (void)getRecordedCallsForPage:(int)thePage delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didReceiveInfo:(SEL)didReceiveInfo { - (void)getRecordedCallsForPage:(int)thePage delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didReceiveInfo:(SEL)didReceiveInfo {
NSMutableDictionary *info = [NSMutableDictionary dictionary]; MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setObject:theDelegate forKey:MGMIDelegate]; [info setReceiveInfo:didReceiveInfo];
if (didReceiveInfo!=NULL) [info setFailWithError:didFailWithError];
[info setObject:NSStringFromSelector(didReceiveInfo) forKey:MGMIDidReceiveInfo];
if (didFailWithError!=NULL)
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
[self retrieveURL:MGMIRecordedURL page:thePage info:info]; [self retrieveURL:MGMIRecordedURL page:thePage info:info];
} }
@ -184,12 +157,9 @@ const BOOL MGMInboxInvisible = YES;
[self getPlacedCallsForPage:thePage delegate:theDelegate didFailWithError:@selector(inbox:didFailWithError:instance:) didReceiveInfo:@selector(inboxGotInfo:instance:)]; [self getPlacedCallsForPage:thePage delegate:theDelegate didFailWithError:@selector(inbox:didFailWithError:instance:) didReceiveInfo:@selector(inboxGotInfo:instance:)];
} }
- (void)getPlacedCallsForPage:(int)thePage delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didReceiveInfo:(SEL)didReceiveInfo { - (void)getPlacedCallsForPage:(int)thePage delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didReceiveInfo:(SEL)didReceiveInfo {
NSMutableDictionary *info = [NSMutableDictionary dictionary]; MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setObject:theDelegate forKey:MGMIDelegate]; [info setReceiveInfo:didReceiveInfo];
if (didReceiveInfo!=NULL) [info setFailWithError:didFailWithError];
[info setObject:NSStringFromSelector(didReceiveInfo) forKey:MGMIDidReceiveInfo];
if (didFailWithError!=NULL)
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
[self retrieveURL:MGMIPlacedURL page:thePage info:info]; [self retrieveURL:MGMIPlacedURL page:thePage info:info];
} }
@ -197,12 +167,9 @@ const BOOL MGMInboxInvisible = YES;
[self getPlacedCallsForPage:thePage delegate:theDelegate didFailWithError:@selector(inbox:didFailWithError:instance:) didReceiveInfo:@selector(inboxGotInfo:instance:)]; [self getPlacedCallsForPage:thePage delegate:theDelegate didFailWithError:@selector(inbox:didFailWithError:instance:) didReceiveInfo:@selector(inboxGotInfo:instance:)];
} }
- (void)getReceivedCallsForPage:(int)thePage delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didReceiveInfo:(SEL)didReceiveInfo { - (void)getReceivedCallsForPage:(int)thePage delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didReceiveInfo:(SEL)didReceiveInfo {
NSMutableDictionary *info = [NSMutableDictionary dictionary]; MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setObject:theDelegate forKey:MGMIDelegate]; [info setReceiveInfo:didReceiveInfo];
if (didReceiveInfo!=NULL) [info setFailWithError:didFailWithError];
[info setObject:NSStringFromSelector(didReceiveInfo) forKey:MGMIDidReceiveInfo];
if (didFailWithError!=NULL)
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
[self retrieveURL:MGMIReceivedURL page:thePage info:info]; [self retrieveURL:MGMIReceivedURL page:thePage info:info];
} }
@ -210,16 +177,13 @@ const BOOL MGMInboxInvisible = YES;
[self getPlacedCallsForPage:thePage delegate:theDelegate didFailWithError:@selector(inbox:didFailWithError:instance:) didReceiveInfo:@selector(inboxGotInfo:instance:)]; [self getPlacedCallsForPage:thePage delegate:theDelegate didFailWithError:@selector(inbox:didFailWithError:instance:) didReceiveInfo:@selector(inboxGotInfo:instance:)];
} }
- (void)getMissedCallsForPage:(int)thePage delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didReceiveInfo:(SEL)didReceiveInfo { - (void)getMissedCallsForPage:(int)thePage delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didReceiveInfo:(SEL)didReceiveInfo {
NSMutableDictionary *info = [NSMutableDictionary dictionary]; MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setObject:theDelegate forKey:MGMIDelegate]; [info setReceiveInfo:didReceiveInfo];
if (didReceiveInfo!=NULL) [info setFailWithError:didFailWithError];
[info setObject:NSStringFromSelector(didReceiveInfo) forKey:MGMIDidReceiveInfo];
if (didFailWithError!=NULL)
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
[self retrieveURL:MGMIMissedURL page:thePage info:info]; [self retrieveURL:MGMIMissedURL page:thePage info:info];
} }
- (void)retrieveURL:(NSString *)theURL page:(int)thePage info:(NSDictionary *)theInfo { - (void)retrieveURL:(NSString *)theURL page:(int)thePage info:(MGMDelegateInfo *)theInfo {
NSString *url = nil; NSString *url = nil;
if (thePage<=1) if (thePage<=1)
url = theURL; url = theURL;
@ -228,30 +192,31 @@ const BOOL MGMInboxInvisible = YES;
#if MGMInboxDebug #if MGMInboxDebug
NSLog(@"MGMInbox Will load %@", url); NSLog(@"MGMInbox Will load %@", url);
#endif #endif
[connectionManager connectionWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]] delegate:self didFailWithError:@selector(request:didFailWithError:) didFinish:@selector(requestDidFinish:) invisible:MGMInboxInvisible object:theInfo]; MGMURLBasicHandler *handler = [MGMURLBasicHandler handlerWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]] delegate:self];
[handler setInvisible:MGMInboxInvisible];
[handler setObject:theInfo];
[connectionManager addHandler:handler];
} }
- (void)request:(NSDictionary *)theInfo didFailWithError:(NSError *)theError { - (void)handler:(MGMURLBasicHandler *)theHandler didFailWithError:(NSError *)theError {
NSDictionary *info = [theInfo objectForKey:MGMConnectionObject]; MGMDelegateInfo *info = [theHandler object];
if ([info objectForKey:MGMIDidFailWithError]!=nil) { BOOL displayError = YES;
SEL selector = NSSelectorFromString([info objectForKey:MGMIDidFailWithError]); if ([info failWithError]!=nil) {
id delegate = [info objectForKey:MGMIDelegate]; NSMethodSignature *signature = [[info delegate] methodSignatureForSelector:[info failWithError]];
NSMethodSignature *signature = [delegate methodSignatureForSelector:selector];
if (signature!=nil) { if (signature!=nil) {
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
[invocation setSelector:selector]; [invocation setSelector:[info failWithError]];
[invocation setArgument:&theInfo atIndex:2]; [invocation setArgument:&info atIndex:2];
[invocation setArgument:&theError atIndex:3]; [invocation setArgument:&theError atIndex:3];
[invocation setArgument:&instance atIndex:4]; [invocation setArgument:&instance atIndex:4];
[invocation invokeWithTarget:delegate]; [invocation invokeWithTarget:[info delegate]];
} else { displayError = NO;
NSLog(@"MGMInbox Error: %@", theError);
} }
} else {
NSLog(@"MGMInbox Error: %@", theError);
} }
if (displayError)
NSLog(@"MGMInbox Error: %@", theError);
} }
- (void)requestDidFinish:(NSDictionary *)theInfo { - (void)handlerDidFinish:(MGMURLBasicHandler *)theHandler {
MGMXMLElement *XML = [(MGMXMLDocument *)[[[MGMXMLDocument alloc] initWithData:[theInfo objectForKey:MGMConnectionData] options:MGMXMLDocumentTidyXML error:nil] autorelease] rootElement]; MGMXMLElement *XML = [(MGMXMLDocument *)[[[MGMXMLDocument alloc] initWithData:[theHandler data] options:MGMXMLDocumentTidyXML error:nil] autorelease] rootElement];
NSDictionary *infoDic = [[[[XML elementsForName:@"json"] objectAtIndex:0] stringValue] parseJSON]; NSDictionary *infoDic = [[[[XML elementsForName:@"json"] objectAtIndex:0] stringValue] parseJSON];
NSDictionary *messagesInfo = [infoDic objectForKey:@"messages"]; NSDictionary *messagesInfo = [infoDic objectForKey:@"messages"];
NSArray *messagesInfoKeys = [messagesInfo allKeys]; NSArray *messagesInfoKeys = [messagesInfo allKeys];
@ -318,23 +283,21 @@ const BOOL MGMInboxInvisible = YES;
} }
[info sortUsingFunction:dateSort context:nil]; [info sortUsingFunction:dateSort context:nil];
NSDictionary *thisInfo = [theInfo objectForKey:MGMConnectionObject]; MGMDelegateInfo *thisInfo = [theHandler object];
if ([thisInfo objectForKey:MGMIDidReceiveInfo]!=nil) { BOOL displayInfo = YES;
SEL selector = NSSelectorFromString([thisInfo objectForKey:MGMIDidReceiveInfo]); if ([thisInfo receiveInfo]!=nil) {
id delegate = [thisInfo objectForKey:MGMIDelegate]; NSMethodSignature *signature = [[thisInfo delegate] methodSignatureForSelector:[thisInfo receiveInfo]];
NSMethodSignature *signature = [delegate methodSignatureForSelector:selector];
if (signature!=nil) { if (signature!=nil) {
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
[invocation setSelector:selector]; [invocation setSelector:[thisInfo receiveInfo]];
[invocation setArgument:&info atIndex:2]; [invocation setArgument:&info atIndex:2];
[invocation setArgument:&instance atIndex:3]; [invocation setArgument:&instance atIndex:3];
[invocation invokeWithTarget:delegate]; [invocation invokeWithTarget:[thisInfo delegate]];
} else { displayInfo = NO;
NSLog(@"MGMInbox Info: %@", info);
} }
} else {
NSLog(@"MGMInbox Info: %@", info);
} }
if (displayInfo)
NSLog(@"MGMInbox Info: %@", info);
} }
- (NSDictionary *)parseMessageWithHTML:(NSString *)theHTML info:(NSDictionary *)theInfo { - (NSDictionary *)parseMessageWithHTML:(NSString *)theHTML info:(NSDictionary *)theInfo {
NSMutableDictionary *message = [NSMutableDictionary dictionary]; NSMutableDictionary *message = [NSMutableDictionary dictionary];
@ -376,13 +339,10 @@ const BOOL MGMInboxInvisible = YES;
#if MGMInboxDebug #if MGMInboxDebug
NSLog(@"MGMInbox Will delete %@", theEntries); NSLog(@"MGMInbox Will delete %@", theEntries);
#endif #endif
NSMutableDictionary *info = [NSMutableDictionary dictionary]; MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setObject:theDelegate forKey:MGMIDelegate]; [info setFinish:didFinish];
if (didFinish!=NULL) [info setFailWithError:didFailWithError];
[info setObject:NSStringFromSelector(didFinish) forKey:MGMIDidFinish]; [info setEntries:theEntries];
if (didFailWithError!=NULL)
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
[info setObject:theEntries forKey:MGMIEntries];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:MGMIDeleteForeverURL]]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:MGMIDeleteForeverURL]];
[request setHTTPMethod:MGMPostMethod]; [request setHTTPMethod:MGMPostMethod];
[request setValue:MGMURLForm forHTTPHeaderField:MGMContentType]; [request setValue:MGMURLForm forHTTPHeaderField:MGMContentType];
@ -392,7 +352,12 @@ const BOOL MGMInboxInvisible = YES;
} }
[body appendFormat:@"_rnr_se=%@", [instance rnr_se]]; [body appendFormat:@"_rnr_se=%@", [instance rnr_se]];
[request setHTTPBody:[body dataUsingEncoding:NSUTF8StringEncoding]]; [request setHTTPBody:[body dataUsingEncoding:NSUTF8StringEncoding]];
[connectionManager connectionWithRequest:request delegate:self didFailWithError:@selector(sendRequest:didFailWithError:) didFinish:@selector(sendRequestDidFinish:) invisible:MGMInboxInvisible object:info]; MGMURLBasicHandler *handler = [MGMURLBasicHandler handlerWithRequest:request delegate:self];
[handler setFailWithError:@selector(send:didFailWithError:)];
[handler setFinish:@selector(sendDidFinish:)];
[handler setInvisible:MGMInboxInvisible];
[handler setObject:info];
[connectionManager addHandler:handler];
} }
- (void)deleteEntries:(NSArray *)theEntries delegate:(id)theDelegate { - (void)deleteEntries:(NSArray *)theEntries delegate:(id)theDelegate {
[self deleteEntries:theEntries delegate:theDelegate didFailWithError:@selector(delete:didFailWithError:instance:) didFinish:@selector(deleteDidFinish:instance:)]; [self deleteEntries:theEntries delegate:theDelegate didFailWithError:@selector(delete:didFailWithError:instance:) didFinish:@selector(deleteDidFinish:instance:)];
@ -401,13 +366,10 @@ const BOOL MGMInboxInvisible = YES;
#if MGMInboxDebug #if MGMInboxDebug
NSLog(@"MGMInbox Will delete %@", theEntries); NSLog(@"MGMInbox Will delete %@", theEntries);
#endif #endif
NSMutableDictionary *info = [NSMutableDictionary dictionary]; MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setObject:theDelegate forKey:MGMIDelegate]; [info setFinish:didFinish];
if (didFinish!=NULL) [info setFailWithError:didFailWithError];
[info setObject:NSStringFromSelector(didFinish) forKey:MGMIDidFinish]; [info setEntries:theEntries];
if (didFailWithError!=NULL)
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
[info setObject:theEntries forKey:MGMIEntries];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:MGMIDeleteURL]]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:MGMIDeleteURL]];
[request setHTTPMethod:MGMPostMethod]; [request setHTTPMethod:MGMPostMethod];
[request setValue:MGMURLForm forHTTPHeaderField:MGMContentType]; [request setValue:MGMURLForm forHTTPHeaderField:MGMContentType];
@ -417,7 +379,12 @@ const BOOL MGMInboxInvisible = YES;
} }
[body appendFormat:@"trash=1&_rnr_se=%@", [instance rnr_se]]; [body appendFormat:@"trash=1&_rnr_se=%@", [instance rnr_se]];
[request setHTTPBody:[body dataUsingEncoding:NSUTF8StringEncoding]]; [request setHTTPBody:[body dataUsingEncoding:NSUTF8StringEncoding]];
[connectionManager connectionWithRequest:request delegate:self didFailWithError:@selector(sendRequest:didFailWithError:) didFinish:@selector(sendRequestDidFinish:) invisible:MGMInboxInvisible object:info]; MGMURLBasicHandler *handler = [MGMURLBasicHandler handlerWithRequest:request delegate:self];
[handler setFailWithError:@selector(send:didFailWithError:)];
[handler setFinish:@selector(sendDidFinish:)];
[handler setInvisible:MGMInboxInvisible];
[handler setObject:info];
[connectionManager addHandler:handler];
} }
- (void)markEntries:(NSArray *)theEntries read:(BOOL)isRead delegate:(id)theDelegate { - (void)markEntries:(NSArray *)theEntries read:(BOOL)isRead delegate:(id)theDelegate {
@ -427,13 +394,10 @@ const BOOL MGMInboxInvisible = YES;
#if MGMInboxDebug #if MGMInboxDebug
NSLog(@"MGMInbox Will delete %@", theEntries); NSLog(@"MGMInbox Will delete %@", theEntries);
#endif #endif
NSMutableDictionary *info = [NSMutableDictionary dictionary]; MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setObject:theDelegate forKey:MGMIDelegate]; [info setFinish:didFinish];
if (didFinish!=NULL) [info setFailWithError:didFailWithError];
[info setObject:NSStringFromSelector(didFinish) forKey:MGMIDidFinish]; [info setEntries:theEntries];
if (didFailWithError!=NULL)
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
[info setObject:theEntries forKey:MGMIEntries];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:MGMIMarkURL]]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:MGMIMarkURL]];
[request setHTTPMethod:MGMPostMethod]; [request setHTTPMethod:MGMPostMethod];
[request setValue:MGMURLForm forHTTPHeaderField:MGMContentType]; [request setValue:MGMURLForm forHTTPHeaderField:MGMContentType];
@ -443,7 +407,12 @@ const BOOL MGMInboxInvisible = YES;
} }
[body appendFormat:@"read=%d&_rnr_se=%@", (isRead ? 1 : 0), [instance rnr_se]]; [body appendFormat:@"read=%d&_rnr_se=%@", (isRead ? 1 : 0), [instance rnr_se]];
[request setHTTPBody:[body dataUsingEncoding:NSUTF8StringEncoding]]; [request setHTTPBody:[body dataUsingEncoding:NSUTF8StringEncoding]];
[connectionManager connectionWithRequest:request delegate:self didFailWithError:@selector(sendRequest:didFailWithError:) didFinish:@selector(sendRequestDidFinish:) invisible:MGMInboxInvisible object:info]; MGMURLBasicHandler *handler = [MGMURLBasicHandler handlerWithRequest:request delegate:self];
[handler setFailWithError:@selector(send:didFailWithError:)];
[handler setFinish:@selector(sendDidFinish:)];
[handler setInvisible:MGMInboxInvisible];
[handler setObject:info];
[connectionManager addHandler:handler];
} }
- (void)reportEntries:(NSArray *)theEntries delegate:(id)theDelegate { - (void)reportEntries:(NSArray *)theEntries delegate:(id)theDelegate {
@ -453,13 +422,10 @@ const BOOL MGMInboxInvisible = YES;
#if MGMInboxDebug #if MGMInboxDebug
NSLog(@"MGMInbox Will delete %@", theEntries); NSLog(@"MGMInbox Will delete %@", theEntries);
#endif #endif
NSMutableDictionary *info = [NSMutableDictionary dictionary]; MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setObject:theDelegate forKey:MGMIDelegate]; [info setFinish:didFinish];
if (didFinish!=NULL) [info setFailWithError:didFailWithError];
[info setObject:NSStringFromSelector(didFinish) forKey:MGMIDidFinish]; [info setEntries:theEntries];
if (didFailWithError!=NULL)
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
[info setObject:theEntries forKey:MGMIEntries];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:MGMIReportURL]]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:MGMIReportURL]];
[request setHTTPMethod:MGMPostMethod]; [request setHTTPMethod:MGMPostMethod];
[request setValue:MGMURLForm forHTTPHeaderField:MGMContentType]; [request setValue:MGMURLForm forHTTPHeaderField:MGMContentType];
@ -469,7 +435,12 @@ const BOOL MGMInboxInvisible = YES;
} }
[body appendFormat:@"spam=1&_rnr_se=%@", [instance rnr_se]]; [body appendFormat:@"spam=1&_rnr_se=%@", [instance rnr_se]];
[request setHTTPBody:[body dataUsingEncoding:NSUTF8StringEncoding]]; [request setHTTPBody:[body dataUsingEncoding:NSUTF8StringEncoding]];
[connectionManager connectionWithRequest:request delegate:self didFailWithError:@selector(sendRequest:didFailWithError:) didFinish:@selector(sendRequestDidFinish:) invisible:MGMInboxInvisible object:info]; MGMURLBasicHandler *handler = [MGMURLBasicHandler handlerWithRequest:request delegate:self];
[handler setFailWithError:@selector(send:didFailWithError:)];
[handler setFinish:@selector(sendDidFinish:)];
[handler setInvisible:MGMInboxInvisible];
[handler setObject:info];
[connectionManager addHandler:handler];
} }
- (void)starEntries:(NSArray *)theEntries starred:(BOOL)isStarred delegate:(id)theDelegate { - (void)starEntries:(NSArray *)theEntries starred:(BOOL)isStarred delegate:(id)theDelegate {
@ -479,13 +450,10 @@ const BOOL MGMInboxInvisible = YES;
#if MGMInboxDebug #if MGMInboxDebug
NSLog(@"MGMInbox Will delete %@", theEntries); NSLog(@"MGMInbox Will delete %@", theEntries);
#endif #endif
NSMutableDictionary *info = [NSMutableDictionary dictionary]; MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setObject:theDelegate forKey:MGMIDelegate]; [info setFinish:didFinish];
if (didFinish!=NULL) [info setFailWithError:didFailWithError];
[info setObject:NSStringFromSelector(didFinish) forKey:MGMIDidFinish]; [info setEntries:theEntries];
if (didFailWithError!=NULL)
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
[info setObject:theEntries forKey:MGMIEntries];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:MGMIStarURL]]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:MGMIStarURL]];
[request setHTTPMethod:MGMPostMethod]; [request setHTTPMethod:MGMPostMethod];
[request setValue:MGMURLForm forHTTPHeaderField:MGMContentType]; [request setValue:MGMURLForm forHTTPHeaderField:MGMContentType];
@ -495,25 +463,25 @@ const BOOL MGMInboxInvisible = YES;
} }
[body appendFormat:@"star=%d&_rnr_se=%@", (isStarred ? 1 : 0), [instance rnr_se]]; [body appendFormat:@"star=%d&_rnr_se=%@", (isStarred ? 1 : 0), [instance rnr_se]];
[request setHTTPBody:[body dataUsingEncoding:NSUTF8StringEncoding]]; [request setHTTPBody:[body dataUsingEncoding:NSUTF8StringEncoding]];
[connectionManager connectionWithRequest:request delegate:self didFailWithError:@selector(sendRequest:didFailWithError:) didFinish:@selector(sendRequestDidFinish:) invisible:MGMInboxInvisible object:info]; MGMURLBasicHandler *handler = [MGMURLBasicHandler handlerWithRequest:request delegate:self];
[handler setFailWithError:@selector(send:didFailWithError:)];
[handler setFinish:@selector(sendDidFinish:)];
[handler setInvisible:MGMInboxInvisible];
[handler setObject:info];
[connectionManager addHandler:handler];
} }
- (void)sendMessage:(NSString *)theMessage phoneNumbers:(NSArray *)thePhoneNumbers smsID:(NSString *)theID delegate:(id)theDelegate { - (void)sendMessage:(NSString *)theMessage phoneNumbers:(NSArray *)thePhoneNumbers smsID:(NSString *)theID delegate:(id)theDelegate {
[self sendMessage:theMessage phoneNumbers:thePhoneNumbers smsID:theID delegate:theDelegate didFailWithError:@selector(message:didFailWithError:instance:) didFinish:@selector(messageDidFinish:instance:)]; [self sendMessage:theMessage phoneNumbers:thePhoneNumbers smsID:theID delegate:theDelegate didFailWithError:@selector(message:didFailWithError:instance:) didFinish:@selector(messageDidFinish:instance:)];
} }
- (void)sendMessage:(NSString *)theMessage phoneNumbers:(NSArray *)thePhoneNumbers smsID:(NSString *)theID delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didFinish:(SEL)didFinish { - (void)sendMessage:(NSString *)theMessage phoneNumbers:(NSArray *)thePhoneNumbers smsID:(NSString *)theID delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didFinish:(SEL)didFinish {
NSMutableDictionary *info = [NSMutableDictionary dictionary]; MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setObject:theDelegate forKey:MGMIDelegate]; [info setFinish:didFinish];
if (didFinish!=NULL) [info setFailWithError:didFailWithError];
[info setObject:NSStringFromSelector(didFinish) forKey:MGMIDidFinish]; [info setMessage:theMessage];
if (didFailWithError!=NULL) [info setPhoneNumbers:thePhoneNumbers];
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
if (theMessage!=nil)
[info setObject:theMessage forKey:MGMIMessage];
if (thePhoneNumbers!=nil)
[info setObject:thePhoneNumbers forKey:MGMIPhoneNumbers];
if (theID==nil) theID = @""; if (theID==nil) theID = @"";
[info setObject:theID forKey:MGMIID]; [info setIdentifier:theID];
if (thePhoneNumbers==nil || [thePhoneNumbers count]==0 || theMessage==nil || [theMessage isEqual:@""]) { if (thePhoneNumbers==nil || [thePhoneNumbers count]==0 || theMessage==nil || [theMessage isEqual:@""]) {
NSMethodSignature *signature = [theDelegate methodSignatureForSelector:didFailWithError]; NSMethodSignature *signature = [theDelegate methodSignatureForSelector:didFailWithError];
if (signature!=nil) { if (signature!=nil) {
@ -538,22 +506,25 @@ const BOOL MGMInboxInvisible = YES;
} }
[body appendFormat:@"&text=%@&sendErrorSms=0&_rnr_se=%@", [theMessage addPercentEscapes], [instance rnr_se]]; [body appendFormat:@"&text=%@&sendErrorSms=0&_rnr_se=%@", [theMessage addPercentEscapes], [instance rnr_se]];
[request setHTTPBody:[body dataUsingEncoding:NSUTF8StringEncoding]]; [request setHTTPBody:[body dataUsingEncoding:NSUTF8StringEncoding]];
[connectionManager connectionWithRequest:request delegate:self didFailWithError:@selector(sendRequest:didFailWithError:) didFinish:@selector(sendRequestDidFinish:) invisible:MGMInboxInvisible object:info]; MGMURLBasicHandler *handler = [MGMURLBasicHandler handlerWithRequest:request delegate:self];
[handler setFailWithError:@selector(send:didFailWithError:)];
[handler setFinish:@selector(sendDidFinish:)];
[handler setInvisible:MGMInboxInvisible];
[handler setObject:info];
[connectionManager addHandler:handler];
} }
- (void)sendRequest:(NSDictionary *)theInfo didFailWithError:(NSError *)theError { - (void)send:(MGMURLBasicHandler *)theHandler didFailWithError:(NSError *)theError {
NSDictionary *info = [theInfo objectForKey:MGMConnectionObject]; MGMDelegateInfo *info = [theHandler object];
if ([info objectForKey:MGMIDidFailWithError]!=nil) { if ([info failWithError]!=nil) {
SEL selector = NSSelectorFromString([info objectForKey:MGMIDidFailWithError]); NSMethodSignature *signature = [[info delegate] methodSignatureForSelector:[info failWithError]];
id delegate = [info objectForKey:MGMIDelegate];
NSMethodSignature *signature = [delegate methodSignatureForSelector:selector];
if (signature!=nil) { if (signature!=nil) {
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
[invocation setSelector:selector]; [invocation setSelector:[info failWithError]];
[invocation setArgument:&theInfo atIndex:2]; [invocation setArgument:&info atIndex:2];
[invocation setArgument:&theError atIndex:3]; [invocation setArgument:&theError atIndex:3];
[invocation setArgument:&instance atIndex:4]; [invocation setArgument:&instance atIndex:4];
[invocation invokeWithTarget:delegate]; [invocation invokeWithTarget:[info delegate]];
} else { } else {
NSLog(@"MGMInbox Send Request Error: %@", theError); NSLog(@"MGMInbox Send Request Error: %@", theError);
} }
@ -561,22 +532,19 @@ const BOOL MGMInboxInvisible = YES;
NSLog(@"MGMInbox Send Request Error: %@", theError); NSLog(@"MGMInbox Send Request Error: %@", theError);
} }
} }
- (void)sendRequestDidFinish:(NSDictionary *)theInfo { - (void)sendDidFinish:(MGMURLBasicHandler *)theHandler {
#if MGMInboxDebug #if MGMInboxDebug
NSLog(@"MGMInbox Did Send Request %@", [[[NSString alloc] initWithData:[theInfo objectForKey:MGMConnectionData] encoding:NSUTF8StringEncoding] autorelease]); NSLog(@"MGMInbox Did Send Request %@", [theHandler string]);
#endif #endif
NSMutableDictionary *thisInfo = [NSMutableDictionary dictionaryWithDictionary:[theInfo objectForKey:MGMConnectionObject]]; MGMDelegateInfo *thisInfo = [theHandler object];
[thisInfo setObject:[theInfo objectForKey:MGMConnectionData] forKey:MGMConnectionData]; if ([thisInfo finish]!=nil) {
if ([thisInfo objectForKey:MGMIDidFinish]!=nil) { NSMethodSignature *signature = [[thisInfo delegate] methodSignatureForSelector:[thisInfo finish]];
SEL selector = NSSelectorFromString([thisInfo objectForKey:MGMIDidFinish]);
id delegate = [thisInfo objectForKey:MGMIDelegate];
NSMethodSignature *signature = [delegate methodSignatureForSelector:selector];
if (signature!=nil) { if (signature!=nil) {
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
[invocation setSelector:selector]; [invocation setSelector:[thisInfo finish]];
[invocation setArgument:&thisInfo atIndex:2]; [invocation setArgument:&thisInfo atIndex:2];
[invocation setArgument:&instance atIndex:3]; [invocation setArgument:&instance atIndex:3];
[invocation invokeWithTarget:delegate]; [invocation invokeWithTarget:[thisInfo delegate]];
} }
} }
} }

View File

@ -7,6 +7,7 @@
// //
#import "MGMInstance.h" #import "MGMInstance.h"
#import "MGMDelegateInfo.h"
#import "MGMInbox.h" #import "MGMInbox.h"
#import "MGMContacts.h" #import "MGMContacts.h"
#import "MGMAddressBook.h" #import "MGMAddressBook.h"
@ -70,7 +71,11 @@ const BOOL MGMInstanceInvisible = YES;
inbox = [[MGMInbox inboxWithInstance:self] retain]; inbox = [[MGMInbox inboxWithInstance:self] retain];
if (!checkingAccount) if (!checkingAccount)
contacts = [[MGMContacts contactsWithClass:NSClassFromString([user settingForKey:MGMSContactsSourceKey]) delegate:self] retain]; contacts = [[MGMContacts contactsWithClass:NSClassFromString([user settingForKey:MGMSContactsSourceKey]) delegate:self] retain];
[connectionManager connectionWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:MGMVoiceIndexURL]] delegate:self didFailWithError:@selector(index:didFailWithError:) didFinish:@selector(indexDidFinish:) invisible:MGMInstanceInvisible object:nil]; MGMURLBasicHandler *handler = [MGMURLBasicHandler handlerWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:MGMVoiceIndexURL]] delegate:self];
[handler setFailWithError:@selector(index:didFailWithError:)];
[handler setFinish:@selector(indexDidFinish:)];
[handler setInvisible:MGMInstanceInvisible];
[connectionManager addHandler:handler];
} }
return self; return self;
} }
@ -176,15 +181,15 @@ const BOOL MGMInstanceInvisible = YES;
return unreadCounts; return unreadCounts;
} }
- (void)index:(NSDictionary *)theInfo didFailWithError:(NSError *)theError { - (void)index:(MGMURLBasicHandler *)theHandler didFailWithError:(NSError *)theError {
if (delegate!=nil && [delegate respondsToSelector:@selector(loginError:)]) { if (delegate!=nil && [delegate respondsToSelector:@selector(loginError:)]) {
[delegate loginError:theError]; [delegate loginError:theError];
} else { } else {
NSLog(@"Login Error: %@", theError); NSLog(@"Login Error: %@", theError);
} }
} }
- (void)indexDidFinish:(NSDictionary *)theInfo { - (void)indexDidFinish:(MGMURLBasicHandler *)theHandler {
NSString *returnedString = [[[NSString alloc] initWithData:[theInfo objectForKey:MGMConnectionData] encoding:NSUTF8StringEncoding] autorelease]; NSString *returnedString = [theHandler string];
if ([returnedString containsString:@"<title>Redirecting</title>"]) { if ([returnedString containsString:@"<title>Redirecting</title>"]) {
NSRange range; NSRange range;
NSString *redirectURL = MGMVoiceIndexURL; NSString *redirectURL = MGMVoiceIndexURL;
@ -213,7 +218,11 @@ const BOOL MGMInstanceInvisible = YES;
} }
} }
//NSLog(@"Redirecting to %@", redirectURL); //NSLog(@"Redirecting to %@", redirectURL);
[connectionManager connectionWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:redirectURL]] delegate:self didFailWithError:@selector(index:didFailWithError:) didFinish:@selector(indexDidFinish:) invisible:MGMInstanceInvisible object:nil]; MGMURLBasicHandler *handler = [MGMURLBasicHandler handlerWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:redirectURL]] delegate:self];
[handler setFailWithError:@selector(index:didFailWithError:)];
[handler setFinish:@selector(indexDidFinish:)];
[handler setInvisible:MGMInstanceInvisible];
[connectionManager addHandler:handler];
} else if ([returnedString containsString:@"<div id=\"gaia_loginbox\">"]) { } else if ([returnedString containsString:@"<div id=\"gaia_loginbox\">"]) {
if (webLoginTries>2) { if (webLoginTries>2) {
NSError *error = [NSError errorWithDomain:@"com.MrGeckosMedia.MGMInstance.Login" code:1 userInfo:[NSDictionary dictionaryWithObject:@"Unable to login. Please check your Credentials." forKey:NSLocalizedDescriptionKey]]; NSError *error = [NSError errorWithDomain:@"com.MrGeckosMedia.MGMInstance.Login" code:1 userInfo:[NSDictionary dictionaryWithObject:@"Unable to login. Please check your Credentials." forKey:NSLocalizedDescriptionKey]];
@ -285,7 +294,11 @@ const BOOL MGMInstanceInvisible = YES;
} }
[request setHTTPBody:[bodyString dataUsingEncoding:NSUTF8StringEncoding]]; [request setHTTPBody:[bodyString dataUsingEncoding:NSUTF8StringEncoding]];
[connectionManager connectionWithRequest:request delegate:self didFailWithError:@selector(index:didFailWithError:) didFinish:@selector(indexDidFinish:) invisible:MGMInstanceInvisible object:nil]; MGMURLBasicHandler *handler = [MGMURLBasicHandler handlerWithRequest:request delegate:self];
[handler setFailWithError:@selector(index:didFailWithError:)];
[handler setFinish:@selector(indexDidFinish:)];
[handler setInvisible:MGMInstanceInvisible];
[connectionManager addHandler:handler];
} else { } else {
NSString *string, *guser = @"", *phonesInfo = @""; NSString *string, *guser = @"", *phonesInfo = @"";
NSRange range; NSRange range;
@ -469,8 +482,8 @@ const BOOL MGMInstanceInvisible = YES;
return loggedIn; return loggedIn;
} }
- (void)xpcFinished:(NSDictionary *)theInfo { - (void)xpcFinished:(MGMURLBasicHandler *)theHandler {
NSString *returnedString = [[[NSString alloc] initWithData:[theInfo objectForKey:MGMConnectionData] encoding:NSUTF8StringEncoding] autorelease]; NSString *returnedString = [theHandler string];
NSRange range = [returnedString rangeOfString:@"new _cd('"]; NSRange range = [returnedString rangeOfString:@"new _cd('"];
if (range.location!=NSNotFound) { if (range.location!=NSNotFound) {
NSString *string = [returnedString substringFromIndex:range.location+range.length]; NSString *string = [returnedString substringFromIndex:range.location+range.length];
@ -486,13 +499,20 @@ const BOOL MGMInstanceInvisible = YES;
[checkTimer fire]; [checkTimer fire];
} }
- (void)checkTimer { - (void)checkTimer {
if (XPCCD) if (XPCCD) {
[connectionManager connectionWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:[XPCURL stringByAppendingString:MGMCheckPath], XPCCD]]] delegate:self didFailWithError:NULL didFinish:@selector(checkFinished:) invisible:MGMInstanceInvisible object:nil]; MGMURLBasicHandler *handler = [MGMURLBasicHandler handlerWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:[XPCURL stringByAppendingString:MGMCheckPath], XPCCD]]] delegate:self];
else [handler setFinish:@selector(checkFinished:)];
[connectionManager connectionWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[XPCURL stringByAppendingString:MGMXPCPath]]] delegate:self didFailWithError:NULL didFinish:@selector(xpcFinished:) invisible:MGMInstanceInvisible object:nil]; [handler setInvisible:MGMInstanceInvisible];
[connectionManager addHandler:handler];
} else {
MGMURLBasicHandler *handler = [MGMURLBasicHandler handlerWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[XPCURL stringByAppendingString:MGMXPCPath]]] delegate:self];
[handler setFinish:@selector(xpcFinished:)];
[handler setInvisible:MGMInstanceInvisible];
[connectionManager addHandler:handler];
}
} }
- (void)checkFinished:(NSDictionary *)theInfo { - (void)checkFinished:(MGMURLBasicHandler *)theHandler {
NSDictionary *returnDic = [[theInfo objectForKey:MGMConnectionData] parseJSON]; NSDictionary *returnDic = [[theHandler data] parseJSON];
if (returnDic!=nil) { if (returnDic!=nil) {
if ([[returnDic objectForKey:@"ok"] intValue]!=0) { if ([[returnDic objectForKey:@"ok"] intValue]!=0) {
NSDictionary *currentUnreadCounts = [[returnDic objectForKey:@"data"] objectForKey:@"unreadCounts"]; NSDictionary *currentUnreadCounts = [[returnDic objectForKey:@"data"] objectForKey:@"unreadCounts"];
@ -519,10 +539,13 @@ const BOOL MGMInstanceInvisible = YES;
[request setHTTPMethod:MGMPostMethod]; [request setHTTPMethod:MGMPostMethod];
[request setValue:MGMURLForm forHTTPHeaderField:MGMContentType]; [request setValue:MGMURLForm forHTTPHeaderField:MGMContentType];
[request setHTTPBody:[[NSString stringWithFormat:@"_rnr_se=%@", rnr_se] dataUsingEncoding:NSUTF8StringEncoding]]; [request setHTTPBody:[[NSString stringWithFormat:@"_rnr_se=%@", rnr_se] dataUsingEncoding:NSUTF8StringEncoding]];
[connectionManager connectionWithRequest:request delegate:self didFailWithError:NULL didFinish:@selector(creditFinished:) invisible:MGMInstanceInvisible object:nil]; MGMURLBasicHandler *handler = [MGMURLBasicHandler handlerWithRequest:request delegate:self];
[handler setFinish:@selector(creditFinished:)];
[handler setInvisible:MGMInstanceInvisible];
[connectionManager addHandler:handler];
} }
- (void)creditFinished:(NSDictionary *)theInfo { - (void)creditFinished:(MGMURLBasicHandler *)theHandler {
NSString *credit = [[[theInfo objectForKey:MGMConnectionData] parseJSON] objectForKey:@"formattedCredit"]; NSString *credit = [[[theHandler data] parseJSON] objectForKey:@"formattedCredit"];
#if MGMInstanceDebug #if MGMInstanceDebug
NSLog(@"Credit = %@", credit); NSLog(@"Credit = %@", credit);
#endif #endif
@ -533,15 +556,11 @@ const BOOL MGMInstanceInvisible = YES;
[self placeCall:thePhoneNumber usingPhone:thePhone delegate:theDelegate didFailWithError:@selector(call:didFailWithError:) didFinish:@selector(callDidFinish:)]; [self placeCall:thePhoneNumber usingPhone:thePhone delegate:theDelegate didFailWithError:@selector(call:didFailWithError:) didFinish:@selector(callDidFinish:)];
} }
- (void)placeCall:(NSString *)thePhoneNumber usingPhone:(int)thePhone delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didFinish:(SEL)didFinish { - (void)placeCall:(NSString *)thePhoneNumber usingPhone:(int)thePhone delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didFinish:(SEL)didFinish {
NSMutableDictionary *info = [NSMutableDictionary dictionary]; MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setObject:theDelegate forKey:MGMIDelegate]; [info setFinish:didFinish];
if (didFinish!=NULL) [info setFailWithError:didFailWithError];
[info setObject:NSStringFromSelector(didFinish) forKey:MGMIDidFinish]; [info setPhoneNumbers:[NSArray arrayWithObject:thePhoneNumber]];
if (didFailWithError!=NULL) [info setPhone:[userPhoneNumbers objectAtIndex:thePhone]];
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
if (thePhoneNumber!=nil)
[info setObject:thePhoneNumber forKey:MGMPhoneNumber];
[info setObject:[userPhoneNumbers objectAtIndex:thePhone] forKey:MGMPhone];
if (thePhoneNumber==nil || [thePhoneNumber isEqual:@""]) { if (thePhoneNumber==nil || [thePhoneNumber isEqual:@""]) {
NSMethodSignature *signature = [theDelegate methodSignatureForSelector:didFailWithError]; NSMethodSignature *signature = [theDelegate methodSignatureForSelector:didFailWithError];
if (signature!=nil) { if (signature!=nil) {
@ -558,59 +577,62 @@ const BOOL MGMInstanceInvisible = YES;
[request setHTTPMethod:MGMPostMethod]; [request setHTTPMethod:MGMPostMethod];
[request setValue:MGMURLForm forHTTPHeaderField:MGMContentType]; [request setValue:MGMURLForm forHTTPHeaderField:MGMContentType];
[request setHTTPBody:[[NSString stringWithFormat:@"outgoingNumber=%@&forwardingNumber=%@&subscriberNumber=undefined&phoneType=%@&remember=1&_rnr_se=%@", thePhoneNumber, [[userPhoneNumbers objectAtIndex:thePhone] objectForKey:MGMPhoneNumber], [[userPhoneNumbers objectAtIndex:thePhone] objectForKey:MGMType], rnr_se] dataUsingEncoding:NSUTF8StringEncoding]]; [request setHTTPBody:[[NSString stringWithFormat:@"outgoingNumber=%@&forwardingNumber=%@&subscriberNumber=undefined&phoneType=%@&remember=1&_rnr_se=%@", thePhoneNumber, [[userPhoneNumbers objectAtIndex:thePhone] objectForKey:MGMPhoneNumber], [[userPhoneNumbers objectAtIndex:thePhone] objectForKey:MGMType], rnr_se] dataUsingEncoding:NSUTF8StringEncoding]];
[connectionManager connectionWithRequest:request delegate:self didFailWithError:@selector(call:didFailWithError:) didFinish:@selector(callDidFinish:) invisible:MGMInstanceInvisible object:info]; MGMURLBasicHandler *handler = [MGMURLBasicHandler handlerWithRequest:request delegate:self];
[handler setFailWithError:@selector(call:didFailWithError:)];
[handler setFinish:@selector(callDidFinish:)];
[handler setInvisible:MGMInstanceInvisible];
[handler setObject:info];
[connectionManager addHandler:handler];
} }
- (void)cancelCallWithDelegate:(id)theDelegate { - (void)cancelCallWithDelegate:(id)theDelegate {
[self cancelCallWithDelegate:theDelegate didFailWithError:@selector(callCancel:didFailWithError:) didFinish:@selector(callCancelDidFinish:)]; [self cancelCallWithDelegate:theDelegate didFailWithError:@selector(callCancel:didFailWithError:) didFinish:@selector(callCancelDidFinish:)];
} }
- (void)cancelCallWithDelegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didFinish:(SEL)didFinish { - (void)cancelCallWithDelegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didFinish:(SEL)didFinish {
NSMutableDictionary *info = [NSMutableDictionary dictionary]; MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setObject:theDelegate forKey:MGMIDelegate]; [info setFinish:didFinish];
if (didFinish!=NULL) [info setFailWithError:didFailWithError];
[info setObject:NSStringFromSelector(didFinish) forKey:MGMIDidFinish];
if (didFailWithError!=NULL)
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:MGMCallCancelURL]]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:MGMCallCancelURL]];
[request setHTTPMethod:MGMPostMethod]; [request setHTTPMethod:MGMPostMethod];
[request setValue:MGMURLForm forHTTPHeaderField:MGMContentType]; [request setValue:MGMURLForm forHTTPHeaderField:MGMContentType];
[request setHTTPBody:[[NSString stringWithFormat:@"outgoingNumber=undefined&forwardingNumber=undefined&cancelType=C2C&_rnr_se=%@", rnr_se] dataUsingEncoding:NSUTF8StringEncoding]]; [request setHTTPBody:[[NSString stringWithFormat:@"outgoingNumber=undefined&forwardingNumber=undefined&cancelType=C2C&_rnr_se=%@", rnr_se] dataUsingEncoding:NSUTF8StringEncoding]];
[connectionManager connectionWithRequest:request delegate:self didFailWithError:@selector(call:didFailWithError:) didFinish:@selector(callDidFinish:) invisible:MGMInstanceInvisible object:info]; MGMURLBasicHandler *handler = [MGMURLBasicHandler handlerWithRequest:request delegate:self];
[handler setFailWithError:@selector(call:didFailWithError:)];
[handler setFinish:@selector(callDidFinish:)];
[handler setInvisible:MGMInstanceInvisible];
[handler setObject:info];
[connectionManager addHandler:handler];
} }
- (void)call:(NSDictionary *)theInfo didFailWithError:(NSError *)theError { - (void)call:(MGMURLBasicHandler *)theHandler didFailWithError:(NSError *)theError {
NSDictionary *info = [theInfo objectForKey:MGMConnectionObject]; MGMDelegateInfo *info = [theHandler object];
if ([info objectForKey:MGMIDidFailWithError]!=nil) { BOOL displayError = YES;
SEL selector = NSSelectorFromString([info objectForKey:MGMIDidFailWithError]); if ([info failWithError]!=nil) {
id theDelegate = [info objectForKey:MGMIDelegate]; NSMethodSignature *signature = [[info delegate] methodSignatureForSelector:[info failWithError]];
NSMethodSignature *signature = [theDelegate methodSignatureForSelector:selector];
if (signature!=nil) { if (signature!=nil) {
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
[invocation setSelector:selector]; [invocation setSelector:[info failWithError]];
[invocation setArgument:&theInfo atIndex:2]; [invocation setArgument:&info atIndex:2];
[invocation setArgument:&theError atIndex:3]; [invocation setArgument:&theError atIndex:3];
[invocation invokeWithTarget:theDelegate]; [invocation invokeWithTarget:[info delegate]];
} else { displayError = NO;
NSLog(@"MGMInstance Call Error: %@", theError);
} }
} else {
NSLog(@"MGMInstance Call Error: %@", theError);
} }
if (displayError)
NSLog(@"MGMInstance Call Error: %@", theError);
} }
- (void)callDidFinish:(NSDictionary *)theInfo { - (void)callDidFinish:(MGMURLBasicHandler *)theHandler {
NSDictionary *infoDic = [[theInfo objectForKey:MGMConnectionData] parseJSON]; NSDictionary *infoDic = [[theHandler data] parseJSON];
MGMDelegateInfo *thisInfo = [theHandler object];
if ([[infoDic objectForKey:@"ok"] boolValue]) { if ([[infoDic objectForKey:@"ok"] boolValue]) {
#if MGMInstanceDebug #if MGMInstanceDebug
NSLog(@"MGMInstance Did Call %@", infoDic); NSLog(@"MGMInstance Did Call %@", infoDic);
#endif #endif
NSDictionary *thisInfo = [theInfo objectForKey:MGMConnectionObject]; if ([thisInfo finish]!=nil) {
if ([thisInfo objectForKey:MGMIDidFinish]!=nil) { NSMethodSignature *signature = [[thisInfo delegate] methodSignatureForSelector:[thisInfo finish]];
SEL selector = NSSelectorFromString([thisInfo objectForKey:MGMIDidFinish]);
id theDelegate = [thisInfo objectForKey:MGMIDelegate];
NSMethodSignature *signature = [theDelegate methodSignatureForSelector:selector];
if (signature!=nil) { if (signature!=nil) {
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
[invocation setSelector:selector]; [invocation setSelector:[thisInfo finish]];
[invocation setArgument:&theInfo atIndex:2]; [invocation setArgument:&thisInfo atIndex:2];
[invocation invokeWithTarget:theDelegate]; [invocation invokeWithTarget:[thisInfo delegate]];
} }
} }
} else { } else {
@ -618,17 +640,14 @@ const BOOL MGMInstanceInvisible = YES;
if ([infoDic objectForKey:@"error"]!=nil) if ([infoDic objectForKey:@"error"]!=nil)
info = [NSDictionary dictionaryWithObject:[infoDic objectForKey:@"error"] forKey:NSLocalizedDescriptionKey]; info = [NSDictionary dictionaryWithObject:[infoDic objectForKey:@"error"] forKey:NSLocalizedDescriptionKey];
NSError *error = [NSError errorWithDomain:@"com.MrGeckosMedia.VoiceBase.Call" code:1 userInfo:info]; NSError *error = [NSError errorWithDomain:@"com.MrGeckosMedia.VoiceBase.Call" code:1 userInfo:info];
NSDictionary *thisInfo = [theInfo objectForKey:MGMConnectionObject]; if ([thisInfo failWithError]!=nil) {
if ([thisInfo objectForKey:MGMIDidFailWithError]!=nil) { NSMethodSignature *signature = [[thisInfo delegate] methodSignatureForSelector:[thisInfo failWithError]];
SEL selector = NSSelectorFromString([thisInfo objectForKey:MGMIDidFailWithError]);
id theDelegate = [thisInfo objectForKey:MGMIDelegate];
NSMethodSignature *signature = [theDelegate methodSignatureForSelector:selector];
if (signature!=nil) { if (signature!=nil) {
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
[invocation setSelector:selector]; [invocation setSelector:[thisInfo failWithError]];
[invocation setArgument:&theInfo atIndex:2]; [invocation setArgument:&thisInfo atIndex:2];
[invocation setArgument:&error atIndex:3]; [invocation setArgument:&error atIndex:3];
[invocation invokeWithTarget:theDelegate]; [invocation invokeWithTarget:[thisInfo delegate]];
} else { } else {
NSLog(@"MGMInstance Call Error: %@", error); NSLog(@"MGMInstance Call Error: %@", error);
} }

View File

@ -84,7 +84,7 @@
} }
- (void)play { - (void)play {
[sound performSelectorOnMainThread:@selector(play) withObject:nil waitUntilDone:NO]; [sound performSelectorOnMainThread:@selector(play) withObject:nil waitUntilDone:YES];
} }
- (void)pause { - (void)pause {
[sound pause]; [sound pause];

View File

@ -158,15 +158,9 @@ NSString * const MGMCAFExt = @"caf";
} }
- (NSString *)soundsFolderPath { - (NSString *)soundsFolderPath {
NSString *supportPath = [[MGMUser applicationSupportPath] stringByAppendingPathComponent:MGMTSoundsFolder]; NSString *supportPath = [[MGMUser applicationSupportPath] stringByAppendingPathComponent:MGMTSoundsFolder];
NSFileManager<NSFileManagerProtocol> *manager = [NSFileManager defaultManager]; NSFileManager *manager = [NSFileManager defaultManager];
if (![manager fileExistsAtPath:supportPath]) { if (![manager fileExistsAtPath:supportPath])
#if !TARGET_OS_IPHONE [manager createDirectoryAtPath:supportPath withAttributes:nil];
if ([manager respondsToSelector:@selector(createDirectoryAtPath:attributes:)])
[manager createDirectoryAtPath:supportPath attributes:nil];
else
#endif
[manager createDirectoryAtPath:supportPath withIntermediateDirectories:YES attributes:nil error:nil];
}
return supportPath; return supportPath;
} }
- (NSDictionary *)sounds { - (NSDictionary *)sounds {
@ -333,15 +327,9 @@ NSString * const MGMCAFExt = @"caf";
- (NSString *)themesFolderPath { - (NSString *)themesFolderPath {
NSString *supportPath = [[MGMUser applicationSupportPath] stringByAppendingPathComponent:MGMTThemeFolder]; NSString *supportPath = [[MGMUser applicationSupportPath] stringByAppendingPathComponent:MGMTThemeFolder];
NSFileManager<NSFileManagerProtocol> *manager = [NSFileManager defaultManager]; NSFileManager *manager = [NSFileManager defaultManager];
if (![manager fileExistsAtPath:supportPath]) { if (![manager fileExistsAtPath:supportPath])
#if !TARGET_OS_IPHONE [manager createDirectoryAtPath:supportPath withAttributes:nil];
if ([manager respondsToSelector:@selector(createDirectoryAtPath:attributes:)])
[manager createDirectoryAtPath:supportPath attributes:nil];
else
#endif
[manager createDirectoryAtPath:supportPath withIntermediateDirectories:YES attributes:nil error:nil];
}
return supportPath; return supportPath;
} }
- (NSString *)currentThemePath { - (NSString *)currentThemePath {
@ -360,7 +348,7 @@ NSString * const MGMCAFExt = @"caf";
NSLog(@"%@ Path: %@", self, [defaults objectForKey:MGMTCurrentThemePath]); NSLog(@"%@ Path: %@", self, [defaults objectForKey:MGMTCurrentThemePath]);
NSLog(@"%@ Name: %@", self, [defaults objectForKey:MGMTCurrentThemeName]); NSLog(@"%@ Name: %@", self, [defaults objectForKey:MGMTCurrentThemeName]);
#endif #endif
NSFileManager<NSFileManagerProtocol> *manager = [NSFileManager defaultManager]; NSFileManager *manager = [NSFileManager defaultManager];
if (![manager fileExistsAtPath:[[self currentThemePath] stringByAppendingPathComponent:MGMTInfoPlist]]) { if (![manager fileExistsAtPath:[[self currentThemePath] stringByAppendingPathComponent:MGMTInfoPlist]]) {
if ([[defaults objectForKey:MGMTCurrentThemePath] isEqual:MGMTPResource]) { if ([[defaults objectForKey:MGMTCurrentThemePath] isEqual:MGMTPResource]) {
NSLog(@"Error: Theme not found in resource!"); NSLog(@"Error: Theme not found in resource!");
@ -416,7 +404,7 @@ NSString * const MGMCAFExt = @"caf";
BOOL isNew = ![[theTheme objectForKey:MGMTThemePath] isEqual:[self currentThemePath]]; BOOL isNew = ![[theTheme objectForKey:MGMTThemePath] isEqual:[self currentThemePath]];
[currentTheme release]; [currentTheme release];
currentTheme = [theTheme mutableCopy]; currentTheme = [theTheme mutableCopy];
NSFileManager<NSFileManagerProtocol> *manager = [NSFileManager defaultManager]; NSFileManager *manager = [NSFileManager defaultManager];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if (isNew) { if (isNew) {
if ([[currentTheme objectForKey:MGMTThemePath] containsString:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:MGMTThemeFolder]]) if ([[currentTheme objectForKey:MGMTThemePath] containsString:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:MGMTThemeFolder]])
@ -470,7 +458,7 @@ NSString * const MGMCAFExt = @"caf";
for (int i=0; i<[variants count]; i++) { for (int i=0; i<[variants count]; i++) {
if ([[[variants objectAtIndex:i] objectForKey:MGMTName] isEqual:theVariant]) { if ([[[variants objectAtIndex:i] objectForKey:MGMTName] isEqual:theVariant]) {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSFileManager<NSFileManagerProtocol> *manager = [NSFileManager defaultManager]; NSFileManager *manager = [NSFileManager defaultManager];
NSString *varriant = [[variants objectAtIndex:i] objectForKey:MGMTFolder]; NSString *varriant = [[variants objectAtIndex:i] objectForKey:MGMTFolder];
if (![manager fileExistsAtPath:[[currentTheme objectForKey:MGMTThemePath] stringByAppendingPathComponent:varriant]]) { if (![manager fileExistsAtPath:[[currentTheme objectForKey:MGMTThemePath] stringByAppendingPathComponent:varriant]]) {
NSLog(@"Error: Varient Folder Is Missing!"); NSLog(@"Error: Varient Folder Is Missing!");
@ -486,7 +474,7 @@ NSString * const MGMCAFExt = @"caf";
} }
- (BOOL)hasCustomIncomingIcon { - (BOOL)hasCustomIncomingIcon {
NSFileManager<NSFileManagerProtocol> *manager = [NSFileManager defaultManager]; NSFileManager *manager = [NSFileManager defaultManager];
NSDictionary *variant = [[currentTheme objectForKey:MGMTVariants] objectAtIndex:[[NSUserDefaults standardUserDefaults] integerForKey:MGMTCurrentThemeVariant]]; NSDictionary *variant = [[currentTheme objectForKey:MGMTVariants] objectAtIndex:[[NSUserDefaults standardUserDefaults] integerForKey:MGMTCurrentThemeVariant]];
NSString *photoPath = nil; NSString *photoPath = nil;
if (variant!=nil) { if (variant!=nil) {
@ -499,7 +487,7 @@ NSString * const MGMCAFExt = @"caf";
return (photoPath!=nil); return (photoPath!=nil);
} }
- (NSString *)incomingIconPath { - (NSString *)incomingIconPath {
NSFileManager<NSFileManagerProtocol> *manager = [NSFileManager defaultManager]; NSFileManager *manager = [NSFileManager defaultManager];
NSDictionary *variant = [[currentTheme objectForKey:MGMTVariants] objectAtIndex:[[NSUserDefaults standardUserDefaults] integerForKey:MGMTCurrentThemeVariant]]; NSDictionary *variant = [[currentTheme objectForKey:MGMTVariants] objectAtIndex:[[NSUserDefaults standardUserDefaults] integerForKey:MGMTCurrentThemeVariant]];
NSString *photoPath = nil; NSString *photoPath = nil;
if (variant!=nil) { if (variant!=nil) {
@ -514,7 +502,7 @@ NSString * const MGMCAFExt = @"caf";
return photoPath; return photoPath;
} }
- (NSString *)outgoingIconPath { - (NSString *)outgoingIconPath {
NSFileManager<NSFileManagerProtocol> *manager = [NSFileManager defaultManager]; NSFileManager *manager = [NSFileManager defaultManager];
NSDictionary *variant = [[currentTheme objectForKey:MGMTVariants] objectAtIndex:[[NSUserDefaults standardUserDefaults] integerForKey:MGMTCurrentThemeVariant]]; NSDictionary *variant = [[currentTheme objectForKey:MGMTVariants] objectAtIndex:[[NSUserDefaults standardUserDefaults] integerForKey:MGMTCurrentThemeVariant]];
NSString *photoPath = nil; NSString *photoPath = nil;
if (variant!=nil) { if (variant!=nil) {
@ -555,7 +543,7 @@ NSString * const MGMCAFExt = @"caf";
- (NSString *)buildHTMLWithMessages:(NSArray *)theMessages messageInfo:(NSDictionary *)theMessageInfo { - (NSString *)buildHTMLWithMessages:(NSArray *)theMessages messageInfo:(NSDictionary *)theMessageInfo {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *variantPath = [self currentThemeVariantPath]; NSString *variantPath = [self currentThemeVariantPath];
NSFileManager<NSFileManagerProtocol> *manager = [NSFileManager defaultManager]; NSFileManager *manager = [NSFileManager defaultManager];
NSMutableString *html = [NSMutableString string]; NSMutableString *html = [NSMutableString string];
if ([manager fileExistsAtPath:[variantPath stringByAppendingPathComponent:MGMTThemeHeaderName]]) { if ([manager fileExistsAtPath:[variantPath stringByAppendingPathComponent:MGMTThemeHeaderName]]) {
#if MGMThemeManagerDebug #if MGMThemeManagerDebug

View File

@ -101,12 +101,12 @@
#if TARGET_OS_IPHONE #if TARGET_OS_IPHONE
if (speaker) [self speaker]; if (speaker) [self speaker];
#endif #endif
if (recorderID!=PJSUA_INVALID_ID)
[self performSelectorOnMainThread:@selector(stopRecordingMain) withObject:nil waitUntilDone:YES];
if (isRingbackOn) if (isRingbackOn)
[self stopRingback]; [self stopRingback];
if (holdMusicPlayer!=PJSUA_INVALID_ID) if (holdMusicPlayer!=PJSUA_INVALID_ID)
[self performSelectorOnMainThread:@selector(stopHoldMusic) withObject:nil waitUntilDone:YES]; [self performSelectorOnMainThread:@selector(stopHoldMusic) withObject:nil waitUntilDone:YES];
if (recorderID!=PJSUA_INVALID_ID)
[self performSelectorOnMainThread:@selector(stopRecordingMain) withObject:nil waitUntilDone:YES];
} }
state = theState; state = theState;
} }
@ -253,6 +253,10 @@
pj_thread_desc PJThreadDesc; pj_thread_desc PJThreadDesc;
[[MGMSIP sharedSIP] registerThread:&PJThreadDesc]; [[MGMSIP sharedSIP] registerThread:&PJThreadDesc];
if (recorderID!=PJSUA_INVALID_ID)
[self performSelectorOnMainThread:@selector(stopRecordingMain) withObject:nil waitUntilDone:YES];
pj_status_t status = pjsua_call_hangup(identifier, 0, NULL, NULL); pj_status_t status = pjsua_call_hangup(identifier, 0, NULL, NULL);
if (status!=PJ_SUCCESS) if (status!=PJ_SUCCESS)
NSLog(@"Error hanging up call %@", self); NSLog(@"Error hanging up call %@", self);

View File

@ -10,6 +10,7 @@
#import <VoiceBase/MGMAddons.h> #import <VoiceBase/MGMAddons.h>
#import <VoiceBase/MGMInstance.h> #import <VoiceBase/MGMInstance.h>
#import <VoiceBase/MGMInbox.h> #import <VoiceBase/MGMInbox.h>
#import <VoiceBase/MGMDelegateInfo.h>
#import <VoiceBase/MGMContactsProtocol.h> #import <VoiceBase/MGMContactsProtocol.h>
#import <VoiceBase/MGMContacts.h> #import <VoiceBase/MGMContacts.h>
#import <VoiceBase/MGMAddressBook.h> #import <VoiceBase/MGMAddressBook.h>

View File

@ -42,7 +42,8 @@
} }
if (audioPlayer!=nil) { if (audioPlayer!=nil) {
connectionManager = [[MGMURLConnectionManager managerWithCookieStorage:[instance cookieStorage]] retain]; connectionManager = [[MGMURLConnectionManager managerWithCookieStorage:[instance cookieStorage]] retain];
[connectionManager connectionWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:MGMIVoiceMailDownloadURL, [[theData objectForKey:MGMIID] addPercentEscapes]]]] delegate:self]; MGMURLBasicHandler *handler = [MGMURLBasicHandler handlerWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:MGMIVoiceMailDownloadURL, [[theData objectForKey:MGMIID] addPercentEscapes]]]] delegate:self];
[connectionManager addHandler:handler];
} }
forceDisplay = NO; forceDisplay = NO;
[self setLevel:NSStatusWindowLevel]; [self setLevel:NSStatusWindowLevel];
@ -67,15 +68,15 @@
[super dealloc]; [super dealloc];
} }
- (void)request:(NSDictionary *)theInfo didFailWithError:(NSError *)theError { - (void)handler:(MGMURLBasicHandler *)theHandler didFailWithError:(NSError *)theError {
NSLog(@"Starting Audio Error: %@", theError); NSLog(@"Starting Audio Error: %@", theError);
NSAlert *theAlert = [[NSAlert new] autorelease]; NSAlert *theAlert = [[NSAlert new] autorelease];
[theAlert setMessageText:@"Error loading audio"]; [theAlert setMessageText:@"Error loading audio"];
[theAlert setInformativeText:[theError localizedDescription]]; [theAlert setInformativeText:[theError localizedDescription]];
[theAlert runModal]; [theAlert runModal];
} }
- (void)requestDidFinish:(NSDictionary *)theInfo { - (void)handlerDidFinish:(MGMURLBasicHandler *)theHandler {
QTDataReference *audioReference = [QTDataReference dataReferenceWithReferenceToData:[theInfo objectForKey:MGMConnectionData] name:@"voicemail.mp3" MIMEType:nil]; QTDataReference *audioReference = [QTDataReference dataReferenceWithReferenceToData:[theHandler data] name:@"voicemail.mp3" MIMEType:nil];
QTMovie *theAudio = [QTMovie movieWithDataReference:audioReference error:NULL]; QTMovie *theAudio = [QTMovie movieWithDataReference:audioReference error:NULL];
[theAudio autoplay]; [theAudio autoplay];
[audioPlayer setMovie:theAudio]; [audioPlayer setMovie:theAudio];

View File

@ -140,7 +140,7 @@ NSString * const MGMSID = @"id";
- (void)checkVoicemail { - (void)checkVoicemail {
[[instance inbox] getVoicemailForPage:1 delegate:self didFailWithError:@selector(voicemail:didFailWithError:instance:) didReceiveInfo:@selector(voicemailGotInfo:instance:)]; [[instance inbox] getVoicemailForPage:1 delegate:self didFailWithError:@selector(voicemail:didFailWithError:instance:) didReceiveInfo:@selector(voicemailGotInfo:instance:)];
} }
- (void)voicemail:(NSDictionary *)theInfo didFailWithError:(NSError *)theError instance:(MGMInstance *)theInstance { - (void)voicemail:(MGMDelegateInfo *)theInfo didFailWithError:(NSError *)theError instance:(MGMInstance *)theInstance {
NSLog(@"Voicemail Error: %@ for instance: %@", theError, theInstance); NSLog(@"Voicemail Error: %@ for instance: %@", theError, theInstance);
} }
- (void)voicemailGotInfo:(NSArray *)theMessages instance:(MGMInstance *)theInstance { - (void)voicemailGotInfo:(NSArray *)theMessages instance:(MGMInstance *)theInstance {
@ -239,7 +239,7 @@ NSString * const MGMSID = @"id";
break; break;
} }
} }
- (void)inbox:(NSDictionary *)theInfo didFailWithError:(NSError *)theError instance:(MGMInstance *)theInstance { - (void)inbox:(MGMDelegateInfo *)theInfo didFailWithError:(NSError *)theError instance:(MGMInstance *)theInstance {
NSLog(@"Inbox Error: %@ for instance: %@", theError, theInstance); NSLog(@"Inbox Error: %@ for instance: %@", theError, theInstance);
NSAlert *theAlert = [[NSAlert new] autorelease]; NSAlert *theAlert = [[NSAlert new] autorelease];
[theAlert setMessageText:@"Error loading inbox"]; [theAlert setMessageText:@"Error loading inbox"];
@ -300,7 +300,7 @@ NSString * const MGMSID = @"id";
[currentData removeObject:data]; [currentData removeObject:data];
[inboxTable reloadData]; [inboxTable reloadData];
} }
- (IBAction)report:(NSDictionary *)theInfo didFailWithError:(NSError *)theError instance:(MGMInstance *)theInstance { - (IBAction)report:(MGMDelegateInfo *)theInfo didFailWithError:(NSError *)theError instance:(MGMInstance *)theInstance {
NSLog(@"Report Error: %@ for instance: %@", theError, theInstance); NSLog(@"Report Error: %@ for instance: %@", theError, theInstance);
NSAlert *theAlert = [[NSAlert new] autorelease]; NSAlert *theAlert = [[NSAlert new] autorelease];
[theAlert setMessageText:@"Error reporting"]; [theAlert setMessageText:@"Error reporting"];
@ -308,7 +308,7 @@ NSString * const MGMSID = @"id";
[theAlert runModal]; [theAlert runModal];
[self stopProgress]; [self stopProgress];
} }
- (void)reportDidFinish:(NSDictionary *)theInfo instance:(MGMInstance *)theInstance { - (void)reportDidFinish:(MGMDelegateInfo *)theInfo instance:(MGMInstance *)theInstance {
[self loadInbox]; [self loadInbox];
[self stopProgress]; [self stopProgress];
} }
@ -342,7 +342,7 @@ NSString * const MGMSID = @"id";
[currentData removeObject:data]; [currentData removeObject:data];
[inboxTable reloadData]; [inboxTable reloadData];
} }
- (void)delete:(NSDictionary *)theInfo didFailWithError:(NSError *)theError instance:(MGMInstance *)theInstance { - (void)delete:(MGMDelegateInfo *)theInfo didFailWithError:(NSError *)theError instance:(MGMInstance *)theInstance {
NSLog(@"Delete Error: %@ for instance: %@", theError, theInstance); NSLog(@"Delete Error: %@ for instance: %@", theError, theInstance);
NSAlert *theAlert = [[NSAlert new] autorelease]; NSAlert *theAlert = [[NSAlert new] autorelease];
[theAlert setMessageText:@"Error deleting"]; [theAlert setMessageText:@"Error deleting"];
@ -350,7 +350,7 @@ NSString * const MGMSID = @"id";
[theAlert runModal]; [theAlert runModal];
[self stopProgress]; [self stopProgress];
} }
- (void)deleteDidFinish:(NSDictionary *)theInfo instance:(MGMInstance *)theInstance { - (void)deleteDidFinish:(MGMDelegateInfo *)theInfo instance:(MGMInstance *)theInstance {
[self loadInbox]; [self loadInbox];
[self stopProgress]; [self stopProgress];
} }

View File

@ -350,14 +350,17 @@ NSString * const MGMSIPDefaultDomain = @"proxy01.sipphone.com";
NSURLCredential *credentials = [NSURLCredential credentialWithUser:username password:[S7CheckUser password] persistence:NSURLCredentialPersistenceForSession]; NSURLCredential *credentials = [NSURLCredential credentialWithUser:username password:[S7CheckUser password] persistence:NSURLCredentialPersistenceForSession];
[S7ConnectionManager setCookieStorage:[S7CheckUser cookieStorage]]; [S7ConnectionManager setCookieStorage:[S7CheckUser cookieStorage]];
[S7ConnectionManager setCredentials:credentials]; [S7ConnectionManager setCredentials:credentials];
[S7ConnectionManager setCustomUseragent:MGMGCUseragent]; [S7ConnectionManager setUserAgent:MGMGCUseragent];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:MGMGCAuthenticationURL] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:15.0]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:MGMGCAuthenticationURL] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:15.0];
[request setHTTPMethod:MGMPostMethod]; [request setHTTPMethod:MGMPostMethod];
[request setValue:MGMURLForm forHTTPHeaderField:MGMContentType]; [request setValue:MGMURLForm forHTTPHeaderField:MGMContentType];
[request setHTTPBody:[[NSString stringWithFormat:MGMGCAuthenticationBody, [username addPercentEscapes], [[S7CheckUser password] addPercentEscapes]] dataUsingEncoding:NSUTF8StringEncoding]]; [request setHTTPBody:[[NSString stringWithFormat:MGMGCAuthenticationBody, [username addPercentEscapes], [[S7CheckUser password] addPercentEscapes]] dataUsingEncoding:NSUTF8StringEncoding]];
[S7ConnectionManager connectionWithRequest:request delegate:self didFailWithError:@selector(authentication:didFailWithError:) didFinish:@selector(authenticationDidFinish:) invisible:NO object:nil]; MGMURLBasicHandler *handler = [MGMURLBasicHandler handlerWithRequest:request delegate:self];
[handler setFailWithError:@selector(authentication:didFailWithError:)];
[handler setFinish:@selector(authenticationDidFinish:)];
[S7ConnectionManager addHandler:handler];
} }
- (void)authentication:(NSDictionary *)theInfo didFailWithError:(NSError *)theError { - (void)authentication:(MGMURLBasicHandler *)theHandler didFailWithError:(NSError *)theError {
[S7CheckUser remove]; [S7CheckUser remove];
[S7CheckUser release]; [S7CheckUser release];
S7CheckUser = nil; S7CheckUser = nil;
@ -367,8 +370,8 @@ NSString * const MGMSIPDefaultDomain = @"proxy01.sipphone.com";
step = 8; step = 8;
[self displayStep]; [self displayStep];
} }
- (void)authenticationDidFinish:(NSDictionary *)theInfo { - (void)authenticationDidFinish:(MGMURLBasicHandler *)theHandler {
NSDictionary *info = [MGMGoogleContacts dictionaryWithData:[theInfo objectForKey:MGMConnectionData]]; NSDictionary *info = [MGMGoogleContacts dictionaryWithString:[theHandler string]];
[S7ConnectionManager setCookieStorage:nil]; [S7ConnectionManager setCookieStorage:nil];
if ([info objectForKey:@"Error"]!=nil) { if ([info objectForKey:@"Error"]!=nil) {
[S7CheckUser remove]; [S7CheckUser remove];

View File

@ -8,7 +8,7 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
@class MGMContactsController, MGMPreferences, MGMTaskManager, MGMWhitePages, MGMThemeManager, MGMSMSManager, MGMBadge, MGMMultiSMS, MGMInstance, WebView; @class MGMContactsController, MGMPreferences, MGMTaskManager, MGMURLConnectionManager, MGMThemeManager, MGMSMSManager, MGMBadge, MGMMultiSMS, MGMInstance, WebView;
extern NSString * const MGMContactsControllersChangedNotification; extern NSString * const MGMContactsControllersChangedNotification;
@ -18,7 +18,7 @@ extern NSString * const MGMContactsControllersChangedNotification;
NSMutableArray *multipleSMS; NSMutableArray *multipleSMS;
MGMPreferences *preferences; MGMPreferences *preferences;
MGMTaskManager *taskManager; MGMTaskManager *taskManager;
MGMWhitePages *whitePages; MGMURLConnectionManager *connectionManager;
BOOL quitting; BOOL quitting;
MGMThemeManager *themeManager; MGMThemeManager *themeManager;

View File

@ -89,13 +89,9 @@ NSString * const MGMLoading = @"Loading...";
} }
} }
NSFileManager<NSFileManagerProtocol> *manager = [NSFileManager defaultManager]; NSFileManager *manager = [NSFileManager defaultManager];
if ([manager fileExistsAtPath:[MGMUser cachePath]]) { if ([manager fileExistsAtPath:[MGMUser cachePath]])
if ([manager respondsToSelector:@selector(removeFileAtPath:handler:)]) [manager removeItemAtPath:[MGMUser cachePath]];
[manager removeFileAtPath:[MGMUser cachePath] handler:nil];
else
[manager removeItemAtPath:[MGMUser cachePath] error:nil];
}
quitting = NO; quitting = NO;
currentContactsController = -1; currentContactsController = -1;
preferences = [MGMPreferences new]; preferences = [MGMPreferences new];
@ -108,7 +104,7 @@ NSString * const MGMLoading = @"Loading...";
[[MGMSIP sharedSIP] setDelegate:self]; [[MGMSIP sharedSIP] setDelegate:self];
#endif #endif
taskManager = [[MGMTaskManager managerWithDelegate:self] retain]; taskManager = [[MGMTaskManager managerWithDelegate:self] retain];
whitePages = [MGMWhitePages new]; connectionManager = [MGMURLConnectionManager new];
themeManager = [MGMThemeManager new]; themeManager = [MGMThemeManager new];
SMSManager = [[MGMSMSManager managerWithController:self] retain]; SMSManager = [[MGMSMSManager managerWithController:self] retain];
@ -162,7 +158,7 @@ NSString * const MGMLoading = @"Loading...";
[multipleSMS release]; [multipleSMS release];
[preferences release]; [preferences release];
[taskManager release]; [taskManager release];
[whitePages release]; [connectionManager release];
[themeManager release]; [themeManager release];
[SMSManager release]; [SMSManager release];
[badge release]; [badge release];
@ -324,27 +320,19 @@ NSString * const MGMLoading = @"Loading...";
[[contactsController phoneField] setStringValue:[phoneNumber readableNumber]]; [[contactsController phoneField] setStringValue:[phoneNumber readableNumber]];
[self sms:self]; [self sms:self];
} else if ([scheme isEqualToString:@"vmtheme"]) { } else if ([scheme isEqualToString:@"vmtheme"]) {
[taskManager addTask:nil withURL:[NSURL URLWithString:[@"http://" stringByAppendingString:data]]]; [taskManager addTask:nil withURL:[NSURL URLWithString:[@"http://" stringByAppendingString:data]] cookieStorage:nil];
} else if ([scheme isEqualToString:@"vmsound"]) { } else if ([scheme isEqualToString:@"vmsound"]) {
[taskManager addTask:nil withURL:[NSURL URLWithString:[@"http://" stringByAppendingString:data]]]; [taskManager addTask:nil withURL:[NSURL URLWithString:[@"http://" stringByAppendingString:data]] cookieStorage:nil];
} }
} }
- (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames { - (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames {
[taskManager application:sender openFiles:filenames]; [taskManager application:sender openFiles:filenames];
NSFileManager *manager = [NSFileManager defaultManager];
for (int i=0; i<[filenames count]; i++) { for (int i=0; i<[filenames count]; i++) {
if ([[[[filenames objectAtIndex:i] pathExtension] lowercaseString] isEqualToString:MGMVMTExt]) { if ([[[[filenames objectAtIndex:i] pathExtension] lowercaseString] isEqualToString:MGMVMTExt])
NSFileManager<NSFileManagerProtocol> *manager = [NSFileManager defaultManager]; [manager moveItemAtPath:[filenames objectAtIndex:i] toPath:[[themeManager themesFolderPath] stringByAppendingPathComponent:[[filenames objectAtIndex:i] lastPathComponent]]];
if ([manager respondsToSelector:@selector(movePath:toPath:handler:)]) else if ([[[[filenames objectAtIndex:i] pathExtension] lowercaseString] isEqualToString:MGMVMSExt])
[manager movePath:[filenames objectAtIndex:i] toPath:[[themeManager themesFolderPath] stringByAppendingPathComponent:[[filenames objectAtIndex:i] lastPathComponent]] handler:nil]; [manager moveItemAtPath:[filenames objectAtIndex:i] toPath:[[themeManager soundsFolderPath] stringByAppendingPathComponent:[[filenames objectAtIndex:i] lastPathComponent]]];
else
[manager moveItemAtPath:[filenames objectAtIndex:i] toPath:[[themeManager themesFolderPath] stringByAppendingPathComponent:[[filenames objectAtIndex:i] lastPathComponent]] error:nil];
} else if ([[[[filenames objectAtIndex:i] pathExtension] lowercaseString] isEqualToString:MGMVMSExt]) {
NSFileManager<NSFileManagerProtocol> *manager = [NSFileManager defaultManager];
if ([manager respondsToSelector:@selector(movePath:toPath:handler:)])
[manager movePath:[filenames objectAtIndex:i] toPath:[[themeManager soundsFolderPath] stringByAppendingPathComponent:[[filenames objectAtIndex:i] lastPathComponent]] handler:nil];
else
[manager moveItemAtPath:[filenames objectAtIndex:i] toPath:[[themeManager soundsFolderPath] stringByAppendingPathComponent:[[filenames objectAtIndex:i] lastPathComponent]] error:nil];
}
} }
} }
- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag { - (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag {
@ -495,7 +483,7 @@ NSString * const MGMLoading = @"Loading...";
MGMVoiceUser *voiceUser = [contactsControllers objectAtIndex:currentContactsController]; MGMVoiceUser *voiceUser = [contactsControllers objectAtIndex:currentContactsController];
NSURL *audioURL = [[voiceUser inboxWindow] audioURL]; NSURL *audioURL = [[voiceUser inboxWindow] audioURL];
NSDictionary *data = [[voiceUser inboxWindow] selectedItem]; NSDictionary *data = [[voiceUser inboxWindow] selectedItem];
[taskManager saveURL:audioURL withName:[NSString stringWithFormat:@"%@ (%@)", [[voiceUser contacts] nameForNumber:[data objectForKey:MGMIPhoneNumber]], [[data objectForKey:MGMIPhoneNumber] readableNumber]]]; [taskManager saveURL:audioURL withName:[NSString stringWithFormat:@"%@ (%@)", [[voiceUser contacts] nameForNumber:[data objectForKey:MGMIPhoneNumber]], [[data objectForKey:MGMIPhoneNumber] readableNumber]] cookieStorage:[[voiceUser instance] cookieStorage]];
} }
- (IBAction)call:(id)sender { - (IBAction)call:(id)sender {
@ -527,7 +515,9 @@ NSString * const MGMLoading = @"Loading...";
NSBeep(); NSBeep();
return; return;
} }
[whitePages reverseLookup:phoneNumber delegate:self]; connectionManager = [MGMURLConnectionManager new];
MGMWhitePagesHandler *handler = [MGMWhitePagesHandler reverseLookup:phoneNumber delegate:self];
[connectionManager addHandler:handler];
[RLName setStringValue:MGMLoading]; [RLName setStringValue:MGMLoading];
[RLAddress setStringValue:MGMLoading]; [RLAddress setStringValue:MGMLoading];
[RLCityState setStringValue:MGMLoading]; [RLCityState setStringValue:MGMLoading];
@ -541,43 +531,46 @@ NSString * const MGMLoading = @"Loading...";
[alert setInformativeText:[theError localizedDescription]]; [alert setInformativeText:[theError localizedDescription]];
[alert runModal]; [alert runModal];
} }
- (void)reverseLookupDidFindInfo:(NSDictionary *)theInfo forRequest:(NSDictionary *)theRequest { - (void)reverseLookupDidFindInfo:(MGMWhitePagesHandler *)theHandler {
if ([theInfo objectForKey:MGMWPName]) { if ([theHandler name]!=nil) {
[RLName setStringValue:[theInfo objectForKey:MGMWPName]]; [RLName setStringValue:[theHandler name]];
} else { } else {
[RLName setStringValue:@""]; [RLName setStringValue:@""];
} }
if ([theInfo objectForKey:MGMWPAddress]) { if ([theHandler address]!=nil) {
[RLAddress setStringValue:[theInfo objectForKey:MGMWPAddress]]; [RLAddress setStringValue:[theHandler address]];
} else { } else {
[RLAddress setStringValue:@""]; [RLAddress setStringValue:@""];
} }
if ([theInfo objectForKey:MGMWPLocation]) { if ([theHandler location]!=nil) {
[RLCityState setStringValue:[theInfo objectForKey:MGMWPLocation]]; [RLCityState setStringValue:[theHandler location]];
} else { } else {
[RLCityState setStringValue:@""]; [RLCityState setStringValue:@""];
} }
if ([theInfo objectForKey:MGMWPZip]) { if ([theHandler zip]) {
[RLZipCode setStringValue:[theInfo objectForKey:MGMWPZip]]; [RLZipCode setStringValue:[theHandler zip]];
} else { } else {
[RLZipCode setStringValue:@""]; [RLZipCode setStringValue:@""];
} }
if ([theInfo objectForKey:MGMWPPhoneNumber]) { if ([theHandler phoneNumber]) {
[RLPhoneNumber setStringValue:[[theInfo objectForKey:MGMWPPhoneNumber] readableNumber]]; [RLPhoneNumber setStringValue:[[theHandler phoneNumber] readableNumber]];
} else { } else {
[RLPhoneNumber setStringValue:@""]; [RLPhoneNumber setStringValue:@""];
} }
int zoom = 0; int zoom = 0;
NSString *address = nil; NSString *address = nil;
if ([theInfo objectForKey:MGMWPAddress]!=nil) { if ([theHandler address]!=nil) {
address = [NSString stringWithFormat:@"%@, %@", [theInfo objectForKey:MGMWPAddress], [theInfo objectForKey:MGMWPZip]]; address = [NSString stringWithFormat:@"%@, %@", [theHandler address], [theHandler zip]];
zoom = 15; zoom = 15;
} else if ([theInfo objectForKey:MGMWPZip]!=nil) { } else if ([theHandler zip]!=nil) {
address = [theInfo objectForKey:MGMWPZip]; address = [theHandler zip];
zoom = 13; zoom = 13;
} else if ([theInfo objectForKey:MGMWPLocation]!=nil) { } else if ([theHandler location]!=nil) {
address = [theInfo objectForKey:MGMWPLocation]; address = [theHandler location];
zoom = 13;
} else if ([theHandler latitude]!=nil && [theHandler longitude]!=nil) {
address = [NSString stringWithFormat:@"%@, %@", [theHandler latitude], [theHandler longitude]];
zoom = 13; zoom = 13;
} }
if (address!=nil) if (address!=nil)

View File

@ -9,7 +9,7 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import "MGMContactsController.h" #import "MGMContactsController.h"
@class MGMController, MGMWhitePages; @class MGMController, MGMURLConnectionManager;
@interface MGMContactsController (MGMSMS) @interface MGMContactsController (MGMSMS)
- (IBAction)sms:(id)sender; - (IBAction)sms:(id)sender;
@ -18,7 +18,7 @@
@interface MGMNumberOptions : NSObject { @interface MGMNumberOptions : NSObject {
MGMContactsController *contactsController; MGMContactsController *contactsController;
MGMController *controller; MGMController *controller;
MGMWhitePages *whitePages; MGMURLConnectionManager *connectionManager;
IBOutlet NSWindow *optionsWindow; IBOutlet NSWindow *optionsWindow;
IBOutlet NSTextField *phoneField; IBOutlet NSTextField *phoneField;
IBOutlet NSTextField *nameField; IBOutlet NSTextField *nameField;

View File

@ -26,8 +26,9 @@
[phoneField setStringValue:[theNumber readableNumber]]; [phoneField setStringValue:[theNumber readableNumber]];
NSString *name = [[contactsController contacts] nameForNumber:theNumber]; NSString *name = [[contactsController contacts] nameForNumber:theNumber];
if (name==nil || [name isEqual:[phoneField stringValue]]) { if (name==nil || [name isEqual:[phoneField stringValue]]) {
whitePages = [MGMWhitePages new]; connectionManager = [MGMURLConnectionManager new];
[whitePages reverseLookup:theNumber delegate:self]; MGMWhitePagesHandler *handler = [MGMWhitePagesHandler reverseLookup:theNumber delegate:self];
[connectionManager addHandler:handler];
[nameField setStringValue:@"Loading..."]; [nameField setStringValue:@"Loading..."];
} else { } else {
[nameField setStringValue:name]; [nameField setStringValue:name];
@ -45,7 +46,7 @@
} }
- (void)dealloc { - (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self]; [[NSNotificationCenter defaultCenter] removeObserver:self];
[whitePages release]; [connectionManager release];
[super dealloc]; [super dealloc];
} }
@ -99,16 +100,16 @@
} }
} }
- (IBAction)cancel:(id)sender { - (IBAction)cancel:(id)sender {
[whitePages cancelAll]; [connectionManager cancelAll];
[optionsWindow close]; [optionsWindow close];
[self release]; [self release];
} }
- (void)reverseLookupDidFindInfo:(NSDictionary *)theInfo forRequest:(NSDictionary *)theRequest { - (void)reverseLookupDidFindInfo:(MGMWhitePagesHandler *)theHandler {
if ([theInfo objectForKey:MGMWPName]!=nil) { if ([theHandler name]!=nil) {
[nameField setStringValue:[theInfo objectForKey:MGMWPName]]; [nameField setStringValue:[theHandler name]];
} else if ([theInfo objectForKey:MGMWPLocation]!=nil) { } else if ([theHandler location]!=nil) {
[nameField setStringValue:[theInfo objectForKey:MGMWPLocation]]; [nameField setStringValue:[theHandler location]];
} }
} }
@end @end

View File

@ -221,7 +221,7 @@ NSString *MGMLastUserPhoneKey = @"MGMLastUserPhone";
[instance placeCall:phoneNumber usingPhone:[userPhonesButton indexOfSelectedItem] delegate:self]; [instance placeCall:phoneNumber usingPhone:[userPhonesButton indexOfSelectedItem] delegate:self];
} }
} }
- (void)call:(NSDictionary *)theInfo didFailWithError:(NSError *)theError { - (void)call:(MGMDelegateInfo *)theInfo didFailWithError:(NSError *)theError {
NSAlert *alert = [[NSAlert new] autorelease]; NSAlert *alert = [[NSAlert new] autorelease];
[alert setMessageText:@"Call Failed"]; [alert setMessageText:@"Call Failed"];
[alert setInformativeText:[theError localizedDescription]]; [alert setInformativeText:[theError localizedDescription]];
@ -229,11 +229,11 @@ NSString *MGMLastUserPhoneKey = @"MGMLastUserPhone";
placingCall = NO; placingCall = NO;
[callTimer fire]; [callTimer fire];
} }
- (void)callDidFinish:(NSDictionary *)theInfo { - (void)callDidFinish:(MGMDelegateInfo *)theInfo {
placingCall = NO; placingCall = NO;
NSLog(@"YEA! We Made The Call!"); NSLog(@"YEA! We Made The Call!");
} }
- (void)callCancel:(NSDictionary *)theInfo didFailWithError:(NSError *)theError { - (void)callCancel:(MGMDelegateInfo *)theInfo didFailWithError:(NSError *)theError {
NSAlert *alert = [[NSAlert new] autorelease]; NSAlert *alert = [[NSAlert new] autorelease];
[alert setMessageText:@"Call Cancel Failed"]; [alert setMessageText:@"Call Cancel Failed"];
[alert setInformativeText:[theError localizedDescription]]; [alert setInformativeText:[theError localizedDescription]];

View File

@ -161,14 +161,10 @@ NSString * const MGMNoAuthor = @"No Author Found";
if ([sender tag]==-1) { if ([sender tag]==-1) {
[themeManager setSound:soundName withPath:MGMTNoSound]; [themeManager setSound:soundName withPath:MGMTNoSound];
if ([soundName isEqual:MGMTSSIPHoldMusic] || [soundName isEqual:MGMTSSIPSound1] || [soundName isEqual:MGMTSSIPSound2] || [soundName isEqual:MGMTSSIPSound3] || [soundName isEqual:MGMTSSIPSound4] || [soundName isEqual:MGMTSSIPSound5]) { if ([soundName isEqual:MGMTSSIPHoldMusic] || [soundName isEqual:MGMTSSIPSound1] || [soundName isEqual:MGMTSSIPSound2] || [soundName isEqual:MGMTSSIPSound3] || [soundName isEqual:MGMTSSIPSound4] || [soundName isEqual:MGMTSSIPSound5]) {
NSFileManager<NSFileManagerProtocol> *manager = [NSFileManager defaultManager]; NSFileManager *manager = [NSFileManager defaultManager];
NSString *finalPath = [[[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:MGMTCallSoundsFolder] stringByAppendingPathComponent:soundName] stringByAppendingPathExtension:MGMWavExt]; NSString *finalPath = [[[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:MGMTCallSoundsFolder] stringByAppendingPathComponent:soundName] stringByAppendingPathExtension:MGMWavExt];
if ([manager fileExistsAtPath:finalPath]) { if ([manager fileExistsAtPath:finalPath])
if ([manager respondsToSelector:@selector(removeFileAtPath:)]) [manager removeItemAtPath:finalPath];
[manager removeFileAtPath:finalPath handler:nil];
else
[manager removeItemAtPath:finalPath error:nil];
}
} }
} else { } else {
NSMenuItem *soundsMenuItem = nil; NSMenuItem *soundsMenuItem = nil;

View File

@ -9,13 +9,13 @@
#if MGMSIPENABLED #if MGMSIPENABLED
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
@class MGMSIPCall, MGMSIPAccount, MGMSIPUser, MGMWhitePages, MGMSound; @class MGMSIPCall, MGMSIPAccount, MGMSIPUser, MGMURLConnectionManager, MGMSound;
@interface MGMSIPCallWindow : NSObject { @interface MGMSIPCallWindow : NSObject {
MGMSIPCall *call; MGMSIPCall *call;
MGMSIPAccount *account; MGMSIPAccount *account;
MGMSIPUser *SIPUser; MGMSIPUser *SIPUser;
MGMWhitePages *whitePages; MGMURLConnectionManager *connectionManager;
IBOutlet NSWindow *incomingWindow; IBOutlet NSWindow *incomingWindow;
IBOutlet NSTextField *phoneField; IBOutlet NSTextField *phoneField;

View File

@ -56,8 +56,9 @@ NSString * const MGMSCTitleNoNameFormat = @"Call With %@";
[phoneField setStringValue:phoneNumber]; [phoneField setStringValue:phoneNumber];
NSString *name = [[SIPUser contacts] nameForNumber:number]; NSString *name = [[SIPUser contacts] nameForNumber:number];
if (name==nil || [name isEqual:phoneNumber]) { if (name==nil || [name isEqual:phoneNumber]) {
whitePages = [MGMWhitePages new]; connectionManager = [MGMURLConnectionManager new];
[whitePages reverseLookup:number delegate:self]; MGMWhitePagesHandler *handler = [MGMWhitePagesHandler reverseLookup:number delegate:self];
[connectionManager addHandler:handler];
[nameField setStringValue:@"Loading..."]; [nameField setStringValue:@"Loading..."];
} else { } else {
fullName = [name copy]; fullName = [name copy];
@ -87,8 +88,9 @@ NSString * const MGMSCTitleNoNameFormat = @"Call With %@";
phoneNumber = [[number readableNumber] copy]; phoneNumber = [[number readableNumber] copy];
NSString *name = [[SIPUser contacts] nameForNumber:number]; NSString *name = [[SIPUser contacts] nameForNumber:number];
if (name==nil || [name isEqual:phoneNumber]) { if (name==nil || [name isEqual:phoneNumber]) {
whitePages = [MGMWhitePages new]; connectionManager = [MGMURLConnectionManager new];
[whitePages reverseLookup:number delegate:self]; MGMWhitePagesHandler *handler = [MGMWhitePagesHandler reverseLookup:number delegate:self];
[connectionManager addHandler:handler];
} else { } else {
fullName = [name copy]; fullName = [name copy];
} }
@ -122,7 +124,7 @@ NSString * const MGMSCTitleNoNameFormat = @"Call With %@";
[self hidePad]; [self hidePad];
[call setDelegate:nil]; [call setDelegate:nil];
[call release]; [call release];
[whitePages release]; [connectionManager release];
[incomingWindow release]; [incomingWindow release];
[callWindow release]; [callWindow release];
[fullName release]; [fullName release];
@ -338,16 +340,16 @@ NSString * const MGMSCTitleNoNameFormat = @"Call With %@";
[call sendDTMFDigits:@"#"]; [call sendDTMFDigits:@"#"];
} }
- (void)reverseLookupDidFindInfo:(NSDictionary *)theInfo forRequest:(NSDictionary *)theRequest { - (void)reverseLookupDidFindInfo:(MGMWhitePagesHandler *)theHandler {
if ([theInfo objectForKey:MGMWPName]!=nil) { if ([theHandler name]!=nil) {
fullName = [[theInfo objectForKey:MGMWPName] copy]; fullName = [[theHandler name] copy];
if ([callWindow isVisible]) if ([callWindow isVisible])
[self setTitle:[NSString stringWithFormat:MGMSCTitleFormat, fullName, phoneNumber]]; [self setTitle:[NSString stringWithFormat:MGMSCTitleFormat, fullName, phoneNumber]];
else else
[nameField setStringValue:fullName]; [nameField setStringValue:fullName];
} else if ([theInfo objectForKey:MGMWPLocation]!=nil) { } else if ([theHandler location]!=nil) {
if ([incomingWindow isVisible]) if ([incomingWindow isVisible])
[nameField setStringValue:[theInfo objectForKey:MGMWPLocation]]; [nameField setStringValue:[theHandler location]];
} }
} }
@end @end

View File

@ -56,14 +56,10 @@
NSAutoreleasePool *pool = [NSAutoreleasePool new]; NSAutoreleasePool *pool = [NSAutoreleasePool new];
backgroundThread = [[NSThread currentThread] retain]; backgroundThread = [[NSThread currentThread] retain];
[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:2.0]]; [NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:2.0]];
NSFileManager<NSFileManagerProtocol> *manager = [NSFileManager defaultManager]; NSFileManager *manager = [NSFileManager defaultManager];
NSString *finalPath = [[MGMUser applicationSupportPath] stringByAppendingPathComponent:MGMTCallSoundsFolder]; NSString *finalPath = [[MGMUser applicationSupportPath] stringByAppendingPathComponent:MGMTCallSoundsFolder];
if (![manager fileExistsAtPath:finalPath]) { if (![manager fileExistsAtPath:finalPath])
if ([manager respondsToSelector:@selector(createDirectoryAtPath:attributes:)]) [manager createDirectoryAtPath:finalPath withAttributes:nil];
[manager createDirectoryAtPath:finalPath attributes:nil];
else
[manager createDirectoryAtPath:finalPath withIntermediateDirectories:YES attributes:nil error:nil];
}
finalPath = [finalPath stringByAppendingPathComponent:soundName]; finalPath = [finalPath stringByAppendingPathComponent:soundName];
NSString *convertFinalPath = [[finalPath stringByAppendingPathExtension:@".tmp"] stringByAppendingPathExtension:MGMWavExt]; NSString *convertFinalPath = [[finalPath stringByAppendingPathExtension:@".tmp"] stringByAppendingPathExtension:MGMWavExt];
finalPath = [finalPath stringByAppendingPathExtension:MGMWavExt]; finalPath = [finalPath stringByAppendingPathExtension:MGMWavExt];
@ -72,18 +68,10 @@
if (![movie writeToFile:convertFinalPath withAttributes:dictionary]) if (![movie writeToFile:convertFinalPath withAttributes:dictionary])
NSLog(@"Could not convert audio %@", fileConverting); NSLog(@"Could not convert audio %@", fileConverting);
} }
if ([manager fileExistsAtPath:finalPath]) { if ([manager fileExistsAtPath:finalPath])
if ([manager respondsToSelector:@selector(removeFileAtPath:)]) [manager removeItemAtPath:finalPath];
[manager removeFileAtPath:finalPath handler:nil]; if (!cancel)
else [manager moveItemAtPath:convertFinalPath toPath:finalPath];
[manager removeItemAtPath:finalPath error:nil];
}
if (!cancel) {
if ([manager respondsToSelector:@selector(movePath:toPath:handler:)])
[manager movePath:convertFinalPath toPath:finalPath handler:nil];
else
[manager moveItemAtPath:convertFinalPath toPath:finalPath error:nil];
}
[pool drain]; [pool drain];
[backgroundThread release]; [backgroundThread release];
backgroundThread = nil; backgroundThread = nil;

View File

@ -116,7 +116,7 @@
[[instance inbox] sendMessage:[SMSTextView string] phoneNumbers:SMSNumbers smsID:@"" delegate:self]; [[instance inbox] sendMessage:[SMSTextView string] phoneNumbers:SMSNumbers smsID:@"" delegate:self];
} }
} }
- (void)message:(NSDictionary *)theInfo didFailWithError:(NSError *)theError instance:(MGMInstance *)theInstance { - (void)message:(MGMDelegateInfo *)theInfo didFailWithError:(NSError *)theError instance:(MGMInstance *)theInstance {
sendingMessage = NO; sendingMessage = NO;
[SMSTextView setEditable:YES]; [SMSTextView setEditable:YES];
[sendButton setTitle:@"Send"]; [sendButton setTitle:@"Send"];
@ -130,7 +130,7 @@
[theAlert setAlertStyle:2]; [theAlert setAlertStyle:2];
[theAlert runModal]; [theAlert runModal];
} }
- (void)messageDidFinish:(NSDictionary *)theInfo instance:(MGMInstance *)theInstance { - (void)messageDidFinish:(MGMDelegateInfo *)theInfo instance:(MGMInstance *)theInstance {
sendingMessage = NO; sendingMessage = NO;
[SMSWindow close]; [SMSWindow close];
} }

View File

@ -128,7 +128,7 @@ const float updateTimeInterval = 300.0;
- (void)checkSMSMessagesForInstance:(MGMInstance *)theInstance { - (void)checkSMSMessagesForInstance:(MGMInstance *)theInstance {
[[theInstance inbox] getSMSForPage:1 delegate:self]; [[theInstance inbox] getSMSForPage:1 delegate:self];
} }
- (void)inbox:(NSDictionary *)theInfo didFailWithError:(NSError *)theError instance:(MGMInstance *)theInstance { - (void)inbox:(MGMDelegateInfo *)theInfo didFailWithError:(NSError *)theError instance:(MGMInstance *)theInstance {
NSLog(@"SMS Error: %@ for instance: %@", theError, theInstance); NSLog(@"SMS Error: %@ for instance: %@", theError, theInstance);
} }
- (void)inboxGotInfo:(NSArray *)theMessages instance:(MGMInstance *)theInstance { - (void)inboxGotInfo:(NSArray *)theMessages instance:(MGMInstance *)theInstance {

View File

@ -187,7 +187,7 @@
[SMSTextView setEditable:NO]; [SMSTextView setEditable:NO];
[[instance inbox] sendMessage:[SMSTextView string] phoneNumbers:[NSArray arrayWithObject:[messageInfo objectForKey:MGMIPhoneNumber]] smsID:[messageInfo objectForKey:MGMIID] delegate:self]; [[instance inbox] sendMessage:[SMSTextView string] phoneNumbers:[NSArray arrayWithObject:[messageInfo objectForKey:MGMIPhoneNumber]] smsID:[messageInfo objectForKey:MGMIID] delegate:self];
} }
- (void)message:(NSDictionary *)theInfo didFailWithError:(NSError *)theError instance:(MGMInstance *)theInstance { - (void)message:(MGMDelegateInfo *)theInfo didFailWithError:(NSError *)theError instance:(MGMInstance *)theInstance {
sendingMessage = NO; sendingMessage = NO;
[SMSTextView setEditable:YES]; [SMSTextView setEditable:YES];
[[manager SMSWindow] makeFirstResponder:SMSTextView]; [[manager SMSWindow] makeFirstResponder:SMSTextView];
@ -196,7 +196,7 @@
[theAlert setInformativeText:[theError localizedDescription]]; [theAlert setInformativeText:[theError localizedDescription]];
[theAlert runModal]; [theAlert runModal];
} }
- (void)messageDidFinish:(NSDictionary *)theInfo instance:(MGMInstance *)theInstance { - (void)messageDidFinish:(MGMDelegateInfo *)theInfo instance:(MGMInstance *)theInstance {
sendingMessage = NO; sendingMessage = NO;
NSDateFormatter *formatter = [[NSDateFormatter new] autorelease]; NSDateFormatter *formatter = [[NSDateFormatter new] autorelease];
[formatter setDateFormat:@"h:mm a"]; [formatter setDateFormat:@"h:mm a"];
@ -242,14 +242,14 @@
- (BOOL)shouldClose { - (BOOL)shouldClose {
return (!sendingMessage); return (!sendingMessage);
} }
- (void)mark:(NSDictionary *)theInfo didFailWithError:(NSError *)theError instance:(MGMInstance *)theInstance { - (void)mark:(MGMDelegateInfo *)theInfo didFailWithError:(NSError *)theError instance:(MGMInstance *)theInstance {
marking = NO; marking = NO;
NSAlert *theAlert = [[NSAlert new] autorelease]; NSAlert *theAlert = [[NSAlert new] autorelease];
[theAlert setMessageText:@"Error marking as read"]; [theAlert setMessageText:@"Error marking as read"];
[theAlert setInformativeText:[theError localizedDescription]]; [theAlert setInformativeText:[theError localizedDescription]];
[theAlert runModal]; [theAlert runModal];
} }
- (void)markDidFinish:(NSDictionary *)theInfo instance:(MGMInstance *)theInstance { - (void)markDidFinish:(MGMDelegateInfo *)theInfo instance:(MGMInstance *)theInstance {
marking = NO; marking = NO;
[messageInfo setObject:[NSNumber numberWithBool:YES] forKey:MGMIRead]; [messageInfo setObject:[NSNumber numberWithBool:YES] forKey:MGMIRead];
[self close:self]; [self close:self];

View File

@ -1,72 +0,0 @@
//
// MGMPath.h
// VoiceMob
//
// Created by Mr. Gecko on 10/1/10.
// Copyright (c) 2010 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/
//
#import <UIKit/UIKit.h>
@interface MGMPath : NSObject {
CGMutablePathRef pathRef;
CGFloat *lineDashPattern;
NSUInteger lineDashPatternCount;
CGFloat lineDashPhase;
CGFloat lineWidth;
CGFloat miterLimit;
CGFloat flatness;
CGLineCap lineCapStyle;
CGLineJoin lineJoinStyle;
}
+ (MGMPath *)path;
+ (MGMPath *)pathWithRect:(CGRect)theRect;
//+ (MGMPath *)pathWithOvalInRect:(CGRect)theRect;
+ (MGMPath *)pathWithRoundedRect:(CGRect)theRect cornerRadius:(CGFloat)theRadius;
+ (MGMPath *)pathWithRoundedRect:(CGRect)theRect cornerRadiusX:(CGFloat)theRadiusX cornerRadiusY:(CGFloat)theRadiusY;
//+ (MGMPath *)pathWithRoundedRect:(CGRect)theRect byRoundingCorners:(UIRectCorner)corners cornerRadii:(CGSize)cornerRadii;
//+ (MGMPath *)pathWithArcCenter:(CGPoint)center radius:(CGFloat)radius startAngle:(CGFloat)startAngle endAngle:(CGFloat)endAngle clockwise:(BOOL)clockwise;
//+ (MGMPath *)pathWithCGPath:(CGPathRef)CGPath;
- (CGMutablePathRef)CGPath;
- (void)moveToPoint:(CGPoint)thePoint;
- (void)addLineToPoint:(CGPoint)thePoint;
- (void)addCurveToPoint:(CGPoint)endPoint controlPoint1:(CGPoint)controlPoint1 controlPoint2:(CGPoint)controlPoint2;
- (void)addQuadCurveToPoint:(CGPoint)endPoint controlPoint:(CGPoint)controlPoint;
- (void)addArcWithCenter:(CGPoint)center radius:(CGFloat)radius startAngle:(CGFloat)startAngle endAngle:(CGFloat)endAngle clockwise:(BOOL)clockwise;
- (void)closePath;
//- (void)removeAllPoints;
- (void)appendPath:(MGMPath *)thePath;
//- (void)applyTransform:(CGAffineTransform)transform;
- (BOOL)isEmpty;
- (CGRect)bounds;
- (CGPoint)currentPoint;
- (BOOL)containsPoint:(CGPoint)point;
- (void)setLineWidth:(CGFloat)theWidth;
- (CGFloat)lineWidth;
- (void)setLineJoinStyle:(CGLineJoin)theLineJoinStyle;
- (CGLineJoin)lineJoinStyle;
- (void)setLineCapStyle:(CGLineCap)theLineCapStyle;
- (CGLineCap)lineCapStyle;
- (void)setMiterLimit:(CGFloat)theMiterLimit;
- (CGFloat)miterLimit;
- (void)setFlatness:(CGFloat)theFlatness;
- (CGFloat)flatness;
- (void)setLineDash:(const CGFloat *)pattern count:(NSInteger)count phase:(CGFloat)phase;
- (void)getLineDash:(CGFloat *)pattern count:(NSInteger *)count phase:(CGFloat *)phase;
- (void)fill;
- (void)fillGradientFrom:(UIColor *)theStartColor to:(UIColor *)theEndColor;
- (void)stroke;
//- (void)fillWithBlendMode:(CGBlendMode)blendMode alpha:(CGFloat)alpha;
//- (void)strokeWithBlendMode:(CGBlendMode)blendMode alpha:(CGFloat)alpha;
- (void)addClip;
@end

View File

@ -1,228 +0,0 @@
//
// MGMPath.m
// VoiceMob
//
// Created by Mr. Gecko on 10/1/10.
// Copyright (c) 2010 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/
//
#import "MGMPath.h"
@implementation MGMPath
+ (MGMPath *)path {
return [[[self alloc] init] autorelease];
}
+ (MGMPath *)pathWithRect:(CGRect)theRect {
MGMPath *path = [self path];
CGPathAddRect([path CGPath], NULL, theRect);
return path;
}
+ (MGMPath *)pathWithRoundedRect:(CGRect)theRect cornerRadius:(CGFloat)theRadius {
return [self pathWithRoundedRect:theRect cornerRadiusX:theRadius cornerRadiusY:theRadius];
}
+ (MGMPath *)pathWithRoundedRect:(CGRect)theRect cornerRadiusX:(CGFloat)theRadiusX cornerRadiusY:(CGFloat)theRadiusY {
MGMPath *path = [self path];
float maxRadiusX = theRect.size.width / 2.0;
float maxRadiusY = theRect.size.height / 2.0;
theRadiusX = (theRadiusX<maxRadiusX ? theRadiusX : maxRadiusX);
theRadiusY = (theRadiusY<maxRadiusY ? theRadiusY : maxRadiusY);
float ellipse = 0.55228474983079;
float controlX = theRadiusX * ellipse;
float controlY = theRadiusY * ellipse;
CGRect edges = CGRectInset(theRect, theRadiusX, theRadiusY);
[path moveToPoint:CGPointMake(edges.origin.x, theRect.origin.y)];
// top right corner
[path addLineToPoint:CGPointMake(CGRectGetMaxX(edges), theRect.origin.y)];
[path addCurveToPoint:CGPointMake(CGRectGetMaxX(theRect), edges.origin.y) controlPoint1:CGPointMake(CGRectGetMaxX(edges) + controlX, theRect.origin.y) controlPoint2:CGPointMake(CGRectGetMaxX(theRect), edges.origin.y - controlY)];
// bottom right corner
[path addLineToPoint:CGPointMake(CGRectGetMaxX(theRect), CGRectGetMaxY(edges))];
[path addCurveToPoint:CGPointMake(CGRectGetMaxX(edges), CGRectGetMaxY(theRect)) controlPoint1:CGPointMake(CGRectGetMaxX(theRect), CGRectGetMaxY(edges) + controlY) controlPoint2:CGPointMake(CGRectGetMaxX(edges) + controlX, CGRectGetMaxY(theRect))];
// bottom left corner
[path addLineToPoint:CGPointMake(edges.origin.x, CGRectGetMaxY(theRect))];
[path addCurveToPoint:CGPointMake(theRect.origin.x, CGRectGetMaxY(edges)) controlPoint1:CGPointMake(edges.origin.x - controlX, CGRectGetMaxY(theRect)) controlPoint2:CGPointMake(theRect.origin.x, CGRectGetMaxY(edges) + controlY)];
// top left corner
[path addLineToPoint:CGPointMake(theRect.origin.x, edges.origin.y)];
[path addCurveToPoint:CGPointMake(edges.origin.x, theRect.origin.y) controlPoint1:CGPointMake(theRect.origin.x, edges.origin.y - controlY) controlPoint2:CGPointMake(edges.origin.x - controlX, theRect.origin.y)];
[path closePath];
return path;
}
- (id)init {
if (self = [super init]) {
pathRef = CGPathCreateMutable();
lineWidth = 1.0;
lineCapStyle = kCGLineCapButt;
lineJoinStyle = kCGLineJoinMiter;
miterLimit = 10.0;
flatness = 0.6;
}
return self;
}
- (void)dealloc {
if (pathRef!=NULL)
CGPathRelease(pathRef);
if (lineDashPattern!=NULL)
free(lineDashPattern);
[super dealloc];
}
- (CGMutablePathRef)CGPath {
return pathRef;
}
- (BOOL)isEqual:(id)object {
if ([object isKindOfClass:[MGMPath class]]) {
return CGPathEqualToPath(pathRef, [object CGPath]);
}
return NO;
}
- (void)moveToPoint:(CGPoint)thePoint {
CGPathMoveToPoint(pathRef, NULL, thePoint.x, thePoint.y);
}
- (void)addLineToPoint:(CGPoint)thePoint {
CGPathAddLineToPoint(pathRef, NULL, thePoint.x, thePoint.y);
}
- (void)addCurveToPoint:(CGPoint)endPoint controlPoint1:(CGPoint)controlPoint1 controlPoint2:(CGPoint)controlPoint2 {
CGPathAddCurveToPoint(pathRef, NULL, controlPoint1.x, controlPoint1.y, controlPoint2.x, controlPoint2.y, endPoint.x, endPoint.y);
}
- (void)addArcWithCenter:(CGPoint)center radius:(CGFloat)radius startAngle:(CGFloat)startAngle endAngle:(CGFloat)endAngle clockwise:(BOOL)clockwise {
CGPathAddArc(pathRef, NULL, center.x, center.y, radius, startAngle, endAngle, clockwise);
}
- (void)addQuadCurveToPoint:(CGPoint)endPoint controlPoint:(CGPoint)controlPoint {
CGPathAddQuadCurveToPoint(pathRef, NULL, controlPoint.x, controlPoint.y, endPoint.x, endPoint.y);
}
- (void)closePath {
CGPathCloseSubpath(pathRef);
}
- (void)appendPath:(MGMPath *)thePath {
CGPathAddPath(pathRef, NULL, [thePath CGPath]);
}
- (BOOL)isEmpty {
return CGPathIsEmpty(pathRef);
}
- (CGRect)bounds {
return CGPathGetBoundingBox(pathRef);
}
- (CGPoint)currentPoint {
return CGPathGetCurrentPoint(pathRef);
}
- (BOOL)containsPoint:(CGPoint)point {
return CGPathContainsPoint(pathRef, NULL, point, NO);
}
- (void)setLineWidth:(CGFloat)theWidth {
lineWidth = theWidth;
}
- (CGFloat)lineWidth {
return lineWidth;
}
- (void)setLineJoinStyle:(CGLineJoin)theLineJoinStyle {
lineJoinStyle = theLineJoinStyle;
}
- (CGLineJoin)lineJoinStyle {
return lineJoinStyle;
}
- (void)setLineCapStyle:(CGLineCap)theLineCapStyle {
lineCapStyle = theLineCapStyle;
}
- (CGLineCap)lineCapStyle {
return lineCapStyle;
}
- (void)setMiterLimit:(CGFloat)theMiterLimit {
miterLimit = theMiterLimit;
}
- (CGFloat)miterLimit {
return miterLimit;
}
- (void)setFlatness:(CGFloat)theFlatness {
flatness = theFlatness;
}
- (CGFloat)flatness {
return flatness;
}
- (void)setLineDash:(const CGFloat *)pattern count:(NSInteger)count phase:(CGFloat)phase {
if (lineDashPattern!=NULL) {
free(lineDashPattern);
lineDashPattern = NULL;
}
if (pattern!=NULL) {
lineDashPattern = malloc(sizeof(CGFloat)*count);
memcpy(lineDashPattern, pattern, sizeof(pattern));
}
lineDashPatternCount = count;
lineDashPhase = phase;
}
- (void)getLineDash:(CGFloat *)pattern count:(NSInteger *)count phase:(CGFloat *)phase {
if (pattern!=NULL) {
memcpy(pattern, lineDashPattern, sizeof(CGFloat)*lineDashPatternCount);
}
*count = lineDashPatternCount;
*phase = lineDashPhase;
}
- (void)setContextOptions:(CGContextRef)theContext {
CGContextSetLineWidth(theContext, lineWidth);
CGContextSetLineCap(theContext, lineCapStyle);
CGContextSetLineJoin(theContext, lineJoinStyle);
CGContextSetMiterLimit(theContext, miterLimit);
CGContextSetFlatness(theContext, flatness);
if (lineDashPattern!=NULL)
CGContextSetLineDash(theContext, lineDashPhase, lineDashPattern, lineDashPatternCount);
}
- (void)fill {
CGContextRef currentContext = UIGraphicsGetCurrentContext();
CGContextSaveGState(currentContext);
CGContextAddPath(currentContext, pathRef);
[self setContextOptions:currentContext];
CGContextFillPath(currentContext);
CGContextRestoreGState(currentContext);
}
- (void)fillGradientFrom:(UIColor *)theStartColor to:(UIColor *)theEndColor {
CGRect bounds = [self bounds];
CGContextRef currentContext = UIGraphicsGetCurrentContext();
CGContextSaveGState(currentContext);
[self addClip];
CGColorRef colorsRef[2];
colorsRef[0] = [theStartColor CGColor];
colorsRef[1] = [theEndColor CGColor];
CFArrayRef colors = CFArrayCreate(NULL, (const void **)colorsRef, sizeof(colorsRef) / sizeof(CGColorRef), &kCFTypeArrayCallBacks);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGGradientRef gradient = CGGradientCreateWithColors(colorSpace, colors, NULL);
CGPoint start = bounds.origin;
bounds.origin.y += bounds.size.height;
CGPoint end = bounds.origin;
CGContextDrawLinearGradient(currentContext, gradient, start, end, 0);
CGColorSpaceRelease(colorSpace);
CFRelease(colors);
CGGradientRelease(gradient);
CGContextRestoreGState(currentContext);
}
- (void)stroke {
CGContextRef currentContext = UIGraphicsGetCurrentContext();
CGContextSaveGState(currentContext);
CGContextAddPath(currentContext, pathRef);
[self setContextOptions:currentContext];
CGContextStrokePath(currentContext);
CGContextRestoreGState(currentContext);
}
- (void)addClip {
CGContextRef currentContext = UIGraphicsGetCurrentContext();
CGContextAddPath(currentContext, pathRef);
[self setContextOptions:currentContext];
CGContextClip(currentContext);
}
@end

View File

@ -3,7 +3,7 @@
// MGMUsers // MGMUsers
// //
// Created by Mr. Gecko on 12/28/08. // Created by Mr. Gecko on 12/28/08.
// Copyright (c) 2010 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/ // Copyright (c) 2011 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/
// //
#if TARGET_OS_IPHONE #if TARGET_OS_IPHONE

View File

@ -3,7 +3,7 @@
// MGMUsers // MGMUsers
// //
// Created by Mr. Gecko on 7/31/10. // Created by Mr. Gecko on 7/31/10.
// Copyright (c) 2010 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/ // Copyright (c) 2011 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/
// //
#if TARGET_OS_IPHONE #if TARGET_OS_IPHONE

View File

@ -3,7 +3,7 @@
// MGMUsers // MGMUsers
// //
// Created by Mr. Gecko on 4/3/10. // Created by Mr. Gecko on 4/3/10.
// Copyright (c) 2010 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/ // Copyright (c) 2011 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/
// //
#if TARGET_OS_IPHONE #if TARGET_OS_IPHONE

View File

@ -3,7 +3,7 @@
// MGMUsers // MGMUsers
// //
// Created by Mr. Gecko on 4/14/10. // Created by Mr. Gecko on 4/14/10.
// Copyright (c) 2010 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/ // Copyright (c) 2011 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/
// //
#if TARGET_OS_IPHONE #if TARGET_OS_IPHONE

View File

@ -3,7 +3,7 @@
// MGMUsers // MGMUsers
// //
// Created by Mr. Gecko on 8/13/10. // Created by Mr. Gecko on 8/13/10.
// Copyright (c) 2010 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/ // Copyright (c) 2011 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/
// //
#if TARGET_OS_IPHONE #if TARGET_OS_IPHONE

View File

@ -3,7 +3,7 @@
// MGMUsers // MGMUsers
// //
// Created by Mr. Gecko on 8/13/10. // Created by Mr. Gecko on 8/13/10.
// Copyright (c) 2010 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/ // Copyright (c) 2011 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/
// //
#if TARGET_OS_IPHONE #if TARGET_OS_IPHONE

View File

@ -3,14 +3,14 @@
// MGMUsers // MGMUsers
// //
// Created by Mr. Gecko on 7/27/10. // Created by Mr. Gecko on 7/27/10.
// Copyright (c) 2010 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/ // Copyright (c) 2011 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/
// //
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
@class MGMPreferencesPane; @class MGMPreferencesPane;
@interface MGMPreferences : NSObject { @interface MGMPreferences : NSObject <NSWindowDelegate, NSToolbarDelegate> {
@private @private
NSWindow *preferencesWindow; NSWindow *preferencesWindow;
NSMutableArray *preferencesPanes; NSMutableArray *preferencesPanes;

View File

@ -3,7 +3,7 @@
// MGMUsers // MGMUsers
// //
// Created by Mr. Gecko on 7/27/10. // Created by Mr. Gecko on 7/27/10.
// Copyright (c) 2010 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/ // Copyright (c) 2011 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/
// //
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>

View File

@ -3,7 +3,7 @@
// YouView // YouView
// //
// Created by Mr. Gecko on 4/16/09. // Created by Mr. Gecko on 4/16/09.
// Copyright (c) 2010 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/ // Copyright (c) 2011 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/
// //
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
@ -28,7 +28,6 @@ extern NSString * const MGMVMSExt;
@end @end
@interface MGMTaskManager : NSObject { @interface MGMTaskManager : NSObject {
id delegate; id delegate;
@ -46,8 +45,8 @@ extern NSString * const MGMVMSExt;
- (void)updateCount; - (void)updateCount;
- (IBAction)showTaskManager:(id)sender; - (IBAction)showTaskManager:(id)sender;
- (IBAction)clear:(id)sender; - (IBAction)clear:(id)sender;
- (void)addTask:(NSDictionary *)theTask withURL:(NSURL *)theURL; - (void)addTask:(NSDictionary *)theTask withURL:(NSURL *)theURL cookieStorage:(id)theCookieStorage;
- (void)saveURL:(NSURL *)theURL withName:(NSString *)theName; - (void)saveURL:(NSURL *)theURL withName:(NSString *)theName cookieStorage:(id)theCookieStorage;
- (void)application:(NSApplication *)sender openFiles:(NSArray *)files; - (void)application:(NSApplication *)sender openFiles:(NSArray *)files;
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender; - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;

View File

@ -2,53 +2,51 @@
// MGMURLConnectionManager.h // MGMURLConnectionManager.h
// MGMUsers // MGMUsers
// //
// Created by Mr. Gecko on 7/23/10. // Created by Mr. Gecko on 2/21/11.
// Copyright (c) 2010 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/ // Copyright (c) 2011 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/
// //
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
extern NSString * const MGMCookie; @class MGMURLConnectionManager;
extern NSString * const MGMUserAgent;
extern NSString * const MGMConnectionObject; @protocol MGMURLConnectionHandler <NSObject>
extern NSString * const MGMConnectionRequest; - (void)setManager:(MGMURLConnectionManager *)theManager;
extern NSString * const MGMConnectionOldRequest; - (void)setConnection:(NSURLConnection *)theConnection;
extern NSString * const MGMConnectionResponse; - (NSURLConnection *)connection;
extern NSString * const MGMConnectionDelegate; - (void)setRequest:(NSMutableURLRequest *)theRequest;
extern NSString * const MGMConnectionDidReceiveResponse; - (NSMutableURLRequest *)request;
extern NSString * const MGMConnectionDidReceiveData; - (BOOL)synchronous;
extern NSString * const MGMConnectionWillRedirect; - (NSURLCredential *)credentailsForChallenge:(NSURLAuthenticationChallenge *)theChallenge;
extern NSString * const MGMConnectionDidFailWithError; - (void)uploaded:(unsigned long)theBytes totalBytes:(unsigned long)theTotalBytes totalBytesExpected:(unsigned long)theExpectedBytes;
extern NSString * const MGMConnectionDidFinish; - (NSURLRequest *)willSendRequest:(NSURLRequest *)theRequest redirectResponse:(NSHTTPURLResponse *)theResponse;
extern NSString * const MGMConnectionInvisible; - (void)didReceiveResponse:(NSHTTPURLResponse *)theResponse;
extern NSString * const MGMConnectionData; - (void)didReceiveData:(NSData *)theData;
- (void)didFailWithError:(NSError *)theError;
- (void)didFinishLoading;
@end
@interface MGMURLConnectionManager : NSObject { @interface MGMURLConnectionManager : NSObject {
@private
NSHTTPCookieStorage *cookieStorage; NSHTTPCookieStorage *cookieStorage;
NSMutableArray *connections; NSString *userAgent;
NSURLConnection *connection;
NSMutableData *receivedData;
NSString *customUseragent;
NSURLCredential *credentials; NSURLCredential *credentials;
NSMutableArray *handlers;
BOOL runningSynchronousConnection;
} }
+ (id)defaultManager; + (id)manager;
+ (id)managerWithCookieStorage:(id)theCookieStorage; + (id)managerWithCookieStorage:(id)theCookieStorage;
- (id)initWithCookieStorage:(id)theCookieStorage; - (id)initWithCookieStorage:(id)theCookieStorage;
- (NSHTTPCookieStorage *)cookieStorage;
- (void)setCredentials:(NSURLCredential *)theCredentials;
- (NSURLCredential *)credentials;
- (void)setCookieStorage:(id)theCookieStorage; - (void)setCookieStorage:(id)theCookieStorage;
- (NSString *)customUseragent; - (NSHTTPCookieStorage *)cookieStorage;
- (void)setCustomUseragent:(NSString *)theCustomUseragent; - (void)setUserAgent:(NSString *)theUserAgent;
- (NSData *)synchronousRequest:(NSURLRequest *)theRequest returningResponse:(NSURLResponse **)theResponse error:(NSError **)theError; - (NSString *)userAgent;
- (void)connectionWithRequest:(NSURLRequest *)theRequest delegate:(id)theDelegate; - (void)setCredentials:(NSURLCredential *)theCredentials;
- (void)connectionWithRequest:(NSURLRequest *)theRequest delegate:(id)theDelegate object:(id)theObject; - (void)setUser:(NSString *)theUser password:(NSString *)thePassword;
- (void)connectionWithRequest:(NSURLRequest *)theRequest delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didFinish:(SEL)didFinish invisible:(BOOL)isInvisible object:(id)theObject; - (NSURLCredential *)credentials;
- (void)connectionWithRequest:(NSURLRequest *)theRequest delegate:(id)theDelegate didReceiveResponse:(SEL)didReceiveResponse didFailWithError:(SEL)didFailWithError didFinish:(SEL)didFinish invisible:(BOOL)isInvisible object:(id)theObject;
- (void)connectionWithRequest:(NSURLRequest *)theRequest delegate:(id)theDelegate didReceiveResponse:(SEL)didReceiveResponse willRedirect:(SEL)willRedirect didFailWithError:(SEL)didFailWithError didFinish:(SEL)didFinish invisible:(BOOL)isInvisible object:(id)theObject; - (void)addHandler:(id)theHandler;
- (void)connectionWithRequest:(NSURLRequest *)theRequest delegate:(id)theDelegate didReceiveResponse:(SEL)didReceiveResponse didReceiveData:(SEL)didReceiveData willRedirect:(SEL)willRedirect didFailWithError:(SEL)didFailWithError didFinish:(SEL)didFinish invisible:(BOOL)isInvisible object:(id)theObject; - (void)cancelHandler:(id)theHandler;
- (void)cancelCurrent;
- (void)cancelAll; - (void)cancelAll;
@end @end

View File

@ -3,7 +3,7 @@
// MGMUsers // MGMUsers
// //
// Created by Mr. Gecko on 7/4/10. // Created by Mr. Gecko on 7/4/10.
// Copyright (c) 2010 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/ // Copyright (c) 2011 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/
// //
#if TARGET_OS_IPHONE #if TARGET_OS_IPHONE

View File

@ -3,7 +3,7 @@
* MGMUsers * MGMUsers
* *
* Created by Mr. Gecko on 4/14/10. * Created by Mr. Gecko on 4/14/10.
* Copyright (c) 2010 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/ * Copyright (c) 2011 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/
* *
*/ */
@ -13,10 +13,14 @@
#import <MGMUsers/MGMUser.h> #import <MGMUsers/MGMUser.h>
#import <MGMUsers/MGMHTTPCookieStorage.h> #import <MGMUsers/MGMHTTPCookieStorage.h>
#import <MGMUsers/MGMURLConnectionManager.h> #import <MGMUsers/MGMURLConnectionManager.h>
#import <MGMUsers/MGMURLBasicHandler.h>
#import <MGMUsers/MGMFileManager.h>
#import <MGMUsers/MGMSettings.h>
#import <MGMUsers/MGMJSON.h> #import <MGMUsers/MGMJSON.h>
#import <MGMUsers/MGMPath.h>
#import <MGMUsers/MGMLiteConnection.h> #import <MGMUsers/MGMLiteConnection.h>
#import <MGMUsers/MGMLiteResult.h> #import <MGMUsers/MGMLiteResult.h>
#import <MGMUsers/MGMWhitePages.h> #import <MGMUsers/MGMWhitePagesHandler.h>
#import <MGMUsers/MGMMD5.h> #import <MGMUsers/MGMMD5.h>
#else #else
#import <MGMUsers/MGMKeychain.h> #import <MGMUsers/MGMKeychain.h>
@ -24,12 +28,15 @@
#import <MGMUsers/MGMUser.h> #import <MGMUsers/MGMUser.h>
#import <MGMUsers/MGMHTTPCookieStorage.h> #import <MGMUsers/MGMHTTPCookieStorage.h>
#import <MGMUsers/MGMURLConnectionManager.h> #import <MGMUsers/MGMURLConnectionManager.h>
#import <MGMUsers/MGMURLBasicHandler.h>
#import <MGMUsers/MGMFileManager.h>
#import <MGMUsers/MGMPreferences.h> #import <MGMUsers/MGMPreferences.h>
#import <MGMUsers/MGMPreferencesPane.h> #import <MGMUsers/MGMPreferencesPane.h>
#import <MGMUsers/MGMAbout.h>
#import <MGMUsers/MGMJSON.h> #import <MGMUsers/MGMJSON.h>
#import <MGMUsers/MGMLiteConnection.h> #import <MGMUsers/MGMLiteConnection.h>
#import <MGMUsers/MGMLiteResult.h> #import <MGMUsers/MGMLiteResult.h>
#import <MGMUsers/MGMWhitePages.h> #import <MGMUsers/MGMWhitePagesHandler.h>
#import <MGMUsers/MGMTaskManager.h> #import <MGMUsers/MGMTaskManager.h>
#import <MGMUsers/MGMMD5.h> #import <MGMUsers/MGMMD5.h>
#endif #endif

View File

@ -1,36 +0,0 @@
//
// MGMWhitePages.h
// MGMUsers
//
// Created by Mr. Gecko on 9/2/09.
// Copyright (c) 2010 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/
//
#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#else
#import <Cocoa/Cocoa.h>
#endif
extern NSString * const MGMWPDelegate;
extern NSString * const MGMWPDidFindInfo;
extern NSString * const MGMWPDidFailWithError;
extern NSString * const MGMWPPhoneNumber;
extern NSString * const MGMWPName;
extern NSString * const MGMWPAddress;
extern NSString * const MGMWPLocation;
extern NSString * const MGMWPZip;
extern NSString * const MGMWPLatitude;
extern NSString * const MGMWPLongitude;
@class MGMURLConnectionManager;
@interface MGMWhitePages : NSObject {
MGMURLConnectionManager *connectionManager;
NSDictionary *states;
BOOL lookingup;
}
- (void)cancelAll;
- (void)reverseLookup:(NSString *)thePhoneNumber delegate:(id)theDelegate;
- (void)reverseLookup:(NSString *)thePhoneNumber delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didFindInfo:(SEL)didFindInfo;
@end

View File

@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>BuildMachineOSBuild</key>
<string>10J567</string>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>English</string> <string>English</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
@ -20,7 +22,21 @@
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>1</string> <string>1</string>
<key>DTCompiler</key>
<string>4.2</string>
<key>DTPlatformBuild</key>
<string>4A278b</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>4A278b</string>
<key>DTSDKName</key>
<string>macosx10.6</string>
<key>DTXcode</key>
<string>0400</string>
<key>DTXcodeBuild</key>
<string>4A278b</string>
<key>NSHumanReadableCopyright</key> <key>NSHumanReadableCopyright</key>
<string>Copyright (c) 2010 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/</string> <string>Copyright (c) 2011 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/</string>
</dict> </dict>
</plist> </plist>

View File

@ -1,100 +0,0 @@
//
// MGMMDTypes.h
//
// Created by Mr. Gecko on 2/24/10.
// No Copyright Claimed. Public Domain.
//
#ifdef __NEXT_RUNTIME__
#import <Foundation/Foundation.h>
#endif
#define INT64(n) n ## ULL
#define ROR32(x, b) ((x >> b) | (x << (32 - b)))
#define ROR64(x, b) ((x >> b) | (x << (64 - b)))
#define SHR(x, b) (x >> b)
#define MDFileReadLength 1048576
static const char hexdigits[] = "0123456789abcdef";
static const unsigned char MDPadding[128] =
{
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
static uint32_t getu32(const uint8_t *addr) {
return ((uint32_t)addr[0] << 24)
| ((uint32_t)addr[1] << 16)
| ((uint32_t)addr[2] << 8)
| ((uint32_t)addr[3]);
}
static void putu32(uint32_t data, uint8_t *addr) {
addr[0] = (uint8_t)(data >> 24);
addr[1] = (uint8_t)(data >> 16);
addr[2] = (uint8_t)(data >> 8);
addr[3] = (uint8_t)data;
}
static uint64_t getu64(const uint8_t *addr) {
return ((uint64_t)addr[0] << 56)
| ((uint64_t)addr[1] << 48)
| ((uint64_t)addr[2] << 40)
| ((uint64_t)addr[3] << 32)
| ((uint64_t)addr[4] << 24)
| ((uint64_t)addr[5] << 16)
| ((uint64_t)addr[6] << 8)
| ((uint64_t)addr[7]);
}
static void putu64(uint64_t data, uint8_t *addr) {
addr[0] = (uint8_t)(data >> 56);
addr[1] = (uint8_t)(data >> 48);
addr[2] = (uint8_t)(data >> 40);
addr[3] = (uint8_t)(data >> 32);
addr[4] = (uint8_t)(data >> 24);
addr[5] = (uint8_t)(data >> 16);
addr[6] = (uint8_t)(data >> 8);
addr[7] = (uint8_t)data;
}
static uint32_t getu32l(const uint8_t *addr) {
return ((uint32_t)addr[0])
| ((uint32_t)addr[1] << 8)
| ((uint32_t)addr[2] << 16)
| ((uint32_t)addr[3] << 24);
}
static void putu32l(uint32_t data, uint8_t *addr) {
addr[0] = (uint8_t)data;
addr[1] = (uint8_t)(data >> 8);
addr[2] = (uint8_t)(data >> 16);
addr[3] = (uint8_t)(data >> 24);
}
static uint64_t getu64l(const uint8_t *addr) {
return ((uint64_t)addr[0])
| ((uint64_t)addr[1] << 8)
| ((uint64_t)addr[2] << 16)
| ((uint64_t)addr[3] << 24)
| ((uint64_t)addr[4] << 32)
| ((uint64_t)addr[5] << 40)
| ((uint64_t)addr[6] << 48)
| ((uint64_t)addr[7] << 56);
}
static void putu64l(uint64_t data, uint8_t *addr) {
addr[0] = (uint8_t)data;
addr[1] = (uint8_t)(data >> 8);
addr[2] = (uint8_t)(data >> 16);
addr[3] = (uint8_t)(data >> 24);
addr[4] = (uint8_t)(data >> 32);
addr[5] = (uint8_t)(data >> 40);
addr[6] = (uint8_t)(data >> 48);
addr[7] = (uint8_t)(data >> 56);
}