Added empty unimplemented methods for notification subscribtion
authorAndriy Gudz <a.gudz@samsung.com>
Wed, 10 May 2017 08:05:50 +0000 (11:05 +0300)
committerAndriy Gudz <a.gudz@samsung.com>
Wed, 10 May 2017 08:05:50 +0000 (11:05 +0300)
network-manager/nmlib/IoT/src/iotivity.cpp
network-manager/nmlib/include/iotivity.h
network-manager/nmlib/include/nmlib.h

index 6eee3b9..88e3e37 100644 (file)
 #include <OCApi.h>
 #include <OCPlatform.h>
 #pragma GCC diagnostic pop
-#include <unistd.h>
-#include "nmexceptions.h"
-#include "nmlib.h"
 #include <logging.h>
 
+using namespace std;
 using namespace OC;
 #define TAG "NetworkManager"
 
@@ -154,19 +152,19 @@ void IoTivity::cleanUp()
     }
 }
 
-void guardTimeout(bool timeout, std::string message)
+inline void guardTimeout(bool timeout, std::string message)
 {
     if (timeout)
         throw IoTInternalError(message + " timeout exceed", EC_TIMEOUT_ERROR);
 }
 
-void guardSignErrorCode(int resultCode, std::string message)
+inline void guardSignErrorCode(int resultCode, std::string message)
 {
     if (resultCode != 4)
         throw IoTInternalError(message + " callback error:" + std::to_string(resultCode), EC_IOTIVITY_ERROR);
 }
 
-void guardErrorCode(OCStackResult resultCode, std::string message)
+inline void guardErrorCode(OCStackResult resultCode, std::string message)
 {
     if (resultCode != OC_STACK_OK)
         throw IoTInternalError(message + " error:" + std::to_string(resultCode), EC_IOTIVITY_ERROR);
@@ -398,8 +396,6 @@ bool IoTivity::isSignedIn()
     return signedIn;
 }
 
-using namespace std;
-
 string IoTivity::getDeviceID()
 {
        OCUUIdentity deviceId;
@@ -423,4 +419,12 @@ string IoTivity::getDeviceID()
 
 }
 
+void IoTivity::subscribeNotifications(NotificationCallback callback) {
+    throw IoTInternalError("subscribeNotifications() not implemented", EC_NOT_IMPLEMENTED_YET);
+}
+
+void IoTivity::unsubscribeNotifications() {
+    throw IoTInternalError("unsubscribeNotifications() not implemented", EC_NOT_IMPLEMENTED_YET);
+}
+
 }
index b7ccb80..2645f0d 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef __IOTIVITY_H__
 #define __IOTIVITY_H__
 
+#include "nmlib.h"
 #include "nmexceptions.h"
 #include "iotdevice.h"
 #include <memory>
@@ -12,6 +13,10 @@ namespace NetworkManager
 
 typedef std::map<std::string, std::shared_ptr<IoTDevice> > IoTDevicesMap;
 
+typedef std::function<void(const std::string&, bool)> PresenceHook;
+
+typedef std::function<void(const std::string)> NotificationCallback;
+
 /**
  * @brief The OAuthCredential struct contains information about current session with cloud server. Filled after signIn().
  */
@@ -28,8 +33,6 @@ struct OAuthCredential
     std::string password;
 };
 
-typedef std::function<void(const std::string&, bool)> PresenceHook;
-
 class IoTivity
 {
 public:
@@ -97,8 +100,24 @@ public:
      */
     IoTDevicesMap getUnOwnedDevices();
 
+    /**
+     * @brief getDeviceID returns device id (DUID) from iotivity persistant storage
+     * @return string that indicates duid
+     */
     static std::string getDeviceID();
 
+    /**
+     * @brief subscribeNotifications subscribes to secure server notifications.
+     * Only one subscription allowed.
+     * @param callback method to receive notifications after subscription
+     */
+    void subscribeNotifications(NotificationCallback callback);
+
+    /**
+     * @brief unsubscribeNotifications unsubscribes to current secure server notifications
+     */
+    void unsubscribeNotifications();
+
 private:
     static const std::string DEFAULT_PROVIDER;
     static const int DEFAULT_TIMEOUT;
index 16e3682..e6f1f7a 100644 (file)
@@ -10,6 +10,8 @@
 #ifndef __NMLIB_H__
 #define __NMLIB_H__
 
+#include <unistd.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif