Implements WatchBase
[platform/core/appfw/widget-viewer.git] / watch-holder / src / watch_holder.cc
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
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 <aul.h>
17 #include <dlog.h>
18 #include <app_control_internal.h>
19 #include <app_control.h>
20 #include <appsvc.h>
21 #include <aul_svc.h>
22 #include <screen_connector_remote_surface_evas/util.h>
23
24 #include "util.hh"
25 #include "watch_holder.hh"
26 #include "bundle_cpp.h"
27
28 #ifdef LOG_TAG
29 #undef LOG_TAG
30 #endif
31
32 #define LOG_TAG "WATCH_HOLDER"
33
34 using namespace tizen_base;
35 using namespace std;
36 namespace watch_holder {
37
38 WatchHolder::~WatchHolder() = default;
39
40 WatchHolder::WatchHolder(Evas_Object* win) :
41     WatchHolderBase(screen_connector::util::GetWlSurface(win),
42       util::GetWidth(win), util::GetHeight(win)), viewer_win_(win) {
43 }
44
45 std::shared_ptr<WatchBase> WatchHolder::CreateWatch(std::string appid,
46     bool mock) {
47   return make_shared<Watch>(
48     std::move(appid), viewer_win_, this, mock);
49 }
50
51 std::shared_ptr<WatchBase> WatchHolder::CreateWatch(int rid, std::string id,
52     std::string appid, bool mock) {
53   return make_shared<Watch>(rid, std::move(id),
54       std::move(appid), viewer_win_, this, mock);
55 }
56
57 std::shared_ptr<WatchBase> WatchHolder::CreateWatch(std::string appid,
58     tizen_base::Bundle extra, bool mock) {
59   return make_shared<Watch>(std::move(appid), viewer_win_, std::move(extra),
60       this, mock);
61 }
62
63 std::shared_ptr<WatchBase> WatchHolder::CreateWatch(int rid, std::string id,
64     std::string appid, tizen_base::Bundle extra, bool mock) {
65   return make_shared<Watch>(rid, std::move(id), std::move(appid),
66       viewer_win_, std::move(extra), this, mock);
67 }
68
69 shared_ptr<Watch> WatchHolder::Cast(shared_ptr<WatchBase> watch) {
70   return dynamic_pointer_cast<Watch>(watch);
71 }
72
73 const Watch& WatchHolder::Cast(const WatchBase& watch) {
74   return dynamic_cast<const Watch&>(watch);
75 }
76
77
78 }  // namespace watch_holder