added posting private posts

This commit is contained in:
Jeena Paradies 2012-12-22 19:37:03 +01:00
parent eb540fae1d
commit 2ca5d1ea68
12 changed files with 144 additions and 92 deletions

View file

@ -61,7 +61,7 @@
- (void)initWebViews;
- (void)initHotKeys;
- (void)alertTitle:(NSString *)title withMessage:(NSString *)message;
- (void)openNewMessageWindowInReplyTo:(NSString *)userName statusId:(NSString *)statusId withString:(NSString *)string;
- (void)openNewMessageWindowInReplyTo:(NSString *)userName statusId:(NSString *)statusId withString:(NSString *)string isPrivate:(BOOL)isPrivate;
- (NSString *)pluginURL;
- (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent;
- (void)unreadMentions:(int)count;

View file

@ -296,11 +296,12 @@
[[NSDocumentController sharedDocumentController] openUntitledDocumentAndDisplay:YES error:nil];
}
- (void)openNewMessageWindowInReplyTo:(NSString *)userName statusId:(NSString *)statusId withString:(NSString *)string
- (void)openNewMessageWindowInReplyTo:(NSString *)userName statusId:(NSString *)statusId withString:(NSString *)string isPrivate:(BOOL)isPrivate
{
[NSApp activateIgnoringOtherApps:YES];
NewMessageWindow *newTweet = (NewMessageWindow *)[[NSDocumentController sharedDocumentController] openUntitledDocumentAndDisplay:YES error:nil];
[newTweet inReplyTo:userName statusId:statusId withString:string];
NewMessageWindow *newMessage = (NewMessageWindow *)[[NSDocumentController sharedDocumentController] openUntitledDocumentAndDisplay:YES error:nil];
[newMessage inReplyTo:userName statusId:statusId withString:string];
[newMessage setIsPrivate:isPrivate];
}
- (void)openNewMessageWindowWithString:(NSString *)aString
@ -347,12 +348,18 @@
imageFilePath = [NSString stringWithFormat:@"\"data:%@;base64,%@\"", mimeType, base64];
}
NSString *func = [NSString stringWithFormat:@"tentia_instance.sendNewMessage(\"%@\", \"%@\", \"%@\", %@, %@)",
NSString *isPrivate = @"false";
if (post.isPrivate) {
isPrivate = @"true";
}
NSString *func = [NSString stringWithFormat:@"tentia_instance.sendNewMessage(\"%@\", \"%@\", \"%@\", %@, %@, %@)",
text,
post.inReplyTostatusId,
post.inReplyToEntity,
locationObject,
imageFilePath];
imageFilePath,
isPrivate];
[timelineView stringByEvaluatingJavaScriptFromString:func];
}

View file

