fix notification manager for m2
authorjyong2.kim <jyong2.kim@samsung.com>
Thu, 13 Nov 2014 07:48:05 +0000 (16:48 +0900)
committerjungyong Kim <jyong2.kim@samsung.com>
Thu, 13 Nov 2014 08:03:38 +0000 (00:03 -0800)
fix all code based on latest resource api.
fix notification folder name, following name convention.

Change-Id: Ic1eba69dd712428b4b0fae542d4acb005ad78a52

56 files changed:
service/Notification-Manager/SampleApp/tizen/sampleConsumer/src/oicapp-log.h [deleted file]
service/Notification-Manager/SampleApp/tizen/sampleNM/NM/NotificationManager.cpp [deleted file]
service/Notification-Manager/SampleApp/tizen/sampleNM/NM/NotificationManager.h [deleted file]
service/Notification-Manager/SampleApp/tizen/sampleNM/NM/RegistrationManager.cpp [deleted file]
service/Notification-Manager/SampleApp/tizen/sampleNM/NM/RegistrationManager.h [deleted file]
service/Notification-Manager/SampleApp/tizen/sampleNM/NM/ResourceManager.cpp [deleted file]
service/Notification-Manager/SampleApp/tizen/sampleNM/NM/ResourceManager.h [deleted file]
service/Notification-Manager/SampleApp/tizen/sampleNM/NM/VirtualRepresentation.cpp [deleted file]
service/Notification-Manager/SampleApp/tizen/sampleNM/NM/VirtualRepresentation.h [deleted file]
service/Notification-Manager/SampleApp/tizen/sampleNM/src/oicapp-sampleNM.cpp [deleted file]
service/Notification-Manager/SampleApp/tizen/sampleNM/src/oicapp-sampleNM.h [deleted file]
service/Notification-Manager/SampleApp/tizen/sampleNM/src/oicapp-utils.c [deleted file]
service/Notification-Manager/SampleApp/tizen/sampleNM/src/oicapp-utils.h [deleted file]
service/notification-manager/.gitignore [moved from service/Notification-Manager/.gitignore with 100% similarity]
service/notification-manager/NotificationManager/build/linux/.gitignore [moved from service/Notification-Manager/NotificationManager/build/linux/.gitignore with 100% similarity]
service/notification-manager/NotificationManager/build/linux/Makefile [moved from service/Notification-Manager/NotificationManager/build/linux/Makefile with 83% similarity]
service/notification-manager/NotificationManager/include/NotificationManager.h [moved from service/Notification-Manager/NotificationManager/include/NotificationManager.h with 95% similarity]
service/notification-manager/NotificationManager/include/RegistrationManager.h [moved from service/Notification-Manager/NotificationManager/include/RegistrationManager.h with 98% similarity]
service/notification-manager/NotificationManager/include/ResourceManager.h [moved from service/Notification-Manager/NotificationManager/include/ResourceManager.h with 98% similarity]
service/notification-manager/NotificationManager/include/VirtualRepresentation.h [moved from service/Notification-Manager/NotificationManager/include/VirtualRepresentation.h with 87% similarity]
service/notification-manager/NotificationManager/src/LinuxMain.cpp [moved from service/Notification-Manager/NotificationManager/src/LinuxMain.cpp with 91% similarity]
service/notification-manager/NotificationManager/src/NotificationManager.cpp [moved from service/Notification-Manager/NotificationManager/src/NotificationManager.cpp with 90% similarity]
service/notification-manager/NotificationManager/src/RegistrationManager.cpp [moved from service/Notification-Manager/NotificationManager/src/RegistrationManager.cpp with 82% similarity]
service/notification-manager/NotificationManager/src/ResourceManager.cpp [moved from service/Notification-Manager/NotificationManager/src/ResourceManager.cpp with 85% similarity]
service/notification-manager/NotificationManager/src/VirtualRepresentation.cpp [moved from service/Notification-Manager/NotificationManager/src/VirtualRepresentation.cpp with 92% similarity]
service/notification-manager/SampleApp/arduino/Time/DateStrings.cpp [moved from service/Notification-Manager/SampleApp/arduino/Time/DateStrings.cpp with 100% similarity]
service/notification-manager/SampleApp/arduino/Time/Readme.txt [moved from service/Notification-Manager/SampleApp/arduino/Time/Readme.txt with 100% similarity]
service/notification-manager/SampleApp/arduino/Time/Time.cpp [moved from service/Notification-Manager/SampleApp/arduino/Time/Time.cpp with 100% similarity]
service/notification-manager/SampleApp/arduino/Time/Time.h [moved from service/Notification-Manager/SampleApp/arduino/Time/Time.h with 100% similarity]
service/notification-manager/SampleApp/arduino/Time/examples/Processing/SyncArduinoClock/SyncArduinoClock.pde [moved from service/Notification-Manager/SampleApp/arduino/Time/examples/Processing/SyncArduinoClock/SyncArduinoClock.pde with 100% similarity]
service/notification-manager/SampleApp/arduino/Time/examples/Processing/SyncArduinoClock/readme.txt [moved from service/Notification-Manager/SampleApp/arduino/Time/examples/Processing/SyncArduinoClock/readme.txt with 100% similarity]
service/notification-manager/SampleApp/arduino/Time/examples/TimeArduinoDue/TimeArduinoDue.ino [moved from service/Notification-Manager/SampleApp/arduino/Time/examples/TimeArduinoDue/TimeArduinoDue.ino with 100% similarity]
service/notification-manager/SampleApp/arduino/Time/examples/TimeGPS/TimeGPS.ino [moved from service/Notification-Manager/SampleApp/arduino/Time/examples/TimeGPS/TimeGPS.ino with 100% similarity]
service/notification-manager/SampleApp/arduino/Time/examples/TimeNTP/TimeNTP.ino [moved from service/Notification-Manager/SampleApp/arduino/Time/examples/TimeNTP/TimeNTP.ino with 100% similarity]
service/notification-manager/SampleApp/arduino/Time/examples/TimeRTC/TimeRTC.pde [moved from service/Notification-Manager/SampleApp/arduino/Time/examples/TimeRTC/TimeRTC.pde with 100% similarity]
service/notification-manager/SampleApp/arduino/Time/examples/TimeRTCLog/TimeRTCLog.pde [moved from service/Notification-Manager/SampleApp/arduino/Time/examples/TimeRTCLog/TimeRTCLog.pde with 100% similarity]
service/notification-manager/SampleApp/arduino/Time/examples/TimeRTCSet/TimeRTCSet.ino [moved from service/Notification-Manager/SampleApp/arduino/Time/examples/TimeRTCSet/TimeRTCSet.ino with 100% similarity]
service/notification-manager/SampleApp/arduino/Time/examples/TimeSerial/TimeSerial.ino [moved from service/Notification-Manager/SampleApp/arduino/Time/examples/TimeSerial/TimeSerial.ino with 100% similarity]
service/notification-manager/SampleApp/arduino/Time/examples/TimeSerialDateStrings/TimeSerialDateStrings.ino [moved from service/Notification-Manager/SampleApp/arduino/Time/examples/TimeSerialDateStrings/TimeSerialDateStrings.ino with 100% similarity]
service/notification-manager/SampleApp/arduino/Time/examples/TimeTeensy3/TimeTeensy3.ino [moved from service/Notification-Manager/SampleApp/arduino/Time/examples/TimeTeensy3/TimeTeensy3.ino with 100% similarity]
service/notification-manager/SampleApp/arduino/Time/keywords.txt [moved from service/Notification-Manager/SampleApp/arduino/Time/keywords.txt with 100% similarity]
service/notification-manager/SampleApp/arduino/local.properties [moved from service/Notification-Manager/SampleApp/arduino/local.properties with 100% similarity]
service/notification-manager/SampleApp/arduino/makefile [moved from service/Notification-Manager/SampleApp/arduino/makefile with 100% similarity]
service/notification-manager/SampleApp/arduino/readme.txt [moved from service/Notification-Manager/SampleApp/arduino/readme.txt with 100% similarity]
service/notification-manager/SampleApp/arduino/thserver.cpp [moved from service/Notification-Manager/SampleApp/arduino/thserver.cpp with 100% similarity]
service/notification-manager/SampleApp/linux/sampleConsumer/SampleConsumer.cpp [moved from service/Notification-Manager/SampleApp/linux/sampleConsumer/SampleConsumer.cpp with 92% similarity]
service/notification-manager/SampleApp/linux/sampleProvider/SampleProvider.cpp [moved from service/Notification-Manager/SampleApp/linux/sampleProvider/SampleProvider.cpp with 62% similarity]
service/notification-manager/SampleApp/tizen/sampleConsumer/src/oicapp-client.cpp [moved from service/Notification-Manager/SampleApp/tizen/sampleConsumer/src/oicapp-client.cpp with 100% similarity]
service/notification-manager/SampleApp/tizen/sampleConsumer/src/oicapp-log.h [moved from service/Notification-Manager/SampleApp/tizen/sampleNM/src/oicapp-log.h with 100% similarity]
service/notification-manager/SampleApp/tizen/sampleConsumer/src/oicapp-sampleConsumer.c [moved from service/Notification-Manager/SampleApp/tizen/sampleConsumer/src/oicapp-sampleConsumer.c with 100% similarity]
service/notification-manager/SampleApp/tizen/sampleConsumer/src/oicapp-sampleConsumer.h [moved from service/Notification-Manager/SampleApp/tizen/sampleConsumer/src/oicapp-sampleConsumer.h with 100% similarity]
service/notification-manager/SampleApp/tizen/sampleConsumer/src/oicapp-utils.c [moved from service/Notification-Manager/SampleApp/tizen/sampleConsumer/src/oicapp-utils.c with 100% similarity]
service/notification-manager/SampleApp/tizen/sampleConsumer/src/oicapp-utils.h [moved from service/Notification-Manager/SampleApp/tizen/sampleConsumer/src/oicapp-utils.h with 100% similarity]
service/notification-manager/build/linux/makefile/Makefile [moved from service/Notification-Manager/build/linux/makefile/Makefile with 91% similarity]
service/notification-manager/build/linux/release/.gitignore [moved from service/Notification-Manager/build/linux/release/.gitignore with 100% similarity]
service/notification-manager/build/tizen/CMakeLists.txt [moved from service/Notification-Manager/build/tizen/CMakeLists.txt with 95% similarity]

