From: Sang-Hun Chung Date: Wed, 3 Jan 2018 05:49:32 +0000 (+0900) Subject: samsung account activation logic added X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e89a0a8f99f5fad7ff18c5521c75e48d67ee228e;p=platform%2Fcore%2Fservice%2Fcloud%2Fua-client.git samsung account activation logic added Change-Id: I559a3ef39db4bf0e60bcc6c775aea30f9a7b1e4c --- diff --git a/inc/agent_util.h b/inc/agent_util.h index 548d05a..cd0a157 100755 --- a/inc/agent_util.h +++ b/inc/agent_util.h @@ -6,6 +6,7 @@ */ #include #include +#include #ifdef __cplusplus extern "C" { @@ -14,6 +15,11 @@ extern "C" { int send_request(char *appid, char *operation, char *json, hello_cb user_cb, void* user_data); +int send_request_with_app_reply(char *appid, char *operation, char *json, + app_control_reply_cb reply_cb, void* user_data); + + + int proxy_send_command(const char *bus_name, const char *bus_obj, const char *bus_if, int cmd_type, GVariant *cmd_param, GVariant **cmd_ret); diff --git a/inc/http_util.h b/inc/http_util.h new file mode 100755 index 0000000..7e2bec8 --- /dev/null +++ b/inc/http_util.h @@ -0,0 +1,30 @@ +#ifndef _HTTP_UTIL_H_ +#define _HTTP_UTIL_H_ + +/** + * This header file is included to define _EXPORT_. + */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + HTTP_GET = 0, + HTTP_POST, + HTTP_PUT, + HTTP_DELETE +} http_req_e; + +typedef struct curl_slist curl_slist; + +int http_send_request(http_req_e type, char *req_url, curl_slist *header, char *json, + char **res_header, char **res_body); +int http_download_file(const char *download_url, const char *download_path); + +#ifdef __cplusplus +} +#endif +#endif // _HTTP_UTIL_H_ + diff --git a/inc/service_agent_lib.h b/inc/service_agent_lib.h index eb1718c..20e8aff 100755 --- a/inc/service_agent_lib.h +++ b/inc/service_agent_lib.h @@ -25,6 +25,7 @@ int get_name_by_id(int id, char** name); typedef enum ERROR_CODE { SSE_ERROR_NONE = 0, SSE_ERROR_APP_CONTROL, + SSE_ERROR_OTHER_MODULE, SSE_ERROR_NULL_PTR, SSE_ERROR_MEM_ALLOC, SSE_ERROR_NOT_SUPPORTED, diff --git a/src/agent_util.c b/src/agent_util.c index 1a4a5aa..ab212b4 100755 --- a/src/agent_util.c +++ b/src/agent_util.c @@ -14,7 +14,7 @@ } while (0) #define ERROR_LOG(fmt, ...) do { \ - dlog_print(DLOG_INFO, LOG_TAG, "%s : %s(%d) > "fmt, rindex(__FILE__, '/')+1, __FUNCTION__, __LINE__,##__VA_ARGS__);\ + dlog_print(DLOG_ERROR, LOG_TAG, "%s : %s(%d) > "fmt, rindex(__FILE__, '/')+1, __FUNCTION__, __LINE__,##__VA_ARGS__);\ } while (0) @@ -47,6 +47,7 @@ _wrapper_cb(app_control_h request, app_control_h reply, int send_request(char *appid, char *operation, char *json, hello_cb user_cb, void* user_data) { + DEBUG_LOG("enter"); if (!appid || !operation) { ERROR_LOG("uri NULL[%p], operation NULL[%p]", appid, operation); return SSE_ERROR_NULL_PTR; //temp:error_code NULL @@ -93,6 +94,44 @@ out: } +int send_request_with_app_reply(char *appid, char *operation, char *json, + app_control_reply_cb reply_cb, void* user_data) +{ + DEBUG_LOG("enter"); + if (!appid || !operation) { + ERROR_LOG("uri NULL[%p], operation NULL[%p]", appid, operation); + return SSE_ERROR_NULL_PTR; //temp:error_code NULL + } + + int ret = 0; //temp:error_code sucess + app_control_h request = NULL; + if ((ret = app_control_create(&request)) != APP_CONTROL_ERROR_NONE) { + ERROR_LOG("app_control_create error[%d]", ret); + ret = -1; //temp: error_code other module + goto out; + } + if ((ret=app_control_set_app_id(request, appid)) != APP_CONTROL_ERROR_NONE) { + ERROR_LOG("app_control_set_app_id error[%d]", ret); + ret = -1; //temp: error_code other module + goto out; + } + if ((ret=app_control_set_operation(request, operation)) != APP_CONTROL_ERROR_NONE) { + ERROR_LOG("app_control_set_operation error[%d]", ret); + ret = -1; //temp: error_code other module + goto out; + } + + ret = app_control_send_launch_request(request, reply_cb, (void*)user_data); + if (ret != APP_CONTROL_ERROR_NONE) { + ERROR_LOG("app_control_send_launch_request error[%d]", ret); + ret = -1; //temp: error_code other module + } + +out: + app_control_destroy(request); + return ret; +} + #if 0 #define DBUS_SERVICE_DBUS "org.freedesktop.DBus" diff --git a/src/http_util.c b/src/http_util.c index 86c662b..f521438 100755 --- a/src/http_util.c +++ b/src/http_util.c @@ -1,16 +1,16 @@ -#include #include -//#include "staticlibrary.h" -//#include +#include "http_util.h" +#include +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "SSE_HTTP" -typedef enum { - FMWUP_HTTP_GET = 0, - FMWUP_HTTP_POST, - FMWUP_HTTP_PUT, - FMWUP_HTTP_DELETE -} fmwup_http_req_e; - +#define ERROR_LOG(fmt, ...) do { \ + dlog_print(DLOG_ERROR, LOG_TAG, "%s : %s(%d) > "fmt,\ + rindex(__FILE__, '/')+1, __FUNCTION__, __LINE__,##__VA_ARGS__);\ + } while (0) static size_t _gather_data(void *downloaded_data, size_t size, @@ -114,22 +114,20 @@ void _curl_set_common_option(CURL *curl, } -static void _curl_set_request_headers(CURL *curl) +static void _curl_set_request_headers(CURL *curl, curl_slist *header) { - struct curl_slist *header = NULL; - - char *tmp_header = NULL; - - tmp_header = g_strconcat("Content-Type: ", "application/json", NULL); - //LOG("header=[%s]", tmp_header); - header = curl_slist_append(header, tmp_header); - g_free(tmp_header); - + if (!header) { + char *tmp_header = NULL; + tmp_header = g_strconcat("Content-Type: ", "application/json", NULL); + header = curl_slist_append(header, tmp_header); + g_free(tmp_header); + } curl_easy_setopt(curl, CURLOPT_HTTPHEADER, header); } -int http_send_request(fmwup_http_req_e type, char *req_url, char **res_header, char **res_body) +int http_send_request(http_req_e type, char *req_url, curl_slist *header, char *json, + char **res_header, char **res_body) { //LOG("Enter http_send_request()"); @@ -144,11 +142,11 @@ int http_send_request(fmwup_http_req_e type, char *req_url, char **res_header, c //LOG("curl_easy_init()"); - _curl_set_request_headers(curl); + _curl_set_request_headers(curl, header); - if (type == FMWUP_HTTP_GET) { + if (type == HTTP_GET) { curl_easy_setopt(curl, CURLOPT_HTTPGET, 1); - } else if (type == FMWUP_HTTP_POST) { + } else if (type == HTTP_POST) { curl_easy_setopt(curl, CURLOPT_HTTPPOST, 1); } else { return -1; @@ -162,9 +160,11 @@ int http_send_request(fmwup_http_req_e type, char *req_url, char **res_header, c if (error_code == CURLE_ABORTED_BY_CALLBACK) { ret = -1; + ERROR_LOG("curl_easy_perform(curl) error with %s (%d)", curl_easy_strerror(error_code), error_code); goto _END_OF_FUNC_; } else if (error_code != CURLE_OK) { ret = -1; + ERROR_LOG("curl_easy_perform(curl) error with %s (%d)", curl_easy_strerror(error_code), error_code); goto _END_OF_FUNC_; } diff --git a/src/service_agent_lib.c b/src/service_agent_lib.c index 282a050..8c2a302 100755 --- a/src/service_agent_lib.c +++ b/src/service_agent_lib.c @@ -123,6 +123,14 @@ int get_name_by_id(int id, char** name) return 1; } + +int register_service(char *appid, int server_id) +{ + + return 0; +} + + #if 0 #include