@ -131,14 +131,14 @@
<string key="NSFrame">{{2, 0}, {18, 19}}</string>
<reference key="NSSuperview" ref="568628114"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="184011745"/>
<reference key="NSNextKeyView" ref="306901015"/>
<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">
<object class="NSFont" key="NSSupport" id="29">
<string key="NSName">LucidaGrande-Bold</string>
<double key="NSSize">12</double>
<int key="NSfFlags">16</int>
@ -187,6 +187,35 @@
</object>
<bool key="NSAllowsLogicalLayoutDirection">NO</bool>
</object>
<object class="NSButton" id="306901015">
<reference key="NSNextResponder" ref="568628114"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{20, 1}, {19, 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="448152979">
<int key="NSCellFlags">67108864</int>
<int key="NSCellFlags2">134217728</int>
<string key="NSContents"/>
<reference key="NSSupport" ref="29"/>
<string key="NSCellIdentifier">_NS:9</string>
<reference key="NSControlView" ref="306901015"/>
<int key="NSButtonFlags">113524736</int>
<int key="NSButtonFlags2">268435629</int>
<object class="NSCustomResource" key="NSNormalImage">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSLockUnlockedTemplate</string>
</object>
<string key="NSAlternateContents"/>
<string key="NSKeyEquivalent">p</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"/>
@ -394,6 +423,22 @@ A</bytes>
</object>
<int key="connectionID">100073</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">togglePrivate:</string>
<reference key="source" ref="512844837"/>
<reference key="destination" ref="306901015"/>
</object>
<int key="connectionID">100076</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">togglePrivateButton</string>
<reference key="source" ref="512844837"/>
<reference key="destination" ref="306901015"/>
</object>
<int key="connectionID">100080</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
@ -453,6 +498,7 @@ A</bytes>
<reference ref="482035741"/>
<reference ref="647941004"/>
<reference ref="184011745"/>
<reference ref="306901015"/>
</object>
<reference key="parent" ref="275939982"/>
</object>
@ -552,6 +598,20 @@ A</bytes>
<reference key="object" ref="486389227"/>
<reference key="parent" ref="723763594"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">100074</int>
<reference key="object" ref="306901015"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="448152979"/>
</object>
<reference key="parent" ref="568628114"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">100075</int>
<reference key="object" ref="448152979"/>
<reference key="parent" ref="306901015"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@ -574,6 +634,8 @@ A</bytes>
<string>100065.IBPluginDependency</string>
<string>100066.IBPluginDependency</string>
<string>100071.IBPluginDependency</string>
<string>100074.IBPluginDependency</string>
<string>100075.IBPluginDependency</string>
<string>5.IBPluginDependency</string>
<string>5.IBWindowTemplateEditedContentRect</string>
<string>6.IBPluginDependency</string>
@ -597,6 +659,8 @@ A</bytes>
<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>
@ -613,78 +677,11 @@ A</bytes>
<reference key="dict.values" ref="0"/>
</object>
<nil key="sourceID"/>
<int key="maxID">100073</int>
<int key="maxID">100080</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">NSDocument</string>
<object class="NSMutableDictionary" key="actions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>printDocument:</string>
<string>revertDocumentToSaved:</string>
<string>runPageLayout:</string>
<string>saveDocument:</string>
<string>saveDocumentAs:</string>
<string>saveDocumentTo:</string>
</object>
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>printDocument:</string>
<string>revertDocumentToSaved:</string>
<string>runPageLayout:</string>
<string>saveDocument:</string>
<string>saveDocumentAs:</string>
<string>saveDocumentTo:</string>
</object>
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBActionInfo">
<string key="name">printDocument:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">revertDocumentToSaved:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">runPageLayout:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">saveDocument:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">saveDocumentAs:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">saveDocumentTo:</string>
<string key="candidateClassName">id</string>
</object>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/NSDocument.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NewMessageWindow</string>
<string key="superclassName">NSDocument</string>
@ -697,6 +694,7 @@ A</bytes>
<string>openAddMenu:</string>
<string>sendPost:</string>
<string>sendPostButtonPressed:</string>
<string>togglePrivate:</string>
</object>
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
@ -705,6 +703,7 @@ A</bytes>
<string>id</string>
<string>NSControl</string>
<string>id</string>
<string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
@ -716,6 +715,7 @@ A</bytes>
<string>openAddMenu:</string>
<string>sendPost:</string>
<string>sendPostButtonPressed:</string>
<string>togglePrivate:</string>
</object>
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
@ -739,6 +739,10 @@ A</bytes>
<string key="name">sendPostButtonPressed:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">togglePrivate:</string>
<string key="candidateClassName">id</string>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="outlets">
@ -749,6 +753,7 @@ A</bytes>
<string>addMenuButton</string>
<string>counter</string>
<string>textField</string>
<string>togglePrivateButton</string>
</object>
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
@ -756,6 +761,7 @@ A</bytes>
<string>NSButton</string>
<string>NSTextField</string>
<string>NSTextField</string>
<string>NSButton</string>
</object>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
@ -766,6 +772,7 @@ A</bytes>
<string>addMenuButton</string>
<string>counter</string>
<string>textField</string>
<string>togglePrivateButton</string>
</object>
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
@ -785,6 +792,10 @@ A</bytes>
<string key="name">textField</string>
<string key="candidateClassName">NSTextField</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">togglePrivateButton</string>
<string key="candidateClassName">NSButton</string>
</object>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
@ -807,12 +818,14 @@ A</bytes>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>NSAddTemplate</string>
<string>NSLockUnlockedTemplate</string>
<string>NSMenuCheckmark</string>
<string>NSMenuMixedState</string>
</object>
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>{8, 8}</string>
<string>{9, 12}</string>
<string>{11, 11}</string>
<string>{10, 3}</string>
</object>

View file

@ -23,6 +23,7 @@
CLLocationManager *locationManager;
CLLocation *currentLocation;
NSString *imageFilePath;
NSButton *togglePrivateButton;
}
@property (nonatomic, retain) IBOutlet NSTextField *textField;
@ -32,6 +33,7 @@
@property (retain, nonatomic) CLLocationManager *locationManager;
@property (retain, nonatomic) CLLocation *currentLocation;
@property (retain, nonatomic) NSString *imageFilePath;
@property (assign) IBOutlet NSButton *togglePrivateButton;
- (IBAction)sendPost:(NSControl *)control;
- (void)inReplyTo:(NSString *)userName statusId:(NSString *)statusId withString:(NSString *)string;
@ -39,5 +41,7 @@
- (IBAction)addCurrentLocation:(id)sender;
- (IBAction)addImage:(id)sender;
- (IBAction)openAddMenu:(id)sender;
- (IBAction)togglePrivate:(id)sender;
- (void)setIsPrivate:(BOOL)isPrivate;
@end

