OLD | NEW |
| (Empty) |
1 // Copyright 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 #include <atlbase.h> | |
17 #include "base/basictypes.h" | |
18 #include "omaha/base/utils.h" | |
19 #include "goopdate/omaha3_idl.h" | |
20 #include "omaha/goopdate/com_proxy.h" | |
21 #include "omaha/goopdate/current_state.h" | |
22 #include "omaha/goopdate/omaha3_idl_datax.h" | |
23 | |
24 namespace omaha { | |
25 | |
26 // TODO(omaha): Try to see if a single proxy DLL can be used for both user and | |
27 // machine. | |
28 | |
29 #if IS_MACHINE_HANDLER | |
30 OBJECT_ENTRY_AUTO(__uuidof(GoogleComProxyMachineClass), ComProxy) | |
31 OBJECT_ENTRY_AUTO(__uuidof(CurrentStateMachineClass), CurrentAppState) | |
32 #else | |
33 OBJECT_ENTRY_AUTO(__uuidof(GoogleComProxyUserClass), ComProxy) | |
34 OBJECT_ENTRY_AUTO(__uuidof(CurrentStateUserClass), CurrentAppState) | |
35 #endif | |
36 | |
37 namespace { | |
38 | |
39 class GoogleUpdatePSModule | |
40 : public CAtlDllModuleT<GoogleUpdatePSModule> { | |
41 public: | |
42 GoogleUpdatePSModule() {} | |
43 | |
44 private: | |
45 DISALLOW_COPY_AND_ASSIGN(GoogleUpdatePSModule); // NOLINT | |
46 } _AtlModule; | |
47 | |
48 } // namespace | |
49 | |
50 } // namespace omaha | |
51 | |
52 BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) { | |
53 HRESULT hr = omaha::_AtlModule.DllMain(reason, reserved); | |
54 if (FAILED(hr)) { | |
55 return hr; | |
56 } | |
57 | |
58 return PrxDllMain(instance, reason, reserved); | |
59 } | |
60 | |
61 STDAPI DllCanUnloadNow() { | |
62 if (omaha::_AtlModule.DllCanUnloadNow() == S_OK && | |
63 PrxDllCanUnloadNow() == S_OK) { | |
64 return S_OK; | |
65 } | |
66 | |
67 return S_FALSE; | |
68 } | |
69 | |
70 STDAPI DllGetClassObject(REFCLSID clsid, REFIID iid, void** ptr) { | |
71 HRESULT hr_atl = omaha::_AtlModule.DllGetClassObject(clsid, iid, ptr); | |
72 if (SUCCEEDED(hr_atl)) { | |
73 return hr_atl; | |
74 } | |
75 | |
76 HRESULT hr_prx = PrxDllGetClassObject(clsid, iid, ptr); | |
77 if (FAILED(hr_prx)) { | |
78 CORE_LOG(LE, (_T("[DllGetClassObject failed][%s][%s][0x%x][0x%x]"), | |
79 omaha::GuidToString(clsid), omaha::GuidToString(iid), hr_atl, hr_prx)); | |
80 } | |
81 | |
82 return hr_prx; | |
83 } | |
84 | |
85 STDAPI DllRegisterServer() { | |
86 HRESULT hr = omaha::_AtlModule.DllRegisterServer(false); | |
87 if (FAILED(hr)) { | |
88 CORE_LOG(LE, (_T("[DllRegisterServer failed][0x%x]"), hr)); | |
89 return hr; | |
90 } | |
91 | |
92 return PrxDllRegisterServer(); | |
93 } | |
94 | |
95 STDAPI DllUnregisterServer() { | |
96 HRESULT hr = PrxDllUnregisterServer(); | |
97 if (FAILED(hr)) { | |
98 CORE_LOG(LE, (_T("[DllUnregisterServer failed][0x%x]"), hr)); | |
99 return hr; | |
100 } | |
101 | |
102 return omaha::_AtlModule.DllUnregisterServer(false); | |
103 } | |
104 | |
OLD | NEW |