summaryrefslogtreecommitdiffstats
path: root/src/c_mpdview.c
diff options
context:
space:
mode:
authorJoe <bousset.rudy@gmail.com>2022-07-14 15:30:10 +0200
committerJoe <bousset.rudy@gmail.com>2022-07-14 15:30:10 +0200
commita1fb4aa469767ce11c8724aaa0cee1fa0cfc4437 (patch)
tree18b0ca9ea86565d8b9cc6772ec741e665d80bdbf /src/c_mpdview.c
parentWIP (diff)
downloadmpdview-master.tar.gz
mpdview-master.tar.bz2
mpdview-master.tar.xz
mpdview-master.tar.zst
mpdview-master.zip
RefactorHEADmaster
Diffstat (limited to 'src/c_mpdview.c')
-rw-r--r--src/c_mpdview.c94
1 files changed, 2 insertions, 92 deletions
diff --git a/src/c_mpdview.c b/src/c_mpdview.c
index 320f8e2..7e6de4e 100644
--- a/src/c_mpdview.c
+++ b/src/c_mpdview.c
@@ -59,109 +59,19 @@
#include <mpd/client.h>
#include "c_defines.h"
+#include "c_mpd.h"
#include "c_mpdview.h"
+#include "c_view.h"
static bool_t doexit = FALSE;
-static struct mpdview_s *
-c_create_view(bool_t verbose)
-{
- struct mpdview_s* view;
-
- view = (struct mpdview_s*)malloc(sizeof(struct mpdview_s));
- if (view == NULL) {
- return (NULL);
- }
- view->conn = NULL;
- view->status = NULL;
- view->song = NULL;
- view->state = MPD_STATE_UNKNOWN;
- view->verbose = verbose;
- return (view);
-}
-
static void
c_get_music_dir(struct mpdview_s* v)
{
strlcpy(v->music_dir, DEF_MUSIC_DIR, PATH_MAX);
}
-static u8_t
-c_connect_mpd(struct mpdview_s* v)
-{
- v->conn = mpd_connection_new(NULL, 0, 3000);
- if (mpd_connection_get_error(v->conn) != MPD_ERROR_SUCCESS) {
- dprintf(
- STDERR_FILENO,
- "%s: %s\n",
- PROGNAME,
- mpd_connection_get_error_message(v->conn)
- );
- return (RET_ERR);
- }
- return (RET_OK);
-}
-
-static void
-c_destroy_mpdview(struct mpdview_s** v)
-{
- (*v)->state = MPD_STATE_UNKNOWN;
- if ((*v)->song != NULL) {
- mpd_song_free((*v)->song);
- }
- (*v)->song = NULL;
- if ((*v)->status != NULL) {
- mpd_status_free((*v)->status);
- }
- (*v)->status = NULL;
- if ((*v)->conn != NULL) {
- mpd_connection_free((*v)->conn);
- }
- (*v)->conn = NULL;
- free(*v);
- *v = NULL;
-}
-
-static u8_t
-c_get_mpd_status(struct mpdview_s* v)
-{
- v->status = mpd_run_status(v->conn);
- if (v->status == NULL) {
- dprintf(
- STDERR_FILENO,
- "%s: %s\n",
- PROGNAME,
- mpd_status_get_error(v->status)
- );
- return (RET_ERR);
- }
- v->state = mpd_status_get_state(v->status);
- mpd_status_free(v->status);
- v->status = NULL;
- return (RET_OK);
-}
-
-static u8_t
-c_get_mpd_song(struct mpdview_s* v)
-{
- if (v->song != NULL) {
- mpd_song_free(v->song);
- v->song = NULL;
- }
- v->song = mpd_run_current_song(v->conn);
- if (v->song == NULL) {
- dprintf(
- STDERR_FILENO,
- "%s: %s\n",
- PROGNAME,
- "Could not get song"
- );
- return (RET_ERR);
- }
- return (RET_OK);
-}
-
static void
c_get_current_dir(struct mpdview_s* v)
{