make ncmpcpp use external libmpdclient (--without-taglib and --without-iconv)
This commit is contained in:
18
configure.in
18
configure.in
@@ -55,6 +55,24 @@ dnl ================================
|
||||
AC_CHECK_HEADERS([dirent.h regex.h], , AC_MSG_ERROR(vital headers missing))
|
||||
AC_CHECK_HEADERS([langinfo.h], , AC_MSG_WARN(locale detection disabled))
|
||||
|
||||
dnl ==============================
|
||||
dnl = checking for libmpdclient2 =
|
||||
dnl ==============================
|
||||
PKG_CHECK_MODULES([libmpdclient], [libmpdclient >= 2.0], [
|
||||
AC_SUBST(libmpdclient_LIBS)
|
||||
AC_SUBST(libmpdclient_CFLAGS)
|
||||
CPPFLAGS="$CPPFLAGS $libmpdclient_CFLAGS"
|
||||
AC_CHECK_HEADERS([mpd/client.h],
|
||||
LDFLAGS="$LDFLAGS $libmpdclient_LIBS"
|
||||
,
|
||||
AC_MSG_ERROR([missing mpd/client.h header])
|
||||
)
|
||||
],
|
||||
if test "$fftw" = "yes" ; then
|
||||
AC_MSG_ERROR([libmpdclient2 is required!])
|
||||
fi
|
||||
)
|
||||
|
||||
dnl ======================
|
||||
dnl = checking for iconv =
|
||||
dnl ======================
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
bin_PROGRAMS = ncmpcpp
|
||||
ncmpcpp_SOURCES = browser.cpp charset.cpp clock.cpp conv.cpp display.cpp \
|
||||
error.cpp help.cpp helpers.cpp info.cpp libmpdclient.c lyrics.cpp \
|
||||
media_library.cpp menu.cpp misc.cpp mpdpp.cpp ncmpcpp.cpp outputs.cpp playlist.cpp \
|
||||
playlist_editor.cpp scrollpad.cpp search_engine.cpp settings.cpp song.cpp status.cpp \
|
||||
str_pool.c tag_editor.cpp tiny_tag_editor.cpp visualizer.cpp window.cpp
|
||||
error.cpp help.cpp helpers.cpp info.cpp lyrics.cpp media_library.cpp menu.cpp \
|
||||
misc.cpp mpdpp.cpp ncmpcpp.cpp outputs.cpp playlist.cpp playlist_editor.cpp \
|
||||
scrollpad.cpp search_engine.cpp settings.cpp song.cpp status.cpp str_pool.c \
|
||||
tag_editor.cpp tiny_tag_editor.cpp visualizer.cpp window.cpp
|
||||
|
||||
# set the include path found by configure
|
||||
INCLUDES= $(all_includes)
|
||||
|
||||
@@ -329,8 +329,8 @@ void Browser::GetLocalDirectory(ItemList &v, const std::string &directory, bool
|
||||
else if (hasSupportedExtension(file->d_name))
|
||||
{
|
||||
new_item.type = itSong;
|
||||
mpd_Song *s = mpd_newSong();
|
||||
s->file = str_pool_get(full_path.c_str());
|
||||
mpd_pair file_pair = { "file", strdup(full_path.c_str()) };
|
||||
mpd_song *s = mpd_song_begin(&file_pair);
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
if (!recursively)
|
||||
TagEditor::ReadTags(s);
|
||||
|
||||
62
src/conv.cpp
62
src/conv.cpp
@@ -45,31 +45,31 @@ std::string IntoStr(int l)
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string IntoStr(mpd_TagItems tag) // this is only for left column's title in media library
|
||||
std::string IntoStr(mpd_tag_type tag) // this is only for left column's title in media library
|
||||
{
|
||||
switch (tag)
|
||||
{
|
||||
case MPD_TAG_ITEM_ARTIST:
|
||||
case MPD_TAG_ARTIST:
|
||||
return "Artist";
|
||||
case MPD_TAG_ITEM_ALBUM:
|
||||
case MPD_TAG_ALBUM:
|
||||
return "Album";
|
||||
case MPD_TAG_ITEM_TITLE:
|
||||
case MPD_TAG_TITLE:
|
||||
return "Title";
|
||||
case MPD_TAG_ITEM_TRACK:
|
||||
case MPD_TAG_TRACK:
|
||||
return "Track";
|
||||
case MPD_TAG_ITEM_GENRE:
|
||||
case MPD_TAG_GENRE:
|
||||
return "Genre";
|
||||
case MPD_TAG_ITEM_DATE:
|
||||
case MPD_TAG_DATE:
|
||||
return "Year";
|
||||
case MPD_TAG_ITEM_COMPOSER:
|
||||
case MPD_TAG_COMPOSER:
|
||||
return "Composer";
|
||||
case MPD_TAG_ITEM_PERFORMER:
|
||||
case MPD_TAG_PERFORMER:
|
||||
return "Performer";
|
||||
case MPD_TAG_ITEM_COMMENT:
|
||||
case MPD_TAG_COMMENT:
|
||||
return "Comment";
|
||||
case MPD_TAG_ITEM_DISC:
|
||||
case MPD_TAG_DISC:
|
||||
return "Disc";
|
||||
case MPD_TAG_ITEM_FILENAME:
|
||||
case MPD_TAG_FILE:
|
||||
return "Filename";
|
||||
default:
|
||||
return "";
|
||||
@@ -126,51 +126,51 @@ NCurses::Color IntoColor(const std::string &color)
|
||||
return result;
|
||||
}
|
||||
|
||||
mpd_TagItems IntoTagItem(char c)
|
||||
mpd_tag_type IntoTagItem(char c)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case 'a':
|
||||
return MPD_TAG_ITEM_ARTIST;
|
||||
return MPD_TAG_ARTIST;
|
||||
case 'y':
|
||||
return MPD_TAG_ITEM_DATE;
|
||||
return MPD_TAG_DATE;
|
||||
case 'g':
|
||||
return MPD_TAG_ITEM_GENRE;
|
||||
return MPD_TAG_GENRE;
|
||||
case 'c':
|
||||
return MPD_TAG_ITEM_COMPOSER;
|
||||
return MPD_TAG_COMPOSER;
|
||||
case 'p':
|
||||
return MPD_TAG_ITEM_PERFORMER;
|
||||
return MPD_TAG_PERFORMER;
|
||||
default:
|
||||
return MPD_TAG_ITEM_ARTIST;
|
||||
return MPD_TAG_ARTIST;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_TAGLIB_H
|
||||
MPD::Song::SetFunction IntoSetFunction(mpd_TagItems tag)
|
||||
MPD::Song::SetFunction IntoSetFunction(mpd_tag_type tag)
|
||||
{
|
||||
switch (tag)
|
||||
{
|
||||
case MPD_TAG_ITEM_ARTIST:
|
||||
case MPD_TAG_ARTIST:
|
||||
return &MPD::Song::SetArtist;
|
||||
case MPD_TAG_ITEM_ALBUM:
|
||||
case MPD_TAG_ALBUM:
|
||||
return &MPD::Song::SetAlbum;
|
||||
case MPD_TAG_ITEM_TITLE:
|
||||
case MPD_TAG_TITLE:
|
||||
return &MPD::Song::SetTitle;
|
||||
case MPD_TAG_ITEM_TRACK:
|
||||
case MPD_TAG_TRACK:
|
||||
return &MPD::Song::SetTrack;
|
||||
case MPD_TAG_ITEM_GENRE:
|
||||
case MPD_TAG_GENRE:
|
||||
return &MPD::Song::SetGenre;
|
||||
case MPD_TAG_ITEM_DATE:
|
||||
case MPD_TAG_DATE:
|
||||
return &MPD::Song::SetDate;
|
||||
case MPD_TAG_ITEM_COMPOSER:
|
||||
case MPD_TAG_COMPOSER:
|
||||
return &MPD::Song::SetComposer;
|
||||
case MPD_TAG_ITEM_PERFORMER:
|
||||
case MPD_TAG_PERFORMER:
|
||||
return &MPD::Song::SetPerformer;
|
||||
case MPD_TAG_ITEM_COMMENT:
|
||||
case MPD_TAG_COMMENT:
|
||||
return &MPD::Song::SetComment;
|
||||
case MPD_TAG_ITEM_DISC:
|
||||
case MPD_TAG_DISC:
|
||||
return &MPD::Song::SetDisc;
|
||||
case MPD_TAG_ITEM_FILENAME:
|
||||
case MPD_TAG_FILE:
|
||||
return &MPD::Song::SetNewName;
|
||||
default:
|
||||
return 0;
|
||||
|
||||
@@ -38,16 +38,16 @@ long StrToLong(const std::string &);
|
||||
|
||||
std::string IntoStr(int);
|
||||
|
||||
std::string IntoStr(mpd_TagItems);
|
||||
std::string IntoStr(mpd_tag_type);
|
||||
|
||||
std::string IntoStr(NCurses::Color);
|
||||
|
||||
NCurses::Color IntoColor(const std::string &);
|
||||
|
||||
mpd_TagItems IntoTagItem(char);
|
||||
mpd_tag_type IntoTagItem(char);
|
||||
|
||||
#ifdef HAVE_TAGLIB_H
|
||||
MPD::Song::SetFunction IntoSetFunction(mpd_TagItems);
|
||||
MPD::Song::SetFunction IntoSetFunction(mpd_tag_type);
|
||||
#endif // HAVE_TAGLIB_H
|
||||
|
||||
void EscapeUnallowedChars(std::string &);
|
||||
|
||||
2102
src/libmpdclient.c
2102
src/libmpdclient.c
File diff suppressed because it is too large
Load Diff
@@ -1,689 +0,0 @@
|
||||
/* libmpdclient
|
||||
(c)2003-2006 by Warren Dukes (warren.dukes@gmail.com)
|
||||
This project's homepage is: http://www.musicpd.org
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Music Player Daemon nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef LIBMPDCLIENT_H
|
||||
#define LIBMPDCLIENT_H
|
||||
|
||||
#ifdef WIN32
|
||||
# define __W32API_USE_DLLIMPORT__ 1
|
||||
#endif
|
||||
|
||||
#include "str_pool.h"
|
||||
#include <sys/time.h>
|
||||
#include <stdarg.h>
|
||||
#define MPD_BUFFER_MAX_LENGTH 50000
|
||||
#define MPD_ERRORSTR_MAX_LENGTH 1000
|
||||
#define MPD_WELCOME_MESSAGE "OK MPD "
|
||||
|
||||
#define MPD_ERROR_TIMEOUT 10 /* timeout trying to talk to mpd */
|
||||
#define MPD_ERROR_SYSTEM 11 /* system error */
|
||||
#define MPD_ERROR_UNKHOST 12 /* unknown host */
|
||||
#define MPD_ERROR_CONNPORT 13 /* problems connecting to port on host */
|
||||
#define MPD_ERROR_NOTMPD 14 /* mpd not running on port at host */
|
||||
#define MPD_ERROR_NORESPONSE 15 /* no response on attempting to connect */
|
||||
#define MPD_ERROR_SENDING 16 /* error sending command */
|
||||
#define MPD_ERROR_CONNCLOSED 17 /* connection closed by mpd */
|
||||
#define MPD_ERROR_ACK 18 /* ACK returned! */
|
||||
#define MPD_ERROR_BUFFEROVERRUN 19 /* Buffer was overrun! */
|
||||
|
||||
#define MPD_ACK_ERROR_UNK -1
|
||||
#define MPD_ERROR_AT_UNK -1
|
||||
|
||||
#define MPD_ACK_ERROR_NOT_LIST 1
|
||||
#define MPD_ACK_ERROR_ARG 2
|
||||
#define MPD_ACK_ERROR_PASSWORD 3
|
||||
#define MPD_ACK_ERROR_PERMISSION 4
|
||||
#define MPD_ACK_ERROR_UNKNOWN_CMD 5
|
||||
|
||||
#define MPD_ACK_ERROR_NO_EXIST 50
|
||||
#define MPD_ACK_ERROR_PLAYLIST_MAX 51
|
||||
#define MPD_ACK_ERROR_SYSTEM 52
|
||||
#define MPD_ACK_ERROR_PLAYLIST_LOAD 53
|
||||
#define MPD_ACK_ERROR_UPDATE_ALREADY 54
|
||||
#define MPD_ACK_ERROR_PLAYER_SYNC 55
|
||||
#define MPD_ACK_ERROR_EXIST 56
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum mpd_TagItems
|
||||
{
|
||||
MPD_TAG_ITEM_ARTIST,
|
||||
MPD_TAG_ITEM_ALBUM,
|
||||
MPD_TAG_ITEM_TITLE,
|
||||
MPD_TAG_ITEM_TRACK,
|
||||
MPD_TAG_ITEM_NAME,
|
||||
MPD_TAG_ITEM_GENRE,
|
||||
MPD_TAG_ITEM_DATE,
|
||||
MPD_TAG_ITEM_COMPOSER,
|
||||
MPD_TAG_ITEM_PERFORMER,
|
||||
MPD_TAG_ITEM_COMMENT,
|
||||
MPD_TAG_ITEM_DISC,
|
||||
MPD_TAG_ITEM_FILENAME,
|
||||
MPD_TAG_ITEM_ANY,
|
||||
MPD_TAG_NUM_OF_ITEM_TYPES
|
||||
} mpd_TagItems;
|
||||
|
||||
extern char * mpdTagItemKeys[MPD_TAG_NUM_OF_ITEM_TYPES];
|
||||
|
||||
/* internal stuff don't touch this struct */
|
||||
typedef struct _mpd_ReturnElement {
|
||||
const char * name;
|
||||
const char * value;
|
||||
} mpd_ReturnElement;
|
||||
|
||||
/* mpd_Connection
|
||||
* holds info about connection to mpd
|
||||
* use error, and errorStr to detect errors
|
||||
*/
|
||||
typedef struct _mpd_Connection {
|
||||
/* use this to check the version of mpd */
|
||||
int version[3];
|
||||
/* IMPORTANT, you want to get the error messages from here */
|
||||
char errorStr[MPD_ERRORSTR_MAX_LENGTH+1];
|
||||
int errorCode;
|
||||
int errorAt;
|
||||
/* this will be set to MPD_ERROR_* if there is an error, 0 if not */
|
||||
int error;
|
||||
/* DON'T TOUCH any of the rest of this stuff */
|
||||
int sock;
|
||||
char buffer[MPD_BUFFER_MAX_LENGTH+1];
|
||||
int buflen;
|
||||
int bufstart;
|
||||
int doneProcessing;
|
||||
int listOks;
|
||||
int doneListOk;
|
||||
int commandList;
|
||||
mpd_ReturnElement * returnElement;
|
||||
struct timeval timeout;
|
||||
char *request;
|
||||
} mpd_Connection;
|
||||
|
||||
/* mpd_newConnection
|
||||
* use this to open a new connection
|
||||
* you should use mpd_closeConnection, when your done with the connection,
|
||||
* even if an error has occurred
|
||||
* _timeout_ is the connection timeout period in seconds
|
||||
*/
|
||||
mpd_Connection * mpd_newConnection(const char * host, int port, float timeout);
|
||||
|
||||
void mpd_setConnectionTimeout(mpd_Connection * connection, float timeout);
|
||||
|
||||
/* mpd_closeConnection
|
||||
* use this to close a connection and free'ing subsequent memory
|
||||
*/
|
||||
void mpd_closeConnection(mpd_Connection * connection);
|
||||
|
||||
/* mpd_clearError
|
||||
* clears error
|
||||
*/
|
||||
void mpd_clearError(mpd_Connection * connection);
|
||||
|
||||
/* added by unK, make this extern as I want to use it */
|
||||
void mpd_executeCommand(mpd_Connection * connection, const char * command);
|
||||
|
||||
/* STATUS STUFF */
|
||||
|
||||
/* use these with status.state to determine what state the player is in */
|
||||
#define MPD_STATUS_STATE_UNKNOWN 0
|
||||
#define MPD_STATUS_STATE_STOP 1
|
||||
#define MPD_STATUS_STATE_PLAY 2
|
||||
#define MPD_STATUS_STATE_PAUSE 3
|
||||
|
||||
/* us this with status.volume to determine if mpd has volume support */
|
||||
#define MPD_STATUS_NO_VOLUME -1
|
||||
|
||||
/* mpd_Status
|
||||
* holds info return from status command
|
||||
*/
|
||||
typedef struct mpd_Status {
|
||||
/* 0-100, or MPD_STATUS_NO_VOLUME when there is no volume support */
|
||||
int volume;
|
||||
/* 1 if repeat is on, 0 otherwise */
|
||||
int repeat;
|
||||
/* 1 if random is on, 0 otherwise */
|
||||
int random;
|
||||
/* 1 if single mode is on, 0 otherwise */
|
||||
int single;
|
||||
/* 1 if consume mode is on, 0 otherwise */
|
||||
int consume;
|
||||
/* playlist length */
|
||||
int playlistLength;
|
||||
/* playlist, use this to determine when the playlist has changed */
|
||||
long long playlist;
|
||||
/* use with MPD_STATUS_STATE_* to determine state of player */
|
||||
int state;
|
||||
/* crossfade setting in seconds */
|
||||
int crossfade;
|
||||
/* if a song is currently selected (always the case when state is
|
||||
* PLAY or PAUSE), this is the position of the currently
|
||||
* playing song in the playlist, beginning with 0
|
||||
*/
|
||||
int song;
|
||||
/* Song ID of the currently selected song */
|
||||
int songid;
|
||||
/* time in seconds that have elapsed in the currently playing/paused
|
||||
* song
|
||||
*/
|
||||
int elapsedTime;
|
||||
/* length in seconds of the currently playing/paused song */
|
||||
int totalTime;
|
||||
/* current bit rate in kbs */
|
||||
int bitRate;
|
||||
/* audio sample rate */
|
||||
unsigned int sampleRate;
|
||||
/* audio bits */
|
||||
int bits;
|
||||
/* audio channels */
|
||||
int channels;
|
||||
/* 1 if mpd is updating, 0 otherwise */
|
||||
int updatingDb;
|
||||
/* error */
|
||||
char * error;
|
||||
} mpd_Status;
|
||||
|
||||
void mpd_sendStatusCommand(mpd_Connection * connection);
|
||||
|
||||
/* mpd_getStatus
|
||||
* returns status info, be sure to free it with mpd_freeStatus()
|
||||
* call this after mpd_sendStatusCommand()
|
||||
*/
|
||||
mpd_Status * mpd_getStatus(mpd_Connection * connection);
|
||||
|
||||
/* mpd_freeStatus
|
||||
* free's status info malloc'd and returned by mpd_getStatus
|
||||
*/
|
||||
void mpd_freeStatus(mpd_Status * status);
|
||||
|
||||
typedef struct _mpd_Stats {
|
||||
int numberOfArtists;
|
||||
int numberOfAlbums;
|
||||
int numberOfSongs;
|
||||
unsigned long uptime;
|
||||
unsigned long dbUpdateTime;
|
||||
unsigned long playTime;
|
||||
unsigned long dbPlayTime;
|
||||
} mpd_Stats;
|
||||
|
||||
typedef struct _mpd_SearchStats {
|
||||
int numberOfSongs;
|
||||
unsigned long playTime;
|
||||
} mpd_SearchStats;
|
||||
|
||||
void mpd_sendStatsCommand(mpd_Connection * connection);
|
||||
|
||||
mpd_Stats * mpd_getStats(mpd_Connection * connection);
|
||||
|
||||
void mpd_freeStats(mpd_Stats * stats);
|
||||
|
||||
mpd_SearchStats * mpd_getSearchStats(mpd_Connection * connection);
|
||||
|
||||
void mpd_freeSearchStats(mpd_SearchStats * stats);
|
||||
|
||||
/* SONG STUFF */
|
||||
|
||||
#define MPD_SONG_NO_TIME -1
|
||||
#define MPD_SONG_NO_NUM -1
|
||||
#define MPD_SONG_NO_ID -1
|
||||
|
||||
/* mpd_Song
|
||||
* for storing song info returned by mpd
|
||||
*/
|
||||
typedef struct _mpd_Song {
|
||||
/* filename of song */
|
||||
const char * file;
|
||||
/* artist, maybe NULL if there is no tag */
|
||||
const char * artist;
|
||||
/* title, maybe NULL if there is no tag */
|
||||
const char * title;
|
||||
/* album, maybe NULL if there is no tag */
|
||||
const char * album;
|
||||
/* track, maybe NULL if there is no tag */
|
||||
const char * track;
|
||||
/* name, maybe NULL if there is no tag; it's the name of the current
|
||||
* song, f.e. the icyName of the stream */
|
||||
const char * name;
|
||||
/* date */
|
||||
const char *date;
|
||||
|
||||
/* added by qball */
|
||||
/* Genre */
|
||||
const char *genre;
|
||||
/* Composer */
|
||||
const char *composer;
|
||||
/* Performer */
|
||||
const char *performer;
|
||||
/* Disc */
|
||||
const char *disc;
|
||||
/* Comment */
|
||||
const char *comment;
|
||||
|
||||
/* length of song in seconds, check that it is not MPD_SONG_NO_TIME */
|
||||
int time;
|
||||
/* if plchanges/playlistinfo/playlistid used, is the position of the
|
||||
* song in the playlist */
|
||||
int pos;
|
||||
/* song id for a song in the playlist */
|
||||
int id;
|
||||
} mpd_Song;
|
||||
|
||||
/* mpd_newSong
|
||||
* use to allocate memory for a new mpd_Song
|
||||
* file, artist, etc all initialized to NULL
|
||||
* if your going to assign values to file, artist, etc
|
||||
* be sure to malloc or strdup the memory
|
||||
* use mpd_freeSong to free the memory for the mpd_Song, it will also
|
||||
* free memory for file, artist, etc, so don't do it yourself
|
||||
*/
|
||||
mpd_Song * mpd_newSong(void);
|
||||
|
||||
/* mpd_freeSong
|
||||
* use to free memory allocated by mpd_newSong
|
||||
* also it will free memory pointed to by file, artist, etc, so be careful
|
||||
*/
|
||||
void mpd_freeSong(mpd_Song * song);
|
||||
|
||||
/* mpd_songDup
|
||||
* works like strDup, but for a mpd_Song
|
||||
*/
|
||||
mpd_Song * mpd_songDup(mpd_Song * song);
|
||||
|
||||
/* DIRECTORY STUFF */
|
||||
|
||||
/* mpd_Directory
|
||||
* used to store info fro directory (right now that just the path)
|
||||
*/
|
||||
typedef struct _mpd_Directory {
|
||||
const char * path;
|
||||
} mpd_Directory;
|
||||
|
||||
/* mpd_newDirectory
|
||||
* allocates memory for a new directory
|
||||
* use mpd_freeDirectory to free this memory
|
||||
*/
|
||||
mpd_Directory * mpd_newDirectory(void);
|
||||
|
||||
/* mpd_freeDirectory
|
||||
* used to free memory allocated with mpd_newDirectory, and it frees
|
||||
* path of mpd_Directory, so be careful
|
||||
*/
|
||||
void mpd_freeDirectory(mpd_Directory * directory);
|
||||
|
||||
/* mpd_directoryDup
|
||||
* works like strdup, but for mpd_Directory
|
||||
*/
|
||||
mpd_Directory * mpd_directoryDup(mpd_Directory * directory);
|
||||
|
||||
/* PLAYLISTFILE STUFF */
|
||||
|
||||
/* mpd_PlaylistFile
|
||||
* stores info about playlist file returned by lsinfo
|
||||
*/
|
||||
typedef struct _mpd_PlaylistFile {
|
||||
const char * path;
|
||||
} mpd_PlaylistFile;
|
||||
|
||||
/* mpd_newPlaylistFile
|
||||
* allocates memory for new mpd_PlaylistFile, path is set to NULL
|
||||
* free this memory with mpd_freePlaylistFile
|
||||
*/
|
||||
mpd_PlaylistFile * mpd_newPlaylistFile(void);
|
||||
|
||||
/* mpd_freePlaylist
|
||||
* free memory allocated for freePlaylistFile, will also free
|
||||
* path, so be careful
|
||||
*/
|
||||
void mpd_freePlaylistFile(mpd_PlaylistFile * playlist);
|
||||
|
||||
/* mpd_playlistFileDup
|
||||
* works like strdup, but for mpd_PlaylistFile
|
||||
*/
|
||||
mpd_PlaylistFile * mpd_playlistFileDup(mpd_PlaylistFile * playlist);
|
||||
|
||||
/* INFO ENTITY STUFF */
|
||||
|
||||
/* the type of entity returned from one of the commands that generates info
|
||||
* use in conjunction with mpd_InfoEntity.type
|
||||
*/
|
||||
#define MPD_INFO_ENTITY_TYPE_DIRECTORY 0
|
||||
#define MPD_INFO_ENTITY_TYPE_SONG 1
|
||||
#define MPD_INFO_ENTITY_TYPE_PLAYLISTFILE 2
|
||||
|
||||
/* mpd_InfoEntity
|
||||
* stores info on stuff returned info commands
|
||||
*/
|
||||
typedef struct mpd_InfoEntity {
|
||||
/* the type of entity, use with MPD_INFO_ENTITY_TYPE_* to determine
|
||||
* what this entity is (song, directory, etc...)
|
||||
*/
|
||||
int type;
|
||||
/* the actual data you want, mpd_Song, mpd_Directory, etc */
|
||||
union {
|
||||
mpd_Directory * directory;
|
||||
mpd_Song * song;
|
||||
mpd_PlaylistFile * playlistFile;
|
||||
} info;
|
||||
} mpd_InfoEntity;
|
||||
|
||||
mpd_InfoEntity * mpd_newInfoEntity(void);
|
||||
|
||||
void mpd_freeInfoEntity(mpd_InfoEntity * entity);
|
||||
|
||||
/* INFO COMMANDS AND STUFF */
|
||||
|
||||
/* use this function to loop over after calling Info/Listall functions */
|
||||
mpd_InfoEntity * mpd_getNextInfoEntity(mpd_Connection * connection);
|
||||
|
||||
/* fetches the currently seeletect song (the song referenced by status->song
|
||||
* and status->songid*/
|
||||
void mpd_sendCurrentSongCommand(mpd_Connection * connection);
|
||||
|
||||
/* songNum of -1, means to display the whole list */
|
||||
void mpd_sendPlaylistInfoCommand(mpd_Connection * connection, int songNum);
|
||||
|
||||
/* songId of -1, means to display the whole list */
|
||||
void mpd_sendPlaylistIdCommand(mpd_Connection * connection, int songId);
|
||||
|
||||
/* use this to get the changes in the playlist since version _playlist_ */
|
||||
void mpd_sendPlChangesCommand(mpd_Connection * connection, long long playlist);
|
||||
|
||||
/**
|
||||
* @param connection: A valid and connected mpd_Connection.
|
||||
* @param playlist: The playlist version you want the diff with.
|
||||
* A more bandwidth efficient version of the mpd_sendPlChangesCommand.
|
||||
* It only returns the pos+id of the changes song.
|
||||
*/
|
||||
void mpd_sendPlChangesPosIdCommand(mpd_Connection * connection, long long playlist);
|
||||
|
||||
/* recursivel fetches all songs/dir/playlists in "dir* (no metadata is
|
||||
* returned) */
|
||||
void mpd_sendListallCommand(mpd_Connection * connection, const char * dir);
|
||||
|
||||
/* same as sendListallCommand, but also metadata is returned */
|
||||
void mpd_sendListallInfoCommand(mpd_Connection * connection, const char * dir);
|
||||
|
||||
/* non-recursive version of ListallInfo */
|
||||
void mpd_sendLsInfoCommand(mpd_Connection * connection, const char * dir);
|
||||
|
||||
#define MPD_TABLE_ARTIST MPD_TAG_ITEM_ARTIST
|
||||
#define MPD_TABLE_ALBUM MPD_TAG_ITEM_ALBUM
|
||||
#define MPD_TABLE_TITLE MPD_TAG_ITEM_TITLE
|
||||
#define MPD_TABLE_TRACK MPD_TAG_ITEM_TRACK
|
||||
#define MPD_TABLE_GENRE MPD_TAG_ITEM_GENRE
|
||||
#define MPD_TABLE_DATE MPD_TAG_ITEM_DATE
|
||||
#define MPD_TABLE_COMPOSER MPD_TAG_ITEM_COMPOSER
|
||||
#define MPD_TABLE_PERFORMER MPD_TAG_ITEM_PERFORMER
|
||||
#define MPD_TABLE_COMMENT MPD_TAG_ITEM_COMMENT
|
||||
#define MPD_TABLE_DISC MPD_TAG_ITEM_DISC
|
||||
#define MPD_TABLE_FILENAME MPD_TAG_ITEM_FILENAME
|
||||
|
||||
void mpd_sendSearchCommand(mpd_Connection * connection, int table,
|
||||
const char * str);
|
||||
|
||||
void mpd_sendFindCommand(mpd_Connection * connection, int table,
|
||||
const char * str);
|
||||
|
||||
/* LIST TAG COMMANDS */
|
||||
|
||||
/* use this function fetch next artist entry, be sure to free the returned
|
||||
* string. NULL means there are no more. Best used with sendListArtists
|
||||
*/
|
||||
char * mpd_getNextArtist(mpd_Connection * connection);
|
||||
|
||||
char * mpd_getNextAlbum(mpd_Connection * connection);
|
||||
|
||||
char * mpd_getNextTag(mpd_Connection *connection, int type);
|
||||
|
||||
/* list artist or albums by artist, arg1 should be set to the artist if
|
||||
* listing albums by a artist, otherwise NULL for listing all artists or albums
|
||||
*/
|
||||
void mpd_sendListCommand(mpd_Connection * connection, int table,
|
||||
const char * arg1);
|
||||
|
||||
/* SIMPLE COMMANDS */
|
||||
|
||||
void mpd_sendAddCommand(mpd_Connection * connection, const char * file);
|
||||
|
||||
int mpd_sendAddIdCommand(mpd_Connection *connection, const char *file);
|
||||
|
||||
void mpd_sendDeleteCommand(mpd_Connection * connection, int songNum);
|
||||
|
||||
void mpd_sendDeleteIdCommand(mpd_Connection * connection, int songNum);
|
||||
|
||||
void mpd_sendSaveCommand(mpd_Connection * connection, const char * name);
|
||||
|
||||
void mpd_sendLoadCommand(mpd_Connection * connection, const char * name);
|
||||
|
||||
void mpd_sendRmCommand(mpd_Connection * connection, const char * name);
|
||||
|
||||
void mpd_sendRenameCommand(mpd_Connection *connection, const char *from,
|
||||
const char *to);
|
||||
|
||||
void mpd_sendShuffleCommand(mpd_Connection * connection);
|
||||
|
||||
void mpd_sendClearCommand(mpd_Connection * connection);
|
||||
|
||||
/* use this to start playing at the beginning, useful when in random mode */
|
||||
#define MPD_PLAY_AT_BEGINNING -1
|
||||
|
||||
void mpd_sendPlayCommand(mpd_Connection * connection, int songNum);
|
||||
|
||||
void mpd_sendPlayIdCommand(mpd_Connection * connection, int songNum);
|
||||
|
||||
void mpd_sendStopCommand(mpd_Connection * connection);
|
||||
|
||||
void mpd_sendPauseCommand(mpd_Connection * connection, int pauseMode);
|
||||
|
||||
void mpd_sendNextCommand(mpd_Connection * connection);
|
||||
|
||||
void mpd_sendPrevCommand(mpd_Connection * connection);
|
||||
|
||||
void mpd_sendMoveCommand(mpd_Connection * connection, int from, int to);
|
||||
|
||||
void mpd_sendMoveIdCommand(mpd_Connection * connection, int from, int to);
|
||||
|
||||
void mpd_sendSwapCommand(mpd_Connection * connection, int song1, int song2);
|
||||
|
||||
void mpd_sendSwapIdCommand(mpd_Connection * connection, int song1, int song2);
|
||||
|
||||
void mpd_sendSeekCommand(mpd_Connection * connection, int song, int time);
|
||||
|
||||
void mpd_sendSeekIdCommand(mpd_Connection * connection, int song, int time);
|
||||
|
||||
void mpd_sendRepeatCommand(mpd_Connection * connection, int repeatMode);
|
||||
|
||||
void mpd_sendRandomCommand(mpd_Connection * connection, int randomMode);
|
||||
|
||||
void mpd_sendSingleCommand(mpd_Connection * connection, int singleMode);
|
||||
|
||||
void mpd_sendConsumeCommand(mpd_Connection * connection, int consumeMode);
|
||||
|
||||
void mpd_sendSetvolCommand(mpd_Connection * connection, int volumeChange);
|
||||
|
||||
/* WARNING: don't use volume command, its depreacted */
|
||||
void mpd_sendVolumeCommand(mpd_Connection * connection, int volumeChange);
|
||||
|
||||
void mpd_sendCrossfadeCommand(mpd_Connection * connection, int seconds);
|
||||
|
||||
void mpd_sendUpdateCommand(mpd_Connection * connection, const char * path);
|
||||
|
||||
/* returns the update job id, call this after a update command*/
|
||||
int mpd_getUpdateId(mpd_Connection * connection);
|
||||
|
||||
void mpd_sendPasswordCommand(mpd_Connection * connection, const char * pass);
|
||||
|
||||
/* after executing a command, when your done with it to get its status
|
||||
* (you want to check connection->error for an error)
|
||||
*/
|
||||
void mpd_finishCommand(mpd_Connection * connection);
|
||||
|
||||
/* command list stuff, use this to do things like add files very quickly */
|
||||
void mpd_sendCommandListBegin(mpd_Connection * connection);
|
||||
|
||||
void mpd_sendCommandListOkBegin(mpd_Connection * connection);
|
||||
|
||||
void mpd_sendCommandListEnd(mpd_Connection * connection);
|
||||
|
||||
/* advance to the next listOk
|
||||
* returns 0 if advanced to the next list_OK,
|
||||
* returns -1 if it advanced to an OK or ACK */
|
||||
int mpd_nextListOkCommand(mpd_Connection * connection);
|
||||
|
||||
typedef struct _mpd_OutputEntity {
|
||||
int id;
|
||||
char * name;
|
||||
int enabled;
|
||||
} mpd_OutputEntity;
|
||||
|
||||
void mpd_sendOutputsCommand(mpd_Connection * connection);
|
||||
|
||||
mpd_OutputEntity * mpd_getNextOutput(mpd_Connection * connection);
|
||||
|
||||
void mpd_sendEnableOutputCommand(mpd_Connection * connection, int outputId);
|
||||
|
||||
void mpd_sendDisableOutputCommand(mpd_Connection * connection, int outputId);
|
||||
|
||||
void mpd_freeOutputElement(mpd_OutputEntity * output);
|
||||
|
||||
/**
|
||||
* @param connection a #mpd_Connection
|
||||
*
|
||||
* Queries mpd for the allowed commands
|
||||
*/
|
||||
void mpd_sendCommandsCommand(mpd_Connection * connection);
|
||||
|
||||
/**
|
||||
* @param connection a #mpd_Connection
|
||||
*
|
||||
* Queries mpd for the not allowed commands
|
||||
*/
|
||||
void mpd_sendNotCommandsCommand(mpd_Connection * connection);
|
||||
|
||||
/**
|
||||
* @param connection a #mpd_Connection
|
||||
*
|
||||
* returns the next supported command.
|
||||
*
|
||||
* @returns a string, needs to be free'ed
|
||||
*/
|
||||
char *mpd_getNextCommand(mpd_Connection *connection);
|
||||
|
||||
void mpd_sendUrlHandlersCommand(mpd_Connection * connection);
|
||||
|
||||
char *mpd_getNextHandler(mpd_Connection * connection);
|
||||
|
||||
void mpd_sendTagTypesCommand(mpd_Connection * connection);
|
||||
|
||||
char *mpd_getNextTagType(mpd_Connection * connection);
|
||||
|
||||
/**
|
||||
* @param connection a MpdConnection
|
||||
* @param path the path to the playlist.
|
||||
*
|
||||
* List the content, with full metadata, of a stored playlist.
|
||||
*
|
||||
*/
|
||||
void mpd_sendListPlaylistInfoCommand(mpd_Connection *connection, const char *path);
|
||||
|
||||
/**
|
||||
* @param connection a MpdConnection
|
||||
* @param path the path to the playlist.
|
||||
*
|
||||
* List the content of a stored playlist.
|
||||
*
|
||||
*/
|
||||
void mpd_sendListPlaylistCommand(mpd_Connection *connection, char *path);
|
||||
|
||||
/**
|
||||
* @param connection a #mpd_Connection
|
||||
* @param exact if to match exact
|
||||
*
|
||||
* starts a search, use mpd_addConstraintSearch to add
|
||||
* a constraint to the search, and mpd_commitSearch to do the actual search
|
||||
*/
|
||||
void mpd_startSearch(mpd_Connection *connection, int exact);
|
||||
|
||||
/**
|
||||
* @param connection a #mpd_Connection
|
||||
* @param type
|
||||
* @param name
|
||||
*/
|
||||
void mpd_addConstraintSearch(mpd_Connection *connection, int type, const char *name);
|
||||
|
||||
/**
|
||||
* @param connection a #mpd_Connection
|
||||
*/
|
||||
void mpd_commitSearch(mpd_Connection *connection);
|
||||
|
||||
/**
|
||||
* @param connection a #mpd_Connection
|
||||
* @param type The type to search for
|
||||
*
|
||||
* starts a search for fields... f.e. get a list of artists would be:
|
||||
* @code
|
||||
* mpd_startFieldSearch(connection, MPD_TAG_ITEM_ARTIST);
|
||||
* mpd_commitSearch(connection);
|
||||
* @endcode
|
||||
*
|
||||
* or get a list of artist in genre "jazz" would be:
|
||||
* @code
|
||||
* mpd_startFieldSearch(connection, MPD_TAG_ITEM_ARTIST);
|
||||
* mpd_addConstraintSearch(connection, MPD_TAG_ITEM_GENRE, "jazz")
|
||||
* mpd_commitSearch(connection);
|
||||
* @endcode
|
||||
*
|
||||
* mpd_startSearch will return a list of songs (and you need mpd_getNextInfoEntity)
|
||||
* this one will return a list of only one field (the one specified with type) and you need
|
||||
* mpd_getNextTag to get the results
|
||||
*/
|
||||
void mpd_startFieldSearch(mpd_Connection *connection, int type);
|
||||
|
||||
void mpd_startPlaylistSearch(mpd_Connection *connection, int exact);
|
||||
|
||||
void mpd_startStatsSearch(mpd_Connection *connection);
|
||||
|
||||
void mpd_sendPlaylistClearCommand(mpd_Connection *connection, const char *path);
|
||||
|
||||
void mpd_sendPlaylistAddCommand(mpd_Connection *connection,
|
||||
const char *playlist, const char *path);
|
||||
|
||||
void mpd_sendPlaylistMoveCommand(mpd_Connection *connection,
|
||||
const char *playlist, int from, int to);
|
||||
|
||||
void mpd_sendPlaylistDeleteCommand(mpd_Connection *connection,
|
||||
const char *playlist, int pos);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -185,11 +185,11 @@ void MediaLibrary::Update()
|
||||
Albums->Reset();
|
||||
TagList list;
|
||||
locale_to_utf(Artists->Current());
|
||||
if (Config.media_lib_primary_tag == MPD_TAG_ITEM_ARTIST)
|
||||
if (Config.media_lib_primary_tag == MPD_TAG_ARTIST)
|
||||
Mpd.GetAlbums(Artists->Current(), list);
|
||||
else
|
||||
{
|
||||
Mpd.StartFieldSearch(MPD_TAG_ITEM_ALBUM);
|
||||
Mpd.StartFieldSearch(MPD_TAG_ALBUM);
|
||||
Mpd.AddSearch(Config.media_lib_primary_tag, Artists->Current());
|
||||
Mpd.CommitSearch(list);
|
||||
}
|
||||
@@ -198,9 +198,9 @@ void MediaLibrary::Update()
|
||||
if (Mpd.Version() > 13)
|
||||
{
|
||||
TagList noalbum_list;
|
||||
Mpd.StartFieldSearch(MPD_TAG_ITEM_FILENAME);
|
||||
Mpd.StartFieldSearch(MPD_TAG_FILE);
|
||||
Mpd.AddSearch(Config.media_lib_primary_tag, Artists->Current());
|
||||
Mpd.AddSearch(MPD_TAG_ITEM_ALBUM, "");
|
||||
Mpd.AddSearch(MPD_TAG_ALBUM, "");
|
||||
Mpd.CommitSearch(noalbum_list);
|
||||
if (!noalbum_list.empty())
|
||||
Albums->AddOption(std::make_pair("<no album>", SearchConstraints("", "")));
|
||||
@@ -209,9 +209,9 @@ void MediaLibrary::Update()
|
||||
for (TagList::const_iterator it = list.begin(); it != list.end(); ++it)
|
||||
{
|
||||
TagList l;
|
||||
Mpd.StartFieldSearch(MPD_TAG_ITEM_DATE);
|
||||
Mpd.StartFieldSearch(MPD_TAG_DATE);
|
||||
Mpd.AddSearch(Config.media_lib_primary_tag, Artists->Current());
|
||||
Mpd.AddSearch(MPD_TAG_ITEM_ALBUM, *it);
|
||||
Mpd.AddSearch(MPD_TAG_ALBUM, *it);
|
||||
Mpd.CommitSearch(l);
|
||||
if (l.empty())
|
||||
{
|
||||
@@ -237,17 +237,17 @@ void MediaLibrary::Update()
|
||||
for (TagList::const_iterator i = artists.begin(); i != artists.end(); ++i)
|
||||
{
|
||||
TagList albums;
|
||||
Mpd.StartFieldSearch(MPD_TAG_ITEM_ALBUM);
|
||||
Mpd.StartFieldSearch(MPD_TAG_ALBUM);
|
||||
Mpd.AddSearch(Config.media_lib_primary_tag, *i);
|
||||
Mpd.CommitSearch(albums);
|
||||
for (TagList::const_iterator j = albums.begin(); j != albums.end(); ++j)
|
||||
{
|
||||
if (Config.media_lib_primary_tag != MPD_TAG_ITEM_DATE)
|
||||
if (Config.media_lib_primary_tag != MPD_TAG_DATE)
|
||||
{
|
||||
TagList years;
|
||||
Mpd.StartFieldSearch(MPD_TAG_ITEM_DATE);
|
||||
Mpd.StartFieldSearch(MPD_TAG_DATE);
|
||||
Mpd.AddSearch(Config.media_lib_primary_tag, *i);
|
||||
Mpd.AddSearch(MPD_TAG_ITEM_ALBUM, *j);
|
||||
Mpd.AddSearch(MPD_TAG_ALBUM, *j);
|
||||
Mpd.CommitSearch(years);
|
||||
if (!years.empty())
|
||||
{
|
||||
@@ -292,9 +292,9 @@ void MediaLibrary::Update()
|
||||
}
|
||||
else
|
||||
{
|
||||
Mpd.AddSearch(MPD_TAG_ITEM_ALBUM, Albums->Current().second.Album);
|
||||
Mpd.AddSearch(MPD_TAG_ALBUM, Albums->Current().second.Album);
|
||||
if (!Albums->Current().second.Album.empty()) // for <no album>
|
||||
Mpd.AddSearch(MPD_TAG_ITEM_DATE, Albums->Current().second.Year);
|
||||
Mpd.AddSearch(MPD_TAG_DATE, Albums->Current().second.Year);
|
||||
}
|
||||
Mpd.CommitSearch(list);
|
||||
|
||||
|
||||
645
src/mpdpp.cpp
645
src/mpdpp.cpp
File diff suppressed because it is too large
Load Diff
68
src/mpdpp.h
68
src/mpdpp.h
@@ -23,7 +23,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "libmpdclient.h"
|
||||
#include <mpd/client.h>
|
||||
#include "song.h"
|
||||
|
||||
namespace MPD
|
||||
@@ -96,14 +96,14 @@ namespace MPD
|
||||
void SetPort(int port) { itsPort = port; }
|
||||
void SetTimeout(int timeout) { itsTimeout = timeout; }
|
||||
void SetPassword(const std::string &password) { itsPassword = password; }
|
||||
void SendPassword() const;
|
||||
bool SendPassword() const;
|
||||
|
||||
void SetStatusUpdater(StatusUpdater, void *);
|
||||
void SetErrorHandler(ErrorHandler, void *);
|
||||
void UpdateStatus();
|
||||
void UpdateDirectory(const std::string &);
|
||||
bool UpdateDirectory(const std::string &);
|
||||
|
||||
void Execute(const std::string &) const;
|
||||
bool Execute(const std::string &) const;
|
||||
|
||||
void Play() const;
|
||||
void Play(int) const;
|
||||
@@ -112,31 +112,31 @@ namespace MPD
|
||||
void Stop() const;
|
||||
void Next() const;
|
||||
void Prev() const;
|
||||
void Move(int, int) const;
|
||||
void Swap(int, int) const;
|
||||
void Seek(int) const;
|
||||
void Move(unsigned, unsigned) const;
|
||||
void Swap(unsigned, unsigned) const;
|
||||
void Seek(unsigned) const;
|
||||
void Shuffle() const;
|
||||
void ClearPlaylist() const;
|
||||
|
||||
bool isPlaying() const { return GetState() > psStop; }
|
||||
|
||||
PlayerState GetState() const { return isConnected && itsCurrentStatus ? PlayerState(itsCurrentStatus->state) : psUnknown; }
|
||||
bool GetRepeat() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->repeat : 0; }
|
||||
bool GetRandom() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->random : 0; }
|
||||
bool GetSingle() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->single : 0; }
|
||||
bool GetConsume() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->consume : 0; }
|
||||
bool GetDBIsUpdating() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->updatingDb : 0; }
|
||||
int GetVolume() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->volume : -1; }
|
||||
int GetCrossfade() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->crossfade : -1; }
|
||||
long long GetPlaylistID() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->playlist : -1; }
|
||||
long long GetOldPlaylistID() const { return isConnected && itsOldStatus ? itsOldStatus->playlist : -1; }
|
||||
int GetElapsedTime() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->elapsedTime : -1; }
|
||||
int GetTotalTime() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->totalTime : 0; }
|
||||
unsigned GetBitrate() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->bitRate : 0; }
|
||||
PlayerState GetState() const{ return itsCurrentStatus ? PlayerState(mpd_status_get_state(itsCurrentStatus)) : psUnknown; }
|
||||
bool GetRepeat() const { return itsCurrentStatus ? mpd_status_get_repeat(itsCurrentStatus) : 0; }
|
||||
bool GetRandom() const { return itsCurrentStatus ? mpd_status_get_random(itsCurrentStatus) : 0; }
|
||||
bool GetSingle() const { return itsCurrentStatus ? mpd_status_get_single(itsCurrentStatus) : 0; }
|
||||
bool GetConsume() const { return itsCurrentStatus ? mpd_status_get_consume(itsCurrentStatus) : 0; }
|
||||
bool GetDBIsUpdating() const { return itsCurrentStatus ? mpd_status_get_update_id(itsCurrentStatus) : 0; }
|
||||
int GetVolume() const { return itsCurrentStatus ? mpd_status_get_volume(itsCurrentStatus) : -1; }
|
||||
unsigned GetCrossfade() const { return itsCurrentStatus ? mpd_status_get_crossfade(itsCurrentStatus) : 0; }
|
||||
unsigned GetPlaylistID() const { return itsCurrentStatus ? mpd_status_get_queue_version(itsCurrentStatus) : 0; }
|
||||
unsigned GetOldPlaylistID() const { return itsOldStatus ? mpd_status_get_queue_version(itsOldStatus) : 0; }
|
||||
unsigned GetElapsedTime() const { return itsCurrentStatus ? mpd_status_get_elapsed_time(itsCurrentStatus) : 0; }
|
||||
int GetTotalTime() const { return itsCurrentStatus ? mpd_status_get_total_time(itsCurrentStatus) : 0; }
|
||||
unsigned GetBitrate() const { return itsCurrentStatus ? mpd_status_get_kbit_rate(itsCurrentStatus) : 0; }
|
||||
|
||||
size_t GetMaxPlaylistLength() const { return itsMaxPlaylistLength; }
|
||||
size_t GetPlaylistLength() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->playlistLength : 0; }
|
||||
void GetPlaylistChanges(long long, SongList &) const;
|
||||
size_t GetPlaylistLength() const { return itsCurrentStatus ? mpd_status_get_queue_length(itsCurrentStatus) : 0; }
|
||||
void GetPlaylistChanges(unsigned, SongList &) const;
|
||||
|
||||
const std::string & GetErrorMessage() const { return itsErrorMessage; }
|
||||
int GetErrorCode() const { return itsErrorCode; }
|
||||
@@ -150,16 +150,16 @@ namespace MPD
|
||||
void SetRandom(bool) const;
|
||||
void SetSingle(bool) const;
|
||||
void SetConsume(bool) const;
|
||||
void SetCrossfade(int) const;
|
||||
void SetVolume(int);
|
||||
void SetCrossfade(unsigned) const;
|
||||
void SetVolume(unsigned);
|
||||
|
||||
int AddSong(const std::string &); // returns id of added song
|
||||
int AddSong(const Song &); // returns id of added song
|
||||
bool AddRandomSongs(size_t);
|
||||
void Add(const std::string &path) const;
|
||||
void Delete(int) const;
|
||||
void DeleteID(int) const;
|
||||
void Delete(const std::string &, int) const;
|
||||
void Delete(unsigned) const;
|
||||
void DeleteID(unsigned) const;
|
||||
void Delete(const std::string &, unsigned) const;
|
||||
void StartCommandsList();
|
||||
bool CommitCommandsList();
|
||||
|
||||
@@ -172,13 +172,13 @@ namespace MPD
|
||||
void Rename(const std::string &, const std::string &) const;
|
||||
|
||||
void StartSearch(bool) const;
|
||||
void StartFieldSearch(mpd_TagItems);
|
||||
void AddSearch(mpd_TagItems, const std::string &) const;
|
||||
void StartFieldSearch(mpd_tag_type);
|
||||
void AddSearch(mpd_tag_type, const std::string &) const;
|
||||
void CommitSearch(SongList &) const;
|
||||
void CommitSearch(TagList &) const;
|
||||
|
||||
void GetPlaylists(TagList &) const;
|
||||
void GetList(TagList &, mpd_TagItems) const;
|
||||
void GetList(TagList &, mpd_tag_type) const;
|
||||
void GetAlbums(const std::string &, TagList &) const;
|
||||
void GetDirectory(const std::string &, ItemList &) const;
|
||||
void GetDirectoryRecursive(const std::string &, SongList &) const;
|
||||
@@ -192,7 +192,7 @@ namespace MPD
|
||||
private:
|
||||
int CheckForErrors();
|
||||
|
||||
mpd_Connection *itsConnection;
|
||||
mpd_connection *itsConnection;
|
||||
bool isConnected;
|
||||
bool isCommandsListEnabled;
|
||||
|
||||
@@ -205,8 +205,8 @@ namespace MPD
|
||||
int itsTimeout;
|
||||
std::string itsPassword;
|
||||
|
||||
mpd_Status *itsCurrentStatus;
|
||||
mpd_Status *itsOldStatus;
|
||||
mpd_status *itsCurrentStatus;
|
||||
mpd_status *itsOldStatus;
|
||||
|
||||
StatusChanges itsChanges;
|
||||
|
||||
@@ -215,7 +215,7 @@ namespace MPD
|
||||
ErrorHandler itsErrorHandler;
|
||||
void *itsErrorHandlerUserdata;
|
||||
|
||||
mpd_TagItems itsSearchedField;
|
||||
mpd_tag_type itsSearchedField;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1816,7 +1816,7 @@ int main(int argc, char *argv[])
|
||||
while (item != 'a' && item != 'y' && item != 'g' && item != 'c' && item != 'p');
|
||||
curs_set(0);
|
||||
UnlockStatusbar();
|
||||
mpd_TagItems new_tagitem = IntoTagItem(item);
|
||||
mpd_tag_type new_tagitem = IntoTagItem(item);
|
||||
if (new_tagitem != Config.media_lib_primary_tag)
|
||||
{
|
||||
Config.media_lib_primary_tag = new_tagitem;
|
||||
|
||||
@@ -279,7 +279,7 @@ void DefaultConfiguration(ncmpcpp_config &conf)
|
||||
conf.active_column_color = clRed;
|
||||
conf.window_border = brGreen;
|
||||
conf.active_window_border = brRed;
|
||||
conf.media_lib_primary_tag = MPD_TAG_ITEM_ARTIST;
|
||||
conf.media_lib_primary_tag = MPD_TAG_ARTIST;
|
||||
conf.colors_enabled = true;
|
||||
conf.fancy_scrolling = true;
|
||||
conf.playlist_show_remaining_time = false;
|
||||
|
||||
@@ -24,8 +24,9 @@
|
||||
#include <limits>
|
||||
#include <vector>
|
||||
|
||||
#include <mpd/client.h>
|
||||
|
||||
#include "home.h"
|
||||
#include "libmpdclient.h"
|
||||
#include "ncmpcpp.h"
|
||||
|
||||
#ifdef WIN32
|
||||
@@ -170,7 +171,7 @@ struct ncmpcpp_config
|
||||
Border window_border;
|
||||
Border active_window_border;
|
||||
|
||||
mpd_TagItems media_lib_primary_tag;
|
||||
mpd_tag_type media_lib_primary_tag;
|
||||
|
||||
bool colors_enabled;
|
||||
bool fancy_scrolling;
|
||||
|
||||
206
src/song.cpp
206
src/song.cpp
@@ -32,13 +32,24 @@
|
||||
#include "error.h"
|
||||
#include "song.h"
|
||||
|
||||
MPD::Song::Song(mpd_Song *s, bool copy_ptr) : itsSong(s ? s : mpd_newSong()),
|
||||
namespace
|
||||
{
|
||||
unsigned calc_hash(const char *p)
|
||||
{
|
||||
unsigned hash = 5381;
|
||||
while (*p)
|
||||
hash = (hash << 5) + hash + *p++;
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
MPD::Song::Song(mpd_song *s, bool copy_ptr) : itsSong(s),
|
||||
itsSlash(std::string::npos),
|
||||
itsHash(0),
|
||||
copyPtr(copy_ptr),
|
||||
isLocalised(0)
|
||||
{
|
||||
if (itsSong->file)
|
||||
if (itsSong)
|
||||
SetHashAndSlash();
|
||||
}
|
||||
|
||||
@@ -49,18 +60,19 @@ MPD::Song::Song(const Song &s) : itsSong(0),
|
||||
copyPtr(s.copyPtr),
|
||||
isLocalised(s.isLocalised)
|
||||
{
|
||||
itsSong = s.copyPtr ? s.itsSong : mpd_songDup(s.itsSong);
|
||||
itsSong = s.copyPtr ? s.itsSong : mpd_song_dup(s.itsSong);
|
||||
}
|
||||
|
||||
MPD::Song::~Song()
|
||||
{
|
||||
if (itsSong)
|
||||
mpd_freeSong(itsSong);
|
||||
mpd_song_free(itsSong);
|
||||
}
|
||||
|
||||
std::string MPD::Song::GetLength() const
|
||||
{
|
||||
return itsSong->time <= 0 ? "-:--" : ShowTime(itsSong->time);
|
||||
unsigned len = mpd_song_get_duration(itsSong);
|
||||
return !len ? "-:--" : ShowTime(len);
|
||||
}
|
||||
|
||||
void MPD::Song::Localize()
|
||||
@@ -88,8 +100,8 @@ void MPD::Song::Localize()
|
||||
void MPD::Song::Clear()
|
||||
{
|
||||
if (itsSong)
|
||||
mpd_freeSong(itsSong);
|
||||
itsSong = mpd_newSong();
|
||||
mpd_song_free(itsSong);
|
||||
itsSong = 0;
|
||||
itsNewName.clear();
|
||||
itsSlash = std::string::npos;
|
||||
itsHash = 0;
|
||||
@@ -99,79 +111,88 @@ void MPD::Song::Clear()
|
||||
|
||||
bool MPD::Song::Empty() const
|
||||
{
|
||||
return !itsSong || (!itsSong->file && !itsSong->title && !itsSong->artist && !itsSong->album && !itsSong->date && !itsSong->track && !itsSong->genre && !itsSong->composer && !itsSong->performer && !itsSong->disc && !itsSong->comment);
|
||||
return !itsSong;// || (!itsSong->file && !itsSong->title && !itsSong->artist && !itsSong->album && !itsSong->date && !itsSong->track && !itsSong->genre && !itsSong->composer && !itsSong->performer && !itsSong->disc && !itsSong->comment);
|
||||
}
|
||||
|
||||
bool MPD::Song::isFromDB() const
|
||||
{
|
||||
return (itsSong->file && itsSong->file[0] != '/') || itsSlash == std::string::npos;
|
||||
return (mpd_song_get_uri(itsSong)[0] != '/') || itsSlash == std::string::npos;
|
||||
}
|
||||
|
||||
bool MPD::Song::isStream() const
|
||||
{
|
||||
return !strncmp(itsSong->file, "http://", 7);
|
||||
return !strncmp(mpd_song_get_uri(itsSong), "http://", 7);
|
||||
}
|
||||
|
||||
std::string MPD::Song::GetFile() const
|
||||
{
|
||||
return !itsSong->file ? "" : itsSong->file;
|
||||
return mpd_song_get_uri(itsSong);
|
||||
}
|
||||
|
||||
std::string MPD::Song::GetName() const
|
||||
{
|
||||
if (itsSong->name)
|
||||
return itsSong->name;
|
||||
else if (!itsSong->file)
|
||||
return "";
|
||||
if (const char *name = mpd_song_get_tag(itsSong, MPD_TAG_NAME, 0))
|
||||
return name;
|
||||
else if (itsSlash != std::string::npos)
|
||||
return itsSong->file+itsSlash+1;
|
||||
return mpd_song_get_uri(itsSong)+itsSlash+1;
|
||||
else
|
||||
return itsSong->file;
|
||||
return mpd_song_get_uri(itsSong);
|
||||
}
|
||||
|
||||
std::string MPD::Song::GetDirectory() const
|
||||
{
|
||||
if (!itsSong->file || isStream())
|
||||
if (isStream())
|
||||
return "";
|
||||
else if (itsSlash == std::string::npos)
|
||||
return "/";
|
||||
else
|
||||
return std::string(itsSong->file, itsSlash);
|
||||
return std::string(mpd_song_get_uri(itsSong), itsSlash);
|
||||
}
|
||||
|
||||
std::string MPD::Song::GetArtist() const
|
||||
{
|
||||
return !itsSong->artist ? "" : itsSong->artist;
|
||||
if (const char *artist = mpd_song_get_tag(itsSong, MPD_TAG_ARTIST, 0))
|
||||
return artist;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string MPD::Song::GetTitle() const
|
||||
{
|
||||
return !itsSong->title ? "" : itsSong->title;
|
||||
if (const char *title = mpd_song_get_tag(itsSong, MPD_TAG_TITLE, 0))
|
||||
return title;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string MPD::Song::GetAlbum() const
|
||||
{
|
||||
return !itsSong->album ? "" : itsSong->album;
|
||||
if (const char *album = mpd_song_get_tag(itsSong, MPD_TAG_ALBUM, 0))
|
||||
return album;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string MPD::Song::GetTrack() const
|
||||
{
|
||||
if (!itsSong->track)
|
||||
const char *track = mpd_song_get_tag(itsSong, MPD_TAG_TRACK, 0);
|
||||
if (!track)
|
||||
return "";
|
||||
else if (itsSong->track[0] != '0' && !itsSong->track[1])
|
||||
return "0"+std::string(itsSong->track);
|
||||
else if (track[0] != '0' && !track[1])
|
||||
return "0"+std::string(track);
|
||||
else
|
||||
return itsSong->track;
|
||||
return track;
|
||||
}
|
||||
|
||||
std::string MPD::Song::GetTrackNumber() const
|
||||
{
|
||||
if (!itsSong->track)
|
||||
const char *track = mpd_song_get_tag(itsSong, MPD_TAG_TRACK, 0);
|
||||
if (!track)
|
||||
return "";
|
||||
const char *slash = strrchr(itsSong->track, '/');
|
||||
const char *slash = strrchr(track, '/');
|
||||
if (slash)
|
||||
{
|
||||
std::string result(itsSong->track, slash-itsSong->track);
|
||||
std::string result(track, slash-track);
|
||||
return result[0] != '0' && result.length() == 1 ? "0"+result : result;
|
||||
}
|
||||
else
|
||||
@@ -180,129 +201,147 @@ std::string MPD::Song::GetTrackNumber() const
|
||||
|
||||
std::string MPD::Song::GetDate() const
|
||||
{
|
||||
return !itsSong->date ? "" : itsSong->date;
|
||||
if (const char *date = mpd_song_get_tag(itsSong, MPD_TAG_DATE, 0))
|
||||
return date;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string MPD::Song::GetGenre() const
|
||||
{
|
||||
return !itsSong->genre ? "" : itsSong->genre;
|
||||
if (const char *genre = mpd_song_get_tag(itsSong, MPD_TAG_GENRE, 0))
|
||||
return genre;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string MPD::Song::GetComposer() const
|
||||
{
|
||||
return !itsSong->composer ? "" : itsSong->composer;
|
||||
if (const char *composer = mpd_song_get_tag(itsSong, MPD_TAG_COMPOSER, 0))
|
||||
return composer;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string MPD::Song::GetPerformer() const
|
||||
{
|
||||
return !itsSong->performer ? "" : itsSong->performer;
|
||||
if (const char *performer = mpd_song_get_tag(itsSong, MPD_TAG_PERFORMER, 0))
|
||||
return performer;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string MPD::Song::GetDisc() const
|
||||
{
|
||||
return !itsSong->disc ? "" : itsSong->disc;
|
||||
if (const char *disc = mpd_song_get_tag(itsSong, MPD_TAG_DISC, 0))
|
||||
return disc;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string MPD::Song::GetComment() const
|
||||
{
|
||||
return !itsSong->comment ? "" : itsSong->comment;
|
||||
if (const char *comment = mpd_song_get_tag(itsSong, MPD_TAG_COMMENT, 0))
|
||||
return comment;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
void MPD::Song::SetFile(const std::string &str)
|
||||
/*void MPD::Song::SetFile(const std::string &str)
|
||||
{
|
||||
if (itsSong->file)
|
||||
str_pool_put(itsSong->file);
|
||||
itsSong->file = str.empty() ? 0 : str_pool_get(str.c_str());
|
||||
SetHashAndSlash();
|
||||
}
|
||||
}*/
|
||||
|
||||
void MPD::Song::SetArtist(const std::string &str)
|
||||
{
|
||||
if (itsSong->artist)
|
||||
str_pool_put(itsSong->artist);
|
||||
itsSong->artist = str.empty() ? 0 : str_pool_get(str.c_str());
|
||||
mpd_song_clear_tag(itsSong, MPD_TAG_ARTIST);
|
||||
if (!str.empty())
|
||||
mpd_song_add_tag(itsSong, MPD_TAG_ARTIST, str.c_str());
|
||||
}
|
||||
|
||||
void MPD::Song::SetTitle(const std::string &str)
|
||||
{
|
||||
if (itsSong->title)
|
||||
str_pool_put(itsSong->title);
|
||||
itsSong->title = str.empty() ? 0 : str_pool_get(str.c_str());
|
||||
mpd_song_clear_tag(itsSong, MPD_TAG_TITLE);
|
||||
if (!str.empty())
|
||||
mpd_song_add_tag(itsSong, MPD_TAG_TITLE, str.c_str());
|
||||
}
|
||||
|
||||
void MPD::Song::SetAlbum(const std::string &str)
|
||||
{
|
||||
if (itsSong->album)
|
||||
str_pool_put(itsSong->album);
|
||||
itsSong->album = str.empty() ? 0 : str_pool_get(str.c_str());
|
||||
mpd_song_clear_tag(itsSong, MPD_TAG_ALBUM);
|
||||
if (!str.empty())
|
||||
mpd_song_add_tag(itsSong, MPD_TAG_ALBUM, str.c_str());
|
||||
}
|
||||
|
||||
void MPD::Song::SetTrack(const std::string &str)
|
||||
{
|
||||
if (itsSong->track)
|
||||
str_pool_put(itsSong->track);
|
||||
itsSong->track = str.empty() ? 0 : str_pool_get(str.c_str());
|
||||
mpd_song_clear_tag(itsSong, MPD_TAG_TRACK);
|
||||
if (!str.empty())
|
||||
mpd_song_add_tag(itsSong, MPD_TAG_TRACK, str.c_str());
|
||||
}
|
||||
|
||||
void MPD::Song::SetTrack(int track)
|
||||
void MPD::Song::SetTrack(unsigned track)
|
||||
{
|
||||
if (itsSong->track)
|
||||
str_pool_put(itsSong->track);
|
||||
itsSong->track = str_pool_get(IntoStr(track).c_str());
|
||||
mpd_song_clear_tag(itsSong, MPD_TAG_TRACK);
|
||||
if (track)
|
||||
mpd_song_add_tag(itsSong, MPD_TAG_ARTIST, IntoStr(track).c_str());
|
||||
}
|
||||
|
||||
void MPD::Song::SetDate(const std::string &str)
|
||||
{
|
||||
if (itsSong->date)
|
||||
str_pool_put(itsSong->date);
|
||||
itsSong->date = str.empty() ? 0 : str_pool_get(str.c_str());
|
||||
mpd_song_clear_tag(itsSong, MPD_TAG_DATE);
|
||||
if (!str.empty())
|
||||
mpd_song_add_tag(itsSong, MPD_TAG_DATE, str.c_str());
|
||||
}
|
||||
|
||||
void MPD::Song::SetDate(int year)
|
||||
void MPD::Song::SetDate(unsigned year)
|
||||
{
|
||||
if (itsSong->date)
|
||||
str_pool_put(itsSong->date);
|
||||
itsSong->date = str_pool_get(IntoStr(year).c_str());
|
||||
mpd_song_clear_tag(itsSong, MPD_TAG_DATE);
|
||||
if (year)
|
||||
mpd_song_add_tag(itsSong, MPD_TAG_DATE, IntoStr(year).c_str());
|
||||
}
|
||||
|
||||
void MPD::Song::SetGenre(const std::string &str)
|
||||
{
|
||||
if (itsSong->genre)
|
||||
str_pool_put(itsSong->genre);
|
||||
itsSong->genre = str.empty() ? 0 : str_pool_get(str.c_str());
|
||||
mpd_song_clear_tag(itsSong, MPD_TAG_GENRE);
|
||||
if (!str.empty())
|
||||
mpd_song_add_tag(itsSong, MPD_TAG_GENRE, str.c_str());
|
||||
}
|
||||
|
||||
void MPD::Song::SetComposer(const std::string &str)
|
||||
{
|
||||
if (itsSong->composer)
|
||||
str_pool_put(itsSong->composer);
|
||||
itsSong->composer = str.empty() ? 0 : str_pool_get(str.c_str());
|
||||
mpd_song_clear_tag(itsSong, MPD_TAG_COMPOSER);
|
||||
if (!str.empty())
|
||||
mpd_song_add_tag(itsSong, MPD_TAG_COMPOSER, str.c_str());
|
||||
}
|
||||
|
||||
void MPD::Song::SetPerformer(const std::string &str)
|
||||
{
|
||||
if (itsSong->performer)
|
||||
str_pool_put(itsSong->performer);
|
||||
itsSong->performer = str.empty() ? 0 : str_pool_get(str.c_str());
|
||||
mpd_song_clear_tag(itsSong, MPD_TAG_PERFORMER);
|
||||
if (!str.empty())
|
||||
mpd_song_add_tag(itsSong, MPD_TAG_PERFORMER, str.c_str());
|
||||
}
|
||||
|
||||
void MPD::Song::SetDisc(const std::string &str)
|
||||
{
|
||||
if (itsSong->disc)
|
||||
str_pool_put(itsSong->disc);
|
||||
itsSong->disc = str.empty() ? 0 : str_pool_get(str.c_str());
|
||||
mpd_song_clear_tag(itsSong, MPD_TAG_DISC);
|
||||
if (!str.empty())
|
||||
mpd_song_add_tag(itsSong, MPD_TAG_DISC, str.c_str());
|
||||
}
|
||||
|
||||
void MPD::Song::SetComment(const std::string &str)
|
||||
{
|
||||
if (itsSong->comment)
|
||||
str_pool_put(itsSong->comment);
|
||||
itsSong->comment = str.empty() ? 0 : str_pool_get(str.c_str());
|
||||
mpd_song_clear_tag(itsSong, MPD_TAG_COMMENT);
|
||||
if (!str.empty())
|
||||
mpd_song_add_tag(itsSong, MPD_TAG_COMMENT, str.c_str());
|
||||
}
|
||||
|
||||
void MPD::Song::SetPosition(int pos)
|
||||
void MPD::Song::SetPosition(unsigned pos)
|
||||
{
|
||||
itsSong->pos = pos;
|
||||
mpd_song_set_pos(itsSong, pos);
|
||||
}
|
||||
|
||||
std::string MPD::Song::ParseFormat(std::string::const_iterator &it) const
|
||||
@@ -434,8 +473,8 @@ MPD::Song &MPD::Song::operator=(const MPD::Song &s)
|
||||
if (this == &s)
|
||||
return *this;
|
||||
if (itsSong)
|
||||
mpd_freeSong(itsSong);
|
||||
itsSong = s.copyPtr ? s.itsSong : mpd_songDup(s.itsSong);
|
||||
mpd_song_free(itsSong);
|
||||
itsSong = s.copyPtr ? s.itsSong : (s.itsSong ? mpd_song_dup(s.itsSong) : 0);
|
||||
itsNewName = s.itsNewName;
|
||||
itsSlash = s.itsSlash;
|
||||
itsHash = s.itsHash;
|
||||
@@ -484,13 +523,12 @@ void MPD::Song::ValidateFormat(const std::string &type, const std::string &s)
|
||||
|
||||
void MPD::Song::SetHashAndSlash()
|
||||
{
|
||||
if (!itsSong->file)
|
||||
return;
|
||||
const char *filename = mpd_song_get_uri(itsSong);
|
||||
if (!isStream())
|
||||
{
|
||||
const char *tmp = strrchr(itsSong->file, '/');
|
||||
itsSlash = tmp ? tmp-itsSong->file : std::string::npos;
|
||||
const char *tmp = strrchr(filename, '/');
|
||||
itsSlash = tmp ? tmp-filename : std::string::npos;
|
||||
}
|
||||
itsHash = calc_hash(itsSong->file);
|
||||
itsHash = calc_hash(filename);
|
||||
}
|
||||
|
||||
|
||||
22
src/song.h
22
src/song.h
@@ -23,7 +23,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "libmpdclient.h"
|
||||
#include <mpd/client.h>
|
||||
|
||||
namespace MPD
|
||||
{
|
||||
@@ -34,8 +34,8 @@ namespace MPD
|
||||
typedef void (Song::*SetFunction)(const std::string &);
|
||||
typedef std::string (Song::*GetFunction)() const;
|
||||
|
||||
Song() : itsSlash(std::string::npos), itsHash(0), copyPtr(0), isLocalised(0) { itsSong = mpd_newSong(); }
|
||||
Song(mpd_Song *, bool = 0);
|
||||
Song() : itsSong(0), itsSlash(std::string::npos), itsHash(0), copyPtr(0), isLocalised(0) { }
|
||||
Song(mpd_song *, bool = 0);
|
||||
Song(const Song &);
|
||||
~Song();
|
||||
|
||||
@@ -56,24 +56,24 @@ namespace MPD
|
||||
std::string GetLength() const;
|
||||
|
||||
unsigned GetHash() const { return itsHash; }
|
||||
int GetTotalLength() const { return itsSong->time < 0 ? 0 : itsSong->time; }
|
||||
int GetPosition() const { return itsSong->pos; }
|
||||
int GetID() const { return itsSong->id; }
|
||||
unsigned GetTotalLength() const { return mpd_song_get_duration(itsSong); }
|
||||
unsigned GetPosition() const { return mpd_song_get_pos(itsSong); }
|
||||
unsigned GetID() const { return mpd_song_get_id(itsSong); }
|
||||
|
||||
void SetFile(const std::string &);
|
||||
//void SetFile(const std::string &);
|
||||
void SetArtist(const std::string &);
|
||||
void SetTitle(const std::string &);
|
||||
void SetAlbum(const std::string &);
|
||||
void SetTrack(const std::string &);
|
||||
void SetTrack(int);
|
||||
void SetTrack(unsigned);
|
||||
void SetDate(const std::string &);
|
||||
void SetDate(int);
|
||||
void SetDate(unsigned);
|
||||
void SetGenre(const std::string &);
|
||||
void SetComposer(const std::string &);
|
||||
void SetPerformer(const std::string &);
|
||||
void SetDisc(const std::string &);
|
||||
void SetComment(const std::string &);
|
||||
void SetPosition(int);
|
||||
void SetPosition(unsigned);
|
||||
|
||||
void SetNewName(const std::string &name) { itsNewName = name == GetName() ? "" : name; }
|
||||
std::string GetNewName() const { return itsNewName; }
|
||||
@@ -99,7 +99,7 @@ namespace MPD
|
||||
void SetHashAndSlash();
|
||||
std::string ParseFormat(std::string::const_iterator &it) const;
|
||||
|
||||
mpd_Song *itsSong;
|
||||
mpd_song *itsSong;
|
||||
std::string itsNewName;
|
||||
size_t itsSlash;
|
||||
unsigned itsHash;
|
||||
|
||||
@@ -158,12 +158,11 @@ void TraceMpdStatus()
|
||||
|
||||
void NcmpcppErrorCallback(Connection *, int errorid, const char *msg, void *)
|
||||
{
|
||||
if (errorid == MPD_ACK_ERROR_PERMISSION)
|
||||
if (errorid == MPD_SERVER_ERROR_PERMISSION)
|
||||
{
|
||||
wFooter->SetGetStringHelper(0);
|
||||
Statusbar() << "Password: ";
|
||||
std::string password = wFooter->GetString(-1, 0, 1);
|
||||
Mpd.SetPassword(password);
|
||||
Mpd.SetPassword(wFooter->GetString(-1, 0, 1));
|
||||
Mpd.SendPassword();
|
||||
Mpd.UpdateStatus();
|
||||
wFooter->SetGetStringHelper(StatusbarGetStringHelper);
|
||||
|
||||
@@ -236,7 +236,7 @@ void TagEditor::Update()
|
||||
{
|
||||
MPD::SongList l;
|
||||
Mpd.StartSearch(1);
|
||||
Mpd.AddSearch(MPD_TAG_ITEM_ALBUM, *it);
|
||||
Mpd.AddSearch(MPD_TAG_ALBUM, *it);
|
||||
Mpd.CommitSearch(l);
|
||||
if (!l.empty())
|
||||
{
|
||||
@@ -285,7 +285,7 @@ void TagEditor::Update()
|
||||
if (Config.albums_in_tag_editor)
|
||||
{
|
||||
Mpd.StartSearch(1);
|
||||
Mpd.AddSearch(MPD_TAG_ITEM_ALBUM, Albums->Current().second);
|
||||
Mpd.AddSearch(MPD_TAG_ALBUM, Albums->Current().second);
|
||||
Mpd.CommitSearch(list);
|
||||
sort(list.begin(), list.end(), CaseInsensitiveSorting());
|
||||
for (MPD::SongList::iterator it = list.begin(); it != list.end(); ++it)
|
||||
|
||||
Reference in New Issue
Block a user