[release] version bump to 13.0 beta1
[vuplus_xbmc] / xbmc / addons / Repository.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 "Addon.h"
23 #include "utils/Job.h"
24
25 namespace ADDON
26 {
27   class CRepository;
28   typedef boost::shared_ptr<CRepository> RepositoryPtr;
29   class CRepository : public CAddon
30   {
31   public:
32     virtual AddonPtr Clone() const;
33     CRepository(const AddonProps& props);
34     CRepository(const cp_extension_t *props);
35     virtual ~CRepository();
36
37     std::string Checksum() const;
38
39     /*! \brief Get the md5 hash for an addon.
40      \param the addon in question.
41      \return the md5 hash for the given addon, empty if non exists.
42      */
43     std::string GetAddonHash(const AddonPtr& addon) const;
44
45     struct DirInfo
46     {
47       DirInfo() : version("0.0.0"), compressed(false), zipped(false), hashes(false) {}
48       AddonVersion version;
49       std::string info;
50       std::string checksum;
51       std::string datadir;
52       bool compressed;
53       bool zipped;
54       bool hashes;
55     };
56
57     typedef std::vector<DirInfo> DirList;
58     DirList m_dirs;
59
60     static VECADDONS Parse(const DirInfo& dir);
61   private:
62     static std::string FetchChecksum(const std::string& url);
63     CRepository(const CRepository &rhs);
64   };
65
66   class CRepositoryUpdateJob : public CJob
67   {
68   public:
69     CRepositoryUpdateJob(const VECADDONS& repos);
70     virtual ~CRepositoryUpdateJob() {}
71
72     virtual const char *GetType() const { return "repoupdate"; };
73     virtual bool DoWork();
74   private:
75     VECADDONS GrabAddons(RepositoryPtr& repo);
76
77     VECADDONS m_repos;
78   };
79 }
80