Merge branch 'master' of github.com:jeena/Bungloo

This commit is contained in:
Jeena Paradies 2013-02-15 19:12:29 +01:00
commit f0f564a577
39 changed files with 850 additions and 849 deletions

View file

@ -2,7 +2,7 @@
BSD license BSD license
=========== ===========
Copyright (c) 2010, Jeena Paradies Copyright (c) 2013, Jeena Paradies
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without

View file

@ -10,119 +10,119 @@ import os
import array import array
class WebPage(QtWebKit.QWebPage): class WebPage(QtWebKit.QWebPage):
def __init__(self, parent=0, app=None): def __init__(self, parent=0, app=None):
super(QtWebKit.QWebPage, self).__init__(parent) super(QtWebKit.QWebPage, self).__init__(parent)
self.setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateExternalLinks) self.setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateExternalLinks)
self.app = app self.app = app
def javaScriptConsoleMessage(self, message, lineNumber, sourceId): def javaScriptConsoleMessage(self, message, lineNumber, sourceId):
print str(message) + " on line: " + str(lineNumber) + " Source: " + str(sourceId) print str(message) + " on line: " + str(lineNumber) + " Source: " + str(sourceId)
def checkRequest(self, request): def checkRequest(self, request):
print request print request
class WebViewCreator(QtWebKit.QWebView): class WebViewCreator(QtWebKit.QWebView):
def __init__(self, app, local=True, parent=None): def __init__(self, app, local=True, parent=None):
if parent != None: if parent != None:
QtGui.QWidget.__init__(self) QtGui.QWidget.__init__(self)
else: else:
QtGui.QWidget.__init__(self) QtGui.QWidget.__init__(self)
self.app = app self.app = app
self.is_local = local self.is_local = local
self.connect(self, SIGNAL("linkClicked (const QUrl&)"), self.app.controller.openQURL) self.connect(self, SIGNAL("linkClicked (const QUrl&)"), self.app.controller.openQURL)
self.setPage(WebPage(self, self.app)) self.setPage(WebPage(self, self.app))
def load_local(self, callback=None): def load_local(self, callback=None):
self.page().settings().setAttribute(QtWebKit.QWebSettings.LocalContentCanAccessRemoteUrls, True) self.page().settings().setAttribute(QtWebKit.QWebSettings.LocalContentCanAccessRemoteUrls, True)
self.page().settings().setAttribute(QtWebKit.QWebSettings.LocalStorageEnabled, True) self.page().settings().setAttribute(QtWebKit.QWebSettings.LocalStorageEnabled, True)
self.loadFinished.connect(lambda ok: self.load_finished(ok, callback)) self.loadFinished.connect(lambda ok: self.load_finished(ok, callback))
frame = self.page().mainFrame() frame = self.page().mainFrame()
frame.addToJavaScriptWindowObject("controller", self.app.controller) frame.addToJavaScriptWindowObject("controller", self.app.controller)
frame.addToJavaScriptWindowObject("__console", self.app.console) frame.addToJavaScriptWindowObject("__console", self.app.console)
url = self.app.resources_uri() + "/index.html" url = self.app.resources_uri() + "/index.html"
self.load(QtCore.QUrl(url)) self.load(QtCore.QUrl(url))
def load_url(self, url, callback=None): def load_url(self, url, callback=None):
self.loadFinished.connect(lambda ok: self.load_finished(ok, callback)) self.loadFinished.connect(lambda ok: self.load_finished(ok, callback))
self.load(QtCore.QUrl(url)) self.load(QtCore.QUrl(url))
def load_finished(self, ok, callback=None): def load_finished(self, ok, callback=None):
frame = self.page().mainFrame() frame = self.page().mainFrame()
if self.is_local: if self.is_local:
frame.evaluateJavaScript("var OS_TYPE = 'linux';") frame.evaluateJavaScript("var OS_TYPE = 'linux';")
js_plugin_path = os.path.expanduser('~/.bungloo/Plugin.js') js_plugin_path = os.path.expanduser('~/.bungloo/Plugin.js')
if os.access(js_plugin_path, os.R_OK): if os.access(js_plugin_path, os.R_OK):
func = "setTimeout(function() { loadJsPlugin('file://localhost" + js_plugin_path + "') }, 1000);" func = "setTimeout(function() { loadJsPlugin('file://localhost" + js_plugin_path + "') }, 1000);"
frame.evaluateJavaScript(func) frame.evaluateJavaScript(func)
css_plugin_path = os.path.expanduser('~/.bungloo/Plugin.css') css_plugin_path = os.path.expanduser('~/.bungloo/Plugin.css')
if os.access(css_plugin_path, os.R_OK): if os.access(css_plugin_path, os.R_OK):
func = "setTimeout(function() { loadCssPlugin('file://localhost" + css_plugin_path + "') }, 1000);" func = "setTimeout(function() { loadCssPlugin('file://localhost" + css_plugin_path + "') }, 1000);"
frame.evaluateJavaScript(func) frame.evaluateJavaScript(func)
if callback: if callback:
callback(ok) callback(ok)
class NetworkAccessManager(QNetworkAccessManager): class NetworkAccessManager(QNetworkAccessManager):
def __init__(self, old_manager, bungloo_callback): def __init__(self, old_manager, bungloo_callback):
QNetworkAccessManager.__init__(self) QNetworkAccessManager.__init__(self)
self.bungloo_callback = bungloo_callback self.bungloo_callback = bungloo_callback
self.old_manager = old_manager self.old_manager = old_manager
self.setCache(old_manager.cache()) self.setCache(old_manager.cache())
self.setCookieJar(old_manager.cookieJar()) self.setCookieJar(old_manager.cookieJar())
self.setProxy(old_manager.proxy()) self.setProxy(old_manager.proxy())
self.setProxyFactory(old_manager.proxyFactory()) self.setProxyFactory(old_manager.proxyFactory())
def createRequest(self, operation, request, data): def createRequest(self, operation, request, data):
if request.url().scheme() != "bungloo": if request.url().scheme() != "bungloo":
return QNetworkAccessManager.createRequest(self, operation, request, data) return QNetworkAccessManager.createRequest(self, operation, request, data)
else: else:
self.bungloo_callback(request.url()) self.bungloo_callback(request.url())
return QNetworkAccessManager.createRequest(self, QNetworkAccessManager.GetOperation, QNetworkRequest(QtCore.QUrl())) return QNetworkAccessManager.createRequest(self, QNetworkAccessManager.GetOperation, QNetworkRequest(QtCore.QUrl()))
class PostModel: class PostModel:
def __init__(self): def __init__(self):
self.text = None self.text = None
self.inReplyTostatusId = None self.inReplyTostatusId = None
self.inReplyToEntity = None self.inReplyToEntity = None
self.location = None self.location = None
self.imageFilePath = None self.imageFilePath = None
self.isPrivate = False self.isPrivate = False
class RestorableWindow(QtGui.QMainWindow): class RestorableWindow(QtGui.QMainWindow):
def __init__(self, action, app): def __init__(self, action, app):
self.action = action self.action = action
self.app = app self.app = app
QtGui.QMainWindow.__init__(self) QtGui.QMainWindow.__init__(self)
self.restoreGeometry(QtCore.QByteArray.fromRawData(self.app.controller.stringForKey("mainWindowGeometry-" + self.action))) self.restoreGeometry(QtCore.QByteArray.fromRawData(self.app.controller.stringForKey("mainWindowGeometry-" + self.action)))
self.restoreState(QtCore.QByteArray.fromRawData(self.app.controller.stringForKey("mainWindowState-" + self.action))) self.restoreState(QtCore.QByteArray.fromRawData(self.app.controller.stringForKey("mainWindowState-" + self.action)))
def closeEvent(self, event): def closeEvent(self, event):
self._saveGeometry() self._saveGeometry()
def _saveGeometry(self): def _saveGeometry(self):
self.app.controller.setStringForKey(self.saveGeometry(), "mainWindowGeometry-" + self.action) self.app.controller.setStringForKey(self.saveGeometry(), "mainWindowGeometry-" + self.action)
self.app.controller.setStringForKey(self.saveState(), "mainWindowState-" + self.action) self.app.controller.setStringForKey(self.saveState(), "mainWindowState-" + self.action)
def hide(self): def hide(self):
self._saveGeometry() self._saveGeometry()
QtGui.QMainWindow.close(self) QtGui.QMainWindow.close(self)
def sizeHint(self): def sizeHint(self):
return QtCore.QSize(300, 500) return QtCore.QSize(300, 500)
def show(self): def show(self):
QtGui.QMainWindow.show(self) QtGui.QMainWindow.show(self)
self.activateWindow() self.activateWindow()
self.raise_() self.raise_()

View file

