Improve log
[platform/core/uifw/capi-ui-sticker.git] / receiver / src / message.cpp
1 /*
2  * Copyright (c) 2020 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
17 #include <stdlib.h>
18 #include <app_event.h>
19
20 #include "message.h"
21 #include "log.h"
22 #include "config.h"
23
24 #define EVENT_NAME "event.org.tizen.sticker-receiver.user_event"
25
26 bool send_message(const char *cmd, const char *data)
27 {
28     bool result = false;
29     int ret;
30
31     bundle *b = bundle_create();
32     bundle_add_str(b, "command", cmd);
33     if (data)
34         bundle_add_str(b, "data", data);
35
36     ret = event_publish_app_event(EVENT_NAME, b);
37     if (ret != EVENT_ERROR_NONE) {
38         result = false;
39         STLOGE("Failed to send message by event publish. error : %d", ret);
40     }
41     else
42     {
43         result = true;
44     }
45
46     bundle_free(b);
47
48     return result;
49 }