#include <stdio.h>
#include <stdbool.h>
-#include "NSCommon.h"
+#include "NSConsumerInterface.h"
#include "NSStructs.h"
#include "ocstack.h"
-#define NS_LOG_PRINTF 0
-
-#define __NS_FILE__ ( strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__ )
-
-const char * NS_CONVERT_LEVEL(int level);
-
-// TODO fix ns log using oic log.
-#ifdef TB_LOG
-#include "logger.h"
-#define NS_CONSUMER_LOG_V(level, format, ...) (OIC_LOG_V((level), __NS_FILE__, (format), __VA_ARGS__))
-#define NS_CONSUMER_LOG(level, msg) (OIC_LOG((level), __NS_FILE__, (msg)))
-#else
-#include "logger.h"
-#define NS_CONSUMER_LOG_V(level, format, ...) { \
- printf("%s: %s ", NS_CONVERT_LEVEL(level), __NS_FILE__); \
- printf((format), __VA_ARGS__); \
- printf("\n"); }
-#define NS_CONSUMER_LOG(level, msg) { \
- printf("%s: %s ", NS_CONVERT_LEVEL(level), __NS_FILE__); \
- printf((msg)); \
- printf("\n"); }
-
-#endif
-
#define NS_QOS OC_LOW_QOS
#define NS_RESOURCE_TYPE "oic.r.notification"
#define NS_RESOURCE_URI "/notification"
#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
{
//Optional
char * mContentText;
+ char * mSource;
OCDevAddr * addr;
char * syncUri;
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 *);
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
}