[Resource-Encapsulation] [IOT-1026] Fixed Jira Issue
authorJay Sharma <jay.sharma@samsung.com>
Mon, 28 Mar 2016 11:27:00 +0000 (16:57 +0530)
committerUze Choi <uzchoi@samsung.com>
Tue, 12 Apr 2016 05:31:15 +0000 (05:31 +0000)
Change-Id: I216c46097a85590ba927fe74c56b74b848a5611f
Signed-off-by: Jay Sharma <jay.sharma@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/6293
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
(cherry picked from commit c055363558b594263a523f54d5016463d64eb872)
Reviewed-on: https://gerrit.iotivity.org/gerrit/7679

service/resource-encapsulation/examples/tizen/RESampleClientApp/src/reclient.cpp

index 8761e1d..e344056 100644 (file)
@@ -538,27 +538,69 @@ popup_set_clicked_cb(void *data, Evas_Object *obj, void *event_info)
     const char *attributeString = elm_entry_entry_get(entry);
     // Remove white spaces(if any) at the beginning
     int beginning = 0;
+    int negative = 0;
+    int invalidflag = 0;
+
     while (attributeString[beginning] == ' ')
     {
         (beginning)++;
     }
 
     int len = strlen(attributeString);
-    if (NULL == attributeString || 1 > len)
+
+    if((len >= 1) && ( '-' == attributeString[0]))
+    {
+        negative = 1;
+    }
+
+    if(((len > 3) && negative) || (len > 2 && (!negative)) || (len==1 && negative))
     {
-        dlog_print(DLOG_INFO, LOG_TAG, "#### Read NULL attribute Value");
-        string logMessage = g_attributeKey + " Cannot be NULL<br>";
+        invalidFlag = 1;
+        dlog_print(DLOG_INFO, LOG_TAG, "#### Not in allowed Range [-99 to 99]");
+        string logMessage = g_attributeKey + " Not in allowed Range [-99 to 99]<br>";
         logMessage += "----------------------<br>";
         dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
-        ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateGroupLog, &logMessage);
+        ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateGroupLog,
+                                                            &logMessage);
     }
     else
     {
+        if (NULL == attributeString || 1 > len)
+        {
+            invalidFlag = 1;
+            dlog_print(DLOG_INFO, LOG_TAG, "#### Read NULL attribute Value");
+            string logMessage = g_attributeKey + " Cannot be NULL<br>";
+            logMessage += "----------------------<br>";
+            dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
+            ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateGroupLog,
+                                                             &logMessage);
+        }
+        else
+        {
+            int i = 0;
+            while(i < len)
+            {
+                if(attributeString[i] < '0' || attributeString[i] > '9')
+                {
+                    invalidFlag = 1;
+                    dlog_print(DLOG_INFO, LOG_TAG, "#### Read invalid attribute Value");
+                    string logMessage = g_attributeKey + " Invalid charaters in input<br>";
+                    logMessage += "----------------------<br>";
+                    dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
+                    ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateGroupLog,
+                                                              &logMessage);
+                }
+                i++;
+            }
+        }
+    }
+
+    if(invalidFlag != 1)
+    {
         int attributeValue = atoi(attributeString);
         string attrString(attributeString);
         setAttributeToRemoteServer(attributeValue);
         dlog_print(DLOG_INFO, LOG_TAG, "#### Attribute to set : %d", attributeValue);
-
         string logMessage = g_attributeKey + " to set : " + attrString + "<br>";
         logMessage += "----------------------<br>";
         dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());