RemoteControl.m (56c26ecc) | RemoteControl.m (53e04a5d) |
---|---|
1/***************************************************************************** 2 * RemoteControl.m 3 * RemoteControlWrapper 4 * 5 * Created by Martin Kahr on 11.03.06 under a MIT-style license. 6 * Copyright (c) 2006 martinkahr.com. All rights reserved. 7 * 8 * Code modified and adapted to OpenOffice.org --- 37 unchanged lines hidden (view full) --- 46 47@implementation RemoteControl 48 49// returns nil if the remote control device is not available 50- (id) initWithDelegate: (id) _remoteControlDelegate { 51 if ( (self = [super init]) ) { 52 delegate = [_remoteControlDelegate retain]; 53#ifdef DEBUG | 1/***************************************************************************** 2 * RemoteControl.m 3 * RemoteControlWrapper 4 * 5 * Created by Martin Kahr on 11.03.06 under a MIT-style license. 6 * Copyright (c) 2006 martinkahr.com. All rights reserved. 7 * 8 * Code modified and adapted to OpenOffice.org --- 37 unchanged lines hidden (view full) --- 46 47@implementation RemoteControl 48 49// returns nil if the remote control device is not available 50- (id) initWithDelegate: (id) _remoteControlDelegate { 51 if ( (self = [super init]) ) { 52 delegate = [_remoteControlDelegate retain]; 53#ifdef DEBUG |
54 NSLog(@"RemoteControl initWithDelegate ok"); | 54 NSLog( @"Apple RemoteControl initWithDelegate ok"); |
55#endif 56 } 57 return self; 58} 59 60- (void) dealloc { 61 [delegate release]; 62 [super dealloc]; 63} 64 65- (void) setListeningToRemote: (BOOL) value { 66#ifdef DEBUG | 55#endif 56 } 57 return self; 58} 59 60- (void) dealloc { 61 [delegate release]; 62 [super dealloc]; 63} 64 65- (void) setListeningToRemote: (BOOL) value { 66#ifdef DEBUG |
67 NSLog(@"setListeningToRemote ok"); | 67 NSLog( @"Apple RemoteControl setListeningToRemote ok"); |
68#endif 69} 70- (BOOL) isListeningToRemote { 71 return NO; 72} 73 74- (void) startListening: (id) sender { 75#ifdef DEBUG | 68#endif 69} 70- (BOOL) isListeningToRemote { 71 return NO; 72} 73 74- (void) startListening: (id) sender { 75#ifdef DEBUG |
76 NSLog(@"startListening ok"); | 76 NSLog( @"Apple RemoteControl startListening ok"); |
77#endif 78} 79- (void) stopListening: (id) sender { 80#ifdef DEBUG | 77#endif 78} 79- (void) stopListening: (id) sender { 80#ifdef DEBUG |
81 NSLog(@"stopListening ok"); | 81 NSLog( @"Apple RemoteControl stopListening ok"); |
82#endif 83} 84 85- (BOOL) isOpenInExclusiveMode { 86 return YES; 87} 88- (void) setOpenInExclusiveMode: (BOOL) value { 89} 90 91- (BOOL) sendsEventForButtonIdentifier: (RemoteControlEventIdentifier) identifier { 92#ifdef DEBUG | 82#endif 83} 84 85- (BOOL) isOpenInExclusiveMode { 86 return YES; 87} 88- (void) setOpenInExclusiveMode: (BOOL) value { 89} 90 91- (BOOL) sendsEventForButtonIdentifier: (RemoteControlEventIdentifier) identifier { 92#ifdef DEBUG |
93 NSLog(@"sending event for button identifier \n"); | 93 NSLog( @"Apple RemoteControl: sending event for button identifier\n"); |
94#endif 95 return YES; 96} 97 98+ (void) sendDistributedNotification: (NSString*) notificationName targetBundleIdentifier: (NSString*) targetIdentifier 99{ 100 NSDictionary* userInfo = [NSDictionary dictionaryWithObjectsAndKeys: [NSString stringWithCString:[self remoteControlDeviceName] encoding:NSASCIIStringEncoding], 101 kRemoteControlDeviceName /* key = RemoteControlDeviceName -> OK */, 102 [[NSBundle mainBundle] bundleIdentifier] /* value = org.openoffice.script -> OK */, 103 kApplicationIdentifier/* key = CFBundleIdentifier -> OK */, 104 targetIdentifier /*value = AppleIRController -> OK */, 105 kTargetApplicationIdentifier /*targetBundleIdentifier -> does not appear, since the peer is nil*/, 106 nil]; 107#ifdef DEBUG | 94#endif 95 return YES; 96} 97 98+ (void) sendDistributedNotification: (NSString*) notificationName targetBundleIdentifier: (NSString*) targetIdentifier 99{ 100 NSDictionary* userInfo = [NSDictionary dictionaryWithObjectsAndKeys: [NSString stringWithCString:[self remoteControlDeviceName] encoding:NSASCIIStringEncoding], 101 kRemoteControlDeviceName /* key = RemoteControlDeviceName -> OK */, 102 [[NSBundle mainBundle] bundleIdentifier] /* value = org.openoffice.script -> OK */, 103 kApplicationIdentifier/* key = CFBundleIdentifier -> OK */, 104 targetIdentifier /*value = AppleIRController -> OK */, 105 kTargetApplicationIdentifier /*targetBundleIdentifier -> does not appear, since the peer is nil*/, 106 nil]; 107#ifdef DEBUG |
108 NSLog( @"Apple Remote: sendDistributedNotification ..."); |
|
108 // Debug purpose: returns all the existing dictionary keys. | 109 // Debug purpose: returns all the existing dictionary keys. |
109 NSString *s; 110 NSEnumerator *e = [userInfo keyEnumerator]; 111 while ( (s = [e nextObject]) ) { 112 NSLog(@"key = %@ ",s); | 110 NSEnumerator* itKey = [userInfo keyEnumerator]; 111 NSEnumerator* itVal = [userInfo objectEnumerator]; 112 for(;;) { 113 NSString* sKey = [itKey nextObject]; 114 NSString* sVal = [itVal nextObject]; 115 if( !sKey && !sVal) 116 break; 117 if( !sKey) sKey = @"nil"; 118 if( !sVal) sVal = @"nil"; 119 NSLog( @"\tARdict[\"%@\"] = \"%@\"",sKey,sVal); |
113 } | 120 } |
114 NSEnumerator *f = [userInfo objectEnumerator ]; 115 while ( (s = [f nextObject]) ) { 116 NSLog(@"value = %@ ",s); 117 } 118 NSLog(@"sendDistributedNotification ..."); | |
119#endif 120 121 [[NSDistributedNotificationCenter defaultCenter] postNotificationName:notificationName 122 object:nil 123 userInfo:userInfo 124 deliverImmediately:YES]; 125} 126 127+ (void) sendFinishedNotifcationForAppIdentifier: (NSString*) identifier { 128 [self sendDistributedNotification:FINISHED_USING_REMOTE_CONTROL_NOTIFICATION targetBundleIdentifier:identifier]; 129#ifdef DEBUG | 121#endif 122 123 [[NSDistributedNotificationCenter defaultCenter] postNotificationName:notificationName 124 object:nil 125 userInfo:userInfo 126 deliverImmediately:YES]; 127} 128 129+ (void) sendFinishedNotifcationForAppIdentifier: (NSString*) identifier { 130 [self sendDistributedNotification:FINISHED_USING_REMOTE_CONTROL_NOTIFICATION targetBundleIdentifier:identifier]; 131#ifdef DEBUG |
130 NSLog(@"sendFinishedNotifcationForAppIdentifier ..."); | 132 NSLog( @"Apple RemoteControl: sendFinishedNotifcationForAppIdentifier ..."); |
131#endif 132} 133+ (void) sendRequestForRemoteControlNotification { 134 [self sendDistributedNotification:REQUEST_FOR_REMOTE_CONTROL_NOTIFCATION targetBundleIdentifier:nil]; 135#ifdef DEBUG | 133#endif 134} 135+ (void) sendRequestForRemoteControlNotification { 136 [self sendDistributedNotification:REQUEST_FOR_REMOTE_CONTROL_NOTIFCATION targetBundleIdentifier:nil]; 137#ifdef DEBUG |
136 NSLog(@"sendRequestForRemoteControlNotification ..."); | 138 NSLog( @"Apple RemoteControl: sendRequestForRemoteControlNotification ..."); |
137#endif 138} 139 140+ (const char*) remoteControlDeviceName { 141 return NULL; 142} 143 144@end | 139#endif 140} 141 142+ (const char*) remoteControlDeviceName { 143 return NULL; 144} 145 146@end |