| OLD | NEW |
| (Empty) |
| 1 // Copyright 2009-2010 Google Inc. | |
| 2 // | |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 // you may not use this file except in compliance with the License. | |
| 5 // You may obtain a copy of the License at | |
| 6 // | |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 // | |
| 9 // Unless required by applicable law or agreed to in writing, software | |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 // See the License for the specific language governing permissions and | |
| 13 // limitations under the License. | |
| 14 // ======================================================================== | |
| 15 | |
| 16 // Defines the AppVersion COM object exposed by the model. | |
| 17 | |
| 18 #ifndef OMAHA_GOOPDATE_APP_VERSION_H_ | |
| 19 #define OMAHA_GOOPDATE_APP_VERSION_H_ | |
| 20 | |
| 21 #include <atlbase.h> | |
| 22 #include <atlcom.h> | |
| 23 #include <vector> | |
| 24 #include "base/basictypes.h" | |
| 25 #include "base/scoped_ptr.h" | |
| 26 #include "goopdate/omaha3_idl.h" | |
| 27 #include "omaha/base/constants.h" | |
| 28 #include "omaha/common/install_manifest.h" | |
| 29 #include "omaha/goopdate/com_wrapper_creator.h" | |
| 30 #include "omaha/goopdate/model_object.h" | |
| 31 | |
| 32 namespace omaha { | |
| 33 | |
| 34 class App; | |
| 35 class AppBundle; | |
| 36 class Package; | |
| 37 | |
| 38 class AppVersion : public ModelObject { | |
| 39 public: | |
| 40 explicit AppVersion(App* app); | |
| 41 virtual ~AppVersion(); | |
| 42 | |
| 43 // IAppVersion. | |
| 44 STDMETHOD(get_version)(BSTR* version); | |
| 45 STDMETHOD(get_packageCount)(long* count); // NOLINT | |
| 46 STDMETHOD(get_package)(long index, Package** package); // NOLINT | |
| 47 | |
| 48 App* app(); | |
| 49 const App* app() const; | |
| 50 | |
| 51 CString version() const; | |
| 52 void set_version(const CString& version); | |
| 53 | |
| 54 const xml::InstallManifest* install_manifest() const; | |
| 55 void set_install_manifest(xml::InstallManifest* install_manifest); | |
| 56 | |
| 57 // Returns the number of packages that make up this app version. | |
| 58 size_t GetNumberOfPackages() const; | |
| 59 | |
| 60 // Gets the package at the specified index. | |
| 61 Package* GetPackage(size_t index); | |
| 62 const Package* GetPackage(size_t index) const; | |
| 63 | |
| 64 // Adds a package to this app version. | |
| 65 HRESULT AddPackage(const CString& filename, uint32 size, const CString& hash); | |
| 66 | |
| 67 // Returns the list of download servers to use in order of preference. | |
| 68 const std::vector<CString>& download_base_urls() const; | |
| 69 | |
| 70 // Adds a download server to the list of fallbacks. Servers are attempted in | |
| 71 // the order they are added. | |
| 72 HRESULT AddDownloadBaseUrl(const CString& server_url); | |
| 73 | |
| 74 private: | |
| 75 | |
| 76 // product version "pv". | |
| 77 CString version_; | |
| 78 | |
| 79 scoped_ptr<xml::InstallManifest> install_manifest_; | |
| 80 | |
| 81 std::vector<Package*> packages_; | |
| 82 | |
| 83 std::vector<CString> download_base_urls_; | |
| 84 | |
| 85 App* app_; | |
| 86 | |
| 87 DISALLOW_COPY_AND_ASSIGN(AppVersion); | |
| 88 }; | |
| 89 | |
| 90 class ATL_NO_VTABLE AppVersionWrapper | |
| 91 : public ComWrapper<AppVersionWrapper, AppVersion>, | |
| 92 public IDispatchImpl<IAppVersion, | |
| 93 &__uuidof(IAppVersion), | |
| 94 &CAtlModule::m_libid, | |
| 95 kMajorTypeLibVersion, | |
| 96 kMinorTypeLibVersion> { | |
| 97 public: | |
| 98 // IAppVersion. | |
| 99 STDMETHOD(get_version)(BSTR* version); | |
| 100 STDMETHOD(get_packageCount)(long* count); // NOLINT | |
| 101 STDMETHOD(get_package)(long index, IDispatch** package); // NOLINT | |
| 102 | |
| 103 protected: | |
| 104 AppVersionWrapper() {} | |
| 105 virtual ~AppVersionWrapper() {} | |
| 106 | |
| 107 BEGIN_COM_MAP(AppVersionWrapper) | |
| 108 COM_INTERFACE_ENTRY(IAppVersion) | |
| 109 COM_INTERFACE_ENTRY(IDispatch) | |
| 110 END_COM_MAP() | |
| 111 | |
| 112 private: | |
| 113 typedef ComWrapper<AppVersionWrapper, AppVersion> Creator; | |
| 114 friend class Creator; | |
| 115 }; | |
| 116 | |
| 117 // Copies all packages of an app version to the specified directory. | |
| 118 HRESULT CopyAppVersionPackages(const AppVersion* app_version, | |
| 119 const CString& dir); | |
| 120 | |
| 121 } // namespace omaha | |
| 122 | |
| 123 #endif // OMAHA_GOOPDATE_APP_VERSION_H_ | |
| OLD | NEW |