+ rating += 0.2;
+ if (rating > 1.0) {
+ rating = 1.0;
+ }
+ ITDebugLog(@"Setting rating to %f", rating);
+ [[self currentRemote] setCurrentSongRating:rating];
+
+ //Show rating status window
+ [statusWindowController showRatingWindowWithRating:rating];
+ NS_HANDLER
+ [self networkError:localException];
+ NS_ENDHANDLER
+}
+
+- (void)decrementRating
+{
+ NS_DURING
+ float rating = [[self currentRemote] currentSongRating];
+ ITDebugLog(@"Decrementing rating.");
+
+ if ([[self currentRemote] currentPlaylistIndex] == 0) {
+ ITDebugLog(@"No song playing, rating change aborted.");
+ return;
+ }
+
+ rating -= 0.2;
+ if (rating < 0.0) {
+ rating = 0.0;
+ }
+ ITDebugLog(@"Setting rating to %f", rating);
+ [[self currentRemote] setCurrentSongRating:rating];
+
+ //Show rating status window
+ [statusWindowController showRatingWindowWithRating:rating];
+ NS_HANDLER
+ [self networkError:localException];
+ NS_ENDHANDLER
+}
+
+- (void)setRating:(ITHotKey *)sender
+{
+ int stars = [[sender name] characterAtIndex:9] - 48;
+ [self selectSongRating:stars * 20];
+ [statusWindowController showRatingWindowWithRating:(float)stars / 5.0];
+}
+
+- (void)toggleLoop
+{
+ NS_DURING
+ ITMTRemotePlayerRepeatMode repeatMode = [[self currentRemote] repeatMode];
+ ITDebugLog(@"Toggling repeat mode.");
+ switch (repeatMode) {
+ case ITMTRemotePlayerRepeatOff:
+ repeatMode = ITMTRemotePlayerRepeatAll;
+ break;
+ case ITMTRemotePlayerRepeatAll:
+ repeatMode = ITMTRemotePlayerRepeatOne;
+ break;
+ case ITMTRemotePlayerRepeatOne:
+ repeatMode = ITMTRemotePlayerRepeatOff;
+ break;
+ }
+ ITDebugLog(@"Setting repeat mode to %i", repeatMode);
+ [[self currentRemote] setRepeatMode:repeatMode];
+
+ //Show loop status window
+ [statusWindowController showRepeatWindowWithMode:repeatMode];
+ NS_HANDLER
+ [self networkError:localException];
+ NS_ENDHANDLER
+}
+
+- (void)toggleShuffle
+{
+ NS_DURING
+ BOOL newShuffleEnabled = ( ! [[self currentRemote] shuffleEnabled] );
+ ITDebugLog(@"Toggling shuffle mode.");
+ [[self currentRemote] setShuffleEnabled:newShuffleEnabled];
+ //Show shuffle status window
+ ITDebugLog(@"Setting shuffle mode to %i", newShuffleEnabled);
+ [statusWindowController showShuffleWindow:newShuffleEnabled];
+ NS_HANDLER
+ [self networkError:localException];
+ NS_ENDHANDLER
+}
+
+- (void)registerNowOK
+{
+ [[StatusWindow sharedWindow] setLocked:NO];
+ [[StatusWindow sharedWindow] vanish:self];
+ [[StatusWindow sharedWindow] setIgnoresMouseEvents:YES];
+
+ [self blingNow];
+}
+
+- (void)registerNowCancel
+{
+ [[StatusWindow sharedWindow] setLocked:NO];
+ [[StatusWindow sharedWindow] vanish:self];
+ [[StatusWindow sharedWindow] setIgnoresMouseEvents:YES];
+
+ [NSApp terminate:self];
+}
+
+/*************************************************************************/
+#pragma mark -
+#pragma mark NETWORK HANDLERS
+/*************************************************************************/
+
+- (void)setServerStatus:(BOOL)newStatus
+{
+ if (newStatus) {
+ //Turn on
+ [networkController setServerStatus:YES];
+ } else {
+ //Tear down
+ [networkController setServerStatus:NO];
+ }
+}
+
+- (int)connectToServer
+{
+ int result;
+ ITDebugLog(@"Attempting to connect to shared remote.");
+ result = [networkController connectToHost:[df stringForKey:@"sharedPlayerHost"]];
+ //Connect
+ if (result == 1) {
+ [[PreferencesController sharedPrefs] resetRemotePlayerTextFields];
+ currentRemote = [[[networkController networkObject] remote] retain];