Permalink
Browse files

getUnreadCount re-implemented

  • Loading branch information...
1 parent 52314d7 commit e510662f9b959a4d578b449c85ef0f290e37776e Mike Godenzi committed May 25, 2010
Showing with 81 additions and 79 deletions.
  1. +6 −3 Classes/NetParam.h
  2. +15 −3 Classes/NetParam.m
  3. +3 −3 Controllers/MainController.h
  4. +57 −70 Controllers/MainController.m
View
@@ -14,13 +14,16 @@
SEL successMethod;
SEL failMethod;
id<NSObject> secondParam;
+ id<NSObject> target;
}
@property(nonatomic, readonly) SEL successMethod;
@property(nonatomic, readonly) SEL failMethod;
@property(nonatomic, readonly) id<NSObject> secondParam;
+@property(nonatomic, readonly) id<NSObject> target;
-- (id)initWithSuccess:(SEL)success andFail:(SEL)fail;
-- (id)initWithSuccess:(SEL)success fail:(SEL)fail andSecondParam:(id<NSObject>)sp;
-
+- (id)initWithSuccess:(SEL)success andFail:(SEL)fail onTarget:(id<NSObject>)t;
+- (id)initWithSuccess:(SEL)success fail:(SEL)fail andSecondParam:(id<NSObject>)sp onTarget:(id<NSObject>)t;
+- (void)invokeSuccessWithFirstParam:(id)firstParam;
+- (void)invokeFailWithError:(NSError *)error;
@end
View
@@ -11,28 +11,40 @@
@implementation NetParam
-@synthesize successMethod, failMethod, secondParam;
+@synthesize successMethod, failMethod, secondParam, target;
-- (id)initWithSuccess:(SEL)success andFail:(SEL)fail {
+- (id)initWithSuccess:(SEL)success andFail:(SEL)fail onTarget:(id<NSObject>)t {
if (self = [super init]) {
successMethod = success;
failMethod = fail;
secondParam = nil;
+ target = [t retain];
}
return self;
}
-- (id)initWithSuccess:(SEL)success fail:(SEL)fail andSecondParam:(id<NSObject>)sp {
+- (id)initWithSuccess:(SEL)success fail:(SEL)fail andSecondParam:(id<NSObject>)sp onTarget:(id<NSObject>)t {
if (self = [super init]) {
successMethod = success;
failMethod = fail;
secondParam = [sp retain];
+ target = [t retain];
}
return self;
}
+- (void)invokeSuccessWithFirstParam:(id)firstParam {
+ DLog(@"INVOKING WITH SECOND PARAM: %@", [secondParam description]);
+ [target performSelector:successMethod withObject:firstParam withObject:secondParam];
+}
+
+- (void)invokeFailWithError:(NSError *)error {
+ [target performSelector:failMethod withObject:error];
+}
+
- (void)dealloc {
[secondParam release];
+ [target release];
[super dealloc];
}
@@ -13,6 +13,7 @@
#import "IPMNetworkManagerDelegate.h"
@class IPMNetworkManager;
+@class NetParam;
@interface MainController : NSObject<GrowlApplicationBridgeDelegate, IPMNetworkManagerDelegate> {
IBOutlet NSSecureTextField * passwordField;
@@ -71,15 +72,15 @@
- (NSAttributedString *)makeAttributedStatusItemString:(NSString *)text;
- (NSAttributedString *)makeAttributedMenuStringWithBigText:(NSString *)bigtext andSmallText:(NSString *)smalltext;
- (void)addFeed:(NSString *)url;
-- (void)displayAlert:(NSString *)headerText:(NSString *)bodyText;
+- (void)displayAlertWithHeader:(NSString *)headerText andBody:(NSString *)bodyText;
- (void)displayMessage:(NSString *)message;
- (NSString *)grabUserNo;
- (NSString *)loginToGoogle;
- (void)removeAllItemsFromMenubar;
- (void)getTokenFromGoogle;
- (void)removeOneItemFromMenu:(NSInteger)index;
- (void)timer:(NSTimer *)timer;
-- (void)getUnreadCount;
+- (void)getUnreadCountWithDeferredCall:(NetParam *)dc;
- (void)retrieveGoogleFeed;
- (void)updateMenu;
- (void)setTimeDelay:(NSInteger)x;
@@ -98,7 +99,6 @@
- (void)lastTimeCheckedTimer:(NSTimer *)timer;
- (void)selectTorrentCastFolderEnded:(NSOpenPanel *)panel returnCode:(int)returnCode contextInfo:(void *)contextInfo;
- (void)checkNowWithDelayDetached:(NSNumber *)delay;
-- (NSString *)getGoogleSIDClean;
- (void)markResultsAsReadDetached;
- (void)markOneAsReadDetached:(NSNumber *)aNumber;
- (void)markAllAsReadDetached;
Oops, something went wrong.

0 comments on commit e510662

Please sign in to comment.