added struct, enum and modified struct, enum
[platform/upstream/iotivity.git] / service / notification / src / consumer / NSConsumerCommon.h
index 00d7612..350c704 100644 (file)
@@ -28,10 +28,9 @@ extern "C" {
 #include <stdio.h>
 #include <stdbool.h>
 
-#include "NSCommon.h"
+#include "NSConsumerInterface.h"
 #include "NSStructs.h"
 #include "ocstack.h"
-#include "NSConsumerInterface.h"
 
 #define NS_QOS OC_LOW_QOS
 #define NS_RESOURCE_TYPE "oic.r.notification"
@@ -42,8 +41,49 @@ extern "C" {
 
 #define NS_DISCOVER_QUERY "/oic/res?rt=oic.r.notification"
 
-typedef OCStackApplicationResult (*onRIResponseListener)(
-        void *, OCDoHandle, OCClientResponse *);
+#define NS_VERTIFY_NOT_NULL_V(obj) { if ((obj) == NULL) \
+    { \
+        NS_LOG_V(ERROR, "%s : obj is null", __func__); \
+        return; \
+    }}
+
+#define NS_VERTIFY_NOT_NULL(obj, retVal) { if ((obj) == NULL) \
+    { \
+        NS_LOG_V(ERROR, "%s : obj is null", __func__); \
+        return (retVal); \
+    }}
+
+#define NS_VERTIFY_NOT_NULL_WITH_POST_CLEANING(obj, retVal, func) { \
+    if ((obj) == NULL) \
+    { \
+        NS_LOG_V(ERROR, "%s : obj is null", __func__); \
+        NS_LOG(ERROR, "execute deletion"); \
+        (func); \
+        return (retVal); \
+    }}
+
+#define NS_VERTIFY_STACK_OK_V(obj) { OCStackResult _ret = (obj); \
+    if ( _ret != OC_STACK_OK) \
+    { \
+        NS_LOG_V(ERROR, "%s : obj is not OC_STACK_OK : %d", __func__, _ret); \
+        return; \
+    }}
+
+#define NS_VERTIFY_STACK_OK(obj, retVal) { OCStackResult _ret = (obj); \
+    if ( _ret != OC_STACK_OK) \
+    { \
+        NS_LOG_V(ERROR, "%s : obj is not OC_STACK_OK : %d", __func__, _ret); \
+        return (retVal); \
+    }}
+
+#define NS_VERTIFY_STACK_OK_WITH_POST_CLEANING(obj, retVal, func) { \
+    OCStackResult _ret = (obj); \
+    if ( _ret != OC_STACK_OK) \
+    { \
+        NS_LOG_V(ERROR, "%s : obj is not OC_STACK_OK : %d", __func__, _ret); \
+        (func); \
+        return (retVal); \
+    }}
 
 typedef enum
 {
@@ -60,6 +100,7 @@ typedef struct
 
     //Optional
     char * mContentText;
+    char * mSource;
 
     OCDevAddr * addr;
     char * syncUri;
@@ -76,10 +117,7 @@ void NSSetNotificationPostedCb(NSNotificationReceivedCallback  cb);
 void NSNotificationPost(NSProvider * provider, NSMessage * obj);
 
 void NSSetNotificationSyncCb(NSSyncCallback cb);
-void NSNotificationSync(NSProvider * provider, NSSync * sync);
-
-onRIResponseListener NSGetResponseListener();
-void NSSetResponseListener(onRIResponseListener cb);
+void NSNotificationSync(NSProvider * provider, NSSyncInfo * sync);
 
 NSTask * NSMakeTask(NSTaskType, void *);
 
@@ -88,9 +126,10 @@ NSResult NSConsumerPushEvent(NSTask *);
 NSMessage_consumer * NSCopyMessage(NSMessage_consumer *);
 void NSRemoveMessage(NSMessage_consumer *);
 
-OCStackResult NSRequestToResourceIntrospection(OCDoHandle * handle,
+OCStackResult NSInvokeRequest(OCDoHandle * handle,
         OCMethod method, const OCDevAddr * addr,
-        const char * queryUrl, OCPayload * payload, void * callback);
+        const char * queryUrl, OCPayload * payload,
+        void * callbackFunc, void * callbackData);
 
 #ifdef __cplusplus
 }