@ -13,109 +13,109 @@
- (id)init - (id)init
{ {
self = [super init]; self = [super init];
if (self) { if (self) {
// Initialization code here. // Initialization code here.
d = [NSUserDefaults standardUserDefaults]; d = [NSUserDefaults standardUserDefaults];
//[d removeObjectForKey:@"user_access_token"]; //[d removeObjectForKey:@"user_access_token"];
} }
return self; return self;
} }
- (void)setString:(NSString *)string forKey:(NSString *)aKey - (void)setString:(NSString *)string forKey:(NSString *)aKey
{ {
[d setObject:string forKey:aKey]; [d setObject:string forKey:aKey];
[d synchronize]; [d synchronize];
} }
- (NSString *)stringForKey:(NSString *)aKey - (NSString *)stringForKey:(NSString *)aKey
{ {
return [d objectForKey:aKey]; return [d objectForKey:aKey];
} }
- (void)setAccessToken:(NSString *)_accessToken - (void)setAccessToken:(NSString *)_accessToken
{ {
[d synchronize]; [d synchronize];
} }
- (NSString *)accessToken - (NSString *)accessToken
{ {
return [d objectForKey:@"accessToken"]; return [d objectForKey:@"accessToken"];
} }
- (void)setSecret:(NSString *)_secret - (void)setSecret:(NSString *)_secret
{ {
UInt32 _passwordLength = 0; UInt32 _passwordLength = 0;
char *_password = nil; char *_password = nil;
SecKeychainItemRef item = nil; SecKeychainItemRef item = nil;
SecKeychainFindGenericPassword(NULL, 6, "Bungloo", 17, "BunglooUserAccount", &_passwordLength, (void **)&_password, &item); SecKeychainFindGenericPassword(NULL, 6, "Bungloo", 17, "BunglooUserAccount", &_passwordLength, (void **)&_password, &item);
OSStatus status; OSStatus status;
void * passwordData = (void*)[_secret cStringUsingEncoding:NSUTF8StringEncoding]; void * passwordData = (void*)[_secret cStringUsingEncoding:NSUTF8StringEncoding];
UInt32 passwordLength = strlen((char*)passwordData); UInt32 passwordLength = strlen((char*)passwordData);
if (!item) if (!item)
{ {
status = SecKeychainAddGenericPassword( status = SecKeychainAddGenericPassword(
NULL, // default keychain NULL, // default keychain
6, // length of service name 6, // length of service name
"Bungloo", // service name "Bungloo", // service name
17, // length of account name 17, // length of account name
"BunglooUserAccount", // account name "BunglooUserAccount", // account name
passwordLength, // length of password passwordLength, // length of password
passwordData, // pointer to password data passwordData, // pointer to password data
NULL // the item reference NULL // the item reference
); );
} }
else else
{ {
status = SecKeychainItemModifyContent( status = SecKeychainItemModifyContent(
item, item,
NULL, NULL,
passwordLength, passwordLength,
passwordData passwordData
); );
} }
NSLog(@"%@",(NSString *)SecCopyErrorMessageString (status,NULL)); NSLog(@"%@",(NSString *)SecCopyErrorMessageString (status,NULL));
} }
- (NSString *)secret - (NSString *)secret
{ {
UInt32 passwordLength = 0; UInt32 passwordLength = 0;
char *password = nil; char *password = nil;
SecKeychainItemRef item = nil; SecKeychainItemRef item = nil;
SecKeychainFindGenericPassword(NULL, 6, "Bungloo", 17, "BunglooUserAccount", &passwordLength, (void **)&password, &item); SecKeychainFindGenericPassword(NULL, 6, "Bungloo", 17, "BunglooUserAccount", &passwordLength, (void **)&password, &item);
if (!item) { if (!item) {
return nil; return nil;
} }
//Get password //Get password
NSString *passwordString = [[[NSString alloc] initWithData:[NSData dataWithBytes:password length:passwordLength] encoding:NSUTF8StringEncoding] autorelease]; NSString *passwordString = [[[NSString alloc] initWithData:[NSData dataWithBytes:password length:passwordLength] encoding:NSUTF8StringEncoding] autorelease];
SecKeychainItemFreeContent(NULL, password); SecKeychainItemFreeContent(NULL, password);
return passwordString; return passwordString;
} }
- (void)setUserId:(NSString *)_userId - (void)setUserId:(NSString *)_userId
{ {
[d setObject:_userId forKey:@"userId"]; [d setObject:_userId forKey:@"userId"];
[d synchronize]; [d synchronize];
} }
- (NSString *)userId - (NSString *)userId
{ {
return [d objectForKey:@"userId"]; return [d objectForKey:@"userId"];
} }
- (void)setScreenName:(NSString *)_screenName - (void)setScreenName:(NSString *)_screenName
{ {
[d setObject:_screenName forKey:@"screenName"]; [d setObject:_screenName forKey:@"screenName"];
[d synchronize]; [d synchronize];
} }
- (NSString *)screenName - (NSString *)screenName
{ {
return [d objectForKey:@"screenName"]; return [d objectForKey:@"screenName"];
} }
+ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector { + (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector {

View file

@ -3,5 +3,5 @@
// //
#ifdef __OBJC__ #ifdef __OBJC__
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#endif #endif

View file

@ -21,20 +21,20 @@
IBOutlet NSWindow *timelineViewWindow; IBOutlet NSWindow *timelineViewWindow;
IBOutlet WebView *mentionsView; IBOutlet WebView *mentionsView;
IBOutlet NSWindow *mentionsViewWindow; IBOutlet NSWindow *mentionsViewWindow;
IBOutlet WebView *conversationView; IBOutlet WebView *conversationView;
IBOutlet NSWindow *conversationViewWindow; IBOutlet NSWindow *conversationViewWindow;
WebView *profileView; WebView *profileView;
NSWindow *profileViewWindow; NSWindow *profileViewWindow;
NSPanel *openProfileWindow; NSPanel *openProfileWindow;
NSWindow *loginViewWindow; NSWindow *loginViewWindow;
NSTextField *loginEntityTextField; NSTextField *loginEntityTextField;
NSProgressIndicator *loginActivityIndicator; NSProgressIndicator *loginActivityIndicator;
IBOutlet NSMenuItem *globalHotkeyMenuItem; IBOutlet NSMenuItem *globalHotkeyMenuItem;
IBOutlet NSImageView *logoLayer; IBOutlet NSImageView *logoLayer;
ViewDelegate *viewDelegate; ViewDelegate *viewDelegate;
WebView *oauthView; WebView *oauthView;
AccessToken *accessToken; AccessToken *accessToken;
NSTextField *showProfileTextField; NSTextField *showProfileTextField;
} }

View file

@ -24,12 +24,12 @@
- (void)awakeFromNib - (void)awakeFromNib
{ {
[timelineViewWindow setExcludedFromWindowsMenu:YES]; [timelineViewWindow setExcludedFromWindowsMenu:YES];
[mentionsViewWindow setExcludedFromWindowsMenu:YES]; [mentionsViewWindow setExcludedFromWindowsMenu:YES];
[self initHotKeys]; [self initHotKeys];
[GrowlApplicationBridge setGrowlDelegate:self]; [GrowlApplicationBridge setGrowlDelegate:self];
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self [nc addObserver:self
@ -56,27 +56,27 @@
andEventID:kAEGetURL]; andEventID:kAEGetURL];
viewDelegate = [[ViewDelegate alloc] init]; viewDelegate = [[ViewDelegate alloc] init];
accessToken = [[AccessToken alloc] init]; accessToken = [[AccessToken alloc] init];
BOOL forceLogin = NO; BOOL forceLogin = NO;
/* /*
if (![accessToken stringForKey:@"version-0.6.0-new-login"]) { if (![accessToken stringForKey:@"version-0.6.0-new-login"]) {
[self logout:self]; [self logout:self];
forceLogin = YES; forceLogin = YES;
[accessToken setString:nil forKey:@"entity"]; [accessToken setString:nil forKey:@"entity"];
[accessToken setString:@"yes" forKey:@"version-0.6.0-new-login"]; [accessToken setString:@"yes" forKey:@"version-0.6.0-new-login"];
}*/ }*/
if (forceLogin || ![accessToken stringForKey:@"user_access_token"] || ![accessToken secret]) { if (forceLogin || ![accessToken stringForKey:@"user_access_token"] || ![accessToken secret]) {
[timelineViewWindow performClose:self]; [timelineViewWindow performClose:self];
[mentionsViewWindow performClose:self]; [mentionsViewWindow performClose:self];
[self.loginViewWindow makeKeyAndOrderFront:self]; [self.loginViewWindow makeKeyAndOrderFront:self];
[self initOauth]; [self initOauth];
} else { } else {
[timelineViewWindow makeKeyAndOrderFront:self]; [timelineViewWindow makeKeyAndOrderFront:self];
[self initWebViews]; [self initWebViews];
} }
} }
# pragma mark Init # pragma mark Init
@ -85,81 +85,81 @@
- (void)initOauth - (void)initOauth
{ {
if (!oauthView) { if (!oauthView) {
NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingString:@"/Webkit/"]; NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingString:@"/Webkit/"];
NSURL *url = [NSURL fileURLWithPath:path]; NSURL *url = [NSURL fileURLWithPath:path];
NSString *index_string = [NSString stringWithContentsOfFile:[NSString stringWithFormat:@"%@index.html", path] encoding:NSUTF8StringEncoding error:nil]; NSString *index_string = [NSString stringWithContentsOfFile:[NSString stringWithFormat:@"%@index.html", path] encoding:NSUTF8StringEncoding error:nil];
oauthView = [[WebView alloc] init]; oauthView = [[WebView alloc] init];
viewDelegate.oauthView = oauthView; viewDelegate.oauthView = oauthView;
[[oauthView mainFrame] loadHTMLString:index_string baseURL:url]; [[oauthView mainFrame] loadHTMLString:index_string baseURL:url];
[oauthView setFrameLoadDelegate:viewDelegate]; [oauthView setFrameLoadDelegate:viewDelegate];
[oauthView setPolicyDelegate:viewDelegate]; [oauthView setPolicyDelegate:viewDelegate];
[oauthView setUIDelegate:viewDelegate]; [oauthView setUIDelegate:viewDelegate];
[[oauthView windowScriptObject] setValue:self forKey:@"controller"]; [[oauthView windowScriptObject] setValue:self forKey:@"controller"];
} }
} }
- (void)initWebViews - (void)initWebViews
{ {
if (viewDelegate.timelineView != timelineView) if (viewDelegate.timelineView != timelineView)
{ {
[self initOauth]; [self initOauth];
NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingString:@"/Webkit/"]; NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingString:@"/Webkit/"];
NSURL *url = [NSURL fileURLWithPath:path]; NSURL *url = [NSURL fileURLWithPath:path];
NSString *index_string = [NSString stringWithContentsOfFile:[NSString stringWithFormat:@"%@index.html", path] encoding:NSUTF8StringEncoding error:nil]; NSString *index_string = [NSString stringWithContentsOfFile:[NSString stringWithFormat:@"%@index.html", path] encoding:NSUTF8StringEncoding error:nil];
viewDelegate.timelineView = timelineView; viewDelegate.timelineView = timelineView;
[[timelineView mainFrame] loadHTMLString:index_string baseURL:url]; [[timelineView mainFrame] loadHTMLString:index_string baseURL:url];
[timelineView setFrameLoadDelegate:viewDelegate]; [timelineView setFrameLoadDelegate:viewDelegate];
[timelineView setPolicyDelegate:viewDelegate]; [timelineView setPolicyDelegate:viewDelegate];
[timelineView setUIDelegate:viewDelegate]; [timelineView setUIDelegate:viewDelegate];
[[timelineView windowScriptObject] setValue:self forKey:@"controller"]; [[timelineView windowScriptObject] setValue:self forKey:@"controller"];
//WebPreferences* prefs = [timelineView preferences]; //WebPreferences* prefs = [timelineView preferences];
//[prefs _setLocalStorageDatabasePath:localStoragePath]; //[prefs _setLocalStorageDatabasePath:localStoragePath];
//[prefs setLocalStorageEnabled:YES]; //[prefs setLocalStorageEnabled:YES];
viewDelegate.mentionsView = mentionsView; viewDelegate.mentionsView = mentionsView;
[[mentionsView mainFrame] loadHTMLString:index_string baseURL:url]; [[mentionsView mainFrame] loadHTMLString:index_string baseURL:url];
[mentionsView setFrameLoadDelegate:viewDelegate]; [mentionsView setFrameLoadDelegate:viewDelegate];
[mentionsView setPolicyDelegate:viewDelegate]; [mentionsView setPolicyDelegate:viewDelegate];
[mentionsView setUIDelegate:viewDelegate]; [mentionsView setUIDelegate:viewDelegate];
[[mentionsView windowScriptObject] setValue:self forKey:@"controller"]; [[mentionsView windowScriptObject] setValue:self forKey:@"controller"];
//prefs = [mentionsView preferences]; //prefs = [mentionsView preferences];
//[prefs _setLocalStorageDatabasePath:localStoragePath]; //[prefs _setLocalStorageDatabasePath:localStoragePath];
//[prefs setLocalStorageEnabled:YES]; //[prefs setLocalStorageEnabled:YES];
viewDelegate.conversationView = conversationView; viewDelegate.conversationView = conversationView;
[[conversationView mainFrame] loadHTMLString:index_string baseURL:url]; [[conversationView mainFrame] loadHTMLString:index_string baseURL:url];
[conversationView setFrameLoadDelegate:viewDelegate]; [conversationView setFrameLoadDelegate:viewDelegate];
[conversationView setPolicyDelegate:viewDelegate]; [conversationView setPolicyDelegate:viewDelegate];
[conversationView setUIDelegate:viewDelegate]; [conversationView setUIDelegate:viewDelegate];
[[conversationView windowScriptObject] setValue:self forKey:@"controller"]; [[conversationView windowScriptObject] setValue:self forKey:@"controller"];
//prefs = [conversationView preferences]; //prefs = [conversationView preferences];
//[prefs _setLocalStorageDatabasePath:localStoragePath]; //[prefs _setLocalStorageDatabasePath:localStoragePath];
//[prefs setLocalStorageEnabled:YES]; //[prefs setLocalStorageEnabled:YES];
viewDelegate.profileView = profileView; viewDelegate.profileView = profileView;
[[profileView mainFrame] loadHTMLString:index_string baseURL:url]; [[profileView mainFrame] loadHTMLString:index_string baseURL:url];
[profileView setFrameLoadDelegate:viewDelegate]; [profileView setFrameLoadDelegate:viewDelegate];
[profileView setPolicyDelegate:viewDelegate]; [profileView setPolicyDelegate:viewDelegate];
[profileView setUIDelegate:viewDelegate]; [profileView setUIDelegate:viewDelegate];
[[profileView windowScriptObject] setValue:self forKey:@"controller"]; [[profileView windowScriptObject] setValue:self forKey:@"controller"];
//prefs = [profileView preferences]; //prefs = [profileView preferences];
//[prefs _setLocalStorageDatabasePath:localStoragePath]; //[prefs _setLocalStorageDatabasePath:localStoragePath];
//[prefs setLocalStorageEnabled:YES]; //[prefs setLocalStorageEnabled:YES];
} }
else else
{ {
[timelineView stringByEvaluatingJavaScriptFromString:@"start('timeline')"]; [timelineView stringByEvaluatingJavaScriptFromString:@"start('timeline')"];
[mentionsView stringByEvaluatingJavaScriptFromString:@"start('mentions')"]; [mentionsView stringByEvaluatingJavaScriptFromString:@"start('mentions')"];
[conversationView stringByEvaluatingJavaScriptFromString:@"start('conversation')"]; [conversationView stringByEvaluatingJavaScriptFromString:@"start('conversation')"];
[profileView stringByEvaluatingJavaScriptFromString:@"start('profile')"]; [profileView stringByEvaluatingJavaScriptFromString:@"start('profile')"];
} }
} }
- (void)initHotKeys - (void)initHotKeys
@ -172,21 +172,21 @@
NSInteger defaultsNewTweetKey = (NSInteger)[defaults integerForKey:@"newTweetKey"]; NSInteger defaultsNewTweetKey = (NSInteger)[defaults integerForKey:@"newTweetKey"];
if ([defaults objectForKey:@"newTweetKey"] != nil) if ([defaults objectForKey:@"newTweetKey"] != nil)
{ {
newTweetKey = defaultsNewTweetKey; newTweetKey = defaultsNewTweetKey;
} }
else else
{ {
[defaults setInteger:newTweetKey forKey:@"newTweetKey"]; [defaults setInteger:newTweetKey forKey:@"newTweetKey"];
} }
NSInteger defaultsNewTweetModifierKey = (NSInteger)[defaults integerForKey:@"newTweetModifierKey"]; NSInteger defaultsNewTweetModifierKey = (NSInteger)[defaults integerForKey:@"newTweetModifierKey"];
if ([defaults objectForKey:@"newTweetModifierKey"] != nil) if ([defaults objectForKey:@"newTweetModifierKey"] != nil)
{ {
newTweetModifierKey = defaultsNewTweetModifierKey; newTweetModifierKey = defaultsNewTweetModifierKey;
} }
else else
{ {
[defaults setInteger:newTweetModifierKey forKey:@"newTweetModifierKey"]; [defaults setInteger:newTweetModifierKey forKey:@"newTweetModifierKey"];
} }
@ -221,23 +221,23 @@
- (void)alertTitle:(NSString *)title withMessage:(NSString *)message - (void)alertTitle:(NSString *)title withMessage:(NSString *)message
{ {
NSAlert *alert = [NSAlert alertWithMessageText:title NSAlert *alert = [NSAlert alertWithMessageText:title
defaultButton:@"OK" alternateButton:nil otherButton:nil defaultButton:@"OK" alternateButton:nil otherButton:nil
informativeTextWithFormat:@"%@", message]; informativeTextWithFormat:@"%@", message];
[alert runModal]; [alert runModal];
} }
- (void)authentificationSucceded:(id)sender - (void)authentificationSucceded:(id)sender
{ {
[loginActivityIndicator stopAnimation:self]; [loginActivityIndicator stopAnimation:self];
[self initWebViews]; [self initWebViews];
[loginViewWindow performClose:self]; [loginViewWindow performClose:self];
} }
- (void)authentificationDidNotSucceed:(NSString *)errorMessage - (void)authentificationDidNotSucceed:(NSString *)errorMessage
{ {
[loginActivityIndicator stopAnimation:self]; [loginActivityIndicator stopAnimation:self];
[self alertTitle:@"Authenication error" withMessage:errorMessage]; [self alertTitle:@"Authenication error" withMessage:errorMessage];
} }
+ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector + (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
@ -252,21 +252,21 @@
- (void)setString:(NSString *)string forKey:(NSString *)aKey - (void)setString:(NSString *)string forKey:(NSString *)aKey
{ {
[self.accessToken setString:string forKey:aKey]; [self.accessToken setString:string forKey:aKey];
} }
- (void)setSecret:(NSString *)string - (void)setSecret:(NSString *)string
{ {
[self.accessToken setSecret:string]; [self.accessToken setSecret:string];
} }
- (NSString *)secret - (NSString *)secret
{ {
return [self.accessToken secret]; return [self.accessToken secret];
} }
- (NSString *)stringForKey:(NSString *)aKey - (NSString *)stringForKey:(NSString *)aKey
{ {
return [self.accessToken stringForKey:aKey]; return [self.accessToken stringForKey:aKey];
} }
@ -274,13 +274,13 @@
-(BOOL)applicationShouldOpenUntitledFile:(NSApplication *)theApplication -(BOOL)applicationShouldOpenUntitledFile:(NSApplication *)theApplication
{ {
return NO; return NO;
} }
- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag - (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag
{ {
[timelineViewWindow makeKeyAndOrderFront:self]; [timelineViewWindow makeKeyAndOrderFront:self];
return NO; return NO;
} }
- (IBAction)openNewMessageWindow:(id)sender - (IBAction)openNewMessageWindow:(id)sender
@ -294,7 +294,7 @@
[NSApp activateIgnoringOtherApps:YES]; [NSApp activateIgnoringOtherApps:YES];
NewMessageWindow *newMessage = (NewMessageWindow *)[[NSDocumentController sharedDocumentController] openUntitledDocumentAndDisplay:YES error:nil]; NewMessageWindow *newMessage = (NewMessageWindow *)[[NSDocumentController sharedDocumentController] openUntitledDocumentAndDisplay:YES error:nil];
[newMessage inReplyTo:userName statusId:statusId withString:string]; [newMessage inReplyTo:userName statusId:statusId withString:string];
[newMessage setIsPrivate:isPrivate]; [newMessage setIsPrivate:isPrivate];
} }
- (void)openNewMessageWindowWithString:(NSString *)aString - (void)openNewMessageWindowWithString:(NSString *)aString
@ -304,11 +304,11 @@
NSRange range = [aString rangeOfString:@"oauthtoken"]; NSRange range = [aString rangeOfString:@"oauthtoken"];
if (range.length > 0) if (range.length > 0)
{ {
[oauthView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"bungloo_instance.requestAccessToken('%@')", aString]]; [oauthView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"bungloo_instance.requestAccessToken('%@')", aString]];
} }
else else
{ {
NewMessageWindow *newTweet = (NewMessageWindow *)[[NSDocumentController sharedDocumentController] openUntitledDocumentAndDisplay:YES error:nil]; NewMessageWindow *newTweet = (NewMessageWindow *)[[NSDocumentController sharedDocumentController] openUntitledDocumentAndDisplay:YES error:nil];
[newTweet withString:aString]; [newTweet withString:aString];
} }
@ -323,38 +323,38 @@
- (IBAction)sendTweet:(id)sender - (IBAction)sendTweet:(id)sender
{ {
PostModel *post = (PostModel *)[sender object]; PostModel *post = (PostModel *)[sender object];
NSString *text = [[post.text stringByReplacingOccurrencesOfString:@"\\" withString:@"\\\\"] stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""]; NSString *text = [[post.text stringByReplacingOccurrencesOfString:@"\\" withString:@"\\\\"] stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""];
text = [text stringByReplacingOccurrencesOfString:@"\n" withString:@"\\n"]; text = [text stringByReplacingOccurrencesOfString:@"\n" withString:@"\\n"];
NSString *locationObject = @"null"; NSString *locationObject = @"null";
if (post.location) { if (post.location) {
locationObject = [NSString stringWithFormat:@"[%f, %f]", post.location.coordinate.latitude, post.location.coordinate.longitude]; locationObject = [NSString stringWithFormat:@"[%f, %f]", post.location.coordinate.latitude, post.location.coordinate.longitude];
} }
NSString *imageFilePath = @"null"; NSString *imageFilePath = @"null";
if (post.imageFilePath) { if (post.imageFilePath) {
NSError *error; NSError *error;
NSString *mimeType = [MimeType mimeTypeForFileAtPath:post.imageFilePath error:&error]; NSString *mimeType = [MimeType mimeTypeForFileAtPath:post.imageFilePath error:&error];
NSData *data = [[NSData alloc] initWithContentsOfFile:post.imageFilePath]; NSData *data = [[NSData alloc] initWithContentsOfFile:post.imageFilePath];
NSString *base64 = [data base64Encoding_xcd]; NSString *base64 = [data base64Encoding_xcd];
[data release]; [data release];
imageFilePath = [NSString stringWithFormat:@"\"data:%@;base64,%@\"", mimeType, base64]; imageFilePath = [NSString stringWithFormat:@"\"data:%@;base64,%@\"", mimeType, base64];
} }
NSString *isPrivate = @"false"; NSString *isPrivate = @"false";
if (post.isPrivate) { if (post.isPrivate) {
isPrivate = @"true"; isPrivate = @"true";
} }
NSString *func = [NSString stringWithFormat:@"bungloo_instance.sendNewMessage(\"%@\", \"%@\", \"%@\", %@, %@, %@)", NSString *func = [NSString stringWithFormat:@"bungloo_instance.sendNewMessage(\"%@\", \"%@\", \"%@\", %@, %@, %@)",
text, text,
post.inReplyTostatusId, post.inReplyTostatusId,
post.inReplyToEntity, post.inReplyToEntity,
locationObject, locationObject,
imageFilePath, imageFilePath,
isPrivate]; isPrivate];
[timelineView stringByEvaluatingJavaScriptFromString:func]; [timelineView stringByEvaluatingJavaScriptFromString:func];
} }
- (NSString *)pluginURL - (NSString *)pluginURL
@ -362,8 +362,8 @@
NSFileManager *fileManager = [NSFileManager defaultManager]; NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *pathToPlugin = [@"~/Library/Application Support/Bungloo/Plugin.js" stringByExpandingTildeInPath]; NSString *pathToPlugin = [@"~/Library/Application Support/Bungloo/Plugin.js" stringByExpandingTildeInPath];
if([fileManager fileExistsAtPath:pathToPlugin]) if([fileManager fileExistsAtPath:pathToPlugin])
{ {
return [NSString stringWithFormat:@"%@", [NSURL fileURLWithPath:pathToPlugin]]; return [NSString stringWithFormat:@"%@", [NSURL fileURLWithPath:pathToPlugin]];
} }
return nil; return nil;
@ -372,12 +372,12 @@
- (void)unreadMentions:(int)count - (void)unreadMentions:(int)count
{ {
if (![mentionsViewWindow isVisible] && count > 0) if (![mentionsViewWindow isVisible] && count > 0)
{ {
[timelineViewWindow setTitle:[NSString stringWithFormat:@"Bungloo (^%i)", count]]; [timelineViewWindow setTitle:[NSString stringWithFormat:@"Bungloo (^%i)", count]];
[[[NSApplication sharedApplication] dockTile] setBadgeLabel:[NSString stringWithFormat:@"%i", count]]; [[[NSApplication sharedApplication] dockTile] setBadgeLabel:[NSString stringWithFormat:@"%i", count]];
} }
else else
{ {
[timelineViewWindow setTitle:[NSString stringWithFormat:@"Bungloo"]]; [timelineViewWindow setTitle:[NSString stringWithFormat:@"Bungloo"]];
[[[NSApplication sharedApplication] dockTile] setBadgeLabel:nil]; [[[NSApplication sharedApplication] dockTile] setBadgeLabel:nil];
[mentionsView stringByEvaluatingJavaScriptFromString:@"bungloo_instance.unread_mentions = 0;"]; [mentionsView stringByEvaluatingJavaScriptFromString:@"bungloo_instance.unread_mentions = 0;"];
@ -386,92 +386,92 @@
- (void)notificateUserAboutMention:(NSString *)text fromName:(NSString *)name withPostId:(NSString *)postId andEntity:(NSString *)entity - (void)notificateUserAboutMention:(NSString *)text fromName:(NSString *)name withPostId:(NSString *)postId andEntity:(NSString *)entity
{ {
[GrowlApplicationBridge [GrowlApplicationBridge
notifyWithTitle:[NSString stringWithFormat:@"Mentioned by %@ on Tent", name] notifyWithTitle:[NSString stringWithFormat:@"Mentioned by %@ on Tent", name]
description:text description:text
notificationName:@"Mention" notificationName:@"Mention"
iconData:nil iconData:nil
priority:0 priority:0
isSticky:NO isSticky:NO
clickContext:[NSDictionary dictionaryWithObjectsAndKeys: clickContext:[NSDictionary dictionaryWithObjectsAndKeys:
entity, @"entity", entity, @"entity",
postId, @"postId", nil]]; postId, @"postId", nil]];
} }
- (void)openURL:(NSString *)url - (void)openURL:(NSString *)url
{ {
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:url]]; [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:url]];
} }
- (IBAction)showProfile:(id)sender - (IBAction)showProfile:(id)sender
{ {
NSString *entity = [self.showProfileTextField stringValue]; NSString *entity = [self.showProfileTextField stringValue];
if ([entity rangeOfString:@"."].location != NSNotFound && ([entity hasPrefix:@"http://"] || [entity hasPrefix:@"https://"])) { if ([entity rangeOfString:@"."].location != NSNotFound && ([entity hasPrefix:@"http://"] || [entity hasPrefix:@"https://"])) {
NSString *func = [NSString stringWithFormat:@"bungloo_instance.showProfileForEntity('%@')", entity]; NSString *func = [NSString stringWithFormat:@"bungloo_instance.showProfileForEntity('%@')", entity];
[profileView stringByEvaluatingJavaScriptFromString:func]; [profileView stringByEvaluatingJavaScriptFromString:func];
[profileViewWindow makeKeyAndOrderFront:self]; [profileViewWindow makeKeyAndOrderFront:self];
[openProfileWindow performClose:self]; [openProfileWindow performClose:self];
} }
} }
- (void)notificateViewsAboutDeletedPostWithId:(NSString *)postId byEntity:(NSString*)entity - (void)notificateViewsAboutDeletedPostWithId:(NSString *)postId byEntity:(NSString*)entity
{ {
NSString *fun = [NSString stringWithFormat:@"bungloo_instance.postDeleted('%@', '%@')", postId, entity]; NSString *fun = [NSString stringWithFormat:@"bungloo_instance.postDeleted('%@', '%@')", postId, entity];
[timelineView stringByEvaluatingJavaScriptFromString:fun]; [timelineView stringByEvaluatingJavaScriptFromString:fun];
[mentionsView stringByEvaluatingJavaScriptFromString:fun]; [mentionsView stringByEvaluatingJavaScriptFromString:fun];
[conversationView stringByEvaluatingJavaScriptFromString:fun]; [conversationView stringByEvaluatingJavaScriptFromString:fun];
[profileView stringByEvaluatingJavaScriptFromString:fun]; [profileView stringByEvaluatingJavaScriptFromString:fun];
} }
/* /*
- (void)storeAccessToken:(NSString *)_accessToken secret:(NSString *)secret userId:(NSString *)userId andScreenName:(NSString *)screenName - (void)storeAccessToken:(NSString *)_accessToken secret:(NSString *)secret userId:(NSString *)userId andScreenName:(NSString *)screenName
{ {
self.accessToken.accessToken = _accessToken; self.accessToken.accessToken = _accessToken;
self.accessToken.secret = secret; self.accessToken.secret = secret;
self.accessToken.userId = userId; self.accessToken.userId = userId;
self.accessToken.screenName = screenName; self.accessToken.screenName = screenName;
[timelineViewWindow makeKeyAndOrderFront:self]; [timelineViewWindow makeKeyAndOrderFront:self];
[[NSNotificationCenter defaultCenter] postNotificationName:@"authentificationSucceded" object:nil]; [[NSNotificationCenter defaultCenter] postNotificationName:@"authentificationSucceded" object:nil];
}*/ }*/
- (void)loggedIn - (void)loggedIn
{ {
[loginActivityIndicator stopAnimation:self]; [loginActivityIndicator stopAnimation:self];
[self initWebViews]; [self initWebViews];
[loginViewWindow performClose:self]; [loginViewWindow performClose:self];
[timelineViewWindow makeKeyAndOrderFront:self]; [timelineViewWindow makeKeyAndOrderFront:self];
} }
- (IBAction)login:(id)sender - (IBAction)login:(id)sender
{ {
if ([[loginEntityTextField stringValue] length] > 0) { if ([[loginEntityTextField stringValue] length] > 0) {
[[loginEntityTextField window] makeFirstResponder:nil]; [[loginEntityTextField window] makeFirstResponder:nil];
[loginActivityIndicator startAnimation:self]; [loginActivityIndicator startAnimation:self];
[oauthView stringByEvaluatingJavaScriptFromString:@"bungloo_instance.authenticate();"]; [oauthView stringByEvaluatingJavaScriptFromString:@"bungloo_instance.authenticate();"];
} }
} }
- (IBAction)logout:(id)sender - (IBAction)logout:(id)sender
{ {
[oauthView stringByEvaluatingJavaScriptFromString:@"bungloo_instance.logout();"]; [oauthView stringByEvaluatingJavaScriptFromString:@"bungloo_instance.logout();"];
[timelineViewWindow performClose:self]; [timelineViewWindow performClose:self];
[mentionsViewWindow performClose:self]; [mentionsViewWindow performClose:self];
[conversationViewWindow performClose:self]; [conversationViewWindow performClose:self];
[profileViewWindow performClose:self]; [profileViewWindow performClose:self];
[self.loginViewWindow makeKeyAndOrderFront:self]; [self.loginViewWindow makeKeyAndOrderFront:self];
[timelineView stringByEvaluatingJavaScriptFromString:@"bungloo_instance.logout();"]; [timelineView stringByEvaluatingJavaScriptFromString:@"bungloo_instance.logout();"];
[mentionsView stringByEvaluatingJavaScriptFromString:@"bungloo_instance.logout();"]; [mentionsView stringByEvaluatingJavaScriptFromString:@"bungloo_instance.logout();"];
} }
// Mentions window has been visible // Mentions window has been visible
- (void)windowDidBecomeKey:(NSNotification *)notification - (void)windowDidBecomeKey:(NSNotification *)notification
{ {
if ([notification object] == mentionsViewWindow) if ([notification object] == mentionsViewWindow)
{ {
//[self unreadMentions:0]; //[self unreadMentions:0];
[mentionsView stringByEvaluatingJavaScriptFromString:@"bungloo_instance.setAllMentionsRead();"]; [mentionsView stringByEvaluatingJavaScriptFromString:@"bungloo_instance.setAllMentionsRead();"];
} }
@ -485,39 +485,39 @@
- (IBAction)showConversationForPostId:(NSString *)postId andEntity:(NSString *)entity - (IBAction)showConversationForPostId:(NSString *)postId andEntity:(NSString *)entity
{ {
NSString *js = [NSString stringWithFormat:@"bungloo_instance.showStatus('%@', '%@');", postId, entity]; NSString *js = [NSString stringWithFormat:@"bungloo_instance.showStatus('%@', '%@');", postId, entity];
[conversationView stringByEvaluatingJavaScriptFromString:js]; [conversationView stringByEvaluatingJavaScriptFromString:js];
[conversationViewWindow makeKeyAndOrderFront:self]; [conversationViewWindow makeKeyAndOrderFront:self];
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES]; [[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
} }
- (IBAction)clearCache:(id)sender - (IBAction)clearCache:(id)sender
{ {
[timelineView stringByEvaluatingJavaScriptFromString:@"bungloo_instance.cache.clear()"]; [timelineView stringByEvaluatingJavaScriptFromString:@"bungloo_instance.cache.clear()"];
} }
- (IBAction)showProfileForEntity:(NSString *)entity - (IBAction)showProfileForEntity:(NSString *)entity
{ {
NSString *js = [NSString stringWithFormat:@"bungloo_instance.showProfileForEntity('%@');", entity]; NSString *js = [NSString stringWithFormat:@"bungloo_instance.showProfileForEntity('%@');", entity];
[profileView stringByEvaluatingJavaScriptFromString:js]; [profileView stringByEvaluatingJavaScriptFromString:js];
[profileViewWindow makeKeyAndOrderFront:self]; [profileViewWindow makeKeyAndOrderFront:self];
} }
- (void)growlNotificationWasClicked:(id)clickContext - (void)growlNotificationWasClicked:(id)clickContext
{ {
NSDictionary *userInfo = (NSDictionary *)clickContext; NSDictionary *userInfo = (NSDictionary *)clickContext;
NSString *postId = [userInfo objectForKey:@"postId"]; NSString *postId = [userInfo objectForKey:@"postId"];
NSString *entity = [userInfo objectForKey:@"entity"]; NSString *entity = [userInfo objectForKey:@"entity"];
[self showConversationForPostId:postId andEntity:entity]; [self showConversationForPostId:postId andEntity:entity];
NSString *js = [NSString stringWithFormat:@"bungloo_instance.mentionRead('%@', '%@');", postId, entity]; NSString *js = [NSString stringWithFormat:@"bungloo_instance.mentionRead('%@', '%@');", postId, entity];
[mentionsView stringByEvaluatingJavaScriptFromString:js]; [mentionsView stringByEvaluatingJavaScriptFromString:js];
} }
- (NSString *) applicationNameForGrowl - (NSString *) applicationNameForGrowl
{ {
return @"Bungloo"; return @"Bungloo";
} }
/* CARBON */ /* CARBON */

View file

@ -11,17 +11,17 @@
@implementation MimeType @implementation MimeType
+(NSString *)mimeTypeForFileAtPath:(NSString *)path error:(NSError **)err { +(NSString *)mimeTypeForFileAtPath:(NSString *)path error:(NSError **)err {
NSString *uti, *mimeType = nil; NSString *uti, *mimeType = nil;
if (!(uti = [[NSWorkspace sharedWorkspace] typeOfFile:path error:err])) if (!(uti = [[NSWorkspace sharedWorkspace] typeOfFile:path error:err]))
return nil; return nil;
if (err) if (err)
*err = nil; *err = nil;
if ((mimeType = (NSString *)UTTypeCopyPreferredTagWithClass((CFStringRef)uti, kUTTagClassMIMEType))) if ((mimeType = (NSString *)UTTypeCopyPreferredTagWithClass((CFStringRef)uti, kUTTagClassMIMEType)))
mimeType = NSMakeCollectable(mimeType); mimeType = NSMakeCollectable(mimeType);
return mimeType; return mimeType;
} }
@end @end

View file

@ -15,15 +15,15 @@
{ {
IBOutlet NSTextField *textField; IBOutlet NSTextField *textField;
IBOutlet NSTextField *counter; IBOutlet NSTextField *counter;
NSMenu *addMenu; NSMenu *addMenu;
NSButton *addMenuButton; NSButton *addMenuButton;
NSString *inReplyTostatusId; NSString *inReplyTostatusId;
NSString *inReplyToEntity; NSString *inReplyToEntity;
NSMenuItem *addImage; NSMenuItem *addImage;
CLLocationManager *locationManager; CLLocationManager *locationManager;
CLLocation *currentLocation; CLLocation *currentLocation;
NSString *imageFilePath; NSString *imageFilePath;
NSButton *togglePrivateButton; NSButton *togglePrivateButton;
} }
@property (nonatomic, retain) IBOutlet NSTextField *textField; @property (nonatomic, retain) IBOutlet NSTextField *textField;

View file

@ -27,31 +27,31 @@
- (void)dealloc - (void)dealloc
{ {
[locationManager stopUpdatingLocation]; [locationManager stopUpdatingLocation];
[locationManager release]; [locationManager release];
[currentLocation release]; [currentLocation release];
[imageFilePath release]; [imageFilePath release];
[super dealloc]; [super dealloc];
} }
- (id)init - (id)init
{ {
self = [super init]; self = [super init];
if (self) if (self)
{ {
// Add your subclass-specific initialization here. // Add your subclass-specific initialization here.
// If an error occurs here, send a [self release] message and return nil. // If an error occurs here, send a [self release] message and return nil.
inReplyTostatusId = @""; inReplyTostatusId = @"";
inReplyToEntity = @""; inReplyToEntity = @"";
} }
return self; return self;
} }
- (NSString *)windowNibName - (NSString *)windowNibName
{ {
// Override returning the nib file name of the document // Override returning the nib file name of the document
// If you need to use a subclass of NSWindowController or if your document supports multiple NSWindowControllers, you should remove this method and override -makeWindowControllers instead. // If you need to use a subclass of NSWindowController or if your document supports multiple NSWindowControllers, you should remove this method and override -makeWindowControllers instead.
return @"NewMessageWindow"; return @"NewMessageWindow";
} }
- (NSString *)displayName - (NSString *)displayName
@ -61,24 +61,24 @@
- (void)windowControllerDidLoadNib:(NSWindowController *) aController - (void)windowControllerDidLoadNib:(NSWindowController *) aController
{ {
[super windowControllerDidLoadNib:aController]; [super windowControllerDidLoadNib:aController];
// Add any code here that needs to be executed once the windowController has loaded the document's window. // Add any code here that needs to be executed once the windowController has loaded the document's window.
[textField becomeFirstResponder]; [textField becomeFirstResponder];
// Enable Continous Spelling // Enable Continous Spelling
NSTextView *textView = (NSTextView *)[[[self.windowControllers objectAtIndex:0] window] firstResponder];; NSTextView *textView = (NSTextView *)[[[self.windowControllers objectAtIndex:0] window] firstResponder];;
[textView setContinuousSpellCheckingEnabled:YES]; [textView setContinuousSpellCheckingEnabled:YES];
} }
- (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError - (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError
{ {
// Insert code here to write your document to data of the specified type. If the given outError != NULL, ensure that you set *outError when returning nil. // Insert code here to write your document to data of the specified type. If the given outError != NULL, ensure that you set *outError when returning nil.
// You can also choose to override -fileWrapperOfType:error:, -writeToURL:ofType:error:, or -writeToURL:ofType:forSaveOperation:originalContentsURL:error: instead. // You can also choose to override -fileWrapperOfType:error:, -writeToURL:ofType:error:, or -writeToURL:ofType:forSaveOperation:originalContentsURL:error: instead.
// For applications targeted for Panther or earlier systems, you should use the deprecated API -dataRepresentationOfType:. In this case you can also choose to override -fileWrapperRepresentationOfType: or -writeToFile:ofType: instead. // For applications targeted for Panther or earlier systems, you should use the deprecated API -dataRepresentationOfType:. In this case you can also choose to override -fileWrapperRepresentationOfType: or -writeToFile:ofType: instead.
if ( outError != NULL ) { if ( outError != NULL ) {
*outError = [NSError errorWithDomain:NSOSStatusErrorDomain code:unimpErr userInfo:NULL]; *outError = [NSError errorWithDomain:NSOSStatusErrorDomain code:unimpErr userInfo:NULL];
} }
return nil; return nil;
@ -86,28 +86,28 @@
- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError **)outError - (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError **)outError
{ {
// Insert code here to read your document from the given data of the specified type. If the given outError != NULL, ensure that you set *outError when returning NO. // Insert code here to read your document from the given data of the specified type. If the given outError != NULL, ensure that you set *outError when returning NO.
// You can also choose to override -readFromFileWrapper:ofType:error: or -readFromURL:ofType:error: instead. // You can also choose to override -readFromFileWrapper:ofType:error: or -readFromURL:ofType:error: instead.
// For applications targeted for Panther or earlier systems, you should use the deprecated API -loadDataRepresentation:ofType. In this case you can also choose to override -readFromFile:ofType: or -loadFileWrapperRepresentation:ofType: instead. // For applications targeted for Panther or earlier systems, you should use the deprecated API -loadDataRepresentation:ofType. In this case you can also choose to override -readFromFile:ofType: or -loadFileWrapperRepresentation:ofType: instead.
if ( outError != NULL ) if ( outError != NULL )
{ {
*outError = [NSError errorWithDomain:NSOSStatusErrorDomain code:unimpErr userInfo:NULL]; *outError = [NSError errorWithDomain:NSOSStatusErrorDomain code:unimpErr userInfo:NULL];
} }
return YES; return YES;
} }
- (void)inReplyTo:(NSString *)entity statusId:(NSString *)statusId withString:(NSString *)string - (void)inReplyTo:(NSString *)entity statusId:(NSString *)statusId withString:(NSString *)string
{ {
[textField setStringValue:string]; [textField setStringValue:string];
NSInteger location = [string rangeOfString:@" "].location; NSInteger location = [string rangeOfString:@" "].location;
NSInteger length = 0; NSInteger length = 0;
if (location != NSNotFound) { if (location != NSNotFound) {
length = [[textField stringValue] length] - location - 1; length = [[textField stringValue] length] - location - 1;
} }
NSRange range = {location + 1, length}; NSRange range = {location + 1, length};
@ -117,11 +117,11 @@
inReplyTostatusId = statusId; inReplyTostatusId = statusId;
[inReplyTostatusId retain]; [inReplyTostatusId retain];
[inReplyToEntity release]; [inReplyToEntity release];
inReplyToEntity = entity; inReplyToEntity = entity;
[inReplyToEntity retain]; [inReplyToEntity retain];
[self controlTextDidChange:nil]; [self controlTextDidChange:nil];
} }
- (void)withString:(NSString *)aString - (void)withString:(NSString *)aString
@ -129,59 +129,59 @@
[textField setStringValue:aString]; [textField setStringValue:aString];
NSRange range = {[[textField stringValue] length] , 0}; NSRange range = {[[textField stringValue] length] , 0};
[[textField currentEditor] setSelectedRange:range]; [[textField currentEditor] setSelectedRange:range];
NSLog(@"BB"); NSLog(@"BB");
[self controlTextDidChange:nil]; [self controlTextDidChange:nil];
} }
- (IBAction)addCurrentLocation:(id)sender - (IBAction)addCurrentLocation:(id)sender
{ {
NSMenuItem *menuItem = (NSMenuItem *)sender; NSMenuItem *menuItem = (NSMenuItem *)sender;
if (!self.locationManager) if (!self.locationManager)
{ {
[menuItem setTitle:@"Current location not available"]; [menuItem setTitle:@"Current location not available"];
[self initLocationManager]; [self initLocationManager];
} }
else else
{ {
[self.locationManager stopUpdatingLocation]; [self.locationManager stopUpdatingLocation];
self.currentLocation = nil; self.currentLocation = nil;
self.locationManager = nil; self.locationManager = nil;
[menuItem setTitle:@"Add current location"]; [menuItem setTitle:@"Add current location"];
} }
} }
- (IBAction)openAddMenu:(id)sender - (IBAction)openAddMenu:(id)sender
{ {
NSRect frame = [(NSButton *)sender frame]; NSRect frame = [(NSButton *)sender frame];
NSPoint menuOrigin = [[(NSButton *)sender superview] convertPoint:NSMakePoint(frame.origin.x, frame.origin.y+frame.size.height) toView:nil]; NSPoint menuOrigin = [[(NSButton *)sender superview] convertPoint:NSMakePoint(frame.origin.x, frame.origin.y+frame.size.height) toView:nil];
NSEvent *event = [NSEvent mouseEventWithType:NSLeftMouseDown NSEvent *event = [NSEvent mouseEventWithType:NSLeftMouseDown
location:menuOrigin location:menuOrigin
modifierFlags:NSLeftMouseDownMask // 0x100 modifierFlags:NSLeftMouseDownMask // 0x100
timestamp:NSTimeIntervalSince1970 timestamp:NSTimeIntervalSince1970
windowNumber:[[(NSButton *)sender window] windowNumber] windowNumber:[[(NSButton *)sender window] windowNumber]
context:[[(NSButton *)sender window] graphicsContext] context:[[(NSButton *)sender window] graphicsContext]
eventNumber:0 eventNumber:0
clickCount:1 clickCount:1
pressure:1]; pressure:1];
[NSMenu popUpContextMenu:self.addMenu withEvent:event forView:self.addMenuButton]; [NSMenu popUpContextMenu:self.addMenu withEvent:event forView:self.addMenuButton];
} }
- (IBAction)togglePrivate:(id)sender - (IBAction)togglePrivate:(id)sender
{ {
NSImage *image = [NSImage imageNamed:NSImageNameLockLockedTemplate]; NSImage *image = [NSImage imageNamed:NSImageNameLockLockedTemplate];
if (self.togglePrivateButton.image == [NSImage imageNamed:NSImageNameLockLockedTemplate]) if (self.togglePrivateButton.image == [NSImage imageNamed:NSImageNameLockLockedTemplate])
{ {
image = [NSImage imageNamed:NSImageNameLockUnlockedTemplate]; image = [NSImage imageNamed:NSImageNameLockUnlockedTemplate];
} }
[self.togglePrivateButton setImage:image]; [self.togglePrivateButton setImage:image];
} }
- (void)setIsPrivate:(BOOL)isPrivate { - (void)setIsPrivate:(BOOL)isPrivate {
NSImage *image = [NSImage imageNamed:(isPrivate ? NSImageNameLockLockedTemplate : NSImageNameLockUnlockedTemplate)]; NSImage *image = [NSImage imageNamed:(isPrivate ? NSImageNameLockLockedTemplate : NSImageNameLockUnlockedTemplate)];
[self.togglePrivateButton setImage:image]; [self.togglePrivateButton setImage:image];
} }
-(void)controlTextDidChange:(NSNotification *)aNotification { -(void)controlTextDidChange:(NSNotification *)aNotification {
@ -196,44 +196,44 @@
- (void)initLocationManager - (void)initLocationManager
{ {
self.locationManager = [[CLLocationManager alloc] init]; self.locationManager = [[CLLocationManager alloc] init];
[self.locationManager setDelegate:self]; [self.locationManager setDelegate:self];
[self.locationManager setDesiredAccuracy:kCLLocationAccuracyBest]; [self.locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[self.locationManager setDistanceFilter:kCLDistanceFilterNone]; [self.locationManager setDistanceFilter:kCLDistanceFilterNone];
[self.locationManager startUpdatingLocation]; [self.locationManager startUpdatingLocation];
} }
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{ {
self.currentLocation = newLocation; self.currentLocation = newLocation;
NSMenuItem *menuItem = [self.addMenu itemAtIndex:0]; NSMenuItem *menuItem = [self.addMenu itemAtIndex:0];
[menuItem setTitle:@"Remove current location"]; [menuItem setTitle:@"Remove current location"];
} }
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error{ - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error{
NSLog(@"CLLocationManager Error: %@", error); NSLog(@"CLLocationManager Error: %@", error);
NSMenuItem *menuItem = [self.addMenu itemAtIndex:0]; NSMenuItem *menuItem = [self.addMenu itemAtIndex:0];
[menuItem setTitle:@"Current location not available"]; [menuItem setTitle:@"Current location not available"];
} }
- (IBAction)sendPostButtonPressed:(id)sender - (IBAction)sendPostButtonPressed:(id)sender
{ {
[self sendPost:self.textField]; [self sendPost:self.textField];
} }
#pragma mark Keyboard delegate methods #pragma mark Keyboard delegate methods
- (IBAction)sendPost:(NSControl *)control { - (IBAction)sendPost:(NSControl *)control {
BOOL emptyIsOk = self.currentLocation || self.imageFilePath; BOOL emptyIsOk = self.currentLocation || self.imageFilePath;
if (emptyIsOk || ([[control stringValue] length] <= MESSAGE_MAX_LENGTH && [[control stringValue] length] > 0)) { if (emptyIsOk || ([[control stringValue] length] <= MESSAGE_MAX_LENGTH && [[control stringValue] length] > 0)) {
PostModel *post = [[[PostModel alloc] init] autorelease]; PostModel *post = [[[PostModel alloc] init] autorelease];
post.text = [control stringValue]; post.text = [control stringValue];
post.inReplyTostatusId = inReplyTostatusId; post.inReplyTostatusId = inReplyTostatusId;
post.inReplyToEntity = inReplyToEntity; post.inReplyToEntity = inReplyToEntity;
post.location = self.currentLocation; post.location = self.currentLocation;
post.imageFilePath = self.imageFilePath; post.imageFilePath = self.imageFilePath;
post.isPrivate = self.togglePrivateButton.image == [NSImage imageNamed:NSImageNameLockLockedTemplate]; post.isPrivate = self.togglePrivateButton.image == [NSImage imageNamed:NSImageNameLockLockedTemplate];
[[NSNotificationCenter defaultCenter] postNotificationName:@"sendTweet" object:post]; [[NSNotificationCenter defaultCenter] postNotificationName:@"sendTweet" object:post];
[self close]; [self close];
} else { } else {
@ -243,102 +243,102 @@
} }
- (BOOL)isCommandEnterEvent:(NSEvent *)e { - (BOOL)isCommandEnterEvent:(NSEvent *)e {
NSUInteger flags = (e.modifierFlags & NSDeviceIndependentModifierFlagsMask); NSUInteger flags = (e.modifierFlags & NSDeviceIndependentModifierFlagsMask);
BOOL isCommand = (flags & NSCommandKeyMask) == NSCommandKeyMask; BOOL isCommand = (flags & NSCommandKeyMask) == NSCommandKeyMask;
BOOL isEnter = (e.keyCode == 0x24); // VK_RETURN BOOL isEnter = (e.keyCode == 0x24); // VK_RETURN
return (isCommand && isEnter); return (isCommand && isEnter);
} }
- (BOOL)control:(NSControl *)control textView:(NSTextView *)fieldEditor doCommandBySelector:(SEL)commandSelector - (BOOL)control:(NSControl *)control textView:(NSTextView *)fieldEditor doCommandBySelector:(SEL)commandSelector
{ {
BOOL retval = NO; BOOL retval = NO;
BOOL isEnter = [[NSApp currentEvent] keyCode] == 76; BOOL isEnter = [[NSApp currentEvent] keyCode] == 76;
if (commandSelector == @selector(insertNewline:) && !isEnter) { if (commandSelector == @selector(insertNewline:) && !isEnter) {
NSText *text = [[textField window] fieldEditor:YES forObject:nil]; NSText *text = [[textField window] fieldEditor:YES forObject:nil];
NSRange range = [text selectedRange]; NSRange range = [text selectedRange];
NSString *stringBefore = [textField.stringValue substringToIndex:range.location]; NSString *stringBefore = [textField.stringValue substringToIndex:range.location];
NSString *stringAfter = [textField.stringValue substringFromIndex:range.location + range.length]; NSString *stringAfter = [textField.stringValue substringFromIndex:range.location + range.length];
textField.stringValue = [NSString stringWithFormat:@"%@\n%@", stringBefore, stringAfter]; textField.stringValue = [NSString stringWithFormat:@"%@\n%@", stringBefore, stringAfter];
NSRange r = NSMakeRange(range.location + 1, 0); NSRange r = NSMakeRange(range.location + 1, 0);
[text scrollRangeToVisible:r]; [text scrollRangeToVisible:r];
[text setSelectedRange:r]; [text setSelectedRange:r];
retval = YES; // causes Apple to NOT fire the default enter action retval = YES; // causes Apple to NOT fire the default enter action
} }
else if (commandSelector == @selector(noop:) && isEnter) { else if (commandSelector == @selector(noop:) && isEnter) {
retval = YES; retval = YES;
[self sendPost:control]; [self sendPost:control];
} }
return retval; return retval;
} }
#pragma mark Add images #pragma mark Add images
- (IBAction)addImage:(id)sender - (IBAction)addImage:(id)sender
{ {
NSMenuItem *menuItem = (NSMenuItem *)sender; NSMenuItem *menuItem = (NSMenuItem *)sender;
if (!self.imageFilePath) if (!self.imageFilePath)
{ {
[menuItem setTitle:@"Remove photo"]; [menuItem setTitle:@"Remove photo"];
NSOpenPanel* openDlg = [NSOpenPanel openPanel]; NSOpenPanel* openDlg = [NSOpenPanel openPanel];
[openDlg setPrompt:@"Select"]; [openDlg setPrompt:@"Select"];
[openDlg setDelegate:self]; [openDlg setDelegate:self];
// Enable the selection of files in the dialog. // Enable the selection of files in the dialog.
[openDlg setCanChooseFiles:YES]; [openDlg setCanChooseFiles:YES];
// Enable the selection of directories in the dialog. // Enable the selection of directories in the dialog.
[openDlg setCanChooseDirectories:NO]; [openDlg setCanChooseDirectories:NO];
// Display the dialog. If the OK button was pressed, // Display the dialog. If the OK button was pressed,
// process the files. // process the files.
if ( [openDlg runModalForDirectory:nil file:nil] == NSOKButton ) if ( [openDlg runModalForDirectory:nil file:nil] == NSOKButton )
{ {
// Get an array containing the full filenames of all // Get an array containing the full filenames of all
// files and directories selected. // files and directories selected.
NSArray* files = [openDlg filenames]; NSArray* files = [openDlg filenames];
// Loop through all the files and process them. // Loop through all the files and process them.
for( int i = 0; i < [files count]; i++ ) for( int i = 0; i < [files count]; i++ )
{ {
self.imageFilePath = [files objectAtIndex:i]; self.imageFilePath = [files objectAtIndex:i];
} }
} }
} }
else else
{ {
self.imageFilePath = nil; self.imageFilePath = nil;
[menuItem setTitle:@"Add photo"]; [menuItem setTitle:@"Add photo"];
} }
} }
-(BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename -(BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename
{ {
NSString* ext = [filename pathExtension]; NSString* ext = [filename pathExtension];
if ([ext isEqualToString:@""] || [ext isEqualToString:@"/"] || ext == nil || ext == NULL || [ext length] < 1) { if ([ext isEqualToString:@""] || [ext isEqualToString:@"/"] || ext == nil || ext == NULL || [ext length] < 1) {
return YES; return YES;
} }
NSEnumerator* tagEnumerator = [[NSArray arrayWithObjects:@"png", @"jpg", @"gif", @"jpeg", nil] objectEnumerator]; NSEnumerator* tagEnumerator = [[NSArray arrayWithObjects:@"png", @"jpg", @"gif", @"jpeg", nil] objectEnumerator];
NSString* allowedExt; NSString* allowedExt;
while ((allowedExt = [tagEnumerator nextObject])) while ((allowedExt = [tagEnumerator nextObject]))
{ {
if ([ext caseInsensitiveCompare:allowedExt] == NSOrderedSame) if ([ext caseInsensitiveCompare:allowedExt] == NSOrderedSame)
{ {
return YES; return YES;
} }
} }
return NO; return NO;
} }
@end @end

View file

@ -12,10 +12,10 @@
@interface PostModel : NSObject { @interface PostModel : NSObject {
NSString *text; NSString *text;
NSString *inReplyTostatusId; NSString *inReplyTostatusId;
NSString *inReplyToEntity; NSString *inReplyToEntity;
CLLocation *location; CLLocation *location;
NSString *imageFilePath; NSString *imageFilePath;
BOOL isPrivate; BOOL isPrivate;
} }
@property (nonatomic, retain) NSString *text; @property (nonatomic, retain) NSString *text;

View file

@ -17,9 +17,9 @@
{ {
[text release]; [text release];
[inReplyTostatusId release]; [inReplyTostatusId release];
[inReplyToEntity release]; [inReplyToEntity release];
[location release]; [location release];
[imageFilePath release]; [imageFilePath release];
[super dealloc]; [super dealloc];
} }

View file

@ -13,9 +13,9 @@
@interface ViewDelegate : NSObject { @interface ViewDelegate : NSObject {
WebView *timelineView; WebView *timelineView;
WebView *mentionsView; WebView *mentionsView;
WebView *conversationView; WebView *conversationView;
WebView *profileView; WebView *profileView;
WebView *oauthView; WebView *oauthView;
} }
@property (nonatomic, assign) WebView *timelineView; @property (nonatomic, assign) WebView *timelineView;

View file

@ -17,14 +17,14 @@
if (![message isKindOfClass:[NSDictionary class]]) return; if (![message isKindOfClass:[NSDictionary class]]) return;
NSString *viewName = @"TimelineView"; NSString *viewName = @"TimelineView";
if (sender == mentionsView) viewName = @"MentionsView"; if (sender == mentionsView) viewName = @"MentionsView";
if (sender == conversationView) viewName = @"ConversationView"; if (sender == conversationView) viewName = @"ConversationView";
if (sender == oauthView) viewName = @"OauthView"; if (sender == oauthView) viewName = @"OauthView";
if (sender == profileView) viewName = @"ProfileView"; if (sender == profileView) viewName = @"ProfileView";
NSLog(@"js<%@>: %@:%@: %@", NSLog(@"js<%@>: %@:%@: %@",
viewName, viewName,
[[message objectForKey:@"sourceURL"] lastPathComponent], [[message objectForKey:@"sourceURL"] lastPathComponent],
[message objectForKey:@"lineNumber"], [message objectForKey:@"lineNumber"],
[message objectForKey:@"message"] [message objectForKey:@"message"]
@ -32,94 +32,94 @@
} }
- (void)webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame { - (void)webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
NSString *viewName = @"TimelineView"; NSString *viewName = @"TimelineView";
if (sender == mentionsView) viewName = @"MentionsView"; if (sender == mentionsView) viewName = @"MentionsView";
if (sender == conversationView) viewName = @"ConversationView"; if (sender == conversationView) viewName = @"ConversationView";
if (sender == oauthView) viewName = @"OauthView"; if (sender == oauthView) viewName = @"OauthView";
NSLog(@"jsa<%@>: %@", viewName, message); NSLog(@"jsa<%@>: %@", viewName, message);
} }
- (BOOL)webView:(WebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame { - (BOOL)webView:(WebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
NSInteger result = NSRunCriticalAlertPanel(NSLocalizedString(@"Bungloo", @""), // title NSInteger result = NSRunCriticalAlertPanel(NSLocalizedString(@"Bungloo", @""), // title
message, // message message, // message
NSLocalizedString(@"OK", @""), // default button NSLocalizedString(@"OK", @""), // default button
NSLocalizedString(@"Cancel", @""), // alt button NSLocalizedString(@"Cancel", @""), // alt button
nil); nil);
return NSAlertDefaultReturn == result; return NSAlertDefaultReturn == result;
return NO; return NO;
} }
- (void)webView:(WebView *)sender decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id <WebPolicyDecisionListener>)listener { - (void)webView:(WebView *)sender decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id <WebPolicyDecisionListener>)listener {
[listener ignore]; [listener ignore];
[[NSWorkspace sharedWorkspace] openURL:[request URL]]; [[NSWorkspace sharedWorkspace] openURL:[request URL]];
} }
- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame { - (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
NSFileManager *fileManager = [NSFileManager defaultManager]; NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *pathToJsPlugin = [@"~/Library/Application Support/bungloo/Plugin.js" stringByExpandingTildeInPath]; NSString *pathToJsPlugin = [@"~/Library/Application Support/bungloo/Plugin.js" stringByExpandingTildeInPath];
NSString *pathToCssPlugin = [@"~/Library/Application Support/bungloo/Plugin.css" stringByExpandingTildeInPath]; NSString *pathToCssPlugin = [@"~/Library/Application Support/bungloo/Plugin.css" stringByExpandingTildeInPath];
if([fileManager fileExistsAtPath:pathToCssPlugin]) if([fileManager fileExistsAtPath:pathToCssPlugin])
{ {
[sender stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"setTimeout(function() { loadCssPlugin('file://localhost%@') }, 1000);", pathToCssPlugin]]; [sender stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"setTimeout(function() { loadCssPlugin('file://localhost%@') }, 1000);", pathToCssPlugin]];
} }
if([fileManager fileExistsAtPath:pathToJsPlugin]) if([fileManager fileExistsAtPath:pathToJsPlugin])
{ {
[sender stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"setTimeout(function() { loadJsPlugin('file://localhost%@') }, 1000);", pathToJsPlugin]]; [sender stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"setTimeout(function() { loadJsPlugin('file://localhost%@') }, 1000);", pathToJsPlugin]];
} }
[sender stringByEvaluatingJavaScriptFromString:@"var OS_TYPE = 'mac';"]; [sender stringByEvaluatingJavaScriptFromString:@"var OS_TYPE = 'mac';"];
if (sender == oauthView) { if (sender == oauthView) {
[oauthView stringByEvaluatingJavaScriptFromString:@"function HostAppGo() { start('oauth') }"]; [oauthView stringByEvaluatingJavaScriptFromString:@"function HostAppGo() { start('oauth') }"];
} else if(sender == conversationView) { } else if(sender == conversationView) {
[conversationView stringByEvaluatingJavaScriptFromString:@"function HostAppGo() { start('conversation') }"]; [conversationView stringByEvaluatingJavaScriptFromString:@"function HostAppGo() { start('conversation') }"];
} else if(sender == profileView) { } else if(sender == profileView) {
[profileView stringByEvaluatingJavaScriptFromString:@"function HostAppGo() { start('profile') }"]; [profileView stringByEvaluatingJavaScriptFromString:@"function HostAppGo() { start('profile') }"];
} else { } else {
NSString *action = @"timeline"; NSString *action = @"timeline";
NSString *delay = @"1"; NSString *delay = @"1";
if (sender == mentionsView) { if (sender == mentionsView) {
action = @"mentions"; action = @"mentions";
delay = @"1000"; delay = @"1000";
} }
[sender stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"function HostAppGo() { start('%@') }", action]]; [sender stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"function HostAppGo() { start('%@') }", action]];
} }
} }
- (NSArray *)webView:(WebView *)sender contextMenuItemsForElement:(NSDictionary *)element defaultMenuItems:(NSArray *)defaultMenuItems - (NSArray *)webView:(WebView *)sender contextMenuItemsForElement:(NSDictionary *)element defaultMenuItems:(NSArray *)defaultMenuItems
{ {
// FIXME // FIXME
/* /*
NSMutableArray *menuItems = [NSMutableArray arrayWithArray:defaultMenuItems]; NSMutableArray *menuItems = [NSMutableArray arrayWithArray:defaultMenuItems];
for (NSMenuItem*item in defaultMenuItems) { for (NSMenuItem*item in defaultMenuItems) {
if ([[item title] isEqualToString:@"Reload"]) { if ([[item title] isEqualToString:@"Reload"]) {
//[item setAction:@selector(reload:)]; //[item setAction:@selector(reload:)];
//[item setTarget:self]; //[item setTarget:self];
} else { } else {
[menuItems addObject:item]; [menuItems addObject:item];
} }
}*/ }*/
return defaultMenuItems; return defaultMenuItems;
} }
- (void)reload:(id)sender { - (void)reload:(id)sender {
[timelineView stringByEvaluatingJavaScriptFromString:@"bungloo_instance.getNewData();"]; [timelineView stringByEvaluatingJavaScriptFromString:@"bungloo_instance.getNewData();"];
[mentionsView stringByEvaluatingJavaScriptFromString:@"bungloo_instance.getNewData();"]; [mentionsView stringByEvaluatingJavaScriptFromString:@"bungloo_instance.getNewData();"];
} }
- (NSString *)pluginURL - (NSString *)pluginURL
@ -127,8 +127,8 @@
NSFileManager *fileManager = [NSFileManager defaultManager]; NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *pathToPlugin = [@"~/Library/Application Support/Bungloo/Plugin.js" stringByExpandingTildeInPath]; NSString *pathToPlugin = [@"~/Library/Application Support/Bungloo/Plugin.js" stringByExpandingTildeInPath];
if([fileManager fileExistsAtPath:pathToPlugin]) if([fileManager fileExistsAtPath:pathToPlugin])
{ {
return [NSString stringWithFormat:@"%@", [NSURL fileURLWithPath:pathToPlugin]]; return [NSString stringWithFormat:@"%@", [NSURL fileURLWithPath:pathToPlugin]];
} }
return nil; return nil;

View file

@ -10,5 +10,5 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
return NSApplicationMain(argc, (const char **) argv); return NSApplicationMain(argc, (const char **) argv);
} }

View file

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle" xmlns:dc="http://purl.org/dc/elements/1.1/"> <rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel> <channel>
<title>Bungloo's Changelog</title> <title>Bungloo's Changelog</title>
<link>http://jabs.nu/Bungloo/download/Appcast.xml</link> <link>http://jabs.nu/Bungloo/download/Appcast.xml</link>
<description>Most recent changes with links to updates.</description> <description>Most recent changes with links to updates.</description>
<language>en</language> <language>en</language>
<item> <item>
<title>Version 1.0.0</title> <title>Version 1.0.0</title>
<sparkle:minimumSystemVersion>10.5.0</sparkle:minimumSystemVersion> <sparkle:minimumSystemVersion>10.5.0</sparkle:minimumSystemVersion>
<sparkle:releaseNotesLink>http://jabs.nu/bungloo/download/ReleaseNotes.html</sparkle:releaseNotesLink> <sparkle:releaseNotesLink>http://jabs.nu/bungloo/download/ReleaseNotes.html</sparkle:releaseNotesLink>
<pubDate>Mon, 11 Feb 2013 00:29:41 +0100</pubDate> <pubDate>Mon, 11 Feb 2013 00:29:41 +0100</pubDate>
@ -15,6 +15,6 @@
length="1101694" length="1101694"
type="application/octet-stream" type="application/octet-stream"
sparkle:dsaSignature="MCwCFB1JIQINycvbZblob0PHy6Be1nVzAhQ2zkoVqoOjJsDjcnZYjI1qY7oX1Q==" /> sparkle:dsaSignature="MCwCFB1JIQINycvbZblob0PHy6Be1nVzAhQ2zkoVqoOjJsDjcnZYjI1qY7oX1Q==" />
</item> </item>
</channel> </channel>
</rss> </rss>

