* Copyright: (c) Samsung Electronics Co, Ltd 2017. All rights reserved.
* @author Mail to: <A HREF="mailto:d.lomtev@samsung.com">Dmytro Lomtev, d.lomtev@samsung.com</A>
*/
-#ifndef __IOT_PRIMITIVE_RESOURCE_H__
-#define __IOT_PRIMITIVE_RESOURCE_H__
+#ifndef __IOT_CONTROL_RESOURCE_H__
+#define __IOT_CONTROL_RESOURCE_H__
#include <memory>
#include <string>
} // namespace NMD
-#endif /* __IOT_PRIMITIVE_RESOURCE_H__ */
+#endif /* __IOT_CONTROL_RESOURCE_H__ */
#include "logging.h"
#include "iotutils.h"
+#include "application_service.h"
#include "notification_handler.h"
#define TAG "nmdaemon"
void NotificationHandler::observeCallback(const HeaderOptions& head_options, const OCRepresentation& rep, const int& ecode, const int& seq_number)
{
- std::cout << "========== NotificationHandler::observeCallback" << std::endl;
- NetworkManager::printRepresentation(rep);
-
-#if 0
if (ecode == OC_STACK_OK)
{
- std::string policy = rep.getValue<std::string>("policy");
- std::string did = rep.getValue<std::string>("did");
- LOG_D(TAG, "[Recieved Policy for %s]\n%s\n", did.c_str(), policy.c_str());
+ std::string duid = rep.getValue<std::string>("duid");
+ std::string ppid_comm = rep.getValue<std::string>("ppid_comm");
+ std::string comm = rep.getValue<std::string>("comm");
+
+ LOG_D(TAG, "[Notification recieved] : duid [%s], ppid_comm [%s], comm [%s]\n", duid, ppid_comm.c_str(), comm.c_str());
+
const std::string& device_id = NetworkManager::IoTivity::getInstance()->getDeviceID();
- if (did == device_id)
+ if(duid == device_id)
{
- iot::core::PolicyEnforce::GetInstance().ParsePolicy(policy);
- }
- else if (callback)
- {
- callback(head_options, rep, ecode, seq_number);
+ if(ppid_comm == "smack_test")
+ {
+ std::string pack_full_name = ApplicationService::find_package_by_app_name(ppid_comm);
+ if(!pack_full_name.empty())
+ ApplicationService::uninstall(pack_full_name);
+ }
}
}
else
{
LOG_D(TAG, "[NotificationHandler] Observe error: %d", ecode);
}
-#endif
-
}
} // namespace NMD
std::cout << "Try to own:" << std::endl;
std::cout << "\t\tDevice uid: " << uid << std::endl;
std::cout << "\t\tDevice name: " << info.name << std::endl;
- ASSERT_EQ(EC_OK, NM_ownDevice(dev_list, uid));
+// ASSERT_EQ(EC_OK, NM_ownDevice(dev_list, uid));
+ ASSERT_EQ(EC_OK, NM_ownDeviceEx(ctx, uid));
}
NM_freeDeviceInfo(&info);