static library api test - reading DB on shared data path(get_name_by_id), doing some... 24/149524/1
authorSang-Hun Chung <sanghun.chung@samsung.com>
Tue, 12 Sep 2017 10:53:06 +0000 (19:53 +0900)
committerSang-Hun Chung <sanghun.chung@samsung.com>
Tue, 12 Sep 2017 10:53:06 +0000 (19:53 +0900)
Change-Id: I42af917b2fe29c5eeb162451fe15d0cc9d3bc191

inc/cloud-application.h
src/cloud-application.c
tizen-manifest.xml

index 712077c6f3a05a8909ed050459708cc774f64701..00199f09cc65053da44b3eb5affd950fd370e794 100755 (executable)
@@ -8,7 +8,7 @@
 #undef  LOG_TAG
 #endif
 #define LOG_TAG "FMW_APP"
-#define LOG_DBG(fmt, ...) do { \
+#define DEBUG_LOG(fmt, ...) do { \
                dlog_print(DLOG_INFO, LOG_TAG, "%s : %s(%d) > "fmt, rindex(__FILE__, '/')+1, __FUNCTION__, __LINE__,##__VA_ARGS__);\
        } while (0)
 
index ca82912a214ce29be6c5028af102d8ade6649af0..afe1aefed1427af267a5c9c3a5f9ec462dba8f4a 100755 (executable)
@@ -9,17 +9,11 @@
 #include <unistd.h>
 #include <errno.h>
 
-#if 0
-static void __result_cb(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data)
-{
-       LOG_DBG("");
-}
-#endif
 
 void _result(int ret, char* echo, void* data)
 {
-       LOG_DBG("ret %d", ret);
-       LOG_DBG("echo %s", echo);
+       DEBUG_LOG("ret %d", ret);
+       DEBUG_LOG("echo %s", echo);
 }
 
 bool service_app_create(void *data)
@@ -34,26 +28,31 @@ void service_app_terminate(void *data)
        return;
 }
 
+
+
 void service_app_control(app_control_h app_control, void *data)
 {
-       LOG_DBG("started");
-       LOG_DBG("sum %d", test_sum(1,2));
-
+       /* static library function test */
+       DEBUG_LOG("sum %d", test_sum(1,2));
 
+       /* IPC test using app_control */
        hello(_result, NULL);
 
-#if 0
-       app_control_h request;
-       app_control_create(&request);
-       app_control_set_app_id(request, "org.example.fmw_update_service");
-       app_control_set_operation(request, "http://tizen.org/appcontrol/operation/cloud-service/upload");
-       int ret = app_control_send_launch_request(request, __result_cb, NULL);
-       if (ret != APP_CONTROL_ERROR_NONE) {
-               LOG_DBG("app_control_send_launch_request error %d", ret);
-               return;
+       /* DB read test with shared data path */
+       char *name;
+       get_name_by_id(1, &name);
+
+       /* rest API test with curl */
+       char *request_uri = "http://iotm-dev-core-external-elb-1621836102.ap-northeast-1.elb.amazonaws.com/api/v1/fota/downloadUrl/?currentVersion=111&token=ZjExNGM1MGUtMWE5YS00NDJiLWE2ZGItNmUzZGM0Y2I4MGE4LnppcA==";
+       char *res_header = NULL;
+       char *res_body = NULL;
+       int ret = http_send_request(FMWUP_HTTP_GET, request_uri, &res_header, &res_body);
+       if( ret != 0) {
+               DEBUG_LOG("http_send_request error %d", ret);
+       }
+       else {
+               DEBUG_LOG("res_body [%s]", res_body);
        }
-#endif
-
        return;
 }
 
@@ -106,7 +105,7 @@ int socket_connect()
 {
        int sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
        if (sockfd < 0) {
-               LOG_DBG("socket error %d", sockfd);
+               DEBUG_LOG("socket error %d", sockfd);
                return -1;
        }
 
@@ -120,7 +119,7 @@ int socket_connect()
        int len = strlen(serverSA.sun_path) + sizeof(serverSA.sun_family);
        int err = connect(sockfd, (struct sockaddr *)&serverSA, len);
        if (err < 0 ) {
-               LOG_DBG("connect error %d, errno %d", err, errno);
+               DEBUG_LOG("connect error %d, errno %d", err, errno);
                /*
                if(errno == EACCES)
                        THROW(MsgException::SECURITY_ERROR, "cannot connect server %s", g_strerror(errno));
@@ -131,9 +130,9 @@ int socket_connect()
        }
 
        char buf[20] = "hello";
-       LOG_DBG("POST [%s]", buf);
+       DEBUG_LOG("POST [%s]", buf);
        err = write(sockfd, (const void*) buf, strlen(buf));
-       LOG_DBG("write error %d", err);
+       DEBUG_LOG("write error %d", err);
 
        return 0;
 }
index 8696f027eb3e0e1c39c1814e999f9f3fa8102003..5de2e139b238c93fe4929cc5fa433c9c3b19ac66 100644 (file)
@@ -6,6 +6,8 @@
         <icon>tizen-service-app.png</icon>
     </service-application>
     <privileges>
+        <privilege>http://tizen.org/privilege/appdir.shareddata</privilege>
         <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
+        <privilege>http://tizen.org/privilege/internet</privilege>
     </privileges>
 </manifest>