otaupdaterApi.h
Go to the documentation of this file.
1 
3 #pragma once
4 
5 #include <boost/function.hpp>
6 #include <boost/system/error_code.hpp>
7 #include <boost/shared_ptr.hpp>
8 
9 #include <vector>
10 #include <map>
11 
12 class OtaUpdaterClient;
13 
14 #ifndef OTAUPDATER_TYPES
15 #define OTAUPDATER_TYPES
16 
22 namespace dpyOtaupdater {
27 struct Channel
28 {
29  std::string type = "";
30  std::string baseurl = "";
31 };
32 
38 {
39  INIT = 0,
41  IDLE = 2,
42  RECOVERING = 3,
43  OPERATING = 4,
45  END = 6
46 };
47 
53 {
54  OK = 0,
55  ERROR = 1,
56  IN_PROCESS = 2,
57  UPGRADED = 3,
58  BACKUP = 4,
59 };
60 
61 
67 {
69  INSTALLING = 1,
70  UPGRADING = 2,
71  REMOVING = 3,
73 };
74 
79 typedef boost::function<void(const bool &available)> service_availability_handler;
80 
89 typedef boost::function<void(boost::system::error_code error_code, int status, int rfsstatus)> status_handler_function;
90 
96 typedef boost::function<void(boost::system::error_code error_code, std::vector<std::pair<std::string, std::string>> &updatesList)> updateslist_handler_function;
97 
103 typedef boost::function<void(boost::system::error_code error_code, std::map<std::string, std::pair<std::string, std::string>> &versionList)> versionlist_handler_function;
104 
111 typedef boost::function<void(boost::system::error_code error_code)> result_handler_function;
112 
120 typedef boost::function<void(boost::system::error_code error_code, std::vector<std::pair<std::string, Channel>> &channelList)> channels_handler_function;
121 
127 typedef boost::function<void(boost::system::error_code error_code, std::vector<std::pair<std::string, std::string>> &updatesList)> remoteversionlist_handler_function;
128 
137 typedef boost::function<void(boost::system::error_code error_code, int operation, int percentage)> operation_percentage_handler_function;
138 }
139 #endif //OTAUPDATER_TYPES
140 
147 {
148 private:
149  boost::shared_ptr<OtaUpdaterClient> mClient;
150 public:
151 
152  explicit OtaUpdater(std::string ip = "127.0.0.1");
153 #ifndef TESTING
154  ~OtaUpdater();
155 #else
156  virtual ~OtaUpdater();
157 #endif
158 
160 #ifndef TESTING
161  bool isAlive();
162  void monitorServiceAvailability_S(dpyOtaupdater::service_availability_handler handler);
163  void monitorServiceAvailability_U();
164  void asyncGetUpdates(dpyOtaupdater::updateslist_handler_function handler);
165  void asyncGetStatus(dpyOtaupdater::status_handler_function handler);
166  void getStatus_S(dpyOtaupdater::status_handler_function handler);
167  void getStatus_U();
168 
169  void asyncRepoSync(dpyOtaupdater::result_handler_function handler);
170  void asyncUpgrade(dpyOtaupdater::result_handler_function handler, std::vector<std::string> packages = {""});
171  void asyncInstall(dpyOtaupdater::result_handler_function handler, std::vector<std::string> packages = {""});
172  void asyncUninstall(dpyOtaupdater::result_handler_function handler, std::vector<std::string> packages = {""});
173  void asyncGetVersions(dpyOtaupdater::versionlist_handler_function handler, std::vector<std::string> packages = {""});
174  void asyncGetRemoteVersions(dpyOtaupdater::remoteversionlist_handler_function handler, std::vector<std::string> packages = {});
175  void asyncRollback(dpyOtaupdater::result_handler_function handler);
176  void asyncDiscard(dpyOtaupdater::result_handler_function handler);
178 
179  void asyncAddChannel(dpyOtaupdater::result_handler_function handler, std::string name, dpyOtaupdater::Channel channel);
180  void asyncDelChannel(dpyOtaupdater::result_handler_function handler, std::string name);
181  void asyncGetChannels(dpyOtaupdater::channels_handler_function handler);
182 
183  void asyncGetOperationPercentage(dpyOtaupdater::operation_percentage_handler_function handler);
184  void getOperationPercentage_S(dpyOtaupdater::operation_percentage_handler_function handler);
185  void getOperationPercentage_U();
186 
187 #else
188  virtual bool isAlive();
189  virtual void monitorServiceAvailability_S(dpyOtaupdater::service_availability_handler handler);
190  virtual void monitorServiceAvailability_U();
191  virtual void asyncGetUpdates(dpyOtaupdater::updateslist_handler_function handler);
192  virtual void asyncGetStatus(dpyOtaupdater::status_handler_function handler);
193  virtual void getStatus_S(dpyOtaupdater::status_handler_function handler);
194  virtual void getStatus_U();
195  virtual void asyncRepoSync(dpyOtaupdater::result_handler_function handler);
196  virtual void asyncUpgrade(dpyOtaupdater::result_handler_function handler, std::vector<std::string> packages = {""});
197  virtual void asyncInstall(dpyOtaupdater::result_handler_function handler, std::vector<std::string> packages = {""});
198  virtual void asyncUninstall(dpyOtaupdater::result_handler_function handler, std::vector<std::string> packages = {""});
199  virtual void asyncGetVersions(dpyOtaupdater::versionlist_handler_function handler, std::vector<std::string> packages = {""});
200  virtual void asyncGetRemoteVersions(dpyOtaupdater::remoteversionlist_handler_function handler, std::vector<std::string> packages = {""});
201  virtual void asyncRollback(dpyOtaupdater::result_handler_function handler);
202  virtual void asyncDiscard(dpyOtaupdater::result_handler_function handler);
203  virtual void asyncAck(dpyOtaupdater::result_handler_function);
204 
205  virtual void asyncAddChannel(dpyOtaupdater::result_handler_function handler, std::string name, dpyOtaupdater::Channel channel);
206  virtual void asyncDelChannel(dpyOtaupdater::result_handler_function handler, std::string name);
207  virtual void asyncGetChannels(dpyOtaupdater::channels_handler_function handler);
208 
209 
210  virtual void asyncGetOperationPercentage(dpyOtaupdater::operation_percentage_handler_function handler);
211  virtual void getOperationPercentage_S(dpyOtaupdater::operation_percentage_handler_function handler);
212  virtual void getOperationPercentage_U();
213 #endif
214 };
Definition: otaupdaterApi.h:55
boost::function< void(boost::system::error_code error_code, std::vector< std::pair< std::string, std::string >> &updatesList)> remoteversionlist_handler_function
Handler for GetRemoteVersions function callback.
Definition: otaupdaterApi.h:127
boost::function< void(const bool &available)> service_availability_handler
Prototype of the handler function used to monitor service availability.
Definition: otaupdaterApi.h:79
Definition: otaupdaterApi.h:40
boost::function< void(boost::system::error_code error_code, std::vector< std::pair< std::string, Channel >> &channelList)> channels_handler_function
Handler for getchannels function callback.
Definition: otaupdaterApi.h:120
boost::function< void(boost::system::error_code error_code)> result_handler_function
Handler for command function callback.
Definition: otaupdaterApi.h:111
std::string baseurl
Base URL.
Definition: otaupdaterApi.h:30
Definition: otaupdaterApi.h:70
Definition: otaupdaterApi.h:27
Definition: otaupdaterApi.h:58
Definition: otaupdaterApi.h:45
Definition: otaupdaterApi.h:57
std::string type
Type.
Definition: otaupdaterApi.h:29
Definition: otaupdaterApi.h:54
Definition: otaupdaterApi.h:68
boost::function< void(boost::system::error_code error_code, int status, int rfsstatus)> status_handler_function
Handler for status function callback.
Definition: otaupdaterApi.h:89
Interacts with ota updater service.
Definition: otaupdaterClient.h:15
boost::function< void(boost::system::error_code error_code, int operation, int percentage)> operation_percentage_handler_function
Handler for operation percentage function callback.
Definition: otaupdaterApi.h:137
Definition: otaupdaterApi.h:69
Definition: otaupdaterApi.h:56
boost::function< void(boost::system::error_code error_code, std::map< std::string, std::pair< std::string, std::string >> &versionList)> versionlist_handler_function
Handler for getVersions function callback.
Definition: otaupdaterApi.h:103
Definition: otaupdaterApi.h:41
Allows to interact with a ota updater service.
Definition: otaupdaterApi.h:146
AltRFSStatus
Definition: otaupdaterApi.h:52
ServiceStatus
Definition: otaupdaterApi.h:37
Definition: otaupdaterApi.h:71
Definition: otaupdaterApi.h:44
Deepsy Otaupdater namespace that includes the different enums, structs or method signatures that shou...
Definition: otaupdaterApi.h:39
Definition: otaupdaterApi.h:43
OperationType
Definition: otaupdaterApi.h:66
Definition: otaupdaterApi.h:72
boost::function< void(boost::system::error_code error_code, std::vector< std::pair< std::string, std::string >> &updatesList)> updateslist_handler_function
Handler for getUpdates function callback.
Definition: otaupdaterApi.h:96
Definition: otaupdaterApi.h:42