mirror of
https://github.com/transmission/transmission
synced 2024-12-25 09:13:06 +00:00
add an RPC session callback for when queue order changes
This commit is contained in:
parent
f2f0dc1861
commit
516164e78e
5 changed files with 28 additions and 6 deletions
|
@ -187,11 +187,12 @@ getTorrents( tr_session * session,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
notifyBatchChange( tr_session * session, tr_torrent ** torrents, int n )
|
notifyBatchQueueChange( tr_session * session, tr_torrent ** torrents, int n )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for( i=0; i<n; ++i )
|
for( i=0; i<n; ++i )
|
||||||
notify( session, TR_RPC_TORRENT_CHANGED, torrents[i] );
|
notify( session, TR_RPC_TORRENT_CHANGED, torrents[i] );
|
||||||
|
notify( session, TR_RPC_SESSION_QUEUE_POSITIONS_CHANGED, NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char*
|
static const char*
|
||||||
|
@ -203,7 +204,7 @@ queueMoveTop( tr_session * session,
|
||||||
int n;
|
int n;
|
||||||
tr_torrent ** torrents = getTorrents( session, args_in, &n );
|
tr_torrent ** torrents = getTorrents( session, args_in, &n );
|
||||||
tr_torrentsQueueMoveTop( torrents, n );
|
tr_torrentsQueueMoveTop( torrents, n );
|
||||||
notifyBatchChange( session, torrents, n );
|
notifyBatchQueueChange( session, torrents, n );
|
||||||
tr_free( torrents );
|
tr_free( torrents );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -217,7 +218,7 @@ queueMoveUp( tr_session * session,
|
||||||
int n;
|
int n;
|
||||||
tr_torrent ** torrents = getTorrents( session, args_in, &n );
|
tr_torrent ** torrents = getTorrents( session, args_in, &n );
|
||||||
tr_torrentsQueueMoveUp( torrents, n );
|
tr_torrentsQueueMoveUp( torrents, n );
|
||||||
notifyBatchChange( session, torrents, n );
|
notifyBatchQueueChange( session, torrents, n );
|
||||||
tr_free( torrents );
|
tr_free( torrents );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -231,7 +232,7 @@ queueMoveDown( tr_session * session,
|
||||||
int n;
|
int n;
|
||||||
tr_torrent ** torrents = getTorrents( session, args_in, &n );
|
tr_torrent ** torrents = getTorrents( session, args_in, &n );
|
||||||
tr_torrentsQueueMoveDown( torrents, n );
|
tr_torrentsQueueMoveDown( torrents, n );
|
||||||
notifyBatchChange( session, torrents, n );
|
notifyBatchQueueChange( session, torrents, n );
|
||||||
tr_free( torrents );
|
tr_free( torrents );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -245,7 +246,7 @@ queueMoveBottom( tr_session * session,
|
||||||
int n;
|
int n;
|
||||||
tr_torrent ** torrents = getTorrents( session, args_in, &n );
|
tr_torrent ** torrents = getTorrents( session, args_in, &n );
|
||||||
tr_torrentsQueueMoveBottom( torrents, n );
|
tr_torrentsQueueMoveBottom( torrents, n );
|
||||||
notifyBatchChange( session, torrents, n );
|
notifyBatchQueueChange( session, torrents, n );
|
||||||
tr_free( torrents );
|
tr_free( torrents );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -517,6 +517,7 @@ typedef enum
|
||||||
TR_RPC_TORRENT_CHANGED, /* catch-all for the "torrent-set" rpc method */
|
TR_RPC_TORRENT_CHANGED, /* catch-all for the "torrent-set" rpc method */
|
||||||
TR_RPC_TORRENT_MOVED,
|
TR_RPC_TORRENT_MOVED,
|
||||||
TR_RPC_SESSION_CHANGED,
|
TR_RPC_SESSION_CHANGED,
|
||||||
|
TR_RPC_SESSION_QUEUE_POSITIONS_CHANGED, /* catch potentially multiple torrents being moved in the queue */
|
||||||
TR_RPC_SESSION_CLOSE
|
TR_RPC_SESSION_CLOSE
|
||||||
}
|
}
|
||||||
tr_rpc_callback_type;
|
tr_rpc_callback_type;
|
||||||
|
|
|
@ -261,5 +261,6 @@ typedef enum
|
||||||
- (void) rpcStartedStoppedTorrent: (Torrent *) torrent;
|
- (void) rpcStartedStoppedTorrent: (Torrent *) torrent;
|
||||||
- (void) rpcChangedTorrent: (Torrent *) torrent;
|
- (void) rpcChangedTorrent: (Torrent *) torrent;
|
||||||
- (void) rpcMovedTorrent: (Torrent *) torrent;
|
- (void) rpcMovedTorrent: (Torrent *) torrent;
|
||||||
|
- (void) rpcUpdateQueue;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -4143,6 +4143,10 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
||||||
[self performSelectorOnMainThread: @selector(rpcMovedTorrent:) withObject: torrent waitUntilDone: NO];
|
[self performSelectorOnMainThread: @selector(rpcMovedTorrent:) withObject: torrent waitUntilDone: NO];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case TR_RPC_SESSION_QUEUE_POSITIONS_CHANGED:
|
||||||
|
[self performSelectorOnMainThread: @selector(rpcUpdateQueue) withObject: nil waitUntilDone: NO];
|
||||||
|
break;
|
||||||
|
|
||||||
case TR_RPC_SESSION_CHANGED:
|
case TR_RPC_SESSION_CHANGED:
|
||||||
[fPrefsController performSelectorOnMainThread: @selector(rpcUpdatePrefs) withObject: nil waitUntilDone: NO];
|
[fPrefsController performSelectorOnMainThread: @selector(rpcUpdatePrefs) withObject: nil waitUntilDone: NO];
|
||||||
break;
|
break;
|
||||||
|
@ -4224,4 +4228,20 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
||||||
[torrent release];
|
[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
|
@end
|
||||||
|
|
|
@ -346,7 +346,6 @@ int trashDataFile(const char * filename)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#warning remove
|
|
||||||
- (NSInteger) queuePosition
|
- (NSInteger) queuePosition
|
||||||
{
|
{
|
||||||
return fStat->queuePosition;
|
return fStat->queuePosition;
|
||||||
|
|
Loading…
Reference in a new issue