xbmc
IDirectory.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "utils/Variant.h"
12 
13 #include <string>
14 
15 class CFileItemList;
16 class CProfileManager;
17 class CURL;
18 
19 namespace XFILE
20 {
21  enum DIR_CACHE_TYPE
22  {
23  DIR_CACHE_NEVER = 0,
24  DIR_CACHE_ONCE,
25  DIR_CACHE_ALWAYS
26  };
27 
32  enum DIR_FLAG
33  {
34  DIR_FLAG_DEFAULTS = 0,
35  DIR_FLAG_NO_FILE_DIRS = (2 << 0),
36  DIR_FLAG_ALLOW_PROMPT = (2 << 1),
37  DIR_FLAG_NO_FILE_INFO = (2 << 2),
38  DIR_FLAG_GET_HIDDEN = (2 << 3),
39  DIR_FLAG_READ_CACHE = (2 << 4),
40  DIR_FLAG_BYPASS_CACHE = (2 << 5)
41  };
51 {
52 public:
53  static void RegisterProfileManager(const CProfileManager &profileManager);
54  static void UnregisterProfileManager();
55 
56  IDirectory();
57  virtual ~IDirectory(void);
65  virtual bool GetDirectory(const CURL& url, CFileItemList &items) = 0;
71  virtual float GetProgress() const { return 0.0f; }
76  virtual void CancelDirectory() {}
83  virtual bool Create(const CURL& url) { return false; }
90  virtual bool Exists(const CURL& url) { return false; }
96  virtual bool Remove(const CURL& url) { return false; }
97 
103  virtual bool RemoveRecursive(const CURL& url) { return false; }
104 
110  virtual bool IsAllowed(const CURL& url) const;
111 
115  virtual bool AllowAll() const { return false; }
116 
122  virtual DIR_CACHE_TYPE GetCacheType(const CURL& url) const { return DIR_CACHE_ONCE; }
123 
124  void SetMask(const std::string& strMask);
125  void SetFlags(int flags);
126 
134  bool ProcessRequirements();
135 
136 protected:
146  bool GetKeyboardInput(const CVariant &heading, std::string &input, bool hiddenInput = false);
147 
156  void SetErrorDialog(const CVariant &heading, const CVariant &line1, const CVariant &line2 = 0, const CVariant &line3 = 0);
157 
165  void RequireAuthentication(const CURL& url);
166 
167  static const CProfileManager *m_profileManager;
168 
169  std::string m_strFileMask;
170 
171  int m_flags;
172 
173  CVariant m_requirements;
174 };
175 }
virtual bool Create(const CURL &url)
Create the directory.
Definition: IDirectory.h:83
virtual bool RemoveRecursive(const CURL &url)
Recursively removes the directory.
Definition: IDirectory.h:103
Interface to the directory on a file system.
Definition: IDirectory.h:50
virtual bool Remove(const CURL &url)
Removes the directory.
Definition: IDirectory.h:96
Definition: Scraper.h:41
virtual bool Exists(const CURL &url)
Check for directory existence.
Definition: IDirectory.h:90
Represents a list of files.
Definition: FileItem.h:713
Definition: URL.h:20
virtual float GetProgress() const
Retrieve the progress of the current directory fetch (if possible).
Definition: IDirectory.h:71
bool GetKeyboardInput(const CVariant &heading, std::string &input, bool hiddenInput=false)
Prompt the user for some keyboard input Call this method from the GetDirectory method to retrieve add...
Definition: IDirectory.cpp:148
Definition: Variant.h:29
virtual bool IsAllowed(const CURL &url) const
Whether this file should be listed.
Definition: IDirectory.cpp:48
virtual void CancelDirectory()
Cancel the current directory fetch (if possible).
Definition: IDirectory.h:76
std::string m_strFileMask
Holds the file mask specified by SetMask()
Definition: IDirectory.h:169
void RequireAuthentication(const CURL &url)
Prompt the user for authentication of a URL. Call this method from the GetDirectory method when authe...
Definition: IDirectory.cpp:172
int m_flags
Directory flags - see DIR_FLAG.
Definition: IDirectory.h:171
bool ProcessRequirements()
Process additional requirements before the directory fetch is performed. Some directory fetches may r...
Definition: IDirectory.cpp:119
void SetMask(const std::string &strMask)
Set a mask of extensions for the files in the directory.
Definition: IDirectory.cpp:101
void SetFlags(int flags)
Set the flags for this directory handler.
Definition: IDirectory.cpp:114
Definition: ProfileManager.h:25
virtual bool GetDirectory(const CURL &url, CFileItemList &items)=0
Get the items of the directory strPath.
virtual bool AllowAll() const
Whether to allow all files/folders to be listed.
Definition: IDirectory.h:115
virtual DIR_CACHE_TYPE GetCacheType(const CURL &url) const
How this directory should be cached.
Definition: IDirectory.h:122
void SetErrorDialog(const CVariant &heading, const CVariant &line1, const CVariant &line2=0, const CVariant &line3=0)
Show an error dialog on failure of GetDirectory call Call this method from the GetDirectory method to...
Definition: IDirectory.cpp:162