[JIRA IOT-778] fixed the jira issue related to CASendNotification API.
authorhyuna0213.jo <hyuna0213.jo@samsung.com>
Mon, 5 Oct 2015 03:54:16 +0000 (12:54 +0900)
committerPatrick Lankswert <patrick.lankswert@intel.com>
Mon, 5 Oct 2015 13:05:11 +0000 (13:05 +0000)
CASendNotification API is not used by RI layer.
RI layer is using CASendRequest API to send notification.
so we removed the CASendNotification API and modified the CA sample.

Change-Id: I90d490814dcd5e250564ca4f221911fb1c365128
Signed-off-by: hyuna0213.jo <hyuna0213.jo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/3457
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Patrick Lankswert <patrick.lankswert@intel.com>
resource/csdk/connectivity/api/cainterface.h
resource/csdk/connectivity/samples/android/casample/sampleService/src/main/java/org/iotivity/ca/service/MainActivity.java
resource/csdk/connectivity/samples/android/casample/sampleService/src/main/java/org/iotivity/ca/service/RMInterface.java
resource/csdk/connectivity/samples/android/casample/sampleService/src/main/jni/ResourceModel.c
resource/csdk/connectivity/samples/android/casample/sampleService/src/main/jni/org_iotivity_ca_service_RMInterface.h
resource/csdk/connectivity/samples/arduino/casample.cpp
resource/csdk/connectivity/samples/linux/sample_main.c
resource/csdk/connectivity/samples/tizen/casample.c
resource/csdk/connectivity/src/caconnectivitymanager.c
resource/csdk/connectivity/test/ca_api_unittest.cpp

