Fixed issues with going to sleep, getting Google Contacts, quitting, and SMS Sound notifications.

This commit is contained in:
GRMrGecko 2010-09-27 08:10:24 -05:00
parent d78ec38bf9
commit 7a586f0eb1
12 changed files with 65 additions and 27 deletions

View File

@ -153,7 +153,7 @@ typedef enum {
#if !TARGET_OS_IPHONE
- (BOOL)setInputSoundDevice:(int)theInputDevice outputSoundDevice:(int)theOutputDevice;
- (BOOL)stopSound;
- (BOOL)stopAudio;
- (void)updateAudioDevices;
- (NSArray *)audioDevices;
#endif

View File

@ -617,19 +617,20 @@ static OSStatus MGMAudioDevicesChanged(AudioHardwarePropertyID propertyID, void
- (void)computerSleep {
restartAccounts = [accounts copy];
[self stopBackground];
[accounts makeObjectsPerformSelector:@selector(logout)];
#if !TARGET_OS_IPHONE
[self stopAudio];
#endif
}
- (void)computerWake {
#if !TARGET_OS_IPHONE
[self updateAudioDevices];
#endif
if (restartAccounts!=nil) {
for (int i=0; i<[restartAccounts count]; i++) {
if (![accounts containsObject:[restartAccounts objectAtIndex:i]])
[accounts addObject:[restartAccounts objectAtIndex:i]];
}
[restartAccounts makeObjectsPerformSelector:@selector(login)];
[restartAccounts release];
restartAccounts = nil;
}
[self start];
}
- (void)registerThread:(pj_thread_desc *)thePJThreadDesc {
@ -845,7 +846,7 @@ static OSStatus MGMAudioDevicesChanged(AudioHardwarePropertyID propertyID, void
bzero(&PJThreadDesc, sizeof(pj_thread_desc));
return (status==PJ_SUCCESS);
}
- (BOOL)stopSound {
- (BOOL)stopAudio {
if (state!=MGMSIPStartedState)
return NO;

View File

@ -60,6 +60,10 @@
NSString *prefix = [[self class] prefixForName:name];
NSString *uri = nil;
if (prefix!=nil) {
if (MGMXMLNodePtr->doc==NULL) {
NSLog(@"You may not search for elements with a namespace if there is no document.");
return nil;
}
xmlNsPtr namespace = xmlSearchNs(MGMXMLNodePtr->doc, MGMXMLNodePtr, [prefix xmlString]);
if (namespace!=NULL)
uri = [NSString stringWithXMLString:namespace->href];

View File

@ -71,6 +71,7 @@ struct _xmlCom {
xmlNsPtr namespaceXML;
xmlNodePtr parentNode;
MGMXMLNodeKind type;
MGMXMLNode *documentNode;
}
+ (id)nodeWithTypeXMLPtr:(xmlTypPtr)theXMLPtr;
- (id)initWithTypeXMLPtr:(xmlTypPtr)theXMLPtr;
@ -81,6 +82,7 @@ struct _xmlCom {
+ (void)removeChildrenFromNode:(xmlNodePtr)theNode;
+ (void)freeNode:(xmlNodePtr)theNode;
- (void)setTypeXMLPtr:(xmlTypPtr)theXMLPtr;
- (void)releaseDocument;
+ (BOOL)isNode:(MGMXMLNodeKind)theType;
- (BOOL)isNode;
+ (NSError *)lastError;

View File

@ -84,6 +84,8 @@ static void MGMXMLErrorHandler(void *userData, xmlErrorPtr error) {
parentNode = NULL;
}
if (commonXML!=NULL) {
if (type!=MGMXMLDocumentKind)
[self releaseDocument];
commonXML->_private = NULL;
if (commonXML->parent==NULL) {
@ -91,7 +93,7 @@ static void MGMXMLErrorHandler(void *userData, xmlErrorPtr error) {
xmlNodePtr child = commonXML->children;
while (child!=NULL) {
xmlNodePtr nextChild = child->next;
if (child->type == XML_ELEMENT_NODE) {
if (child->type==MGMXMLElementKind) {
if (child->prev!=NULL)
child->prev->next = child->next;
if (child->next!=NULL)
@ -199,7 +201,10 @@ static void MGMXMLErrorHandler(void *userData, xmlErrorPtr error) {
theNode->parent = NULL;
theNode->prev = NULL;
theNode->next = NULL;
if (theNode->doc!=NULL) [self stripDocumentFromNode:theNode];
if (theNode->doc!=NULL) {
[(MGMXMLNode *)theNode->_private releaseDocument];
[self stripDocumentFromNode:theNode];
}
}
}
}
@ -219,6 +224,14 @@ static void MGMXMLErrorHandler(void *userData, xmlErrorPtr error) {
self->isa = [MGMXMLDocument class];
else if (type==MGMXMLElementKind && [self isMemberOfClass:[MGMXMLNode class]])
self->isa = [MGMXMLElement class];
if (type!=MGMXMLDocumentKind)
documentNode = [[MGMXMLNode alloc] initWithTypeXMLPtr:(xmlTypPtr)commonXML->doc];
}
}
- (void)releaseDocument {
if (documentNode!=nil) {
[documentNode release];
documentNode = nil;
}
}
+ (BOOL)isNode:(MGMXMLNodeKind)theType {

View File

@ -60,6 +60,11 @@ NSString *MGMLastUserPhoneKey = @"MGMLastUserPhone";
}
}
- (void)dealloc {
if (progressFadeAnimation!=nil) {
[progressFadeAnimation stopAnimation];
[progressFadeAnimation release];
progressFadeAnimation = nil;
}
[super dealloc];
if (instance!=nil) {
[instance setDelegate:nil];

View File

@ -83,7 +83,7 @@ NSString * const MGMLogout = @"Logout";
if ([[tableColumn identifier] isEqual:@"username"]) {
#if MGMSIPENABLED
NSArray *users = [MGMUser users];
if ([users count]>=row)
if ([users count]<=row)
return nil;
MGMUser *user = [MGMUser userWithID:[users objectAtIndex:row]];
if ([[user settingForKey:MGMSAccountType] isEqual:MGMSSIP]) {
@ -94,7 +94,7 @@ NSString * const MGMLogout = @"Logout";
return [[MGMUser userNames] objectAtIndex:row];
} else if ([[tableColumn identifier] isEqual:@"state"]) {
NSDictionary *users = [MGMUser usersPlist];
if ([[users allKeys] count]>=row)
if ([[users allKeys] count]<=row)
return nil;
return ([[users objectForKey:[[users allKeys] objectAtIndex:row]] boolValue] ? @"✓" : @"");
}

View File

@ -61,7 +61,7 @@
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
if (shouldRestart) {
/*NSAlert *alert = [[NSAlert new] autorelease];
NSAlert *alert = [[NSAlert new] autorelease];
[alert setMessageText:@"Restart Required"];
[alert setInformativeText:@"You have changed some settings that requires you to restart VoiceMac for them to take place, do you want to restart VoiceMac now?"];
[alert addButtonWithTitle:@"Yes"];
@ -73,8 +73,8 @@
NSString *relaunchPath = [[[NSBundle bundleWithIdentifier:@"org.andymatuschak.Sparkle"] resourcePath] stringByAppendingPathComponent:@"relaunch"];
[NSTask launchedTaskWithLaunchPath:relaunchPath arguments:[NSArray arrayWithObjects:pathToRelaunch, [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]], nil]];
[[NSApplication sharedApplication] terminate:self];
}*/
[[MGMSIP sharedSIP] restart];
}
//[[MGMSIP sharedSIP] restart];
}
if (mainView!=nil)
[mainView release];

View File

@ -62,6 +62,11 @@ NSString * const MGMSIPUserAreaCode = @"MGMVSIPUserAreaCode";
}
}
- (void)dealloc {
if (progressFadeAnimation!=nil) {
[progressFadeAnimation stopAnimation];
[progressFadeAnimation release];
progressFadeAnimation = nil;
}
[super dealloc];
if (calls!=nil) {
[calls removeAllObjects];

View File

@ -144,6 +144,7 @@ const float updateTimeInterval = 300.0;
}
NSDate *newestDate = [NSDate distantPast];
BOOL newMessage = NO;
BOOL newTab = NO;
for (unsigned int i=0; i<[theMessages count]; i++) {
if ([lastDates objectForKey:[theInstance userNumber]]==nil || (![[lastDates objectForKey:[theInstance userNumber]] isEqual:[[theMessages objectAtIndex:i] objectForKey:MGMITime]] && [[lastDates objectForKey:[theInstance userNumber]] earlierDate:[[theMessages objectAtIndex:i] objectForKey:MGMITime]]==[lastDates objectForKey:[theInstance userNumber]])) {
NSMutableDictionary *messageInfo = [NSMutableDictionary dictionaryWithDictionary:[theMessages objectAtIndex:i]];
@ -151,16 +152,18 @@ const float updateTimeInterval = 300.0;
[messageInfo removeObjectForKey:MGMIMessages];
[messageInfo setObject:[[theInstance contacts] nameForNumber:[messageInfo objectForKey:MGMIPhoneNumber]] forKey:MGMTInName];
[messageInfo setObject:[theInstance userNumber] forKey:MGMTUserNumber];
BOOL window = NO;
BOOL tab = NO;
for (unsigned int m=0; m<[SMSMessages count]; m++) {
if ([[[[SMSMessages objectAtIndex:m] messageInfo] objectForKey:MGMIPhoneNumber] isEqual:[messageInfo objectForKey:MGMIPhoneNumber]] && ([[[[SMSMessages objectAtIndex:m] messageInfo] objectForKey:MGMIID] isEqual:[messageInfo objectForKey:MGMIID]] || [[[[SMSMessages objectAtIndex:m] messageInfo] objectForKey:MGMIID] isEqual:@""]) && [[SMSMessages objectAtIndex:m] instance]==theInstance) {
window = YES;
[[SMSMessages objectAtIndex:m] updateWithMessages:messages messageInfo:messageInfo];
tab = YES;
if ([[SMSMessages objectAtIndex:m] updateWithMessages:messages messageInfo:messageInfo])
newMessage = YES;
break;
}
}
if (!window && ![[[theMessages objectAtIndex:i] objectForKey:MGMIRead] boolValue]) {
if (!tab && ![[[theMessages objectAtIndex:i] objectForKey:MGMIRead] boolValue]) {
newMessage = YES;
newTab = YES;
[SMSMessages addObject:[MGMSMSMessageView viewWithManager:self messages:messages messageInfo:messageInfo instance:theInstance]];
}
if ([newestDate earlierDate:[[theMessages objectAtIndex:i] objectForKey:MGMITime]]==newestDate)
@ -168,10 +171,12 @@ const float updateTimeInterval = 300.0;
}
}
if (newMessage) {
[self loadWindow];
[lastDates setObject:newestDate forKey:[theInstance userNumber]];
[self reloadData];
[[controller themeManager] playSound:MGMTSSMSMessage];
}
if (newTab) {
[self loadWindow];
[self reloadData];
[SMSWindow makeKeyAndOrderFront:self];
}
}

View File

@ -41,7 +41,7 @@
- (void)sendNotifications;
- (void)updateWithMessages:(NSArray *)theMessages messageInfo:(NSDictionary *)theMessageInfo;
- (BOOL)updateWithMessages:(NSArray *)theMessages messageInfo:(NSDictionary *)theMessageInfo;
- (void)buildHTML;
- (void)addMessage:(NSDictionary *)theMessage;

View File

@ -97,27 +97,30 @@
}
}
- (void)updateWithMessages:(NSArray *)theMessages messageInfo:(NSDictionary *)theMessageInfo {
- (BOOL)updateWithMessages:(NSArray *)theMessages messageInfo:(NSDictionary *)theMessageInfo {
BOOL newIncomingMessages = NO;
if (![[theMessageInfo objectForKey:MGMITime] isEqual:[messageInfo objectForKey:MGMITime]]) {
if (messageInfo!=nil) [messageInfo release];
messageInfo = [theMessageInfo mutableCopy];
BOOL read = [[messageInfo objectForKey:MGMIRead] boolValue];
[self setRead:read];
[self setRead:[[messageInfo objectForKey:MGMIRead] boolValue]];
BOOL rebuild = [[[[manager themeManager] variant] objectForKey:MGMTRebuild] boolValue];
BOOL newMessages = NO;
for (unsigned int i=[messages count]; i<[theMessages count]; i++) {
newMessages = YES;
[messages addObject:[theMessages objectAtIndex:i]];
if (![[[theMessages objectAtIndex:i] objectForKey:MGMIYou] boolValue])
newIncomingMessages = YES;
if (!rebuild)
[self addMessage:[messages lastObject]];
}
if (newMessages && rebuild)
[self buildHTML];
if (!read)
if (newIncomingMessages)
[self sendNotifications];
}
return newIncomingMessages;
}
- (void)updatedTheme:(NSNotification *)theNotification {