diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2019-02-20 14:01:08 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2019-02-21 09:14:14 +0100 |
commit | 6333dcf6f18c5d5a03e5daa267f89c06a528b698 (patch) | |
tree | e5d5246bd595e0a647b6cac436aba5d4f4351259 | |
parent | 07f24df0e8dbc035f2f9a24c12879848a1f318f1 (diff) |
loplugin:indentation (macOS)
* Some .m/.mm files that still contained tabs instead of spaces have been
cleaned up with Emacs' untabify (and
apple_remote/source/HIDRemoteControlDevice.m needed further manual adaptions):
apple_remote/source/GlobalKeyboardDevice.m
apple_remote/source/HIDRemoteControlDevice.m
apple_remote/source/KeyspanFrontRowControl.m
apple_remote/source/RemoteControl.m
vcl/osx/a11yrolehelper.mm
* Some of the changes predate 0626e66d761de18f62e4d00d427903032da9d517 "Avoid
loplugin:indentation after preproc conditional inclusion lines" and would
likely have no longer been flagged since.
Change-Id: Ibf5faffa743c7f79b36109d9879eb79d63c8c40f
Reviewed-on: https://gerrit.libreoffice.org/68090
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r-- | apple_remote/source/GlobalKeyboardDevice.m | 232 | ||||
-rw-r--r-- | apple_remote/source/HIDRemoteControlDevice.m | 658 | ||||
-rw-r--r-- | apple_remote/source/KeyspanFrontRowControl.m | 66 | ||||
-rw-r--r-- | apple_remote/source/RemoteControl.m | 6 | ||||
-rw-r--r-- | bridges/source/cpp_uno/gcc3_macosx_x86-64/uno2cpp.cxx | 4 | ||||
-rw-r--r-- | connectivity/source/drivers/macab/MacabResultSet.cxx | 16 | ||||
-rw-r--r-- | connectivity/source/drivers/macab/MacabTables.cxx | 2 | ||||
-rw-r--r-- | connectivity/source/drivers/odbc/OFunctions.cxx | 2 | ||||
-rw-r--r-- | lingucomponent/source/spellcheck/macosxspell/macspellimp.mm | 68 | ||||
-rw-r--r-- | sal/osl/unx/system.cxx | 12 | ||||
-rw-r--r-- | sd/source/ui/remotecontrol/OSXNetworkService.mm | 6 | ||||
-rw-r--r-- | tools/source/datetime/ttime.cxx | 4 | ||||
-rw-r--r-- | vcl/osx/DataFlavorMapping.cxx | 6 | ||||
-rw-r--r-- | vcl/osx/a11yrolehelper.mm | 10 | ||||
-rw-r--r-- | vcl/osx/a11ywrapper.mm | 2 | ||||
-rw-r--r-- | vcl/osx/salframeview.mm | 2 | ||||
-rw-r--r-- | vcl/source/outdev/text.cxx | 14 | ||||
-rw-r--r-- | vcl/source/window/winproc.cxx | 2 |
18 files changed, 556 insertions, 556 deletions
diff --git a/apple_remote/source/GlobalKeyboardDevice.m b/apple_remote/source/GlobalKeyboardDevice.m index c9e77097f9c1..cbd78f5b011c 100644 --- a/apple_remote/source/GlobalKeyboardDevice.m +++ b/apple_remote/source/GlobalKeyboardDevice.m @@ -64,166 +64,166 @@ static OSStatus hotKeyEventHandler(EventHandlerCallRef, EventRef, void*); @implementation GlobalKeyboardDevice - (id) initWithDelegate: (id) _remoteControlDelegate { - if ( (self = [super initWithDelegate: _remoteControlDelegate]) ) { - hotKeyRemoteEventMapping = [[NSMutableDictionary alloc] init]; - - unsigned int modifiers = cmdKey + shiftKey /*+ optionKey*/ + controlKey; - - [self mapRemoteButton:kRemoteButtonPlus defaultKeycode:F1 defaultModifiers:modifiers]; - [self mapRemoteButton:kRemoteButtonMinus defaultKeycode:F2 defaultModifiers:modifiers]; - [self mapRemoteButton:kRemoteButtonPlay defaultKeycode:F3 defaultModifiers:modifiers]; - [self mapRemoteButton:kRemoteButtonLeft defaultKeycode:F4 defaultModifiers:modifiers]; - [self mapRemoteButton:kRemoteButtonRight defaultKeycode:F5 defaultModifiers:modifiers]; - [self mapRemoteButton:kRemoteButtonMenu defaultKeycode:F6 defaultModifiers:modifiers]; - [self mapRemoteButton:kRemoteButtonPlay_Hold defaultKeycode:F7 defaultModifiers:modifiers]; - } - return self; + if ( (self = [super initWithDelegate: _remoteControlDelegate]) ) { + hotKeyRemoteEventMapping = [[NSMutableDictionary alloc] init]; + + unsigned int modifiers = cmdKey + shiftKey /*+ optionKey*/ + controlKey; + + [self mapRemoteButton:kRemoteButtonPlus defaultKeycode:F1 defaultModifiers:modifiers]; + [self mapRemoteButton:kRemoteButtonMinus defaultKeycode:F2 defaultModifiers:modifiers]; + [self mapRemoteButton:kRemoteButtonPlay defaultKeycode:F3 defaultModifiers:modifiers]; + [self mapRemoteButton:kRemoteButtonLeft defaultKeycode:F4 defaultModifiers:modifiers]; + [self mapRemoteButton:kRemoteButtonRight defaultKeycode:F5 defaultModifiers:modifiers]; + [self mapRemoteButton:kRemoteButtonMenu defaultKeycode:F6 defaultModifiers:modifiers]; + [self mapRemoteButton:kRemoteButtonPlay_Hold defaultKeycode:F7 defaultModifiers:modifiers]; + } + return self; } - (void) dealloc { - [hotKeyRemoteEventMapping release]; - [super dealloc]; + [hotKeyRemoteEventMapping release]; + [super dealloc]; } - (void) mapRemoteButton: (RemoteControlEventIdentifier) remoteButtonIdentifier defaultKeycode: (unsigned int) defaultKeycode defaultModifiers: (unsigned int) defaultModifiers { - NSString* defaultsKey = NULL; - - switch(remoteButtonIdentifier) { - case kRemoteButtonPlus: - defaultsKey = @"plus"; - break; - case kRemoteButtonMinus: - defaultsKey = @"minus"; - break; - case kRemoteButtonMenu: - defaultsKey = @"menu"; - break; - case kRemoteButtonPlay: - defaultsKey = @"play"; - break; - case kRemoteButtonRight: - defaultsKey = @"right"; - break; - case kRemoteButtonLeft: - defaultsKey = @"left"; - break; - case kRemoteButtonPlay_Hold: - defaultsKey = @"playhold"; - break; - default: + NSString* defaultsKey = NULL; + + switch(remoteButtonIdentifier) { + case kRemoteButtonPlus: + defaultsKey = @"plus"; + break; + case kRemoteButtonMinus: + defaultsKey = @"minus"; + break; + case kRemoteButtonMenu: + defaultsKey = @"menu"; + break; + case kRemoteButtonPlay: + defaultsKey = @"play"; + break; + case kRemoteButtonRight: + defaultsKey = @"right"; + break; + case kRemoteButtonLeft: + defaultsKey = @"left"; + break; + case kRemoteButtonPlay_Hold: + defaultsKey = @"playhold"; + break; + default: #ifdef DEBUG - NSLog( @"Apple Remote: Unknown global keyboard defaults key for button identifier %d", remoteButtonIdentifier); + NSLog( @"Apple Remote: Unknown global keyboard defaults key for button identifier %d", remoteButtonIdentifier); #endif break; - } + } - NSNumber* modifiersCfg = [[NSUserDefaults standardUserDefaults] objectForKey: [NSString stringWithFormat: @"mac.remotecontrols.GlobalKeyboardDevice.%@_modifiers", defaultsKey]]; - NSNumber* keycodeCfg = [[NSUserDefaults standardUserDefaults] objectForKey: [NSString stringWithFormat: @"mac.remotecontrols.GlobalKeyboardDevice.%@_keycode", defaultsKey]]; + NSNumber* modifiersCfg = [[NSUserDefaults standardUserDefaults] objectForKey: [NSString stringWithFormat: @"mac.remotecontrols.GlobalKeyboardDevice.%@_modifiers", defaultsKey]]; + NSNumber* keycodeCfg = [[NSUserDefaults standardUserDefaults] objectForKey: [NSString stringWithFormat: @"mac.remotecontrols.GlobalKeyboardDevice.%@_keycode", defaultsKey]]; - unsigned int modifiers = defaultModifiers; - if (modifiersCfg) modifiers = [modifiersCfg unsignedIntValue]; + unsigned int modifiers = defaultModifiers; + if (modifiersCfg) modifiers = [modifiersCfg unsignedIntValue]; - unsigned int keycode = defaultKeycode; - if (keycodeCfg) keycode = [keycodeCfg unsignedIntValue]; + unsigned int keycode = defaultKeycode; + if (keycodeCfg) keycode = [keycodeCfg unsignedIntValue]; [self registerHotKeyCode: keycode modifiers: modifiers remoteEventIdentifier: remoteButtonIdentifier]; } - (void) setListeningToRemote: (BOOL) value { - if (value == [self isListeningToRemote]) return; - if (value) { - [self startListening: self]; - } else { - [self stopListening: self]; - } + if (value == [self isListeningToRemote]) return; + if (value) { + [self startListening: self]; + } else { + [self stopListening: self]; + } } - (BOOL) isListeningToRemote { - return (eventHandlerRef!=NULL); + return (eventHandlerRef!=NULL); } - (void) startListening: (id) sender { - if (eventHandlerRef) return; + if (eventHandlerRef) return; - EventTypeSpec const eventSpec[2] = { - { kEventClassKeyboard, kEventHotKeyPressed }, - { kEventClassKeyboard, kEventHotKeyReleased } - }; + EventTypeSpec const eventSpec[2] = { + { kEventClassKeyboard, kEventHotKeyPressed }, + { kEventClassKeyboard, kEventHotKeyReleased } + }; - InstallEventHandler( GetEventDispatcherTarget(), - (EventHandlerProcPtr)hotKeyEventHandler, - 2, eventSpec, self, &eventHandlerRef); + InstallEventHandler( GetEventDispatcherTarget(), + (EventHandlerProcPtr)hotKeyEventHandler, + 2, eventSpec, self, &eventHandlerRef); (void)sender; } - (void) stopListening: (id) sender { - RemoveEventHandler(eventHandlerRef); - eventHandlerRef = NULL; + RemoveEventHandler(eventHandlerRef); + eventHandlerRef = NULL; (void)sender; } - (BOOL) sendsEventForButtonIdentifier: (RemoteControlEventIdentifier) identifier { - NSEnumerator* values = [hotKeyRemoteEventMapping objectEnumerator]; - NSNumber* remoteIdentifier; - while( (remoteIdentifier = [values nextObject]) ) { - if ([remoteIdentifier unsignedIntValue] == identifier) return YES; - } - return NO; + NSEnumerator* values = [hotKeyRemoteEventMapping objectEnumerator]; + NSNumber* remoteIdentifier; + while( (remoteIdentifier = [values nextObject]) ) { + if ([remoteIdentifier unsignedIntValue] == identifier) return YES; + } + return NO; } + (const char*) remoteControlDeviceName { - return "Keyboard"; + return "Keyboard"; } - (BOOL)registerHotKeyCode: (unsigned int) keycode modifiers: (unsigned int) modifiers remoteEventIdentifier: (RemoteControlEventIdentifier) identifier { - OSStatus err; - EventHotKeyID hotKeyID; - EventHotKeyRef carbonHotKey; + OSStatus err; + EventHotKeyID hotKeyID; + EventHotKeyRef carbonHotKey; - hotKeyID.signature = 'PTHk'; - hotKeyID.id = (long)keycode; + hotKeyID.signature = 'PTHk'; + hotKeyID.id = (long)keycode; - err = RegisterEventHotKey(keycode, modifiers, hotKeyID, GetEventDispatcherTarget(), 0, &carbonHotKey ); + err = RegisterEventHotKey(keycode, modifiers, hotKeyID, GetEventDispatcherTarget(), 0, &carbonHotKey ); - if( err ) - return NO; + if( err ) + return NO; - [hotKeyRemoteEventMapping setObject: [NSNumber numberWithInt:identifier] forKey: [NSNumber numberWithUnsignedInt: hotKeyID.id]]; + [hotKeyRemoteEventMapping setObject: [NSNumber numberWithInt:identifier] forKey: [NSNumber numberWithUnsignedInt: hotKeyID.id]]; - return YES; + return YES; } /* - (void)unregisterHotKey: (PTHotKey*)hotKey { - OSStatus err; - EventHotKeyRef carbonHotKey; - NSValue* key; + OSStatus err; + EventHotKeyRef carbonHotKey; + NSValue* key; - if( [[self allHotKeys] containsObject: hotKey] == NO ) - return; + if( [[self allHotKeys] containsObject: hotKey] == NO ) + return; - carbonHotKey = [self _carbonHotKeyForHotKey: hotKey]; - NSAssert( carbonHotKey != nil, @"" ); + carbonHotKey = [self _carbonHotKeyForHotKey: hotKey]; + NSAssert( carbonHotKey != nil, @"" ); - err = UnregisterEventHotKey( carbonHotKey ); - //Watch as we ignore 'err': + err = UnregisterEventHotKey( carbonHotKey ); + //Watch as we ignore 'err': - key = [NSValue valueWithPointer: carbonHotKey]; - [mHotKeys removeObjectForKey: key]; + key = [NSValue valueWithPointer: carbonHotKey]; + [mHotKeys removeObjectForKey: key]; - [self _updateEventHandler]; + [self _updateEventHandler]; - //See that? Completely ignored + //See that? Completely ignored } */ - (RemoteControlEventIdentifier) remoteControlEventIdentifierForID: (unsigned int) id { - NSNumber* remoteEventIdentifier = [hotKeyRemoteEventMapping objectForKey:[NSNumber numberWithUnsignedInt: id]]; - return [remoteEventIdentifier unsignedIntValue]; + NSNumber* remoteEventIdentifier = [hotKeyRemoteEventMapping objectForKey:[NSNumber numberWithUnsignedInt: id]]; + return [remoteEventIdentifier unsignedIntValue]; } - (void) sendRemoteButtonEvent: (RemoteControlEventIdentifier) event pressedDown: (BOOL) pressedDown { - [delegate sendRemoteButtonEvent: event pressedDown: pressedDown remoteControl:self]; + [delegate sendRemoteButtonEvent: event pressedDown: pressedDown remoteControl:self]; } static RemoteControlEventIdentifier lastEvent; @@ -232,23 +232,23 @@ static RemoteControlEventIdentifier lastEvent; static OSStatus hotKeyEventHandler(EventHandlerCallRef inHandlerRef, EventRef inEvent, void* userData ) { (void)inHandlerRef; - GlobalKeyboardDevice* keyboardDevice = (GlobalKeyboardDevice*) userData; - EventHotKeyID hkCom; - GetEventParameter(inEvent,kEventParamDirectObject,typeEventHotKeyID,NULL,sizeof(hkCom),NULL,&hkCom); - - RemoteControlEventIdentifier identifier = [keyboardDevice remoteControlEventIdentifierForID:hkCom.id]; - if (identifier == 0) return noErr; - - BOOL pressedDown = YES; - if (identifier != lastEvent) { - lastEvent = identifier; - } else { - lastEvent = 0; - pressedDown = NO; - } - [keyboardDevice sendRemoteButtonEvent: identifier pressedDown: pressedDown]; - - return noErr; + GlobalKeyboardDevice* keyboardDevice = (GlobalKeyboardDevice*) userData; + EventHotKeyID hkCom; + GetEventParameter(inEvent,kEventParamDirectObject,typeEventHotKeyID,NULL,sizeof(hkCom),NULL,&hkCom); + + RemoteControlEventIdentifier identifier = [keyboardDevice remoteControlEventIdentifierForID:hkCom.id]; + if (identifier == 0) return noErr; + + BOOL pressedDown = YES; + if (identifier != lastEvent) { + lastEvent = identifier; + } else { + lastEvent = 0; + pressedDown = NO; + } + [keyboardDevice sendRemoteButtonEvent: identifier pressedDown: pressedDown]; + + return noErr; } @end diff --git a/apple_remote/source/HIDRemoteControlDevice.m b/apple_remote/source/HIDRemoteControlDevice.m index d7aaeaecb4e7..58f936d180cb 100644 --- a/apple_remote/source/HIDRemoteControlDevice.m +++ b/apple_remote/source/HIDRemoteControlDevice.m @@ -58,52 +58,52 @@ @implementation HIDRemoteControlDevice + (const char*) remoteControlDeviceName { - return ""; + return ""; } + (BOOL) isRemoteAvailable { - io_object_t hidDevice = [self findRemoteDevice]; - if (hidDevice != 0) { - IOObjectRelease(hidDevice); - return YES; - } else { - return NO; - } + io_object_t hidDevice = [self findRemoteDevice]; + if (hidDevice != 0) { + IOObjectRelease(hidDevice); + return YES; + } else { + return NO; + } } - (id) initWithDelegate: (id) _remoteControlDelegate { - if ([[self class] isRemoteAvailable] == NO) return nil; + if ([[self class] isRemoteAvailable] == NO) return nil; - if ( (self = [super initWithDelegate: _remoteControlDelegate]) ) { - openInExclusiveMode = YES; - queue = NULL; - hidDeviceInterface = NULL; - cookieToButtonMapping = [[NSMutableDictionary alloc] init]; + if ( (self = [super initWithDelegate: _remoteControlDelegate]) ) { + openInExclusiveMode = YES; + queue = NULL; + hidDeviceInterface = NULL; + cookieToButtonMapping = [[NSMutableDictionary alloc] init]; - [self setCookieMappingInDictionary: cookieToButtonMapping]; + [self setCookieMappingInDictionary: cookieToButtonMapping]; - NSEnumerator* enumerator = [cookieToButtonMapping objectEnumerator]; - NSNumber* identifier; - supportedButtonEvents = 0; - while( (identifier = [enumerator nextObject]) ) { - supportedButtonEvents |= [identifier intValue]; - } + NSEnumerator* enumerator = [cookieToButtonMapping objectEnumerator]; + NSNumber* identifier; + supportedButtonEvents = 0; + while( (identifier = [enumerator nextObject]) ) { + supportedButtonEvents |= [identifier intValue]; + } - fixSecureEventInputBug = [[NSUserDefaults standardUserDefaults] boolForKey: @"remoteControlWrapperFixSecureEventInputBug"]; - } + fixSecureEventInputBug = [[NSUserDefaults standardUserDefaults] boolForKey: @"remoteControlWrapperFixSecureEventInputBug"]; + } - return self; + return self; } - (void) dealloc { - [self removeNotificationObserver]; - [self stopListening:self]; - [cookieToButtonMapping release]; - [super dealloc]; + [self removeNotificationObserver]; + [self stopListening:self]; + [cookieToButtonMapping release]; + [super dealloc]; } - (void) sendRemoteButtonEvent: (RemoteControlEventIdentifier) event pressedDown: (BOOL) pressedDown { - [delegate sendRemoteButtonEvent: event pressedDown: pressedDown remoteControl:self]; + [delegate sendRemoteButtonEvent: event pressedDown: pressedDown remoteControl:self]; } - (void) setCookieMappingInDictionary: (NSMutableDictionary*) cookieToButtonMap { @@ -111,140 +111,140 @@ } - (int) remoteIdSwitchCookie { - return 0; + return 0; } - (BOOL) sendsEventForButtonIdentifier: (RemoteControlEventIdentifier) identifier { - return (supportedButtonEvents & identifier) == identifier; + return (supportedButtonEvents & identifier) == identifier; } - (BOOL) isListeningToRemote { - return (hidDeviceInterface != NULL && allCookies != NULL && queue != NULL); + return (hidDeviceInterface != NULL && allCookies != NULL && queue != NULL); } - (void) setListeningToRemote: (BOOL) value { - if (value == NO) { - [self stopListening:self]; - } else { - [self startListening:self]; - } + if (value == NO) { + [self stopListening:self]; + } else { + [self startListening:self]; + } } - (BOOL) isOpenInExclusiveMode { - return openInExclusiveMode; + return openInExclusiveMode; } - (void) setOpenInExclusiveMode: (BOOL) value { - openInExclusiveMode = value; + openInExclusiveMode = value; } - (BOOL) processesBacklog { - return processesBacklog; + return processesBacklog; } - (void) setProcessesBacklog: (BOOL) value { - processesBacklog = value; + processesBacklog = value; } - (void) startListening: (id) sender { (void)sender; - if ([self isListeningToRemote]) return; + if ([self isListeningToRemote]) return; - // 4th July 2007 + // 4th July 2007 - // A security update in february of 2007 introduced an odd behavior. - // Whenever SecureEventInput is activated or deactivated the exclusive access - // to the remote control device is lost. This leads to very strange behavior where - // a press on the Menu button activates FrontRow while your app still gets the event. - // A great number of people have complained about this. + // A security update in february of 2007 introduced an odd behavior. + // Whenever SecureEventInput is activated or deactivated the exclusive access + // to the remote control device is lost. This leads to very strange behavior where + // a press on the Menu button activates FrontRow while your app still gets the event. + // A great number of people have complained about this. - // Enabling the SecureEventInput and keeping it enabled does the trick. + // Enabling the SecureEventInput and keeping it enabled does the trick. - // I'm pretty sure this is a kind of bug at Apple and I'm in contact with the responsible - // Apple Engineer. This solution is not a perfect one - I know. - // One of the side effects is that applications that listen for special global keyboard shortcuts (like Quicksilver) - // may get into problems as they no longer get the events. - // As there is no official Apple Remote API from Apple I also failed to open a technical incident on this. + // I'm pretty sure this is a kind of bug at Apple and I'm in contact with the responsible + // Apple Engineer. This solution is not a perfect one - I know. + // One of the side effects is that applications that listen for special global keyboard shortcuts (like Quicksilver) + // may get into problems as they no longer get the events. + // As there is no official Apple Remote API from Apple I also failed to open a technical incident on this. - // Note that there is a corresponding DisableSecureEventInput in the stopListening method below. + // Note that there is a corresponding DisableSecureEventInput in the stopListening method below. - if ([self isOpenInExclusiveMode] && fixSecureEventInputBug) EnableSecureEventInput(); + if ([self isOpenInExclusiveMode] && fixSecureEventInputBug) EnableSecureEventInput(); - [self removeNotificationObserver]; + [self removeNotificationObserver]; - io_object_t hidDevice = [[self class] findRemoteDevice]; - if (hidDevice == 0) return; + io_object_t hidDevice = [[self class] findRemoteDevice]; + if (hidDevice == 0) return; - if ([self createInterfaceForDevice:hidDevice] == NULL) { - goto error; - } + if ([self createInterfaceForDevice:hidDevice] == NULL) { + goto error; + } - if ([self initializeCookies]==NO) { - goto error; - } + if ([self initializeCookies]==NO) { + goto error; + } - if ([self openDevice]==NO) { - goto error; - } - // be KVO friendly - [self willChangeValueForKey:@"listeningToRemote"]; - [self didChangeValueForKey:@"listeningToRemote"]; - goto cleanup; + if ([self openDevice]==NO) { + goto error; + } + // be KVO friendly + [self willChangeValueForKey:@"listeningToRemote"]; + [self didChangeValueForKey:@"listeningToRemote"]; + goto cleanup; error: - [self stopListening:self]; - DisableSecureEventInput(); + [self stopListening:self]; + DisableSecureEventInput(); cleanup: - IOObjectRelease(hidDevice); + IOObjectRelease(hidDevice); } - (void) stopListening: (id) sender { (void)sender; - if ([self isListeningToRemote]==NO) return; + if ([self isListeningToRemote]==NO) return; - BOOL sendNotification = NO; + BOOL sendNotification = NO; - if (eventSource != NULL) { - CFRunLoopRemoveSource(CFRunLoopGetCurrent(), eventSource, kCFRunLoopDefaultMode); - CFRelease(eventSource); - eventSource = NULL; - } - if (queue != NULL) { - (*queue)->stop(queue); + if (eventSource != NULL) { + CFRunLoopRemoveSource(CFRunLoopGetCurrent(), eventSource, kCFRunLoopDefaultMode); + CFRelease(eventSource); + eventSource = NULL; + } + if (queue != NULL) { + (*queue)->stop(queue); - //dispose of queue - (*queue)->dispose(queue); + //dispose of queue + (*queue)->dispose(queue); - //release the queue we allocated - (*queue)->Release(queue); + //release the queue we allocated + (*queue)->Release(queue); - queue = NULL; + queue = NULL; - sendNotification = YES; - } + sendNotification = YES; + } - if (allCookies != nil) { - [allCookies autorelease]; - allCookies = nil; - } + if (allCookies != nil) { + [allCookies autorelease]; + allCookies = nil; + } - if (hidDeviceInterface != NULL) { - //close the device - (*hidDeviceInterface)->close(hidDeviceInterface); + if (hidDeviceInterface != NULL) { + //close the device + (*hidDeviceInterface)->close(hidDeviceInterface); - //release the interface - (*hidDeviceInterface)->Release(hidDeviceInterface); + //release the interface + (*hidDeviceInterface)->Release(hidDeviceInterface); - hidDeviceInterface = NULL; - } + hidDeviceInterface = NULL; + } - if ([self isOpenInExclusiveMode] && fixSecureEventInputBug) DisableSecureEventInput(); + if ([self isOpenInExclusiveMode] && fixSecureEventInputBug) DisableSecureEventInput(); - if ([self isOpenInExclusiveMode] && sendNotification) { - [[self class] sendFinishedNotificationForAppIdentifier: nil]; - } - // be KVO friendly - [self willChangeValueForKey:@"listeningToRemote"]; - [self didChangeValueForKey:@"listeningToRemote"]; + if ([self isOpenInExclusiveMode] && sendNotification) { + [[self class] sendFinishedNotificationForAppIdentifier: nil]; + } + // be KVO friendly + [self willChangeValueForKey:@"listeningToRemote"]; + [self didChangeValueForKey:@"listeningToRemote"]; } @end @@ -252,40 +252,40 @@ cleanup: @implementation HIDRemoteControlDevice (PrivateMethods) - (IOHIDQueueInterface**) queue { - return queue; + return queue; } - (IOHIDDeviceInterface**) hidDeviceInterface { - return hidDeviceInterface; + return hidDeviceInterface; } - (NSDictionary*) cookieToButtonMapping { - return cookieToButtonMapping; + return cookieToButtonMapping; } - (NSString*) validCookieSubstring: (NSString*) cookieString { - if (cookieString == nil || [cookieString length] == 0) return nil; - NSEnumerator* keyEnum = [[self cookieToButtonMapping] keyEnumerator]; - NSString* key; - while( (key = [keyEnum nextObject]) ) { - NSRange range = [cookieString rangeOfString:key]; - if (range.location == 0) return key; - } - return nil; + if (cookieString == nil || [cookieString length] == 0) return nil; + NSEnumerator* keyEnum = [[self cookieToButtonMapping] keyEnumerator]; + NSString* key; + while( (key = [keyEnum nextObject]) ) { + NSRange range = [cookieString rangeOfString:key]; + if (range.location == 0) return key; + } + return nil; } - (void) handleEventWithCookieString: (NSString*) cookieString sumOfValues: (SInt32) sumOfValues { - /* - if (previousRemainingCookieString) { - cookieString = [previousRemainingCookieString stringByAppendingString: cookieString]; - NSLog( @"Apple Remote: New cookie string is %@", cookieString); - [previousRemainingCookieString release], previousRemainingCookieString=nil; - }*/ - if (cookieString == nil || [cookieString length] == 0) return; - - NSNumber* buttonId = [[self cookieToButtonMapping] objectForKey: cookieString]; - if (buttonId != nil) { + /* + if (previousRemainingCookieString) { + cookieString = [previousRemainingCookieString stringByAppendingString: cookieString]; + NSLog( @"Apple Remote: New cookie string is %@", cookieString); + [previousRemainingCookieString release], previousRemainingCookieString=nil; + }*/ + if (cookieString == nil || [cookieString length] == 0) return; + + NSNumber* buttonId = [[self cookieToButtonMapping] objectForKey: cookieString]; + if (buttonId != nil) { switch ( (int)buttonId ) { case kMetallicRemote2009ButtonPlay: @@ -297,240 +297,240 @@ cleanup: } [self sendRemoteButtonEvent: [buttonId intValue] pressedDown: (sumOfValues>0)]; - } else { - // let's see if a number of events are stored in the cookie string. this does - // happen when the main thread is too busy to handle all incoming events in time. - NSString* subCookieString; - NSString* lastSubCookieString=nil; - while( (subCookieString = [self validCookieSubstring: cookieString]) ) { - cookieString = [cookieString substringFromIndex: [subCookieString length]]; - lastSubCookieString = subCookieString; - if (processesBacklog) [self handleEventWithCookieString: subCookieString sumOfValues:sumOfValues]; - } - if (processesBacklog == NO && lastSubCookieString != nil) { - // process the last event of the backlog and assume that the button is not pressed down any longer. - // The events in the backlog do not seem to be in order and therefore (in rare cases) the last event might be - // a button pressed down event while in reality the user has released it. - // NSLog(@"processing last event of backlog"); - [self handleEventWithCookieString: lastSubCookieString sumOfValues:0]; - } - if ([cookieString length] > 0) { - NSLog( @"Apple Remote: Unknown button for cookiestring %@", cookieString); - } - } + } else { + // let's see if a number of events are stored in the cookie string. this does + // happen when the main thread is too busy to handle all incoming events in time. + NSString* subCookieString; + NSString* lastSubCookieString=nil; + while( (subCookieString = [self validCookieSubstring: cookieString]) ) { + cookieString = [cookieString substringFromIndex: [subCookieString length]]; + lastSubCookieString = subCookieString; + if (processesBacklog) [self handleEventWithCookieString: subCookieString sumOfValues:sumOfValues]; + } + if (processesBacklog == NO && lastSubCookieString != nil) { + // process the last event of the backlog and assume that the button is not pressed down any longer. + // The events in the backlog do not seem to be in order and therefore (in rare cases) the last event might be + // a button pressed down event while in reality the user has released it. + // NSLog(@"processing last event of backlog"); + [self handleEventWithCookieString: lastSubCookieString sumOfValues:0]; + } + if ([cookieString length] > 0) { + NSLog( @"Apple Remote: Unknown button for cookiestring %@", cookieString); + } + } } - (void) removeNotificationObserver { - [[NSDistributedNotificationCenter defaultCenter] removeObserver:self name:FINISHED_USING_REMOTE_CONTROL_NOTIFICATION object:nil]; + [[NSDistributedNotificationCenter defaultCenter] removeObserver:self name:FINISHED_USING_REMOTE_CONTROL_NOTIFICATION object:nil]; } - (void) remoteControlAvailable:(NSNotification *)notification { (void)notification; - [self removeNotificationObserver]; - [self startListening: self]; + [self removeNotificationObserver]; + [self startListening: self]; } @end -/* Callback method for the device queue +/* Callback method for the device queue Will be called for any event of any type (cookie) to which we subscribe */ static void QueueCallbackFunction(void* target, IOReturn result, void* refcon, void* sender) { (void)refcon; (void)sender; - if ((intptr_t)target < 0) { - NSLog( @"Apple Remote: QueueCallbackFunction called with invalid target!"); - return; - } - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - - HIDRemoteControlDevice* remote = (HIDRemoteControlDevice*)target; - IOHIDEventStruct event; - AbsoluteTime const zeroTime = {0,0}; - NSMutableString* cookieString = [NSMutableString string]; - SInt32 sumOfValues = 0; - while (result == kIOReturnSuccess) - { - result = (*[remote queue])->getNextEvent([remote queue], &event, zeroTime, 0); - if ( result != kIOReturnSuccess ) - continue; - - //printf("%d %d %d\n", event.elementCookie, event.value, event.longValue); - - if (((int)event.elementCookie)!=5) { - sumOfValues+=event.value; - [cookieString appendString:[NSString stringWithFormat:@"%lld_", (long long) (intptr_t) event.elementCookie]]; - } - } - [remote handleEventWithCookieString: cookieString sumOfValues: sumOfValues]; - - [pool release]; + if ((intptr_t)target < 0) { + NSLog( @"Apple Remote: QueueCallbackFunction called with invalid target!"); + return; + } + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + + HIDRemoteControlDevice* remote = (HIDRemoteControlDevice*)target; + IOHIDEventStruct event; + AbsoluteTime const zeroTime = {0,0}; + NSMutableString* cookieString = [NSMutableString string]; + SInt32 sumOfValues = 0; + while (result == kIOReturnSuccess) + { + result = (*[remote queue])->getNextEvent([remote queue], &event, zeroTime, 0); + if ( result != kIOReturnSuccess ) + continue; + + //printf("%d %d %d\n", event.elementCookie, event.value, event.longValue); + + if (((int)event.elementCookie)!=5) { + sumOfValues+=event.value; + [cookieString appendString:[NSString stringWithFormat:@"%lld_", (long long) (intptr_t) event.elementCookie]]; + } + } + [remote handleEventWithCookieString: cookieString sumOfValues: sumOfValues]; + + [pool release]; } @implementation HIDRemoteControlDevice (IOKitMethods) - (IOHIDDeviceInterface**) createInterfaceForDevice: (io_object_t) hidDevice { - io_name_t className; - IOCFPlugInInterface** plugInInterface = NULL; - HRESULT plugInResult = S_OK; - SInt32 score = 0; - IOReturn ioReturnValue = kIOReturnSuccess; - - hidDeviceInterface = NULL; - - ioReturnValue = IOObjectGetClass(hidDevice, className); - - if (ioReturnValue != kIOReturnSuccess) { - NSLog( @"Apple Remote: Error: Failed to get RemoteControlDevice class name."); - return NULL; - } - - ioReturnValue = IOCreatePlugInInterfaceForService(hidDevice, - kIOHIDDeviceUserClientTypeID, - kIOCFPlugInInterfaceID, - &plugInInterface, - &score); - if (ioReturnValue == kIOReturnSuccess) - { - //Call a method of the intermediate plug-in to create the device interface - plugInResult = (*plugInInterface)->QueryInterface(plugInInterface, CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID), (LPVOID) &hidDeviceInterface); - - if (plugInResult != S_OK) { - NSLog( @"Apple Remote: Error: Couldn't create HID class device interface"); - } - // Release - if (plugInInterface) (*plugInInterface)->Release(plugInInterface); - } - return hidDeviceInterface; + io_name_t className; + IOCFPlugInInterface** plugInInterface = NULL; + HRESULT plugInResult = S_OK; + SInt32 score = 0; + IOReturn ioReturnValue = kIOReturnSuccess; + + hidDeviceInterface = NULL; + + ioReturnValue = IOObjectGetClass(hidDevice, className); + + if (ioReturnValue != kIOReturnSuccess) { + NSLog( @"Apple Remote: Error: Failed to get RemoteControlDevice class name."); + return NULL; + } + + ioReturnValue = IOCreatePlugInInterfaceForService(hidDevice, + kIOHIDDeviceUserClientTypeID, + kIOCFPlugInInterfaceID, + &plugInInterface, + &score); + if (ioReturnValue == kIOReturnSuccess) + { + //Call a method of the intermediate plug-in to create the device interface + plugInResult = (*plugInInterface)->QueryInterface(plugInInterface, CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID), (LPVOID) &hidDeviceInterface); + + if (plugInResult != S_OK) { + NSLog( @"Apple Remote: Error: Couldn't create HID class device interface"); + } + // Release + if (plugInInterface) (*plugInInterface)->Release(plugInInterface); + } + return hidDeviceInterface; } - (BOOL) initializeCookies { - IOHIDDeviceInterface122** handle = (IOHIDDeviceInterface122**)hidDeviceInterface; - IOHIDElementCookie cookie; - long usage; - long usagePage; - id object; - NSArray* elements = nil; - NSDictionary* element; - IOReturn success; - - if (!handle || !(*handle)) return NO; - - // Copy all elements, since we're grabbing most of the elements - // for this device anyway, and thus, it's faster to iterate them - // ourselves. When grabbing only one or two elements, a matching - // dictionary should be passed in here instead of NULL. - success = (*handle)->copyMatchingElements(handle, NULL, (CFArrayRef*)&elements); - - if (success == kIOReturnSuccess) { - - /* - cookies = calloc(NUMBER_OF_APPLE_REMOTE_ACTIONS, sizeof(IOHIDElementCookie)); - memset(cookies, 0, sizeof(IOHIDElementCookie) * NUMBER_OF_APPLE_REMOTE_ACTIONS); - */ - allCookies = [[NSMutableArray alloc] init]; - - NSEnumerator *elementsEnumerator = [elements objectEnumerator]; - - while ( (element = [elementsEnumerator nextObject]) ) { - //Get cookie - object = [element valueForKey: (NSString*)CFSTR(kIOHIDElementCookieKey) ]; - if (object == nil || ![object isKindOfClass:[NSNumber class]]) continue; - if (object == NULL || CFGetTypeID(object) != CFNumberGetTypeID()) continue; - cookie = (IOHIDElementCookie) [object longValue]; - - //Get usage - object = [element valueForKey: (NSString*)CFSTR(kIOHIDElementUsageKey) ]; - if (object == nil || ![object isKindOfClass:[NSNumber class]]) continue; - usage = [object longValue]; - - //Get usage page - object = [element valueForKey: (NSString*)CFSTR(kIOHIDElementUsagePageKey) ]; - if (object == nil || ![object isKindOfClass:[NSNumber class]]) continue; - usagePage = [object longValue]; - - [allCookies addObject: [NSNumber numberWithInt:(int)cookie]]; - } - CFRelease(elements); - elements=nil; - } else { - return NO; - } - - return YES; + IOHIDDeviceInterface122** handle = (IOHIDDeviceInterface122**)hidDeviceInterface; + IOHIDElementCookie cookie; + long usage; + long usagePage; + id object; + NSArray* elements = nil; + NSDictionary* element; + IOReturn success; + + if (!handle || !(*handle)) return NO; + + // Copy all elements, since we're grabbing most of the elements + // for this device anyway, and thus, it's faster to iterate them + // ourselves. When grabbing only one or two elements, a matching + // dictionary should be passed in here instead of NULL. + success = (*handle)->copyMatchingElements(handle, NULL, (CFArrayRef*)&elements); + + if (success == kIOReturnSuccess) { + + /* + cookies = calloc(NUMBER_OF_APPLE_REMOTE_ACTIONS, sizeof(IOHIDElementCookie)); + memset(cookies, 0, sizeof(IOHIDElementCookie) * NUMBER_OF_APPLE_REMOTE_ACTIONS); + */ + allCookies = [[NSMutableArray alloc] init]; + + NSEnumerator *elementsEnumerator = [elements objectEnumerator]; + + while ( (element = [elementsEnumerator nextObject]) ) { + //Get cookie + object = [element valueForKey: (NSString*)CFSTR(kIOHIDElementCookieKey) ]; + if (object == nil || ![object isKindOfClass:[NSNumber class]]) continue; + if (object == NULL || CFGetTypeID(object) != CFNumberGetTypeID()) continue; + cookie = (IOHIDElementCookie) [object longValue]; + + //Get usage + object = [element valueForKey: (NSString*)CFSTR(kIOHIDElementUsageKey) ]; + if (object == nil || ![object isKindOfClass:[NSNumber class]]) continue; + usage = [object longValue]; + + //Get usage page + object = [element valueForKey: (NSString*)CFSTR(kIOHIDElementUsagePageKey) ]; + if (object == nil || ![object isKindOfClass:[NSNumber class]]) continue; + usagePage = [object longValue]; + + [allCookies addObject: [NSNumber numberWithInt:(int)cookie]]; + } + CFRelease(elements); + elements=nil; + } else { + return NO; + } + + return YES; } - (BOOL) openDevice { - HRESULT result; - - IOHIDOptionsType openMode = kIOHIDOptionsTypeNone; - if ([self isOpenInExclusiveMode]) openMode = kIOHIDOptionsTypeSeizeDevice; - IOReturn ioReturnValue = (*hidDeviceInterface)->open(hidDeviceInterface, openMode); - - if (ioReturnValue == KERN_SUCCESS) { - queue = (*hidDeviceInterface)->allocQueue(hidDeviceInterface); - if (queue) { - result = (*queue)->create(queue, 0, 12); //depth: maximum number of elements in queue before oldest elements in queue begin to be lost. - - IOHIDElementCookie cookie; - NSEnumerator *allCookiesEnumerator = [allCookies objectEnumerator]; - - while ( (cookie = (IOHIDElementCookie)[[allCookiesEnumerator nextObject] intValue]) ) { - (*queue)->addElement(queue, cookie, 0); - } - - // add callback for async events - ioReturnValue = (*queue)->createAsyncEventSource(queue, &eventSource); - if (ioReturnValue == KERN_SUCCESS) { - ioReturnValue = (*queue)->setEventCallout(queue,QueueCallbackFunction, self, NULL); - if (ioReturnValue == KERN_SUCCESS) { - CFRunLoopAddSource(CFRunLoopGetCurrent(), eventSource, kCFRunLoopDefaultMode); - - //start data delivery to queue - (*queue)->start(queue); - return YES; - } else { - NSLog( @"Apple Remote: Error when setting event callback"); - } - } else { - NSLog( @"Apple Remote: Error when creating async event source"); - } - } else { - NSLog( @"Apple Remote: Error when opening device"); - } - } else if (ioReturnValue == kIOReturnExclusiveAccess) { - // the device is used exclusive by another application - - // 1. we register for the FINISHED_USING_REMOTE_CONTROL_NOTIFICATION notification - [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(remoteControlAvailable:) name:FINISHED_USING_REMOTE_CONTROL_NOTIFICATION object:nil]; - - // 2. send a distributed notification that we wanted to use the remote control - [[self class] sendRequestForRemoteControlNotification]; - } - return NO; + HRESULT result; + + IOHIDOptionsType openMode = kIOHIDOptionsTypeNone; + if ([self isOpenInExclusiveMode]) openMode = kIOHIDOptionsTypeSeizeDevice; + IOReturn ioReturnValue = (*hidDeviceInterface)->open(hidDeviceInterface, openMode); + + if (ioReturnValue == KERN_SUCCESS) { + queue = (*hidDeviceInterface)->allocQueue(hidDeviceInterface); + if (queue) { + result = (*queue)->create(queue, 0, 12); //depth: maximum number of elements in queue before oldest elements in queue begin to be lost. + + IOHIDElementCookie cookie; + NSEnumerator *allCookiesEnumerator = [allCookies objectEnumerator]; + + while ( (cookie = (IOHIDElementCookie)[[allCookiesEnumerator nextObject] intValue]) ) { + (*queue)->addElement(queue, cookie, 0); + } + + // add callback for async events + ioReturnValue = (*queue)->createAsyncEventSource(queue, &eventSource); + if (ioReturnValue == KERN_SUCCESS) { + ioReturnValue = (*queue)->setEventCallout(queue,QueueCallbackFunction, self, NULL); + if (ioReturnValue == KERN_SUCCESS) { + CFRunLoopAddSource(CFRunLoopGetCurrent(), eventSource, kCFRunLoopDefaultMode); + + //start data delivery to queue + (*queue)->start(queue); + return YES; + } else { + NSLog( @"Apple Remote: Error when setting event callback"); + } + } else { + NSLog( @"Apple Remote: Error when creating async event source"); + } + } else { + NSLog( @"Apple Remote: Error when opening device"); + } + } else if (ioReturnValue == kIOReturnExclusiveAccess) { + // the device is used exclusive by another application + + // 1. we register for the FINISHED_USING_REMOTE_CONTROL_NOTIFICATION notification + [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(remoteControlAvailable:) name:FINISHED_USING_REMOTE_CONTROL_NOTIFICATION object:nil]; + + // 2. send a distributed notification that we wanted to use the remote control + [[self class] sendRequestForRemoteControlNotification]; + } + return NO; } + (io_object_t) findRemoteDevice { - CFMutableDictionaryRef hidMatchDictionary = NULL; - IOReturn ioReturnValue = kIOReturnSuccess; - io_iterator_t hidObjectIterator = 0; - io_object_t hidDevice = 0; + CFMutableDictionaryRef hidMatchDictionary = NULL; + IOReturn ioReturnValue = kIOReturnSuccess; + io_iterator_t hidObjectIterator = 0; + io_object_t hidDevice = 0; - // Set up a matching dictionary to search the I/O Registry by class - // name for all HID class devices - hidMatchDictionary = IOServiceMatching([self remoteControlDeviceName]); + // Set up a matching dictionary to search the I/O Registry by class + // name for all HID class devices + hidMatchDictionary = IOServiceMatching([self remoteControlDeviceName]); - // Now search I/O Registry for matching devices. - ioReturnValue = IOServiceGetMatchingServices(kIOMasterPortDefault, hidMatchDictionary, &hidObjectIterator); + // Now search I/O Registry for matching devices. + ioReturnValue = IOServiceGetMatchingServices(kIOMasterPortDefault, hidMatchDictionary, &hidObjectIterator); - if ((ioReturnValue == kIOReturnSuccess) && (hidObjectIterator != 0)) { - hidDevice = IOIteratorNext(hidObjectIterator); - } + if ((ioReturnValue == kIOReturnSuccess) && (hidObjectIterator != 0)) { + hidDevice = IOIteratorNext(hidObjectIterator); + } - // release the iterator - IOObjectRelease(hidObjectIterator); + // release the iterator + IOObjectRelease(hidObjectIterator); - return hidDevice; + return hidDevice; } @end diff --git a/apple_remote/source/KeyspanFrontRowControl.m b/apple_remote/source/KeyspanFrontRowControl.m index c637aa9cf9c7..ed0cd106869c 100644 --- a/apple_remote/source/KeyspanFrontRowControl.m +++ b/apple_remote/source/KeyspanFrontRowControl.m @@ -38,60 +38,60 @@ @implementation KeyspanFrontRowControl -- (void) setCookieMappingInDictionary: (NSMutableDictionary*) _cookieToButtonMapping { - [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonPlus] forKey:@"11_18_99_10_"]; - [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonMinus] forKey:@"11_18_98_10_"]; - [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonMenu] forKey:@"11_18_58_10_"]; - [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonPlay] forKey:@"11_18_61_10_"]; - [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonRight] forKey:@"11_18_96_10_"]; - [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonLeft] forKey:@"11_18_97_10_"]; - /* hold events are not being send by this device - [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonRight_Hold] forKey:@"14_6_4_2_"]; - [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonLeft_Hold] forKey:@"14_6_3_2_"]; - [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonMenu_Hold] forKey:@"14_6_14_6_"]; - [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonPlay_Sleep] forKey:@"18_14_6_18_14_6_"]; - [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteControl_Switched] forKey:@"19_"]; - */ +- (void) setCookieMappingInDictionary: (NSMutableDictionary*) _cookieToButtonMapping { + [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonPlus] forKey:@"11_18_99_10_"]; + [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonMinus] forKey:@"11_18_98_10_"]; + [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonMenu] forKey:@"11_18_58_10_"]; + [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonPlay] forKey:@"11_18_61_10_"]; + [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonRight] forKey:@"11_18_96_10_"]; + [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonLeft] forKey:@"11_18_97_10_"]; + /* hold events are not being send by this device + [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonRight_Hold] forKey:@"14_6_4_2_"]; + [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonLeft_Hold] forKey:@"14_6_3_2_"]; + [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonMenu_Hold] forKey:@"14_6_14_6_"]; + [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonPlay_Sleep] forKey:@"18_14_6_18_14_6_"]; + [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteControl_Switched] forKey:@"19_"]; + */ } + (io_object_t) findRemoteDevice { - CFMutableDictionaryRef hidMatchDictionary = NULL; - IOReturn ioReturnValue = kIOReturnSuccess; - io_iterator_t hidObjectIterator = 0; - io_object_t hidDevice = 0; - SInt32 idVendor = 1741; - SInt32 idProduct = 0x420; + CFMutableDictionaryRef hidMatchDictionary = NULL; + IOReturn ioReturnValue = kIOReturnSuccess; + io_iterator_t hidObjectIterator = 0; + io_object_t hidDevice = 0; + SInt32 idVendor = 1741; + SInt32 idProduct = 0x420; - // Set up a matching dictionary to search the I/O Registry by class - // name for all HID class devices - hidMatchDictionary = IOServiceMatching(kIOHIDDeviceKey); + // Set up a matching dictionary to search the I/O Registry by class + // name for all HID class devices + hidMatchDictionary = IOServiceMatching(kIOHIDDeviceKey); - CFNumberRef numberRefVendor = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &idVendor); + CFNumberRef numberRefVendor = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &idVendor); if ( numberRefVendor ) { CFDictionaryAddValue(hidMatchDictionary, CFSTR(kIOHIDVendorIDKey), numberRefVendor); CFRelease(numberRefVendor); - } + } CFNumberRef numberRefProduct = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &idProduct); if ( numberRefProduct ) { CFDictionaryAddValue(hidMatchDictionary, CFSTR(kIOHIDProductIDKey), numberRefProduct); CFRelease(numberRefProduct); - } + } - // Now search I/O Registry for matching devices. - ioReturnValue = IOServiceGetMatchingServices(kIOMasterPortDefault, hidMatchDictionary, &hidObjectIterator); + // Now search I/O Registry for matching devices. + ioReturnValue = IOServiceGetMatchingServices(kIOMasterPortDefault, hidMatchDictionary, &hidObjectIterator); - if ((ioReturnValue == kIOReturnSuccess) && (hidObjectIterator != 0)) { - hidDevice = IOIteratorNext(hidObjectIterator); - } + if ((ioReturnValue == kIOReturnSuccess) && (hidObjectIterator != 0)) { + hidDevice = IOIteratorNext(hidObjectIterator); + } - // release the iterator + // release the iterator if ( hidObjectIterator ) IOObjectRelease(hidObjectIterator); - return hidDevice; + return hidDevice; } diff --git a/apple_remote/source/RemoteControl.m b/apple_remote/source/RemoteControl.m index 9cf840527bd3..2d4021a910b1 100644 --- a/apple_remote/source/RemoteControl.m +++ b/apple_remote/source/RemoteControl.m @@ -49,7 +49,7 @@ NSString* kTargetApplicationIdentifier = @"TargetBundleIdentifier"; // returns nil if the remote control device is not available - (id) initWithDelegate: (id) _remoteControlDelegate { - if ( (self = [super init]) ) { + if ( (self = [super init]) ) { delegate = [_remoteControlDelegate retain]; #ifdef DEBUG NSLog( @"Apple RemoteControl initWithDelegate ok"); @@ -59,8 +59,8 @@ NSString* kTargetApplicationIdentifier = @"TargetBundleIdentifier"; } - (void) dealloc { - [delegate release]; - [super dealloc]; + [delegate release]; + [super dealloc]; } - (void) setListeningToRemote: (BOOL) value { diff --git a/bridges/source/cpp_uno/gcc3_macosx_x86-64/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_macosx_x86-64/uno2cpp.cxx index 75cf8861c332..2f71e4410705 100644 --- a/bridges/source/cpp_uno/gcc3_macosx_x86-64/uno2cpp.cxx +++ b/bridges/source/cpp_uno/gcc3_macosx_x86-64/uno2cpp.cxx @@ -106,8 +106,8 @@ static void cpp_call( { // Maximum space for [complex ret ptr], values | ptr ... // (but will be used less - some of the values will be in pGPR and pFPR) - sal_uInt64 *pStack = static_cast<sal_uInt64 *>(__builtin_alloca( (nParams + 3) * sizeof(sal_uInt64) )); - sal_uInt64 *pStackStart = pStack; + sal_uInt64 *pStack = static_cast<sal_uInt64 *>(__builtin_alloca( (nParams + 3) * sizeof(sal_uInt64) )); + sal_uInt64 *pStackStart = pStack; sal_uInt64 pGPR[x86_64::MAX_GPR_REGS]; sal_uInt32 nGPR = 0; diff --git a/connectivity/source/drivers/macab/MacabResultSet.cxx b/connectivity/source/drivers/macab/MacabResultSet.cxx index fd129a1b798a..149a3123208d 100644 --- a/connectivity/source/drivers/macab/MacabResultSet.cxx +++ b/connectivity/source/drivers/macab/MacabResultSet.cxx @@ -144,8 +144,8 @@ void MacabResultSet::disposing() ::osl::MutexGuard aGuard(m_aMutex); -m_xStatement.clear(); -m_xMetaData.clear(); + m_xStatement.clear(); + m_xMetaData.clear(); } Any SAL_CALL MacabResultSet::queryInterface(const Type & rType) @@ -235,7 +235,7 @@ sal_Bool SAL_CALL MacabResultSet::getBoolean(sal_Int32) ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed); -::dbtools::throwFunctionNotSupportedSQLException("getBoolean", nullptr); + ::dbtools::throwFunctionNotSupportedSQLException("getBoolean", nullptr); return false; } @@ -245,7 +245,7 @@ sal_Int8 SAL_CALL MacabResultSet::getByte(sal_Int32) ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed); -::dbtools::throwFunctionNotSupportedSQLException("getByte", nullptr); + ::dbtools::throwFunctionNotSupportedSQLException("getByte", nullptr); return 0; } @@ -255,7 +255,7 @@ sal_Int16 SAL_CALL MacabResultSet::getShort(sal_Int32) ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed); -::dbtools::throwFunctionNotSupportedSQLException("getShort", nullptr); + ::dbtools::throwFunctionNotSupportedSQLException("getShort", nullptr); return 0; } @@ -490,7 +490,7 @@ Reference< XClob > SAL_CALL MacabResultSet::getClob(sal_Int32) ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed); -::dbtools::throwFunctionNotSupportedSQLException("getClob", nullptr); + ::dbtools::throwFunctionNotSupportedSQLException("getClob", nullptr); return nullptr; } @@ -500,7 +500,7 @@ Reference< XArray > SAL_CALL MacabResultSet::getArray(sal_Int32) ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed); -::dbtools::throwFunctionNotSupportedSQLException("getArray", nullptr); + ::dbtools::throwFunctionNotSupportedSQLException("getArray", nullptr); return nullptr; } @@ -897,7 +897,7 @@ sal_Bool SAL_CALL MacabResultSet::moveToBookmark(const Any& bookmark) checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed); OUString sBookmark = comphelper::getString(bookmark); - sal_Int32 nRecords = m_aMacabRecords->size(); + sal_Int32 nRecords = m_aMacabRecords->size(); for (sal_Int32 nRow = 0; nRow < nRecords; nRow++) { diff --git a/connectivity/source/drivers/macab/MacabTables.cxx b/connectivity/source/drivers/macab/MacabTables.cxx index 42d2adfe63c3..a3128846f89d 100644 --- a/connectivity/source/drivers/macab/MacabTables.cxx +++ b/connectivity/source/drivers/macab/MacabTables.cxx @@ -73,7 +73,7 @@ void MacabTables::impl_refresh( ) void MacabTables::disposing() { -m_xMetaData.clear(); + m_xMetaData.clear(); OCollection::disposing(); } diff --git a/connectivity/source/drivers/odbc/OFunctions.cxx b/connectivity/source/drivers/odbc/OFunctions.cxx index f740052325c3..9e3c1893b8c7 100644 --- a/connectivity/source/drivers/odbc/OFunctions.cxx +++ b/connectivity/source/drivers/odbc/OFunctions.cxx @@ -96,7 +96,7 @@ bool LoadLibrary_ODBC3(OUString &_rPath) #endif #ifdef UNX #ifdef MACOSX - _rPath = "libiodbc.dylib"; + _rPath = "libiodbc.dylib"; #else _rPath = "libodbc.so.1"; pODBCso = osl_loadModule( _rPath.pData,SAL_LOADMODULE_NOW ); diff --git a/lingucomponent/source/spellcheck/macosxspell/macspellimp.mm b/lingucomponent/source/spellcheck/macosxspell/macspellimp.mm index ba43a6bcaa7d..a141b8752ac9 100644 --- a/lingucomponent/source/spellcheck/macosxspell/macspellimp.mm +++ b/lingucomponent/source/spellcheck/macosxspell/macspellimp.mm @@ -92,15 +92,15 @@ Sequence< Locale > SAL_CALL MacSpellChecker::getLocales() { MutexGuard aGuard( GetLinguMutex() ); - // this routine should return the locales supported by the installed - // dictionaries. So here we need to parse both the user edited - // dictionary list and the shared dictionary list - // to see what dictionaries the admin/user has installed + // this routine should return the locales supported by the installed + // dictionaries. So here we need to parse both the user edited + // dictionary list and the shared dictionary list + // to see what dictionaries the admin/user has installed - int numshr; // number of shared dictionary entries - rtl_TextEncoding aEnc = RTL_TEXTENCODING_UTF8; + int numshr; // number of shared dictionary entries + rtl_TextEncoding aEnc = RTL_TEXTENCODING_UTF8; - std::vector<NSString *> postspdict; + std::vector<NSString *> postspdict; if (!numdict) { @@ -263,12 +263,12 @@ Sequence< Locale > SAL_CALL MacSpellChecker::getLocales() } else { /* no dictionary.lst found so register no dictionaries */ numdict = 0; - aDEncs = nullptr; - aDLocs = nullptr; - aDNames = nullptr; - aSuppLocales.realloc(0); - } + aDEncs = nullptr; + aDLocs = nullptr; + aDNames = nullptr; + aSuppLocales.realloc(0); } + } return aSuppLocales; } @@ -307,16 +307,16 @@ sal_Int16 MacSpellChecker::GetSpellFailure( const OUString &rWord, const Locale sal_Int16 nRes = -1; - // first handle smart quotes both single and double + // first handle smart quotes both single and double OUStringBuffer rBuf(rWord); - sal_Int32 n = rBuf.getLength(); - sal_Unicode c; + sal_Int32 n = rBuf.getLength(); + sal_Unicode c; for (sal_Int32 ix=0; ix < n; ix++) { c = rBuf[ix]; if ((c == 0x201C) || (c == 0x201D)) rBuf[ix] = u'"'; if ((c == 0x2018) || (c == 0x2019)) rBuf[ix] = u'\''; - } - OUString nWord(rBuf.makeStringAndClear()); + } + OUString nWord(rBuf.makeStringAndClear()); if (n) { @@ -361,7 +361,7 @@ sal_Bool SAL_CALL { MutexGuard aGuard( GetLinguMutex() ); - if (rLocale == Locale() || !rWord.getLength()) + if (rLocale == Locale() || !rWord.getLength()) return true; if (!hasLocale( rLocale )) @@ -411,14 +411,14 @@ Reference< XSpellAlternatives > // first handle smart quotes (single and double) OUStringBuffer rBuf(rWord); - sal_Int32 n = rBuf.getLength(); - sal_Unicode c; + sal_Int32 n = rBuf.getLength(); + sal_Unicode c; for (sal_Int32 ix=0; ix < n; ix++) { c = rBuf[ix]; if ((c == 0x201C) || (c == 0x201D)) rBuf[ix] = u'"'; if ((c == 0x2018) || (c == 0x2019)) rBuf[ix] = u'\''; - } - OUString nWord(rBuf.makeStringAndClear()); + } + OUString nWord(rBuf.makeStringAndClear()); if (n) { @@ -438,24 +438,24 @@ Reference< XSpellAlternatives > { aStr.realloc( count ); OUString *pStr = aStr.getArray(); - for (int ii=0; ii < count; ii++) - { + for (int ii=0; ii < count; ii++) + { // if needed add: if (suglst[ii] == NULL) continue; NSString* guess = [guesses objectAtIndex:ii]; OUString cvtwrd(reinterpret_cast<const sal_Unicode*>([guess cStringUsingEncoding:NSUnicodeStringEncoding]), static_cast<sal_Int32>([guess length])); pStr[ii] = cvtwrd; - } + } } - [pool release]; + [pool release]; } - // now return an empty alternative for no suggestions or the list of alternatives if some found - SpellAlternatives *pAlt = new SpellAlternatives; - pAlt->SetWordLanguage( rWord, nLang ); - pAlt->SetFailureType( SpellFailure::SPELLING_ERROR ); - pAlt->SetAlternatives( aStr ); - xRes = pAlt; - return xRes; + // now return an empty alternative for no suggestions or the list of alternatives if some found + SpellAlternatives *pAlt = new SpellAlternatives; + pAlt->SetWordLanguage( rWord, nLang ); + pAlt->SetFailureType( SpellFailure::SPELLING_ERROR ); + pAlt->SetAlternatives( aStr ); + xRes = pAlt; + return xRes; } @@ -467,7 +467,7 @@ Reference< XSpellAlternatives > SAL_CALL { MutexGuard aGuard( GetLinguMutex() ); - if (rLocale == Locale() || !rWord.getLength()) + if (rLocale == Locale() || !rWord.getLength()) return nullptr; if (!hasLocale( rLocale )) diff --git a/sal/osl/unx/system.cxx b/sal/osl/unx/system.cxx index 2abbc24c0bd4..2d58555b8307 100644 --- a/sal/osl/unx/system.cxx +++ b/sal/osl/unx/system.cxx @@ -63,12 +63,12 @@ struct hostent *gethostbyname_r(const char *name, struct hostent *result, * NULL * addr1addr2addr3...addrn */ - struct hostent* res; + struct hostent* res; - RTL_MUTEX_LOCK + RTL_MUTEX_LOCK - if ( (res = gethostbyname(name)) ) - { + if ( (res = gethostbyname(name)) ) + { int nname, naliases, naddr_list, naliasesdata; char **p, **parray, *data; @@ -98,7 +98,7 @@ struct hostent *gethostbyname_r(const char *name, struct hostent *result, memcpy(result, res, sizeof(struct hostent)); strcpy(buffer, res->h_name); - result->h_name = buffer; + result->h_name = buffer; buffer += nname; parray = reinterpret_cast<char**>(buffer); @@ -122,7 +122,7 @@ struct hostent *gethostbyname_r(const char *name, struct hostent *result, } *parray = nullptr; - res = result; + res = result; } else { diff --git a/sd/source/ui/remotecontrol/OSXNetworkService.mm b/sd/source/ui/remotecontrol/OSXNetworkService.mm index a03c1d5e7998..51cbd8c99ca0 100644 --- a/sd/source/ui/remotecontrol/OSXNetworkService.mm +++ b/sd/source/ui/remotecontrol/OSXNetworkService.mm @@ -19,12 +19,12 @@ { netService = [[NSNetService alloc] initWithDomain:@"local" type:@"_impressremote._tcp" name:sName port:1599]; - if (netService != nil) - { + if (netService != nil) + { [netService setDelegate:self]; [netService scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; [netService publish]; - } + } } -(void)netService:(NSNetService *)aNetService diff --git a/tools/source/datetime/ttime.cxx b/tools/source/datetime/ttime.cxx index b5b3e1c533a0..068787dfe389 100644 --- a/tools/source/datetime/ttime.cxx +++ b/tools/source/datetime/ttime.cxx @@ -426,8 +426,8 @@ Time tools::Time::GetUTCOffset() // Linux mktime() seems not to handle tm_isdst correctly nUTC = nLocalTime - aTM.tm_gmtoff; #else - gmtime_r( &nTime, &aTM ); - nUTC = mktime( &aTM ); + gmtime_r( &nTime, &aTM ); + nUTC = mktime( &aTM ); #endif nCacheTicks = nTicks; nCacheSecOffset = (nLocalTime-nUTC) / 60; diff --git a/vcl/osx/DataFlavorMapping.cxx b/vcl/osx/DataFlavorMapping.cxx index de8dc8c41338..2390e797ad4e 100644 --- a/vcl/osx/DataFlavorMapping.cxx +++ b/vcl/osx/DataFlavorMapping.cxx @@ -400,7 +400,7 @@ Any PNGDataProvider::getOOoData() oOOData = mData; } - return oOOData; + return oOOData; } class FileListDataProvider : public DataProviderBaseImpl @@ -483,9 +483,9 @@ DataFlavorMapper::~DataFlavorMapper() DataFlavor DataFlavorMapper::systemToOpenOfficeFlavor( const NSString* systemDataFlavor) const { - DataFlavor oOOFlavor; + DataFlavor oOOFlavor; - for (size_t i = 0; i < SIZE_FLAVOR_MAP; i++) + for (size_t i = 0; i < SIZE_FLAVOR_MAP; i++) { if ([systemDataFlavor caseInsensitiveCompare:const_cast<NSString*>(flavorMap[i].SystemFlavor)] == NSOrderedSame) { diff --git a/vcl/osx/a11yrolehelper.mm b/vcl/osx/a11yrolehelper.mm index 0723fbc9c2d3..e42b2d53db8b 100644 --- a/vcl/osx/a11yrolehelper.mm +++ b/vcl/osx/a11yrolehelper.mm @@ -268,11 +268,11 @@ using namespace ::com::sun::star::uno; } +(id)getRoleDescriptionFrom: (NSString *) role with: (NSString *) subRole { - id roleDescription; - if ( [ subRole length ] == 0 ) - roleDescription = NSAccessibilityRoleDescription( role, nil ); - else - roleDescription = NSAccessibilityRoleDescription( role, subRole ); + id roleDescription; + if ( [ subRole length ] == 0 ) + roleDescription = NSAccessibilityRoleDescription( role, nil ); + else + roleDescription = NSAccessibilityRoleDescription( role, subRole ); return roleDescription; } diff --git a/vcl/osx/a11ywrapper.mm b/vcl/osx/a11ywrapper.mm index e24b83e5e2c0..555835021650 100644 --- a/vcl/osx/a11ywrapper.mm +++ b/vcl/osx/a11ywrapper.mm @@ -886,7 +886,7 @@ static std::ostream &operator<<(std::ostream &s, NSObject *obj) { // Make sure the focused object is a descendant of self // do { // if( self == ancestor ) - return focusedUIElement; + return focusedUIElement; // ancestor = [ ancestor accessibilityAttributeValue: NSAccessibilityParentAttribute ]; // } while( nil != ancestor ); diff --git a/vcl/osx/salframeview.mm b/vcl/osx/salframeview.mm index a3f727719e74..baf5fa96773e 100644 --- a/vcl/osx/salframeview.mm +++ b/vcl/osx/salframeview.mm @@ -566,7 +566,7 @@ static AquaSalFrame* getMouseContainerFrame() NSPoint aPt = [NSEvent mouseLocation]; NSRect aFrameRect = [pDispatchFrame->getNSWindow() frame]; - if ( ! NSPointInRect( aPt, aFrameRect ) ) + if ( ! NSPointInRect( aPt, aFrameRect ) ) { // no, it is not // now we need to find the one it may be in diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx index 45b9848c051a..68b7a4ffc250 100644 --- a/vcl/source/outdev/text.cxx +++ b/vcl/source/outdev/text.cxx @@ -856,13 +856,13 @@ void OutputDevice::DrawText( const Point& rStartPt, const OUString& rStr, if(mpFontInstance->mpConversion) pLayoutCache = nullptr; - #ifdef MACOSX - // FIXME: tdf#112990 - // Cache text layout crashes on mac with OpenGL enabled - // Force it to not use the cache - if(OpenGLHelper::isVCLOpenGLEnabled()) - pLayoutCache = nullptr; - #endif +#ifdef MACOSX + // FIXME: tdf#112990 + // Cache text layout crashes on mac with OpenGL enabled + // Force it to not use the cache + if(OpenGLHelper::isVCLOpenGLEnabled()) + pLayoutCache = nullptr; +#endif std::unique_ptr<SalLayout> pSalLayout = ImplLayout(rStr, nIndex, nLen, rStartPt, 0, nullptr, SalLayoutFlags::NONE, nullptr, pLayoutCache); if(pSalLayout) diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx index dccd084f668d..b0e1ea918115 100644 --- a/vcl/source/window/winproc.cxx +++ b/vcl/source/window/winproc.cxx @@ -2065,7 +2065,7 @@ static void ImplHandleSalKeyMod( vcl::Window* pWindow, SalKeyModEvent const * pE if ( nOldCode != nNewCode ) { #ifdef MACOSX - nNewCode |= pWindow->ImplGetWindowImpl()->mpFrameData->mnMouseCode & ~(KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_MOD3); + nNewCode |= pWindow->ImplGetWindowImpl()->mpFrameData->mnMouseCode & ~(KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_MOD3); #else nNewCode |= pWindow->ImplGetWindowImpl()->mpFrameData->mnMouseCode & ~(KEY_SHIFT | KEY_MOD1 | KEY_MOD2); #endif |