diff --git a/service/Notification-Manager/SampleApp/tizen/sampleConsumer/src/oicapp-log.h b/service/Notification-Manager/SampleApp/tizen/sampleConsumer/src/oicapp-log.h
deleted file mode 100644 (file)
index 4a7fdb3..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2010 Samsung Electronics, Inc.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information
- * of Samsung Electronics, Inc. ("Confidential Information").  You
- * shall not disclose such Confidential Information and shall use
- * it only in accordance with the terms of the license agreement
- * you entered into with Samsung Electronics.
- */
-#ifndef __OICAPP_LOG_H__
-#define __OICAPP_LOG_H__
-
-#define TIZEN_DEBUG_ENABLE
-#define LOG_TAG "OIC_TEST"
-#include <dlog.h>
-
-#define LOG_COLOR_RED          "\033[0;31m"
-#define LOG_COLOR_BROWN                "\033[0;33m"
-#define LOG_COLOR_BLUE         "\033[0;34m"
-#define LOG_COLOR_END          "\033[0;m"
-
-
-#if 1
-#define _DBG(fmt, arg...) SLOGD(fmt, ##arg)
-#define _INFO(fmt, arg...) SLOGI(fmt, ##arg)
-#define _WARN(fmt, arg...) SLOGW(fmt, ##arg)
-#define _ERR(fmt, arg...) SLOGE(fmt, ##arg)
-#else
-#define _DBG(fmt, arg...) \
-       printf("[OIC_TEST]%s(%d):" fmt "\n", __FUNCTION__, __LINE__, ##arg)
-#define _INFO(fmt, arg...) \
-       printf("[OIC_TEST]%s(%d):" fmt "\n", __FUNCTION__, __LINE__, ##arg)
-#define _WARN(fmt, arg...) \
-       printf("[OIC_TEST]%s(%d):" fmt "\n", __FUNCTION__, __LINE__, ##arg)
-#define _ERR(fmt, arg...) \
-       printf("[OIC_TEST]%s(%d):" fmt "\n", __FUNCTION__, __LINE__, ##arg)
-#endif
-
-#define DBG(fmt, arg...) _DBG(fmt, ##arg)
-#define WARN(fmt, arg...) _WARN(LOG_COLOR_BROWN fmt LOG_COLOR_END, ##arg)
-#define ERR(fmt, arg...) _ERR(LOG_COLOR_RED fmt LOG_COLOR_END, ##arg)
-#define INFO(fmt, arg...) _INFO(LOG_COLOR_BLUE fmt LOG_COLOR_END, ##arg)
-
-#define ret_if(expr) \
-       do { \
-               if (expr) { \
-                       ERR("(%s)", #expr); \
-                       return; \
-               }\
-       } while(0)
-#define retv_if(expr, val) \
-       do {\
-               if (expr) { \
-                       ERR("(%s)", #expr); \
-                       return (val); \
-               } \
-       } while(0)
-#define retm_if(expr, fmt, arg...) \
-       do {\
-               if (expr) { \
-                       ERR(fmt, ##arg); \
-                       return; \
-               }\
-       } while(0)
-#define retvm_if(expr, val, fmt, arg...) \
-       do {\
-               if (expr) { \
-                       ERR(fmt, ##arg); \
-                       return (val); \
-               } \
-       } while(0)
-#define warn_if(expr) \
-       do { \
-               if (expr) { \
-                       WARN("(%s)", #expr); \
-               } \
-       } while (0)
-
-
-#endif //__OICAPP_LOG_H__
-
diff --git a/service/Notification-Manager/SampleApp/tizen/sampleNM/NM/NotificationManager.cpp b/service/Notification-Manager/SampleApp/tizen/sampleNM/NM/NotificationManager.cpp
deleted file mode 100644 (file)
index fb32c4e..0000000
+++ /dev/null
@@ -1,335 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-#include "NotificationManager.h"
-
-NotificationManager *NotificationManager::instance = NULL;
-OCPlatform *NotificationManager::nmOCPlatform = NULL;
-PlatformConfig NotificationManager::cfg;
-
-NotificationManager::NotificationManager()
-{
-
-       print                   = NULL;
-       onfound         = NULL;
-       onObserve               = NULL;
-       startHosting    = NULL;
-       findHosting     = NULL;
-       addExtraStr     = NULL;
-}
-
-NotificationManager::~NotificationManager()
-{
-       if(nmOCPlatform!=NULL)
-       {
-               delete nmOCPlatform;
-               nmOCPlatform = NULL;
-       }
-}
-
-void NotificationManager::initialize()
-{
-
-       std::string ip_address;
-       scanAndGetNetworkInterface(ip_address);
-
-       cfg.ipAddress = ip_address;
-       cfg.port = 5683;
-       cfg.mode = ModeType::Both;
-       cfg.serviceType = ServiceType::InProc;
-
-       nmOCPlatform = new OCPlatform(cfg);
-
-       setPrint(NULL);
-       setOnFoundHostingCandidate(NULL);
-       setStartHosting(NotificationManager::getInstance()->startHosting);
-       setFindHosting(NotificationManager::getInstance()->findHosting);
-       setAddExtraStr(NotificationManager::getInstance()->addExtraStr);
-
-}
-
-void NotificationManager::registerHostingEvent()
-{
-       // TODO : Initial HostingEventListener
-}
-
-void NotificationManager::findHostingCandidate()
-{
-       try
-       {
-               ResourceManager::getInstance()->findNMResource("", "coap://224.0.1.187/oc/core",true);
-       }
-       catch(OCException e)
-       {
-               std::cout << "Fail!!" << endl;
-       }
-}
-
-NotificationManager *NotificationManager::getInstance()
-{
-       if(!instance)
-       {
-               instance = new NotificationManager();
-       }
-
-       return instance;
-}
-
-OCPlatform *NotificationManager::getOCPlatform()
-{
-       if(!nmOCPlatform)
-       {
-               nmOCPlatform = new OCPlatform(cfg);
-       }
-       return nmOCPlatform;
-}
-
-int NotificationManager::setPrint( std::function<void(AttributeMap &inputAttMap)> func )
-{
-       if( func != NULL )
-       {
-               try
-               {
-                       NotificationManager::getInstance()->print = func;
-               }
-               catch(exception e)
-               {
-                       return false;
-               }
-       }
-       else
-       {
-               NotificationManager::getInstance()->print =
-                               std::function<void(AttributeMap &inputAttMap)>
-                               (std::bind(&ResourceManager::printAttributeMap,ResourceManager::getInstance(),std::placeholders::_1));
-       }
-       return true;
-}
-
-int NotificationManager::setOnFoundHostingCandidate( std::function<void(std::shared_ptr<OCResource> resource)> func )
-{
-       if( func != NULL )
-       {
-               try
-               {
-                       NotificationManager::getInstance()->onfound = func;
-               }
-               catch(exception e)
-               {
-                       return false;
-               }
-       }
-       else
-       {
-               NotificationManager::getInstance()->onfound =
-                               std::function<void(std::shared_ptr<OCResource> resource)>
-                               (std::bind(&ResourceManager::onFoundReport, ResourceManager::getInstance(),std::placeholders::_1));
-       }
-
-       return true;
-}
-
-int NotificationManager::setOnObserve( std::function<void(AttributeMap &inputAttMap)> func )
-{
-       if( func != NULL )
-       {
-               try
-               {
-                       NotificationManager::getInstance()->onObserve = func;
-               }
-               catch(exception e)
-               {
-                       return false;
-               }
-       }
-       return true;
-}
-
-std::function<void(AttributeMap &inputAttMap)> NotificationManager::getPrint()
-{
-       return print;
-}
-
-std::function<void(std::shared_ptr<OCResource> resource)> NotificationManager::getOnFoundHostingCandidate()
-{
-       return onfound;
-}
-
-std::function<void(AttributeMap &inputAttMap)> NotificationManager::getOnObserve()
-{
-       return onObserve;
-}
-
-int NotificationManager::setStartHosting( std::function<void(std::shared_ptr<OCResource> resource)> &func )
-{
-       try
-       {
-               func = std::function<void(std::shared_ptr<OCResource> resource)>
-               (std::bind(&ResourceManager::startHosting,ResourceManager::getInstance(),std::placeholders::_1));
-       }
-       catch(exception e)
-       {
-               return false;
-       }
-
-       return true;
-}
-
-int NotificationManager::setFindHosting( std::function<void()> &func )
-{
-       try
-       {
-               func = std::function<void()>
-               (std::bind(&NotificationManager::findHostingCandidate,NotificationManager::getInstance()));
-       }
-       catch(exception e)
-       {
-               return false;
-       }
-
-       return true;
-}
-
-int NotificationManager::setAddExtraStr( std::function<void(std::string)> &func )
-{
-       try
-       {
-               func = std::function<void(std::string str)>
-               (std::bind(&ResourceManager::addExtraStr,ResourceManager::getInstance(),std::placeholders::_1));
-       }
-       catch(exception e)
-       {
-               return false;
-       }
-
-       return true;
-}
-
-std::function<void(std::shared_ptr<OCResource> resource)> NotificationManager::getStartHosting()
-{
-       if(startHosting)
-       {
-               return startHosting;
-       }
-       else
-       {
-               return NULL;
-       }
-}
-std::function<void()> NotificationManager::getFindHosting()
-{
-       if(findHosting)
-       {
-               return findHosting;
-       }
-       else
-       {
-               return NULL;
-       }
-}
-std::function<void(std::string)> NotificationManager::getAddExtraStr()
-{
-       if(addExtraStr)
-       {
-               return addExtraStr;
-       }
-       else
-       {
-               return NULL;
-       }
-}
-
-
-int NotificationManager::getNetInfo(IN int& sck, IN struct ifreq* item, OUT std::string& ip_addres)
-{
-       struct ifreq temp_ifr;
-       memset(&temp_ifr, 0, sizeof(temp_ifr));
-       strcpy(temp_ifr.ifr_name, item->ifr_name);
-
-       if (ioctl(sck, SIOCGIFFLAGS, &temp_ifr))
-       {
-               return -1;
-       }
-
-       if (!((temp_ifr.ifr_flags & IFF_UP) && (temp_ifr.ifr_flags & IFF_RUNNING)))
-       {
-               return -1;
-       }
-
-       std::string ip(inet_ntoa(((struct sockaddr_in *) &item->ifr_addr)->sin_addr));
-       if (ip.empty())
-       {
-               return -1;
-       }
-
-       if (ip.find("127.0.0") == 0)
-       {
-               return -1;
-       }
-
-       ip_addres = ip;
-       return 0;
-}
-
-bool NotificationManager::scanAndGetNetworkInterface(OUT std::string& ip_addres)
-{
-       while(1)
-       {
-               char buf[1024] =        { 0, };
-               struct ifconf ifc;
-               struct ifreq *ifr;
-               int sck;
-               int interfaces;
-               int i;
-
-               sck = socket(AF_INET, SOCK_DGRAM, 0);
-               if (sck < 0)
-               {
-                       usleep(10);
-                       continue;
-               }
-
-               ifc.ifc_len = sizeof(buf);
-               ifc.ifc_buf = buf;
-               if (ioctl(sck, SIOCGIFCONF, &ifc) < 0)
-               {
-                       printf( "SIOCGIFCONF Failed ");
-                       close(sck);
-                       usleep(10);
-                       continue;
-               }
-
-               ifr = ifc.ifc_req;
-               interfaces = ifc.ifc_len / sizeof(struct ifreq);
-
-               for (i = 0; i < interfaces; i++)
-               {
-                       if(  getNetInfo(sck, &ifr[i], ip_addres) == 0 )
-                       {
-                               return 0;
-                       }
-                       continue;
-               }
-               close(sck);
-               usleep(10);
-       }
-
-       return 0;
-}
diff --git a/service/Notification-Manager/SampleApp/tizen/sampleNM/NM/NotificationManager.h b/service/Notification-Manager/SampleApp/tizen/sampleNM/NM/NotificationManager.h
deleted file mode 100644 (file)
index acb7862..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-/*
- * NotificationCore.h
- *
- *  Created on: 2014. 8. 7.
- *      Author: jyong2
- */
-
-#ifndef NOTIFICATIONMANAGER_H_
-#define NOTIFICATIONMANAGER_H_
-
-#include <iostream>
-#include <functional>
-#include <pthread.h>
-#include <cstdint>
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "OCApi.h"
-#include "OCPlatform.h"
-#include "OCResource.h"
-#include "OCResourceRequest.h"
-#include "OCResourceResponse.h"
-#include "ocstack.h"
-
-#include "ResourceManager.h"
-#include "RegistrationManager.h"
-#include "VirtualRepresentation.h"
-
-
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <unistd.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <net/if.h>
-
-#define ISFORLINUX 0
-#define ISFORTIZEN 1
-
-#define IN
-#define OUT
-
-using namespace OC;
-
-const std::string VIRTURL_TAG = "/virtual";
-
-class NotificationManager {
-
-private:
-
-       static NotificationManager *instance;
-       static OCPlatform *nmOCPlatform;
-
-       static PlatformConfig cfg;
-
-       std::function<void(AttributeMap &inputAttMap)> print;
-       std::function<void(std::shared_ptr<OCResource> resource)> onfound;
-       std::function<void(AttributeMap &inputAttMap)> onObserve;
-
-       std::function<void(std::shared_ptr<OCResource> resource)> startHosting;
-       std::function<void()> findHosting;
-       std::function<void(std::string)> addExtraStr;
-
-public:
-
-       NotificationManager();
-       ~NotificationManager();
-
-       static NotificationManager *getInstance();
-       static OCPlatform *getOCPlatform();
-
-       void initialize();
-       void findHostingCandidate();
-       void registerHostingEvent();
-
-       int setPrint( std::function<void(AttributeMap &inputAttMap)> func );
-       int setOnFoundHostingCandidate( std::function<void(std::shared_ptr<OCResource> resource)> func );
-       int setOnObserve( std::function<void(AttributeMap &inputAttMap)> func );
-
-       std::function<void(AttributeMap &inputAttMap)> getPrint();
-       std::function<void(std::shared_ptr<OCResource> resource)> getOnFoundHostingCandidate();
-       std::function<void(AttributeMap &inputAttMap)> getOnObserve();
-
-       int setStartHosting( std::function<void(std::shared_ptr<OCResource> resource)> &func );
-       int setFindHosting( std::function<void()> &func );
-       int setAddExtraStr( std::function<void(std::string)> &func );
-
-       std::function<void(std::shared_ptr<OCResource> resource)> getStartHosting();
-       std::function<void()> getFindHosting();
-       std::function<void(std::string)> getAddExtraStr();
-
-       int     getNetInfo(IN int& sck, IN struct ifreq* item, OUT std::string& ip_addres);
-       bool    scanAndGetNetworkInterface(OUT std::string& ip_addres);
-
-};
-
-#endif /* NOTIFICATIONMANAGER_H_ */
diff --git a/service/Notification-Manager/SampleApp/tizen/sampleNM/NM/RegistrationManager.cpp b/service/Notification-Manager/SampleApp/tizen/sampleNM/NM/RegistrationManager.cpp
deleted file mode 100644 (file)
index 08761db..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-#include "RegistrationManager.h"
-
-RegistrationManager *RegistrationManager::instance = NULL;
-
-RegistrationManager::RegistrationManager()
-{
-}
-
-RegistrationManager::~RegistrationManager()
-{
-}
-
-RegistrationManager *RegistrationManager::getInstance()
-{
-       if(!instance)
-       {
-               instance = new RegistrationManager();
-       }
-       return instance;
-}
-
-int RegistrationManager::addResource ()
-{
-       return 0;
-}
-
-int RegistrationManager::removeResource ()
-{
-       return 0;
-}
-
-int RegistrationManager::updateResource ()
-{
-       return 0;
-}
-
-bool RegistrationManager::registerNMResource(VirtualRepresentation &resourceObject, std::shared_ptr<OCResource> resource)
-{
-       std::string uri         = resourceObject.getUri();
-       std::string type                = resourceObject.getResourceTypeName();
-       std::string interface= resourceObject.getResourceInterface();
-
-       OCResourceHandle resourceHandle;
-
-       OCStackResult result;
-       result = NotificationManager::getOCPlatform()->registerResource(
-                       resourceHandle,
-                       uri,
-                       type,
-                       interface,
-                       std::function<void(std::shared_ptr<OCResourceRequest> request, std::shared_ptr<OCResourceResponse> response)>
-                               (std::bind(&VirtualRepresentation::entityHandler,
-                                                               resourceObject,
-                                                               std::placeholders::_1,
-                                                               std::placeholders::_2)),
-                       resourceObject.getResourceProperty());
-       resourceObject.setResourceHandle(resourceHandle);
-
-       if(OC_STACK_OK != result)
-       {
-               std::cout << "Resource : " << uri << "Register Fail\n";
-               return false;
-       }
-       else
-       {
-               QueryParamsMap queryParmaMap;
-               resource->observe(ObserveType::Observe, queryParmaMap,
-                               std::function<void(const OCRepresentation& rep, const int& eCode, const int& sequenceNumber)>
-                               (std::bind(&VirtualRepresentation::onObserve,
-                                                               resourceObject,
-                                                               std::placeholders::_1,
-                                                               std::placeholders::_2,
-                                                               std::placeholders::_3)));
-       }
-
-       return true;
-}
-
-bool RegistrationManager::unregisterResource ()
-{
-       return true;
-}
-
diff --git a/service/Notification-Manager/SampleApp/tizen/sampleNM/NM/RegistrationManager.h b/service/Notification-Manager/SampleApp/tizen/sampleNM/NM/RegistrationManager.h
deleted file mode 100644 (file)
index 4c04625..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-#ifndef REGISTRATIONMANAGER_H_
-#define REGISTRATIONMANAGER_H_
-
-#include "NotificationManager.h"
-
-using namespace OC;
-
-class VirtualRepresentation;
-
-class RegistrationManager {
-
-private:
-       static RegistrationManager *instance;
-
-
-public:
-       RegistrationManager();
-       ~RegistrationManager();
-
-       static RegistrationManager *getInstance();
-
-       bool registerNMResource(VirtualRepresentation &resourceObject, std::shared_ptr<OCResource> resource);
-
-
-       int addResource ();
-       int removeResource ();
-       int updateResource ();
-       bool unregisterResource ();
-
-};
-
-#endif /* REGISTRATIONMANAGER_H_ */
diff --git a/service/Notification-Manager/SampleApp/tizen/sampleNM/NM/ResourceManager.cpp b/service/Notification-Manager/SampleApp/tizen/sampleNM/NM/ResourceManager.cpp
deleted file mode 100644 (file)
index 00e03bb..0000000
+++ /dev/null
@@ -1,241 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-#include "ResourceManager.h"
-
-ResourceManager *ResourceManager::instance = NULL;
-std::list<VirtualRepresentation> ResourceManager::resourceList;
-
-std::string ResourceManager::extraStr;
-
-ResourceManager::ResourceManager()
-{
-}
-
-ResourceManager::~ResourceManager()
-{
-}
-
-ResourceManager *ResourceManager::getInstance()
-{
-       if(!instance)
-       {
-               instance = new ResourceManager();
-       }
-       return instance;
-}
-
-VirtualRepresentation ResourceManager::findVirtualRepresentation(std::string uri)
-{
-
-       VirtualRepresentation retObject;
-
-       for(auto it = resourceList.begin(); it != resourceList.end(); it++)
-       {
-               if(it->getUri().compare(uri) == 0)
-               {
-                       retObject = *it;
-                       return retObject;
-               }
-       }
-
-       return retObject;
-}
-
-OCStackResult ResourceManager::findNMResource(const std::string& host, const std::string& resourceName, bool ishosting)
-{
-       return NotificationManager::getOCPlatform()->findResource(host, resourceName,
-                       std::function<void(std::shared_ptr<OCResource> resource)>(std::bind(&ResourceManager::foundResourceforhosting,this,std::placeholders::_1)));
-}
-
-void ResourceManager::foundResourceforhosting(std::shared_ptr<OCResource> resource)
-{
-       try
-       {
-               if(resource)
-               {
-#if ISFORLINUX
-                       if( resource->uri() == "/a/NM/TempHumSensor")
-                       {
-                               std::cout << "Resource Found!!" << endl;
-                               std::cout << endl;
-                               std::cout << "========================================================" << endl;
-                               std::cout << "Hosting Resource : " << std::endl;
-
-                               std::cout << "\tResource URI: " << resource->uri() << std::endl;
-                               std::cout << "\tResource TypeName: " << *(resource->getResourceTypes().data()) << std::endl;
-                               std::cout << "\tResource Interface: " << *(resource->getResourceInterfaces().data()) << std::endl;
-                       }
-                       else
-                       {
-                               std::cout << "But is not host uri" << endl;
-                               return;
-                       }
-                       std::cout << endl;
-                       std::cout << "========================================================" << endl;
-                       std::cout << "[Virtualization] ";
-#endif
-                       NotificationManager::getInstance()->getOnFoundHostingCandidate()(resource);
-               }
-               else
-               {
-               }
-
-       }
-       catch(std::exception& e)
-       {
-       }
-}
-
-void ResourceManager::startHosting(std::shared_ptr<OCResource> resource)
-{
-       VirtualRepresentation resourceObject;
-       resourceObject.setUri( resource->uri() );
-
-       std::cout << "resourceObject uri: " << resourceObject.getUri() << std::endl;
-
-       std::string resourceHostIP;
-       std::string resourceType;
-       std::string resourceInterface;
-       uint8_t resourceProperty;
-
-       resourceHostIP  = resource->host();
-       resourceType            = *(resource->getResourceTypes().data());
-       resourceInterface       = *(resource->getResourceInterfaces().data());
-       resourceProperty        = (OC_DISCOVERABLE | resource->isObservable());
-
-       resourceObject.setHostIP(resourceHostIP);
-       resourceObject.setResourceTypeName(resourceType);
-       resourceObject.setResourceInterface(resourceInterface);
-       resourceObject.setResourceProperty(resourceProperty);
-
-       RegistrationManager::getInstance()->registerNMResource(resourceObject, resource);
-
-       resourceList.push_back(resourceObject);
-
-}
-
-AttributeMap ResourceManager::copyAttributeMap(AttributeMap &inputAttMap)
-{
-
-       AttributeMap retAttMap;
-
-       for(auto it = inputAttMap.begin(); it != inputAttMap.end(); ++it)
-       {
-               AttributeValues tmpVal;
-
-               for(auto valueItr = it->second.begin(); valueItr != it->second.end(); ++valueItr)
-               {
-                       std::string tmpStr;
-#if ISFORLINUX
-                       if(it->first == "temperature")
-                       {
-                               tmpStr.append("\"");
-                               tmpStr.append(extraStr);
-                               tmpStr.append(":");
-                               tmpStr.append(*valueItr);
-                               tmpStr.append("\"");
-                       }
-                       else
-                       {
-                               tmpStr.append(*valueItr);
-                       }
-
-#endif
-#if ISFORTIZEN
-                       if(it->first == "temperature" && !extraStr.empty())
-                       {
-                               tmpStr.append("\"");
-                               tmpStr.append(extraStr);
-                               tmpStr.append(":");
-                               tmpStr.append(*valueItr);
-                               tmpStr.append("\"");
-                       }
-                       else
-                       {
-                               tmpStr.append(*valueItr);
-                       }
-#else
-                       tmpStr.append(*valueItr);
-#endif
-                       tmpVal.push_back(tmpStr);
-               }
-               retAttMap[it->first] = tmpVal;
-
-       }
-       return retAttMap;
-}
-
-bool ResourceManager::isEmptyAttributeMap(AttributeMap &inputAttMap)
-{
-       for(auto it=inputAttMap.begin(); it != inputAttMap.end(); ++it)
-       {
-               if(inputAttMap.find(it->first) == inputAttMap.end())
-               {
-                       return true;
-               }
-       }
-       return false;
-}
-
-void ResourceManager::onFoundReport(std::shared_ptr<OCResource> resource)
-{
-       NotificationManager::getInstance()->getStartHosting()(resource);
-}
-
-void ResourceManager::printAttributeMap(AttributeMap &inputAttMap)
-{
-
-#if ISFORLINUX
-       for(auto it = inputAttMap.begin(); it != inputAttMap.end(); ++it)
-       {
-               std::cout << "\tAttribute name: " << it->first << " value: ";
-
-               for(auto valueItr = it->second.begin(); valueItr != it->second.end(); ++valueItr)
-               {
-                       std::cout << "\t" << *valueItr << " ";
-               }
-
-               std::cout << std::endl;
-       }
-#endif
-#if ISFORTIZEN
-
-#endif
-
-}
-
-void ResourceManager::addExtraStr(std::string str)
-{
-       extraStr = str;
-}
-
-std::string ResourceManager::getExtraStr()
-{
-       return extraStr;
-}
-
-void ResourceManager::checkResourceDBPolicy() {
-
-}
-
-void ResourceManager::saveResourceDB() {
-
-}
diff --git a/service/Notification-Manager/SampleApp/tizen/sampleNM/NM/ResourceManager.h b/service/Notification-Manager/SampleApp/tizen/sampleNM/NM/ResourceManager.h
deleted file mode 100644 (file)
index 09081be..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-#ifndef RESOURCEMANAGER_H_
-#define RESOURCEMANAGER_H_
-
-#include <map>
-#include <memory>
-#include <string>
-#include "OCPlatform.h"
-#include "OCResource.h"
-#include "OCResourceResponse.h"
-#include "ocstack.h"
-
-#include "NotificationManager.h"
-
-using namespace OC;
-
-class VirtualRepresentation;
-
-class ResourceManager {
-
-private:
-       static ResourceManager *instance;
-
-       static std::list<VirtualRepresentation> resourceList;
-
-       static std::string extraStr;
-
-
-       void foundResourceforhosting(std::shared_ptr<OCResource> resource);
-
-       void checkResourceDBPolicy();
-       void saveResourceDB();
-
-public:
-       ResourceManager();
-       virtual ~ResourceManager();
-
-       static ResourceManager *getInstance();
-       VirtualRepresentation findVirtualRepresentation(std::string uri);
-
-       OCStackResult findNMResource(const std::string& host, const std::string& resourceName, bool ishosting);
-       void startHosting(std::shared_ptr<OCResource> resource);
-
-       AttributeMap copyAttributeMap(AttributeMap &inputAttMap);
-       bool isEmptyAttributeMap(AttributeMap &inputAttMap);
-
-       void printAttributeMap(AttributeMap &inputAttMap);
-       void onFoundReport(std::shared_ptr<OCResource> resource);
-
-       void addExtraStr(std::string str);
-       std::string getExtraStr();
-
-
-//     void findResource();
-//     void foundResource();
-
-};
-
-#endif /* RESOURCEMANAGER_H_ */
diff --git a/service/Notification-Manager/SampleApp/tizen/sampleNM/NM/VirtualRepresentation.cpp b/service/Notification-Manager/SampleApp/tizen/sampleNM/NM/VirtualRepresentation.cpp
deleted file mode 100644 (file)
index 6ae3336..0000000
+++ /dev/null
@@ -1,266 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-#include "VirtualRepresentation.h"
-
-VirtualRepresentation m_VirtualRepresentation;
-
-AttributeMap VirtualRepresentation::attributeMap;
-
-std::mutex VirtualRepresentation::mutexAttributeMap;
-std::condition_variable VirtualRepresentation::conditionAttributeMap;
-bool VirtualRepresentation::isReadyAttributeMap = true;
-
-int g_num = 0;
-
-VirtualRepresentation::VirtualRepresentation()
-{
-       m_resourceHandle = NULL;
-       resourceProperty = 0x00;
-}
-
-VirtualRepresentation::~VirtualRepresentation()
-{
-}
-
-std::string VirtualRepresentation::addVirtualTag(std::string uri)
-{
-       std::string ret = uri;
-       return ret.append(VIRTURL_TAG + std::to_string(g_num++));
-}
-
-OCResourceHandle VirtualRepresentation::getResourceHandle()
-{
-       return m_resourceHandle;
-}
-
-std::string VirtualRepresentation::getUri()
-{
-       return virtualUri;
-}
-std::string VirtualRepresentation::getHostIP()
-{
-       return originHostIP;
-}
-std::string VirtualRepresentation::getResourceTypeName()
-{
-       return resourceTypeName;
-}
-std::string VirtualRepresentation::getResourceInterface()
-{
-       return resourceInterface;
-}
-uint8_t VirtualRepresentation::getResourceProperty()
-{
-       return resourceProperty;
-}
-
-int VirtualRepresentation::setUri(std::string uri)
-{
-       virtualUri = addVirtualTag(uri);
-       return true;
-}
-int VirtualRepresentation::setHostIP(std::string ip)
-{
-       originHostIP = ip;
-       return true;
-}
-int VirtualRepresentation::setResourceTypeName(std::string typeName)
-{
-       resourceTypeName = typeName;
-       return true;
-}
-int VirtualRepresentation::setResourceInterface(std::string interface)
-{
-       resourceInterface = interface;
-       return true;
-}
-int VirtualRepresentation::setResourceProperty(uint8_t property)
-{
-       resourceProperty = property;
-       return true;
-}
-int VirtualRepresentation::setResourceHandle(OCResourceHandle & handle)
-{
-       m_resourceHandle = handle;
-       return true;
-}
-
-int VirtualRepresentation::getRepresentation(OCRepresentation& oc)
-{
-       oc.setAttributeMap(attributeMap);
-       oc.setUri(this->getUri().c_str());
-       return true;
-}
-
-void VirtualRepresentation::entityHandler(std::shared_ptr<OCResourceRequest> request, std::shared_ptr<OCResourceResponse> response){
-       if(request)
-       {
-               std::string requestType = request->getRequestType();
-               RequestHandlerFlag requestFlag = request->getRequestHandlerFlag();
-
-               if(requestFlag == RequestHandlerFlag::InitFlag)
-               {
-               }
-               else if(requestFlag == RequestHandlerFlag::RequestFlag)
-               {
-                       if(requestType == "GET")
-                       {
-
-                               if(response)
-                               {
-                                       std::unique_lock<std::mutex> lck(mutexAttributeMap);
-                                       while(!isReadyAttributeMap)     { conditionAttributeMap.wait(lck); }
-                                       isReadyAttributeMap = false;
-
-                                       NotificationManager::getInstance()->getPrint()(attributeMap);
-#if ISFORLINUX
-                                               std::cout << "\t";
-#endif
-
-                                       OCRepresentation rep;
-                                       getRepresentation(rep);
-
-                                       response->setErrorCode(200);
-                                       response->setResourceRepresentation(rep, "");
-
-                                       isReadyAttributeMap = true;
-                                       conditionAttributeMap.notify_all();
-                               }
-                               else
-                               {
-                               }
-
-                       }
-                       else if(requestType == "PUT")
-                       {
-                       }
-                       else if(requestType == "POST")
-                       {
-                       }
-                       else if(requestType == "DELETE")
-                       {
-                       }
-                       else
-                       {
-                       }
-               }
-               else if(requestFlag == RequestHandlerFlag::ObserverFlag)
-               {
-#if ISFORLINUX
-                       std::cout << endl;
-                       std::cout << "========================================================" << endl;
-                       std::cout << "Receive ObserverFlag : ";
-                       std::cout << "Start Observe" << response->getPayload() << std::endl;
-#endif
-               }
-               else
-               {
-               }
-       }
-       else
-       {
-       }
-}
-
-void VirtualRepresentation::onObserve(const OCRepresentation& rep, const int& eCode, const int& sequenceNumber)
-{
-    if(eCode == SUCCESS_RESPONSE)
-    {
-       AttributeMap tmp = rep.getAttributeMap();
-
-       if( ResourceManager::getInstance()->isEmptyAttributeMap(tmp) )
-       {
-               return;
-       }
-
-       if(NotificationManager::getInstance()->getOnObserve())
-       {
-               NotificationManager::getInstance()->getOnObserve()(tmp);
-       }
-
-#if ISFORLINUX
-       std::cout << endl;
-               std::cout << "========================================================" << endl;
-               std::cout << "Receive OBSERVE RESULT:" << std::endl;
-               std::cout << "\tResource URI: " << rep.getUri() << std::endl;
-#endif
-
-               NotificationManager::getInstance()->getPrint()(tmp);
-
-#if ISFORLINUX
-               std::cout << endl;
-               std::cout << "========================================================" << endl;
-               std::cout << "Check Is it Hosting: ";
-#endif
-
-               OCStackResult result = OC_STACK_OK;
-
-               VirtualRepresentation tmpObj = *this;
-               if(!tmpObj.getUri().empty())
-               {
-
-                       AttributeMap tmpAttMap = ResourceManager::getInstance()->copyAttributeMap(tmp);
-
-                       {
-                               std::unique_lock<std::mutex> lck(mutexAttributeMap);
-                               while(!isReadyAttributeMap)     { conditionAttributeMap.wait(lck); }
-                               isReadyAttributeMap = false;
-
-                               attributeMap = tmpAttMap;
-
-                               isReadyAttributeMap = true;
-                               conditionAttributeMap.notify_all();
-                       }
-
-#if ISFORLINUX
-                       std::cout << "Yes!!\n";
-                       std::cout << "\tVirtual URI: " << tmpObj.getUri() << std::endl;
-                       std::cout << "\tVirtual Resource Handle: " << tmpObj.getResourceHandle() << std::endl;
-                       std::cout << endl;
-                       std::cout << "========================================================" << endl;
-                       std::cout << "Send Virtual Resource: "  << endl;
-                       std::cout << "\tResource URI: " << tmpObj.getUri() << endl;
-#endif
-                       result = OCPlatform::notifyObservers(tmpObj.getResourceHandle());
-               }
-               else
-               {
-#if ISFORLINUX
-                       std::cout << "No!!\n";
-#endif
-#if ISFORTIZEN
-#endif
-               }
-
-       if(OC_STACK_NO_OBSERVERS == result)
-               {
-#if ISFORLINUX
-                       std::cout << "Nothing!!" << endl;
-#endif
-               }
-
-    }
-    else
-    {
-        std::cout << "onObserve Response error: " << eCode << std::endl;
-        std::exit(-1);
-    }
-}
diff --git a/service/Notification-Manager/SampleApp/tizen/sampleNM/NM/VirtualRepresentation.h b/service/Notification-Manager/SampleApp/tizen/sampleNM/NM/VirtualRepresentation.h
deleted file mode 100644 (file)
index 2d42122..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-#ifndef VIRTUALREPRESENTATION_H_
-#define VIRTUALREPRESENTATION_H_
-
-#include <functional>
-#include <condition_variable>
-
-#include "OCPlatform.h"
-#include "OCApi.h"
-#include "NotificationManager.h"
-
-#define SUCCESS_RESPONSE 0
-
-using namespace OC;
-using namespace std;
-
-class ResourceManager;
-
-class VirtualRepresentation{
-
-private:
-       std::string     virtualUri;
-       std::string     originHostIP;
-       std::string     resourceTypeName;
-       std::string     resourceInterface;
-       uint8_t                 resourceProperty;
-
-       OCResourceHandle m_resourceHandle;
-
-       static AttributeMap attributeMap;
-       static std::mutex mutexAttributeMap;
-       static std::condition_variable conditionAttributeMap;
-       static bool isReadyAttributeMap;
-
-       int getRepresentation(OCRepresentation& oc);
-
-public:
-
-       std::string             getUri();
-       std::string             getHostIP();
-       std::string             getResourceTypeName();
-       std::string             getResourceInterface();
-       uint8_t                         getResourceProperty();
-       OCResourceHandle        getResourceHandle();
-
-       int setUri(std::string uri);
-       int setHostIP(std::string ip);
-       int setResourceTypeName(std::string typeName);
-       int setResourceInterface(std::string interface);
-       int setResourceProperty(uint8_t property);
-       int setResourceHandle(OCResourceHandle & handle);
-
-public:
-       VirtualRepresentation();
-       virtual ~VirtualRepresentation();
-
-       std::string addVirtualTag(std::string uri);
-
-       void entityHandler(std::shared_ptr<OCResourceRequest> request, std::shared_ptr<OCResourceResponse> response);
-       void onObserve(const OCRepresentation& rep, const int& eCode, const int& sequenceNumber);
-
-};
-
-#endif /* VIRTUALREPRESENTATION_H_ */
diff --git a/service/Notification-Manager/SampleApp/tizen/sampleNM/src/oicapp-sampleNM.cpp b/service/Notification-Manager/SampleApp/tizen/sampleNM/src/oicapp-sampleNM.cpp
deleted file mode 100644 (file)
index 2cb044d..0000000
+++ /dev/null
@@ -1,601 +0,0 @@
-/*
- * oicapp-test.cpp
- *
- *  Created on: Aug 29, 2014
- *      Author: parhi
- */
-
-#include <appcore-efl.h>
-#include <Ecore_X.h>
-#include <efl_assist.h>
-
-#include "oicapp-sampleNM.h"
-#include "oicapp-utils.h"
-
-#include "NotificationManager.h"
-
-const char* OICAPP_STR_NM = "Notification Manager";
-const char* OICAPP_STR_URI = "uri : ";
-const char* OICAPP_STR_HOST = "host : ";
-const char* OICAPP_STR_TEMP = "temperature : ";
-const char* OICAPP_STR_HUMID = "humidity : ";
-
-static oicappData *g_current_ad = nullptr;
-std::shared_ptr< OCResource > g_curResource;
-
-static void _update_resource(oicappData * ad , Elm_Object_Item * elm_item , const char* type ,
-        const char* value);
-
-class NMHandler
-{
-public:
-
-    static std::function< void(std::shared_ptr< OCResource > resource) > s_startHosting;
-    static std::function< void() > s_findHostingCandidate;
-    static std::function< void(std::string) > s_addExtraStr;
-
-    void Observe(AttributeMap &inputAttMap)
-    {
-        DBG("Onobserve");
-
-        std::string tmpStr[2];
-        int index = 0;
-        for(auto it = inputAttMap.begin() ; it != inputAttMap.end() ; ++it)
-        {
-            tmpStr[index] = it->first;
-            tmpStr[index].append(" : ");
-            for(auto value = it->second.begin() ; value != it->second.end() ; ++value)
-            {
-                tmpStr[index].append(*value);
-            }
-            index++;
-        }
-
-        _update_resource(g_current_ad , g_current_ad->itemTemp , "" , tmpStr[0].c_str());
-        _update_resource(g_current_ad , g_current_ad->itemHumid , "" , tmpStr[1].c_str());
-    }
-
-    void Found(std::shared_ptr< OCResource > resource)
-    {
-        g_curResource = resource;
-
-        std::string uri = resource->uri();
-        std::string host = resource->host();
-        std::string type = *(resource->getResourceTypes().data());
-
-        _update_resource(g_current_ad , g_current_ad->itemUri , OICAPP_STR_URI , uri.c_str());
-        _update_resource(g_current_ad , g_current_ad->itemHost , OICAPP_STR_HOST , host.c_str());
-    }
-};
-
-std::function< void(std::shared_ptr< OCResource > resource) > NMHandler::s_startHosting;
-std::function< void() > NMHandler::s_findHostingCandidate;
-std::function< void(std::string) > NMHandler::s_addExtraStr;
-
-NMHandler handle;
-
-static Elm_Object_Item* oicapp_append_separator(Evas_Object *genlist , oicappData *ad)
-{
-    DBG("Enter");
-    Elm_Object_Item *item = NULL;
-
-    item = elm_genlist_item_append(genlist , &ad->itcSeperator , NULL , NULL ,
-            ELM_GENLIST_ITEM_NONE , NULL , NULL);
-    elm_genlist_item_select_mode_set(item , ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
-    DBG("LEAVE");
-    return item;
-}
-
-static void _win_del(void *data , Evas_Object *obj , void *event)
-{
-    DBG("ENTER - test _win_del()");
-    elm_exit();
-    DBG("LEAVE - test _win_del()");
-}
-
-static Evas_Object* oicapp_create_win(const char *name)
-{
-    DBG("Enter");
-    Evas_Object *eo;
-    int w , h;
-
-    eo = elm_win_add(NULL , name , ELM_WIN_BASIC);
-    if(eo)
-    {
-        elm_win_title_set(eo , name);
-        elm_win_borderless_set(eo , EINA_TRUE);
-        evas_object_smart_callback_add(eo , "delete,request" , _win_del , NULL);
-        ecore_x_window_size_get(ecore_x_window_root_first_get() , &w , &h);
-        evas_object_resize(eo , w , h);
-        elm_win_indicator_mode_set(eo , ELM_WIN_INDICATOR_SHOW);
-        elm_win_indicator_opacity_set(eo , ELM_WIN_INDICATOR_OPAQUE);
-    }
-
-    evas_object_show(eo);
-    DBG("LEAVE");
-    return eo;
-}
-
-static Evas_Object* oicapp_create_bg(Evas_Object *parent)
-{
-    DBG("Enter");
-    Evas_Object *bg;
-
-    bg = elm_bg_add(parent);
-    evas_object_size_hint_weight_set(bg , EVAS_HINT_EXPAND , EVAS_HINT_EXPAND);
-    elm_win_resize_object_add(parent , bg);
-    evas_object_show(bg);
-    DBG("LEAVE");
-
-    return bg;
-}
-
-static Evas_Object* oicapp_create_base_layout(Evas_Object *parent)
-{
-    DBG("Enter");
-    Evas_Object *base;
-
-    base = elm_layout_add(parent);
-    elm_layout_theme_set(base , "layout" , "application" , "default");
-    evas_object_size_hint_weight_set(base , EVAS_HINT_EXPAND , EVAS_HINT_EXPAND);
-    evas_object_show(base);
-
-    DBG("LEAVE");
-    return base;
-}
-
-void __gl_realized_cb(void *data , Evas_Object *obj , void *event_info)
-{
-    DBG("Enter");
-    Elm_Object_Item *item = (Elm_Object_Item *) event_info;
-
-    elm_object_item_signal_emit(item , "elm,state,normal" , "");
-    DBG("LEAVE");
-}
-
-static Evas_Object* oicapp_create_genlist(Evas_Object *parent)
-{
-    DBG("Enter");
-    Evas_Object *genlist;
-
-    genlist = elm_genlist_add(parent);
-    if(NULL == genlist)
-    {
-        ERR("elm_genlist_add() Fail");
-        return NULL;
-    }
-
-    elm_object_style_set(genlist , "dialogue");
-    evas_object_size_hint_weight_set(genlist , EVAS_HINT_EXPAND , EVAS_HINT_EXPAND);
-    evas_object_show(genlist);
-
-    evas_object_smart_callback_add(genlist , "realized" , __gl_realized_cb , NULL);
-
-    DBG("LEAVE");
-    return genlist;
-}
-
-static Elm_Object_Item* _gl_append_item(oicappData *ad , Elm_Genlist_Item_Class *itc ,
-        const char * title , Evas_Smart_Cb sel_func)
-{
-    DBG("Enter");
-    Elm_Object_Item *item;
-    oicappItemData *it_data;
-
-    it_data = (oicappItemData *) calloc(1 , sizeof(oicappItemData));
-    it_data->title = title;
-    it_data->ad = ad;
-
-    item = elm_genlist_item_append(ad->genlist , itc , it_data , NULL , ELM_GENLIST_ITEM_NONE ,
-            sel_func , ad);
-
-    DBG("LEAVE");
-    return item;
-}
-
-static Elm_Object_Item* _gl_append_btn(oicappData *ad , Elm_Genlist_Item_Class *itc)
-{
-    DBG("Enter");
-    Elm_Object_Item *item;
-
-    item = elm_genlist_item_append(ad->genlist , itc , ad , NULL , ELM_GENLIST_ITEM_NONE , NULL ,
-            NULL);
-
-    elm_genlist_item_select_mode_set(item , ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
-
-    DBG("LEAVE");
-    return item;
-}
-
-static char* _gl_text_get(void *data , Evas_Object *obj , const char *part)
-{
-    DBG("Enter");
-    oicappItemData *it_data = (oicappItemData *) data;
-
-    DBG("title : %s" , it_data->title);
-
-    DBG("Leave");
-    return strdup(it_data->title);
-}
-
-static void oicapp_append_contents(oicappData *ad)
-{
-    DBG("Enter");
-    Elm_Object_Item *item;
-
-    _gl_append_item(ad , &ad->itcTitle , OICAPP_STR_NM , NULL);
-
-    item = _gl_append_item(ad , &ad->itcText , OICAPP_STR_URI , NULL);
-    ad->itemUri = item;
-
-    item = _gl_append_item(ad , &ad->itcText , OICAPP_STR_HOST , NULL);
-    ad->itemHost = item;
-
-    _gl_append_btn(ad , &ad->itcBtnFindResource);
-
-    item = _gl_append_item(ad , &ad->itcText , OICAPP_STR_TEMP , NULL);
-    ad->itemTemp = item;
-
-    item = _gl_append_item(ad , &ad->itcText , OICAPP_STR_HUMID , NULL);
-    ad->itemHumid = item;
-
-    item = _gl_append_item(ad , &ad->itcEdit , NULL , NULL);
-
-    _gl_append_btn(ad , &ad->itcBtnApplyExtraStr);
-    _gl_append_btn(ad , &ad->itcBtnStartHost);
-
-    oicapp_append_separator(ad->genlist , ad);
-    DBG("Leave");
-}
-
-static Evas_Object* oicapp_create_conform(Evas_Object *win)
-{
-    DBG("Enter");
-    Evas_Object *conform = NULL;
-    conform = elm_conformant_add(win);
-
-    evas_object_size_hint_weight_set(conform , EVAS_HINT_EXPAND , EVAS_HINT_EXPAND);
-    elm_win_resize_object_add(win , conform);
-    evas_object_show(conform);
-
-    Evas_Object *bg_indicator = elm_bg_add(conform);
-    elm_object_style_set(bg_indicator , "indicator/headerbg");
-    elm_object_part_content_set(conform , "elm.swallow.indicator_bg" , bg_indicator);
-    evas_object_show(bg_indicator);
-
-    DBG("Leave");
-    return conform;
-}
-
-static Eina_Bool _back_cb(void *data , Elm_Object_Item *item)
-{
-    DBG("Enter");
-    elm_exit();
-    DBG("Leave");
-    return EINA_FALSE;
-}
-
-static void _update_resource(oicappData * ad , Elm_Object_Item * elm_item , const char* type ,
-        const char* value)
-{
-    DBG("Enter");
-    oicappItemData* it_data;
-    char* temp;
-    temp = (char*) calloc(100 , sizeof(char));
-    strcpy(temp , type);
-    strcat(temp , value);
-
-    it_data = (oicappItemData*) calloc(1 , sizeof(oicappItemData));
-    it_data->ad = ad;
-    it_data->title = temp;
-
-    DBG("it_data->title : %s" , it_data->title);
-
-    elm_object_item_data_set(elm_item , it_data);
-    elm_genlist_item_update(elm_item);
-    DBG("LEAVE");
-}
-static void _btn_findresource_clicked(void *data , Evas_Object *obj , void *event_info)
-{
-    DBG("Enter");
-    g_current_ad = (oicappData *) data;
-
-    handle.s_findHostingCandidate();
-
-    DBG("Leave");
-}
-
-static void _btn_starthost_clicked(void *data , Evas_Object *obj , void *event_info)
-{
-    DBG("Enter");
-    g_current_ad = (oicappData *) data;
-
-    handle.s_startHosting(g_curResource);
-
-    DBG("Leave");
-}
-
-static void _btn_apply_clicked(void *data , Evas_Object *obj , void *event_info)
-{
-    DBG("Enter");
-    g_current_ad = (oicappData *) data;
-
-    if( g_current_ad->inputMsg != nullptr )
-    {
-        DBG("current_ad->input_msg : %s" , g_current_ad->inputMsg);
-        char *tmp_s = strdup(g_current_ad->inputMsg);
-
-        DBG("Onobserve_addstrTmp");
-        handle.s_addExtraStr(tmp_s);
-        DBG("Onobserve_addstr done");
-    }
-
-    DBG("Leave");
-}
-
-static Evas_Object* _gl_btn_findresource_content_get(void *data , Evas_Object *obj ,
-        const char *part)
-{
-    DBG("Enter");
-    Evas_Object *button;
-    oicappData *ad = (oicappData *) data;
-
-    button = elm_button_add(obj);
-    elm_object_part_text_set(button , NULL , "Find Resource");
-    evas_object_propagate_events_set(button , EINA_FALSE);
-    evas_object_smart_callback_add(button , "clicked" , _btn_findresource_clicked , ad);
-
-    DBG("Leave");
-    return button;
-}
-
-static Evas_Object* _gl_btn_starthost_content_get(void *data , Evas_Object *obj , const char *part)
-{
-    DBG("Enter");
-    Evas_Object *button;
-    oicappData *ad = (oicappData *) data;
-
-    button = elm_button_add(obj);
-    elm_object_part_text_set(button , NULL , "Start Host");
-    evas_object_propagate_events_set(button , EINA_FALSE);
-    evas_object_smart_callback_add(button , "clicked" , _btn_starthost_clicked , ad);
-
-    DBG("Leave");
-    return button;
-}
-
-static Evas_Object* _gl_btn_applyEXstr_content_get(void *data , Evas_Object *obj , const char *part)
-{
-    DBG("Enter");
-    Evas_Object *button;
-    oicappData *ad = (oicappData *) data;
-
-    button = elm_button_add(obj);
-    elm_object_part_text_set(button , NULL , "APPLY");
-    evas_object_propagate_events_set(button , EINA_FALSE);
-    evas_object_smart_callback_add(button , "clicked" , _btn_apply_clicked , ad);
-
-    DBG("Leave");
-    return button;
-}
-
-static void _edit_unfocused(void *data , Evas_Object *obj , void *event_info)
-{
-    DBG("Enter");
-
-    oicappData *ad = (oicappData *) data;
-    DBG("ad : %p" , ad);
-    ad->inputMsg = strdup(elm_entry_entry_get(obj));
-    g_current_ad->inputMsg = strdup(elm_entry_entry_get(obj));
-    DBG("Clicked : %s" , ad->inputMsg);
-    DBG("LEAVE");
-}
-static Evas_Object* _gl_edit_content_get(void *data , Evas_Object *obj , const char *part)
-{
-    DBG("Enter");
-    oicappData *ad = (oicappData *) data;
-    DBG("ad : %p" , ad);
-    Evas_Object *entry = ea_editfield_add(obj , EA_EDITFIELD_SINGLELINE);
-    ea_editfield_clear_button_disabled_set(entry , EINA_TRUE);
-    ad->inputMsg = nullptr;
-    elm_entry_entry_set(entry , ad->inputMsg);
-    evas_object_smart_callback_add(entry , "unfocused" , _edit_unfocused , ad);
-
-    DBG("LEAVE");
-    return entry;
-}
-
-static void _gl_item_del(void *data , Evas_Object *obj)
-{
-    DBG("Enter");
-    if(data != NULL)
-        free(data);
-    DBG("LEAVE");
-}
-
-static inline void oicapp_init_itcs(oicappData *ad)
-{
-    DBG("Enter");
-    ad->itcSeperator.item_style = "dialogue/separator";
-    ad->itcSeperator.func.text_get = NULL;
-    ad->itcSeperator.func.content_get = NULL;
-    ad->itcSeperator.func.state_get = NULL;
-    ad->itcSeperator.func.del = NULL;
-
-    ad->itcTitle.item_style = "dialogue/title";
-    ad->itcTitle.func.text_get = _gl_text_get;
-    ad->itcTitle.func.content_get = NULL;
-    ad->itcTitle.func.state_get = NULL;
-    ad->itcTitle.func.del = _gl_item_del;
-
-    ad->itcText.item_style = "dialogue/1text";
-    ad->itcText.func.text_get = _gl_text_get;
-    ad->itcText.func.content_get = NULL;
-    ad->itcText.func.state_get = NULL;
-    ad->itcText.func.del = _gl_item_del;
-
-    ad->itcBtnFindResource.item_style = "dialogue/1icon";
-    ad->itcBtnFindResource.func.text_get = NULL;
-    ad->itcBtnFindResource.func.content_get = _gl_btn_findresource_content_get;
-    ad->itcBtnFindResource.func.state_get = NULL;
-    ad->itcBtnFindResource.func.del = NULL;
-
-    DBG("edit before ad : %p" , ad);
-
-    ad->itcEdit.item_style = "dialogue/editfield";
-    ad->itcEdit.func.text_get = NULL;
-    ad->itcEdit.func.content_get = _gl_edit_content_get;
-    ad->itcEdit.func.state_get = NULL;
-    ad->itcEdit.func.del = NULL;
-
-    DBG("edit after ad : %p" , ad);
-
-    ad->itcBtnApplyExtraStr.item_style = "dialogue/1icon";
-    ad->itcBtnApplyExtraStr.func.text_get = NULL;
-    ad->itcBtnApplyExtraStr.func.content_get = _gl_btn_applyEXstr_content_get;
-    ad->itcBtnApplyExtraStr.func.state_get = NULL;
-    ad->itcBtnApplyExtraStr.func.del = NULL;
-
-    ad->itcBtnStartHost.item_style = "dialogue/1icon";
-    ad->itcBtnStartHost.func.text_get = NULL;
-    ad->itcBtnStartHost.func.content_get = _gl_btn_starthost_content_get;
-    ad->itcBtnStartHost.func.state_get = NULL;
-    ad->itcBtnStartHost.func.del = NULL;
-    DBG("Leave");
-}
-
-static int oicapp_create(void *data)
-{
-    DBG("Enter");
-    oicappData *ad = (oicappData *) data;
-    Elm_Object_Item *it;
-
-    oicapp_init_itcs(ad);
-
-    // create window
-    ad->win = oicapp_create_win(PACKAGE);
-    if(NULL == ad->win)
-        return -1;
-
-    ad->bg = oicapp_create_bg(ad->win);
-    if(NULL == ad->bg)
-        return -1;
-
-    ad->conform = oicapp_create_conform(ad->win);
-    if(NULL == ad->conform)
-        return -1;
-
-    // create layout
-    ad->base = oicapp_create_base_layout(ad->conform);
-    if(NULL == ad->base)
-        return -1;
-    elm_object_content_set(ad->conform , ad->base);
-
-    ad->navi = elm_naviframe_add(ad->base);
-    elm_object_part_content_set(ad->base , "elm.swallow.content" , ad->navi);
-
-    ea_object_event_callback_add(ad->navi , EA_CALLBACK_BACK , ea_naviframe_back_cb , NULL);
-
-    ad->genlist = oicapp_create_genlist(ad->navi);
-
-    it = elm_naviframe_item_push(ad->navi , "NM - OIC Tester" , NULL , NULL , ad->genlist , NULL);
-    elm_naviframe_item_pop_cb_set(it , _back_cb , ad);
-
-    ad->ipAddr = oicapp_util_wifi();
-    if(NULL == ad->ipAddr)
-    {
-        ERR("wifi is not connected");
-    }
-    else
-    {
-        INFO("IP Address = %s" , ad->ipAddr);
-    }
-    oicapp_append_contents(ad);
-
-    // initialize NotificationManager
-
-    NotificationManager *Ptr = NotificationManager::getInstance();
-    Ptr->initialize();
-    Ptr->setOnFoundHostingCandidate(
-            std::function< void(std::shared_ptr< OCResource > resource) >(
-                    std::bind(&NMHandler::Found , handle , std::placeholders::_1)));
-    Ptr->setOnObserve(
-            std::function< void(AttributeMap &inputAttMap) >(
-                    std::bind(&NMHandler::Observe , handle , std::placeholders::_1)));
-
-    Ptr->setFindHosting(handle.s_findHostingCandidate);
-    Ptr->setStartHosting(handle.s_startHosting);
-    Ptr->setAddExtraStr(handle.s_addExtraStr);
-    DBG("Leave");
-    return 0;
-}
-
-static int oicapp_terminate(void *data)
-{
-    DBG("Enter");
-    oicappData *ad = (oicappData *) data;
-
-    DBG("Enter evas_object_del(ad->win)");
-    if(ad->win)
-        evas_object_del(ad->win);
-    DBG("Leave evas_object_del(ad->win)");
-
-    DBG("Enter ap->ip_addr");
-    free(ad->ipAddr);
-    DBG("Leave free(ad->ip_addr)");
-    DBG("Enter free(ad)");
-    DBG("Leave free(ad)");
-    DBG("Leave");
-    return 0;
-}
-
-static int oicapp_pause(void *data)
-{
-    DBG("Enter");
-    DBG("Leave");
-    return 0;
-}
-
-static int oicapp_resume(void *data)
-{
-    DBG("Enter");
-    static int tmpCnt = 0;
-    char buf[1024];
-
-    snprintf(buf , sizeof(buf) , "Test %d" , tmpCnt++);
-
-    DBG("Leave");
-    return 0;
-}
-
-static int oicapp_reset(bundle *b , void *data)
-{
-    DBG("Enter");
-    oicappData *ad = (oicappData *) data;
-
-    if(ad->win)
-        elm_win_activate(ad->win);
-
-    DBG("Leave");
-    return 0;
-}
-
-int main(int argc , char *argv[])
-{
-    oicappData ad;
-    g_current_ad = &ad;
-
-    struct appcore_ops ops;
-
-    ops.create = oicapp_create;
-    ops.terminate = oicapp_terminate;
-    ops.pause = oicapp_pause;
-    ops.resume = oicapp_resume;
-    ops.reset = oicapp_reset;
-
-    memset(&ad , 0x00 , sizeof(oicappData));
-    ops.data = &ad;
-    DBG("&ad : %p" , &ad);
-
-    return appcore_efl_main(PACKAGE , &argc , &argv , &ops);
-}
diff --git a/service/Notification-Manager/SampleApp/tizen/sampleNM/src/oicapp-sampleNM.h b/service/Notification-Manager/SampleApp/tizen/sampleNM/src/oicapp-sampleNM.h
deleted file mode 100644 (file)
index a823aa3..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 2010 Samsung Electronics, Inc.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information
- * of Samsung Electronics, Inc. ("Confidential Information").  You
- * shall not disclose such Confidential Information and shall use
- * it only in accordance with the terms of the license agreement
- * you entered into with Samsung Electronics.
- */
-
-#ifndef __OICAPP_TEST_H__
-#define __OICAPP_TEST_H__
-
-#include <Elementary.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include "oicapp-log.h"
-
-#if !defined(PACKAGE)
-#  define PACKAGE "oicapp-test"
-#endif
-
-#if !defined(LOCALEDIR)
-#  define LOCALEDIR "/usr/apps/com.samsung.oicapp-test/res/locale"
-#endif
-
-#if !defined(EDJDIR)
-#  define EDJDIR "/usr/apps/com.samsung.oicapp-test/res/edje"
-#endif
-
-#define GRP_MAIN "main"
-
-       typedef enum {
-               OICAPP_MODE_NONE = 0,
-               OICAPP_MODE_CLIENT,
-               OICAPP_MODE_SERVER,
-               OICAPP_MODE_MAX
-       }oicappMode;
-
-       enum {
-               OICAPP_GENLIST_GRP_NONE = 0,
-               OICAPP_GENLIST_GRP_TOP,
-               OICAPP_GENLIST_GRP_CENTER,
-               OICAPP_GENLIST_GRP_BOTTOM
-       };
-
-
-       typedef struct
-       {
-               Evas_Object *win;
-               Evas_Object *base;
-               Evas_Object *bg;
-               Evas_Object *navi;
-               Evas_Object *genlist;
-               Evas_Object *popup;
-               Evas_Object *conform;
-
-               Elm_Object_Item *itemTitle;
-               Elm_Object_Item *itemUri;
-               Elm_Object_Item *itemHost;
-               Elm_Object_Item *itemTemp;
-               Elm_Object_Item *itemHumid;
-               Elm_Object_Item *itemMultiLine;
-               Elm_Object_Item *itemApplyExtraStr;
-
-
-               Elm_Genlist_Item_Class itcTitle;
-               Elm_Genlist_Item_Class itcText;
-               Elm_Genlist_Item_Class itcSeperator;
-               Elm_Genlist_Item_Class itcEdit;
-               Elm_Genlist_Item_Class itcEdit2;
-               Elm_Genlist_Item_Class itcBtnStartHost;
-               Elm_Genlist_Item_Class itcBtnApplyExtraStr;
-               Elm_Genlist_Item_Class itcBtnFindResource;
-
-               char *ipAddr;
-               char *inputMsg;
-               char *outputMsg;
-
-       }oicappData;
-
-       typedef struct
-       {
-               oicappData *ad;
-               const char *title;
-
-       }oicappItemData;
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__OICAPP_TEST_H__
-
diff --git a/service/Notification-Manager/SampleApp/tizen/sampleNM/src/oicapp-utils.c b/service/Notification-Manager/SampleApp/tizen/sampleNM/src/oicapp-utils.c
deleted file mode 100644 (file)
index 7eda787..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2014 Samsung Electronics, Inc.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information
- * of Samsung Electronics, Inc. ("Confidential Information").  You
- * shall not disclose such Confidential Information and shall use
- * it only in accordance with the terms of the license agreement
- * you entered into with Samsung Electronics.
- */
-#include <appcore-efl.h>
-#include <wifi.h>
-
-#include "oicapp-utils.h"
-
-static void _popup_timeout_cb(void *data, Evas_Object *obj, void *event_info)
-{
-    oicappData *ad = data;
-
-       ret_if(data == NULL);
-
-       ad->popup = NULL;
-}
-
-void oicapp_fail_popup(oicappData *ad, char *title, char *text, int timeout)
-{
-       if (ad->popup)
-       {
-               evas_object_del(ad->popup);
-               ad->popup = NULL;
-       }
-
-       Evas_Object *popup = elm_popup_add(ad->win);
-       evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-
-       if (title)
-               elm_object_part_text_set(popup, "title,text", title);
-
-       if (text)
-               elm_object_text_set(popup, text);
-
-       if (0 < timeout)
-               elm_popup_timeout_set(popup, timeout);
-       else
-               elm_popup_timeout_set(popup, 3);
-
-       evas_object_smart_callback_add(popup, "timeout", _popup_timeout_cb, ad);
-
-       evas_object_show(popup);
-
-       ad->popup = popup;
-}
-
-char* oicapp_util_wifi()
-{
-       int ret;
-       wifi_ap_h ap;
-       char *ip_addr = NULL;
-
-       ret = wifi_initialize();
-       if (WIFI_ERROR_NONE != ret)
-       {
-               ERR("wifi_initialize() Fail");
-               return NULL;
-       }
-
-       ret = wifi_get_connected_ap(&ap);
-       if (WIFI_ERROR_NONE != ret)
-       {
-               ERR("wifi_get_connected_ap() Fail");
-               return NULL;
-       }
-
-       ret = wifi_ap_get_ip_address(ap, WIFI_ADDRESS_FAMILY_IPV4, &ip_addr);
-       if (WIFI_ERROR_NONE != ret)
-       {
-               ERR("wifi_ap_get_ip_address() Fail");
-               return NULL;
-       }
-
-       return ip_addr;
-}
-
diff --git a/service/Notification-Manager/SampleApp/tizen/sampleNM/src/oicapp-utils.h b/service/Notification-Manager/SampleApp/tizen/sampleNM/src/oicapp-utils.h
deleted file mode 100644 (file)
index d6f5fcc..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2010 Samsung Electronics, Inc.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information
- * of Samsung Electronics, Inc. ("Confidential Information").  You
- * shall not disclose such Confidential Information and shall use
- * it only in accordance with the terms of the license agreement
- * you entered into with Samsung Electronics.
- */
-#ifndef __OICAPP_UTILS_H__
-#define __OICAPP_UTILS_H__
-
-#include "oicapp-sampleNM.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-void oicapp_fail_popup(oicappData *ad, char *title, char *text, int timeout);
-char* oicapp_util_wifi();
-
-int oicapp_client_start(oicappData *ad);
-void oicapp_client_stop();
-int oicapp_client_put(int power, int level);
-
-int oicapp_server_start(oicappData *ad);
-void oicapp_server_stop();
-void oicapp_server_put(int power, int level);
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__OICAPP_UTILS_H__
-
@@ -4,15 +4,16 @@ OCPATH = ../../../../../resource
 OCINCLUDE = $(OCPATH)/include
 STACKINCLUDE = $(OCPATH)/csdk/stack/include
 SOCKETINCLUDE = $(OCPATH)/csdk/ocsocket/include
+OCLOGGERINCLUDE = $(OCPATH)/oc_logger/include
 NOTIFICATIONINCLUDE = ../../include
 BOOSTPATH = ../../../../../boost_1_51_0
 
 CXX=g++
-CXXFLAGS = -O2 -g -Wall -fmessage-length=0 -std=c++0x -I$(NOTIFICATIONINCLUDE) -I$(OCINCLUDE) -I$(STACKINCLUDE) -I$(SOCKETINCLUDE) -I$(BOOSTPATH)
+CXXFLAGS = -O2 -g -Wall -fmessage-length=0 -std=c++0x -I$(NOTIFICATIONINCLUDE) -I$(OCINCLUDE) -I$(STACKINCLUDE) -I$(SOCKETINCLUDE) -I$(OCLOGGERINCLUDE) -I$(BOOSTPATH)
 
 OBJS =  ResourceManager.o RegistrationManager.o VirtualRepresentation.o NotificationManager.o LinuxMain.o
 
-LIBS = $(OCPATH)/build/linux/release/obj/liboc.a $(OCPATH)/csdk/build/linux/release/liboctbstack.a
+LIBS = $(OCPATH)/release/obj/liboc.a $(OCPATH)/csdk/linux/release/liboctbstack.a $(OCPATH)/oc_logger/lib/oc_logger.a
 
 all:   NotificationManager SampleProvider SampleConsumer
 
@@ -28,6 +28,7 @@
 #include <memory>
 #include <string>
 #include <vector>
+#include <list>
 
 #include "OCApi.h"
 #include "OCPlatform.h"
@@ -43,6 +44,7 @@
 #define ISFORDEMO 1
 
 using namespace OC;
+using namespace OCPlatform;
 
 const std::string VIRTURL_TAG = "/virtual";
 
@@ -52,7 +54,7 @@ class NotificationManager
 private:
 
     static NotificationManager *s_instance;
-    static OCPlatform *s_nmOCPlatform;
+//    static OCPlatform *s_nmOCPlatform;
 
     static PlatformConfig s_cfg;
 
@@ -70,11 +72,10 @@ public:
     ~NotificationManager();
 
     static NotificationManager *getInstance();
-    static OCPlatform *getOCPlatform();
 
     void initialize();
     void findHostingCandidate();
-    void registerHostingEvent();
+    void registerHostingEventListener();
 
     int setPrint(std::function< void(AttributeMap &inputAttMap) > func);
     int setOnFoundHostingCandidate(
@@ -31,6 +31,7 @@
 #define SUCCESS_RESPONSE 0
 
 using namespace OC;
+using namespace OCPlatform;
 using namespace std;
 
 class ResourceManager;
@@ -76,9 +77,10 @@ public:
 
     std::string addVirtualTag(std::string uri);
 
-    void entityHandler(std::shared_ptr< OCResourceRequest > request ,
-            std::shared_ptr< OCResourceResponse > response);
-    void onObserve(const OCRepresentation& rep , const int& eCode , const int& sequenceNumber);
+    OCEntityHandlerResult entityHandler(const std::shared_ptr<OCResourceRequest> request ,
+               const std::shared_ptr<OCResourceResponse> response);
+    void onObserve(const HeaderOptions &headerOption, const OCRepresentation &rep ,
+            const int eCode , const int sequenceNumber);
 
 };
 
@@ -93,7 +93,20 @@ int main(void)
 
     while(true)
     {
-        // todo something
+       char signal;
+       cin >> signal;
+
+       switch(signal)
+       {
+       case 'q':
+       case 'Q':
+               std::cout << endl;
+                       std::cout << "========================================================" << endl;
+                       std::cout << "End Notification Manager : Hosting v0.5\n";
+               return true;
+       default:
+               break;
+       }
     }
 
     std::cout << endl;
@@ -21,9 +21,9 @@
 #include "NotificationManager.h"
 
 NotificationManager *NotificationManager::s_instance = NULL;
-OCPlatform *NotificationManager::s_nmOCPlatform = NULL;
-PlatformConfig NotificationManager::s_cfg(ServiceType::InProc, ModeType::Both,
-        "134.134.161.33", 5683, QualityOfService::NonConfirmable);
+//OCPlatform *NotificationManager::s_nmOCPlatform = NULL;
+PlatformConfig NotificationManager::s_cfg;
+//(ServiceType::InProc, ModeType::Both, "134.134.161.33", 5683, QualityOfService::NonConfirmable);
 
 NotificationManager::NotificationManager()
 {
@@ -38,17 +38,12 @@ NotificationManager::NotificationManager()
 
 NotificationManager::~NotificationManager()
 {
-    if(s_nmOCPlatform != NULL)
-    {
-        delete s_nmOCPlatform;
-        s_nmOCPlatform = NULL;
-    }
 }
 
 void NotificationManager::initialize()
 {
 
-    s_nmOCPlatform = new OCPlatform(s_cfg);
+    Configure(s_cfg);
 
     setPrint(NULL);
     setOnFoundHostingCandidate(NULL);
@@ -62,7 +57,7 @@ void NotificationManager::initialize()
 
 }
 
-void NotificationManager::registerHostingEvent()
+void NotificationManager::registerHostingEventListener()
 {
     // TODO : Initial HostingEventListener (v1.0)
 }
@@ -88,15 +83,6 @@ NotificationManager *NotificationManager::getInstance()
     return s_instance;
 }
 
-OCPlatform *NotificationManager::getOCPlatform()
-{
-    if(!s_nmOCPlatform)
-    {
-        s_nmOCPlatform = new OCPlatform(s_cfg);
-    }
-    return s_nmOCPlatform;
-}
-
 int NotificationManager::setPrint(std::function< void(AttributeMap &inputAttMap) > func)
 {
     if(func != NULL)
@@ -64,11 +64,12 @@ bool RegistrationManager::registerNMResource(VirtualRepresentation &resourceObje
     OCResourceHandle resourceHandle;
 
     OCStackResult result;
-    result = NotificationManager::getOCPlatform()->registerResource(resourceHandle , uri , type ,
+
+    result = registerResource(resourceHandle , uri , type ,
             interface ,
             std::function<
-                    void(std::shared_ptr< OCResourceRequest > request ,
-                            std::shared_ptr< OCResourceResponse > response) >(
+                    OCEntityHandlerResult(const std::shared_ptr< OCResourceRequest > request ,
+                            const std::shared_ptr< OCResourceResponse > response) >(
                     std::bind(&VirtualRepresentation::entityHandler , resourceObject ,
                             std::placeholders::_1 , std::placeholders::_2)) ,
             resourceObject.getResourceProperty());
@@ -83,11 +84,12 @@ bool RegistrationManager::registerNMResource(VirtualRepresentation &resourceObje
         QueryParamsMap queryParmaMap;
         resource->observe(ObserveType::Observe , queryParmaMap ,
                 std::function<
-                        void(const OCRepresentation& rep , const int& eCode ,
-                                const int& sequenceNumber) >(
+                        void(const HeaderOptions headerOption,
+                                       const OCRepresentation& rep , const int eCode ,
+                                const int sequenceNumber) >(
                         std::bind(&VirtualRepresentation::onObserve , resourceObject ,
                                 std::placeholders::_1 , std::placeholders::_2 ,
-                                std::placeholders::_3)));
+                                std::placeholders::_3 , std::placeholders::_4)));
     }
 
     return true;
@@ -62,7 +62,7 @@ VirtualRepresentation ResourceManager::findVirtualRepresentation(std::string uri
 OCStackResult ResourceManager::findNMResource(const std::string& host ,
         const std::string& resourceName , bool ishosting)
 {
-    return NotificationManager::getOCPlatform()->findResource(host , resourceName ,
+       return findResource(host , resourceName ,
             std::function< void(std::shared_ptr< OCResource > resource) >(
                     std::bind(&ResourceManager::foundResourceforhosting , this ,
                             std::placeholders::_1)));
@@ -129,32 +129,8 @@ AttributeMap ResourceManager::copyAttributeMap(AttributeMap &inputAttMap)
 
     AttributeMap retAttMap;
 
-    for(auto it = inputAttMap.begin() ; it != inputAttMap.end() ; ++it)
-    {
-        AttributeValues tmpVal;
+    retAttMap = inputAttMap;
 
-        for(auto valueItr = it->second.begin() ; valueItr != it->second.end() ; ++valueItr)
-        {
-            std::string tmpStr;
-#if ISFORDEMO
-            if(it->first == "temperature" && !s_extraStr.empty())
-            {
-                tmpStr.append(s_extraStr);
-                tmpStr.append(":");
-                tmpStr.append(*valueItr);
-            }
-            else
-            {
-                tmpStr.append(*valueItr);
-            }
-#else
-            tmpStr.append(*valueItr);
-#endif
-            tmpVal.push_back(tmpStr);
-        }
-        retAttMap[it->first] = tmpVal;
-
-    }
     return retAttMap;
 }
 
@@ -117,13 +117,13 @@ int VirtualRepresentation::getRepresentation(OCRepresentation& oc)
     return true;
 }
 
-void VirtualRepresentation::entityHandler(std::shared_ptr< OCResourceRequest > request ,
-        std::shared_ptr< OCResourceResponse > response)
+OCEntityHandlerResult VirtualRepresentation::entityHandler(const std::shared_ptr<OCResourceRequest> request ,
+               const std::shared_ptr<OCResourceResponse> response)
 {
     if(request)
     {
         std::string requestType = request->getRequestType();
-        RequestHandlerFlag requestFlag = request->getRequestHandlerFlag();
+        int requestFlag = request->getRequestHandlerFlag();
 
         if(requestFlag == RequestHandlerFlag::InitFlag)
         {
@@ -181,10 +181,11 @@ void VirtualRepresentation::entityHandler(std::shared_ptr< OCResourceRequest > r
     else
     {
     }
+
+    return OC_EH_OK;
 }
 
-void VirtualRepresentation::onObserve(const OCRepresentation& rep , const int& eCode ,
-        const int& sequenceNumber)
+void VirtualRepresentation::onObserve(const HeaderOptions &headerOption, const OCRepresentation &rep , const int eCode , const int sequenceNumber)
 {
     if(eCode == SUCCESS_RESPONSE)
     {
@@ -224,7 +225,7 @@ void VirtualRepresentation::onObserve(const OCRepresentation& rep , const int& e
                 s_conditionAttributeMap.notify_all();
             }
 
-            result = OCPlatform::notifyObservers(tmpObj.getResourceHandle());
+            result = notifyAllObservers(tmpObj.getResourceHandle());
         }
         else
         {
@@ -20,6 +20,7 @@
 
 // OCClient.cpp : Defines the entry point for the console application.
 //
+
 #include <string>
 #include <cstdlib>
 #include <pthread.h>
@@ -31,11 +32,10 @@ using namespace OC;
 const int SUCCESS_RESPONSE = 0;
 static ObserveType OBSERVE_TYPE_TO_USE = ObserveType::Observe;
 
-OCPlatform *g_nmOCPlatform = NULL;
 std::shared_ptr< OCResource > g_curResource;
 
 OCStackResult nmfindResource(const std::string& host , const std::string& resourceName);
-void onObserve(const OCRepresentation& rep , const int& eCode , const int& sequenceNumber);
+void onObserve(const HeaderOptions &headerOption , const OCRepresentation& rep , const int& eCode, const int& sequenceNumber);
 
 void findResourceCandidate()
 {
@@ -45,7 +45,17 @@ void findResourceCandidate()
         std::cout << "Finding Resource... " << std::endl;
         while(true)
         {
-            // some operations
+               char signal;
+                       cin >> signal;
+
+                       switch(signal)
+                       {
+                       case 'q':
+                       case 'Q':
+                               exit(-1);
+                       default:
+                               break;
+                       }
         }
 
     }
@@ -68,8 +78,9 @@ int observe_count()
     return ++oc;
 }
 
-void onObserve(const OCRepresentation& rep , const int& eCode , const int& sequenceNumber)
+void onObserve(const HeaderOptions &headerOption , const OCRepresentation& rep , const int& eCode, const int& sequenceNumber)
 {
+       std::cout << "onObserve" << std::endl;
     if(eCode == SUCCESS_RESPONSE)
     {
 
@@ -157,7 +168,7 @@ void foundResource(std::shared_ptr< OCResource > resource)
 
 OCStackResult nmfindResource(const std::string& host , const std::string& resourceName)
 {
-    return g_nmOCPlatform->findResource(host , resourceName , &foundResource);
+    return OCPlatform::findResource(host , resourceName , &foundResource);
 }
 
 void getRepresentation(std::shared_ptr< OCResource > resource)
@@ -212,7 +223,7 @@ void onPut(const OCRepresentation& rep , const int eCode)
 
         QueryParamsMap test;
 
-        g_curResource->observe(OBSERVE_TYPE_TO_USE , test , &onObserve);
+        g_curResource->observe(ObserveType::Observe , test , &onObserve);
 
     }
     else
@@ -223,7 +234,7 @@ void onPut(const OCRepresentation& rep , const int eCode)
 }
 
 // callback handler on GET request
-void onGet(const OCRepresentation& rep , const int eCode)
+void onGet(const HeaderOptions &headerOption , const OCRepresentation& rep , const int eCode)
 {
     if(eCode == SUCCESS_RESPONSE)
     {
@@ -313,10 +324,10 @@ int main(int argc , char* argv[])
         return -1;
     }
 
-    PlatformConfig cfg(ServiceType::InProc, ModeType::Client,
-            "192.168.1.10", 56832, QualityOfService::NonConfirmable);
+    PlatformConfig cfg;
+
+    OCPlatform::Configure(cfg);
 
-    g_nmOCPlatform = new OCPlatform(cfg);
     std::cout << "Created Platform..." << std::endl;
     findResourceCandidate();
 
@@ -32,14 +32,12 @@ using namespace std;
 
 int g_Observation = 0;
 
-void entityHandler(std::shared_ptr< OCResourceRequest > request ,
+OCEntityHandlerResult entityHandler(std::shared_ptr< OCResourceRequest > request ,
         std::shared_ptr< OCResourceResponse > response);
 
-class LightResource
+class TempHumidResource
 {
 public:
-    bool m_state;
-    int m_power;
 
     int m_temp;
     int m_humid;
@@ -47,13 +45,15 @@ public:
     std::string m_uri;
     OCResourceHandle m_resourceHandle;
 
+    OCRepresentation m_Rep;
+
 public:
-    LightResource() :
-            m_state(false), m_power(0), m_temp(0), m_humid(0), m_uri("/a/TempHumSensor")
+    TempHumidResource() :
+            m_temp(0), m_humid(0), m_uri("/a/TempHumSensor")
     {
     }
 
-    void createResource(OC::OCPlatform& platform)
+    void createResource()
     {
         std::string resourceURI = "/a/NM/TempHumSensor";
         std::string resourceTypeName = "NotificationManager.Hosting";
@@ -63,7 +63,7 @@ public:
 
         uint8_t resourceProperty = OC_DISCOVERABLE | OC_OBSERVABLE;
 
-        OCStackResult result = platform.registerResource(m_resourceHandle , resourceURI ,
+        OCStackResult result = OCPlatform::registerResource(m_resourceHandle , resourceURI ,
                 resourceTypeName , resourceInterface , &entityHandler , resourceProperty);
 
         if(OC_STACK_OK != result)
@@ -72,67 +72,101 @@ public:
         }
     }
 
-    OCResourceHandle getHandle()
-    {
-        return m_resourceHandle;
-    }
-
-    void setRepresentation(AttributeMap& attributeMap)
-    {
-        cout << "\t\t\t" << "Received representation: " << endl;
-        cout << "\t\t\t\t" << "temp: " << attributeMap["temperature"][0] << endl;
-        cout << "\t\t\t\t" << "humid: " << attributeMap["humidity"][0] << endl;
-        m_temp = std::stoi(attributeMap["temperature"][0]);
-        m_humid = std::stoi(attributeMap["humidity"][0]);
-    }
-
-    OCRepresentation getRepresentation()
-    {
-        OCRepresentation temp;
+    OCStackResult createResource1()
+       {
+               std::string resourceURI = "/a/NM/TempHumSensor1"; // URI of the resource
+               std::string resourceTypeName = "NotificationManager.Hosting"; // resource type name. In this case, it is light
+               std::string resourceInterface = DEFAULT_INTERFACE; // resource interface.
 
-        temp.setUri(m_uri);
+               // OCResourceProperty is defined ocstack.h
+               uint8_t resourceProperty = OC_DISCOVERABLE | OC_OBSERVABLE;
 
-        std::vector< std::string > interfaces;
+               OCResourceHandle resHandle;
 
-        temp.setResourceInterfaces(interfaces);
+               // This will internally create and register the resource.
+               OCStackResult result = OCPlatform::registerResource(
+                                                                       resHandle, resourceURI, resourceTypeName,
+                                                                       resourceInterface, &entityHandler, resourceProperty);
 
-        std::vector< std::string > types;
+               if (OC_STACK_OK != result)
+               {
+                       cout << "Resource creation was unsuccessful\n";
+               }
 
-        temp.setResourceTypes(types);
+               return result;
+       }
 
-        AttributeMap attributeMap;
+    OCResourceHandle getHandle()
+    {
+        return m_resourceHandle;
+    }
 
-        AttributeValues tempVal;
-        AttributeValues humidVal;
+    OCRepresentation post(OCRepresentation& rep)
+    {
+        static int first = 1;
 
-        tempVal.push_back(to_string(m_temp));
-        humidVal.push_back(to_string(m_humid));
+        // for the first time it tries to create a resource
+        if(first)
+        {
+            first = 0;
 
-        attributeMap["temperature"] = tempVal;
-        attributeMap["humidity"] = humidVal;
+            if(OC_STACK_OK == createResource1())
+            {
+                OCRepresentation rep1;
+                rep1.setValue("createduri", std::string("/a/light1"));
 
-        temp.setAttributeMap(attributeMap);
+                return rep1;
+            }
+        }
 
-        return temp;
+        // from second time onwards it just puts
+        put(rep);
+        return get();
     }
 
-    void getRepresentation(AttributeMap& attributeMap)
-    {
-        AttributeValues tempVal;
-        AttributeValues humidVal;
-
-        tempVal.push_back(to_string(m_temp));
-        humidVal.push_back(to_string(m_humid));
+    void put(OCRepresentation& rep)
+       {
+               try {
+                       if (rep.getValue("temperature", m_temp))
+                       {
+                               cout << "\t\t\t\t" << "temperature: " << m_temp << endl;
+                       }
+                       else
+                       {
+                               cout << "\t\t\t\t" << "temperature not found in the representation" << endl;
+                       }
+
+                       if (rep.getValue("humidity", m_humid))
+                       {
+                               cout << "\t\t\t\t" << "humidity: " << m_humid << endl;
+                       }
+                       else
+                       {
+                               cout << "\t\t\t\t" << "m_power not found in the representation" << endl;
+                       }
+               }
+               catch (exception& e)
+               {
+                       cout << e.what() << endl;
+               }
+
+       }
+
+    OCRepresentation get()
+       {
+               m_Rep.setValue("temperature", m_temp);
+               m_Rep.setValue("humidity", m_humid);
+
+               return m_Rep;
+       }
 
-        attributeMap["temperature"] = tempVal;
-        attributeMap["humidity"] = humidVal;
-    }
 };
 
-LightResource myResource;
+TempHumidResource myResource;
 
 void *ChangeLightRepresentation(void *param)
 {
+
     if(g_Observation)
     {
 
@@ -147,7 +181,7 @@ void *ChangeLightRepresentation(void *param)
         cout << "Attribute Name: Temp\tvalue: " << myResource.m_temp << endl;
         cout << "Attribute Name: Humid\tvalue: " << myResource.m_humid << endl;
 
-        OCStackResult result = OCPlatform::notifyObservers(myResource.getHandle());
+        OCStackResult result = OCPlatform::notifyAllObservers(myResource.getHandle());
 
         if(OC_STACK_NO_OBSERVERS == result)
         {
@@ -159,64 +193,39 @@ void *ChangeLightRepresentation(void *param)
     return NULL;
 }
 
-void entityHandler(std::shared_ptr< OCResourceRequest > request ,
+OCEntityHandlerResult entityHandler(std::shared_ptr< OCResourceRequest > request ,
         std::shared_ptr< OCResourceResponse > response)
 {
 
     if(request)
     {
         std::string requestType = request->getRequestType();
-        RequestHandlerFlag requestFlag = request->getRequestHandlerFlag();
+        int requestFlag = request->getRequestHandlerFlag();
 
         if(requestFlag == RequestHandlerFlag::InitFlag)
         {
         }
-        else if(requestFlag == RequestHandlerFlag::RequestFlag)
+        if(requestFlag == RequestHandlerFlag::RequestFlag)
         {
             if(requestType == "GET")
             {
-                QueryParamsMap queryParamsMap = request->getQueryParameters();
-
-                for(QueryParamsMap::iterator it = queryParamsMap.begin() ;
-                        it != queryParamsMap.end() ; it++)
-                {
-                }
-
-                OCRepresentation rep;
-                rep = myResource.getRepresentation();
-
                 if(response)
                 {
                     response->setErrorCode(200);
-
-                    auto findRes = queryParamsMap.find("if");
-
-                    if(findRes != queryParamsMap.end())
-                    {
-                        response->setResourceRepresentation(rep , findRes->second);
-                    }
-                    else
-                    {
-                        response->setResourceRepresentation(rep , DEFAULT_INTERFACE);
-                    }
+                    response->setResourceRepresentation(myResource.get());
                 }
             }
             else if(requestType == "PUT")
             {
                 cout << "\t\t\trequestType : PUT\n";
 
-                QueryParamsMap queryParamsMap = request->getQueryParameters();
-
-                AttributeMap attributeMap = request->getAttributeRepresentation();
-
-                myResource.setRepresentation(attributeMap);
-
-                myResource.getRepresentation(attributeMap);
+                OCRepresentation rep = request->getResourceRepresentation();
+                myResource.put(rep);
 
                 if(response)
                 {
                     response->setErrorCode(200);
-                    response->setResourceRepresentation(attributeMap);
+                    response->setResourceRepresentation(myResource.get());
                 }
             }
             else if(requestType == "POST")
@@ -226,7 +235,7 @@ void entityHandler(std::shared_ptr< OCResourceRequest > request ,
             {
             }
         }
-        else if(requestFlag == RequestHandlerFlag::ObserverFlag)
+        else if(requestFlag & RequestHandlerFlag::ObserverFlag)
         {
             pthread_t threadId;
 
@@ -247,21 +256,29 @@ void entityHandler(std::shared_ptr< OCResourceRequest > request ,
     {
         std::cout << "Request invalid" << std::endl;
     }
+
+    return OC_EH_OK;
 }
 
 int main()
 {
 
-    PlatformConfig cfg(ServiceType::InProc, ModeType::Server,
-            "134.134.161.33", 56832, QualityOfService::NonConfirmable);
+       PlatformConfig cfg {
+               OC::ServiceType::InProc,
+               OC::ModeType::Server,
+               "0.0.0.0",
+               0,
+               OC::QualityOfService::LowQos
+           };
+
+       OCPlatform::Configure(cfg);
 
     int number = 0;
 
     try
     {
-        OCPlatform platform(cfg);
 
-        myResource.createResource(platform);
+        myResource.createResource();
 
         while(true)
         {
@@ -1,4 +1,4 @@
-OCPATH = ../../../../../resource/build/linux
+OCPATH = ../../../../../resource
 NOTIFICATIONMGRPATH = ../../../NotificationManager/build/linux
 
 .PHONY : resource NotificationManager
@@ -1,6 +1,6 @@
 LINK_DIRECTORIES(${LIB_INSTALL_DIR})
 
-SET(NOTI_BASE_DIR "${BASE_SRC_DIR}/Notification-Manager")
+SET(NOTI_BASE_DIR "${BASE_SRC_DIR}/notification-manager")
 
 INCLUDE_DIRECTORIES(${INCLUDE_INSTALL_DIR}/oic)
 INCLUDE_DIRECTORIES(${INCLUDE_INSTALL_DIR}/oic/stack)