]> git.mxchange.org Git - simgear.git/blob - simgear/io/SVNDirectory.hxx
SVN read-only client code using our HTTP engine.
[simgear.git] / simgear / io / SVNDirectory.hxx
1 // DAVCollectionMirror.hxx - mirror a DAV collection to the local filesystem
2 //
3 // Copyright (C) 2013  James Turner <zakalawe@mac.com>
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License as
7 // published by the Free Software Foundation; either version 2 of the
8 // License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful, but
11 // WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18
19
20 #ifndef SG_IO_DAVCOLLECTIONMIRROR_HXX
21 #define SG_IO_DAVCOLLECTIONMIRROR_HXX
22
23 #include <string>
24 #include <vector>
25 #include <memory>
26
27 #include <simgear/misc/sg_path.hxx>
28 #include <simgear/misc/strutils.hxx>
29 #include <simgear/io/DAVMultiStatus.hxx>
30
31 namespace simgear  {
32
33 class Dir;
34 namespace HTTP { class Request; }
35
36 // forward decls
37 class DAVMirror;
38 class SVNRepository;
39 class SVNDirectory;
40
41 typedef std::vector<SVNDirectory*> DirectoryList;
42
43 class SVNDirectory
44 {
45 public:
46   // init from local
47   SVNDirectory(SVNRepository *repo, const SGPath& path);
48   ~SVNDirectory();
49   
50   void setBaseUrl(const std::string& url);
51   
52   // init from a collection
53   SVNDirectory(SVNDirectory* pr, DAVCollection* col);
54   
55 //  void update();
56  // void gotResource(HTTP::Request* get, const std::string& etag);
57   void requestFailed(HTTP::Request* req);
58   
59   void beginUpdateReport();
60   void updateReportComplete();
61   
62   bool isDoingSync() const;
63   
64   std::string url() const;
65   
66   std::string name() const;
67       
68   DAVResource* addChildFile(const std::string& fileName);
69   SVNDirectory* addChildDirectory(const std::string& dirName);
70       
71  // void updateChild(DAVResource* child);
72   void deleteChildByName(const std::string& name);
73   
74   SGPath fsPath() const
75     { return localPath; }
76   
77   simgear::Dir fsDir() const;
78   
79   std::string repoPath() const;
80     
81   SVNRepository* repository() const;
82   DAVCollection* collection() const
83     { return dav; }
84   
85   std::string cachedRevision() const
86       { return _cachedRevision; }
87   
88   void mergeUpdateReportDetails(unsigned int depth, string_list& items);
89   
90   SVNDirectory* parent() const;
91   SVNDirectory* child(const std::string& dirName) const;
92 private:
93   
94   void parseCache();
95   void writeCache();
96   
97   DirectoryList::iterator findChildDir(const std::string& dirName);
98       
99   SGPath localPath;
100   DAVCollection* dav;
101   SVNRepository* repo;
102   
103   std::string _cachedRevision;
104   bool _doingUpdateReport;
105   
106   SVNDirectory* _parent;
107   DirectoryList _children;
108 };
109
110 } // of namespace simgear
111
112 #endif // of SG_IO_DAVCOLLECTIONMIRROR_HXX