Commit bd02a66d authored by Ivan.Shulga's avatar Ivan.Shulga Committed by Alexander Trofimov

added for macos version

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@56735 954022d7-b5bf-4e40-9824-e11837661b57
parent 479b07ef
/*
* Copyright (C) 2009 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Modified by Josh Aas of Mozilla Corporation.
*/
#ifndef ComplexTextInputPanel_h_
#define ComplexTextInputPanel_h_
#import <Cocoa/Cocoa.h>
#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5
@class NSTextInputContext;
#endif
@interface ComplexTextInputPanel : NSPanel {
NSTextView *mInputTextView;
}
+ (ComplexTextInputPanel*)sharedComplexTextInputPanel;
- (NSTextInputContext*)inputContext;
- (BOOL)interpretKeyEvent:(NSEvent*)event string:(NSString**)string;
- (void)cancelComposition;
- (BOOL)inComposition;
@end
#endif // ComplexTextInputPanel_h_
/*
* Copyright (C) 2009 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Modified by Josh Aas of Mozilla Corporation.
*/
#import "ComplexTextInputPanel.h"
#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5
@interface NSView (SnowLeopardMethods)
- (NSTextInputContext *)inputContext;
@end
// This is actually an NSTextInputContext method, but we can't declare
// that since the whole class is 10.6+.
@interface NSObject (SnowLeopardMethods)
- (BOOL)handleEvent:(NSEvent *)theEvent;
@end
static NSString* const NSTextInputContextKeyboardSelectionDidChangeNotification =
@"NSTextInputContextKeyboardSelectionDidChangeNotification";
#endif
#define kInputWindowHeight 20
@implementation ComplexTextInputPanel
+ (ComplexTextInputPanel*)sharedComplexTextInputPanel
{
static ComplexTextInputPanel *sComplexTextInputPanel;
if (!sComplexTextInputPanel)
sComplexTextInputPanel = [[ComplexTextInputPanel alloc] init];
return sComplexTextInputPanel;
}
- (id)init
{
// In the original Apple code the style mask is given by a function which is not open source.
// What could possibly be worth hiding in that function, I do not know.
// Courtesy of gdb: stylemask: 011000011111, 0x61f
self = [super initWithContentRect:NSZeroRect styleMask:0x61f backing:NSBackingStoreBuffered defer:YES];
if (!self)
return nil;
// Set the frame size.
NSRect visibleFrame = [[NSScreen mainScreen] visibleFrame];
NSRect frame = NSMakeRect(visibleFrame.origin.x, visibleFrame.origin.y, visibleFrame.size.width, kInputWindowHeight);
[self setFrame:frame display:NO];
mInputTextView = [[NSTextView alloc] initWithFrame:[self.contentView frame]];
mInputTextView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable | NSViewMaxXMargin | NSViewMinXMargin | NSViewMaxYMargin | NSViewMinYMargin;
NSScrollView* scrollView = [[NSScrollView alloc] initWithFrame:[self.contentView frame]];
scrollView.documentView = mInputTextView;
self.contentView = scrollView;
[scrollView release];
[self setFloatingPanel:YES];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardInputSourceChanged:)
name:NSTextInputContextKeyboardSelectionDidChangeNotification
object:nil];
return self;
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
[mInputTextView release];
[super dealloc];
}
- (void)keyboardInputSourceChanged:(NSNotification *)notification
{
[self cancelComposition];
}
- (BOOL)interpretKeyEvent:(NSEvent*)event string:(NSString**)string
{
BOOL hadMarkedText = [mInputTextView hasMarkedText];
*string = nil;
if (![[mInputTextView inputContext] handleEvent:event])
return NO;
if ([mInputTextView hasMarkedText]) {
// Don't show the input method window for dead keys
if ([[event characters] length] > 0)
[self orderFront:nil];
return YES;
} else {
[self orderOut:nil];
NSString *text = [[mInputTextView textStorage] string];
if ([text length] > 0)
*string = [[text copy] autorelease];
}
[mInputTextView setString:@""];
return hadMarkedText;
}
- (NSTextInputContext*)inputContext
{
return [mInputTextView inputContext];
}
- (void)cancelComposition
{
[mInputTextView setString:@""];
[self orderOut:nil];
}
- (BOOL)inComposition
{
return [mInputTextView hasMarkedText];
}
@end
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Chimera code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Simon Fraser <sfraser@netscape.com>
* Bruce Davidson <Bruce.Davidson@ipl.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#import <AppKit/AppKit.h>
extern NSString* const kCorePasteboardFlavorType_url;
extern NSString* const kCorePasteboardFlavorType_urln;
extern NSString* const kCorePasteboardFlavorType_urld;
extern NSString* const kCaminoBookmarkListPBoardType;
extern NSString* const kWebURLsWithTitlesPboardType;
@interface NSPasteboard(ChimeraPasteboardURLUtils)
- (int) declareURLPasteboardWithAdditionalTypes:(NSArray*)additionalTypes owner:(id)newOwner;
- (void) setDataForURL:(NSString*)url title:(NSString*)title;
- (void) setURLs:(NSArray*)inUrls withTitles:(NSArray*)inTitles;
- (void) getURLs:(NSArray**)outUrls
andTitles:(NSArray**)outTitles
convertingFilenames:(BOOL)convertFilenames;
- (BOOL) containsURLData;
@end
@interface NSPasteboard(ChromiumHTMLUtils)
// Returns the HTML converted from RTF data on the pasteboard. If there is
// none, returns an empty string.
- (NSString*)htmlFromRtf;
@end
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#import <Cocoa/Cocoa.h>
@interface NSScreen (CHScreenAdditions)
+ (NSScreen*)screenForPoint:(NSPoint)point;
@end
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#import "NSScreen+Utils.h"
@implementation NSScreen (CHScreenAdditions)
+ (NSScreen*)screenForPoint:(NSPoint)point
{
NSArray* screens = [NSScreen screens];
NSEnumerator* screenEnum = [screens objectEnumerator];
NSScreen* screen;
while ( (screen = [screenEnum nextObject]) ) {
NSRect frame = [screen frame];
if (NSPointInRect(point, frame))
break;
}
return screen;
}
@end
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Chimera code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Simon Fraser <sfraser@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#import <Foundation/Foundation.h>
typedef enum
{
kTruncateAtStart,
kTruncateAtMiddle,
kTruncateAtEnd
} ETruncationType;
// a category to extend NSString
@interface NSString (ChimeraStringUtils)
+ (id)ellipsisString;
+ (NSString*)stringWithUUID;
- (BOOL)isEqualToStringIgnoringCase:(NSString*)inString;
- (BOOL)hasCaseInsensitivePrefix:(NSString*)inString;
// Some URIs can contain spaces and still work, even though they aren't strictly valid
// per RFC2396. This method allows us to account for those URIs.
- (BOOL)isLooselyValidatedURI;
// Utility method to identify URIs that can be run in the context of the current page.
// These URIs could be used as attack vectors via AppleScript, for example.
- (BOOL)isPotentiallyDangerousURI;
// Utility method to ensure validity of URI strings. NSURL is used to validate
// most of them, but the NSURL test may fail for |javascript:| and |data:| URIs
// because they often contain invalid (per RFC2396) characters such as spaces.
- (BOOL)isValidURI;
- (NSString *)stringByRemovingCharactersInSet:(NSCharacterSet*)characterSet;
- (NSString *)stringByReplacingCharactersInSet:(NSCharacterSet*)characterSet withString:(NSString*)string;
- (NSString *)stringByTruncatingTo:(unsigned int)maxCharacters at:(ETruncationType)truncationType;
- (NSString *)stringByTruncatingToWidth:(float)inWidth at:(ETruncationType)truncationType withAttributes:(NSDictionary *)attributes;
- (NSString *)stringByTrimmingWhitespace;
- (NSString *)stringByRemovingAmpEscapes;
- (NSString *)stringByAddingAmpEscapes;
@end
@interface NSMutableString (ChimeraMutableStringUtils)
- (void)truncateTo:(unsigned)maxCharacters at:(ETruncationType)truncationType;
- (void)truncateToWidth:(float)maxWidth at:(ETruncationType)truncationType withAttributes:(NSDictionary *)attributes;
@end
@interface NSString (ChimeraFilePathStringUtils)
- (NSString*)volumeNamePathComponent;
- (NSString*)displayNameOfLastPathComponent;
@end
@interface NSString (CaminoURLStringUtils)
// Returns true if the string represents a "blank" URL ("" or "about:blank")
- (BOOL)isBlankURL;
// Returns a URI that looks good in a location field
- (NSString *)unescapedURI;
@end
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Camino code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Nate Weaver (Wevah) - wevah@derailer.org
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#import <Cocoa/Cocoa.h>
@interface NSURL (CaminoExtensions)
// This takes an NSURL to a local file, and if that file is a file that
// represents a URL, returns the URL it contains. Otherwise, returns the
// passed URL. Supports .url, .webloc and .ftploc files.
+ (NSURL*)decodeLocalFileURL:(NSURL*)url;
+(NSURL*)URLFromInetloc:(NSString*)inFile;
+(NSURL*)URLFromIEURLFile:(NSString*)inFile;
@end
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Camino code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Nate Weaver (Wevah) - wevah@derailer.org
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#import "NSURL+Utils.h"
@implementation NSURL (CaminoExtensions)
+ (NSURL*)decodeLocalFileURL:(NSURL*)url
{
NSString* urlPathString = [url path];
NSString* ext = [[urlPathString pathExtension] lowercaseString];
OSType fileType = NSHFSTypeCodeFromFileType(NSHFSTypeOfFile(urlPathString));
if ([ext isEqualToString:@"url"] || fileType == 'LINK') {
url = [NSURL URLFromIEURLFile:urlPathString];
}
else if ([ext isEqualToString:@"webloc"] || [ext isEqualToString:@"ftploc"] ||
fileType == 'ilht' || fileType == 'ilft')
{
url = [NSURL URLFromInetloc:urlPathString];
}
return url;
}
//
// Reads the URL from a .webloc/.ftploc file.
// Returns the URL, or nil on failure.
//
+(NSURL*)URLFromInetloc:(NSString*)inFile
{
FSRef ref;
NSURL *ret = nil;
if (inFile && FSPathMakeRef((UInt8 *)[inFile fileSystemRepresentation], &ref, NULL) == noErr) {
short resRef;
resRef = FSOpenResFile(&ref, fsRdPerm);
if (resRef != -1) { // Has resouce fork.
Handle urlResHandle;
if ((urlResHandle = Get1Resource('url ', 256))) { // Has 'url ' resource with ID 256.
long size;
size = GetMaxResourceSize(urlResHandle);
// Begin Google Modified
// ret = [NSURL URLWithString:[NSString stringWithCString:(char *)*urlResHandle length:size]];
NSString *urlString = [[[NSString alloc] initWithBytes:(void *)*urlResHandle
length:size
encoding:NSMacOSRomanStringEncoding] // best guess here
autorelease];
ret = [NSURL URLWithString:urlString];
// End Google Modified
}
CloseResFile(resRef);
}
if (!ret) { // Look for valid plist data.
NSDictionary *plist;
if ((plist = [[NSDictionary alloc] initWithContentsOfFile:inFile])) {
ret = [NSURL URLWithString:[plist objectForKey:@"URL"]];
[plist release];
}
}
}
return ret;
}
//
// Reads the URL from a .url file.
// Returns the URL or nil on failure.
//
+(NSURL*)URLFromIEURLFile:(NSString*)inFile
{
NSURL *ret = nil;
// Is this really an IE .url file?
if (inFile) {
NSCharacterSet *newlines = [NSCharacterSet characterSetWithCharactersInString:@"\r\n"];
// Begin Google Modified
// NSScanner *scanner = [NSScanner scannerWithString:[NSString stringWithContentsOfFile:inFile]];
NSString *fileString = [NSString stringWithContentsOfFile:inFile
encoding:NSWindowsCP1252StringEncoding // best guess here
error:nil];
NSScanner *scanner = [NSScanner scannerWithString:fileString];
// End Google Modified
[scanner scanUpToString:@"[InternetShortcut]" intoString:nil];
if ([scanner scanString:@"[InternetShortcut]" intoString:nil]) {
// Scan each non-empty line in this section. We don't need to explicitly scan the newlines or
// whitespace because NSScanner ignores these by default.
NSString *line;
while ([scanner scanUpToCharactersFromSet:newlines intoString:&line]) {
if ([line hasPrefix:@"URL="]) {
ret = [NSURL URLWithString:[line substringFromIndex:4]];
break;
}
else if ([line hasPrefix:@"["]) {
// This is the start of a new section, so if we haven't found an URL yet, we should bail.
break;
}
}
}
}
return ret;
}
@end
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Simon Fraser <smfr@smfr.org>
* Josh Aas <josh@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#import <AppKit/AppKit.h>
@interface NSWorkspace(CaminoDefaultBrowserAdditions)
- (NSArray*)installedBrowserIdentifiers; // sort order not specified
- (NSString*)defaultBrowserIdentifier;
- (NSURL*)defaultBrowserURL;
- (NSArray*)installedFeedViewerIdentifiers;
- (NSString*)defaultFeedViewerIdentifier;
- (NSURL*)defaultFeedViewerURL;
- (void)setDefaultBrowserWithIdentifier:(NSString*)bundleID;
- (void)setDefaultFeedViewerWithIdentifier:(NSString*)bundleID;
- (NSURL*)urlOfApplicationWithIdentifier:(NSString*)bundleID;
- (NSString*)identifierForBundle:(NSURL*)inBundleURL;
- (NSString*)displayNameForFile:(NSURL*)inFileURL;
// OS feature checks
+ (NSString*)osVersionString;
+ (BOOL)isLeopardOrHigher;
@end
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Simon Fraser <smfr@smfr.org>
* Josh Aas <josh@mozilla.com>
* Nick Kreeger <nick.kreeger@park.edu>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#import "NSWorkspace+Utils.h"
@implementation NSWorkspace(CaminoDefaultBrowserAdditions)
- (NSArray*)installedBrowserIdentifiers
{
NSArray* apps = [(NSArray*)LSCopyAllHandlersForURLScheme(CFSTR("https")) autorelease];
// add the default if it isn't there
NSString* defaultHandler = [self defaultBrowserIdentifier];
if (defaultHandler && ([apps indexOfObject:defaultHandler] == NSNotFound))
apps = [apps arrayByAddingObject:defaultHandler];
return apps;
}
- (NSArray*)installedFeedViewerIdentifiers
{
NSArray* apps = [(NSArray*)LSCopyAllHandlersForURLScheme(CFSTR("feed")) autorelease];
// add the default if it isn't there
NSString* defaultHandler = [self defaultFeedViewerIdentifier];
if (defaultHandler && ([apps indexOfObject:defaultHandler] == NSNotFound))
apps = [apps arrayByAddingObject:defaultHandler];
return apps;
}
- (NSString*)defaultBrowserIdentifier
{
NSString* defaultBundleId = [(NSString*)LSCopyDefaultHandlerForURLScheme(CFSTR("http")) autorelease];
// Sometimes LaunchServices likes to pretend there's no default browser.
// If that happens, we'll assume it's probably Safari.
if (!defaultBundleId)
defaultBundleId = @"com.apple.safari";
return defaultBundleId;
}
- (NSString*)defaultFeedViewerIdentifier
{
return [(NSString*)LSCopyDefaultHandlerForURLScheme(CFSTR("feed")) autorelease];
}
- (NSURL*)defaultBrowserURL
{
NSString* defaultBundleId = [self defaultBrowserIdentifier];
if (defaultBundleId)
return [self urlOfApplicationWithIdentifier:defaultBundleId];
return nil;
}
- (NSURL*)defaultFeedViewerURL
{
NSString* defaultBundleId = [self defaultFeedViewerIdentifier];
if (defaultBundleId)
return [self urlOfApplicationWithIdentifier:defaultBundleId];
return nil;
}
- (void)setDefaultBrowserWithIdentifier:(NSString*)bundleID
{
LSSetDefaultHandlerForURLScheme(CFSTR("http"), (CFStringRef)bundleID);
LSSetDefaultHandlerForURLScheme(CFSTR("https"), (CFStringRef)bundleID);
LSSetDefaultRoleHandlerForContentType(kUTTypeHTML, kLSRolesViewer, (CFStringRef)bundleID);
LSSetDefaultRoleHandlerForContentType(kUTTypeURL, kLSRolesViewer, (CFStringRef)bundleID);
}
- (void)setDefaultFeedViewerWithIdentifier:(NSString*)bundleID
{
LSSetDefaultHandlerForURLScheme(CFSTR("feed"), (CFStringRef)bundleID);
}
- (NSURL*)urlOfApplicationWithIdentifier:(NSString*)bundleID
{
if (!bundleID)
return nil;
NSURL* appURL = nil;
if (LSFindApplicationForInfo(kLSUnknownCreator, (CFStringRef)bundleID, NULL, NULL, (CFURLRef*)&appURL) == noErr)
return [appURL autorelease];
return nil;
}
- (NSString*)identifierForBundle:(NSURL*)inBundleURL
{
if (!inBundleURL) return nil;
NSBundle* tmpBundle = [NSBundle bundleWithPath:[[inBundleURL path] stringByStandardizingPath]];
if (tmpBundle)
{
NSString* tmpBundleID = [tmpBundle bundleIdentifier];
if (tmpBundleID && ([tmpBundleID length] > 0)) {
return tmpBundleID;
}
}
return nil;
}
- (NSString*)displayNameForFile:(NSURL*)inFileURL
{
NSString *name;
LSCopyDisplayNameForURL((CFURLRef)inFileURL, (CFStringRef *)&name);
return [name autorelease];
}
//
// +osVersionString
//
// Returns the system version string from
// /System/Library/CoreServices/SystemVersion.plist
// (as recommended by Apple).
//
+ (NSString*)osVersionString
{
NSDictionary* versionInfo = [NSDictionary dictionaryWithContentsOfFile:@"/System/Library/CoreServices/SystemVersion.plist"];
return [versionInfo objectForKey:@"ProductVersion"];
}
//
// +systemVersion
//
// Returns the host's OS version as returned by the 'sysv' gestalt selector,
// 10.x.y = 0x000010xy
//
+ (long)systemVersion
{
static SInt32 sSystemVersion = 0;
if (!sSystemVersion)
Gestalt(gestaltSystemVersion, &sSystemVersion);
return (long)sSystemVersion;
}
//
// +isLeopardOrHigher
//
// returns YES if we're on 10.5 or better
//
+ (BOOL)isLeopardOrHigher
{
#if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4
return YES;
#else
return [self systemVersion] >= 0x1050;
#endif
}
@end
Name: Cocoa extension code from Camino
Short Name: camino
URL: http://caminobrowser.org/
Version: unknown
License: MPL 1.1/GPL 2.0/LGPL 2.1
Description:
This directory contains the following files come from (Mozilla) Camino
(src/camino/src/extensions):
NSPasteboard+Utils.h/mm
NSScreen+Utils.h/m
NSString+Utils.h/m
NSURL+Utils.h/m
NSWorkspace+Utils.h/m
Local modifications:
- NSURL+Utils.m was modified to use non-deprecated Cocoa APIs to allow
compilation on future versions of Mac OS X.
- NSString+Utils.m was renamed to NSString+Utils.mm and modified to use GURL
for validation in -[NSString isValidURI].
- NSPasteboard+Utils.mm was modified to add an argument to
-[NSPasteboard getURLs:andTitles:] to determine whether or not filenames in
the drag should be converted to file URLs.
-[NSPasteboard htmlFromRtf] added to do rtf->html conversion.
- NSWorkspace+Utils.m was modified to compile on the x86_64 architecture.
-----------------------------------------------------------------
Also includes IME panel from Gecko, which is based on WebKit's implementation.
Although it comes from Mozilla (http://mxr.mozilla.org), it uses the original
WebKit license.
Local modifitations:
- Add #ifdef'd definifitions of a few symbols to support 10.5 SDK.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment