added add/show geolocation and changed name from TweetModel to PostModel
This commit is contained in:
parent
d39b643844
commit
76b63d5c68
12 changed files with 398 additions and 50 deletions
|
@ -29,6 +29,7 @@
|
|||
ViewDelegate *viewDelegate;
|
||||
WebView *oauthView;
|
||||
AccessToken *accessToken;
|
||||
|
||||
}
|
||||
|
||||
@property (retain, nonatomic) IBOutlet WebView *timelineView;
|
||||
|
@ -46,6 +47,7 @@
|
|||
@property (retain, nonatomic) WebView *oauthView;
|
||||
@property (retain, nonatomic) AccessToken *accessToken;
|
||||
|
||||
|
||||
- (void)initOauth;
|
||||
- (void)authentificationSucceded:(id)sender;
|
||||
- (void)authentificationDidNotSucceed:(NSString *)errorMessage;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#import "Controller.h"
|
||||
#import "NewMessageWindow.h"
|
||||
#import "TweetModel.h"
|
||||
#import "PostModel.h"
|
||||
|
||||
@implementation Controller
|
||||
@synthesize loginViewWindow;
|
||||
|
@ -74,6 +74,10 @@
|
|||
}
|
||||
}
|
||||
|
||||
# pragma mark Init
|
||||
|
||||
|
||||
|
||||
- (void)initOauth
|
||||
{
|
||||
if (!oauthView) {
|
||||
|
@ -280,13 +284,19 @@
|
|||
|
||||
- (IBAction)sendTweet:(id)sender
|
||||
{
|
||||
TweetModel *tweet = (TweetModel *)[sender object];
|
||||
NSString *text = [[tweet.text stringByReplacingOccurrencesOfString:@"\\" withString:@"\\\\"] stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""];
|
||||
PostModel *post = (PostModel *)[sender object];
|
||||
NSString *text = [[post.text stringByReplacingOccurrencesOfString:@"\\" withString:@"\\\\"] stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""];
|
||||
text = [text stringByReplacingOccurrencesOfString:@"\n" withString:@"\\n"];
|
||||
NSString *func = [NSString stringWithFormat:@"tentia_instance.sendNewMessage(\"%@\", \"%@\", \"%@\")",
|
||||
|
||||
NSString *locationObject = @"null";
|
||||
if (post.location) {
|
||||
locationObject = [NSString stringWithFormat:@"[%f, %f]", post.location.coordinate.latitude, post.location.coordinate.longitude];
|
||||
}
|
||||
NSString *func = [NSString stringWithFormat:@"tentia_instance.sendNewMessage(\"%@\", \"%@\", \"%@\", %@)",
|
||||
text,
|
||||
tweet.inReplyTostatusId,
|
||||
tweet.inReplyToEntity];
|
||||
post.inReplyTostatusId,
|
||||
post.inReplyToEntity,
|
||||
locationObject];
|
||||
[timelineView stringByEvaluatingJavaScriptFromString:func];
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,11 @@
|
|||
</object>
|
||||
<object class="NSArray" key="IBDocument.IntegratedClassDependencies">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>NSButton</string>
|
||||
<string>NSButtonCell</string>
|
||||
<string>NSCustomObject</string>
|
||||
<string>NSMenu</string>
|
||||
<string>NSMenuItem</string>
|
||||
<string>NSTextField</string>
|
||||
<string>NSTextFieldCell</string>
|
||||
<string>NSView</string>
|
||||
|
@ -55,11 +59,11 @@
|
|||
<string key="NSFrame">{{0, 22}, {299, 91}}</string>
|
||||
<reference key="NSSuperview" ref="568628114"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="184011745"/>
|
||||
<reference key="NSNextKeyView" ref="482035741"/>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSTextFieldCell" key="NSCell" id="834602598">
|
||||
<int key="NSCellFlags">-1809842175</int>
|
||||
<int key="NSCellFlags2">268435456</int>
|
||||
<int key="NSCellFlags2">268468224</int>
|
||||
<string key="NSContents"/>
|
||||
<object class="NSFont" key="NSSupport" id="991349575">
|
||||
<string key="NSName">LucidaGrande</string>
|
||||
|
@ -95,6 +99,7 @@
|
|||
<string key="NSFrame">{{257, 2}, {38, 17}}</string>
|
||||
<reference key="NSSuperview" ref="568628114"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView"/>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSTextFieldCell" key="NSCell" id="894039108">
|
||||
<int key="NSCellFlags">68157504</int>
|
||||
|
@ -120,6 +125,39 @@
|
|||
</object>
|
||||
<bool key="NSAllowsLogicalLayoutDirection">NO</bool>
|
||||
</object>
|
||||
<object class="NSButton" id="482035741">
|
||||
<reference key="NSNextResponder" ref="568628114"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{2, 0}, {18, 19}}</string>
|
||||
<reference key="NSSuperview" ref="568628114"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="184011745"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:9</string>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSButtonCell" key="NSCell" id="482669194">
|
||||
<int key="NSCellFlags">67108864</int>
|
||||
<int key="NSCellFlags2">134217728</int>
|
||||
<string key="NSContents"/>
|
||||
<object class="NSFont" key="NSSupport">
|
||||
<string key="NSName">LucidaGrande-Bold</string>
|
||||
<double key="NSSize">12</double>
|
||||
<int key="NSfFlags">16</int>
|
||||
</object>
|
||||
<string key="NSCellIdentifier">_NS:9</string>
|
||||
<reference key="NSControlView" ref="482035741"/>
|
||||
<int key="NSButtonFlags">113524736</int>
|
||||
<int key="NSButtonFlags2">268435629</int>
|
||||
<object class="NSCustomResource" key="NSNormalImage">
|
||||
<string key="NSClassName">NSImage</string>
|
||||
<string key="NSResourceName">NSAddTemplate</string>
|
||||
</object>
|
||||
<string key="NSAlternateContents"/>
|
||||
<string key="NSKeyEquivalent">+</string>
|
||||
<int key="NSPeriodicDelay">200</int>
|
||||
<int key="NSPeriodicInterval">25</int>
|
||||
</object>
|
||||
<bool key="NSAllowsLogicalLayoutDirection">NO</bool>
|
||||
</object>
|
||||
</object>
|
||||
<string key="NSFrameSize">{299, 113}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
|
@ -137,6 +175,26 @@
|
|||
<object class="NSCustomObject" id="796877042">
|
||||
<string key="NSClassName">NSApplication</string>
|
||||
</object>
|
||||
<object class="NSMenu" id="723763594">
|
||||
<string key="NSTitle"/>
|
||||
<object class="NSMutableArray" key="NSMenuItems">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSMenuItem" id="921309347">
|
||||
<reference key="NSMenu" ref="723763594"/>
|
||||
<string key="NSTitle">Add current location</string>
|
||||
<string key="NSKeyEquiv"/>
|
||||
<int key="NSMnemonicLoc">2147483647</int>
|
||||
<object class="NSCustomResource" key="NSOnImage">
|
||||
<string key="NSClassName">NSImage</string>
|
||||
<string key="NSResourceName">NSMenuCheckmark</string>
|
||||
</object>
|
||||
<object class="NSCustomResource" key="NSMixedImage">
|
||||
<string key="NSClassName">NSImage</string>
|
||||
<string key="NSResourceName">NSMenuMixedState</string>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBObjectContainer" key="IBDocument.Objects">
|
||||
<object class="NSMutableArray" key="connectionRecords">
|
||||
|
@ -173,6 +231,38 @@
|
|||
</object>
|
||||
<int key="connectionID">100038</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">addMenu</string>
|
||||
<reference key="source" ref="512844837"/>
|
||||
<reference key="destination" ref="723763594"/>
|
||||
</object>
|
||||
<int key="connectionID">100048</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBActionConnection" key="connection">
|
||||
<string key="label">addCurrentLocation:</string>
|
||||
<reference key="source" ref="512844837"/>
|
||||
<reference key="destination" ref="921309347"/>
|
||||
</object>
|
||||
<int key="connectionID">100049</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBActionConnection" key="connection">
|
||||
<string key="label">openAddMenu:</string>
|
||||
<reference key="source" ref="512844837"/>
|
||||
<reference key="destination" ref="482035741"/>
|
||||
</object>
|
||||
<int key="connectionID">100053</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">addMenuButton</string>
|
||||
<reference key="source" ref="512844837"/>
|
||||
<reference key="destination" ref="482035741"/>
|
||||
</object>
|
||||
<int key="connectionID">100054</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">delegate</string>
|
||||
|
@ -181,6 +271,14 @@
|
|||
</object>
|
||||
<int key="connectionID">100035</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">menu</string>
|
||||
<reference key="source" ref="482035741"/>
|
||||
<reference key="destination" ref="723763594"/>
|
||||
</object>
|
||||
<int key="connectionID">100045</int>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<object class="NSArray" key="orderedObjects">
|
||||
|
@ -222,6 +320,7 @@
|
|||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="884814600"/>
|
||||
<reference ref="184011745"/>
|
||||
<reference ref="482035741"/>
|
||||
</object>
|
||||
<reference key="parent" ref="275939982"/>
|
||||
</object>
|
||||
|
@ -259,6 +358,34 @@
|
|||
<reference key="object" ref="894039108"/>
|
||||
<reference key="parent" ref="184011745"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">100039</int>
|
||||
<reference key="object" ref="482035741"/>
|
||||
<object class="NSMutableArray" key="children">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="482669194"/>
|
||||
</object>
|
||||
<reference key="parent" ref="568628114"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">100040</int>
|
||||
<reference key="object" ref="482669194"/>
|
||||
<reference key="parent" ref="482035741"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">100041</int>
|
||||
<reference key="object" ref="723763594"/>
|
||||
<object class="NSMutableArray" key="children">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="921309347"/>
|
||||
</object>
|
||||
<reference key="parent" ref="0"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">100043</int>
|
||||
<reference key="object" ref="921309347"/>
|
||||
<reference key="parent" ref="723763594"/>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="flattenedProperties">
|
||||
|
@ -272,6 +399,10 @@
|
|||
<string>100029.IBPluginDependency</string>
|
||||
<string>100036.IBPluginDependency</string>
|
||||
<string>100037.IBPluginDependency</string>
|
||||
<string>100039.IBPluginDependency</string>
|
||||
<string>100040.IBPluginDependency</string>
|
||||
<string>100041.IBPluginDependency</string>
|
||||
<string>100043.IBPluginDependency</string>
|
||||
<string>5.IBPluginDependency</string>
|
||||
<string>5.IBWindowTemplateEditedContentRect</string>
|
||||
<string>6.IBPluginDependency</string>
|
||||
|
@ -286,6 +417,10 @@
|
|||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>{{127, 736}, {299, 113}}</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
</object>
|
||||
|
@ -302,7 +437,7 @@
|
|||
<reference key="dict.values" ref="0"/>
|
||||
</object>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">100038</int>
|
||||
<int key="maxID">100054</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
|
@ -311,25 +446,64 @@
|
|||
<string key="className">NewMessageWindow</string>
|
||||
<string key="superclassName">NSDocument</string>
|
||||
<object class="NSMutableDictionary" key="actions">
|
||||
<string key="NS.key.0">sendTweet:</string>
|
||||
<string key="NS.object.0">NSControl</string>
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSArray" key="dict.sortedKeys">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>addCurrentLocation:</string>
|
||||
<string>addImage:</string>
|
||||
<string>openAddMenu:</string>
|
||||
<string>sendTweet:</string>
|
||||
</object>
|
||||
<object class="NSArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>id</string>
|
||||
<string>id</string>
|
||||
<string>id</string>
|
||||
<string>NSControl</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="actionInfosByName">
|
||||
<string key="NS.key.0">sendTweet:</string>
|
||||
<object class="IBActionInfo" key="NS.object.0">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSArray" key="dict.sortedKeys">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>addCurrentLocation:</string>
|
||||
<string>addImage:</string>
|
||||
<string>openAddMenu:</string>
|
||||
<string>sendTweet:</string>
|
||||
</object>
|
||||
<object class="NSArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="IBActionInfo">
|
||||
<string key="name">addCurrentLocation:</string>
|
||||
<string key="candidateClassName">id</string>
|
||||
</object>
|
||||
<object class="IBActionInfo">
|
||||
<string key="name">addImage:</string>
|
||||
<string key="candidateClassName">id</string>
|
||||
</object>
|
||||
<object class="IBActionInfo">
|
||||
<string key="name">openAddMenu:</string>
|
||||
<string key="candidateClassName">id</string>
|
||||
</object>
|
||||
<object class="IBActionInfo">
|
||||
<string key="name">sendTweet:</string>
|
||||
<string key="candidateClassName">NSControl</string>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="outlets">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSArray" key="dict.sortedKeys">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>addMenu</string>
|
||||
<string>addMenuButton</string>
|
||||
<string>counter</string>
|
||||
<string>textField</string>
|
||||
</object>
|
||||
<object class="NSArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>NSMenu</string>
|
||||
<string>NSButton</string>
|
||||
<string>NSTextField</string>
|
||||
<string>NSTextField</string>
|
||||
</object>
|
||||
|
@ -338,11 +512,21 @@
|
|||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSArray" key="dict.sortedKeys">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>addMenu</string>
|
||||
<string>addMenuButton</string>
|
||||
<string>counter</string>
|
||||
<string>textField</string>
|
||||
</object>
|
||||
<object class="NSArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="IBToOneOutletInfo">
|
||||
<string key="name">addMenu</string>
|
||||
<string key="candidateClassName">NSMenu</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo">
|
||||
<string key="name">addMenuButton</string>
|
||||
<string key="candidateClassName">NSButton</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo">
|
||||
<string key="name">counter</string>
|
||||
<string key="candidateClassName">NSTextField</string>
|
||||
|
@ -368,5 +552,20 @@
|
|||
</object>
|
||||
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
|
||||
<int key="IBDocument.defaultPropertyAccessControl">3</int>
|
||||
<object class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSArray" key="dict.sortedKeys">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>NSAddTemplate</string>
|
||||
<string>NSMenuCheckmark</string>
|
||||
<string>NSMenuMixedState</string>
|
||||
</object>
|
||||
<object class="NSArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>{8, 8}</string>
|
||||
<string>{11, 11}</string>
|
||||
<string>{10, 3}</string>
|
||||
</object>
|
||||
</object>
|
||||
</data>
|
||||
</archive>
|
||||
|
|
|
@ -8,21 +8,34 @@
|
|||
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <CoreLocation/CoreLocation.h>
|
||||
|
||||
|
||||
@interface NewMessageWindow : NSDocument <NSTextFieldDelegate>
|
||||
@interface NewMessageWindow : NSDocument <NSTextFieldDelegate, CLLocationManagerDelegate>
|
||||
{
|
||||
IBOutlet NSTextField *textField;
|
||||
IBOutlet NSTextField *counter;
|
||||
NSMenu *addMenu;
|
||||
NSButton *addMenuButton;
|
||||
NSString *inReplyTostatusId;
|
||||
NSString *inReplyToEntity;
|
||||
NSMenuItem *addImage;
|
||||
CLLocationManager *locationManager;
|
||||
CLLocation *currentLocation;
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) IBOutlet NSTextField *textField;
|
||||
@property (nonatomic, retain) IBOutlet NSTextField *counter;
|
||||
@property (assign) IBOutlet NSMenu *addMenu;
|
||||
@property (assign) IBOutlet NSButton *addMenuButton;
|
||||
@property (retain, nonatomic) CLLocationManager *locationManager;
|
||||
@property (retain, nonatomic) CLLocation *currentLocation;
|
||||
|
||||
- (IBAction)sendTweet:(NSControl *)control;
|
||||
- (void)inReplyTo:(NSString *)userName statusId:(NSString *)statusId withString:(NSString *)string;
|
||||
- (void)withString:(NSString *)aString;
|
||||
- (IBAction)addCurrentLocation:(id)sender;
|
||||
- (IBAction)addImage:(id)sender;
|
||||
- (IBAction)openAddMenu:(id)sender;
|
||||
|
||||
@end
|
||||
|
|
|
@ -8,22 +8,34 @@
|
|||
|
||||
#import "NewMessageWindow.h"
|
||||
#import "Constants.h"
|
||||
#import "TweetModel.h"
|
||||
#import "PostModel.h"
|
||||
#import "Controller.h"
|
||||
|
||||
@interface NewMessageWindow (private)
|
||||
- (BOOL)isCommandEnterEvent:(NSEvent *)e;
|
||||
- (void)initLocationManager;
|
||||
@end
|
||||
|
||||
@implementation NewMessageWindow
|
||||
|
||||
@synthesize addMenu;
|
||||
@synthesize addMenuButton;
|
||||
@synthesize textField, counter;
|
||||
@synthesize locationManager, currentLocation;
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[locationManager stopUpdatingLocation];
|
||||
[locationManager release];
|
||||
[currentLocation release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
|
||||
if (self)
|
||||
{
|
||||
// Add your subclass-specific initialization here.
|
||||
// If an error occurs here, send a [self release] message and return nil.
|
||||
inReplyTostatusId = @"";
|
||||
|
@ -39,7 +51,8 @@
|
|||
return @"NewMessageWindow";
|
||||
}
|
||||
|
||||
- (NSString *)displayName {
|
||||
- (NSString *)displayName
|
||||
{
|
||||
return @"New Post";
|
||||
}
|
||||
|
||||
|
@ -76,13 +89,15 @@
|
|||
|
||||
// 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];
|
||||
}
|
||||
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];
|
||||
NSRange range = {[[textField stringValue] length] , 0};
|
||||
[[textField currentEditor] setSelectedRange:range];
|
||||
|
@ -98,7 +113,8 @@
|
|||
[self controlTextDidChange:nil];
|
||||
}
|
||||
|
||||
- (void)withString:(NSString *)aString {
|
||||
- (void)withString:(NSString *)aString
|
||||
{
|
||||
[textField setStringValue:aString];
|
||||
NSRange range = {[[textField stringValue] length] , 0};
|
||||
[[textField currentEditor] setSelectedRange:range];
|
||||
|
@ -106,6 +122,45 @@
|
|||
[self controlTextDidChange:nil];
|
||||
}
|
||||
|
||||
- (IBAction)addCurrentLocation:(id)sender
|
||||
{
|
||||
NSMenuItem *menuItem = (NSMenuItem *)sender;
|
||||
if (!self.locationManager)
|
||||
{
|
||||
[menuItem setTitle:@"Current location not available"];
|
||||
[self initLocationManager];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self.locationManager stopUpdatingLocation];
|
||||
self.currentLocation = nil;
|
||||
self.locationManager = nil;
|
||||
[menuItem setTitle:@"Add current location"];
|
||||
}
|
||||
}
|
||||
|
||||
- (IBAction)addImage:(id)sender
|
||||
{
|
||||
}
|
||||
|
||||
- (IBAction)openAddMenu:(id)sender
|
||||
{
|
||||
NSRect frame = [(NSButton *)sender frame];
|
||||
NSPoint menuOrigin = [[(NSButton *)sender superview] convertPoint:NSMakePoint(frame.origin.x, frame.origin.y+frame.size.height) toView:nil];
|
||||
|
||||
NSEvent *event = [NSEvent mouseEventWithType:NSLeftMouseDown
|
||||
location:menuOrigin
|
||||
modifierFlags:NSLeftMouseDownMask // 0x100
|
||||
timestamp:NSTimeIntervalSince1970
|
||||
windowNumber:[[(NSButton *)sender window] windowNumber]
|
||||
context:[[(NSButton *)sender window] graphicsContext]
|
||||
eventNumber:0
|
||||
clickCount:1
|
||||
pressure:1];
|
||||
|
||||
[NSMenu popUpContextMenu:self.addMenu withEvent:event forView:self.addMenuButton];
|
||||
}
|
||||
|
||||
-(void)controlTextDidChange:(NSNotification *)aNotification {
|
||||
NSInteger c = MESSAGE_MAX_LENGTH - [[textField stringValue] length];
|
||||
[counter setIntValue:c];
|
||||
|
@ -116,16 +171,39 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (void)initLocationManager
|
||||
{
|
||||
self.locationManager = [[CLLocationManager alloc] init];
|
||||
[self.locationManager setDelegate:self];
|
||||
[self.locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
|
||||
[self.locationManager setDistanceFilter:kCLDistanceFilterNone];
|
||||
[self.locationManager startUpdatingLocation];
|
||||
}
|
||||
|
||||
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
|
||||
{
|
||||
self.currentLocation = newLocation;
|
||||
NSMenuItem *menuItem = [self.addMenu itemAtIndex:0];
|
||||
[menuItem setTitle:@"Remove current location"];
|
||||
}
|
||||
|
||||
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error{
|
||||
NSLog(@"CLLocationManager Error: %@", error);
|
||||
|
||||
NSMenuItem *menuItem = [self.addMenu itemAtIndex:0];
|
||||
[menuItem setTitle:@"Current location not available"];
|
||||
}
|
||||
|
||||
#pragma mark Keyboard delegate methods
|
||||
|
||||
- (IBAction)sendTweet:(NSControl *)control {
|
||||
if ([[control stringValue] length] <= MESSAGE_MAX_LENGTH) {
|
||||
TweetModel *tweet = [[[TweetModel alloc] init] autorelease];
|
||||
tweet.text = [control stringValue];
|
||||
tweet.inReplyTostatusId = inReplyTostatusId;
|
||||
tweet.inReplyToEntity = inReplyToEntity;
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:@"sendTweet" object:tweet];
|
||||
PostModel *post = [[[PostModel alloc] init] autorelease];
|
||||
post.text = [control stringValue];
|
||||
post.inReplyTostatusId = inReplyTostatusId;
|
||||
post.inReplyToEntity = inReplyToEntity;
|
||||
post.location = self.currentLocation;
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:@"sendTweet" object:post];
|
||||
[self close];
|
||||
} else {
|
||||
NSBeep();
|
||||
|
|
|
@ -7,16 +7,20 @@
|
|||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <CoreLocation/CoreLocation.h>
|
||||
|
||||
|
||||
@interface TweetModel : NSObject {
|
||||
@interface PostModel : NSObject {
|
||||
NSString *text;
|
||||
NSString *inReplyTostatusId;
|
||||
NSString *inReplyToEntity;
|
||||
CLLocation *location;
|
||||
NSImage *image;
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) NSString *text;
|
||||
@property (nonatomic, retain) NSString *inReplyTostatusId;
|
||||
@property (nonatomic, retain) NSString *inReplyToEntity;
|
||||
@property (nonatomic, retain) CLLocation *location;
|
||||
@property (nonatomic, retain) NSImage *image;
|
||||
|
||||
@end
|
|
@ -6,17 +6,19 @@
|
|||
// Copyright 2011 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TweetModel.h"
|
||||
#import "PostModel.h"
|
||||
|
||||
|
||||
@implementation TweetModel
|
||||
@implementation PostModel
|
||||
|
||||
@synthesize text, inReplyTostatusId, inReplyToEntity;
|
||||
@synthesize text, inReplyTostatusId, inReplyToEntity, location, image;
|
||||
|
||||
- (void)dealloc {
|
||||
[text release];
|
||||
[inReplyTostatusId release];
|
||||
[inReplyToEntity release];
|
||||
[location release];
|
||||
[image release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
|
@ -12,8 +12,9 @@
|
|||
1F122D49118E1DE100E83B77 /* Icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 1F122D48118E1DE100E83B77 /* Icon.icns */; };
|
||||
1F1990C6117BCA960049BEA7 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F1990C5117BCA960049BEA7 /* ApplicationServices.framework */; };
|
||||
1F1C80F916482A250010B409 /* WebKit in Resources */ = {isa = PBXBuildFile; fileRef = 1F1C80F816482A250010B409 /* WebKit */; };
|
||||
1F2D79BD165E8C6B000E8428 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F2D79BC165E8C6B000E8428 /* CoreLocation.framework */; };
|
||||
1F3F129E164F202000C7C983 /* dsa_pub.pem in Resources */ = {isa = PBXBuildFile; fileRef = 1F3F129D164F202000C7C983 /* dsa_pub.pem */; };
|
||||
1F618ECA12DB5E6100E500D9 /* TweetModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F618EC912DB5E6100E500D9 /* TweetModel.m */; };
|
||||
1F618ECA12DB5E6100E500D9 /* PostModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F618EC912DB5E6100E500D9 /* PostModel.m */; };
|
||||
1F70619F1178FBB300C85707 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F70619E1178FBB300C85707 /* Carbon.framework */; };
|
||||
1F77DB47118C5F1C007C7F1E /* Constants.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F77DB46118C5F1C007C7F1E /* Constants.m */; };
|
||||
1FA09847144602530079E258 /* libicucore.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1FA09846144602530079E258 /* libicucore.dylib */; };
|
||||
|
@ -56,9 +57,10 @@
|
|||
1F122D48118E1DE100E83B77 /* Icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Icon.icns; sourceTree = "<group>"; };
|
||||
1F1990C5117BCA960049BEA7 /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = System/Library/Frameworks/ApplicationServices.framework; sourceTree = SDKROOT; };
|
||||
1F1C80F816482A250010B409 /* WebKit */ = {isa = PBXFileReference; lastKnownFileType = folder; name = WebKit; path = ../WebKit; sourceTree = "<group>"; };
|
||||
1F2D79BC165E8C6B000E8428 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = /System/Library/Frameworks/CoreLocation.framework; sourceTree = "<absolute>"; };
|
||||
1F3F129D164F202000C7C983 /* dsa_pub.pem */ = {isa = PBXFileReference; lastKnownFileType = text; name = dsa_pub.pem; path = publish/dsa_pub.pem; sourceTree = "<group>"; };
|
||||
1F618EC812DB5E6100E500D9 /* TweetModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = TweetModel.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
||||
1F618EC912DB5E6100E500D9 /* TweetModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = TweetModel.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
|
||||
1F618EC812DB5E6100E500D9 /* PostModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = PostModel.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
||||
1F618EC912DB5E6100E500D9 /* PostModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = PostModel.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
|
||||
1F70619E1178FBB300C85707 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = System/Library/Frameworks/Carbon.framework; sourceTree = SDKROOT; };
|
||||
1F77DB45118C5F1C007C7F1E /* Constants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = Constants.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
||||
1F77DB46118C5F1C007C7F1E /* Constants.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = Constants.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
|
||||
|
@ -89,6 +91,7 @@
|
|||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
1F2D79BD165E8C6B000E8428 /* CoreLocation.framework in Frameworks */,
|
||||
1FDEF722164EFE9100F927F3 /* Growl.framework in Frameworks */,
|
||||
1FA09847144602530079E258 /* libicucore.dylib in Frameworks */,
|
||||
8D15AC340486D014006FF6A4 /* Cocoa.framework in Frameworks */,
|
||||
|
@ -105,6 +108,7 @@
|
|||
1058C7A6FEA54F5311CA2CBB /* Linked Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1F2D79BC165E8C6B000E8428 /* CoreLocation.framework */,
|
||||
1FDEF721164EFE9100F927F3 /* Growl.framework */,
|
||||
1FE2FC92117A818D000504B0 /* Sparkle.framework */,
|
||||
1058C7A7FEA54F5311CA2CBB /* Cocoa.framework */,
|
||||
|
@ -157,8 +161,8 @@
|
|||
2A37F4ACFDCFA73011CA2CEA /* NewMessageWindow.m */,
|
||||
1F77DB45118C5F1C007C7F1E /* Constants.h */,
|
||||
1F77DB46118C5F1C007C7F1E /* Constants.m */,
|
||||
1F618EC812DB5E6100E500D9 /* TweetModel.h */,
|
||||
1F618EC912DB5E6100E500D9 /* TweetModel.m */,
|
||||
1F618EC812DB5E6100E500D9 /* PostModel.h */,
|
||||
1F618EC912DB5E6100E500D9 /* PostModel.m */,
|
||||
1FC2549A1427D9930035D84B /* AccessToken.h */,
|
||||
1FC2549B1427D9930035D84B /* AccessToken.m */,
|
||||
);
|
||||
|
@ -277,7 +281,7 @@
|
|||
1FFA36D71177D879006C8562 /* Controller.m in Sources */,
|
||||
1FFA36D81177D879006C8562 /* ViewDelegate.m in Sources */,
|
||||
1F77DB47118C5F1C007C7F1E /* Constants.m in Sources */,
|
||||
1F618ECA12DB5E6100E500D9 /* TweetModel.m in Sources */,
|
||||
1F618ECA12DB5E6100E500D9 /* PostModel.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
@ -56,6 +56,20 @@
|
|||
|
||||
- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
|
||||
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
NSString *pathToJsPlugin = [@"~/Library/Application Support/Tentia/Plugin.js" stringByExpandingTildeInPath];
|
||||
NSString *pathToCssPlugin = [@"~/Library/Application Support/Tentia/Plugin.css" stringByExpandingTildeInPath];
|
||||
|
||||
if([fileManager fileExistsAtPath:pathToCssPlugin])
|
||||
{
|
||||
[sender stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"setTimeout(function() { loadCssPlugin('file://localhost%@') }, 1000);", pathToCssPlugin]];
|
||||
}
|
||||
|
||||
if([fileManager fileExistsAtPath:pathToJsPlugin])
|
||||
{
|
||||
[sender stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"setTimeout(function() { loadJsPlugin('file://localhost%@') }, 1000);", pathToJsPlugin]];
|
||||
}
|
||||
|
||||
[sender stringByEvaluatingJavaScriptFromString:@"var OS_TYPE = 'mac';"];
|
||||
|
||||
if (sender == oauthView) {
|
||||
|
@ -96,4 +110,16 @@
|
|||
[mentionsView stringByEvaluatingJavaScriptFromString:@"tentia_instance.getNewData();"];
|
||||
}
|
||||
|
||||
- (NSString *)pluginURL
|
||||
{
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
NSString *pathToPlugin = [@"~/Library/Application Support/Tentia/Plugin.js" stringByExpandingTildeInPath];
|
||||
|
||||
if([fileManager fileExistsAtPath:pathToPlugin])
|
||||
{
|
||||
return [NSString stringWithFormat:@"%@", [NSURL fileURLWithPath:pathToPlugin]];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -117,10 +117,10 @@ function(Core, Paths, HostApp, URI) {
|
|||
}
|
||||
}
|
||||
|
||||
Timeline.prototype.sendNewMessage = function(content, in_reply_to_status_id, in_reply_to_entity) {
|
||||
Timeline.prototype.sendNewMessage = function(content, in_reply_to_status_id, in_reply_to_entity, location) {
|
||||
var _this = this;
|
||||
var callback = function(data) { _this.getNewData(); }
|
||||
Core.prototype.sendNewMessage.call(this, content, in_reply_to_status_id, in_reply_to_entity, callback);
|
||||
Core.prototype.sendNewMessage.call(this, content, in_reply_to_status_id, in_reply_to_entity, location, callback);
|
||||
}
|
||||
|
||||
Timeline.prototype.remove = function(id) {
|
||||
|
|
|
@ -237,7 +237,7 @@ function(jQuery, Paths, URI, HostApp, Followings) {
|
|||
}
|
||||
|
||||
// {"type":"Point","coordinates":[57.10803113,12.25854746]}
|
||||
if (status.content && status.content.location && status.content.location.type == "Point") {
|
||||
if (status.content && status.content.location && (typeof status.content.location.type == "undefined" || status.content.location.type == "Point")) {
|
||||
template.geo.href = "http://maps.google.com/maps?q=" + status.content.location.coordinates[0] + "," + status.content.location.coordinates[1];
|
||||
template.geo.style.display = "";
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ function(jQuery, Paths, URI, HostApp, Followings) {
|
|||
return template.item;
|
||||
}
|
||||
|
||||
Core.prototype.sendNewMessage = function(content, in_reply_to_status_id, in_reply_to_entity, callback) {
|
||||
Core.prototype.sendNewMessage = function(content, in_reply_to_status_id, in_reply_to_entity, location, callback) {
|
||||
|
||||
var url = URI(Paths.mkApiRootPath("/posts"));
|
||||
|
||||
|
@ -266,6 +266,10 @@ function(jQuery, Paths, URI, HostApp, Followings) {
|
|||
},
|
||||
};
|
||||
|
||||
if (location) {
|
||||
data["content"]["location"] = { "type": "Point", "coordinates": location }
|
||||
}
|
||||
|
||||
var mentions = this.parseMentions(content, in_reply_to_status_id, in_reply_to_entity);
|
||||
|
||||
if (mentions.length > 0) {
|
||||
|
|
|
@ -105,17 +105,23 @@ var console = {
|
|||
}
|
||||
};
|
||||
|
||||
function loadPlugin(js_url, css_url) {
|
||||
function loadJsPlugin(js_url) {
|
||||
if (js_url) {
|
||||
|
||||
var js_plugin = document.createElement("script");
|
||||
js_plugin.type = "text/javascript";
|
||||
js_plugin.src = js_url;
|
||||
document.getElementsByTagName("head")[0].appendChild(js_plugin);
|
||||
}
|
||||
var plugin = document.createElement("script");
|
||||
plugin.type = "text/javascript";
|
||||
plugin.src = js_url;
|
||||
document.getElementsByTagName("head")[0].appendChild(plugin);
|
||||
}
|
||||
|
||||
if (css_url != null) {
|
||||
function loadCssPlugin(css_url) {
|
||||
|
||||
if (css_url) {
|
||||
var css_plugin = document.createElement("link");
|
||||
css_plugin.rel = 'stylesheet';
|
||||
css_plugin.type = 'text/css'
|
||||
css_plugin.href = css_url;
|
||||
document.getElementsByTagName("head")[0].appendChild(css_plugin);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue