Commit Graph

413 Commits

Author SHA1 Message Date
Max Kellermann
b7a7953757 db/Directory: use "unsigned" for inode and device
This is what we get from the storage plugin via FileInfo.  Fixes a
compiler warning on Mac OS X where dev_t appears to be signed.
2014-02-21 10:48:43 +01:00
Max Kellermann
e92a41fa3a db/upnp: move plugin source to upnp directory 2014-02-19 23:46:00 +01:00
Max Kellermann
150443b014 DatabasePlugin: add FLAG_REQUIRE_STORAGE
Ignore the storage configuration if FLAG_REQUIRE_STORAGE is not set in
the DatabasePlugin.
2014-02-19 23:24:17 +01:00
Max Kellermann
9e36af7916 DatabasePlugin: add attribute "flags" 2014-02-19 23:24:15 +01:00
Max Kellermann
85b8675e7a db/Interface: add attribute "plugin"
The new method IsPlugin() replaces the "is_simple" flag.
2014-02-19 23:17:21 +01:00
Max Kellermann
ae594ad92c DatabasePlugin: split header 2014-02-19 22:54:52 +01:00
Max Kellermann
579e48edbb util/StringUtil: add function Strip()
Replaces g_strstrip().
2014-02-17 22:37:43 +01:00
Max Kellermann
91729437a0 Main: initialize Database before Storage 2014-02-17 22:14:00 +01:00
Max Kellermann
1ddd00433e db/Configured: disallow both "db_file" and "database"
This is misconfiguration, and MPD should abort.
2014-02-17 22:13:53 +01:00
Max Kellermann
de160bb2d1 Main: move code to db/Configured.cxx 2014-02-17 22:13:53 +01:00
Max Kellermann
6da0af94df db/DatabaseSimple: remove obsolete header 2014-02-17 20:44:03 +01:00
Max Kellermann
2182209a8a db/update/Walk: disable FindAncestorLoop() if device/inode==0 2014-02-09 10:47:29 +01:00
Max Kellermann
e29a8b3a9c db/update/Walk: document FindAncestorLoop() 2014-02-09 10:46:39 +01:00
Max Kellermann
ace3f37af4 db/update/Walk: rename find_inode_ancestor() to FindAncestorLoop() 2014-02-09 10:46:39 +01:00
Max Kellermann
fe7c6fee34 ArchivePlugin: pass Path to open() 2014-02-08 13:25:44 +01:00
Max Kellermann
9906daeca7 ArchivePlugin: rename struct archive_plugin to ArchivePlugin 2014-02-08 13:22:13 +01:00
Max Kellermann
f947274626 InotifyUpdate: use class Storage instead of Mapper.cxx 2014-02-07 22:30:40 +01:00
Max Kellermann
f6939f71a7 InotifyUpdate: use the root name instead of mapper_get_music_directory_fs()
The root WatchDirectory instance already contains the music directory,
and we don't need to fetch it again.
2014-02-07 22:30:01 +01:00
Max Kellermann
25aa17ad89 InotifyUpdate: move functions into the WatchDirectory class 2014-02-07 22:24:26 +01:00
Max Kellermann
05ee057db5 InotifyUpdate: remove unnecessary #ifdefs 2014-02-07 22:17:27 +01:00
Max Kellermann
ffd16b55a6 StoragePlugin: add method MapToRelativeUTF8()
Replaces map_to_relative_path() from Mapper.cxx.
2014-02-07 19:09:28 +01:00
Max Kellermann
6b421cc354 DecoderPlugin: pass Path instance to file_decode() and scan_file() 2014-02-07 18:52:19 +01:00
Max Kellermann
4ab4cf8532 SongUpdate: pass Storage to UpdateFileInArchive() 2014-02-07 18:44:47 +01:00
Max Kellermann
c13810ebaa Mapper: move map_song_detach() to db/DatabaseSong.cxx
Use Storage::MapUTF8() internally, don't use global variables.
2014-02-07 00:42:14 +01:00
geneticdrift
0f1f509be7 fixed leaked LocalDirectoryReader *const reader in UpdateWalk::UpdateDirectory 2014-02-06 23:08:24 +01:00
Max Kellermann
29b18d9ab7 SongUpdate: use the Storage interface, support remote files
This commit finally allows the database update to scan remote files,
e.g. using the smbclient storage plugin.  However, it is not yet
possible to configure that, therefore the feature is not accessible
yet.
2014-02-06 19:06:08 +01:00
Max Kellermann
f6682aae77 db/update: include StorageInterface.hxx instead of LocalStorage.hxx 2014-02-05 19:26:18 +01:00
Max Kellermann
0ba1b73395 storage: add abstract interface
Prepare for the plugin interface.
2014-02-05 18:53:51 +01:00
Max Kellermann
4c995eb498 db/UpdateWalk: move LocalStorage to Instance
Keep only a reference.
2014-02-05 17:58:13 +01:00
Max Kellermann
144cfe70bf db/update/Remove: initialize attribute "removed_song"
Fixes bogus assertion failure.
2014-02-05 17:58:13 +01:00
Max Kellermann
9ae7f186bc LocalStorage: new API abstracting filesystem walk
Prepare to make this a new plugin API, for example to use a SMB share
for the music_directory.
2014-02-05 10:04:03 +01:00
Max Kellermann
f8d114be42 db/UpdateIO: add "pure" attributes 2014-02-05 10:04:03 +01:00
Max Kellermann
2c70251df1 db/UpdateGlue: relax assertion
Fixes assertion failure when update gets launched during MPD startup.
2014-02-05 10:04:03 +01:00
Max Kellermann
ff665b37cb db/DatabaseListener: add method OnDatabaseSongRemoved()
Decouples db/update/Remove.cpp from global variables.
2014-02-04 19:53:37 +01:00
Max Kellermann
ce73843014 db/proxy: include cleanup 2014-02-04 19:53:12 +01:00
Max Kellermann
eec6d09959 db/update/Service: use DatabaseListener instead of Instance
Don't use the global variable "instance".
2014-02-04 18:54:54 +01:00
Max Kellermann
c5fa8ed321 db/update/Service: use EventLoop::IsInside()
Don't use the global variable "main_thread".
2014-02-04 18:54:45 +01:00
Max Kellermann
cf6281a5a7 Instance: add Database attribute
Move from db/DatabaseGlue.cxx, eliminating global variable.
2014-02-04 11:22:33 +01:00
Max Kellermann
c953904343 db/update/Service: initialize "progress" and "update_task_id"
Database update was randomly broken due to these uninitialized
variables.
2014-02-04 11:22:13 +01:00
Max Kellermann
d76b6f878e db/update/Service: add SimpleDatabase reference
Don't use the global variables from the DatabaseSimple library.
2014-02-04 09:05:32 +01:00
Max Kellermann
f25ef8d682 db/update/Walk: add Directory reference parameter
Remove dependency on the DatabaseSimple library.
2014-02-04 09:05:32 +01:00
Max Kellermann
33a2c01ea2 db/Simple: remove unused function db_get_directory() 2014-02-04 09:03:17 +01:00
Max Kellermann
29072797ca db/DatabasePlaylist: pass Database reference around
Reduce global variable usage, move to frontend code.
2014-02-04 00:57:43 +01:00
Max Kellermann
db69ceade6 db/LightSong: make "real_uri" a pointer
Reduce overhead.  LightSong can always point to the "real" allocated
string.
2014-02-04 00:38:52 +01:00
Max Kellermann
78689645dc db/update/Archive: delete archive from database on error 2014-01-31 22:24:28 +01:00
Max Kellermann
26970579b8 db/update/Editor: add locking method variants 2014-01-31 22:17:49 +01:00
Max Kellermann
04b4f53488 db/update: convert runtime check to assertion 2014-01-31 21:59:35 +01:00
Max Kellermann
a631200cca update/Walk: declare std::string at assignment
Reduce overhead.
2014-01-30 22:19:56 +01:00
Max Kellermann
c6725884bc db/update: convert to OO API
Move global variables into the new classes.  That may allow multiple
update threads for multiple databases one day.
2014-01-30 18:47:05 +01:00
Max Kellermann
d5b017407d ExcludeList: move to db/update/ 2014-01-30 10:11:12 +01:00
Max Kellermann
4b044bd8e1 InotifyUpdate: pass EventLoop to mpd_inotify_init() 2014-01-29 18:36:32 +01:00
Max Kellermann
a137f817f5 db/Directory: move isRootDirectory() to Uri.hxx
Decouple command/OtherCommands.cxx from the "simple" database plugin.
2014-01-29 18:05:33 +01:00
Max Kellermann
f548a966f5 Playlist{Info,Vector}: move to db/ 2014-01-27 11:05:21 +01:00
Max Kellermann
3dad837ca6 db/upnp: remove sleep(2) call
This call was unnecessary.  It is a bad idea anyway to block the MPD
process for some arbitrary amount of time.
2014-01-26 15:50:30 +01:00
Max Kellermann
d7e78059b0 upnp: initialize the client handle only once
Eliminate class LibUPnP and move the code to ClientInit.cxx.  Its
initialization function can be called multiple times, but
UpnpRegisterClient() is called at most once.
2014-01-26 15:43:23 +01:00
Max Kellermann
e57e89b9d5 upnp/discovery: use a plain UpnpClient_Handle instead of class LibUPnP 2014-01-26 15:22:33 +01:00
Max Kellermann
f86f5ad224 db/upnp: move generic code to lib/upnp/ 2014-01-26 13:41:40 +01:00
Max Kellermann
4a3dc2cea2 db/upnp: rename variables 2014-01-26 13:08:52 +01:00
Max Kellermann
97391fd4b9 DespotifyUtils, Expat: move to lib/ 2014-01-24 16:44:36 +01:00
Max Kellermann
9d34fc394c Database*: move to db/ 2014-01-24 16:38:44 +01:00
Max Kellermann
197b503f3e Config*: move to config/ 2014-01-24 00:20:01 +01:00
Max Kellermann
b8e382b011 db/upnp/Discovery: use std::list instead of std::map
There will only be very few items, and that does not justify the bloat
of std::map.
2014-01-23 22:35:22 +01:00
Max Kellermann
c9af358e4b db/upnp/Discovery: move code to LockAdd(), LockRemove() 2014-01-23 22:35:22 +01:00
Max Kellermann
3afcfe3330 db/upnp/Discovery: un-inline the destructor 2014-01-23 22:35:22 +01:00
Max Kellermann
f3f5e2e162 db/upnp: un-inline a few destructors
Reduce bloat.
2014-01-23 21:17:40 +01:00
Max Kellermann
b52d8fbebe db/upnp: strict vpath checks for the "root" directory 2014-01-23 00:40:39 +01:00
Max Kellermann
b61a2c722c db/upnp: move code to VisitObject() 2014-01-23 00:28:27 +01:00
Max Kellermann
c455d2c1de db/upnp: merge two PathTraitsUTF8::Build() calls 2014-01-23 00:25:08 +01:00
Max Kellermann
77070f5ab9 db/upnp: move code to VisitItem() 2014-01-23 00:17:38 +01:00
Max Kellermann
8d5f7160ac db/upnp: fix subdirectory paths in "listallinfo"
Add missing server name prefix.
2014-01-23 00:07:35 +01:00
Max Kellermann
b167ce2913 base_uri 2014-01-23 00:06:17 +01:00
Max Kellermann
3ac15ca8d1 db/upnp: pass char* to visitSong()
Don't use std::string, reduce bloat.
2014-01-23 00:06:03 +01:00
Max Kellermann
f703d4fc3e db/upnp: call VisitDirectory on servers, even in recursive mode 2014-01-22 23:52:08 +01:00
Max Kellermann
77c461fed7 db/upnp: make several methods "const" 2014-01-22 23:50:33 +01:00
Max Kellermann
a89c21b06a db/upnp: inline Configure() 2014-01-22 23:30:53 +01:00
Max Kellermann
b74aa6b14c db/upnp: don't duplicate song data for VisitSong
Not necessary because we control the LightSong's life cycle.
2014-01-22 23:28:23 +01:00
Max Kellermann
0c4a791111 db/upnp: emplace/move in csvToStrings() 2014-01-22 23:21:23 +01:00
Max Kellermann
1feedd4d9c db/upnp: require an empty token list in csvToStrings() 2014-01-22 23:21:14 +01:00
Max Kellermann
0ec1808956 db/proxy: simplify csvToStrings() 2014-01-22 23:17:42 +01:00
Max Kellermann
546e7cafa4 db/proxy: merge redundant string::push_back() calls 2014-01-22 23:13:24 +01:00
Max Kellermann
d9926a1c21 db/upnp: use PathTraitsUTF8::Build() 2014-01-22 23:10:00 +01:00
Max Kellermann
e50969e31c db/proxy: fix for libmpdclient < 2.9 2014-01-22 23:09:36 +01:00
Max Kellermann
a6d9998e1d db/proxy: copy "Last-Modified" from remote directories 2014-01-22 23:07:21 +01:00
Max Kellermann
a42f9e4ee3 LightDirectory: new struct replacing Directory in the DB API 2014-01-22 23:01:32 +01:00
Max Kellermann
4943606f4a db/upnp: append characters instead of single-character strings 2014-01-22 21:55:58 +01:00
Max Kellermann
87629dda81 db/upnp: use string::push_back() instead of string::append() 2014-01-22 21:55:08 +01:00
Max Kellermann
71928b473e db/upnp/Discovery: unlock mutex before deleting DiscoveredTask 2014-01-22 21:48:33 +01:00
Max Kellermann
a0bee9fa0a db/upnp/Discovery: eliminate two strlen() calls 2014-01-22 21:47:34 +01:00
Max Kellermann
0defd927f3 db/upnp: use std::list instead of std::set for SearchCapabilities
Reduce bloat.  We never used the set lookup.
2014-01-22 21:41:05 +01:00
Max Kellermann
6c41e8f63f db/upnp: check offset<total at end of loop 2014-01-22 21:37:21 +01:00
Max Kellermann
fa67a4e956 db/upnp: break when zero objects have been returned 2014-01-22 21:37:19 +01:00
Max Kellermann
bf9352fb26 db/upnp: free responses manually 2014-01-22 21:33:54 +01:00
Max Kellermann
7573d4e1ba db/upnp: break when count==0
Make this non-fatal.  Just stop reading more objects.
2014-01-22 21:33:19 +01:00
Max Kellermann
bfb483898f db/upnp: use ParseUnsigned() instead of atoi() 2014-01-22 21:11:04 +01:00
Max Kellermann
f363788d76 db/upnp: pass unsigned integers to readDirSlice() 2014-01-22 20:57:10 +01:00
Max Kellermann
714056f157 db/upnp: inline ContentDirectoryService::readDirSlice() 2014-01-22 20:42:36 +01:00
Max Kellermann
1abc96fa27 db/upnp: remove special case for "*"
Passing this to csvToStrings() will do the same.
2014-01-22 20:37:17 +01:00
Max Kellermann
0fa98479ad db/upnp: obtain char* from ixmlwrap::getFirstElementValue()
Fixes crash when there's no SearchCaps element.
2014-01-22 20:26:33 +01:00
Max Kellermann
02f2171010 db/upnp/Util: pass char* to csvToStrings() 2014-01-22 20:24:55 +01:00
Max Kellermann
a5e7d0a90f db/upnp: require an empty input capability set 2014-01-22 20:21:01 +01:00
Max Kellermann
9fb5134f64 db/upnp/Util: handle absolute URI paths properly in caturl()
Fixes problems with some UPnP servers.
2014-01-22 19:38:07 +01:00
Max Kellermann
9aeb23dfe9 db/upnp/Util: use string::back(), string::front() 2014-01-22 19:38:02 +01:00
Max Kellermann
e59d8c9378 db/upnp/Device: clear the "value" pointer on unknown element
Avoid appending to an obsolete string object.
2014-01-22 19:38:02 +01:00
Max Kellermann
9747cc9e58 db/upnp/Device: replace std::vector with a std::string pointer 2014-01-22 09:55:51 +01:00
Max Kellermann
7b44dea4b1 db/upnp/Device: remove unused UPnPService attributes 2014-01-22 09:51:26 +01:00
Max Kellermann
18aea922e9 db/upnp/Directory: "emplace" items into the vector 2014-01-22 09:43:49 +01:00
Max Kellermann
7d194aceb6 db/upnp/Device: emplace/move the UPnPService into the vector
Reduce overhead.
2014-01-22 09:42:46 +01:00
Max Kellermann
2722b8a3df db/upnp/Util: "emplace" items into the list
Reduce overhead.
2014-01-22 09:40:38 +01:00
Max Kellermann
fd754ff8f8 db/upnp/Directory: replace std::vector with a simple enum
Reduce bloat.
2014-01-22 09:32:11 +01:00
Max Kellermann
b7738e7af3 db/upnp/Directory: join all CDATA nodes for tag values
Expat can call CharacterData() multiple times if the CDATA contains
entity references.  We need to collect all of them in one large
string.
2014-01-22 08:44:35 +01:00
Max Kellermann
99bebabac9 db/upnp/Directory: make "m_dir" private 2014-01-22 08:44:20 +01:00
Max Kellermann
0ed48b364a db/upnp: merge duplicate branches in Namei() 2014-01-21 23:42:02 +01:00
Max Kellermann
b38b8b9c18 db/upnp: simplify Namei() 2014-01-21 23:37:27 +01:00
Max Kellermann
5434856136 db/upnp: use std::list instead of std::vector
Reduce overhead.
2014-01-21 23:33:28 +01:00
Max Kellermann
aa1eb2f40d db/upnp: use iterator in Namei() 2014-01-21 23:32:42 +01:00
Max Kellermann
7260d7883c db/upnp: move "objid" declaration down
Don't allocate the object when it's not needed.
2014-01-21 23:10:30 +01:00
Max Kellermann
154250f551 db/upnp: eliminate redundant Namei() parameter "oobjid"
The caller should better obtain the object id from the returned
UPnPDirObject instance.
2014-01-21 23:07:33 +01:00
Max Kellermann
3e4fb92cfb db/upnp: remove redundant objid.empty() check from VisitServer()
If Namei() succeeds, the object id is guaranteed to be set.
2014-01-21 23:07:06 +01:00
Max Kellermann
0da713e278 db/upnp: use std::move() to extract server name
Reduce runtime overhead.
2014-01-21 22:57:54 +01:00
Max Kellermann
94cb1545b3 db/upnp: use vector::front() instead of [0] 2014-01-21 22:57:16 +01:00
Max Kellermann
411527a240 db/upnp: don't use stringToTokens() in ParseDuration()
Reduce bloat.
2014-01-21 22:52:12 +01:00
Max Kellermann
7777057d35 db/upnp: don't construct redundant empty vector<string> in Visit()
We know already that vpath is empty, let's use this instance.
2014-01-21 22:47:57 +01:00
Max Kellermann
dc5ef9ad01 db/upnp: simplify GetSong() 2014-01-21 22:43:04 +01:00
Max Kellermann
7471f65d95 LightSong: add attribute "real_uri"
The UPnP database plugin can now show relative song URIs for remote
songs.
2014-01-21 21:08:11 +01:00
Max Kellermann
ecac7a629e db/upnp: fix empty song URI
Fall back to UPnPDirObject::url if there is no override.
2014-01-21 21:02:21 +01:00
Max Kellermann
f5ae1ce00b LightSong: new class to be used by DatabasePlugin callbacks
Detach the Song class completely from the public API, only to be used
by SimpleDatabase and the update thread.
2014-01-19 17:04:51 +01:00
Max Kellermann
738d6f1040 db/proxy: simplify error handling in GetSong()
Check mpd_response_finish() before using mpd_song.  Don't skip this
check even if the mpd_song is non-nullptr.
2014-01-19 11:37:42 +01:00
Max Kellermann
ba372197fb db/simple: make borrowed_song_count "mutable"
Simpler to use than const_cast.
2014-01-19 11:23:02 +01:00
Max Kellermann
d2cf74027c Song: embed the Tag object statically into class Song
Reduces overhead because we need to manage only one memory allocation.
According to valgrind/massif, we save 7%.
2014-01-19 02:58:55 +01:00
Max Kellermann
fdf4dff561 db/upnp: move Tag from UPnPDirObject to Song
The UPnPDirObject is a temporary object, we can move its contents.
This reduces runtime overhead.
2014-01-18 19:09:42 +01:00
Max Kellermann
fab6cbed75 db/upnp/Discovery: eliminate attribute "last_seen" 2014-01-18 16:28:12 +01:00
Max Kellermann
051eede1ed db/upnp/Discovery: use monotonic clock instead of time() 2014-01-18 16:26:11 +01:00
Max Kellermann
0696cac50b db/upnp/Discovery: eliminate full copy in getServer() 2014-01-18 16:18:51 +01:00
Max Kellermann
0c2485e86c db/upnp: use getServer() in Visit()
Reduce bloat.
2014-01-18 16:13:33 +01:00
Max Kellermann
7d696a7063 db/upnp/Discovery: eliminate Error attribute
Move code to method Start() and add Error& parameters to several
methods.
2014-01-18 16:08:30 +01:00
Max Kellermann
53573e950f db/upnp: remove unnecessary m_superdir nullptr checks 2014-01-18 16:02:21 +01:00
Max Kellermann
1e99983263 db/upnp: pass ContentDirectoryService references 2014-01-18 15:58:02 +01:00
Max Kellermann
5409e43fb5 db/upnp: cache m_path.back() 2014-01-18 15:44:41 +01:00
Max Kellermann
f33f891c54 db/upnp: add UpnpMakeAction() helper function 2014-01-18 15:27:54 +01:00
Max Kellermann
6e55552292 db/upnp/ixmlwrap: getFirstElementValue() returns const char *
Eliminate the std::string bloat.
2014-01-18 15:01:19 +01:00
Max Kellermann
e569f82dd3 db/upnp: merge duplicate nullptr check 2014-01-18 14:44:06 +01:00
Max Kellermann
1a4940bbda db/upnp: free IXML_Document *request manually 2014-01-18 14:38:52 +01:00
Max Kellermann
22dd3c8048 db/upnp/Device: move code to method Parse()
Forward the Error to the caller.
2014-01-18 14:29:31 +01:00
Max Kellermann
04b7648e00 db/upnp/Device: use ContentDirectoryDescriptor's move operator
Reduce bloat.
2014-01-18 14:26:24 +01:00
Max Kellermann
be0759d465 db/upnp/Discovery: don't copy XML to std::string
Pass "const char *" to Expat.
2014-01-18 14:24:38 +01:00
Max Kellermann
339d939873 db/upnp/Discovery: fix memory leak 2014-01-18 14:03:18 +01:00
Max Kellermann
c1950e40e6 db/upnp: remove unused typedef DevServIt 2014-01-18 13:42:54 +01:00
Max Kellermann
ad76bad8fd db/upnp: use move operator to assign XML CDATA
Reduce runtime bloat.
2014-01-18 13:39:31 +01:00
Max Kellermann
55737e4ff6 db/upnp/Util: trimstring() constructs string from buffer
Reduce overhead by omitting the part of the buffer that consists only
of whitespace.
2014-01-18 13:36:50 +01:00
Max Kellermann
f3b4ddee6c db/upnp/Discovery: free the response body
Memory leak.
2014-01-18 13:08:48 +01:00