112e6734ddd4e84da587690d7b4441e17cf677cd
[platform/core/security/krate.git] / lib / app-proxy.cpp
1 /*
2  *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *  Licensed under the Apache License, Version 2.0 (the "License");
5  *  you may not use this file except in compliance with the License.
6  *  You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License
15  */
16 #include "rmi/app-proxy.h"
17
18 namespace Krate {
19
20 AppProxy::AppProxy(KrateControlContext& ctx)
21         : context(ctx)
22 {
23 }
24
25 AppProxy::~AppProxy()
26 {
27 }
28
29 AppProxy::AppInfo AppProxy::getAppInfo(const std::string& name, const std::string& appid)
30 {
31         try {
32                 return context->methodCall<AppProxy::AppInfo>("AppProxy::getAppInfo", name, appid);
33         } catch (runtime::Exception& e) {}
34         return AppProxy::AppInfo();
35 }
36
37 int AppProxy::createIterator(const std::string& krate)
38 {
39         try {
40                 return context->methodCall<int>("AppProxy::createIterator", krate);
41         } catch (runtime::Exception& e) {}
42         return -1;
43 }
44
45 AppProxy::AppInfo AppProxy::getIteratorValue(int iterator)
46 {
47         try {
48                 return context->methodCall<AppProxy::AppInfo>("AppProxy::getIteratorValue", iterator);
49         } catch (runtime::Exception& e) {}
50         return AppProxy::AppInfo();
51 }
52
53 bool AppProxy::nextIterator(int iterator)
54 {
55         try {
56                 return context->methodCall<bool>("AppProxy::nextIterator", iterator);
57         } catch (runtime::Exception& e) {}
58         return false;
59 }
60
61 int AppProxy::destroyIterator(int iterator)
62 {
63         try {
64                 return context->methodCall<int>("AppProxy::destroyIterator", iterator);
65         } catch (runtime::Exception& e) {}
66         return -1;
67 }
68
69 int AppProxy::launch(const std::string& name, const AppProxy::Bundle& bundle)
70 {
71         try {
72                 return context->methodCall<int>("AppProxy::launch", name, bundle);
73         } catch (runtime::Exception& e) {
74                 return -1;
75         }
76 }
77
78 int AppProxy::resume(const std::string& name, const std::string& appid)
79 {
80         try {
81                 return context->methodCall<int>("AppProxy::resume", name, appid);
82         } catch (runtime::Exception& e) {
83                 return -1;
84         }
85 }
86
87 int AppProxy::terminate(const std::string& name, const std::string& appid)
88 {
89         try {
90                 return context->methodCall<int>("AppProxy::terminate", name, appid);
91         } catch (runtime::Exception& e) {
92                 return -1;
93         }
94 }
95
96 bool AppProxy::isRunning(const std::string& name, const std::string& appid)
97 {
98         try {
99                 return context->methodCall<bool>("AppProxy::isRunning", name, appid);
100         } catch (runtime::Exception& e) {
101                 return -1;
102         }
103 }
104
105 } // namespace Krate