summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorLars-Dominik Braun <PromyLOPh@gmail.com>2008-08-17 21:31:33 +0200
committerLars-Dominik Braun <PromyLOPh@gmail.com>2008-08-17 21:31:33 +0200
commit69c04691c486aaf39cbe3c70e9e3cb47a2ad934a (patch)
tree47457744e7c8b67342ec7ad0e6f8b2617297ad76 /src/main.c
parent8beb2162be16ac4311ffdd397f0337e5ad0934d4 (diff)
downloadpianobar-windows-69c04691c486aaf39cbe3c70e9e3cb47a2ad934a.tar.gz
pianobar-windows-69c04691c486aaf39cbe3c70e9e3cb47a2ad934a.tar.bz2
pianobar-windows-69c04691c486aaf39cbe3c70e9e3cb47a2ad934a.zip
Transform station before changing anything
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c46
1 files changed, 34 insertions, 12 deletions
diff --git a/src/main.c b/src/main.c
index 45cbc4c..6814f79 100644
--- a/src/main.c
+++ b/src/main.c
@@ -358,6 +358,23 @@ void BarStationFromGenre (PianoHandle_t *ph) {
BarUiPrintPianoStatus (PianoCreateStation (ph, "sh", curStation->id));
}
+/* transform station if necessary to allow changes like rename, rate, ...
+ * @param piano handle
+ * @param transform this station
+ * @return 0 = error, 1 = everything went well
+ */
+int BarTransformIfShared (PianoHandle_t *ph, PianoStation_t *station) {
+ /* shared stations must be transformed */
+ if (!station->isCreator) {
+ BarUiMsg ("Transforming station... ");
+ if (BarUiPrintPianoStatus (PianoTransformShared (ph, station)) !=
+ PIANO_RET_OK) {
+ return 0;
+ }
+ }
+ return 1;
+}
+
int main (int argc, char **argv) {
PianoHandle_t ph;
struct aacPlayer player;
@@ -543,6 +560,9 @@ int main (int argc, char **argv) {
}
musicId = BarUiSelectMusicId (&ph);
if (musicId == NULL) {
+ if (!BarTransformIfShared (&ph, curStation)) {
+ break;
+ }
BarUiMsg ("Adding music to station... ");
BarUiPrintPianoStatus (PianoStationAddMusic (&ph,
curStation, musicId));
@@ -555,12 +575,8 @@ int main (int argc, char **argv) {
BarUiMsg ("No song playing.\n");
break;
}
- if (!curStation->isCreator) {
- BarUiMsg ("Transforming station... ");
- if (BarUiPrintPianoStatus (PianoTransformShared (&ph,
- curStation)) != PIANO_RET_OK) {
- break;
- }
+ if (!BarTransformIfShared (&ph, curStation)) {
+ break;
}
BarUiMsg ("Banning song... ");
if (BarUiPrintPianoStatus (PianoRateTrack (&ph, curSong,
@@ -653,12 +669,8 @@ int main (int argc, char **argv) {
BarUiMsg ("Already loved. No need to do this twice.\n");
break;
}
- if (!curStation->isCreator) {
- BarUiMsg ("Transforming station... ");
- if (BarUiPrintPianoStatus (PianoTransformShared (&ph,
- curStation)) != PIANO_RET_OK) {
- break;
- }
+ if (!BarTransformIfShared (&ph, curStation)) {
+ break;
}
BarUiMsg ("Loving song... ");
BarUiPrintPianoStatus (PianoRateTrack (&ph, curSong,
@@ -676,6 +688,10 @@ int main (int argc, char **argv) {
}
moveStation = BarUiSelectStation (&ph, "Move song to station: ");
if (moveStation != NULL) {
+ if (!BarTransformIfShared (&ph, curStation) ||
+ !BarTransformIfShared (&ph, moveStation)) {
+ break;
+ }
printf ("Moving song to \"%s\"... ", moveStation->name);
fflush (stdout);
if (BarUiPrintPianoStatus (PianoMoveSong (&ph,
@@ -702,6 +718,9 @@ int main (int argc, char **argv) {
}
lineBuf = readline ("New name?\n");
if (lineBuf != NULL && strlen (lineBuf) > 0) {
+ if (!BarTransformIfShared (&ph, curStation)) {
+ break;
+ }
BarUiMsg ("Renaming station... ");
BarUiPrintPianoStatus (PianoRenameStation (&ph,
curStation, lineBuf));
@@ -726,6 +745,9 @@ int main (int argc, char **argv) {
BarUiMsg ("No song playing.\n");
break;
}
+ if (!BarTransformIfShared (&ph, curStation)) {
+ break;
+ }
BarUiMsg ("Putting song on shelf... ");
if (BarUiPrintPianoStatus (PianoSongTired (&ph,
curSong)) == PIANO_RET_OK) {