Merge pull request #5070 from Memphiz/osx_fix_devicechanged_recursionbp
[vuplus_xbmc] / xbmc / URL.h
1 #pragma once
2 /*
3  *      Copyright (C) 2005-2013 Team XBMC
4  *      http://xbmc.org
5  *
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.
10  *
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.
15  *
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/>.
19  *
20  */
21
22 #include "utils/StdString.h"
23 #include "utils/UrlOptions.h"
24
25 #ifdef TARGET_WINDOWS
26 #undef SetPort // WIN32INCLUDES this is defined as SetPortA in WinSpool.h which is being included _somewhere_
27 #endif
28
29 class CURL
30 {
31 public:
32   CURL(const CStdString& strURL);
33   CURL();
34   virtual ~CURL(void);
35
36   void Reset();
37   void Parse(const CStdString& strURL);
38   void SetFileName(const CStdString& strFileName);
39   void SetHostName(const CStdString& strHostName);
40   void SetUserName(const CStdString& strUserName);
41   void SetPassword(const CStdString& strPassword);
42   void SetProtocol(const CStdString& strProtocol);
43   void SetOptions(const CStdString& strOptions);
44   void SetProtocolOptions(const CStdString& strOptions);
45   void SetPort(int port);
46
47   bool HasPort() const;
48
49   int GetPort() const;
50   const CStdString& GetHostName() const;
51   const CStdString& GetDomain() const;
52   const CStdString& GetUserName() const;
53   const CStdString& GetPassWord() const;
54   const CStdString& GetFileName() const;
55   const CStdString& GetProtocol() const;
56   const CStdString GetTranslatedProtocol() const;
57   const CStdString& GetFileType() const;
58   const CStdString& GetShareName() const;
59   const CStdString& GetOptions() const;
60   const CStdString& GetProtocolOptions() const;
61   const CStdString GetFileNameWithoutPath() const; /* return the filename excluding path */
62
63   char GetDirectorySeparator() const;
64
65   CStdString Get() const;
66   std::string GetWithoutUserDetails(bool redact = false) const;
67   CStdString GetWithoutFilename() const;
68   std::string GetRedacted() const;
69   static std::string GetRedacted(const std::string& path);
70   bool IsLocal() const;
71   bool IsLocalHost() const;
72   static bool IsFileOnly(const CStdString &url); ///< return true if there are no directories in the url.
73   static bool IsFullPath(const CStdString &url); ///< return true if the url includes the full path
74   static std::string Decode(const std::string& strURLData);
75   static std::string Encode(const std::string& strURLData);
76   static CStdString TranslateProtocol(const CStdString& prot);
77
78   void GetOptions(std::map<CStdString, CStdString> &options) const;
79   bool HasOption(const CStdString &key) const;
80   bool GetOption(const CStdString &key, CStdString &value) const;
81   CStdString GetOption(const CStdString &key) const;
82   void SetOption(const CStdString &key, const CStdString &value);
83   void RemoveOption(const CStdString &key);
84
85   void GetProtocolOptions(std::map<CStdString, CStdString> &options) const;
86   bool HasProtocolOption(const CStdString &key) const;
87   bool GetProtocolOption(const CStdString &key, CStdString &value) const;
88   CStdString GetProtocolOption(const CStdString &key) const;
89   void SetProtocolOption(const CStdString &key, const CStdString &value);
90   void RemoveProtocolOption(const CStdString &key);
91
92 protected:
93   int m_iPort;
94   CStdString m_strHostName;
95   CStdString m_strShareName;
96   CStdString m_strDomain;
97   CStdString m_strUserName;
98   CStdString m_strPassword;
99   CStdString m_strFileName;
100   CStdString m_strProtocol;
101   CStdString m_strFileType;
102   CStdString m_strOptions;
103   CStdString m_strProtocolOptions;
104   CUrlOptions m_options;
105   CUrlOptions m_protocolOptions;
106 };