Merge pull request #4594 from FernetMenta/paplayer
[xbmc.git] / xbmc / filesystem / PluginDirectory.h
blob35cd2276cd251451ced0c216f15c77bfcfaea2f8
1 #pragma once
2 /*
3 * Copyright (C) 2005-2013 Team XBMC
4 * http://xbmc.org
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with XBMC; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
22 #include "IDirectory.h"
23 #include "Directory.h"
24 #include "utils/StdString.h"
25 #include "SortFileItem.h"
27 #include <string>
28 #include <map>
29 #include "threads/CriticalSection.h"
30 #include "addons/IAddon.h"
31 #include "PlatformDefs.h"
33 #include "threads/Event.h"
35 class CURL;
36 class CFileItem;
37 class CFileItemList;
39 namespace XFILE
42 class CPluginDirectory : public IDirectory
44 public:
45 CPluginDirectory();
46 ~CPluginDirectory(void);
47 virtual bool GetDirectory(const CStdString& strPath, CFileItemList& items);
48 virtual bool IsAllowed(const CStdString &strFile) const { return true; };
49 virtual bool Exists(const char* strPath) { return true; }
50 virtual float GetProgress() const;
51 virtual void CancelDirectory();
52 static bool RunScriptWithParams(const CStdString& strPath);
53 static bool GetPluginResult(const CStdString& strPath, CFileItem &resultItem);
55 // callbacks from python
56 static bool AddItem(int handle, const CFileItem *item, int totalItems);
57 static bool AddItems(int handle, const CFileItemList *items, int totalItems);
58 static void EndOfDirectory(int handle, bool success, bool replaceListing, bool cacheToDisc);
59 static void AddSortMethod(int handle, SORT_METHOD sortMethod, const CStdString &label2Mask);
60 static CStdString GetSetting(int handle, const CStdString &key);
61 static void SetSetting(int handle, const CStdString &key, const CStdString &value);
62 static void SetContent(int handle, const CStdString &strContent);
63 static void SetProperty(int handle, const CStdString &strProperty, const CStdString &strValue);
64 static void SetResolvedUrl(int handle, bool success, const CFileItem* resultItem);
65 static void SetLabel2(int handle, const CStdString& ident);
67 private:
68 ADDON::AddonPtr m_addon;
69 bool StartScript(const CStdString& strPath, bool retrievingDir);
70 bool WaitOnScriptResult(const CStdString &scriptPath, int scriptId, const CStdString &scriptName, bool retrievingDir);
72 static std::map<int,CPluginDirectory*> globalHandles;
73 static int getNewHandle(CPluginDirectory *cp);
74 static void removeHandle(int handle);
75 static CPluginDirectory *dirFromHandle(int handle);
76 static CCriticalSection m_handleLock;
77 static int handleCounter;
79 CFileItemList* m_listItems;
80 CFileItem* m_fileResult;
81 CEvent m_fetchComplete;
83 bool m_cancelled; // set to true when we are cancelled
84 bool m_success; // set by script in EndOfDirectory
85 int m_totalItems; // set by script in AddDirectoryItem