This is an automated email from the ASF dual-hosted git repository.
mseidel pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/openoffice.git
The following commit(s) were added to refs/heads/trunk by this push:
new 3dff66329e pre-commit clean ups for `.m` files (#345)
3dff66329e is described below
commit 3dff66329e41be01823376d93e21b595bd3e3094
Author: John Bampton <[email protected]>
AuthorDate: Mon Mar 31 02:08:11 2025 +1000
pre-commit clean ups for `.m` files (#345)
Enforced 3 hooks:
- end-of-file-fixer
- mixed-line-ending
- trailing-whitespace
---
.pre-commit-config.yaml | 6 +-
main/apple_remote/source/AppleRemote.m | 36 ++--
main/apple_remote/source/GlobalKeyboardDevice.m | 84 ++++----
main/apple_remote/source/HIDRemoteControlDevice.m | 213 ++++++++++-----------
main/apple_remote/source/KeyspanFrontRowControl.m | 34 ++--
.../apple_remote/source/MultiClickRemoteBehavior.m | 58 +++---
main/apple_remote/source/RemoteControl.m | 18 +-
main/apple_remote/source/RemoteControlContainer.m | 20 +-
main/apple_remote/source/RemoteMainController.m | 26 +--
.../source/macosx/spotlight/GetMetadataForFile.m | 30 +--
.../source/macosx/spotlight/OOoContentDataParser.m | 40 ++--
.../source/macosx/spotlight/OOoMetaDataParser.m | 50 ++---
.../source/macosx/spotlight/OOoSpotlightImporter.m | 66 +++----
main/extensions/source/macosx/spotlight/ioapi.m | 8 +-
main/extensions/source/macosx/spotlight/main.m | 17 +-
main/extensions/source/macosx/spotlight/unzip.m | 8 +-
16 files changed, 356 insertions(+), 358 deletions(-)
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 256fcaff78..ad64453973 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -33,12 +33,12 @@ repos:
- id: check-merge-conflict
- id: check-vcs-permalinks
- id: end-of-file-fixer
- files:
(m|M)akefile$|\.(asp|bat|c|cxx|dxp|el|h|hrc|hxx|idl|in|ini|java|md|mk|pas|php|pl|pm|py|rc|sh|xcs|xdl|xhp|xmi|xsd|xslt?|ya?ml)$|^ext_libraries/.*$|^test/.*$
+ files:
(m|M)akefile$|\.(asp|bat|c|cxx|dxp|el|h|hrc|hxx|idl|in|ini|java|m|md|mk|pas|php|pl|pm|py|rc|sh|xcs|xdl|xhp|xmi|xsd|xslt?|ya?ml)$|^ext_libraries/.*$|^test/.*$
- id: fix-byte-order-marker
- id: mixed-line-ending
- files:
^main/.*\.(c|h)xx$|^main/.*\.java$|\.(asp|c|dxp|el|h|hrc|idl|in|ini|md|mk|pas|php|pl|pm|py|rc|sh|xcs|xdl|xhp|xmi|xsd|xslt?|ya?ml)$|^main/accessibility/.*$|^main/afms/.*$|^main/animations/.*$|^main/apache-commons/.*$
+ files:
^main/.*\.(c|h)xx$|^main/.*\.java$|\.(asp|c|dxp|el|h|hrc|idl|in|ini|m|md|mk|pas|php|pl|pm|py|rc|sh|xcs|xdl|xhp|xmi|xsd|xslt?|ya?ml)$|^main/accessibility/.*$|^main/afms/.*$|^main/animations/.*$|^main/apache-commons/.*$
- id: trailing-whitespace
- files: \.(asp|bat|el|ini|pas|php|pl|rc|sh|xcs|xdl|xmi|xsd|ya?ml)$
+ files: \.(asp|bat|el|ini|m|pas|php|pl|rc|sh|xcs|xdl|xmi|xsd|ya?ml)$
- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
hooks:
diff --git a/main/apple_remote/source/AppleRemote.m
b/main/apple_remote/source/AppleRemote.m
index fee5fc3703..5dcfc15214 100644
--- a/main/apple_remote/source/AppleRemote.m
+++ b/main/apple_remote/source/AppleRemote.m
@@ -2,13 +2,13 @@
* RemoteControlWrapper.m
* RemoteControlWrapper
*
- * Created by Martin Kahr on 11.03.06 under a MIT-style license.
+ * Created by Martin Kahr on 11.03.06 under a MIT-style license.
* Copyright (c) 2006 martinkahr.com. All rights reserved.
*
- * Code modified and adapted to OpenOffice.org
+ * Code modified and adapted to OpenOffice.org
* by Eric Bachard on 11.08.2008 under the same license
*
- * Permission is hereby granted, free of charge, to any person obtaining a
+ * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
@@ -20,7 +20,7 @@
*
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
@@ -54,9 +54,9 @@ const char* AppleRemoteDeviceName = "AppleIRController";
}
- (void) setCookieMappingInDictionary: (NSMutableDictionary*)
_cookieToButtonMapping
-{
- // TODO : avoid such magics
- if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_4)
+{
+ // TODO : avoid such magics
+ if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_4)
{
#ifdef DEBUG
NSLog( @"Apple Remote: setting 10.4 cookies" );
@@ -64,8 +64,8 @@ const char* AppleRemoteDeviceName = "AppleIRController";
// 10.4.x Tiger
[_cookieToButtonMapping setObject:[NSNumber
numberWithInt:kRemoteButtonPlus] forKey:@"14_12_11_6_"];
- [_cookieToButtonMapping setObject:[NSNumber
numberWithInt:kRemoteButtonMinus] forKey:@"14_13_11_6_"];
- [_cookieToButtonMapping setObject:[NSNumber
numberWithInt:kRemoteButtonMenu] forKey:@"14_7_6_14_7_6_"];
+ [_cookieToButtonMapping setObject:[NSNumber
numberWithInt:kRemoteButtonMinus] forKey:@"14_13_11_6_"];
+ [_cookieToButtonMapping setObject:[NSNumber
numberWithInt:kRemoteButtonMenu] forKey:@"14_7_6_14_7_6_"];
[_cookieToButtonMapping setObject:[NSNumber
numberWithInt:kRemoteButtonPlay] forKey:@"14_8_6_14_8_6_"];
[_cookieToButtonMapping setObject:[NSNumber
numberWithInt:kRemoteButtonRight] forKey:@"14_9_6_14_9_6_"];
[_cookieToButtonMapping setObject:[NSNumber
numberWithInt:kRemoteButtonLeft] forKey:@"14_10_6_14_10_6_"];
@@ -73,8 +73,8 @@ const char* AppleRemoteDeviceName = "AppleIRController";
[_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_Hold] forKey:@"18_14_6_18_14_6_"];
- [_cookieToButtonMapping setObject:[NSNumber
numberWithInt:kRemoteControl_Switched] forKey:@"19_"];
- }
+ [_cookieToButtonMapping setObject:[NSNumber
numberWithInt:kRemoteControl_Switched] forKey:@"19_"];
+ }
else if( floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_5 )
{
#ifdef DEBUG
@@ -82,7 +82,7 @@ const char* AppleRemoteDeviceName = "AppleIRController";
#endif
// 10.5.x Leopard
[_cookieToButtonMapping setObject:[NSNumber
numberWithInt:kRemoteButtonPlus] forKey:@"31_29_28_19_18_"];
- [_cookieToButtonMapping setObject:[NSNumber
numberWithInt:kRemoteButtonMinus] forKey:@"31_30_28_19_18_"];
+ [_cookieToButtonMapping setObject:[NSNumber
numberWithInt:kRemoteButtonMinus] forKey:@"31_30_28_19_18_"];
[_cookieToButtonMapping setObject:[NSNumber
numberWithInt:kRemoteButtonMenu] forKey:@"31_20_19_18_31_20_19_18_"];
[_cookieToButtonMapping setObject:[NSNumber
numberWithInt:kRemoteButtonPlay] forKey:@"31_21_19_18_31_21_19_18_"];
[_cookieToButtonMapping setObject:[NSNumber
numberWithInt:kRemoteButtonRight] forKey:@"31_22_19_18_31_22_19_18_"];
@@ -91,8 +91,8 @@ const char* AppleRemoteDeviceName = "AppleIRController";
[_cookieToButtonMapping setObject:[NSNumber
numberWithInt:kRemoteButtonLeft_Hold] forKey:@"31_19_18_3_2_"];
[_cookieToButtonMapping setObject:[NSNumber
numberWithInt:kRemoteButtonMenu_Hold] forKey:@"31_19_18_31_19_18_"];
[_cookieToButtonMapping setObject:[NSNumber
numberWithInt:kRemoteButtonPlay_Hold] forKey:@"35_31_19_18_35_31_19_18_"];
- [_cookieToButtonMapping setObject:[NSNumber
numberWithInt:kRemoteControl_Switched] forKey:@"19_"];
- }
+ [_cookieToButtonMapping setObject:[NSNumber
numberWithInt:kRemoteControl_Switched] forKey:@"19_"];
+ }
else
{
#ifdef DEBUG
@@ -100,7 +100,7 @@ const char* AppleRemoteDeviceName = "AppleIRController";
#endif
// 10.6.x Snow Leopard
[_cookieToButtonMapping setObject:[NSNumber
numberWithInt:kRemoteButtonPlus] forKey:@"33_31_30_21_20_2_"];
- [_cookieToButtonMapping setObject:[NSNumber
numberWithInt:kRemoteButtonMinus] forKey:@"33_32_30_21_20_2_"];
+ [_cookieToButtonMapping setObject:[NSNumber
numberWithInt:kRemoteButtonMinus] forKey:@"33_32_30_21_20_2_"];
[_cookieToButtonMapping setObject:[NSNumber
numberWithInt:kRemoteButtonMenu]
forKey:@"33_22_21_20_2_33_22_21_20_2_"];
[_cookieToButtonMapping setObject:[NSNumber
numberWithInt:kRemoteButtonPlay]
forKey:@"33_23_21_20_2_33_23_21_20_2_"];
[_cookieToButtonMapping setObject:[NSNumber
numberWithInt:kRemoteButtonRight]
forKey:@"33_24_21_20_2_33_24_21_20_2_"];
@@ -120,10 +120,10 @@ const char* AppleRemoteDeviceName = "AppleIRController";
if (pressedDown == NO && event == kRemoteButtonMenu_Hold) {
// There is no separate event for pressed down on menu hold. We
are simulating that event here
[super sendRemoteButtonEvent:event pressedDown:YES];
- }
-
+ }
+
[super sendRemoteButtonEvent:event pressedDown:pressedDown];
-
+
if (pressedDown && (event == kRemoteButtonRight || event ==
kRemoteButtonLeft || event == kRemoteButtonPlay || event == kRemoteButtonMenu
|| event == kRemoteButtonPlay_Hold)) {
// There is no separate event when the button is being
released. We are simulating that event here
[super sendRemoteButtonEvent:event pressedDown:NO];
diff --git a/main/apple_remote/source/GlobalKeyboardDevice.m
b/main/apple_remote/source/GlobalKeyboardDevice.m
index 9cc4739d85..4bf98279cb 100644
--- a/main/apple_remote/source/GlobalKeyboardDevice.m
+++ b/main/apple_remote/source/GlobalKeyboardDevice.m
@@ -2,13 +2,13 @@
* GlobalKeyboardDevice.m
* RemoteControlWrapper
*
- * Created by Martin Kahr on 11.03.06 under a MIT-style license.
+ * Created by Martin Kahr on 11.03.06 under a MIT-style license.
* Copyright (c) 2006 martinkahr.com. All rights reserved.
*
- * Code modified and adapted to OpenOffice.org
+ * Code modified and adapted to OpenOffice.org
* by Eric Bachard on 11.08.2008 under the same license
*
- * Permission is hereby granted, free of charge, to any person obtaining a
+ * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
@@ -20,7 +20,7 @@
*
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
@@ -41,7 +41,7 @@
/*
the following default keys are read and shall be used to change the keyboard
mapping
-
+
mac.remotecontrols.GlobalKeyboardDevice.plus_modifiers
mac.remotecontrols.GlobalKeyboardDevice.plus_keycode
mac.remotecontrols.GlobalKeyboardDevice.minus_modifiers
@@ -62,19 +62,19 @@ static OSStatus hotKeyEventHandler(EventHandlerCallRef,
EventRef, void*);
@implementation GlobalKeyboardDevice
-- (id) initWithDelegate: (id) _remoteControlDelegate {
+- (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];
+ [self mapRemoteButton:kRemoteButtonPlay_Hold
defaultKeycode:F7 defaultModifiers:modifiers];
}
return self;
}
@@ -85,48 +85,48 @@ static OSStatus hotKeyEventHandler(EventHandlerCallRef,
EventRef, void*);
}
- (void) mapRemoteButton: (RemoteControlEventIdentifier)
remoteButtonIdentifier defaultKeycode: (unsigned int) defaultKeycode
defaultModifiers: (unsigned int) defaultModifiers {
- NSString* defaultsKey = NULL;
-
+ NSString* defaultsKey = NULL;
+
switch(remoteButtonIdentifier) {
case kRemoteButtonPlus:
defaultsKey = @"plus";
break;
case kRemoteButtonMinus:
defaultsKey = @"minus";
- break;
+ break;
case kRemoteButtonMenu:
defaultsKey = @"menu";
- break;
+ break;
case kRemoteButtonPlay:
defaultsKey = @"play";
break;
case kRemoteButtonRight:
defaultsKey = @"right";
- break;
- case kRemoteButtonLeft:
+ break;
+ case kRemoteButtonLeft:
defaultsKey = @"left";
break;
case kRemoteButtonPlay_Hold:
defaultsKey = @"playhold";
- break;
- default:
+ break;
+ default:
#ifdef DEBUG
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]];
-
+
unsigned int modifiers = defaultModifiers;
if (modifiersCfg) modifiers = [modifiersCfg 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;
@@ -136,22 +136,22 @@ static OSStatus hotKeyEventHandler(EventHandlerCallRef,
EventRef, void*);
[self stopListening: self];
}
}
-- (BOOL) isListeningToRemote {
+- (BOOL) isListeningToRemote {
return (eventHandlerRef!=NULL);
}
- (void) startListening: (id) sender {
-
+
if (eventHandlerRef) return;
-
+
EventTypeSpec eventSpec[2] = {
{ kEventClassKeyboard, kEventHotKeyPressed },
{ kEventClassKeyboard, kEventHotKeyReleased }
- };
-
+ };
+
InstallEventHandler( GetEventDispatcherTarget(),
-
(EventHandlerProcPtr)hotKeyEventHandler,
- 2, eventSpec, self,
&eventHandlerRef);
+
(EventHandlerProcPtr)hotKeyEventHandler,
+ 2, eventSpec, self,
&eventHandlerRef);
}
- (void) stopListening: (id) sender {
RemoveEventHandler(eventHandlerRef);
@@ -171,21 +171,21 @@ static OSStatus hotKeyEventHandler(EventHandlerCallRef,
EventRef, void*);
return "Keyboard";
}
-- (BOOL)registerHotKeyCode: (unsigned int) keycode modifiers: (unsigned int)
modifiers remoteEventIdentifier: (RemoteControlEventIdentifier) identifier {
+- (BOOL)registerHotKeyCode: (unsigned int) keycode modifiers: (unsigned int)
modifiers remoteEventIdentifier: (RemoteControlEventIdentifier) identifier {
OSStatus err;
EventHotKeyID hotKeyID;
EventHotKeyRef carbonHotKey;
hotKeyID.signature = 'PTHk';
hotKeyID.id = (long)keycode;
-
+
err = RegisterEventHotKey(keycode, modifiers, hotKeyID,
GetEventDispatcherTarget(), 0, &carbonHotKey );
-
+
if( err )
return NO;
-
+
[hotKeyRemoteEventMapping setObject: [NSNumber
numberWithInt:identifier] forKey: [NSNumber numberWithUnsignedInt:
hotKeyID.id]];
-
+
return YES;
}
/*
@@ -194,21 +194,21 @@ static OSStatus hotKeyEventHandler(EventHandlerCallRef,
EventRef, void*);
OSStatus err;
EventHotKeyRef carbonHotKey;
NSValue* key;
-
+
if( [[self allHotKeys] containsObject: hotKey] == NO )
return;
-
+
carbonHotKey = [self _carbonHotKeyForHotKey: hotKey];
NSAssert( carbonHotKey != nil, @"" );
-
+
err = UnregisterEventHotKey( carbonHotKey );
//Watch as we ignore 'err':
-
+
key = [NSValue valueWithPointer: carbonHotKey];
[mHotKeys removeObjectForKey: key];
-
+
[self _updateEventHandler];
-
+
//See that? Completely ignored
}
*/
@@ -233,7 +233,7 @@ static OSStatus hotKeyEventHandler(EventHandlerCallRef
inHandlerRef, EventRef in
RemoteControlEventIdentifier identifier = [keyboardDevice
remoteControlEventIdentifierForID:hkCom.id];
if (identifier == 0) return noErr;
-
+
BOOL pressedDown = YES;
if (identifier != lastEvent) {
lastEvent = identifier;
@@ -242,7 +242,7 @@ static OSStatus hotKeyEventHandler(EventHandlerCallRef
inHandlerRef, EventRef in
pressedDown = NO;
}
[keyboardDevice sendRemoteButtonEvent: identifier pressedDown:
pressedDown];
-
+
return noErr;
}
diff --git a/main/apple_remote/source/HIDRemoteControlDevice.m
b/main/apple_remote/source/HIDRemoteControlDevice.m
index f6bc848f72..b9a31a0cff 100644
--- a/main/apple_remote/source/HIDRemoteControlDevice.m
+++ b/main/apple_remote/source/HIDRemoteControlDevice.m
@@ -2,13 +2,13 @@
* HIDRemoteControlDevice.m
* RemoteControlWrapper
*
- * Created by Martin Kahr on 11.03.06 under a MIT-style license.
+ * Created by Martin Kahr on 11.03.06 under a MIT-style license.
* Copyright (c) 2006 martinkahr.com. All rights reserved.
*
- * Code modified and adapted to OpenOffice.org
+ * Code modified and adapted to OpenOffice.org
* by Eric Bachard on 11.08.2008 under the same license
*
- * Permission is hereby granted, free of charge, to any person obtaining a
+ * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
@@ -20,7 +20,7 @@
*
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
@@ -37,17 +37,17 @@
#import <IOKit/hid/IOHIDKeys.h>
#import <Carbon/Carbon.h>
-@interface HIDRemoteControlDevice (PrivateMethods)
+@interface HIDRemoteControlDevice (PrivateMethods)
- (NSDictionary*) cookieToButtonMapping; // Creates the dictionary using the
magics, depending on the remote
- (IOHIDQueueInterface**) queue;
- (IOHIDDeviceInterface**) hidDeviceInterface;
-- (void) handleEventWithCookieString: (NSString*) cookieString sumOfValues:
(SInt32) sumOfValues;
+- (void) handleEventWithCookieString: (NSString*) cookieString sumOfValues:
(SInt32) sumOfValues;
- (void) removeNotifcationObserver;
- (void) remoteControlAvailable:(NSNotification *)notification;
@end
-@interface HIDRemoteControlDevice (IOKitMethods)
+@interface HIDRemoteControlDevice (IOKitMethods)
+ (io_object_t) findRemoteDevice;
- (IOHIDDeviceInterface**) createInterfaceForDevice: (io_object_t) hidDevice;
- (BOOL) initializeCookies;
@@ -60,25 +60,25 @@
return "";
}
-+ (BOOL) isRemoteAvailable {
++ (BOOL) isRemoteAvailable {
io_object_t hidDevice = [self findRemoteDevice];
if (hidDevice != 0) {
IOObjectRelease(hidDevice);
return YES;
} else {
- return NO;
+ return NO;
}
}
-- (id) initWithDelegate: (id) _remoteControlDelegate {
+- (id) initWithDelegate: (id) _remoteControlDelegate {
if ([[self class] isRemoteAvailable] == NO) return nil;
-
+
if ( (self = [super initWithDelegate: _remoteControlDelegate]) ) {
openInExclusiveMode = YES;
queue = NULL;
hidDeviceInterface = NULL;
cookieToButtonMapping = [[NSMutableDictionary alloc] init];
-
+
[self setCookieMappingInDictionary: cookieToButtonMapping];
NSEnumerator* enumerator = [cookieToButtonMapping
objectEnumerator];
@@ -87,10 +87,10 @@
while( (identifier = [enumerator nextObject]) ) {
supportedButtonEvents |= [identifier intValue];
}
-
+
fixSecureEventInputBug = [[NSUserDefaults standardUserDefaults]
boolForKey: @"remoteControlWrapperFixSecureEventInputBug"];
}
-
+
return self;
}
@@ -114,9 +114,9 @@
- (BOOL) sendsEventForButtonIdentifier: (RemoteControlEventIdentifier)
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 {
@@ -141,38 +141,38 @@
processesBacklog = value;
}
-- (void) startListening: (id) sender {
+- (void) startListening: (id) sender {
if ([self isListeningToRemote]) return;
-
+
// 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 great number of people have complained about this.
+ //
// 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.
+ // 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.
- //
- if ([self isOpenInExclusiveMode] && fixSecureEventInputBug)
EnableSecureEventInput();
-
+ //
+ if ([self isOpenInExclusiveMode] && fixSecureEventInputBug)
EnableSecureEventInput();
+
[self removeNotifcationObserver];
-
+
io_object_t hidDevice = [[self class] findRemoteDevice];
if (hidDevice == 0) return;
-
+
if ([self createInterfaceForDevice:hidDevice] == NULL) {
goto error;
}
-
+
if ([self initializeCookies]==NO) {
goto error;
}
@@ -184,67 +184,67 @@
[self willChangeValueForKey:@"listeningToRemote"];
[self didChangeValueForKey:@"listeningToRemote"];
goto cleanup;
-
+
error:
[self stopListening:self];
DisableSecureEventInput();
-
-cleanup:
- IOObjectRelease(hidDevice);
+
+cleanup:
+ IOObjectRelease(hidDevice);
}
- (void) stopListening: (id) sender {
if ([self isListeningToRemote]==NO) return;
-
+
BOOL sendNotification = NO;
-
+
if (eventSource != NULL) {
CFRunLoopRemoveSource(CFRunLoopGetCurrent(), eventSource,
kCFRunLoopDefaultMode);
CFRelease(eventSource);
eventSource = NULL;
}
if (queue != NULL) {
- (*queue)->stop(queue);
-
+ (*queue)->stop(queue);
+
//dispose of queue
- (*queue)->dispose(queue);
-
+ (*queue)->dispose(queue);
+
//release the queue we allocated
- (*queue)->Release(queue);
-
+ (*queue)->Release(queue);
+
queue = NULL;
-
+
sendNotification = YES;
}
-
+
if (allCookies != nil) {
[allCookies autorelease];
allCookies = nil;
}
-
+
if (hidDeviceInterface != NULL) {
//close the device
(*hidDeviceInterface)->close(hidDeviceInterface);
-
- //release the interface
+
+ //release the interface
(*hidDeviceInterface)->Release(hidDeviceInterface);
-
+
hidDeviceInterface = NULL;
}
-
+
if ([self isOpenInExclusiveMode] && fixSecureEventInputBug)
DisableSecureEventInput();
-
+
if ([self isOpenInExclusiveMode] && sendNotification) {
- [[self class] sendFinishedNotifcationForAppIdentifier: nil];
+ [[self class] sendFinishedNotifcationForAppIdentifier: nil];
}
// be KVO friendly
[self willChangeValueForKey:@"listeningToRemote"];
- [self didChangeValueForKey:@"listeningToRemote"];
+ [self didChangeValueForKey:@"listeningToRemote"];
}
@end
-@implementation HIDRemoteControlDevice (PrivateMethods)
+@implementation HIDRemoteControlDevice (PrivateMethods)
- (IOHIDQueueInterface**) queue {
return queue;
@@ -265,7 +265,7 @@ cleanup:
NSString* key;
while( (key = [keyEnum nextObject]) ) {
NSRange range = [cookieString rangeOfString:key];
- if (range.location == 0) return key;
+ if (range.location == 0) return key;
}
return nil;
}
@@ -275,7 +275,7 @@ cleanup:
if (previousRemainingCookieString) {
cookieString = [previousRemainingCookieString
stringByAppendingString: cookieString];
NSLog( @"Apple Remote: New cookie string is %@", cookieString);
- [previousRemainingCookieString release],
previousRemainingCookieString=nil;
+ [previousRemainingCookieString release],
previousRemainingCookieString=nil;
}*/
if (cookieString == nil || [cookieString length] == 0) return;
@@ -304,14 +304,14 @@ cleanup:
}
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.
+ // 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);
- }
+ }
}
}
@@ -329,33 +329,33 @@ cleanup:
/* 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) {
+static void QueueCallbackFunction(void* target, IOReturn result, void*
refcon, void* sender) {
if (target < 0) {
NSLog( @"Apple Remote: QueueCallbackFunction called with
invalid target!");
return;
}
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
-
- HIDRemoteControlDevice* remote = (HIDRemoteControlDevice*)target;
- IOHIDEventStruct event;
+
+ HIDRemoteControlDevice* remote = (HIDRemoteControlDevice*)target;
+ IOHIDEventStruct event;
AbsoluteTime zeroTime = {0,0};
NSMutableString* cookieString = [NSMutableString string];
SInt32 sumOfValues = 0;
while (result == kIOReturnSuccess)
{
- result = (*[remote queue])->getNextEvent([remote queue],
&event, zeroTime, 0);
+ result = (*[remote queue])->getNextEvent([remote queue],
&event, zeroTime, 0);
if ( result != kIOReturnSuccess )
continue;
-
- //printf("%d %d %d\n", event.elementCookie, event.value,
event.longValue);
-
+
+ //printf("%d %d %d\n", event.elementCookie, event.value,
event.longValue);
+
if (((int)event.elementCookie)!=5) {
sumOfValues+=event.value;
[cookieString appendString:[NSString
stringWithFormat:@"%d_", event.elementCookie]];
}
}
[remote handleEventWithCookieString: cookieString sumOfValues:
sumOfValues];
-
+
[pool release];
}
@@ -367,16 +367,16 @@ static void QueueCallbackFunction(void* target, IOReturn
result, void* refcon,
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,
@@ -386,7 +386,7 @@ static void QueueCallbackFunction(void* target, IOReturn
result, void* refcon,
{
//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");
}
@@ -405,41 +405,41 @@ static void QueueCallbackFunction(void* target, IOReturn
result, void* refcon,
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) {
-
- [elements autorelease];
+
+ [elements autorelease];
/*
- cookies = calloc(NUMBER_OF_APPLE_REMOTE_ACTIONS,
sizeof(IOHIDElementCookie));
+ 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]) ) {
+
+ while ( (element = [elementsEnumerator nextObject]) ) {
//Get cookie
object = [element valueForKey:
(NSString*)CFSTR(kIOHIDElementCookieKey) ];
if (object == nil || ![object isKindOfClass:[NSNumber
class]]) continue;
if (object == 0 || CFGetTypeID(object) !=
CFNumberGetTypeID()) continue;
cookie = (IOHIDElementCookie) [object longValue];
-
+
//Get usage
object = [element valueForKey:
(NSString*)CFSTR(kIOHIDElementUsageKey) ];
- if (object == nil || ![object isKindOfClass:[NSNumber
class]]) continue;
+ 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;
+ if (object == nil || ![object isKindOfClass:[NSNumber
class]]) continue;
usagePage = [object longValue];
[allCookies addObject: [NSNumber
numberWithInt:(int)cookie]];
@@ -447,38 +447,38 @@ static void QueueCallbackFunction(void* target, IOReturn
result, void* refcon,
} 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) {
+ 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);
+
+ // 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);
+ (*queue)->start(queue);
return YES;
} else {
NSLog( @"Apple Remote: Error when
setting event callback");
@@ -491,38 +491,37 @@ static void QueueCallbackFunction(void* target, IOReturn
result, void* refcon,
}
} 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
+
+ // 2. send a distributed notification that we wanted to use the
remote control
[[self class] sendRequestForRemoteControlNotification];
}
- return NO;
+ return NO;
}
+ (io_object_t) findRemoteDevice {
CFMutableDictionaryRef hidMatchDictionary = NULL;
- IOReturn ioReturnValue = kIOReturnSuccess;
+ 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]);
-
+
// Now search I/O Registry for matching devices.
ioReturnValue = IOServiceGetMatchingServices(kIOMasterPortDefault,
hidMatchDictionary, &hidObjectIterator);
-
+
if ((ioReturnValue == kIOReturnSuccess) && (hidObjectIterator != 0)) {
hidDevice = IOIteratorNext(hidObjectIterator);
}
-
+
// release the iterator
IOObjectRelease(hidObjectIterator);
-
+
return hidDevice;
}
@end
-
diff --git a/main/apple_remote/source/KeyspanFrontRowControl.m
b/main/apple_remote/source/KeyspanFrontRowControl.m
index dd86475b12..fd8a7e4f6e 100644
--- a/main/apple_remote/source/KeyspanFrontRowControl.m
+++ b/main/apple_remote/source/KeyspanFrontRowControl.m
@@ -2,13 +2,13 @@
* KeyspanFrontRowControl.m
* RemoteControlWrapper
*
- * Created by Martin Kahr on 11.03.06 under a MIT-style license.
+ * Created by Martin Kahr on 11.03.06 under a MIT-style license.
* Copyright (c) 2006 martinkahr.com. All rights reserved.
*
- * Code modified and adapted to OpenOffice.org
+ * Code modified and adapted to OpenOffice.org
* by Eric Bachard on 11.08.2008 under the same License
*
- * Permission is hereby granted, free of charge, to any person obtaining a
+ * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
@@ -20,14 +20,14 @@
*
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*****************************************************************************/
-
+
#import "KeyspanFrontRowControl.h"
#import <mach/mach.h>
#import <mach/mach_error.h>
@@ -37,10 +37,10 @@
@implementation KeyspanFrontRowControl
-- (void) setCookieMappingInDictionary: (NSMutableDictionary*)
_cookieToButtonMapping {
+- (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: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_"];
@@ -49,22 +49,22 @@
[_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_"];
+ [_cookieToButtonMapping setObject:[NSNumber
numberWithInt:kRemoteControl_Switched] forKey:@"19_"];
*/
}
+ (io_object_t) findRemoteDevice {
CFMutableDictionaryRef hidMatchDictionary = NULL;
- IOReturn ioReturnValue = kIOReturnSuccess;
+ IOReturn ioReturnValue = kIOReturnSuccess;
io_iterator_t hidObjectIterator = 0;
io_object_t hidDevice = 0;
SInt32 idVendor = 1741;
- SInt32 idProduct = 0x420;
-
+ 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);
-
+
CFNumberRef numberRefVendor = CFNumberCreate(kCFAllocatorDefault,
kCFNumberSInt32Type, &idVendor);
if ( numberRefVendor )
{
@@ -76,22 +76,22 @@
if ( numberRefProduct )
{
CFDictionaryAddValue(hidMatchDictionary, CFSTR(kIOHIDProductIDKey),
numberRefProduct);
- CFRelease(numberRefProduct);
+ CFRelease(numberRefProduct);
}
// Now search I/O Registry for matching devices.
ioReturnValue = IOServiceGetMatchingServices(kIOMasterPortDefault,
hidMatchDictionary, &hidObjectIterator);
-
+
if ((ioReturnValue == kIOReturnSuccess) && (hidObjectIterator != 0)) {
hidDevice = IOIteratorNext(hidObjectIterator);
}
-
+
// release the iterator
if ( hidObjectIterator )
IOObjectRelease(hidObjectIterator);
return hidDevice;
-
+
}
@end
diff --git a/main/apple_remote/source/MultiClickRemoteBehavior.m
b/main/apple_remote/source/MultiClickRemoteBehavior.m
index 070aefa59e..b06f08fe73 100644
--- a/main/apple_remote/source/MultiClickRemoteBehavior.m
+++ b/main/apple_remote/source/MultiClickRemoteBehavior.m
@@ -2,13 +2,13 @@
* MultiClickRemoteBehavior.m
* RemoteControlWrapper
*
- * Created by Martin Kahr on 11.03.06 under a MIT-style license.
+ * Created by Martin Kahr on 11.03.06 under a MIT-style license.
* Copyright (c) 2006 martinkahr.com. All rights reserved.
*
- * Code modified and adapted to OpenOffice.org
+ * Code modified and adapted to OpenOffice.org
* by Eric Bachard on 11.08.2008 under the same License
*
- * Permission is hereby granted, free of charge, to any person obtaining a
+ * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
@@ -20,7 +20,7 @@
*
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
@@ -44,12 +44,12 @@ const NSTimeInterval HOLD_RECOGNITION_TIME_INTERVAL = 0.4;
// Delegates are not retained!
//
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/chapter_6_section_4.html
-// Delegating objects do not (and should not) retain their delegates.
+// Delegating objects do not (and should not) retain their delegates.
// However, clients of delegating objects (applications, usually) are
responsible for ensuring that their delegates are around
// to receive delegation messages. To do this, they may have to retain the
delegate.
- (void) setDelegate: (id) _delegate {
if ( _delegate && ( [_delegate
respondsToSelector:@selector(remoteButton:pressedDown:clickCount:)] == NO ))
return; // return what ?
-
+
delegate = _delegate;
}
- (id) delegate {
@@ -65,8 +65,8 @@ const NSTimeInterval HOLD_RECOGNITION_TIME_INTERVAL = 0.4;
- (BOOL) simulatesHoldForButtonIdentifier: (RemoteControlEventIdentifier)
identifier remoteControl: (RemoteControl*) remoteControl {
// we do that check only for the normal button identifiers as we would
check for hold support for hold events instead
- if (identifier > (1 << EVENT_TO_HOLD_EVENT_OFFSET)) return NO;
-
+ if (identifier > (1 << EVENT_TO_HOLD_EVENT_OFFSET)) return NO;
+
return [self simulateHoldEvent] && [remoteControl
sendsEventForButtonIdentifier: (identifier << EVENT_TO_HOLD_EVENT_OFFSET)]==NO;
}
@@ -109,32 +109,32 @@ const NSTimeInterval HOLD_RECOGNITION_TIME_INTERVAL = 0.4;
}
- (void) executeClickCountEvent: (NSArray*) values {
- RemoteControlEventIdentifier event = [[values objectAtIndex: 0]
unsignedIntValue];
+ RemoteControlEventIdentifier event = [[values objectAtIndex: 0]
unsignedIntValue];
NSTimeInterval eventTimePoint = [[values objectAtIndex: 1] doubleValue];
-
+
BOOL finishedClicking = NO;
- int finalClickCount = eventClickCount;
-
+ int finalClickCount = eventClickCount;
+
@synchronized(self) {
finishedClicking = (event != lastClickCountEvent ||
eventTimePoint == lastClickCountEventTime);
if (finishedClicking) {
- eventClickCount = 0;
+ eventClickCount = 0;
lastClickCountEvent = 0;
lastClickCountEventTime = 0;
}
}
-
- if (finishedClicking) {
- [delegate remoteButton:event pressedDown: YES
clickCount:finalClickCount];
+
+ if (finishedClicking) {
+ [delegate remoteButton:event pressedDown: YES
clickCount:finalClickCount];
// trigger a button release event, too
[NSThread sleepUntilDate: [NSDate
dateWithTimeIntervalSinceNow:0.1]];
[delegate remoteButton:event pressedDown: NO
clickCount:finalClickCount];
}
}
-- (void) sendRemoteButtonEvent: (RemoteControlEventIdentifier) event
pressedDown: (BOOL) pressedDown remoteControl: (RemoteControl*) remoteControl {
+- (void) sendRemoteButtonEvent: (RemoteControlEventIdentifier) event
pressedDown: (BOOL) pressedDown remoteControl: (RemoteControl*) remoteControl {
if (!delegate) return;
-
+
BOOL clickCountingForEvent = ([self clickCountEnabledButtons] & event)
== event;
if ([self simulatesHoldForButtonIdentifier: event remoteControl:
remoteControl] && lastClickCountEvent==0) {
@@ -142,7 +142,7 @@ const NSTimeInterval HOLD_RECOGNITION_TIME_INTERVAL = 0.4;
// wait to see if it is a hold
lastHoldEvent = event;
lastHoldEventTime = [NSDate
timeIntervalSinceReferenceDate];
- [self
performSelector:@selector(sendSimulatedHoldEvent:)
+ [self performSelector:@selector(sendSimulatedHoldEvent:)
withObject:[NSNumber
numberWithDouble:lastHoldEventTime]
afterDelay:HOLD_RECOGNITION_TIME_INTERVAL];
return;
@@ -160,31 +160,31 @@ const NSTimeInterval HOLD_RECOGNITION_TIME_INTERVAL = 0.4;
RemoteControlEventIdentifier previousEvent =
lastHoldEvent;
@synchronized(self) {
lastHoldEvent = 0;
- }
-
+ }
+
// in case click counting is enabled we have to
setup the state for that, too
if (clickCountingForEvent) {
lastClickCountEvent = previousEvent;
lastClickCountEventTime =
lastHoldEventTime;
NSNumber* eventNumber;
- NSNumber* timeNumber;
+ NSNumber* timeNumber;
eventClickCount = 1;
timeNumber = [NSNumber
numberWithDouble:lastClickCountEventTime];
eventNumber= [NSNumber
numberWithUnsignedInt:previousEvent];
NSTimeInterval diffTime =
maxClickTimeDifference-([NSDate
timeIntervalSinceReferenceDate]-lastHoldEventTime);
- [self performSelector:
@selector(executeClickCountEvent:)
+ [self performSelector:
@selector(executeClickCountEvent:)
withObject: [NSArray
arrayWithObjects:eventNumber, timeNumber, nil]
- afterDelay:
diffTime];
+ afterDelay:
diffTime];
// we do not return here because we are
still in the press-release event
// that will be consumed below
} else {
// trigger the pressed down event that
we consumed first
- [delegate remoteButton:event
pressedDown: YES clickCount:1];
+ [delegate remoteButton:event
pressedDown: YES clickCount:1];
}
- }
+ }
}
}
-
+
if (clickCountingForEvent) {
if (pressedDown == NO) return;
@@ -201,12 +201,12 @@ const NSTimeInterval HOLD_RECOGNITION_TIME_INTERVAL = 0.4;
timeNumber = [NSNumber
numberWithDouble:lastClickCountEventTime];
eventNumber= [NSNumber numberWithUnsignedInt:event];
}
- [self performSelector: @selector(executeClickCountEvent:)
+ [self performSelector: @selector(executeClickCountEvent:)
withObject: [NSArray
arrayWithObjects:eventNumber, timeNumber, nil]
afterDelay: maxClickTimeDifference];
} else {
[delegate remoteButton:event pressedDown: pressedDown
clickCount:1];
- }
+ }
}
diff --git a/main/apple_remote/source/RemoteControl.m
b/main/apple_remote/source/RemoteControl.m
index 02275ed7e5..22d09ebd08 100644
--- a/main/apple_remote/source/RemoteControl.m
+++ b/main/apple_remote/source/RemoteControl.m
@@ -2,13 +2,13 @@
* RemoteControl.m
* RemoteControlWrapper
*
- * Created by Martin Kahr on 11.03.06 under a MIT-style license.
+ * Created by Martin Kahr on 11.03.06 under a MIT-style license.
* Copyright (c) 2006 martinkahr.com. All rights reserved.
*
- * Code modified and adapted to OpenOffice.org
+ * Code modified and adapted to OpenOffice.org
* by Eric Bachard on 11.08.2008 under the same License
*
- * Permission is hereby granted, free of charge, to any person obtaining a
+ * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
@@ -20,17 +20,17 @@
*
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*****************************************************************************/
-
+
#import "RemoteControl.h"
-// notifaction names that are being used to signal that an application wants
to
+// notifaction names that are being used to signal that an application wants to
// have access to the remote control device or if the application has finished
// using the remote control device
NSString* REQUEST_FOR_REMOTE_CONTROL_NOTIFCATION =
@"mac.remotecontrols.RequestForRemoteControl";
@@ -47,7 +47,7 @@ NSString* kTargetApplicationIdentifier =
@"TargetBundleIdentifier";
@implementation RemoteControl
// returns nil if the remote control device is not available
-- (id) initWithDelegate: (id) _remoteControlDelegate {
+- (id) initWithDelegate: (id) _remoteControlDelegate {
if ( (self = [super init]) ) {
delegate = [_remoteControlDelegate retain];
#ifdef DEBUG
@@ -106,7 +106,7 @@ NSString* kTargetApplicationIdentifier =
@"TargetBundleIdentifier";
nil];
#ifdef DEBUG
NSLog( @"Apple Remote: sendDistributedNotification ...");
- // Debug purpose: returns all the existing dictionary keys.
+ // Debug purpose: returns all the existing dictionary keys.
NSEnumerator* itKey = [userInfo keyEnumerator];
NSEnumerator* itVal = [userInfo objectEnumerator];
for(;;) {
@@ -123,7 +123,7 @@ NSString* kTargetApplicationIdentifier =
@"TargetBundleIdentifier";
[[NSDistributedNotificationCenter defaultCenter]
postNotificationName:notificationName
object:nil
userInfo:userInfo
-
deliverImmediately:YES];
+
deliverImmediately:YES];
}
+ (void) sendFinishedNotifcationForAppIdentifier: (NSString*) identifier {
diff --git a/main/apple_remote/source/RemoteControlContainer.m
b/main/apple_remote/source/RemoteControlContainer.m
index e4247618c9..00a7522d51 100644
--- a/main/apple_remote/source/RemoteControlContainer.m
+++ b/main/apple_remote/source/RemoteControlContainer.m
@@ -2,13 +2,13 @@
* RemoteControlContainer.m
* RemoteControlWrapper
*
- * Created by Martin Kahr on 11.03.06 under a MIT-style license.
+ * Created by Martin Kahr on 11.03.06 under a MIT-style license.
* Copyright (c) 2006 martinkahr.com. All rights reserved.
*
- * Code modified and adapted to OpenOffice.org
+ * Code modified and adapted to OpenOffice.org
* by Eric Bachard on 11.08.2008 under the same License
*
- * Permission is hereby granted, free of charge, to any person obtaining a
+ * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
@@ -20,7 +20,7 @@
*
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
@@ -58,12 +58,12 @@
if (remoteControl) {
[remoteControls addObject: remoteControl];
[remoteControl addObserver: self forKeyPath:@"listeningToRemote"
options:NSKeyValueObservingOptionNew context:nil];
- toReturn = YES;
+ toReturn = YES;
}
#ifdef DEBUG
else {
NSLog( @"Apple Remote: ControlContainer
instantiateAndAddRemoteControlDeviceWithClass failed");
- toReturn = NO;
+ toReturn = NO;
}
#endif
return toReturn;
@@ -110,7 +110,7 @@
int i;
for(i=0; i < [remoteControls count]; i++) {
[[remoteControls objectAtIndex: i] startListening: sender];
- }
+ }
}
- (void) stopListening: (id) sender {
#ifdef DEBUG
@@ -119,7 +119,7 @@
int i;
for(i=0; i < [remoteControls count]; i++) {
[[remoteControls objectAtIndex: i] stopListening: sender];
- }
+ }
}
- (BOOL) isOpenInExclusiveMode {
@@ -128,13 +128,13 @@
for(i=0; i < [remoteControls count]; i++) {
mode = mode && ([[remoteControls objectAtIndex: i]
isOpenInExclusiveMode]);
}
- return mode;
+ return mode;
}
- (void) setOpenInExclusiveMode: (BOOL) value {
int i;
for(i=0; i < [remoteControls count]; i++) {
[[remoteControls objectAtIndex: i]
setOpenInExclusiveMode:value];
- }
+ }
}
@end
diff --git a/main/apple_remote/source/RemoteMainController.m
b/main/apple_remote/source/RemoteMainController.m
index 01def69f00..39539aa959 100644
--- a/main/apple_remote/source/RemoteMainController.m
+++ b/main/apple_remote/source/RemoteMainController.m
@@ -1,13 +1,13 @@
/*****************************************************************************
* RemoteMainController.m
*
- * Created by Martin Kahr on 11.03.06 under a MIT-style license.
+ * Created by Martin Kahr on 11.03.06 under a MIT-style license.
* Copyright (c) 2006 martinkahr.com. All rights reserved.
*
- * Code modified and adapted to OpenOffice.org
+ * Code modified and adapted to OpenOffice.org
* by Eric Bachard on 11.08.2008 under the same License
*
- * Permission is hereby granted, free of charge, to any person obtaining a
+ * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
@@ -19,7 +19,7 @@
*
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
@@ -40,15 +40,15 @@
@implementation AppleRemoteMainController
- (id) init {
- self = [super init]; // because we redefined our own init instead of use
the fu..nny awakeFromNib
+ self = [super init]; // because we redefined our own init instead of use
the fu..nny awakeFromNib
if (self != nil) {
// 1. instantiate the desired behavior for the remote control device
- remoteControlBehavior = [[MultiClickRemoteBehavior alloc] init];
+ remoteControlBehavior = [[MultiClickRemoteBehavior alloc] init];
// 2. configure the behavior
[remoteControlBehavior setDelegate: self];
-
+
// 3. a Remote Control Container manages a number of devices and
conforms to the RemoteControl interface
// Therefore you can enable or disable all the devices of the
container with a single "startListening:" call.
RemoteControlContainer* container = [[RemoteControlContainer alloc]
initWithDelegate: remoteControlBehavior];
@@ -69,21 +69,21 @@
else {
NSLog(@"[container instantiateAndAddRemoteControlDeviceWithClass:
[GlobalKeyboardDevice class]] failed");
#endif
- }
+ }
// to give the binding mechanism a chance to see the change of the
attribute
- [self setValue: container forKey: @"remoteControl"];
+ [self setValue: container forKey: @"remoteControl"];
#ifdef DEBUG
NSLog(@"AppleRemoteMainController init done");
#endif
}
- else
+ else
NSLog(@"AppleRemoteMainController init failed");
return self;
}
- (void) postTheEvent: (short int)buttonIdentifier
modifierFlags:(int)modifierFlags
{
- [NSApp postEvent:
+ [NSApp postEvent:
[NSEvent otherEventWithType:NSApplicationDefined
location:NSZeroPoint
modifierFlags:modifierFlags
@@ -91,7 +91,7 @@
windowNumber:[[NSApp keyWindow] windowNumber]
context:nil
subtype:AppleRemoteControlEvent
- data1: buttonIdentifier
+ data1: buttonIdentifier
data2: 0]
atStart: NO];
}
@@ -108,7 +108,7 @@
pressed = @"(AppleRemoteMainController: button pressed)";
#ifdef DEBUG
- switch(buttonIdentifier)
+ switch(buttonIdentifier)
{
case kRemoteButtonPlus: buttonName = @"Volume up";
break; // MEDIA_COMMAND_VOLUME_UP ( see vcl/inc/vcl/cmdevt.hxx )
case kRemoteButtonMinus: buttonName = @"Volume down";
break; // MEDIA_COMMAND_VOLUME_DOWN
diff --git a/main/extensions/source/macosx/spotlight/GetMetadataForFile.m
b/main/extensions/source/macosx/spotlight/GetMetadataForFile.m
index 6bfdd797f4..2b55e9da23 100644
--- a/main/extensions/source/macosx/spotlight/GetMetadataForFile.m
+++ b/main/extensions/source/macosx/spotlight/GetMetadataForFile.m
@@ -1,5 +1,5 @@
/**************************************************************
- *
+ *
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -7,22 +7,22 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *
+ *
*************************************************************/
#include <CoreFoundation/CoreFoundation.h>
-#include <CoreServices/CoreServices.h>
+#include <CoreServices/CoreServices.h>
#include <Foundation/Foundation.h>
@@ -31,13 +31,13 @@
/*
-----------------------------------------------------------------------------
Get metadata attributes from file
-
+
This function's job is to extract useful information your file format
supports
and return it as a dictionary
----------------------------------------------------------------------------- */
-Boolean GetMetadataForFile(void* thisInterface,
- CFMutableDictionaryRef attributes,
+Boolean GetMetadataForFile(void* thisInterface,
+ CFMutableDictionaryRef attributes,
CFStringRef contentTypeUTI,
CFStringRef pathToFile)
{
@@ -45,22 +45,22 @@ Boolean GetMetadataForFile(void* thisInterface,
/* Return the attribute keys and attribute values in the dict */
/* Return TRUE if successful, FALSE if there was no data provided */
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
+
OOoSpotlightImporter *importer = [OOoSpotlightImporter new];
-
+
Boolean importOK = NO;
@try {
- importOK = [importer importDocument:(NSString*)pathToFile
- contentType:(NSString*)contentTypeUTI
+ importOK = [importer importDocument:(NSString*)pathToFile
+ contentType:(NSString*)contentTypeUTI
attributes:(NSMutableDictionary*)attributes];
}
@catch (NSException *exception) {
NSLog(@"main: Caught %@: %@", [exception name], [exception reason]);
}
-
+
[importer release];
-
+
[pool release];
-
+
return importOK;
}
diff --git a/main/extensions/source/macosx/spotlight/OOoContentDataParser.m
b/main/extensions/source/macosx/spotlight/OOoContentDataParser.m
index 39f37afbeb..c233ce398f 100644
--- a/main/extensions/source/macosx/spotlight/OOoContentDataParser.m
+++ b/main/extensions/source/macosx/spotlight/OOoContentDataParser.m
@@ -1,5 +1,5 @@
/**************************************************************
- *
+ *
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -7,16 +7,16 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *
+ *
*************************************************************/
@@ -31,30 +31,30 @@
shouldReadCharacters = NO;
textContent = nil;
runningTextContent = nil;
-
+
return self;
}
-
+
return nil;
}
- (void)parseXML:(NSData*)data intoDictionary:(NSMutableDictionary*)dict
{
mdiValues = dict;
-
+
//NSLog(@"data: %@ %d", data, [data length]);
-
+
//init parser settings
shouldReadCharacters = NO;
-
+
NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data];
-
+
[parser setDelegate:self];
[parser setShouldResolveExternalEntities:NO];
[parser parse];
-
+
[parser release];
-
+
//NSLog(@"finished");
}
@@ -68,11 +68,11 @@
} else {
return;
}
-
+
//NSLog(@"start element %@", elementName);
}
-- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
+- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
if (shouldReadCharacters == TRUE) {
if (textContent == nil) {
@@ -82,7 +82,7 @@
[textContent appendString:@" "];
}
//NSLog(@"end");
-
+
[textContent appendString:[NSString
stringWithString:runningTextContent]];
[runningTextContent release];
}
@@ -95,21 +95,21 @@
return;
}
//NSLog(string);
-
+
[runningTextContent appendString:string];
-
+
//NSLog(@"currentElement: %@", currentElement);
//NSLog(@"read: %@", string);
-
+
}
- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError
{
//NSLog(@"parsing finished with error");
- NSLog([NSString stringWithFormat:@"An error occurred parsing the document.
(Error %i, Description: %@, Line: %i, Column: %i)", [parseError code],
+ NSLog([NSString stringWithFormat:@"An error occurred parsing the document.
(Error %i, Description: %@, Line: %i, Column: %i)", [parseError code],
[[parser parserError] localizedDescription], [parser lineNumber],
[parser columnNumber]]);
-
+
if (runningTextContent != nil) {
[runningTextContent release];
}
diff --git a/main/extensions/source/macosx/spotlight/OOoMetaDataParser.m
b/main/extensions/source/macosx/spotlight/OOoMetaDataParser.m
index e054574a12..dfd8d2e6e8 100644
--- a/main/extensions/source/macosx/spotlight/OOoMetaDataParser.m
+++ b/main/extensions/source/macosx/spotlight/OOoMetaDataParser.m
@@ -1,5 +1,5 @@
/**************************************************************
- *
+ *
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -7,16 +7,16 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *
+ *
*************************************************************/
@@ -32,7 +32,7 @@ static NSDictionary *metaXML2MDIKeys;
+ (void)initialize
{
static BOOL isInitialized = NO;
-
+
if (isInitialized == NO) {
//set up the meta elements with only one value
NSMutableSet *temp = [NSMutableSet new];
@@ -40,7 +40,7 @@ static NSDictionary *metaXML2MDIKeys;
[temp addObject:@"dc:description"];
[temp addObject:@"meta:user-defined"];
singleValueXMLElements = [[NSSet setWithSet:temp] retain];
-
+
//set up the meta elements that can have more than one value
[temp removeAllObjects];
[temp addObject:@"dc:subject"];
@@ -49,7 +49,7 @@ static NSDictionary *metaXML2MDIKeys;
[temp addObject:@"dc:creator"];
multiValueXMLElements = [[NSSet setWithSet:temp] retain];
[temp release];
-
+
//set up the map to store the values with the correct MDI keys
NSMutableDictionary *tempDict = [NSMutableDictionary new];
[tempDict setObject:(NSString*)kMDItemTitle forKey:@"dc:title"];
@@ -64,7 +64,7 @@ static NSDictionary *metaXML2MDIKeys;
[tempDict setObject:@"org_openoffice_opendocument_custominfo4"
forKey:@"Info 4"];
metaXML2MDIKeys = [[NSDictionary dictionaryWithDictionary:tempDict]
retain];
[tempDict release];
-
+
isInitialized = YES;
}
}
@@ -75,30 +75,30 @@ static NSDictionary *metaXML2MDIKeys;
shouldReadCharacters = NO;
// currentElement = nil;
textCurrentElement = nil;
-
+
return self;
}
-
+
return nil;
}
- (void)parseXML:(NSData*)data intoDictionary:(NSMutableDictionary*)dict
{
metaValues = dict;
-
+
//NSLog(@"data: %@ %d", data, [data length]);
-
+
//init parser settings
shouldReadCharacters = NO;
-
+
NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data];
-
+
[parser setDelegate:self];
[parser setShouldResolveExternalEntities:NO];
[parser parse];
-
+
[parser release];
-
+
//NSLog(@"finished parsing meta");
}
@@ -114,7 +114,7 @@ static NSDictionary *metaXML2MDIKeys;
shouldReadCharacters = NO;
return;
}
-
+
if (shouldReadCharacters == YES) {
textCurrentElement = [NSMutableString new];
isCustom = [elementName isEqualToString:@"meta:user-defined"];
@@ -127,7 +127,7 @@ static NSDictionary *metaXML2MDIKeys;
//NSLog(@"start element %@", elementName);
}
-- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
+- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
// NSLog(@"</%@>", elementName);
if (shouldReadCharacters == YES) {
@@ -138,11 +138,11 @@ static NSDictionary *metaXML2MDIKeys;
mdiName = (NSString*)[metaXML2MDIKeys objectForKey:elementName];
}
//NSLog(@"mdiName: %@", mdiName);
-
+
if (mdiName == nil) {
return;
}
-
+
if ([singleValueXMLElements containsObject:elementName] == YES) {
[metaValues setObject:textCurrentElement forKey:mdiName];
} else {
@@ -165,7 +165,7 @@ static NSDictionary *metaXML2MDIKeys;
[customAttribute release];
}
}
-
+
//cleanup part 2
shouldReadCharacters = NO;
isCustom = NO;
@@ -177,18 +177,18 @@ static NSDictionary *metaXML2MDIKeys;
if (shouldReadCharacters == NO) {
return;
}
-
- // this delegate method might be called several times for a single
element,
+
+ // this delegate method might be called several times for a single element,
// so we have to collect the received data
[textCurrentElement appendString:string];
-
+
//NSLog(@"chars read: %@", string);
}
- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError
{
//NSLog(@"parsing finished with error");
- NSLog([NSString stringWithFormat:@"Error %i, Description: %@, Line: %i,
Column: %i", [parseError code],
+ NSLog([NSString stringWithFormat:@"Error %i, Description: %@, Line: %i,
Column: %i", [parseError code],
[[parser parserError] localizedDescription], [parser lineNumber],
[parser columnNumber]]);
}
diff --git a/main/extensions/source/macosx/spotlight/OOoSpotlightImporter.m
b/main/extensions/source/macosx/spotlight/OOoSpotlightImporter.m
index dc4fbbeb63..5d4dd27d79 100644
--- a/main/extensions/source/macosx/spotlight/OOoSpotlightImporter.m
+++ b/main/extensions/source/macosx/spotlight/OOoSpotlightImporter.m
@@ -1,5 +1,5 @@
/**************************************************************
- *
+ *
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -7,16 +7,16 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *
+ *
*************************************************************/
@@ -61,10 +61,10 @@ static NSDictionary *uti2kind;
[temp setObject:@"OpenDocument Drawing Template"
forKey:@"org.oasis.opendocument.graphics-template"];
[temp setObject:@"OpenOffice.org 1.0 Database"
forKey:@"org.openoffice.database"];
[temp setObject:@"OpenDocument Chart"
forKey:@"org.oasis.opendocument.chart"];
-
+
uti2kind = [[NSDictionary dictionaryWithDictionary:temp] retain];
[temp release];
-
+
isInitialized = YES;
}
}
@@ -74,12 +74,12 @@ static NSDictionary *uti2kind;
{
//NSLog(contentTypeUTI);
//NSLog(pathToFile);
-
+
NSString *itemKind = [uti2kind objectForKey:contentTypeUTI];
if (itemKind != nil) {
[attributes setObject:itemKind forKey:(NSString*)kMDItemKind];
}
-
+
//first check to see if this is a valid zipped file that contains a file
"meta.xml"
unzFile unzipFile = [self openZipFileAtPath:pathToFile];
@@ -88,7 +88,7 @@ static NSDictionary *uti2kind;
//NSLog(@"zip file not open");
return YES;
}
-
+
//first get the metadata
NSData *metaData = [self metaDataFileFromZip:unzipFile];
if (metaData == nil) {
@@ -97,7 +97,7 @@ static NSDictionary *uti2kind;
}
[metaData retain];
-
+
OOoMetaDataParser *parser = [OOoMetaDataParser new];
if (parser != nil) {
//parse and extract the data
@@ -106,16 +106,16 @@ static NSDictionary *uti2kind;
[metaData release];
[parser release];
-
+
//and now get the content
NSData *contentData = [self contentDataFileFromZip:unzipFile];
if (contentData == nil) {
unzClose(unzipFile);
return YES;
}
-
+
[contentData retain];
-
+
OOoContentDataParser *parser2 = [OOoContentDataParser new];
if (parser2 != nil) {
//parse and extract the data
@@ -126,7 +126,7 @@ static NSDictionary *uti2kind;
[parser2 release];
unzClose(unzipFile);
-
+
return YES;
}
@@ -134,26 +134,26 @@ static NSDictionary *uti2kind;
- (unzFile)openZipFileAtPath:(NSString*)pathToFile
{
unzFile unzipFile = nil;
-
+
const char *zipfilename = [pathToFile UTF8String];
-
+
if (zipfilename != nil)
{
unzipFile = unzOpen(zipfilename);
}
-
+
if (unzipFile == nil)
{
//NSLog(@"Cannot open %s",zipfilename);
return nil;
}
-
+
//NSLog(@"%s opened",zipfilename);
-
+
return unzipFile;
}
-/* metaDataFileFromZip extracts the file meta.xml from the zip file and
returns it as an NSData* structure
+/* metaDataFileFromZip extracts the file meta.xml from the zip file and
returns it as an NSData* structure
or nil if the metadata is not present */
- (NSData*) metaDataFileFromZip:(unzFile)unzipFile
{
@@ -163,11 +163,11 @@ static NSDictionary *uti2kind;
unzCloseCurrentFile(unzipFile);
return nil;
}
-
+
//open the current file
if (unzOpenCurrentFile(unzipFile) != UNZ_OK) {
//we hit an error, do cleanup
- unzCloseCurrentFile(unzipFile);
+ unzCloseCurrentFile(unzipFile);
unzClose(unzipFile);
return nil;
}
@@ -180,17 +180,17 @@ static NSDictionary *uti2kind;
//append the data until we are finished
[data appendData:[NSData dataWithBytes:(const void *)buffer
length:bytesRead]];
}
-
+
//we no longer need the file, so close it
unzCloseCurrentFile(unzipFile);
-
+
NSData *returnValue = [NSData dataWithData:data];
[data release];
-
+
return returnValue;
}
-/* contentDataFileFromZip extracts the file content.xml from the zip file and
returns it as an NSData* structure
+/* contentDataFileFromZip extracts the file content.xml from the zip file and
returns it as an NSData* structure
or nil if the metadata is not present */
- (NSData*) contentDataFileFromZip:(unzFile)unzipFile
{
@@ -200,30 +200,30 @@ static NSDictionary *uti2kind;
unzCloseCurrentFile(unzipFile);
return nil;
}
-
+
//open the current file
if (unzOpenCurrentFile(unzipFile) != UNZ_OK) {
//we hit an error, do cleanup
- unzCloseCurrentFile(unzipFile);
+ unzCloseCurrentFile(unzipFile);
unzClose(unzipFile);
return nil;
}
-
+
NSMutableData *data = [NSMutableData new];
-
+
unsigned buffer[BUFFER_SIZE];
int bytesRead = 0;
while ((bytesRead = unzReadCurrentFile(unzipFile, buffer, sizeof(buffer)))
> 0) {
//append the data
[data appendData:[NSData dataWithBytes:(const void *)buffer
length:bytesRead]];
}
-
+
//we no longer need the file, so close it
unzCloseCurrentFile(unzipFile);
-
+
NSData *returnValue = [NSData dataWithData:data];
[data release];
-
+
return returnValue;
}
diff --git a/main/extensions/source/macosx/spotlight/ioapi.m
b/main/extensions/source/macosx/spotlight/ioapi.m
index 52049ea64b..80ff761d8a 100644
--- a/main/extensions/source/macosx/spotlight/ioapi.m
+++ b/main/extensions/source/macosx/spotlight/ioapi.m
@@ -1,5 +1,5 @@
/**************************************************************
- *
+ *
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -7,16 +7,16 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *
+ *
*************************************************************/
diff --git a/main/extensions/source/macosx/spotlight/main.m
b/main/extensions/source/macosx/spotlight/main.m
index 81570c9637..a76c7e5ae1 100644
--- a/main/extensions/source/macosx/spotlight/main.m
+++ b/main/extensions/source/macosx/spotlight/main.m
@@ -1,5 +1,5 @@
/**************************************************************
- *
+ *
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -7,16 +7,16 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *
+ *
*************************************************************/
//
@@ -63,12 +63,12 @@
//
-----------------------------------------------------------------------------
// The import function to be implemented in GetMetadataForFile.c
-Boolean GetMetadataForFile(void *thisInterface,
- CFMutableDictionaryRef attributes,
+Boolean GetMetadataForFile(void *thisInterface,
+ CFMutableDictionaryRef attributes,
CFStringRef contentTypeUTI,
CFStringRef pathToFile);
-
-// The layout for an instance of MetaDataImporterPlugIn
+
+// The layout for an instance of MetaDataImporterPlugIn
typedef struct __MetadataImporterPluginType
{
MDImporterInterfaceStruct *conduitInterface;
@@ -237,4 +237,3 @@ void *MetadataImporterPluginFactory(CFAllocatorRef
allocator,CFUUIDRef typeID)
/* If the requested type is incorrect, return NULL. */
return NULL;
}
-
diff --git a/main/extensions/source/macosx/spotlight/unzip.m
b/main/extensions/source/macosx/spotlight/unzip.m
index 6d439f6b76..7cddd8ca65 100644
--- a/main/extensions/source/macosx/spotlight/unzip.m
+++ b/main/extensions/source/macosx/spotlight/unzip.m
@@ -1,5 +1,5 @@
/**************************************************************
- *
+ *
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -7,16 +7,16 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *
+ *
*************************************************************/