2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Contact: Jin Yoon <jinny.yoon@samsung.com>
5 * Geunsun Lee <gs86.lee@samsung.com>
6 * Eunyoung Lee <ey928.lee@samsung.com>
7 * Junkyu Han <junkyu.han@samsung.com>
8 * Jeonghoon Park <jh1979.park@samsung.com>
10 * Licensed under the Flora License, Version 1.1 (the License);
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://floralicense.org/license/
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an AS IS BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
25 #include <curl/curl.h>
28 static int _web_notify(const char *resource, const char *data)
32 curl = curl_easy_init();
36 _E("fail to init curl");
40 curl_easy_setopt(curl, CURLOPT_URL, resource);
41 curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
43 response = curl_easy_perform(curl);
45 if(response != CURLE_OK) {
46 _E("curl_easy_perform() failed: %s",
47 curl_easy_strerror(response));
51 curl_easy_cleanup(curl);
56 int web_notify_init(void)
60 result = curl_global_init(CURL_GLOBAL_DEFAULT);
61 if(result != CURLE_OK) {
62 _E("curl_global_init() failed: %s",
63 curl_easy_strerror(result));
69 void web_notify_fini(void)
71 curl_global_cleanup();
75 int web_notify_data(const char *resource, const char *data)
77 return _web_notify(resource, data);
80 int web_notify_bool(const char *resource, bool value)
84 _D("Notify to %s - value[%d]", resource, value);
87 ret = _web_notify(resource, "TRUE");
89 ret = _web_notify(resource, "FALSE");
94 int web_notify_int(const char *resource, int value)
99 data = g_strdup_printf("%d", value);
100 retv_if(NULL == data, -1);
102 ret = _web_notify(resource, data);
108 int web_notify_double(const char *resource, double value)
113 data = g_strdup_printf("%lf", value);
114 retv_if(NULL == data, -1);
116 ret = _web_notify(resource, data);