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

View File

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

View File

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

View File

@ -59,17 +59,3 @@ NSComparisonResult dateSort(NSDictionary *info1, NSDictionary *info2, void *cont
- (NSData *)resizeTo:(NSSize)theSize;
#endif
@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>
#endif
@class MGMInstance, MGMURLConnectionManager;
@class MGMDelegateInfo, MGMInstance, MGMURLConnectionManager;
#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 MGMIPhoneNumber;
@ -89,7 +81,7 @@ extern const int MGMISMSOutType;
- (void)getMissedCallsForPage:(int)thePage delegate:(id)theDelegate;
- (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;
- (void)deleteEntriesForever:(NSArray *)theEntries delegate:(id)theDelegate;

View File

@ -7,19 +7,12 @@
//
#import "MGMInbox.h"
#import "MGMDelegateInfo.h"
#import "MGMInstance.h"
#import "MGMAddons.h"
#import "MGMXML.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 MGMIStarredURL = @"https://www.google.com/voice/inbox/recent/starred/";
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:)];
}
- (void)getInboxForPage:(int)thePage delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didReceiveInfo:(SEL)didReceiveInfo {
NSMutableDictionary *info = [NSMutableDictionary dictionary];
[info setObject:theDelegate forKey:MGMIDelegate];
if (didReceiveInfo!=NULL)
[info setObject:NSStringFromSelector(didReceiveInfo) forKey:MGMIDidReceiveInfo];
if (didFailWithError!=NULL)
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setReceiveInfo:didReceiveInfo];
[info setFailWithError:didFailWithError];
[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:)];
}
- (void)getStarredForPage:(int)thePage delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didReceiveInfo:(SEL)didReceiveInfo {
NSMutableDictionary *info = [NSMutableDictionary dictionary];
[info setObject:theDelegate forKey:MGMIDelegate];
if (didReceiveInfo!=NULL)
[info setObject:NSStringFromSelector(didReceiveInfo) forKey:MGMIDidReceiveInfo];
if (didFailWithError!=NULL)
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setReceiveInfo:didReceiveInfo];
[info setFailWithError:didFailWithError];
[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:)];
}
- (void)getSpamForPage:(int)thePage delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didReceiveInfo:(SEL)didReceiveInfo {
NSMutableDictionary *info = [NSMutableDictionary dictionary];
[info setObject:theDelegate forKey:MGMIDelegate];
if (didReceiveInfo!=NULL)
[info setObject:NSStringFromSelector(didReceiveInfo) forKey:MGMIDidReceiveInfo];
if (didFailWithError!=NULL)
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setReceiveInfo:didReceiveInfo];
[info setFailWithError:didFailWithError];
[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:)];
}
- (void)getTrashForPage:(int)thePage delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didReceiveInfo:(SEL)didReceiveInfo {
NSMutableDictionary *info = [NSMutableDictionary dictionary];
[info setObject:theDelegate forKey:MGMIDelegate];
if (didReceiveInfo!=NULL)
[info setObject:NSStringFromSelector(didReceiveInfo) forKey:MGMIDidReceiveInfo];
if (didFailWithError!=NULL)
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setDelegate:theDelegate];
[info setReceiveInfo:didReceiveInfo];
[info setFailWithError:didFailWithError];
[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:)];
}
- (void)getVoicemailForPage:(int)thePage delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didReceiveInfo:(SEL)didReceiveInfo {
NSMutableDictionary *info = [NSMutableDictionary dictionary];
[info setObject:theDelegate forKey:MGMIDelegate];
if (didReceiveInfo!=NULL)
[info setObject:NSStringFromSelector(didReceiveInfo) forKey:MGMIDidReceiveInfo];
if (didFailWithError!=NULL)
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setReceiveInfo:didReceiveInfo];
[info setFailWithError:didFailWithError];
[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:)];
}
- (void)getSMSForPage:(int)thePage delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didReceiveInfo:(SEL)didReceiveInfo {
NSMutableDictionary *info = [NSMutableDictionary dictionary];
[info setObject:theDelegate forKey:MGMIDelegate];
if (didReceiveInfo!=NULL)
[info setObject:NSStringFromSelector(didReceiveInfo) forKey:MGMIDidReceiveInfo];
if (didFailWithError!=NULL)
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setReceiveInfo:didReceiveInfo];
[info setFailWithError:didFailWithError];
[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:)];
}
- (void)getRecordedCallsForPage:(int)thePage delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didReceiveInfo:(SEL)didReceiveInfo {
NSMutableDictionary *info = [NSMutableDictionary dictionary];
[info setObject:theDelegate forKey:MGMIDelegate];
if (didReceiveInfo!=NULL)
[info setObject:NSStringFromSelector(didReceiveInfo) forKey:MGMIDidReceiveInfo];
if (didFailWithError!=NULL)
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setReceiveInfo:didReceiveInfo];
[info setFailWithError:didFailWithError];
[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:)];
}
- (void)getPlacedCallsForPage:(int)thePage delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didReceiveInfo:(SEL)didReceiveInfo {
NSMutableDictionary *info = [NSMutableDictionary dictionary];
[info setObject:theDelegate forKey:MGMIDelegate];
if (didReceiveInfo!=NULL)
[info setObject:NSStringFromSelector(didReceiveInfo) forKey:MGMIDidReceiveInfo];
if (didFailWithError!=NULL)
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setReceiveInfo:didReceiveInfo];
[info setFailWithError:didFailWithError];
[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:)];
}
- (void)getReceivedCallsForPage:(int)thePage delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didReceiveInfo:(SEL)didReceiveInfo {
NSMutableDictionary *info = [NSMutableDictionary dictionary];
[info setObject:theDelegate forKey:MGMIDelegate];
if (didReceiveInfo!=NULL)
[info setObject:NSStringFromSelector(didReceiveInfo) forKey:MGMIDidReceiveInfo];
if (didFailWithError!=NULL)
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setReceiveInfo:didReceiveInfo];
[info setFailWithError:didFailWithError];
[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:)];
}
- (void)getMissedCallsForPage:(int)thePage delegate:(id)theDelegate didFailWithError:(SEL)didFailWithError didReceiveInfo:(SEL)didReceiveInfo {
NSMutableDictionary *info = [NSMutableDictionary dictionary];
[info setObject:theDelegate forKey:MGMIDelegate];
if (didReceiveInfo!=NULL)
[info setObject:NSStringFromSelector(didReceiveInfo) forKey:MGMIDidReceiveInfo];
if (didFailWithError!=NULL)
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setReceiveInfo:didReceiveInfo];
[info setFailWithError:didFailWithError];
[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;
if (thePage<=1)
url = theURL;
@ -228,30 +192,31 @@ const BOOL MGMInboxInvisible = YES;
#if MGMInboxDebug
NSLog(@"MGMInbox Will load %@", url);
#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 {
NSDictionary *info = [theInfo objectForKey:MGMConnectionObject];
if ([info objectForKey:MGMIDidFailWithError]!=nil) {
SEL selector = NSSelectorFromString([info objectForKey:MGMIDidFailWithError]);
id delegate = [info objectForKey:MGMIDelegate];
NSMethodSignature *signature = [delegate methodSignatureForSelector:selector];
- (void)handler:(MGMURLBasicHandler *)theHandler didFailWithError:(NSError *)theError {
MGMDelegateInfo *info = [theHandler object];
BOOL displayError = YES;
if ([info failWithError]!=nil) {
NSMethodSignature *signature = [[info delegate] methodSignatureForSelector:[info failWithError]];
if (signature!=nil) {
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
[invocation setSelector:selector];
[invocation setArgument:&theInfo atIndex:2];
[invocation setSelector:[info failWithError]];
[invocation setArgument:&info atIndex:2];
[invocation setArgument:&theError atIndex:3];
[invocation setArgument:&instance atIndex:4];
[invocation invokeWithTarget:delegate];
} else {
[invocation invokeWithTarget:[info delegate]];
displayError = NO;
}
}
if (displayError)
NSLog(@"MGMInbox Error: %@", theError);
}
} else {
NSLog(@"MGMInbox Error: %@", theError);
}
}
- (void)requestDidFinish:(NSDictionary *)theInfo {
MGMXMLElement *XML = [(MGMXMLDocument *)[[[MGMXMLDocument alloc] initWithData:[theInfo objectForKey:MGMConnectionData] options:MGMXMLDocumentTidyXML error:nil] autorelease] rootElement];
- (void)handlerDidFinish:(MGMURLBasicHandler *)theHandler {
MGMXMLElement *XML = [(MGMXMLDocument *)[[[MGMXMLDocument alloc] initWithData:[theHandler data] options:MGMXMLDocumentTidyXML error:nil] autorelease] rootElement];
NSDictionary *infoDic = [[[[XML elementsForName:@"json"] objectAtIndex:0] stringValue] parseJSON];
NSDictionary *messagesInfo = [infoDic objectForKey:@"messages"];
NSArray *messagesInfoKeys = [messagesInfo allKeys];
@ -318,23 +283,21 @@ const BOOL MGMInboxInvisible = YES;
}
[info sortUsingFunction:dateSort context:nil];
NSDictionary *thisInfo = [theInfo objectForKey:MGMConnectionObject];
if ([thisInfo objectForKey:MGMIDidReceiveInfo]!=nil) {
SEL selector = NSSelectorFromString([thisInfo objectForKey:MGMIDidReceiveInfo]);
id delegate = [thisInfo objectForKey:MGMIDelegate];
NSMethodSignature *signature = [delegate methodSignatureForSelector:selector];
MGMDelegateInfo *thisInfo = [theHandler object];
BOOL displayInfo = YES;
if ([thisInfo receiveInfo]!=nil) {
NSMethodSignature *signature = [[thisInfo delegate] methodSignatureForSelector:[thisInfo receiveInfo]];
if (signature!=nil) {
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
[invocation setSelector:selector];
[invocation setSelector:[thisInfo receiveInfo]];
[invocation setArgument:&info atIndex:2];
[invocation setArgument:&instance atIndex:3];
[invocation invokeWithTarget:delegate];
} else {
NSLog(@"MGMInbox Info: %@", info);
[invocation invokeWithTarget:[thisInfo delegate]];
displayInfo = NO;
}
} else {
NSLog(@"MGMInbox Info: %@", info);
}
if (displayInfo)
NSLog(@"MGMInbox Info: %@", info);
}
- (NSDictionary *)parseMessageWithHTML:(NSString *)theHTML info:(NSDictionary *)theInfo {
NSMutableDictionary *message = [NSMutableDictionary dictionary];
@ -376,13 +339,10 @@ const BOOL MGMInboxInvisible = YES;
#if MGMInboxDebug
NSLog(@"MGMInbox Will delete %@", theEntries);
#endif
NSMutableDictionary *info = [NSMutableDictionary dictionary];
[info setObject:theDelegate forKey:MGMIDelegate];
if (didFinish!=NULL)
[info setObject:NSStringFromSelector(didFinish) forKey:MGMIDidFinish];
if (didFailWithError!=NULL)
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
[info setObject:theEntries forKey:MGMIEntries];
MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setFinish:didFinish];
[info setFailWithError:didFailWithError];
[info setEntries:theEntries];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:MGMIDeleteForeverURL]];
[request setHTTPMethod:MGMPostMethod];
[request setValue:MGMURLForm forHTTPHeaderField:MGMContentType];
@ -392,7 +352,12 @@ const BOOL MGMInboxInvisible = YES;
}
[body appendFormat:@"_rnr_se=%@", [instance rnr_se]];
[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 {
[self deleteEntries:theEntries delegate:theDelegate didFailWithError:@selector(delete:didFailWithError:instance:) didFinish:@selector(deleteDidFinish:instance:)];
@ -401,13 +366,10 @@ const BOOL MGMInboxInvisible = YES;
#if MGMInboxDebug
NSLog(@"MGMInbox Will delete %@", theEntries);
#endif
NSMutableDictionary *info = [NSMutableDictionary dictionary];
[info setObject:theDelegate forKey:MGMIDelegate];
if (didFinish!=NULL)
[info setObject:NSStringFromSelector(didFinish) forKey:MGMIDidFinish];
if (didFailWithError!=NULL)
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
[info setObject:theEntries forKey:MGMIEntries];
MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setFinish:didFinish];
[info setFailWithError:didFailWithError];
[info setEntries:theEntries];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:MGMIDeleteURL]];
[request setHTTPMethod:MGMPostMethod];
[request setValue:MGMURLForm forHTTPHeaderField:MGMContentType];
@ -417,7 +379,12 @@ const BOOL MGMInboxInvisible = YES;
}
[body appendFormat:@"trash=1&_rnr_se=%@", [instance rnr_se]];
[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 {
@ -427,13 +394,10 @@ const BOOL MGMInboxInvisible = YES;
#if MGMInboxDebug
NSLog(@"MGMInbox Will delete %@", theEntries);
#endif
NSMutableDictionary *info = [NSMutableDictionary dictionary];
[info setObject:theDelegate forKey:MGMIDelegate];
if (didFinish!=NULL)
[info setObject:NSStringFromSelector(didFinish) forKey:MGMIDidFinish];
if (didFailWithError!=NULL)
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
[info setObject:theEntries forKey:MGMIEntries];
MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setFinish:didFinish];
[info setFailWithError:didFailWithError];
[info setEntries:theEntries];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:MGMIMarkURL]];
[request setHTTPMethod:MGMPostMethod];
[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]];
[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 {
@ -453,13 +422,10 @@ const BOOL MGMInboxInvisible = YES;
#if MGMInboxDebug
NSLog(@"MGMInbox Will delete %@", theEntries);
#endif
NSMutableDictionary *info = [NSMutableDictionary dictionary];
[info setObject:theDelegate forKey:MGMIDelegate];
if (didFinish!=NULL)
[info setObject:NSStringFromSelector(didFinish) forKey:MGMIDidFinish];
if (didFailWithError!=NULL)
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
[info setObject:theEntries forKey:MGMIEntries];
MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setFinish:didFinish];
[info setFailWithError:didFailWithError];
[info setEntries:theEntries];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:MGMIReportURL]];
[request setHTTPMethod:MGMPostMethod];
[request setValue:MGMURLForm forHTTPHeaderField:MGMContentType];
@ -469,7 +435,12 @@ const BOOL MGMInboxInvisible = YES;
}
[body appendFormat:@"spam=1&_rnr_se=%@", [instance rnr_se]];
[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 {
@ -479,13 +450,10 @@ const BOOL MGMInboxInvisible = YES;
#if MGMInboxDebug
NSLog(@"MGMInbox Will delete %@", theEntries);
#endif
NSMutableDictionary *info = [NSMutableDictionary dictionary];
[info setObject:theDelegate forKey:MGMIDelegate];
if (didFinish!=NULL)
[info setObject:NSStringFromSelector(didFinish) forKey:MGMIDidFinish];
if (didFailWithError!=NULL)
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
[info setObject:theEntries forKey:MGMIEntries];
MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setFinish:didFinish];
[info setFailWithError:didFailWithError];
[info setEntries:theEntries];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:MGMIStarURL]];
[request setHTTPMethod:MGMPostMethod];
[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]];
[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 {
[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 {
NSMutableDictionary *info = [NSMutableDictionary dictionary];
[info setObject:theDelegate forKey:MGMIDelegate];
if (didFinish!=NULL)
[info setObject:NSStringFromSelector(didFinish) forKey:MGMIDidFinish];
if (didFailWithError!=NULL)
[info setObject:NSStringFromSelector(didFailWithError) forKey:MGMIDidFailWithError];
if (theMessage!=nil)
[info setObject:theMessage forKey:MGMIMessage];
if (thePhoneNumbers!=nil)
[info setObject:thePhoneNumbers forKey:MGMIPhoneNumbers];
MGMDelegateInfo *info = [MGMDelegateInfo infoWithDelegate:theDelegate];
[info setFinish:didFinish];
[info setFailWithError:didFailWithError];
[info setMessage:theMessage];
[info setPhoneNumbers:thePhoneNumbers];
if (theID==nil) theID = @"";
[info setObject:theID forKey:MGMIID];
[info setIdentifier:theID];
if (thePhoneNumbers==nil || [thePhoneNumbers count]==0 || theMessage==nil || [theMessage isEqual:@""]) {
NSMethodSignature *signature = [theDelegate methodSignatureForSelector:didFailWithError];
if (signature!=nil) {
@ -538,22 +506,25 @@ const BOOL MGMInboxInvisible = YES;
}
[body appendFormat:@"&text=%@&sendErrorSms=0&_rnr_se=%@", [theMessage addPercentEscapes], [instance rnr_se]];
[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 {
NSDictionary *info = [theInfo objectForKey:MGMConnectionObject];
if ([info objectForKey:MGMIDidFailWithError]!=nil) {
SEL selector = NSSelectorFromString([info objectForKey:MGMIDidFailWithError]);
id delegate = [info objectForKey:MGMIDelegate];
NSMethodSignature *signature = [delegate methodSignatureForSelector:selector];
- (void)send:(MGMURLBasicHandler *)theHandler didFailWithError:(NSError *)theError {
MGMDelegateInfo *info = [theHandler object];
if ([info failWithError]!=nil) {
NSMethodSignature *signature = [[info delegate] methodSignatureForSelector:[info failWithError]];
if (signature!=nil) {
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
[invocation setSelector:selector];
[invocation setArgument:&theInfo atIndex:2];
[invocation setSelector:[info failWithError]];
[invocation setArgument:&info atIndex:2];
[invocation setArgument:&theError atIndex:3];
[invocation setArgument:&instance atIndex:4];
[invocation invokeWithTarget:delegate];
[invocation invokeWithTarget:[info delegate]];
} else {
NSLog(@"MGMInbox Send Request Error: %@", theError);
}
@ -561,22 +532,19 @@ const BOOL MGMInboxInvisible = YES;
NSLog(@"MGMInbox Send Request Error: %@", theError);
}
}
- (void)sendRequestDidFinish:(NSDictionary *)theInfo {
- (void)sendDidFinish:(MGMURLBasicHandler *)theHandler {
#if MGMInboxDebug
NSLog(@"MGMInbox Did Send Request %@", [[[NSString alloc] initWithData:[theInfo objectForKey:MGMConnectionData] encoding:NSUTF8StringEncoding] autorelease]);
NSLog(@"MGMInbox Did Send Request %@", [theHandler string]);
#endif
NSMutableDictionary *thisInfo = [NSMutableDictionary dictionaryWithDictionary:[theInfo objectForKey:MGMConnectionObject]];
[thisInfo setObject:[theInfo objectForKey:MGMConnectionData] forKey:MGMConnectionData];
if ([thisInfo objectForKey:MGMIDidFinish]!=nil) {
SEL selector = NSSelectorFromString([thisInfo objectForKey:MGMIDidFinish]);
id delegate = [thisInfo objectForKey:MGMIDelegate];
NSMethodSignature *signature = [delegate methodSignatureForSelector:selector];
MGMDelegateInfo *thisInfo = [theHandler object];
if ([thisInfo finish]!=nil) {
NSMethodSignature *signature = [[thisInfo delegate] methodSignatureForSelector:[thisInfo finish]];
if (signature!=nil) {
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
[invocation setSelector:selector];
[invocation setSelector:[thisInfo finish]];
[invocation setArgument:&thisInfo atIndex:2];
[invocation setArgument:&instance atIndex:3];
[invocation invokeWithTarget:delegate];
[invocation invokeWithTarget:[thisInfo delegate]];
}
}
}

View File

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

View File

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

View File

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

View File

@ -101,12 +101,12 @@
#if TARGET_OS_IPHONE
if (speaker) [self speaker];
#endif
if (recorderID!=PJSUA_INVALID_ID)
[self performSelectorOnMainThread:@selector(stopRecordingMain) withObject:nil waitUntilDone:YES];
if (isRingbackOn)
[self stopRingback];
if (holdMusicPlayer!=PJSUA_INVALID_ID)
[self performSelectorOnMainThread:@selector(stopHoldMusic) withObject:nil waitUntilDone:YES];
if (recorderID!=PJSUA_INVALID_ID)
[self performSelectorOnMainThread:@selector(stopRecordingMain) withObject:nil waitUntilDone:YES];
}
state = theState;
}
@ -253,6 +253,10 @@
pj_thread_desc 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);
if (status!=PJ_SUCCESS)
NSLog(@"Error hanging up call %@", self);

View File

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

View File

@ -42,7 +42,8 @@
}
if (audioPlayer!=nil) {
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;
[self setLevel:NSStatusWindowLevel];
@ -67,15 +68,15 @@
[super dealloc];
}
- (void)request:(NSDictionary *)theInfo didFailWithError:(NSError *)theError {
- (void)handler:(MGMURLBasicHandler *)theHandler didFailWithError:(NSError *)theError {
NSLog(@"Starting Audio Error: %@", theError);
NSAlert *theAlert = [[NSAlert new] autorelease];
[theAlert setMessageText:@"Error loading audio"];
[theAlert setInformativeText:[theError localizedDescription]];
[theAlert runModal];
}
- (void)requestDidFinish:(NSDictionary *)theInfo {
QTDataReference *audioReference = [QTDataReference dataReferenceWithReferenceToData:[theInfo objectForKey:MGMConnectionData] name:@"voicemail.mp3" MIMEType:nil];
- (void)handlerDidFinish:(MGMURLBasicHandler *)theHandler {
QTDataReference *audioReference = [QTDataReference dataReferenceWithReferenceToData:[theHandler data] name:@"voicemail.mp3" MIMEType:nil];
QTMovie *theAudio = [QTMovie movieWithDataReference:audioReference error:NULL];
[theAudio autoplay];
[audioPlayer setMovie:theAudio];

View File

@ -140,7 +140,7 @@ NSString * const MGMSID = @"id";
- (void)checkVoicemail {
[[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);
}
- (void)voicemailGotInfo:(NSArray *)theMessages instance:(MGMInstance *)theInstance {
@ -239,7 +239,7 @@ NSString * const MGMSID = @"id";
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);
NSAlert *theAlert = [[NSAlert new] autorelease];
[theAlert setMessageText:@"Error loading inbox"];
@ -300,7 +300,7 @@ NSString * const MGMSID = @"id";
[currentData removeObject:data];
[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);
NSAlert *theAlert = [[NSAlert new] autorelease];
[theAlert setMessageText:@"Error reporting"];
@ -308,7 +308,7 @@ NSString * const MGMSID = @"id";
[theAlert runModal];
[self stopProgress];
}
- (void)reportDidFinish:(NSDictionary *)theInfo instance:(MGMInstance *)theInstance {
- (void)reportDidFinish:(MGMDelegateInfo *)theInfo instance:(MGMInstance *)theInstance {
[self loadInbox];
[self stopProgress];
}
@ -342,7 +342,7 @@ NSString * const MGMSID = @"id";
[currentData removeObject:data];
[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);
NSAlert *theAlert = [[NSAlert new] autorelease];
[theAlert setMessageText:@"Error deleting"];
@ -350,7 +350,7 @@ NSString * const MGMSID = @"id";
[theAlert runModal];
[self stopProgress];
}
- (void)deleteDidFinish:(NSDictionary *)theInfo instance:(MGMInstance *)theInstance {
- (void)deleteDidFinish:(MGMDelegateInfo *)theInfo instance:(MGMInstance *)theInstance {
[self loadInbox];
[self stopProgress];
}

View File

@ -350,14 +350,17 @@ NSString * const MGMSIPDefaultDomain = @"proxy01.sipphone.com";
NSURLCredential *credentials = [NSURLCredential credentialWithUser:username password:[S7CheckUser password] persistence:NSURLCredentialPersistenceForSession];
[S7ConnectionManager setCookieStorage:[S7CheckUser cookieStorage]];
[S7ConnectionManager setCredentials:credentials];
[S7ConnectionManager setCustomUseragent:MGMGCUseragent];
[S7ConnectionManager setUserAgent:MGMGCUseragent];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:MGMGCAuthenticationURL] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:15.0];
[request setHTTPMethod:MGMPostMethod];
[request setValue:MGMURLForm forHTTPHeaderField:MGMContentType];
[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 release];
S7CheckUser = nil;
@ -367,8 +370,8 @@ NSString * const MGMSIPDefaultDomain = @"proxy01.sipphone.com";
step = 8;
[self displayStep];
}
- (void)authenticationDidFinish:(NSDictionary *)theInfo {
NSDictionary *info = [MGMGoogleContacts dictionaryWithData:[theInfo objectForKey:MGMConnectionData]];
- (void)authenticationDidFinish:(MGMURLBasicHandler *)theHandler {
NSDictionary *info = [MGMGoogleContacts dictionaryWithString:[theHandler string]];
[S7ConnectionManager setCookieStorage:nil];
if ([info objectForKey:@"Error"]!=nil) {
[S7CheckUser remove];

View File

@ -8,7 +8,7 @@
#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;
@ -18,7 +18,7 @@ extern NSString * const MGMContactsControllersChangedNotification;
NSMutableArray *multipleSMS;
MGMPreferences *preferences;
MGMTaskManager *taskManager;
MGMWhitePages *whitePages;
MGMURLConnectionManager *connectionManager;
BOOL quitting;
MGMThemeManager *themeManager;

View File

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

View File

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

View File

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

View File

@ -221,7 +221,7 @@ NSString *MGMLastUserPhoneKey = @"MGMLastUserPhone";
[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];
[alert setMessageText:@"Call Failed"];
[alert setInformativeText:[theError localizedDescription]];
@ -229,11 +229,11 @@ NSString *MGMLastUserPhoneKey = @"MGMLastUserPhone";
placingCall = NO;
[callTimer fire];
}
- (void)callDidFinish:(NSDictionary *)theInfo {
- (void)callDidFinish:(MGMDelegateInfo *)theInfo {
placingCall = NO;
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];
[alert setMessageText:@"Call Cancel Failed"];
[alert setInformativeText:[theError localizedDescription]];

View File

@ -161,14 +161,10 @@ NSString * const MGMNoAuthor = @"No Author Found";
if ([sender tag]==-1) {
[themeManager setSound:soundName withPath:MGMTNoSound];
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];
if ([manager fileExistsAtPath:finalPath]) {
if ([manager respondsToSelector:@selector(removeFileAtPath:)])
[manager removeFileAtPath:finalPath handler:nil];
else
[manager removeItemAtPath:finalPath error:nil];
}
if ([manager fileExistsAtPath:finalPath])
[manager removeItemAtPath:finalPath];
}
} else {
NSMenuItem *soundsMenuItem = nil;

View File

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

View File

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

View File

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

View File

@ -116,7 +116,7 @@
[[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;
[SMSTextView setEditable:YES];
[sendButton setTitle:@"Send"];
@ -130,7 +130,7 @@
[theAlert setAlertStyle:2];
[theAlert runModal];
}
- (void)messageDidFinish:(NSDictionary *)theInfo instance:(MGMInstance *)theInstance {
- (void)messageDidFinish:(MGMDelegateInfo *)theInfo instance:(MGMInstance *)theInstance {
sendingMessage = NO;
[SMSWindow close];
}

View File

@ -128,7 +128,7 @@ const float updateTimeInterval = 300.0;
- (void)checkSMSMessagesForInstance:(MGMInstance *)theInstance {
[[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);
}
- (void)inboxGotInfo:(NSArray *)theMessages instance:(MGMInstance *)theInstance {

View File

@ -187,7 +187,7 @@
[SMSTextView setEditable:NO];
[[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;
[SMSTextView setEditable:YES];
[[manager SMSWindow] makeFirstResponder:SMSTextView];
@ -196,7 +196,7 @@
[theAlert setInformativeText:[theError localizedDescription]];
[theAlert runModal];
}
- (void)messageDidFinish:(NSDictionary *)theInfo instance:(MGMInstance *)theInstance {
- (void)messageDidFinish:(MGMDelegateInfo *)theInfo instance:(MGMInstance *)theInstance {
sendingMessage = NO;
NSDateFormatter *formatter = [[NSDateFormatter new] autorelease];
[formatter setDateFormat:@"h:mm a"];
@ -242,14 +242,14 @@
- (BOOL)shouldClose {
return (!sendingMessage);
}
- (void)mark:(NSDictionary *)theInfo didFailWithError:(NSError *)theError instance:(MGMInstance *)theInstance {
- (void)mark:(MGMDelegateInfo *)theInfo didFailWithError:(NSError *)theError instance:(MGMInstance *)theInstance {
marking = NO;
NSAlert *theAlert = [[NSAlert new] autorelease];
[theAlert setMessageText:@"Error marking as read"];
[theAlert setInformativeText:[theError localizedDescription]];
[theAlert runModal];
}
- (void)markDidFinish:(NSDictionary *)theInfo instance:(MGMInstance *)theInstance {
- (void)markDidFinish:(MGMDelegateInfo *)theInfo instance:(MGMInstance *)theInstance {
marking = NO;
[messageInfo setObject:[NSNumber numberWithBool:YES] forKey:MGMIRead];
[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
//
// 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

View File

@ -3,7 +3,7 @@
// MGMUsers
//
// 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

View File

@ -3,7 +3,7 @@
// MGMUsers
//
// 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

View File

@ -3,7 +3,7 @@
// MGMUsers
//
// 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

View File

@ -3,7 +3,7 @@
// MGMUsers
//
// 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

View File

@ -3,7 +3,7 @@
// MGMUsers
//
// 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

View File

@ -3,14 +3,14 @@
// MGMUsers
//
// 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>
@class MGMPreferencesPane;
@interface MGMPreferences : NSObject {
@interface MGMPreferences : NSObject <NSWindowDelegate, NSToolbarDelegate> {
@private
NSWindow *preferencesWindow;
NSMutableArray *preferencesPanes;

View File

@ -3,7 +3,7 @@
// MGMUsers
//
// 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>

View File

@ -3,7 +3,7 @@
// YouView
//
// 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>
@ -28,7 +28,6 @@ extern NSString * const MGMVMSExt;
@end
@interface MGMTaskManager : NSObject {
id delegate;
@ -46,8 +45,8 @@ extern NSString * const MGMVMSExt;
- (void)updateCount;
- (IBAction)showTaskManager:(id)sender;
- (IBAction)clear:(id)sender;
- (void)addTask:(NSDictionary *)theTask withURL:(NSURL *)theURL;
- (void)saveURL:(NSURL *)theURL withName:(NSString *)theName;
- (void)addTask:(NSDictionary *)theTask withURL:(NSURL *)theURL cookieStorage:(id)theCookieStorage;
- (void)saveURL:(NSURL *)theURL withName:(NSString *)theName cookieStorage:(id)theCookieStorage;
- (void)application:(NSApplication *)sender openFiles:(NSArray *)files;
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;

View File

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

View File

@ -3,7 +3,7 @@
// MGMUsers
//
// 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

View File

@ -3,7 +3,7 @@
* MGMUsers
*
* 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/MGMHTTPCookieStorage.h>
#import <MGMUsers/MGMURLConnectionManager.h>
#import <MGMUsers/MGMURLBasicHandler.h>
#import <MGMUsers/MGMFileManager.h>
#import <MGMUsers/MGMSettings.h>
#import <MGMUsers/MGMJSON.h>
#import <MGMUsers/MGMPath.h>
#import <MGMUsers/MGMLiteConnection.h>
#import <MGMUsers/MGMLiteResult.h>
#import <MGMUsers/MGMWhitePages.h>
#import <MGMUsers/MGMWhitePagesHandler.h>
#import <MGMUsers/MGMMD5.h>
#else
#import <MGMUsers/MGMKeychain.h>
@ -24,12 +28,15 @@
#import <MGMUsers/MGMUser.h>
#import <MGMUsers/MGMHTTPCookieStorage.h>
#import <MGMUsers/MGMURLConnectionManager.h>
#import <MGMUsers/MGMURLBasicHandler.h>
#import <MGMUsers/MGMFileManager.h>
#import <MGMUsers/MGMPreferences.h>
#import <MGMUsers/MGMPreferencesPane.h>
#import <MGMUsers/MGMAbout.h>
#import <MGMUsers/MGMJSON.h>
#import <MGMUsers/MGMLiteConnection.h>
#import <MGMUsers/MGMLiteResult.h>
#import <MGMUsers/MGMWhitePages.h>
#import <MGMUsers/MGMWhitePagesHandler.h>
#import <MGMUsers/MGMTaskManager.h>
#import <MGMUsers/MGMMD5.h>
#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">
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>10J567</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
@ -20,7 +22,21 @@
<string>????</string>
<key>CFBundleVersion</key>
<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>
<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>
</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);
}