}
static void
-notifyBatchChange( tr_session * session, tr_torrent ** torrents, int n )
+notifyBatchQueueChange( tr_session * session, tr_torrent ** torrents, int n )
{
int i;
for( i=0; i<n; ++i )
notify( session, TR_RPC_TORRENT_CHANGED, torrents[i] );
+ notify( session, TR_RPC_SESSION_QUEUE_POSITIONS_CHANGED, NULL );
}
static const char*
int n;
tr_torrent ** torrents = getTorrents( session, args_in, &n );
tr_torrentsQueueMoveTop( torrents, n );
- notifyBatchChange( session, torrents, n );
+ notifyBatchQueueChange( session, torrents, n );
tr_free( torrents );
return NULL;
}
int n;
tr_torrent ** torrents = getTorrents( session, args_in, &n );
tr_torrentsQueueMoveUp( torrents, n );
- notifyBatchChange( session, torrents, n );
+ notifyBatchQueueChange( session, torrents, n );
tr_free( torrents );
return NULL;
}
int n;
tr_torrent ** torrents = getTorrents( session, args_in, &n );
tr_torrentsQueueMoveDown( torrents, n );
- notifyBatchChange( session, torrents, n );
+ notifyBatchQueueChange( session, torrents, n );
tr_free( torrents );
return NULL;
}
int n;
tr_torrent ** torrents = getTorrents( session, args_in, &n );
tr_torrentsQueueMoveBottom( torrents, n );
- notifyBatchChange( session, torrents, n );
+ notifyBatchQueueChange( session, torrents, n );
tr_free( torrents );
return NULL;
}
[self performSelectorOnMainThread: @selector(rpcMovedTorrent:) withObject: torrent waitUntilDone: NO];
break;
+ case TR_RPC_SESSION_QUEUE_POSITIONS_CHANGED:
+ [self performSelectorOnMainThread: @selector(rpcUpdateQueue) withObject: nil waitUntilDone: NO];
+ break;
+
case TR_RPC_SESSION_CHANGED:
[fPrefsController performSelectorOnMainThread: @selector(rpcUpdatePrefs) withObject: nil waitUntilDone: NO];
break;
[torrent release];
}
+- (void) rpcUpdateQueue
+{
+ NSLog(@"rpcUpdateQueue");
+
+ for (Torrent * torrent in fTorrents)
+ [torrent update];
+
+ NSSortDescriptor * descriptor = [[NSSortDescriptor alloc] initWithKey: @"queuePosition" ascending: YES];
+ NSArray * descriptors = [NSArray arrayWithObject: descriptor];
+ [descriptor release];
+
+ [fTorrents sortUsingDescriptors: descriptors];
+
+ [self fullUpdateUI];
+}
+
@end