diff options
Diffstat (limited to '')
-rw-r--r-- | src/db/LazyDatabase.cxx | 2 | ||||
-rw-r--r-- | src/db/LazyDatabase.hxx | 2 | ||||
-rw-r--r-- | src/db/ProxyDatabasePlugin.cxx | 2 | ||||
-rw-r--r-- | src/db/ProxyDatabasePlugin.hxx | 2 | ||||
-rw-r--r-- | src/db/SimpleDatabasePlugin.cxx | 2 | ||||
-rw-r--r-- | src/db/SimpleDatabasePlugin.hxx | 2 | ||||
-rw-r--r-- | src/db/UpnpDatabasePlugin.cxx | 9 | ||||
-rw-r--r-- | src/db/UpnpDatabasePlugin.hxx | 2 | ||||
-rw-r--r-- | src/db/upnp/Directory.cxx | 14 | ||||
-rw-r--r-- | src/db/upnp/Discovery.cxx | 14 | ||||
-rw-r--r-- | src/db/upnp/Domain.cxx | 2 | ||||
-rw-r--r-- | src/db/upnp/Domain.hxx | 2 | ||||
-rw-r--r-- | src/db/upnp/upnpplib.cxx | 16 | ||||
-rw-r--r-- | src/db/upnp/upnpplib.hxx | 21 |
14 files changed, 43 insertions, 49 deletions
diff --git a/src/db/LazyDatabase.cxx b/src/db/LazyDatabase.cxx index f767e89cd..0718c3dcd 100644 --- a/src/db/LazyDatabase.cxx +++ b/src/db/LazyDatabase.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/db/LazyDatabase.hxx b/src/db/LazyDatabase.hxx index 3910cb7fa..7f97aa40d 100644 --- a/src/db/LazyDatabase.hxx +++ b/src/db/LazyDatabase.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/db/ProxyDatabasePlugin.cxx b/src/db/ProxyDatabasePlugin.cxx index 7e8dcf65f..9f4d3d31c 100644 --- a/src/db/ProxyDatabasePlugin.cxx +++ b/src/db/ProxyDatabasePlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/db/ProxyDatabasePlugin.hxx b/src/db/ProxyDatabasePlugin.hxx index 576c01c69..699d374b5 100644 --- a/src/db/ProxyDatabasePlugin.hxx +++ b/src/db/ProxyDatabasePlugin.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/db/SimpleDatabasePlugin.cxx b/src/db/SimpleDatabasePlugin.cxx index 31d4213a5..9b17ada29 100644 --- a/src/db/SimpleDatabasePlugin.cxx +++ b/src/db/SimpleDatabasePlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/db/SimpleDatabasePlugin.hxx b/src/db/SimpleDatabasePlugin.hxx index 98cbb96f0..5145c0bc8 100644 --- a/src/db/SimpleDatabasePlugin.hxx +++ b/src/db/SimpleDatabasePlugin.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/db/UpnpDatabasePlugin.cxx b/src/db/UpnpDatabasePlugin.cxx index 68a24cb4f..19a27d994 100644 --- a/src/db/UpnpDatabasePlugin.cxx +++ b/src/db/UpnpDatabasePlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2012 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -829,8 +829,13 @@ UpnpDatabase::VisitUniqueTags(const DatabaseSelection &selection, for (auto &dirent : dirbuf.m_items) { std::string tagvalue; - if (getTagValue(dirent, tag, tagvalue)) + if (getTagValue(dirent, tag, tagvalue)) { +#if defined(__clang__) || GCC_CHECK_VERSION(4,8) values.emplace(std::move(tagvalue)); +#else + values.insert(std::move(tagvalue)); +#endif + } } } diff --git a/src/db/UpnpDatabasePlugin.hxx b/src/db/UpnpDatabasePlugin.hxx index 7fe2dde60..0228405cd 100644 --- a/src/db/UpnpDatabasePlugin.hxx +++ b/src/db/UpnpDatabasePlugin.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2011 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/db/upnp/Directory.cxx b/src/db/upnp/Directory.cxx index a42719e4d..3b75eceda 100644 --- a/src/db/upnp/Directory.cxx +++ b/src/db/upnp/Directory.cxx @@ -104,12 +104,6 @@ protected: const char *pid = GetAttribute(attrs, "parentID"); if (pid != nullptr) m_tobj.m_pid = pid; - - const char *item_class_name = - GetAttribute(attrs, "upnp:class"); - if (item_class_name != nullptr) - m_tobj.item_class = - ParseItemClass(item_class_name); } break; @@ -132,7 +126,8 @@ protected: bool checkobjok() { if (m_tobj.m_id.empty() || m_tobj.m_pid.empty() || m_tobj.m_title.empty() || - m_tobj.item_class == UPnPDirObject::ItemClass::UNKNOWN) + (m_tobj.type == UPnPDirObject::Type::ITEM && + m_tobj.item_class == UPnPDirObject::ItemClass::UNKNOWN)) return false; return true; @@ -168,6 +163,11 @@ protected: } break; case 'u': + if (m_path.back() == "upnp:class") { + m_tobj.item_class = ParseItemClass(str.c_str()); + break; + } + for (auto i = upnptags; *i != nullptr; ++i) if (!m_path.back().compare(*i)) m_tobj.m_props[*i] += str; diff --git a/src/db/upnp/Discovery.cxx b/src/db/upnp/Discovery.cxx index a94f29d8c..23705271d 100644 --- a/src/db/upnp/Discovery.cxx +++ b/src/db/upnp/Discovery.cxx @@ -142,7 +142,11 @@ discoExplorer(void *) continue; } +#if defined(__clang__) || GCC_CHECK_VERSION(4,8) auto e = contentDirectories.m_directories.emplace(tsk->deviceId, d); +#else + auto e = contentDirectories.m_directories.insert(std::make_pair(tsk->deviceId, d)); +#endif if (!e.second) e.first->second = d; } @@ -158,7 +162,7 @@ discoExplorer(void *) // mutex just for clarifying the message printing, the workqueue is // mt-safe of course. static int -cluCallBack(Upnp_EventType et, void *evp, void *) +cluCallBack(Upnp_EventType et, void *evp) { static Mutex cblock; const ScopeLock protect(cblock); @@ -231,11 +235,9 @@ UPnPDeviceDirectory::UPnPDeviceDirectory() if (lib == nullptr) return; - lib->registerHandler(UPNP_DISCOVERY_SEARCH_RESULT, cluCallBack, this); - lib->registerHandler(UPNP_DISCOVERY_ADVERTISEMENT_ALIVE, - cluCallBack, this); - lib->registerHandler(UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE, - cluCallBack, this); + lib->SetHandler([](Upnp_EventType type, void *event){ + cluCallBack(type, event); + }); search(); } diff --git a/src/db/upnp/Domain.cxx b/src/db/upnp/Domain.cxx index 12984bd19..010d4c7c2 100644 --- a/src/db/upnp/Domain.cxx +++ b/src/db/upnp/Domain.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/db/upnp/Domain.hxx b/src/db/upnp/Domain.hxx index e249aa5dc..ec01ef735 100644 --- a/src/db/upnp/Domain.hxx +++ b/src/db/upnp/Domain.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/db/upnp/upnpplib.cxx b/src/db/upnp/upnpplib.cxx index d7c65ccf4..508315b26 100644 --- a/src/db/upnp/upnpplib.cxx +++ b/src/db/upnp/upnpplib.cxx @@ -65,15 +65,6 @@ LibUPnP::LibUPnP() ixmlRelaxParser(1); } -void -LibUPnP::registerHandler(Upnp_EventType et, Upnp_FunPtr handler, void *cookie) -{ - if (handler == nullptr) - m_handlers.erase(et); - else - m_handlers.emplace(et, Handler(handler, cookie)); -} - int LibUPnP::o_callback(Upnp_EventType et, void* evp, void* cookie) { @@ -83,10 +74,9 @@ LibUPnP::o_callback(Upnp_EventType et, void* evp, void* cookie) ulib = theLib; } - auto it = ulib->m_handlers.find(et); - if (it != ulib->m_handlers.end()) { - (it->second.handler)(et, evp, it->second.cookie); - } + if (ulib->handler) + ulib->handler(et, evp); + return UPNP_E_SUCCESS; } diff --git a/src/db/upnp/upnpplib.hxx b/src/db/upnp/upnpplib.hxx index b6ce80212..c1443624c 100644 --- a/src/db/upnp/upnpplib.hxx +++ b/src/db/upnp/upnpplib.hxx @@ -22,24 +22,18 @@ #include "util/Error.hxx" -#include <map> - #include <upnp/upnp.h> +#include <functional> + /** Our link to libupnp. Initialize and keep the handle around */ class LibUPnP { - // A Handler object records the data from registerHandler. - class Handler { - public: - Handler(Upnp_FunPtr h, void *c) - : handler(h), cookie(c) {} - Upnp_FunPtr handler; - void *cookie; - }; + typedef std::function<void(Upnp_EventType type, void *event)> Handler; Error init_error; UpnpClient_Handle m_clh; - std::map<Upnp_EventType, Handler> m_handlers; + + Handler handler; LibUPnP(); @@ -65,7 +59,10 @@ public: return init_error; } - void registerHandler(Upnp_EventType et, Upnp_FunPtr handler, void *cookie); + template<typename T> + void SetHandler(T &&_handler) { + handler = std::forward<T>(_handler); + } UpnpClient_Handle getclh() { |