View file

@ -1,5 +1,4 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" <!DOCTYPE html>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html> <html>
<head> <head>
<title>Tentia Release Notes</title> <title>Tentia Release Notes</title>
@ -8,8 +7,8 @@
h1 { font-size: 1.2em; } h1 { font-size: 1.2em; }
h2 { font-size: 1em; margin-top: 2em; } h2 { font-size: 1em; margin-top: 2em; }
hr { margin: 2em 0; } hr { margin: 2em 0; }
p { margin: 0; padding: 0; } p { margin: 0; padding: 0; }
strong { color: red; } strong { color: red; }
</style> </style>
</head> </head>
<body> <body>

View file

@ -2,10 +2,10 @@
require 'time' require 'time'
def test var, message def test var, message
unless var unless var
puts message puts message
exit exit
end end
end end
path = File.dirname File.expand_path(__FILE__) path = File.dirname File.expand_path(__FILE__)
@ -28,13 +28,13 @@ end
xml = <<XML xml = <<XML
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle" xmlns:dc="http://purl.org/dc/elements/1.1/"> <rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel> <channel>
<title>Bungloo's Changelog</title> <title>Bungloo's Changelog</title>
<link>http://jabs.nu/Bungloo/download/Appcast.xml</link> <link>http://jabs.nu/Bungloo/download/Appcast.xml</link>
<description>Most recent changes with links to updates.</description> <description>Most recent changes with links to updates.</description>
<language>en</language> <language>en</language>
<item> <item>
<title>Version #{version}</title> <title>Version #{version}</title>
<sparkle:minimumSystemVersion>10.5.0</sparkle:minimumSystemVersion> <sparkle:minimumSystemVersion>10.5.0</sparkle:minimumSystemVersion>
<sparkle:releaseNotesLink>http://jabs.nu/bungloo/download/ReleaseNotes.html</sparkle:releaseNotesLink> <sparkle:releaseNotesLink>http://jabs.nu/bungloo/download/ReleaseNotes.html</sparkle:releaseNotesLink>
<pubDate>#{Time.now.rfc2822}</pubDate> <pubDate>#{Time.now.rfc2822}</pubDate>
@ -43,8 +43,8 @@ xml = <<XML
length="#{length}" length="#{length}"
type="application/octet-stream" type="application/octet-stream"
sparkle:dsaSignature="#{signature}" /> sparkle:dsaSignature="#{signature}" />
</item> </item>
</channel> </channel>
</rss> </rss>
XML XML

View file

@ -13,6 +13,7 @@ body {
a { a {
text-decoration: none; text-decoration: none;
color: #00317a; color: #00317a;
outline: 0;
} }
ol { ol {
@ -80,6 +81,7 @@ body > ol > li:after, header.profile:after {
header.profile img { header.profile img {
float: left; float: left;
margin: 0 10px 10px 0; margin: 0 10px 10px 0;
max-height: 100px;
max-width: 100px; max-width: 100px;
border-radius: 10px; border-radius: 10px;
} }