9f003e37731153fd41a7f512deb7290b925443de
[platform/core/appfw/wgt-backend.git] / src / wgt_backend / wgt_backend.cc
1 /* 2014, Copyright © Intel Coporation, license APACHE-2.0, see LICENSE file */
2 // Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3 // Use of this source code is governed by a apache 2.0 license that can be
4 // found in the LICENSE file.
5
6 #include <common/pkgmgr_interface.h>
7 #include <cerrno>
8
9 #include "hybrid/hybrid_installer.h"
10 #include "wgt/utils/wgt_app_query_interface.h"
11 #include "wgt/wgt_installer.h"
12
13 namespace ci = common_installer;
14
15 int main(int argc, char** argv) {
16   ci::PkgmgrInstaller pkgmgr_installer;
17   wgt::WgtAppQueryInterface query_interface;
18   auto pkgmgr = ci::PkgMgrInterface::Create(argc, argv, &pkgmgr_installer,
19                                             &query_interface);
20   if (!pkgmgr) {
21     LOG(ERROR) << "Options of pkgmgr installer cannot be parsed";
22     return EINVAL;
23   }
24
25   // This is workaround for hybrid apps as they requires much different flow
26   // but installer does not branch at all in current design
27   if (query_interface.IsHybridApplication(
28       pkgmgr->GetRequestInfo(), pkgmgr->GetUid())) {
29     LOG(INFO) << "Hybrid package detected";
30     hybrid::HybridInstaller installer(pkgmgr);
31     return (installer.Run() == ci::AppInstaller::Result::OK) ? 0 : 1;
32   } else {
33     wgt::WgtInstaller installer(pkgmgr);
34     return (installer.Run() == ci::AppInstaller::Result::OK) ? 0 : 1;
35   }
36 }