Merge pull request #4857 from t-nelson/Gotham_13.2_backports
[vuplus_xbmc] / xbmc / filesystem / MusicSearchDirectory.cpp
1 /*
2  *      Copyright (C) 2005-2013 Team XBMC
3  *      http://xbmc.org
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with XBMC; see the file COPYING.  If not, see
17  *  <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 #include "threads/SystemClock.h"
22 #include "MusicSearchDirectory.h"
23 #include "music/MusicDatabase.h"
24 #include "URL.h"
25 #include "FileItem.h"
26 #include "utils/log.h"
27 #include "utils/TimeUtils.h"
28 #include "guilib/LocalizeStrings.h"
29
30 using namespace XFILE;
31
32 CMusicSearchDirectory::CMusicSearchDirectory(void)
33 {
34 }
35
36 CMusicSearchDirectory::~CMusicSearchDirectory(void)
37 {
38 }
39
40 bool CMusicSearchDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
41 {
42   // break up our path
43   // format is:  musicsearch://<url encoded search string>
44   CURL url(strPath);
45   CStdString search(url.GetHostName());
46
47   if (search.empty())
48     return false;
49
50   // and retrieve the search details
51   items.SetPath(strPath);
52   unsigned int time = XbmcThreads::SystemClockMillis();
53   CMusicDatabase db;
54   db.Open();
55   db.Search(search, items);
56   db.Close();
57   CLog::Log(LOGDEBUG, "%s (%s) took %u ms",
58             __FUNCTION__, strPath.c_str(), XbmcThreads::SystemClockMillis() - time);
59   items.SetLabel(g_localizeStrings.Get(137)); // Search
60   return true;
61 }
62
63 bool CMusicSearchDirectory::Exists(const char* strPath)
64 {
65   return true;
66 }