OLD | NEW |
| (Empty) |
1 // Copyright 2009 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 // The current state of the App. | |
17 | |
18 #ifndef OMAHA_GOOPDATE_CURRENT_STATE_H_ | |
19 #define OMAHA_GOOPDATE_CURRENT_STATE_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/atlregmapex.h" | |
28 #include "omaha/base/constants.h" | |
29 #include "omaha/base/marshal_by_value.h" | |
30 #include "omaha/goopdate/google_update_ps_resource.h" | |
31 #include "omaha/common/goopdate_utils.h" | |
32 | |
33 namespace omaha { | |
34 | |
35 class ATL_NO_VTABLE CurrentAppState | |
36 : public CComObjectRootEx<CComObjectThreadModel>, | |
37 public CComCoClass<CurrentAppState>, | |
38 public IDispatchImpl<ICurrentState, | |
39 &__uuidof(ICurrentState), | |
40 &CAtlModule::m_libid, | |
41 kMajorTypeLibVersion, | |
42 kMinorTypeLibVersion>, | |
43 public IPersistStreamInitImpl<CurrentAppState>, | |
44 public MarshalByValue<CurrentAppState> { | |
45 public: | |
46 static HRESULT Create(LONG state_value, | |
47 const CString& available_version, | |
48 ULONGLONG bytes_downloaded, | |
49 ULONGLONG total_bytes_to_download, | |
50 LONG download_time_remaining_ms, | |
51 ULONGLONG next_retry_time, | |
52 LONG install_progress_percentage, | |
53 LONG install_time_remaining_ms, | |
54 bool is_canceled, | |
55 LONG error_code, | |
56 LONG extra_code1, | |
57 const CString& completion_message, | |
58 LONG installer_result_code, | |
59 LONG installer_result_extra_code1, | |
60 const CString& success_launch_cmd_line, | |
61 const CString& post_install_url, | |
62 PostInstallAction post_install_action, | |
63 CComObject<CurrentAppState>** current_state); | |
64 CurrentAppState(); | |
65 | |
66 static bool is_machine() { | |
67 return goopdate_utils::IsRunningFromOfficialGoopdateDir(true); | |
68 } | |
69 | |
70 static const CLSID& GetObjectCLSID() { | |
71 return is_machine() ? __uuidof(CurrentStateMachineClass) : | |
72 __uuidof(CurrentStateUserClass); | |
73 } | |
74 | |
75 DECLARE_REGISTRY_RESOURCEID_EX(IDR_INPROC_SERVER_RGS) | |
76 | |
77 #pragma warning(push) | |
78 // C4640: construction of local static object is not thread-safe | |
79 #pragma warning(disable : 4640) | |
80 BEGIN_REGISTRY_MAP() | |
81 REGMAP_ENTRY(_T("HKROOT"), is_machine() ? _T("HKLM") : _T("HKCU")) | |
82 REGMAP_ENTRY(_T("CLSID"), GetObjectCLSID()) | |
83 END_REGISTRY_MAP() | |
84 | |
85 BEGIN_PROP_MAP(CurrentAppState) | |
86 PROP_DATA_ENTRY("StateValue", state_value_, VT_I4) | |
87 PROP_DATA_ENTRY("AvailableVersion", available_version_, VT_BSTR) | |
88 PROP_DATA_ENTRY("BytesDownloaded", bytes_downloaded_, VT_UI8) | |
89 PROP_DATA_ENTRY("TotalBytesToDownload", total_bytes_to_download_, VT_UI8) | |
90 PROP_DATA_ENTRY("DownloadTimeRemainingMs", download_time_remaining_ms_, | |
91 VT_I4) | |
92 PROP_DATA_ENTRY("NextRetryTime", next_retry_time_, VT_UI8) | |
93 PROP_DATA_ENTRY("InstallProgressPercentage", install_progress_percentage_, | |
94 VT_I4) | |
95 PROP_DATA_ENTRY("InstallTimeRemainingMs", install_time_remaining_ms_, VT_I4) | |
96 PROP_DATA_ENTRY("IsCanceled", is_canceled_, VT_BOOL) | |
97 PROP_DATA_ENTRY("ErrorCode", error_code_, VT_I4) | |
98 PROP_DATA_ENTRY("ExtraCode1", extra_code1_, VT_I4) | |
99 PROP_DATA_ENTRY("CompletionMessage", completion_message_, VT_BSTR) | |
100 PROP_DATA_ENTRY("InstallerResultCode", installer_result_code_, VT_I4) | |
101 PROP_DATA_ENTRY("InstallerResultExtraCode1", installer_result_extra_code1_, | |
102 VT_I4) | |
103 PROP_DATA_ENTRY("PostInstallLaunchCommandLine", | |
104 post_install_launch_command_line_, VT_BSTR) | |
105 PROP_DATA_ENTRY("PostInstallUrl", post_install_url_, VT_BSTR) | |
106 PROP_DATA_ENTRY("PostInstallAction", post_install_action_, VT_I4) | |
107 END_PROP_MAP() | |
108 #pragma warning(pop) | |
109 | |
110 // ICurrentState. | |
111 STDMETHOD(get_stateValue)(LONG* state_value); | |
112 STDMETHOD(get_availableVersion)(BSTR* available_version); | |
113 STDMETHOD(get_bytesDownloaded)(ULONG* bytes_downloaded); | |
114 STDMETHOD(get_totalBytesToDownload)(ULONG* total_bytes_to_download); | |
115 STDMETHOD(get_downloadTimeRemainingMs)(LONG* download_time_remaining_ms); | |
116 STDMETHOD(get_nextRetryTime)(ULONGLONG* next_retry_time); | |
117 STDMETHOD(get_installProgress)(LONG* install_progress_percentage); | |
118 STDMETHOD(get_installTimeRemainingMs)(LONG* install_time_remaining_ms); | |
119 STDMETHOD(get_isCanceled)(VARIANT_BOOL* is_canceled); | |
120 STDMETHOD(get_errorCode)(LONG* error_code); | |
121 STDMETHOD(get_extraCode1)(LONG* extra_code1); | |
122 STDMETHOD(get_completionMessage)(BSTR* completion_message); | |
123 STDMETHOD(get_installerResultCode)(LONG* installer_result_code); | |
124 STDMETHOD(get_installerResultExtraCode1)(LONG* installer_result_extra_code1); | |
125 STDMETHOD(get_postInstallLaunchCommandLine)( | |
126 BSTR* post_install_launch_command_line); | |
127 STDMETHOD(get_postInstallUrl)(BSTR* post_install_url); | |
128 STDMETHOD(get_postInstallAction)(LONG* post_install_action); | |
129 | |
130 protected: | |
131 virtual ~CurrentAppState(); | |
132 | |
133 BEGIN_COM_MAP(CurrentAppState) | |
134 COM_INTERFACE_ENTRY(ICurrentState) | |
135 COM_INTERFACE_ENTRY(IDispatch) | |
136 COM_INTERFACE_ENTRY(IMarshal) | |
137 END_COM_MAP() | |
138 | |
139 BOOL m_bRequiresSave; | |
140 | |
141 private: | |
142 LONG state_value_; | |
143 CComBSTR available_version_; | |
144 ULONGLONG bytes_downloaded_; | |
145 ULONGLONG total_bytes_to_download_; | |
146 LONG download_time_remaining_ms_; | |
147 ULONGLONG next_retry_time_; | |
148 LONG install_progress_percentage_; | |
149 LONG install_time_remaining_ms_; | |
150 VARIANT_BOOL is_canceled_; | |
151 LONG error_code_; | |
152 LONG extra_code1_; | |
153 CComBSTR completion_message_; | |
154 LONG installer_result_code_; | |
155 LONG installer_result_extra_code1_; | |
156 CComBSTR post_install_launch_command_line_; | |
157 CComBSTR post_install_url_; | |
158 LONG post_install_action_; | |
159 | |
160 DISALLOW_COPY_AND_ASSIGN(CurrentAppState); | |
161 }; | |
162 | |
163 } // namespace omaha | |
164 | |
165 #endif // OMAHA_GOOPDATE_CURRENT_STATE_H_ | |
OLD | NEW |