From: hyunho Date: Wed, 26 Feb 2020 07:01:15 +0000 (+0900) Subject: Add missing files X-Git-Tag: submit/tizen/20200226.074332~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c7ed0cb214060356d160097c29919002cd5506cd;p=platform%2Fcore%2Fappfw%2Fwidget-viewer.git Add missing files Change-Id: I7ef4b60c45578b136656bb8b1fa411602a5579d4 Signed-off-by: hyunho --- diff --git a/watch-holder/src/ambient_listener.cc b/watch-holder/src/ambient_listener.cc new file mode 100644 index 00000000..48bf5952 --- /dev/null +++ b/watch-holder/src/ambient_listener.cc @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include + +#include +#include +#include +#include +#include + +#include "common.hh" +#include "ambient_listener.hh" + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#define LOG_TAG "WATCH_HOLDER" + +using namespace tizen_base; +using namespace std; +namespace watch_holder { + AmbientListener::AmbientListener() { + if (aul_app_com_create("watch.ambientchange", nullptr, OnAmbientChangedSignal, + this, &ambient_changed_signal_conn_) != AUL_R_OK) { + LOGE("Failed to listen watch.launch signal"); + } + } + + AmbientListener::~AmbientListener() { + if (ambient_changed_signal_conn_) + aul_app_com_leave(ambient_changed_signal_conn_); + } +} diff --git a/watch-holder/src/ambient_listener.hh b/watch-holder/src/ambient_listener.hh new file mode 100644 index 00000000..bb73255d --- /dev/null +++ b/watch-holder/src/ambient_listener.hh @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __WATCH_HOLDER_AMBIENT_LISTENER_HH__ +#define __WATCH_HOLDER_AMBIENT_LISTENER_HH__ + +#include +#include + +#include "common.hh" + +namespace watch_holder { + +class AmbientListener { + public: + AmbientListener(); + ~AmbientListener(); + static int OnAmbientChangedSignal(const char *endpoint, + aul_app_com_result_e e, bundle *envelope, void *user_data) { + tizen_base::Bundle data(envelope, false, false); + AmbientListener* listener = (AmbientListener*)user_data; + std::string mode = data.GetString("__AMBIENT_MODE__"); + std::string extra = data.GetString("__AMBIENT_EXTRA__"); + if (mode.empty()) + return 0; + + tizen_base::Bundle extra_data; + bool enter; + try { + extra_data = tizen_base::Bundle(extra); + enter = (bool)stoi(mode); + } catch (const std::exception& e) { + return 0; + } + listener->OnAmbientChanged(enter, extra_data); + return 0; + } + + virtual void OnAmbientChanged(bool enter, tizen_base::Bundle& extra) = 0; + + private: + aul_app_com_connection_h ambient_changed_signal_conn_; +}; + +} // namespace watch_holder + +#endif // __WATCH_HOLDER_AMBIENT_LISTENER_HH__ \ No newline at end of file