Opera 12.15 Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

updatablefile.h 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. /* -*- Mode: c++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
  2. *
  3. * Copyright (C) 1995-2011 Opera Software AS. All rights reserved.
  4. *
  5. * This file is part of the Opera web browser. It may not be distributed
  6. * under any circumstances.
  7. *
  8. * @author Marius Blomli, Michal Zajaczkowski
  9. */
  10. #ifndef _UPDATEABLEFILE_H_INCLUDED_
  11. #define _UPDATEABLEFILE_H_INCLUDED_
  12. #ifdef AUTO_UPDATE_SUPPORT
  13. #include "adjunct/autoupdate/updatableresource.h"
  14. #include "adjunct/autoupdate/autoupdater.h"
  15. #include "modules/prefsloader/prefsloadmanager.h"
  16. #ifdef PLUGIN_AUTO_INSTALL
  17. #include "adjunct/quick/managers/PluginInstallManager.h"
  18. #endif // PLUGIN_AUTO_INSTALL
  19. /**
  20. * This class is a representation of a local file resource that is to be
  21. * kept up to date by the auto update system.
  22. */
  23. class UpdatableFile:
  24. public UpdatableResource,
  25. public FileDownloader
  26. {
  27. public:
  28. UpdatableFile();
  29. /**
  30. * Gets the class of resource
  31. *
  32. * @returns - ResourceClass::File
  33. */
  34. virtual ResourceClass GetResourceClass() { return File; }
  35. /**
  36. * Override this method to implement the way that your file resource is checked after being downloaded.
  37. * The default implementation found in UpdatebleFile::CheckResource() checks the SHA checksum that should
  38. * be sent from the server along with each file resource.
  39. *
  40. * @returns - TRUE is case the file was checked to be OK, FALSE otherwise
  41. */
  42. virtual BOOL CheckResource();
  43. /**
  44. * Implement this method to ensure that the attribute list sent from the server along with your file resource
  45. * is complete, i.e. that the server has sent all the XML elements that are essential for the given type of file
  46. * resource.
  47. * This method is called by the UpdatableResourceFactory just after the XML fragment containing the description
  48. * of the given file is fully parsed. In case this method returns FALSE, the file resource is dropped, i.e. the
  49. * UpdatableResourceFactory refuses to construct it.
  50. *
  51. * @returns - TRUE if the file resource has all the needed attributes, FALSE otherwise
  52. */
  53. virtual BOOL VerifyAttributes() = 0;
  54. /**
  55. * Constructs the full local filename for the given file resource, i.e. the filename containing the full path to the file.
  56. * Utilizes the folder name returned by GetDownloadFolder() and the filename sent from the autoupdate server within the
  57. * <name> XML element. This file name will determine the download location for the given file resource.
  58. *
  59. * @param full_filename - an OpString reference that will be filled with the full file name including the path
  60. *
  61. * @returns - OpStatus::OK if the file name was construced OK, ERR otherwise.
  62. */
  63. OP_STATUS GetDownloadFullName(OpString& full_filename);
  64. /**
  65. * Specifies the folder for the given file resource. The default implementation sets the folder to OPFILE_TEMPDOWNLOAD_FOLDER,
  66. * this method can be overriden in order to have the file downloaded to some other folder.
  67. *
  68. * @param download_folder - an OpString reference that will contain the folder name string
  69. *
  70. * @returns - OpStatus::OK if the string was set successfully, ERR otherwise.
  71. */
  72. virtual OP_STATUS GetDownloadFolder(OpString& download_folder);
  73. /**
  74. * Starts the download of the given file resource. Notify the given FileDownloadListener implementation about the progress.
  75. *
  76. * @param listener - The FileDownloadListener implementation that will receive the progress events.
  77. *
  78. * @returns - OpStatus::OK in case the download started OK, error code otherwise.
  79. */
  80. OP_STATUS StartDownloading(FileDownloadListener* listener);
  81. protected:
  82. /**
  83. * In order to report the file resource download progress, Opera needs to know the resource size. This should come from the
  84. * HTTP headers sent by the server hosting the download, however if the size received that way is zero, we need a better
  85. * way to know it, thus this method is called then.
  86. * The default implementation uses the <size> XML element content to determine the download size. This is not always the
  87. * best idea, i.e. with the plugin downloads that are hosted on vendors' servers this element may not contain the lastest
  88. * up-to-date information.
  89. * If your UpdatableFile implementation has a good way of knowing the download size, implement this method.
  90. *
  91. * @returns - the download size in bytes, best guess.
  92. */
  93. virtual OpFileLength GetOverridedFileLength();
  94. };
  95. /**
  96. *
  97. * UpdatablePackage
  98. *
  99. */
  100. class UpdatablePackage : public UpdatableFile
  101. {
  102. public:
  103. UpdatablePackage() {}
  104. virtual ~UpdatablePackage() {}
  105. /**
  106. * Implementing UpdatableResource API.
  107. */
  108. virtual UpdatableResourceType GetType() { return RTPackage; }
  109. virtual OP_STATUS UpdateResource();
  110. virtual BOOL CheckResource();
  111. virtual OP_STATUS Cleanup();
  112. virtual const uni_char* GetResourceName() { return UNI_L("Package"); }
  113. virtual BOOL UpdateRequiresUnpacking();
  114. virtual BOOL UpdateRequiresRestart() { return TRUE; }
  115. virtual BOOL GetShowNotification();
  116. virtual BOOL VerifyAttributes();
  117. OP_STATUS GetPackageVersion(OperaVersion& version);
  118. };
  119. /**
  120. *
  121. * UpdatableSpoof
  122. *
  123. */
  124. class UpdatableSpoof : public UpdatableFile
  125. {
  126. public:
  127. UpdatableSpoof() {}
  128. virtual ~UpdatableSpoof() {}
  129. /**
  130. * Implementing UpdatableResource API.
  131. */
  132. virtual UpdatableResourceType GetType() { return RTSpoofFile; }
  133. virtual OP_STATUS UpdateResource();
  134. virtual BOOL CheckResource();
  135. virtual OP_STATUS Cleanup();
  136. virtual const uni_char* GetResourceName() { return UNI_L("Spoof"); }
  137. virtual BOOL UpdateRequiresUnpacking() { return FALSE; }
  138. virtual BOOL UpdateRequiresRestart() { return FALSE; }
  139. virtual BOOL VerifyAttributes();
  140. private:
  141. class EndChecker: public OpEndChecker
  142. {
  143. public:
  144. /**
  145. * Always accept spoof lists Opera downloads automatically: return FALSE
  146. */
  147. BOOL IsEnd(OpStringC info) { return FALSE; }
  148. void Dispose() { OP_DELETE(this); }
  149. };
  150. };
  151. /**
  152. *
  153. * UpdatableBrowserJS
  154. *
  155. */
  156. class UpdatableBrowserJS : public UpdatableFile
  157. {
  158. public:
  159. UpdatableBrowserJS() {}
  160. virtual ~UpdatableBrowserJS() {}
  161. /**
  162. * Implementing UpdatableResource API.
  163. */
  164. virtual UpdatableResourceType GetType() { return RTBrowserJSFile; }
  165. virtual OP_STATUS UpdateResource();
  166. virtual BOOL CheckResource();
  167. virtual OP_STATUS Cleanup();
  168. virtual const uni_char* GetResourceName() { return UNI_L("Browser JS"); }
  169. virtual BOOL UpdateRequiresUnpacking() { return FALSE; }
  170. virtual BOOL UpdateRequiresRestart() { return FALSE; }
  171. virtual BOOL VerifyAttributes();
  172. };
  173. /**
  174. *
  175. * UpdatableDictionary
  176. *
  177. */
  178. class UpdatableDictionary : public UpdatableFile
  179. {
  180. public:
  181. UpdatableDictionary() {}
  182. virtual ~UpdatableDictionary() {}
  183. /**
  184. * Implementing UpdatableResource API.
  185. */
  186. virtual UpdatableResourceType GetType() { return RTDictionary; }
  187. virtual OP_STATUS UpdateResource();
  188. virtual BOOL CheckResource();
  189. virtual OP_STATUS Cleanup();
  190. virtual const uni_char* GetResourceName() { return UNI_L("Dictionary"); }
  191. virtual BOOL UpdateRequiresUnpacking() { return FALSE; }
  192. virtual BOOL UpdateRequiresRestart() { return FALSE; }
  193. virtual URAttr GetResourceKey() { return URA_ID; }
  194. virtual BOOL VerifyAttributes();
  195. };
  196. /**
  197. *
  198. * UpdatableDictionaryXML
  199. *
  200. */
  201. class UpdatableDictionaryXML : public UpdatableFile
  202. {
  203. public:
  204. UpdatableDictionaryXML() {}
  205. virtual ~UpdatableDictionaryXML() {}
  206. /**
  207. * Implementing UpdatableResource API.
  208. */
  209. virtual UpdatableResourceType GetType() { return RTDictionary; }
  210. virtual OP_STATUS UpdateResource();
  211. virtual BOOL CheckResource();
  212. virtual OP_STATUS Cleanup();
  213. virtual OpFileLength GetSize() const { return 0; }
  214. virtual const uni_char* GetResourceName() { return UNI_L("DictionaryXML"); }
  215. virtual BOOL UpdateRequiresUnpacking() { return FALSE; }
  216. virtual BOOL UpdateRequiresRestart() { return FALSE; }
  217. virtual BOOL VerifyAttributes();
  218. };
  219. #ifdef PLUGIN_AUTO_INSTALL
  220. /**
  221. *
  222. * UpdatablePlugin
  223. *
  224. */
  225. class UpdatablePlugin:
  226. public UpdatableFile,
  227. public PIM_AsyncProcessRunnerListener
  228. {
  229. public:
  230. UpdatablePlugin();
  231. virtual ~UpdatablePlugin();
  232. /**
  233. * Implementing UpdatableResource API.
  234. */
  235. virtual UpdatableResourceType GetType() { return RTPlugin; }
  236. virtual OP_STATUS UpdateResource();
  237. virtual BOOL CheckResource();
  238. virtual OP_STATUS Cleanup();
  239. virtual const uni_char* GetResourceName() { return UNI_L("Plugin"); }
  240. virtual BOOL UpdateRequiresRestart() { return FALSE; }
  241. virtual BOOL UpdateRequiresUnpacking() { return FALSE; }
  242. virtual URAttr GetResourceKey() { return URA_MIME_TYPE; }
  243. virtual BOOL VerifyAttributes();
  244. /**
  245. * Extending API for UpdatablePlugin
  246. */
  247. OP_STATUS InstallPlugin(BOOL a_silent);
  248. OP_STATUS CancelPluginInstallation();
  249. PIM_AsyncProcessRunner* GetAsyncProcessRunner() { return m_async_process_runner; }
  250. void SetAsyncProcessRunner(PIM_AsyncProcessRunner* runner) { m_async_process_runner = runner; }
  251. /**
  252. * PIM_AsyncProcessRunnerListener
  253. */
  254. void OnProcessFinished(DWORD exit_code);
  255. private:
  256. PIM_AsyncProcessRunner* m_async_process_runner;
  257. };
  258. #endif // PLUGIN_AUTO_INSTALL
  259. #ifdef VEGA_3DDEVICE
  260. /**
  261. *
  262. * UpdatableHardwareBlocklist
  263. *
  264. */
  265. class UpdatableHardwareBlocklist : public UpdatableFile
  266. {
  267. public:
  268. UpdatableHardwareBlocklist() {}
  269. virtual ~UpdatableHardwareBlocklist() {}
  270. /**
  271. * Implementing UpdatableResource API.
  272. */
  273. virtual UpdatableResourceType GetType() { return RTHardwareBlocklist; }
  274. virtual OP_STATUS UpdateResource();
  275. virtual BOOL CheckResource();
  276. virtual const uni_char* GetResourceName() { return UNI_L("HardwareBlocklist"); }
  277. virtual BOOL UpdateRequiresUnpacking() { return FALSE; }
  278. virtual BOOL UpdateRequiresRestart() { return FALSE; }
  279. virtual OP_STATUS Cleanup();
  280. virtual BOOL VerifyAttributes();
  281. };
  282. #endif // VEGA_3DDEVICE
  283. /**
  284. *
  285. * UpdatableHandlersIgnore
  286. *
  287. */
  288. class UpdatableHandlersIgnore : public UpdatableFile
  289. {
  290. public:
  291. UpdatableHandlersIgnore() {}
  292. virtual ~UpdatableHandlersIgnore() {}
  293. /**
  294. * Implementing UpdatableResource API.
  295. */
  296. virtual UpdatableResourceType GetType() { return RTHandlersIgnore; }
  297. virtual OP_STATUS UpdateResource();
  298. virtual const uni_char* GetResourceName() { return UNI_L("HandlersIgnore"); }
  299. virtual BOOL UpdateRequiresUnpacking() { return FALSE; }
  300. virtual BOOL UpdateRequiresRestart() { return FALSE; }
  301. virtual OP_STATUS Cleanup();
  302. virtual BOOL VerifyAttributes();
  303. };
  304. #endif // AUTO_UPDATE_SUPPORT
  305. #endif // _UPDATEABLEFILE_H_INCLUDED_