Skip to content

Commit

Permalink
Trying to remove multiple tweets caused by calling sendupdate during …
Browse files Browse the repository at this point in the history
…wrong phase
  • Loading branch information
Simon Madine committed Nov 6, 2009
1 parent 227d915 commit 0647d13
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 15 deletions.
10 changes: 6 additions & 4 deletions source/GrowlBirdDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@

#import <Cocoa/Cocoa.h>
#import <GrowlDisplayPlugin.h>
#import "MGTwitterEngine.h"

@class GrowlApplicationNotification;

@interface GrowlBirdDisplay : GrowlDisplayPlugin {
// @class GrowlApplicationNotification;

@interface GrowlBirdDisplay : GrowlDisplayPlugin <MGTwitterEngineDelegate> {
MGTwitterEngine *twitterEngine;
}

- (void) configureBridge:(GrowlNotificationDisplayBridge *)theBridge;
- (void) displayNotification:(GrowlApplicationNotification *)notification;

@end
71 changes: 62 additions & 9 deletions source/GrowlBirdDisplay.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ @implementation GrowlBirdDisplay
- (id) init {
if ((self = [super init])) {
windowControllerClass = NSClassFromString(@"GrowlBirdWindowController");
twitterEngine = [[MGTwitterEngine alloc] initWithDelegate:self];
}
return self;
}
Expand Down Expand Up @@ -44,17 +45,69 @@ - (BOOL)requiresPositioning {
#pragma mark GAB
#pragma mark -

- (void) configureBridge:(GrowlNotificationDisplayBridge *)theBridge {
GrowlBirdWindowController *controller = [[theBridge windowControllers] objectAtIndex:0U];
GrowlApplicationNotification *note = [theBridge notification];
NSDictionary *noteDict = [note dictionaryRepresentation];
- (void) displayNotification:(GrowlApplicationNotification *)notification {
NSString *twitter_username = Bird_DEFAULT_USERNAME;
NSString *twitter_password = Bird_DEFAULT_PASSWORD;
READ_GROWL_PREF_VALUE(Bird_USERNAME_PREF, SamplePrefDomain, NSString *, &twitter_username);
READ_GROWL_PREF_VALUE(Bird_PASSWORD_PREF, SamplePrefDomain, NSString *, &twitter_password);
[twitterEngine setUsername:twitter_username password:twitter_password];
NSLog(@"Twitter Login: username = %@", twitter_username);

[controller setNotifyingApplicationName:[note applicationName]];
[controller setNotifyingApplicationProcessIdentifier:[noteDict objectForKey:GROWL_APP_PID]];
[controller setClickContext:[noteDict objectForKey:GROWL_NOTIFICATION_CLICK_CONTEXT]];
[controller setScreenshotModeEnabled:getBooleanForKey(noteDict, GROWL_SCREENSHOT_MODE)];
[controller setClickHandlerEnabled:[noteDict objectForKey:@"ClickHandlerEnabled"]];
NSString *tweet_prefix = Bird_DEFAULT_PREFIX;
NSString *tweet_postfix = Bird_DEFAULT_POSTFIX;
READ_GROWL_PREF_VALUE(Bird_PREFIX_PREF, SamplePrefDomain, NSString *, &tweet_prefix);
READ_GROWL_PREF_VALUE(Bird_POSTFIX_PREF, SamplePrefDomain, NSString *, &tweet_postfix);

int formatPref = Bird_FORMAT_BOTH;
READ_GROWL_PREF_INT(Bird_FORMAT_PREF, SamplePrefDomain, &formatPref);
if (formatPref == Bird_FORMAT_TITLE) {
// NSLog(@"format is title");
NSLog(@"sendUpdate: connectionIdentifier = %@", [twitterEngine sendUpdate:[NSString stringWithFormat:@"%@%@%@", tweet_prefix, title, tweet_postfix]]);
} else if (formatPref == Bird_FORMAT_TEXT) {
// NSLog(@"format is text");
NSLog(@"sendUpdate: connectionIdentifier = %@", [twitterEngine sendUpdate:[NSString stringWithFormat:@"%@%@%@", tweet_prefix, text, tweet_postfix]]);
} else {
// NSLog(@"format is both");
NSLog(@"sendUpdate: connectionIdentifier = %@", [twitterEngine sendUpdate:[NSString stringWithFormat:@"%@%@, %@%@", tweet_prefix, title, text, tweet_postfix]]);
}

// NSLog(@"sendUpdate: connectionIdentifier = %@", [twitterEngine sendUpdate:[NSString stringWithFormat:@"%@%@, %@%@", tweet_prefix, title, text, tweet_postfix]]);

// GrowlBirdWindowController *controller = [[theBridge windowControllers] objectAtIndex:0U];
// GrowlApplicationNotification *note = [theBridge notification];
// NSDictionary *noteDict = [note dictionaryRepresentation];
//
// [controller setNotifyingApplicationName:[note applicationName]];
// [controller setNotifyingApplicationProcessIdentifier:[noteDict objectForKey:GROWL_APP_PID]];
// [controller setClickContext:[noteDict objectForKey:GROWL_NOTIFICATION_CLICK_CONTEXT]];
// [controller setScreenshotModeEnabled:getBooleanForKey(noteDict, GROWL_SCREENSHOT_MODE)];
// [controller setClickHandlerEnabled:[noteDict objectForKey:@"ClickHandlerEnabled"]];

}

#pragma mark MGTwitterEngineDelegate Methods

- (void)requestSucceeded:(NSString *)requestIdentifier {

}
- (void)requestFailed:(NSString *)requestIdentifier withError:(NSError *)error {

}
- (void)statusesReceived:(NSArray *)statuses forRequest:(NSString *)identifier {

}
- (void)directMessagesReceived:(NSArray *)messages forRequest:(NSString *)identifier {

}
- (void)userInfoReceived:(NSArray *)userInfo forRequest:(NSString *)identifier {

}
- (void)miscInfoReceived:(NSArray *)miscInfo forRequest:(NSString *)identifier {

}
- (void)imageReceived:(NSImage *)image forRequest:(NSString *)identifier {

}


@end
4 changes: 2 additions & 2 deletions source/GrowlBirdWindowController.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//

#import "GrowlDisplayWindowController.h"
#import "MGTwitterEngine.h"
// #import "MGTwitterEngine.h"


@class GrowlBirdWindowView;
Expand All @@ -15,7 +15,7 @@
CGFloat frameHeight;
NSInteger priority;
NSPoint frameOrigin;
MGTwitterEngine *twitterEngine;
// MGTwitterEngine *twitterEngine;
}

@end

0 comments on commit 0647d13

Please sign in to comment.