Skip to content

Instantly share code, notes, and snippets.

Created July 18, 2013 19:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/6032071 to your computer and use it in GitHub Desktop.
Save anonymous/6032071 to your computer and use it in GitHub Desktop.
diff --git a/src/libpiano/piano.c b/src/libpiano/piano.c
index 9020a6a..3305be6 100644
--- a/src/libpiano/piano.c
+++ b/src/libpiano/piano.c
@@ -107,7 +107,7 @@ void PianoDestroyStation (PianoStation_t *station) {
/* free complete station list
* @param piano handle
*/
-static void PianoDestroyStations (PianoStation_t *stations) {
+void PianoDestroyStations (PianoStation_t *stations) {
PianoStation_t *curStation, *lastStation;
curStation = stations;
diff --git a/src/libpiano/response.c b/src/libpiano/response.c
index 1b63bee..0fac5fc 100644
--- a/src/libpiano/response.c
+++ b/src/libpiano/response.c
@@ -174,6 +174,9 @@ PianoReturn_t PianoResponse (PianoHandle_t *ph, PianoRequest_t *req) {
/* get stations */
assert (req->responseData != NULL);
+ PianoDestroyStations (ph->stations);
+ ph->stations = NULL;
+
json_object *stations = json_object_object_get (result,
"stations"), *mix = NULL;
diff --git a/src/settings.h b/src/settings.h
index aad1fc4..97c86e4 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -60,8 +60,9 @@ typedef enum {
BAR_KS_PLAY = 26,
BAR_KS_PAUSE = 27,
BAR_KS_VOLRESET = 28,
+ BAR_KS_RELOADSTATIONS = 29,
/* insert new shortcuts _before_ this element and increase its value */
- BAR_KS_COUNT = 29,
+ BAR_KS_COUNT = 30,
} BarKeyShortcutId_t;
#define BAR_KS_DISABLED '\x00'
diff --git a/src/ui_act.c b/src/ui_act.c
index 270c1f5..51d9a8a 100644
--- a/src/ui_act.c
+++ b/src/ui_act.c
@@ -788,3 +788,13 @@ BarUiActCallback(BarUiActManageStation) {
PianoDestroyStationInfo (&reqData.info);
}
+/* reload stations
+ */
+BarUiActCallback(BarUiActReloadStations) {
+ PianoReturn_t pRet;
+ WaitressReturn_t wRet;
+
+ BarUiMsg (&app->settings, MSG_INFO, "Retrieving stations... ");
+ BarUiActDefaultPianoCall (PIANO_REQUEST_GET_STATIONS, NULL);
+ BarUiActDefaultEventcmd ("usergetstations");
+}
diff --git a/src/ui_act.h b/src/ui_act.h
index bd2cf88..5e89f9f 100644
--- a/src/ui_act.h
+++ b/src/ui_act.h
@@ -61,5 +61,6 @@ BarUiActCallback(BarUiActVolDown);
BarUiActCallback(BarUiActVolUp);
BarUiActCallback(BarUiActManageStation);
BarUiActCallback(BarUiActVolReset);
+BarUiActCallback(BarUiActReloadStations);
#endif /* _UI_ACT_H */
diff --git a/src/ui_dispatch.h b/src/ui_dispatch.h
index ca8a292..2b92681 100644
--- a/src/ui_dispatch.h
+++ b/src/ui_dispatch.h
@@ -103,6 +103,8 @@ static const BarUiDispatchAction_t dispatchActions[BAR_KS_COUNT] = {
"act_songpause"},
{'^', BAR_DC_GLOBAL, BarUiActVolReset, "reset volume",
"act_volreset"},
+ {'.', BAR_DC_GLOBAL, BarUiActReloadStations, "reload station list",
+ "act_reloadstations"},
};
#include <piano.h>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment