Permalink
Browse files

Added a delegate to WLRemoteLink and implemented two methods to infor…

…m the delegate of failed/finished actions
  • Loading branch information...
1 parent 76fd1de commit 30ab7386a12b5e9e2c386e105e4b9486ff540f3f Miles Tinsley committed May 10, 2012
Showing with 15 additions and 0 deletions.
  1. +15 −0 WLRemoteLink.j
View
@@ -66,6 +66,7 @@ WLLoginActionDidFailNotification = "WLLoginDidFailNotification";
*/
@implementation WLRemoteLink : CPObject
{
+ id _delegate @accessors(property=delegate);
CPArray actionQueue;
CPString baseUrl @accessors;
int updateDelay;
@@ -238,6 +239,13 @@ WLLoginActionDidFailNotification = "WLLoginDidFailNotification";
- (void)remoteActionDidFail:(WLRemoteAction)anAction dueToAuthentication:(BOOL)dueToAuthentication
{
CPLog.error("Action failed " + anAction);
+
+ // Tell the delegate an action has failed
+ if ([_delegate respondsToSelector:@selector(remoteActionDidFail:dueToAuthentication:)])
+ {
+ [_delegate remoteActionDidFail:anAction dueToAuthentication:dueToAuthentication];
+ }
+
// Ready the action for a later retry.
[anAction reset];
@@ -274,6 +282,13 @@ WLLoginActionDidFailNotification = "WLLoginDidFailNotification";
{
//CPLog.info("Remote op finished: "+[anAction description]);
+ // Tell the delegate an action has finished
+ if ([_delegate respondsToSelector:@selector(remoteActionDidFinish:)])
+ {
+ [_delegate remoteActionDidFinish:anAction];
+ }
+
+
var actionIndex = [actionQueue indexOfObject:anAction];
if (actionIndex == CPNotFound && ![anAction isLoginAction])
{

0 comments on commit 30ab738

Please sign in to comment.