View file

@ -23,6 +23,7 @@
@synthesize textField, counter;
@synthesize locationManager, currentLocation;
@synthesize imageFilePath;
@synthesize togglePrivateButton;
- (void)dealloc
{
@ -159,6 +160,21 @@
[NSMenu popUpContextMenu:self.addMenu withEvent:event forView:self.addMenuButton];
}
- (IBAction)togglePrivate:(id)sender
{
NSImage *image = [NSImage imageNamed:NSImageNameLockLockedTemplate];
if (self.togglePrivateButton.image == [NSImage imageNamed:NSImageNameLockLockedTemplate])
{
image = [NSImage imageNamed:NSImageNameLockUnlockedTemplate];
}
[self.togglePrivateButton setImage:image];
}
- (void)setIsPrivate:(BOOL)isPrivate {
NSImage *image = [NSImage imageNamed:(isPrivate ? NSImageNameLockLockedTemplate : NSImageNameLockUnlockedTemplate)];
[self.togglePrivateButton setImage:image];
}
-(void)controlTextDidChange:(NSNotification *)aNotification {
NSInteger c = MESSAGE_MAX_LENGTH - [[textField stringValue] length];
[counter setIntValue:c];
@ -207,6 +223,7 @@
post.inReplyToEntity = inReplyToEntity;
post.location = self.currentLocation;
post.imageFilePath = self.imageFilePath;
post.isPrivate = self.togglePrivateButton.image == [NSImage imageNamed:NSImageNameLockLockedTemplate];
[[NSNotificationCenter defaultCenter] postNotificationName:@"sendTweet" object:post];
[self close];
} else {

View file

@ -15,6 +15,7 @@
NSString *inReplyToEntity;
CLLocation *location;
NSString *imageFilePath;
BOOL isPrivate;
}
@property (nonatomic, retain) NSString *text;
@ -22,5 +23,6 @@
@property (nonatomic, retain) NSString *inReplyToEntity;
@property (nonatomic, retain) CLLocation *location;
@property (nonatomic, retain) NSString *imageFilePath;
@property (nonatomic) BOOL isPrivate;
@end

View file

@ -11,7 +11,7 @@
@implementation PostModel
@synthesize text, inReplyTostatusId, inReplyToEntity, location, imageFilePath;
@synthesize text, inReplyTostatusId, inReplyToEntity, location, imageFilePath, isPrivate;
- (void)dealloc
{