changed: Add logic to properly handle subtitles for stacked files
[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 void Decode(CStdString& strURLData);
75   static void Encode(CStdString& strURLData);
76   static std::string Decode(const std::string& strURLData);
77   static std::string Encode(const std::string& strURLData);
78   static CStdString TranslateProtocol(const CStdString& prot);
79
80   void GetOptions(std::map<CStdString, CStdString> &options) const;
81   bool HasOption(const CStdString &key) const;
82   bool GetOption(const CStdString &key, CStdString &value) const;
83   CStdString GetOption(const CStdString &key) const;
84   void SetOption(const CStdString &key, const CStdString &value);
85   void RemoveOption(const CStdString &key);
86
87   void GetProtocolOptions(std::map<CStdString, CStdString> &options) const;
88   bool HasProtocolOption(const CStdString &key) const;
89   bool GetProtocolOption(const CStdString &key, CStdString &value) const;
90   CStdString GetProtocolOption(const CStdString &key) const;
91   void SetProtocolOption(const CStdString &key, const CStdString &value);
92   void RemoveProtocolOption(const CStdString &key);
93
94 protected:
95   int m_iPort;
96   CStdString m_strHostName;
97   CStdString m_strShareName;
98   CStdString m_strDomain;
99   CStdString m_strUserName;
100   CStdString m_strPassword;
101   CStdString m_strFileName;
102   CStdString m_strProtocol;
103   CStdString m_strFileType;
104   CStdString m_strOptions;
105   CStdString m_strProtocolOptions;
106   CUrlOptions m_options;
107   CUrlOptions m_protocolOptions;
108 };