Code

libmpdclient updated (r1507) - added path to mpdclient_cmd_db_update()
authorKalle Wallin <kaw@linux.se>
Wed, 16 Jun 2004 11:13:27 +0000 (11:13 +0000)
committerKalle Wallin <kaw@linux.se>
Wed, 16 Jun 2004 11:13:27 +0000 (11:13 +0000)
git-svn-id: https://svn.musicpd.org/ncmpc/trunk@1508 09075e82-0dd4-0310-85a5-a0d7c8717e4f

src/libmpdclient.c
src/libmpdclient.h
src/mpdclient.c
src/mpdclient.h
src/screen.c
src/screen_file.c
src/screen_play.c

index 089e7201faa70d62c305a2f3e95e0511d7fe437b..01386ac5ad4d21456ac89b04087d7a7b9658eb7f 100644 (file)
@@ -101,7 +101,7 @@ mpd_Connection * mpd_newConnection(const char * host, int port, float timeout) {
        int err;
        struct hostent * he;
        struct sockaddr * dest;
-#ifdef MPD_HAVE_SOCKLEN_T
+#ifdef HAVE_SOCKLEN_T
        socklen_t destlen;
 #else
        int destlen;
@@ -1265,8 +1265,13 @@ void mpd_sendSeekIdCommand(mpd_Connection * connection, int id, int time) {
        free(string);
 }
 
-void mpd_sendUpdateCommand(mpd_Connection * connection) {
-        mpd_executeCommand(connection,"update\n");
+void mpd_sendUpdateCommand(mpd_Connection * connection, char * path) {
+       char * sPath = mpd_sanitizeArg(path);
+       char * string = malloc(strlen("update")+strlen(sPath)+5);
+       sprintf(string,"update \"%s\"\n",sPath);
+       mpd_sendInfoCommand(connection,string);
+       free(string);
+       free(sPath);
 }
 
 int mpd_getUpdateId(mpd_Connection * connection) {
index 0cce020283332d9907bd148126dcda3bd7d52dbb..2208faf225f7149b9ac96b4f1d86a6d648305465 100644 (file)
@@ -435,7 +435,7 @@ void mpd_sendVolumeCommand(mpd_Connection * connection, int volumeChange);
 
 void mpd_sendCrossfadeCommand(mpd_Connection * connection, int seconds);
 
-void mpd_sendUpdateCommand(mpd_Connection * connection);
+void mpd_sendUpdateCommand(mpd_Connection * connection, char * path);
 
 /* returns the update job id, call this after a update command*/
 int mpd_getUpdateId(mpd_Connection * connection);
index c4a88ffe0b548e5385dac792559f908a950a64c0..c47dc3d19af9da34f5c3acf39a1edf5bb0a5dd05 100644 (file)
@@ -316,9 +316,9 @@ mpdclient_cmd_crossfade(mpdclient_t *c, gint value)
 }
 
 gint 
-mpdclient_cmd_db_update(mpdclient_t *c)
+mpdclient_cmd_db_update(mpdclient_t *c, gchar *path)
 {
-  mpd_sendUpdateCommand(c->connection);
+  mpd_sendUpdateCommand(c->connection, path ? path : "");
   return mpdclient_finish_command(c);
 }
 
index 50b8e9a92fe014d997a196042b1f66110715dd54..7debd80508810ecc9db7a164336630caf9c31b9a 100644 (file)
@@ -81,7 +81,7 @@ gint mpdclient_cmd_clear(mpdclient_t *c);
 gint mpdclient_cmd_repeat(mpdclient_t *c, gint value);
 gint mpdclient_cmd_random(mpdclient_t *c, gint value);
 gint mpdclient_cmd_crossfade(mpdclient_t *c, gint value);
-gint mpdclient_cmd_db_update(mpdclient_t *c);
+gint mpdclient_cmd_db_update(mpdclient_t *c, gchar *path);
 gint mpdclient_cmd_volume(mpdclient_t *c, gint value);
 
 gint mpdclient_cmd_add(mpdclient_t *c, mpd_Song *song);
index 8beab97f2117c199f63b33d3662e2a0000f6c42a..43383d93c4e8b1460a651e938feeb75823190068 100644 (file)
@@ -782,7 +782,7 @@ screen_cmd(mpdclient_t *c, command_t cmd)
     case CMD_DB_UPDATE:
       if( !c->status->updatingDb )
        {
-         if( mpdclient_cmd_db_update(c)==0 )
+         if( mpdclient_cmd_db_update(c,NULL)==0 )
            screen_status_printf(_("Database update started!"));
        }
       else
index f26333a2125ca979f7a8cc9ec8e8ff1be36edf7d..2caf2519723a6953185a60810a5d553af2d17d60 100644 (file)
@@ -563,6 +563,21 @@ browse_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
       list_window_check_selected(lw, filelist->length);
       screen_status_printf(_("Screen updated!"));
       return 1;
+    case CMD_DB_UPDATE:
+      if( !c->status->updatingDb )
+       {
+         if( mpdclient_cmd_db_update(c,filelist->path)==0 )
+           {
+             screen_status_printf(_("Database update of %s started!"),
+                                  filelist->path);
+             /* set updatingDb to make shure the browse callback gets called
+              * even if the updated has finished before status is updated */
+             c->status->updatingDb = 1; 
+           }
+       }
+      else
+       screen_status_printf(_("Database update running..."));
+      return 1;
     case CMD_LIST_FIND:
     case CMD_LIST_RFIND:
     case CMD_LIST_FIND_NEXT:
index 9d3cef8bef41cf778a0e192bb69aa15e5241b727..8c38c5b1a6a86b0bd2d0ef0b7c56acbcf6a577ea 100644 (file)
@@ -154,6 +154,7 @@ handle_save_playlist(screen_t *screen, mpdclient_t *c, char *name)
              g_free(filename);
              return error;
            }     
+         screen_status_printf(_("Aborted!"));
        }
       g_free(filename);
       return -1;