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 #include "omaha/goopdate/app_state_waiting_to_install.h" | |
17 #include "omaha/base/debug.h" | |
18 #include "omaha/base/file.h" | |
19 #include "omaha/base/logging.h" | |
20 #include "omaha/base/path.h" | |
21 #include "omaha/base/utils.h" | |
22 #include "omaha/goopdate/app_state_installing.h" | |
23 #include "omaha/goopdate/install_manager.h" | |
24 #include "omaha/goopdate/model.h" | |
25 #include "omaha/goopdate/server_resource.h" | |
26 #include "omaha/goopdate/string_formatter.h" | |
27 | |
28 namespace omaha { | |
29 | |
30 namespace fsm { | |
31 | |
32 AppStateWaitingToInstall::AppStateWaitingToInstall() | |
33 : AppState(STATE_WAITING_TO_INSTALL) { | |
34 } | |
35 | |
36 void AppStateWaitingToInstall::Download( | |
37 App* app, | |
38 DownloadManagerInterface* download_manager) { | |
39 CORE_LOG(L3, (_T("[AppStateWaitingToInstall::Download][0x%p]"), app)); | |
40 ASSERT1(app); | |
41 ASSERT1(download_manager); | |
42 UNREFERENCED_PARAMETER(app); | |
43 UNREFERENCED_PARAMETER(download_manager); | |
44 } | |
45 | |
46 void AppStateWaitingToInstall::QueueInstall(App* app) { | |
47 CORE_LOG(L3, (_T("[AppStateWaitingToInstall::QueueInstall][%p]"), app)); | |
48 ASSERT1(app); | |
49 UNREFERENCED_PARAMETER(app); | |
50 } | |
51 | |
52 // Copies app packages and runs the installer. The packages are cleaned up | |
53 // by the InstallManager constructor, when its instance will be created by | |
54 // the next COM server that starts up. | |
55 void AppStateWaitingToInstall::Install( | |
56 App* app, | |
57 InstallManagerInterface* install_manager) { | |
58 CORE_LOG(L3, (_T("[AppStateWaitingToInstall::Install][0x%p]"), app)); | |
59 ASSERT1(app); | |
60 ASSERT1(install_manager); | |
61 | |
62 CString guid; | |
63 HRESULT hr(GetGuid(&guid)); | |
64 if (SUCCEEDED(hr)) { | |
65 const CString installer_dir( | |
66 ConcatenatePath(install_manager->install_working_dir(), guid)); | |
67 hr = CopyAppVersionPackages(app->next_version(), installer_dir); | |
68 if (SUCCEEDED(hr)) { | |
69 install_manager->InstallApp(app, installer_dir); | |
70 } | |
71 } | |
72 | |
73 if (FAILED(hr)) { | |
74 StringFormatter formatter(app->app_bundle()->display_language()); | |
75 CString message; | |
76 VERIFY1(SUCCEEDED(formatter.LoadString(IDS_INSTALL_FAILED, &message))); | |
77 Error(app, ErrorContext(hr), message); | |
78 } | |
79 } | |
80 | |
81 void AppStateWaitingToInstall::Installing(App* app) { | |
82 CORE_LOG(L3, (_T("[AppStateWaitingToInstall::Installing][%p]"), app)); | |
83 ASSERT1(app); | |
84 | |
85 ChangeState(app, new AppStateInstalling); | |
86 } | |
87 | |
88 } // namespace fsm | |
89 | |
90 } // namespace omaha | |
OLD | NEW |