Permalink
Browse files

Changes required for supporting Apple appstore.

- Use system instaled WebKit.
- Update some deprecated OSX APIs.
- Bump up min deployment to 10.5
  • Loading branch information...
1 parent d68f4bb commit 779eaaf7da0edf0c50ba03f5e817236e0678ae1f Josh Roesslein committed Mar 11, 2011
@@ -100,8 +100,8 @@ -(void)dealloc
if (temporaryDirectory)
{
- [[NSFileManager defaultManager]
- removeFileAtPath:temporaryDirectory handler:nil];
+ [[NSFileManager defaultManager]
+ removeItemAtPath:temporaryDirectory error:nil];
[temporaryDirectory release];
}
@@ -662,7 +662,7 @@ -(void)applicationDidFinishLaunching:(NSNotification *) notif
// Remove the update file as soon as possible, so that if the installation
// fails the application will still start. We can always fetch the update
// later.
- [[NSFileManager defaultManager] removeFileAtPath:updateFile handler:nil];
+ [[NSFileManager defaultManager] removeItemAtPath:updateFile error:nil];
}
std::string tempDir = FileUtils::GetTempDirectory();
@@ -598,7 +598,7 @@ void File::GetSpaceAvailable(const ValueList& args, KValueRef result)
#ifdef OS_OSX
NSString *p = [NSString stringWithCString:this->filename.c_str() encoding:NSUTF8StringEncoding];
- unsigned long avail = [[[[NSFileManager defaultManager] fileSystemAttributesAtPath:p] objectForKey:NSFileSystemFreeSize] longValue];
+ unsigned long avail = [[[[NSFileManager defaultManager] attributesOfFileSystemForPath:p error:nil] objectForKey:NSFileSystemFreeSize] longValue];
diskSize = (double)avail;
#elif defined(OS_WIN32)
unsigned __int64 i64FreeBytesToCaller;
@@ -9,6 +9,13 @@ build.add_thirdparty(env, 'poco')
build.add_thirdparty(env, 'webkit')
env.Append(LIBS=['tiappmodule'])
+# If we are on Mac use the system installed WebKit.
+# Otherwise use our build of WebKit on all other platforms.
+if build.is_osx():
+ env.Append(FRAMEWORKS=['WebKit', 'JavaScriptCore'])
+else:
+ build.add_thirdparty(env, 'webkit')
+
sources = Glob('*.cpp') + ['url/URLUtils.cpp']
if build.is_linux():
sources = sources + Glob('gtk/*.cpp')
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2009-2010 Appcelerator, Inc. All Rights Reserved.
- *
- * Licensed 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 "ScriptEvaluator.h"
-
-#include <algorithm>
-#include <cstring>
-
-#include <kroll/javascript/javascript_module.h>
-
-namespace Titanium {
-
-/*static*/
-void ScriptEvaluator::Initialize()
-{
- static AutoPtr<ScriptEvaluator> instance(new ScriptEvaluator());
-#if defined(OS_OSX)
- [WebScriptElement addScriptEvaluator:[[OSXScriptEvaluator alloc]
- initWithEvaluator:instance.get()]];
-#elif defined(OS_WIN32)
- addScriptEvaluator(instance.get());
-#elif defined(OS_LINUX)
- webkit_titanium_add_script_evaluator(instance.get());
-#endif
-}
-
-} // namespace Titanium
-
-#if defined(OS_OSX)
-@implementation OSXScriptEvaluator
--(OSXScriptEvaluator*) initWithEvaluator:(Titanium::ScriptEvaluator*)evaluator
-{
- self = [self init];
- delegate = evaluator;
- return self;
-}
-
--(BOOL) matchesMimeType:(NSString*)mimeType
-{
- return kroll::Script::GetInstance()->CanEvaluate([mimeType UTF8String]);
-}
-
--(void) evaluate:(NSString *)mimeType sourceCode:(NSString*)sourceCode context:(void *)context
-{
- // TODO get source name from webkit
- try
- {
- Script::GetInstance()->Evaluate([mimeType UTF8String], "<script>",
- [sourceCode UTF8String], JSContextToKrollContext(context));
- }
- catch (ValueException& exception)
- {
- Logger::Get("UI.ScriptEvaluator")->Error("Script evaluation failed: %s",
- exception.ToString().c_str());
- }
-}
-@end
-#endif
@@ -1,140 +0,0 @@
-/*
- * Copyright (c) 2009-2010 Appcelerator, Inc. All Rights Reserved.
- *
- * Licensed 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.
- */
-
-#ifndef ScriptEvaluator_h
-#define ScriptEvaluator_h
-
-#include <kroll/kroll.h>
-#include <Poco/URI.h>
-
-#if defined(OS_OSX)
-# import <WebKit/WebKit.h>
-# import <WebKit/WebViewPrivate.h>
-# import <WebKit/WebInspector.h>
-# import <WebKit/WebScriptDebugDelegate.h>
-# import <WebKit/WebScriptObject.h>
-# import <WebKit/WebPreferencesPrivate.h>
-# import <WebKit/WebScriptElement.h>
-#elif defined(OS_LINUX)
-# include <webkit/webkit.h>
-# include <webkit/webkittitanium.h>
-#else
-# include <WebKit/WebKit.h>
-# include <WebKit/WebKitCOMAPI.h>
-# include <WebKit/WebKitTitanium.h>
-# include <comutil.h>
-#endif
-
-#include <kroll/javascript/javascript_module.h>
-
-#define JSContextToKrollContext(context) \
- new KKJSObject(reinterpret_cast<JSContextRef>(context), JSContextGetGlobalObject(reinterpret_cast<JSContextRef>(context)))
-
-namespace Titanium {
-
-/*
- * Script evaluators are responsible for matching and
- * evaluating custom <script> types, and preprocessing URLs.
- */
-class ScriptEvaluator
-#if defined(OS_WIN32)
- : public IWebScriptEvaluator, public COMReferenceCounted
-#elif defined(OS_LINUX)
- : public WebKitWebScriptEvaluator, public ReferenceCounted
-#else
- : public ReferenceCounted
-#endif
-{
- public:
- static void Initialize();
-
- protected:
- ScriptEvaluator() {}
-
- public:
-#if defined(OS_WIN32)
- virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject)
- {
- return COMReferenceCounted::QueryInterface(riid,ppvObject);
- }
- virtual ULONG STDMETHODCALLTYPE AddRef(void)
- {
- return COMReferenceCounted::AddRef();
- }
- virtual ULONG STDMETHODCALLTYPE Release(void)
- {
- return COMReferenceCounted::Release();
- }
- virtual HRESULT STDMETHODCALLTYPE matchesMimeType(BSTR mimeType, BOOL *result)
- {
- *result = kroll::Script::GetInstance()->CanEvaluate((const char *)_bstr_t(mimeType));
- return S_OK;
- }
- virtual HRESULT STDMETHODCALLTYPE evaluate(BSTR mimeType, BSTR sourceCode, int* context)
- {
- try
- {
- kroll::Script::GetInstance()->Evaluate(
- (const char *)_bstr_t(mimeType), "<script>",
- (const char *)_bstr_t(sourceCode),
- JSContextToKrollContext(context));
- }
- catch (ValueException& exception)
- {
- Logger::Get("UI.ScriptEvaluator")->Error("Script evaluation failed: %s",
- exception.ToString().c_str());
-
- }
- return S_OK;
- }
-#elif defined(OS_LINUX)
- virtual bool matchesMimeType(const gchar *mimeType)
- {
- return kroll::Script::GetInstance()->CanEvaluate(mimeType);
- }
- virtual void evaluate(const gchar *mimeType, const gchar *sourceCode, void* context)
- {
- try
- {
- kroll::Script::GetInstance()->Evaluate(mimeType, "<script>",
- sourceCode, JSContextToKrollContext(context));
- }
- catch (ValueException& exception)
- {
- Logger::Get("UI.ScriptEvaluator")->Error("Script evaluation failed: %s",
- exception.ToString().c_str());
-
- }
- }
-#endif
-};
-
-} // namespace Titanium
-
-#if defined(OS_OSX)
-@interface OSXScriptEvaluator : NSObject
-{
- Titanium::ScriptEvaluator* delegate;
-}
--(OSXScriptEvaluator*) initWithEvaluator:(Titanium::ScriptEvaluator*)evaluator;
--(BOOL) matchesMimeType:(NSString*)mimeType;
--(void) evaluate:(NSString *)mimeType sourceCode:(NSString*)sourceCode context:(void *)context;
-@end
-#elif defined(OS_LINUX)
- extern void addScriptEvaluator(WebKitWebScriptEvaluator *evaluator);
-#endif
-
-#endif
@@ -18,7 +18,6 @@
#include <Poco/URI.h>
-#include "ScriptEvaluator.h"
#include "../ti.App/ApplicationConfig.h"
#if defined(OS_OSX)
@@ -53,7 +52,6 @@ void UIModule::Start()
host->GetGlobalObject()->SetObject("UI", this->uiBinding);
host->GetGlobalObject()->SetObject("Notification", this->uiBinding);
- ScriptEvaluator::Initialize();
ApplicationConfig* config = ApplicationConfig::Instance();
if (!config)
{
@@ -18,13 +18,17 @@
#include "MenuMac.h"
-@interface MenuDelegate : NSObject
+@interface MenuDelegate : NSObject <NSMenuDelegate>
{
Titanium::MenuMac* menu;
BOOL dirty;
BOOL registerNative;
}
- (id)initWithMenu:(Titanium::MenuMac*)menu willRegister:(BOOL)willRegister;
+
+- (NSInteger)numberOfItemsInMenu:(NSMenu *)menu;
- (void)menuNeedsUpdate:(NSMenu *)menu;
+
- (void)markAsDirty;
+
@end
@@ -30,6 +30,12 @@ - (id)initWithMenu:(Titanium::MenuMac*)inMenu willRegister:(BOOL)willRegister
return self;
}
+- (NSInteger)numberOfItemsInMenu:(NSMenu *)menu
+{
+ // We will setup the menu in menuNeedsUpdate.
+ return -1;
+}
+
- (void)menuNeedsUpdate:(NSMenu *)nativeMenu
{
if (!dirty) {
@@ -79,10 +79,6 @@
// native menu will have to use the title of the item it is attached to.
[submenu setTitle:nstitle];
}
- if ([item menu] != nil)
- {
- [[item menu] sizeToFit];
- }
}
/*static*/
@@ -105,10 +101,6 @@
[item setImage:nil];
}
- if ([item menu] != nil) {
- [[item menu] sizeToFit];
- }
-
if (needsRelease) {
[image release];
}
@@ -198,7 +198,6 @@
int index = [nativeMenu numberOfItems] - rearOffset;
[nativeMenu insertItem:nativeItem atIndex:index];
}
- [nativeMenu sizeToFit];
}
void MenuMac::AddChildrenToNSArray(NSMutableArray* array)
@@ -21,8 +21,6 @@
#import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h>
-#import <WebKit/WebInspector.h>
-
#include "../../ti.App/WindowConfig.h"
namespace Titanium {
@@ -33,14 +31,13 @@ class UserWindowMac;
@class WebViewDelegate;
-@interface NativeWindow : NSWindow
+@interface NativeWindow : NSWindow <NSWindowDelegate>
{
BOOL canReceiveFocus;
WebView* webView;
WebViewDelegate* delegate;
BOOL requiresDisplay;
AutoPtr<Titanium::UserWindowMac>* userWindow;
- WebInspector* inspector;
BOOL fullscreen;
BOOL focused;
NSRect savedFrame;
Oops, something went wrong. Retry.

0 comments on commit 779eaaf

Please sign in to comment.