2 * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include "log-private.hh"
22 Job::Job(int status, std::string id, tizen_base::Bundle data)
23 : status_(status), id_(std::move(id)), data_(std::move(data)) {
31 int Job::GetStatus() const {
35 const std::string& Job::GetId() const {
39 bundle* Job::GetData() const {
40 return data_.GetHandle();
43 void Job::SetEventListener(IEvent* listener) {
48 void Job::SetTimer() {
50 timer_ = g_timeout_add(5000, TimedOutCb, this);
52 _E("g_timeout_add() is failed");
57 void Job::UnsetTimer() {
60 g_source_remove(timer_);
66 void Job::SetIdler() {
68 idler_ = g_idle_add(IdleCb, this);
70 _E("g_idle_add() is failed"); // LCOV_EXCL_LINE
74 void Job::UnsetIdler() {
77 g_source_remove(idler_);
84 gboolean Job::TimedOutCb(gpointer data) {
85 auto* handle = static_cast<Job*>(data);
88 auto* listener = handle->listener_;
89 if (listener != nullptr)
90 listener->OnTimedOut(handle);
92 return G_SOURCE_REMOVE;
96 gboolean Job::IdleCb(gpointer data) {
97 auto* handle = static_cast<Job*>(data);
99 auto* listener = handle->listener_;
100 if (listener != nullptr)
101 listener->OnRun(handle);
103 return G_SOURCE_REMOVE;
106 } // namespace tizen_cpp