index 85f5733..eb021c3 100644 (file)
@@ -196,16 +196,6 @@ CAResult_t CASendRequest(const CAEndpoint_t *object, const CARequestInfo_t *requ
 CAResult_t CASendResponse(const CAEndpoint_t *object, const CAResponseInfo_t *responseInfo);
 
 /**
- * Send notification to the remote object.
- * @param[in]   object           Endpoint where the payload need to be sent.
- *                               This endpoint is delivered with Request or response callback.
- * @param[in]   responseInfo     Information for the response.
- * @return  ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
- */
-CAResult_t CASendNotification(const CAEndpoint_t *object,
-                      const  CAResponseInfo_t *responseInfo);
-
-/**
  * Select network to use.
  * @param[in]   interestedNetwork    Connectivity Type enum.
  * @return  ::CA_STATUS_OK or ::CA_NOT_SUPPORTED or
index abd6b11..cdc82bd 100755 (executable)
@@ -383,7 +383,7 @@ public class MainActivity extends Activity {
             DLog.v(TAG, "SendNotification click");
             if ( selectedNetwork != -1) {
                 RM.RMSendNotification(mNotification_ed.getText().toString(),
-                    null, selectedNetwork, isSecured, msgType, responseValue);
+                    null, selectedNetwork, isSecured, msgType);
             }
             else {
                 DLog.v(TAG, "Please Select Network Type");
index 39608c5..9b6a6dc 100755 (executable)
@@ -36,7 +36,7 @@ public class RMInterface {
     public native void RMAdvertiseResource(String advertiseResource);
 
     public native void RMSendNotification(String uri, String payload,
-            int selectedNetwork, int isSecured, int msgType, int responseValue);
+            int selectedNetwork, int isSecured, int msgType);
 
     public native void RMSelectNetwork(int interestedNetwork);
 
index c041f83..9e032ee 100644 (file)
@@ -647,8 +647,7 @@ Java_org_iotivity_ca_service_RMInterface_RMSendResponse(JNIEnv *env, jobject obj
 JNIEXPORT void JNICALL
 Java_org_iotivity_ca_service_RMInterface_RMSendNotification(JNIEnv *env, jobject obj, jstring uri,
                                                             jstring payload, jint selectedNetwork,
-                                                            jint isSecured, jint msgType,
-                                                            jint responseValue)
+                                                            jint isSecured, jint msgType)
 {
     LOGI("selectedNetwork - %d", selectedNetwork);
     if (!env || !obj)
@@ -714,11 +713,11 @@ Java_org_iotivity_ca_service_RMInterface_RMSendNotification(JNIEnv *env, jobject
         return;
     }
 
-    CAInfo_t responseData = { 0 };
-    responseData.token = token;
-    responseData.tokenLength = tokenLength;
-    responseData.resourceUri = (CAURI_t) malloc(sizeof(resourceURI));
-    if (NULL == responseData.resourceUri)
+    CAInfo_t requestData = { 0 };
+    requestData.token = token;
+    requestData.tokenLength = tokenLength;
+    requestData.resourceUri = (CAURI_t) malloc(sizeof(resourceURI));
+    if (NULL == requestData.resourceUri)
     {
         LOGE("Memory allocation failed!");
         // destroy token
@@ -727,13 +726,13 @@ Java_org_iotivity_ca_service_RMInterface_RMSendNotification(JNIEnv *env, jobject
         CADestroyEndpoint(endpoint);
         return;
     }
-    memcpy(responseData.resourceUri, resourceURI, sizeof(resourceURI));
+    memcpy(requestData.resourceUri, resourceURI, sizeof(resourceURI));
 
     if (1 == isSecured)
     {
         uint32_t length = sizeof(SECURE_INFO_DATA) + strlen(resourceURI);
-        responseData.payload = (CAPayload_t) malloc(length);
-        if (NULL == responseData.payload)
+        requestData.payload = (CAPayload_t) malloc(length);
+        if (NULL == requestData.payload)
         {
             LOGE("Memory allocation failed!");
             // destroy token
@@ -741,17 +740,17 @@ Java_org_iotivity_ca_service_RMInterface_RMSendNotification(JNIEnv *env, jobject
             // destroy remote endpoint
             CADestroyEndpoint(endpoint);
 
-            free(responseData.resourceUri);
+            free(requestData.resourceUri);
             return;
         }
-        snprintf((char *) responseData.payload, length, SECURE_INFO_DATA, resourceURI, g_localSecurePort);
-        responseData.payloadSize = length;
+        snprintf((char *) requestData.payload, length, SECURE_INFO_DATA, resourceURI, g_localSecurePort);
+        requestData.payloadSize = length;
     }
     else
     {
         uint32_t length = sizeof(NORMAL_INFO_DATA) + strlen(resourceURI);
-        responseData.payload = (CAPayload_t) malloc(length);
-        if (NULL == responseData.payload)
+        requestData.payload = (CAPayload_t) malloc(length);
+        if (NULL == requestData.payload)
         {
             LOGE("Memory allocation failed!");
             // destroy token
@@ -759,21 +758,21 @@ Java_org_iotivity_ca_service_RMInterface_RMSendNotification(JNIEnv *env, jobject
             // destroy remote endpoint
             CADestroyEndpoint(endpoint);
 
-            free(responseData.resourceUri);
+            free(requestData.resourceUri);
             return;
         }
-        snprintf((char *) responseData.payload, length, NORMAL_INFO_DATA, resourceURI);
-        responseData.payloadSize = length;
+        snprintf((char *) requestData.payload, length, NORMAL_INFO_DATA, resourceURI);
+        requestData.payloadSize = length;
     }
 
-    responseData.type = messageType;
+    requestData.type = messageType;
 
-    CAResponseInfo_t responseInfo = { 0 };
-    responseInfo.result = responseValue;
-    responseInfo.info = responseData;
+    CARequestInfo_t requestInfo = { 0 };
+    requestInfo.method = CA_GET;
+    requestInfo.info = requestData;
 
     // send notification
-    if (CA_STATUS_OK != CASendNotification(endpoint, &responseInfo))
+    if (CA_STATUS_OK != CASendRequest(endpoint, &requestInfo))
     {
         LOGE("Could not send notification");
     }
@@ -786,8 +785,8 @@ Java_org_iotivity_ca_service_RMInterface_RMSendNotification(JNIEnv *env, jobject
     // destroy remote endpoint
     CADestroyEndpoint(endpoint);
 
-    free(responseData.payload);
-    free(responseData.resourceUri);
+    free(requestData.payload);
+    free(requestData.resourceUri);
 }
 
 JNIEXPORT void JNICALL
index b2a5d66..48f82f8 100644 (file)
@@ -78,7 +78,7 @@ JNIEXPORT void JNICALL Java_org_iotivity_ca_service_RMInterface_RMSendResponse
  * Signature: (Ljava/lang/String;Ljava/lang/String;IIII)V
  */
 JNIEXPORT void JNICALL Java_org_iotivity_ca_service_RMInterface_RMSendNotification
-  (JNIEnv *, jobject, jstring, jstring, jint, jint, jint, jint);
+  (JNIEnv *, jobject, jstring, jstring, jint, jint, jint);
 
 /*
  * Class:     org_iotivity_ca_service_RMInterface
index 5d18828..273ed08 100644 (file)
@@ -514,20 +514,20 @@ void SendNotification()
         return;
     }
 
-    CAInfo_t respondData = {CA_MSG_NONCONFIRM};
-    respondData.token = token;
-    respondData.tokenLength = tokenLength;
-    respondData.payload = (CAPayload_t)"Notification Data";
-    respondData.payloadSize = strlen((const char *) respondData.payload);
-    respondData.resourceUri = (char *)OICMalloc(strlen(resourceUri) + 1);
-    strcpy(respondData.resourceUri, resourceUri);
+    CAInfo_t requestData = {CA_MSG_NONCONFIRM};
+    requestData.token = token;
+    requestData.tokenLength = tokenLength;
+    requestData.payload = (CAPayload_t)"Notification Data";
+    requestData.payloadSize = strlen((const char *) requestData.payload);
+    requestData.resourceUri = (char *)OICMalloc(strlen(resourceUri) + 1);
+    strcpy(requestData.resourceUri, resourceUri);
 
-    CAResponseInfo_t responseInfo = {CA_BAD_REQ, {CA_MSG_RESET}};
-    responseInfo.result = CA_CONTENT;
-    responseInfo.info = respondData;
+    CARequestInfo_t requestInfo = {CA_GET, {CA_MSG_RESET}};
+    requestInfo.method = CA_GET;
+    requestInfo.info = requestData;
 
     // send request
-    CASendNotification(endpoint, &responseInfo);
+    CASendRequest(endpoint, &requestInfo);
     // destroy remote endpoint
     if (NULL != endpoint)
     {
index 57063bf..5e10a8d 100644 (file)
@@ -779,7 +779,7 @@ void send_notification()
     CAPayload_t payload = (CAPayload_t) "TempNotificationData";
     size_t payloadSize = strlen((const char *) payload);
 
-    CAInfo_t respondData = { .type = messageType,
+    CAInfo_t requestData = { .type = messageType,
                              .messageId = 0,
                              .token = token,
                              .tokenLength = tokenLength,
@@ -787,13 +787,13 @@ void send_notification()
                              .numOptions = 0,
                              .payload = payload,
                              .payloadSize = payloadSize,
-                             .resourceUri = (CAURI_t)uri };
+                             .resourceUri = (CAURI_t) uri };
 
-    CAResponseInfo_t responseInfo = { .result = CA_CONTENT,
-                                      .info = respondData };
+    CARequestInfo_t requestInfo = { .method = CA_GET,
+                                    .info = requestData };
 
     // send request
-    res = CASendNotification(endpoint, &responseInfo);
+    res = CASendRequest(endpoint, &requestInfo);
     if (CA_STATUS_OK != res)
     {
         printf("Send notification error, error code: %d\n", res);
index 88396ee..162b512 100644 (file)
@@ -770,20 +770,20 @@ void send_notification()
 
     printf("Generated token %s\n", token);
 
-    CAInfo_t respondData = { 0 };
-    respondData.token = token;
-    respondData.tokenLength = tokenLength;
-    respondData.payload = (CAPayload_t) "TempNotificationData";
-    respondData.payloadSize = strlen((const char *) respondData.payload);
-    respondData.type = messageType;
-    respondData.resourceUri = (CAURI_t)uri;
+    CAInfo_t requestData = { 0 };
+    requestData.token = token;
+    requestData.tokenLength = tokenLength;
+    requestData.payload = (CAPayload_t) "TempNotificationData";
+    requestData.payloadSize = strlen((const char *) requestData.payload);
+    requestData.type = messageType;
+    requestData.resourceUri = (CAURI_t)uri;
 
-    CAResponseInfo_t responseInfo = { 0 };
-    responseInfo.result = CA_CONTENT;
-    responseInfo.info = respondData;
+    CARequestInfo_t requestInfo = { 0 };
+    requestInfo.method = CA_GET;
+    requestInfo.info = requestData;
 
     // send notification
-    res = CASendNotification(endpoint, &responseInfo);
+    res = CASendRequest(endpoint, &requestInfo);
     if (CA_STATUS_OK != res)
     {
         printf("Send notification error, error code: %d\n", res);
index b97b0ff..9f6aef8 100644 (file)
@@ -248,18 +248,6 @@ CAResult_t CASendRequest(const CAEndpoint_t *object,const CARequestInfo_t *reque
     return CADetachRequestMessage(object, requestInfo);
 }
 
-CAResult_t CASendNotification(const CAEndpoint_t *object, const CAResponseInfo_t *responseInfo)
-{
-    OIC_LOG(DEBUG, TAG, "CASendNotification");
-
-    if(!g_isInitialized)
-    {
-        return CA_STATUS_NOT_INITIALIZED;
-    }
-
-    return CADetachResponseMessage(object, responseInfo);
-}
-
 CAResult_t CASendResponse(const CAEndpoint_t *object, const CAResponseInfo_t *responseInfo)
 {
     OIC_LOG(DEBUG, TAG, "CASendResponse");
index 433cf8c..7d66ab8 100644 (file)
@@ -397,46 +397,6 @@ TEST_F(CATests, SendResponseTest)
     }
 }
 
-// CASendNotification TC
-// check return value
-TEST(SendNotificationTest, DISABLED_TC_22_Positive_01)
-{
-    addr = (char *) ADDRESS;
-    CACreateEndpoint(CA_DEFAULT_FLAGS, CA_ADAPTER_IP, addr, PORT, &tempRep);
-
-    memset(&responseData, 0, sizeof(CAInfo_t));
-    responseData.type = CA_MSG_NONCONFIRM;
-    responseData.payload = (CAPayload_t)malloc(sizeof("Temp Notification Data"));
-
-    EXPECT_TRUE(responseData.payload != NULL);
-    if(!responseData.payload)
-    {
-        CADestroyEndpoint(tempRep);
-        return;
-    }
-
-    memcpy(responseData.payload, "Temp Notification Data", sizeof("Temp Notification Data"));
-    responseData.payloadSize = sizeof("Temp Notification Data");
-
-    CAGenerateToken(&tempToken, tokenLength);
-    requestData.token = tempToken;
-    requestData.tokenLength = tokenLength;
-
-    memset(&responseInfo, 0, sizeof(CAResponseInfo_t));
-    responseInfo.result = CA_CONTENT;
-    responseInfo.info = responseData;
-
-    EXPECT_EQ(CA_STATUS_OK, CASendNotification(tempRep, &responseInfo));
-
-    CADestroyToken(tempToken);
-    if (tempRep != NULL)
-    {
-        CADestroyEndpoint(tempRep);
-        tempRep = NULL;
-    }
-    free(responseData.payload);
-}
-
 // CASelectNewwork TC
 // check return value
 TEST_F(CATests, SelectNetworkTestGood)