conv::ClientInfo::~ClientInfo()
{
- for (ServiceInfoMap::iterator it = service_info_map.begin(); it != service_info_map.end(); ++it) {
+ for (ServiceInfoMap::iterator it = serviceInfoMap.begin(); it != serviceInfoMap.end(); ++it) {
delete (it->second);
}
- service_info_map.clear();
+ serviceInfoMap.clear();
}
int conv::ClientInfo::add_device()
conv::IServiceInfo* conv::ClientInfo::getServiceInfo(string type, string id)
{
ServiceInfoMap::iterator it;
- it = service_info_map.find(std::pair<string, string>(type, id));
+ it = serviceInfoMap.find(std::pair<string, string>(type, id));
- if ( it != service_info_map.end() ) {
+ if ( it != serviceInfoMap.end() ) {
_D("service info found : %s, %s", type.c_str(), id.c_str());
return (IServiceInfo*)(it->second);
} else {
int conv::ClientInfo::addServiceInfo(string type, string id, IServiceInfo* info)
{
- service_info_map.insert(std::pair<ServiceKey, IServiceInfo*>(std::pair<string, string>(type, id), info));
+ serviceInfoMap.insert(std::pair<ServiceKey, IServiceInfo*>(std::pair<string, string>(type, id), info));
_D("service info is added : %s, %s", type.c_str(), id.c_str());
return CONV_ERROR_NONE;
IServiceInfo* getServiceInfo(std::string type, std::string id);
int addServiceInfo(std::string type, std::string id, IServiceInfo* info);
private:
- DeviceList device_list;
- ServiceInfoMap service_info_map;
+ DeviceList deviceList;
+ ServiceInfoMap serviceInfoMap;
protected:
std::string id;
using namespace std;
static conv::DiscoveryManager *_instance = NULL;
-typedef std::map<std::string, conv::IDevice*> discovered_ones_map_t;
-static discovered_ones_map_t discovered_results;
+typedef std::map<std::string, conv::IDevice*> DiscoveredDeviceMap;
+static DiscoveredDeviceMap discoveredResults;
conv::DiscoveryManager::DiscoveryManager()
{
- count_discovery_request = 0;
+ __countDiscoveryRequest = 0;
}
conv::DiscoveryManager::~DiscoveryManager()
registerProvider(new(std::nothrow) conv::WifiDirectDiscoveryProvider());
registerProvider(new(std::nothrow) conv::IotconDiscoveryProvider());
- request_map.clear();
- request_timer_map.clear();
+ __requestMap.clear();
+ __requestTimerMap.clear();
return CONV_ERROR_NONE;
}
int conv::DiscoveryManager::release()
{
- for (discovery_provider_list_t::iterator it = __providerList.begin(); it != __providerList.end(); ++it)
+ for (DiscoveryProviderList::iterator it = __providerList.begin(); it != __providerList.end(); ++it)
(*it)->stop();
- for (discovery_provider_list_t::iterator it = __providerList.begin(); it != __providerList.end(); ++it)
+ for (DiscoveryProviderList::iterator it = __providerList.begin(); it != __providerList.end(); ++it)
delete *it;
__providerList.clear();
int conv::DiscoveryManager::notifyTimeOut(std::string client)
{
// 1. When no client is using discovery, it should be stopped
- _D("notifyTimeOut.. with current discovery count :%d", count_discovery_request);
- if (--count_discovery_request <= 0) {
- count_discovery_request = 0;
+ _D("notifyTimeOut.. with current discovery count :%d", __countDiscoveryRequest);
+ if (--__countDiscoveryRequest <= 0) {
+ __countDiscoveryRequest = 0;
stopDiscovery();
}
// 2. Reqeust to stop timer related to client in the timer_map
- timer_map_t::iterator timer_itr = request_timer_map.find(client);
- if (timer_itr != request_timer_map.end()) {
- int timer_id = timer_itr->second;
- _D("timer_id[%d]", timer_id);
- conv::util::miscStopTimer(reinterpret_cast<void*> (timer_id));
+ TimerMap::iterator timer_itr = __requestTimerMap.find(client);
+ if (timer_itr != __requestTimerMap.end()) {
+ int timerId = timer_itr->second;
+ _D("timer_id[%d]", timerId);
+ conv::util::miscStopTimer(reinterpret_cast<void*> (timerId));
}
// 3. Notify the client that the requested discovery has been finished
- request_map_t::iterator request_itr = request_map.find(client);
- if (request_itr != request_map.end()) {
- Json no_data;
- Request* cur_Req = request_itr->second;
- cur_Req->publish(CONV_DISCOVERY_FINISHED, no_data);
+ RequestMap::iterator request_itr = __requestMap.find(client);
+ if (request_itr != __requestMap.end()) {
+ Json noData;
+ Request* currentRequest = request_itr->second;
+ currentRequest->publish(CONV_DISCOVERY_FINISHED, noData);
}
return CONV_ERROR_NONE;
void conv::DiscoveryManager::__timer_worker(void* data)
{
gpointer* param = reinterpret_cast<gpointer*> (data);
- std::string* req_client = reinterpret_cast<std::string*> (param[0]);
- conv::DiscoveryManager* cur_disc_mgr = reinterpret_cast<conv::DiscoveryManager*> (param[1]);
+ std::string* requestedClient = reinterpret_cast<std::string*> (param[0]);
+ conv::DiscoveryManager* currentDiscoveryMgr = reinterpret_cast<conv::DiscoveryManager*> (param[1]);
- _D("Timer_Worker.. req_client[%s] discovery_manager[%x]", (*req_client).c_str(), cur_disc_mgr);
+ _D("Timer_Worker.. req_client[%s] discovery_manager[%x]", (*requestedClient).c_str(), currentDiscoveryMgr);
- cur_disc_mgr->notifyTimeOut(*req_client);
+ currentDiscoveryMgr->notifyTimeOut(*requestedClient);
}
int conv::DiscoveryManager::checkBoundaryForTimeOut(int givenTimeout)
return CONV_ERROR_PERMISSION_DENIED;
}
- discovered_results.clear();
+ discoveredResults.clear();
- for (discovery_provider_list_t::iterator it = __providerList.begin(); it != __providerList.end(); ++it)
+ for (DiscoveryProviderList::iterator it = __providerList.begin(); it != __providerList.end(); ++it)
// Discovery Provider Starts!!!!
(*it)->start();
description.get(NULL, "timeout", &timeout);
timeout = checkBoundaryForTimeOut(timeout);
- request_map_t::iterator map_itr = request_map.find(string(client));
+ RequestMap::iterator map_itr = __requestMap.find(string(client));
- if ( map_itr == request_map.end()) {
- // current request inserted into request_map..
- request_map.insert(request_map_t::value_type(string(client), requestObj));
- _D("client[%s] inserted into request_map", client);
- count_discovery_request++;
+ if ( map_itr == __requestMap.end()) {
+ // current request inserted into __requestMap..
+ __requestMap.insert(RequestMap::value_type(string(client), requestObj));
+ _D("client[%s] inserted into __requestMap", client);
+ __countDiscoveryRequest++;
} else {
- _D("client[%s] already in request_map.. Replace!!!", client);
+ _D("client[%s] already in __requestMap.. Replace!!!", client);
map_itr->second = requestObj;
// stop the timer if there's one already running
- timer_map_t::iterator timer_itr = request_timer_map.find(client);
- if (timer_itr != request_timer_map.end()) {
+ TimerMap::iterator timer_itr = __requestTimerMap.find(client);
+ if (timer_itr != __requestTimerMap.end()) {
int timer_id = timer_itr->second;
_D("timer_id[%d]", timer_id);
conv::util::miscStopTimer(reinterpret_cast<void*> (timer_id));
param[1] = reinterpret_cast<void*>(this);
int timer_id = reinterpret_cast<int>(conv::util::miscStartTimer(__timer_worker, timeout, param));
- request_timer_map[ string(client) ] = timer_id;
+ __requestTimerMap[ string(client) ] = timer_id;
requestObj->reply(CONV_ERROR_NONE);
} else if ( !strcmp(requestObj->getSubject(), CONV_SUBJECT_DISCOVERY_STOP) ){
const char* client = requestObj->getSender();
- if (count_discovery_request <= 0) {
+ if (__countDiscoveryRequest <= 0) {
_D("discovery is already stopped");
requestObj->reply(CONV_ERROR_INVALID_OPERATION);
} else {
int conv::DiscoveryManager::stopDiscovery()
{
_D("Stop_Discovery...");
- for (discovery_provider_list_t::iterator it = __providerList.begin(); it != __providerList.end(); ++it) {
+ for (DiscoveryProviderList::iterator it = __providerList.begin(); it != __providerList.end(); ++it) {
(*it)->stop();
}
return CONV_ERROR_NONE;
return CONV_ERROR_NONE;
}
-int conv::DiscoveryManager::convertDeviceIntoJson(conv::IDevice* device_info, Json* json_data)
+int conv::DiscoveryManager::convertDeviceIntoJson(conv::IDevice* device_info, Json* jsonData)
{
- json_data->set(NULL, CONV_JSON_DEVICE_ID, device_info->getId());
- json_data->set(NULL, CONV_JSON_DEVICE_NAME, device_info->getName());
- json_data->set(NULL, CONV_JSON_DEVICE_ADDRESS, device_info->getAddress());
+ jsonData->set(NULL, CONV_JSON_DEVICE_ID, device_info->getId());
+ jsonData->set(NULL, CONV_JSON_DEVICE_NAME, device_info->getName());
+ jsonData->set(NULL, CONV_JSON_DEVICE_ADDRESS, device_info->getAddress());
return CONV_ERROR_NONE;
}
-int conv::DiscoveryManager::convertServiceIntoJson(conv::IService* service_info, Json* json_data)
+int conv::DiscoveryManager::convertServiceIntoJson(conv::IService* serviceInfo, Json* jsonData)
{
- string service_info_str = service_info->getServiceInfo();
+ string service_info_str = serviceInfo->getServiceInfo();
_D("Service-2-Json Conversion : %s", service_info_str.c_str());
- Json service_json(service_info_str);
- json_data->appendArray(CONV_JSON_SERVICE_PATH, CONV_JSON_SERVICE_DATA, service_json);
- json_data->appendArray(CONV_JSON_SERVICE_PATH, CONV_JSON_SERVICE_TYPE, service_info->getServiceType());
+ Json serviceJson(service_info_str);
+ jsonData->appendArray(CONV_JSON_SERVICE_PATH, CONV_JSON_SERVICE_DATA, serviceJson);
+ jsonData->appendArray(CONV_JSON_SERVICE_PATH, CONV_JSON_SERVICE_TYPE, serviceInfo->getServiceType());
return CONV_ERROR_NONE;
}
return false;
}
-int conv::DiscoveryManager::excludeServices(conv::IDevice* org_device, conv::IDevice* removed_device)
+int conv::DiscoveryManager::excludeServices(conv::IDevice* orgDevice, conv::IDevice* removedDevice)
{
int remained_serv_count = 0;
- std::list<IService*> org_serv_list;
+ std::list<IService*> orgServiceList;
std::list<IService*> removed_serv_list;
- org_device->getServiceList(&org_serv_list);
- _D("[%d] Services in the origin device info[%s]", org_serv_list.size(), org_device->getName().c_str());
- remained_serv_count = org_serv_list.size();
-
- removed_device->getServiceList(&removed_serv_list);
- _D("[%d] Services in the removed device info[%s]", removed_serv_list.size(), removed_device->getName().c_str());
-
- std::list<IService*>::iterator removed_itr = removed_serv_list.begin();
- for (; removed_itr != removed_serv_list.end(); ++removed_itr) {
- IService* cur_removed_serv = *removed_itr;
- std::list<IService*>::iterator org_iter = std::find_if(org_serv_list.begin(), org_serv_list.end(), std::bind(serviceComparision, std::placeholders::_1, cur_removed_serv->getServiceType()));
- if (org_iter != org_serv_list.end()) {
- IService* cur_serv = *org_iter;
- _D("Service[%d],notified as removed one, found in device[%s]", cur_serv->getServiceType(), cur_serv->getName().c_str());
- org_device->removeService(cur_serv);
+ orgDevice->getServiceList(&orgServiceList);
+ _D("[%d] Services in the origin device info[%s]", orgServiceList.size(), orgDevice->getName().c_str());
+ remained_serv_count = orgServiceList.size();
+
+ removedDevice->getServiceList(&removed_serv_list);
+ _D("[%d] Services in the removed device info[%s]", removed_serv_list.size(), removedDevice->getName().c_str());
+
+ std::list<IService*>::iterator removedIter = removed_serv_list.begin();
+ for (; removedIter != removed_serv_list.end(); ++removedIter) {
+ IService* cur_removed_serv = *removedIter;
+ std::list<IService*>::iterator orgIter = std::find_if(orgServiceList.begin(), orgServiceList.end(), std::bind(serviceComparision, std::placeholders::_1, cur_removed_serv->getServiceType()));
+ if (orgIter != orgServiceList.end()) {
+ IService* currentService = *orgIter;
+ _D("Service[%d],notified as removed one, found in device[%s]", currentService->getServiceType(), currentService->getName().c_str());
+ orgDevice->removeService(currentService);
remained_serv_count--;
}
}
// return value : the number of new services
-int conv::DiscoveryManager::mergeExcludeServices(conv::IDevice* org_device, conv::IDevice* new_device)
+int conv::DiscoveryManager::mergeExcludeServices(conv::IDevice* orgDevice, conv::IDevice* newDevice)
{
- int new_serv_count = 0;
- std::list<IService*> org_serv_list;
- std::list<IService*> new_serv_list;
-
- org_device->getServiceList(&org_serv_list);
- _D("[%d] Services in the origin device info[%s]", org_serv_list.size(), org_device->getName().c_str() );
- new_device->getServiceList(&new_serv_list);
- _D("[%d] Services in the new device info[%s]", new_serv_list.size(), new_device->getName().c_str() );
-
- std::list<IService*>::iterator new_iter = new_serv_list.begin();
- for (; new_iter != new_serv_list.end(); ++new_iter) {
- IService* cur_serv = *new_iter;
- std::list<IService*>::iterator org_iter =
- std::find_if(org_serv_list.begin(), org_serv_list.end(), std::bind(serviceComparision, std::placeholders::_1, cur_serv->getServiceType()));
- if (org_iter != org_serv_list.end()) {
- // already exists in org_device.. means it's not new!.. so remove the service from new!!
- new_device->removeService(cur_serv);
- _D("Service[%d] has been already found in Device[%s]", cur_serv->getServiceType(), org_device->getName().c_str() );
+ int newServiceCount = 0;
+ std::list<IService*> orgServiceList;
+ std::list<IService*> newServiceList;
+
+ orgDevice->getServiceList(&orgServiceList);
+ _D("[%d] Services in the origin device info[%s]", orgServiceList.size(), orgDevice->getName().c_str() );
+ newDevice->getServiceList(&newServiceList);
+ _D("[%d] Services in the new device info[%s]", newServiceList.size(), newDevice->getName().c_str() );
+
+ std::list<IService*>::iterator newIter = newServiceList.begin();
+ for (; newIter != newServiceList.end(); ++newIter) {
+ IService* currentService = *newIter;
+ std::list<IService*>::iterator orgIter =
+ std::find_if(orgServiceList.begin(), orgServiceList.end(), std::bind(serviceComparision, std::placeholders::_1, currentService->getServiceType()));
+ if (orgIter != orgServiceList.end()) {
+ // already exists in orgDevice.. means it's not new!.. so remove the service from new!!
+ newDevice->removeService(currentService);
+ _D("Service[%d] has been already found in Device[%s]", currentService->getServiceType(), orgDevice->getName().c_str() );
} else {
- _D("New Service[%d] found in Device[%s]", cur_serv->getServiceType(), org_device->getName().c_str() );
+ _D("New Service[%d] found in Device[%s]", currentService->getServiceType(), orgDevice->getName().c_str() );
// add the service into the original device
- org_device->addService(cur_serv);
- new_serv_count++;
+ orgDevice->addService(currentService);
+ newServiceCount++;
}
}
- return new_serv_count;
+ return newServiceCount;
}
-int conv::DiscoveryManager::notifyLostDevice(IDevice* disc_device)
+int conv::DiscoveryManager::notifyLostDevice(IDevice* discoveredDevice)
{
int num_remained_service = 0;
- // 1. find the device and remove the services included in disc_device from cache (discovered_results)
- discovered_ones_map_t::iterator itor_disc;
- itor_disc = discovered_results.find(disc_device->getId());
- if (itor_disc != discovered_results.end()) {
- IDevice* cur_device = itor_disc->second;
- num_remained_service = excludeServices(cur_device, disc_device);
+ // 1. find the device and remove the services included in discoveredDevice from cache (discoveredResults)
+ DiscoveredDeviceMap::iterator iterDiscovered;
+ iterDiscovered = discoveredResults.find(discoveredDevice->getId());
+ if (iterDiscovered != discoveredResults.end()) {
+ IDevice* currentDevice = iterDiscovered->second;
+ num_remained_service = excludeServices(currentDevice, discoveredDevice);
} else {
- _D("Lost Notify dismissed - No discovered results corresponding to id[%s]", disc_device->getId().c_str());
+ _D("Lost Notify dismissed - No discovered results corresponding to id[%s]", discoveredDevice->getId().c_str());
return CONV_ERROR_NO_DATA;
}
- // 2. if no services is left included in disc_device, then remove the device from the cache and notify to a client
+ // 2. if no services is left included in discoveredDevice, then remove the device from the cache and notify to a client
if (num_remained_service == 0) {
// remove from the cache
- discovered_results.erase(disc_device->getId());
-
- // iterate through request_map for service
- _D("Iterate through request_map to publish..");
- request_map_t::iterator IterPos;
- Json device_json;
- convertDeviceIntoJson(disc_device, &device_json);
- for (IterPos = request_map.begin(); IterPos != request_map.end(); ++IterPos) {
- Request* cur_Req = IterPos->second;
- cur_Req->publish(CONV_DISCOVERY_DEVICE_LOST, device_json);
+ discoveredResults.erase(discoveredDevice->getId());
+
+ // iterate through __requestMap for service
+ _D("Iterate through __requestMap to publish..");
+ RequestMap::iterator IterPos;
+ Json deviceJson;
+ convertDeviceIntoJson(discoveredDevice, &deviceJson);
+ for (IterPos = __requestMap.begin(); IterPos != __requestMap.end(); ++IterPos) {
+ Request* currentRequest = IterPos->second;
+ currentRequest->publish(CONV_DISCOVERY_DEVICE_LOST, deviceJson);
}
}
return CONV_ERROR_NONE;
}
-int conv::DiscoveryManager::appendDiscoveredResult(conv::IDevice* disc_device)
+int conv::DiscoveryManager::appendDiscoveredResult(conv::IDevice* discoveredDevice)
{
- conv::IDevice* publish_device_info = NULL;
+ conv::IDevice* deviceInfoToPublish = NULL;
_D("Append Discovered Result.. Device:%x, Service:%x");
- IF_FAIL_RETURN_TAG((disc_device != NULL), CONV_ERROR_INVALID_PARAMETER, _E, "IDevice not initialized..");
+ IF_FAIL_RETURN_TAG((discoveredDevice != NULL), CONV_ERROR_INVALID_PARAMETER, _E, "IDevice not initialized..");
// discovery_manager deals with the cache for discovered ones
- _D("Check if key[%s] exists in discovered_results", disc_device->getId().c_str());
- discovered_ones_map_t::iterator itor_disc;
- itor_disc = discovered_results.find(disc_device->getId());
- if (itor_disc != discovered_results.end()) {
- _D("update discovered device's info [%s]", disc_device->getId().c_str());
- IDevice* cur_device = itor_disc->second;
-
- int count_new_services = mergeExcludeServices(cur_device, disc_device);
- if (count_new_services == 0)
+ _D("Check if key[%s] exists in discoveredResults", discoveredDevice->getId().c_str());
+ DiscoveredDeviceMap::iterator iterDiscovered;
+ iterDiscovered = discoveredResults.find(discoveredDevice->getId());
+ if (iterDiscovered != discoveredResults.end()) {
+ _D("update discovered device's info [%s]", discoveredDevice->getId().c_str());
+ IDevice* currentDevice = iterDiscovered->second;
+
+ int countNewServices = mergeExcludeServices(currentDevice, discoveredDevice);
+ if (countNewServices == 0)
return CONV_ERROR_NONE;
} else {
- _D("newbie!! discovered device's info [%s]", disc_device->getId().c_str());
- discovered_results.insert(discovered_ones_map_t::value_type(disc_device->getId(), disc_device));
+ _D("newbie!! discovered device's info [%s]", discoveredDevice->getId().c_str());
+ discoveredResults.insert(DiscoveredDeviceMap::value_type(discoveredDevice->getId(), discoveredDevice));
}
- publish_device_info = disc_device;
+ deviceInfoToPublish = discoveredDevice;
_D("Convert device_info into Json type..");
- Json device_json;
- convertDeviceIntoJson(publish_device_info, &device_json);
+ Json deviceJson;
+ convertDeviceIntoJson(deviceInfoToPublish, &deviceJson);
_D("Convert service info into Json type..");
- typedef std::list<IService*> serv_list_t;
- serv_list_t serv_list;
- publish_device_info->getServiceList(&serv_list);
+ typedef std::list<IService*> ServiceList;
+ ServiceList serviceList;
+ deviceInfoToPublish->getServiceList(&serviceList);
- for (serv_list_t::iterator iterPos = serv_list.begin(); iterPos != serv_list.end(); ++iterPos) {
- IService* cur_serv = *iterPos;
- convertServiceIntoJson(cur_serv, &device_json);
+ for (ServiceList::iterator iterPos = serviceList.begin(); iterPos != serviceList.end(); ++iterPos) {
+ IService* currentService = *iterPos;
+ convertServiceIntoJson(currentService, &deviceJson);
}
- // iterate through request_map for service
- _D("Iterate through request_map to publish..");
+ // iterate through __requestMap for service
+ _D("Iterate through __requestMap to publish..");
int index = 0;
- request_map_t::iterator IterPos;
- for (IterPos = request_map.begin(); IterPos != request_map.end(); ++IterPos) {
- Request* cur_Req = IterPos->second;
- cur_Req->publish(CONV_ERROR_NONE, device_json);
+ RequestMap::iterator IterPos;
+ for (IterPos = __requestMap.begin(); IterPos != __requestMap.end(); ++IterPos) {
+ Request* currentRequest = IterPos->second;
+ currentRequest->publish(CONV_ERROR_NONE, deviceJson);
index++;
}
int handleRequest(Request* requestObj);
// discovery_manager aggregates devices with services which have been discovered through the registered discover providers
- int appendDiscoveredResult(IDevice* disc_device);
- int notifyLostDevice(IDevice* disc_device);
+ int appendDiscoveredResult(IDevice* discoveredDevice);
+ int notifyLostDevice(IDevice* discoveredDevice);
int notifyTimeOut(std::string client);
int stopDiscovery();
int startDiscovery();
static void __timer_worker(void* data);
private:
- int count_discovery_request;
+ int __countDiscoveryRequest;
- typedef std::list<IDiscoveryProvider*> discovery_provider_list_t;
- typedef std::map<string, Request*> request_map_t;
- typedef std::map<int, Json> filter_map_t;
- typedef std::map<std::string, int> timer_map_t;
+ typedef std::list<IDiscoveryProvider*> DiscoveryProviderList;
+ typedef std::map<string, Request*> RequestMap;
+ typedef std::map<std::string, int> TimerMap;
int registerProvider(IDiscoveryProvider *discoveryProvider);
- discovery_provider_list_t __providerList;
- request_map_t request_map;
- filter_map_t discovery_filter_map;
- timer_map_t request_timer_map;
+ DiscoveryProviderList __providerList;
+ RequestMap __requestMap;
+ TimerMap __requestTimerMap;
// internal function
- int convertServiceIntoJson(conv::IService* service_info, Json* json_data);
- int convertDeviceIntoJson(conv::IDevice* service_info, Json* json_data);
+ int convertServiceIntoJson(conv::IService* serviceInfo, Json* jsonData);
+ int convertDeviceIntoJson(conv::IDevice* serviceInfo, Json* jsonData);
int checkBoundaryForTimeOut(int givenTimeout);
- int mergeExcludeServices(conv::IDevice* org_device, conv::IDevice* new_device);
- int excludeServices(conv::IDevice* org_device, conv::IDevice* removed_device);
+ int mergeExcludeServices(conv::IDevice* org_device, conv::IDevice* newDevice);
+ int excludeServices(conv::IDevice* org_device, conv::IDevice* removedDevice);
};
namespace discovery_manager {
void setInstance(DiscoveryManager* mgr);
int handleRequest(Request* requestObj);
- int setResult(SmartViewDevice* device_obj);
+ int setResult(SmartViewDevice* deviceObj);
};
}
public:
virtual ~IDevice() {}
- virtual int addService(IService* service_obj) = 0;
- virtual int removeService(IService* service_obj) = 0;
+ virtual int addService(IService* serviceObj) = 0;
+ virtual int removeService(IService* serviceObj) = 0;
virtual int getServiceList(std::list<IService*> *list) = 0;
virtual string getName() = 0;
#include "DiscoveryManager.h"
-conv::DiscoveryManager* conv::IDiscoveryProvider::_discovery_manager = NULL;
+conv::DiscoveryManager* conv::IDiscoveryProvider::__discoveryManager = NULL;
-int conv::IDiscoveryProvider::setManager(DiscoveryManager* discovery_manager)
+int conv::IDiscoveryProvider::setManager(DiscoveryManager* discoveryManager)
{
- _discovery_manager = discovery_manager;
+ __discoveryManager = discoveryManager;
return CONV_ERROR_NONE;
}
virtual int start() = 0;
virtual int stop() = 0;
- int setManager(DiscoveryManager* discovery_manager);
+ int setManager(DiscoveryManager* discoveryManager);
protected:
- static DiscoveryManager* _discovery_manager;
+ static DiscoveryManager* __discoveryManager;
}; /* class IDiscoveryProvider */
}
virtual int init() = 0;
virtual int release() = 0;
- virtual int startRequest(Request* request_obj) = 0;
- virtual int stopRequest(Request* request_obj) = 0;
- virtual int readRequest(Request* request_obj) = 0;
- virtual int publishRequest(Request* request_obj) = 0;
- virtual int registerRequest(Request* request_obj) = 0;
- virtual int loadServiceInfo(Request* request_obj) = 0;
- virtual int getServiceInfoForDiscovery(Json* json_obj) = 0;
+ virtual int startRequest(Request* requestObj) = 0;
+ virtual int stopRequest(Request* requestObj) = 0;
+ virtual int readRequest(Request* requestObj) = 0;
+ virtual int publishRequest(Request* requestObj) = 0;
+ virtual int registerRequest(Request* requestObj) = 0;
+ virtual int loadServiceInfo(Request* requestObj) = 0;
+ virtual int getServiceInfoForDiscovery(Json* jsonObj) = 0;
int checkActivationState() {
if (__activationState == 1) {
return CONV_ERROR_NONE;
public:
std::string address;
std::string uri;
- std::string resource_type;
+ std::string resourceType;
- iotcon_remote_resource_h iotcon_resource_handle;
- iotcon_representation_h iotcon_representation_handle;
+ iotcon_remote_resource_h iotconResourceHandle;
+ iotcon_representation_h iotconRepresentationHandle;
};
}
return NULL;
}
- char* device_id = (char*) conv::util::getDeviceId().c_str();
- char* device_name = (char*) conv::util::getDeviceName().c_str();
+ char* deviceId = (char*) conv::util::getDeviceId().c_str();
+ char* deviceName = (char*) conv::util::getDeviceName().c_str();
- iotcon_attributes_add_str(attributes, CONV_JSON_DEVICE_ID, device_id);
- iotcon_attributes_add_str(attributes, CONV_JSON_DEVICE_NAME, device_name);
+ iotcon_attributes_add_str(attributes, CONV_JSON_DEVICE_ID, deviceId);
+ iotcon_attributes_add_str(attributes, CONV_JSON_DEVICE_NAME, deviceName);
#ifdef _TV_
string device_type("TV");
#else
#endif
iotcon_attributes_add_str(attributes, CONV_JSON_DEVICE_TYPE, (char*) device_type.c_str());
- conv::Json service_json;
- instance->getServiceInfoForDiscovery(&service_json);
- char* service_json_char = service_json.dupCstr();
+ conv::Json serviceJson;
+ instance->getServiceInfoForDiscovery(&serviceJson);
+ char* service_json_char = serviceJson.dupCstr();
- iotcon_attributes_add_str(attributes, "service_json", service_json_char);
+ iotcon_attributes_add_str(attributes, "serviceJson", service_json_char);
ret = iotcon_representation_set_attributes(repr, attributes);
g_free(service_json_char);
return repr;
}
-int conv::ServiceManager::getServiceInfoForDiscovery(Json* service_json)
+int conv::ServiceManager::getServiceInfoForDiscovery(Json* serviceJson)
{
- IF_FAIL_RETURN_TAG(service_json, CONV_ERROR_INVALID_OPERATION, _E, "service_json is NULL");
+ IF_FAIL_RETURN_TAG(serviceJson, CONV_ERROR_INVALID_OPERATION, _E, "serviceJson is NULL");
for (ServiceProviderList::iterator it = __providerList.begin(); it != __providerList.end(); ++it) {
- Json service_info;
- if ((*it)->getServiceInfoForDiscovery(&service_info) == CONV_ERROR_NONE) {
- service_json->appendArray(NULL, "service_list", service_info);
+ Json serviceInfo;
+ if ((*it)->getServiceInfoForDiscovery(&serviceInfo) == CONV_ERROR_NONE) {
+ serviceJson->appendArray(NULL, "service_list", serviceInfo);
}
}
- _D("service_info : %s", service_json->str().c_str());
+ _D("service_info : %s", serviceJson->str().c_str());
return CONV_ERROR_NONE;
}
int release();
int handleRequest(Request* requestObj);
- int getServiceInfoForDiscovery(Json* service_json);
+ int getServiceInfoForDiscovery(Json* serviceJson);
int handleVconfUpdate(keynode_t *node);
private:
std::string conv::util::getBtMacAddress()
{
- static std::string g_mac_address;
- if(g_mac_address.empty()) {
+ static std::string __macAddress;
+ if(__macAddress.empty()) {
bt_initialize();
- char* mac_address;
+ char* macAddress;
bt_adapter_enable();
- int ret = bt_adapter_get_address(&mac_address);
+ int ret = bt_adapter_get_address(&macAddress);
IF_FAIL_RETURN_TAG(ret == 0, NULL, _E, "bluetooth get mac address failed : %d", ret);
- _D("bluetooth get mac address : %s", mac_address);
- g_mac_address = mac_address;
- free(mac_address);
+ _D("bluetooth get mac address : %s", macAddress);
+ __macAddress = macAddress;
+ free(macAddress);
bt_deinitialize();
}
- _D("mac address:%s", g_mac_address.c_str());
- return g_mac_address;
+ _D("mac address:%s", __macAddress.c_str());
+ return __macAddress;
}
std::string conv::util::getDeviceName()
{
- static std::string g_device_name;
- if(g_device_name.empty()) {
- char* device_name = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR);
- if (device_name == NULL) {
- g_device_name = "Tizen";
+ static std::string __deviceName;
+ if(__deviceName.empty()) {
+ char* deviceName = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR);
+ if (deviceName == NULL) {
+ __deviceName = "Tizen";
} else {
- g_device_name = device_name;
+ __deviceName = deviceName;
}
- _D("device_name: %s", g_device_name.c_str());
+ _D("device_name: %s", __deviceName.c_str());
}
- return g_device_name;
+ return __deviceName;
}
static char __make_p2p_mac(char c)
{
- char convert_c = c;
- if ((convert_c >= 'A') && (convert_c <= 'F')) {
- convert_c = ((((convert_c - 'A') + 10) | 0x02) - 10) + 'A';
- } else if ((convert_c >= '0') && (convert_c <= '9')) {
- convert_c = ((convert_c - '0') | 0x02);
- if (convert_c < 10)
- convert_c = convert_c + '0';
+ char convertC = c;
+ if ((convertC >= 'A') && (convertC <= 'F')) {
+ convertC = ((((convertC - 'A') + 10) | 0x02) - 10) + 'A';
+ } else if ((convertC >= '0') && (convertC <= '9')) {
+ convertC = ((convertC - '0') | 0x02);
+ if (convertC < 10)
+ convertC = convertC + '0';
else
- convert_c = 'A' + (convert_c - 10);
+ convertC = 'A' + (convertC - 10);
} else {
_E("wrong byte for mac!");
}
- return convert_c;
+ return convertC;
}
std::string conv::util::getP2pMacAddress()
{
- static std::string g_p2p_mac_address;
- if(g_p2p_mac_address.empty()) {
+ static std::string __p2pMacAddress;
+ if(__p2pMacAddress.empty()) {
char p2p_mac[MAC_ADDR_STR_LEN];
memset(p2p_mac, 0x0, MAC_ADDR_STR_LEN);
_I("P2P mac is %s", p2p_mac);
free(temp_addr);
- g_p2p_mac_address = p2p_mac;
+ __p2pMacAddress = p2p_mac;
}
}
- _D("p2p mac address:%s", g_p2p_mac_address.c_str());
- return g_p2p_mac_address;
+ _D("p2p mac address:%s", __p2pMacAddress.c_str());
+ return __p2pMacAddress;
}
static gboolean __misc_timer_worker(gpointer ud)
std::string conv::util::getDeviceId()
{
- static std::string g_device_id;
- if(g_device_id.empty()) {
- g_device_id = Service::getUniqueId("127.0.0.1:8001");
+ static std::string __deviceId;
+ if(__deviceId.empty()) {
+ __deviceId = Service::getUniqueId("127.0.0.1:8001");
- if(g_device_id.empty())
+ if(__deviceId.empty())
#ifdef _TV_
- g_device_id = getBtMacAddress();
+ __deviceId = getBtMacAddress();
#else
- g_device_id = getP2pMacAddress();
+ __deviceId = getP2pMacAddress();
#endif
}
- _D("device id : %s", g_device_id.c_str());
+ _D("device id : %s", __deviceId.c_str());
- return g_device_id;
+ return __deviceId;
}
bool conv::util::isServiceActivated(int serviceValue)
ret = iotcon_attributes_foreach(recv_attributes, response_attributes_cb, NULL);
IF_FAIL_VOID_TAG((ret == IOTCON_ERROR_NONE), _E, "iotcon_attributes_for_each() Fail[%d]", ret);
- char *device_id = NULL, *device_name = NULL, *device_type = NULL, *version = NULL, *service_list = NULL;
- ret = iotcon_attributes_get_str(recv_attributes, "device_id", &device_id); // device id (ex. bt address)
+ char *deviceId = NULL, *deviceName = NULL, *device_type = NULL, *version = NULL, *service_list = NULL;
+ ret = iotcon_attributes_get_str(recv_attributes, "device_id", &deviceId); // device id (ex. bt address)
IF_FAIL_VOID_TAG((ret == IOTCON_ERROR_NONE), _E, "iotcon_attributes_get_str() Fail[%d]", ret);
- cur_resource_h.setDeviceId(string(device_id));
+ cur_resource_h.setDeviceId(string(deviceId));
- if ( conv::util::getDeviceId().compare(device_id) == 0 ) {
- _D("the device has found itself..[device_id:%s].. out!", device_id);
+ if ( conv::util::getDeviceId().compare(deviceId) == 0 ) {
+ _D("the device has found itself..[device_id:%s].. out!", deviceId);
return;
}
- ret = iotcon_attributes_get_str(recv_attributes, "device_name", &device_name);
+ ret = iotcon_attributes_get_str(recv_attributes, "device_name", &deviceName);
IF_FAIL_VOID_TAG((ret == IOTCON_ERROR_NONE), _E, "iotcon_attributes_get_str() Fail[%d]", ret);
- cur_resource_h.setDeviceName(string(device_name));
+ cur_resource_h.setDeviceName(string(deviceName));
ret = iotcon_attributes_get_str(recv_attributes, "device_type", &device_type);
IF_FAIL_VOID_TAG((ret == IOTCON_ERROR_NONE), _E, "iotcon_attributes_get_str() Fail[%d]", ret);
cur_resource_h.setDeviceType(string(device_type));
char* service_json_char = NULL;
- ret = iotcon_attributes_get_str(recv_attributes, "service_json", &service_json_char);
+ ret = iotcon_attributes_get_str(recv_attributes, "serviceJson", &service_json_char);
if (service_json_char == NULL) {
- _D("service_json does not exist...");
+ _D("serviceJson does not exist...");
service_json_char = const_cast<char*>("");
}
- std::string service_json(service_json_char);
+ std::string serviceJson(service_json_char);
- cur_resource_h.setServiceList(service_json);
- Json service_list_json(service_json);
+ cur_resource_h.setServiceList(serviceJson);
+ Json service_list_json(serviceJson);
_D("on_response : device_id[%s] device_name[%s] device_type[%s] version[%s] service_list[%s]"
- , device_id, device_name, device_type, version, service_list);
+ , deviceId, deviceName, device_type, version, service_list);
- if (_discovery_manager != NULL) {
+ if (__discoveryManager != NULL) {
DeviceAdapter* device = new(std::nothrow) DeviceAdapter (cur_resource_h);
int num_service = service_list_json.getArraySize(NULL, "service_list");
device->addService(serv);
}
- _discovery_manager->appendDiscoveredResult(device);
+ __discoveryManager->appendDiscoveredResult(device);
}
discovery_complete_list.push_back(discoveryKey);
char* resource_uri_path = NULL;
char* resource_host = NULL;
iotcon_resource_types_h resource_types = NULL;
- string resource_type;
+ string resourceType;
iotcon_resource_interfaces_h resource_interfaces;
// uri_path , host_address
conv::SmartviewDiscoveryProvider* disc_provider;
public:
- void set_discovery_manager(conv::DiscoveryManager* discovery_manager)
+ void set_discovery_manager(conv::DiscoveryManager* discoveryManager)
{
- this->disc_manager = discovery_manager;
+ this->disc_manager = discoveryManager;
}
void set_discovery_provider(conv::SmartviewDiscoveryProvider* discovery_provider)
return CONV_ERROR_OUT_OF_MEMORY;
}
listener_impl->set_discovery_provider(this);
- listener_impl->set_discovery_manager(_discovery_manager);
+ listener_impl->set_discovery_manager(__discoveryManager);
}
search->setSearchListener(listener_impl);
//1. delete it from the cache..
removeFromCache(conv_service);
//2. notify
- _discovery_manager->notifyLostDevice(conv_device);
+ __discoveryManager->notifyLostDevice(conv_device);
return CONV_ERROR_NONE;
} else {
if (!alreadyExisted) {
//the discovered one is NEW!!
- _discovery_manager->appendDiscoveredResult(conv_device);
+ __discoveryManager->appendDiscoveredResult(conv_device);
}
}
{
#if 0//def TEMP_TEST
static int first = 1;
- if (!strcmp(peer->device_name, "D2d note" ) ) {
+ if (!strcmp(peer->deviceName, "D2d note" ) ) {
first = 0;
int result = wifi_direct_connect(peer->mac_address);
_D("connect result = %d", result);
conv::WifiDirectDiscoveryProvider* disc_provider = (conv::WifiDirectDiscoveryProvider*)user_data;
conv::SmartViewService *conv_service = new(std::nothrow) conv::SmartViewService;
- conv_service->setName(peer->device_name);
+ conv_service->setName(peer->deviceName);
conv_service->setVersion("0.0");
conv_service->setType("");
conv_service->setId(peer->mac_address);
if (!alreadyExisted) {
//the discovered one is NEW!!
// TO-DO : need to re-write this code
- //_discovery_manager->appendDiscoveredResult(NULL, conv_service);
+ //__discoveryManager->appendDiscoveredResult(NULL, conv_service);
}
return CONV_ERROR_NONE;
return false;
}
-int conv::DeviceAdapter::addService(IService* service_obj)
+int conv::DeviceAdapter::addService(IService* serviceObj)
{
service_list_t::iterator itr;
- itr = std::find_if(service_list.begin(), service_list.end(), std::bind(serviceComparision, std::placeholders::_1, service_obj->getServiceType()));
+ itr = std::find_if(service_list.begin(), service_list.end(), std::bind(serviceComparision, std::placeholders::_1, serviceObj->getServiceType()));
if (itr == service_list.end()) {
_D("New Service Type[%d] added to the device[%s]",
- service_obj->getServiceType(), getId().c_str());
- service_list.push_back(service_obj);
+ serviceObj->getServiceType(), getId().c_str());
+ service_list.push_back(serviceObj);
} else {
_D("Service Type[%d] is already included in device[%s] so skipped!",
- service_obj->getServiceType(), getId().c_str());
+ serviceObj->getServiceType(), getId().c_str());
}
return CONV_ERROR_NONE;
}
-int conv::DeviceAdapter::removeService(IService* service_obj)
+int conv::DeviceAdapter::removeService(IService* serviceObj)
{
- service_list.remove(service_obj);
+ service_list.remove(serviceObj);
return CONV_ERROR_NONE;
}
DeviceAdapter(ResourceHandle res_h);
~DeviceAdapter();
- int addService(IService* service_obj);
- int removeService(IService* service_obj);
+ int addService(IService* serviceObj);
+ int removeService(IService* serviceObj);
int getServiceList(std::list<IService*> *list);
string getName();
string getId();
using namespace std;
-int conv::ResourceHandle::setDeviceId(string dev_id)
+int conv::ResourceHandle::setDeviceId(string devId)
{
- this->device_id = dev_id;
+ this->deviceId = devId;
return CONV_ERROR_NONE;
}
string conv::ResourceHandle::getDeviceId()
{
- return this->device_id;
+ return this->deviceId;
}
-int conv::ResourceHandle::setDeviceName(string dev_name)
+int conv::ResourceHandle::setDeviceName(string devName)
{
- this->device_name = dev_name;
+ this->deviceName = devName;
return CONV_ERROR_NONE;
}
string conv::ResourceHandle::getDeviceName()
{
- return device_name;
+ return deviceName;
}
-int conv::ResourceHandle::setDeviceType(string dev_type)
+int conv::ResourceHandle::setDeviceType(string devType)
{
- this->device_type = dev_type;
+ this->device_type = devType;
return CONV_ERROR_NONE;
}
list<string> types;
list<string> interfaces;
- string device_id;
- string device_name;
+ string deviceId;
+ string deviceName;
string device_type;
string version;
Json services_list;
int conv::ServiceAdapter::setServiceInfo(string serviceInfo)
{
- this->service_info = serviceInfo;
+ this->__serviceInfo = serviceInfo;
return CONV_ERROR_NONE;
}
string conv::ServiceAdapter::getServiceInfo()
{
- return service_info;
+ return __serviceInfo;
}
ResourceHandle m_resource_h;
int service_type;
- string service_info;
+ string __serviceInfo;
};
}
return false;
}
-int conv::SmartViewDevice::addService(IService* service_obj)
+int conv::SmartViewDevice::addService(IService* serviceObj)
{
service_list_t::iterator itr;
- itr = std::find_if(service_list.begin(), service_list.end(), std::bind(serviceComparision, std::placeholders::_1, service_obj->getServiceType()));
+ itr = std::find_if(service_list.begin(), service_list.end(), std::bind(serviceComparision, std::placeholders::_1, serviceObj->getServiceType()));
if (itr == service_list.end()) {
_D("New Service Type[%d] added to the device[%s]",
- service_obj->getServiceType(), getId().c_str());
- service_list.push_back(service_obj);
+ serviceObj->getServiceType(), getId().c_str());
+ service_list.push_back(serviceObj);
} else {
_D("Service Type[%d] is already included in device[%s] so skipped!",
- service_obj->getServiceType(), getId().c_str());
+ serviceObj->getServiceType(), getId().c_str());
}
return CONV_ERROR_NONE;
}
-int conv::SmartViewDevice::removeService(IService* service_obj)
+int conv::SmartViewDevice::removeService(IService* serviceObj)
{
- service_list.remove(service_obj);
+ service_list.remove(serviceObj);
return CONV_ERROR_NONE;
}
~SmartViewDevice();
// functions from IDevice
- int addService(IService* service_obj);
- int removeService(IService* service_obj);
+ int addService(IService* serviceObj);
+ int removeService(IService* serviceObj);
int getServiceList(std::list<IService*> *list);
std::string getName();
std::string getId();
string conv::SmartViewService::getServiceInfo()
{
- return service_info;
+ return __serviceInfo;
}
void conv::SmartViewService::setName(string name)
this->service_uri = uri;
}
-void conv::SmartViewService::setServiceInfo(string service_info)
+void conv::SmartViewService::setServiceInfo(string serviceInfo)
{
- this->service_info = service_info;
+ this->__serviceInfo = serviceInfo;
}
void conv::SmartViewService::setServiceType(int service_type)
void setType(string type);
void setId(string id);
void setUri(string uri);
- void setServiceInfo(string service_info);
+ void setServiceInfo(string serviceInfo);
void setServiceType(int service_type);
void printInfo();
int connection_state;
string service_name;
int service_type;
- string service_info;
+ string __serviceInfo;
string service_version;
string service_id;
#include "Result.h"
namespace conv {
- class application_instance : public OnConnectListener, public OnDisconnectListener, public OnClientConnectListener, public OnClientDisconnectListener,
+ class ApplicationInstance : public OnConnectListener, public OnDisconnectListener, public OnClientConnectListener, public OnClientDisconnectListener,
public OnMessageListener, public OnErrorListener, public OnStartAppListener, public OnStopAppListener, public OnPublishListener {
public:
- virtual ~application_instance()
+ virtual ~ApplicationInstance()
{
if (application != NULL)
delete application;
}
- conv::Request** request_obj;
+ conv::Request** requestObj;
Channel* application;
string uri;
- string channel_id;
- Service local_service;
- bool is_local;
+ string channelId;
+ Service localService;
+ bool isLocal;
void onStart(bool start_result)
{
_D("onStart Called");
- if ((*request_obj) != NULL) {
+ if ((*requestObj) != NULL) {
_D(RED("publishing_response"));
Json result;
Json payload;
payload.set(NULL, CONV_JSON_RESULT_TYPE, CONV_JSON_ON_START);
- description = (*request_obj)->getDescription();
+ description = (*requestObj)->getDescription();
description.set(CONV_JSON_CHANNEL, CONV_JSON_URI, uri);
- description.set(CONV_JSON_CHANNEL, CONV_JSON_CHANNEL_ID, channel_id);
+ description.set(CONV_JSON_CHANNEL, CONV_JSON_CHANNEL_ID, channelId);
result.set(NULL, CONV_JSON_DESCRIPTION, description);
result.set(NULL, CONV_JSON_PAYLOAD, payload);
if (start_result)
- (*request_obj)->publish(CONV_ERROR_NONE, result);
+ (*requestObj)->publish(CONV_ERROR_NONE, result);
else
- (*request_obj)->publish(CONV_ERROR_INVALID_OPERATION, result);
+ (*requestObj)->publish(CONV_ERROR_INVALID_OPERATION, result);
}
}
{
_D("onStop Called");
- if (!is_local && application != NULL) {
+ if (!isLocal && application != NULL) {
application->disconnect();
}
- if ((*request_obj) != NULL) {
+ if ((*requestObj) != NULL) {
_D(RED("publishing_response"));
Json result;
Json payload;
payload.set(NULL, CONV_JSON_RESULT_TYPE, CONV_JSON_ON_STOP);
- description = (*request_obj)->getDescription();
+ description = (*requestObj)->getDescription();
description.set(CONV_JSON_CHANNEL, CONV_JSON_URI, uri);
- description.set(CONV_JSON_CHANNEL, CONV_JSON_CHANNEL_ID, channel_id);
+ description.set(CONV_JSON_CHANNEL, CONV_JSON_CHANNEL_ID, channelId);
result.set(NULL, CONV_JSON_DESCRIPTION, description);
result.set(NULL, CONV_JSON_PAYLOAD, payload);
if (start_result)
- (*request_obj)->publish(CONV_ERROR_NONE, result);
+ (*requestObj)->publish(CONV_ERROR_NONE, result);
else
- (*request_obj)->publish(CONV_ERROR_INVALID_OPERATION, result);
+ (*requestObj)->publish(CONV_ERROR_INVALID_OPERATION, result);
}
}
_D("onConnect Called");
publishResponse(CONV_ERROR_NONE, CONV_JSON_ON_CONNECT, &client);
- if (!is_local && application != NULL) {
+ if (!isLocal && application != NULL) {
((Application*)application)->start();
_D("Application start requested");
}
{
_D("onMessage Called");
- if ((*request_obj) != NULL) {
+ if ((*requestObj) != NULL) {
_D(RED("publishing_response"));
Json result;
Json message_json;
payload.set(NULL, CONV_JSON_RESULT_TYPE, CONV_JSON_ON_MESSAGE);
payload.set(NULL, CONV_JSON_MESSAGE, message_json);
- description = (*request_obj)->getDescription();
+ description = (*requestObj)->getDescription();
description.set(CONV_JSON_CHANNEL, CONV_JSON_URI, uri);
- description.set(CONV_JSON_CHANNEL, CONV_JSON_CHANNEL_ID, channel_id);
+ description.set(CONV_JSON_CHANNEL, CONV_JSON_CHANNEL_ID, channelId);
result.set(NULL, CONV_JSON_DESCRIPTION, description);
result.set(NULL, CONV_JSON_PAYLOAD, payload);
- (*request_obj)->publish(CONV_ERROR_NONE, result);
+ (*requestObj)->publish(CONV_ERROR_NONE, result);
}
}
{
_D("onError Called");
- if ((*request_obj) != NULL) {
+ if ((*requestObj) != NULL) {
_D(RED("publishing_response"));
Json result;
Json payload;
payload.set(NULL, CONV_JSON_RESULT_TYPE, CONV_JSON_ON_ERROR);
payload.set(NULL, CONV_JSON_ERROR_MESSAGE, error.get_error_message());
- description = (*request_obj)->getDescription();
+ description = (*requestObj)->getDescription();
description.set(CONV_JSON_CHANNEL, CONV_JSON_URI, uri);
- description.set(CONV_JSON_CHANNEL, CONV_JSON_CHANNEL_ID, channel_id);
+ description.set(CONV_JSON_CHANNEL, CONV_JSON_CHANNEL_ID, channelId);
result.set(NULL, CONV_JSON_DESCRIPTION, description);
result.set(NULL, CONV_JSON_PAYLOAD, payload);
- (*request_obj)->publish(CONV_ERROR_INVALID_OPERATION, result);
+ (*requestObj)->publish(CONV_ERROR_INVALID_OPERATION, result);
}
}
{
_D("onPublished Called");
- if ((*request_obj) != NULL) {
+ if ((*requestObj) != NULL) {
_D(RED("publishing_response"));
Json result;
Json payload;
payload.set(NULL, CONV_JSON_RESULT_TYPE, CONV_JSON_ON_PUBLISH);
- description = (*request_obj)->getDescription();
+ description = (*requestObj)->getDescription();
description.set(CONV_JSON_CHANNEL, CONV_JSON_URI, uri);
- description.set(CONV_JSON_CHANNEL, CONV_JSON_CHANNEL_ID, channel_id);
+ description.set(CONV_JSON_CHANNEL, CONV_JSON_CHANNEL_ID, channelId);
result.set(NULL, CONV_JSON_DESCRIPTION, description);
result.set(NULL, CONV_JSON_PAYLOAD, payload);
if (publish_result)
- (*request_obj)->publish(CONV_ERROR_NONE, result);
+ (*requestObj)->publish(CONV_ERROR_NONE, result);
else
- (*request_obj)->publish(CONV_ERROR_INVALID_OPERATION, result);
+ (*requestObj)->publish(CONV_ERROR_INVALID_OPERATION, result);
}
}
bool isHost = client->isHost();
int connecttime = client->getConnectTime();
- if ((*request_obj) != NULL) {
+ if ((*requestObj) != NULL) {
_D(RED("publishing_response"));
Json result;
Json payload;
payload.set(NULL, CONV_JSON_RESULT_TYPE, result_type);
payload.set(NULL, CONV_JSON_CLIENT, client_json);
- description = (*request_obj)->getDescription();
+ description = (*requestObj)->getDescription();
description.set(CONV_JSON_CHANNEL, CONV_JSON_URI, uri);
- description.set(CONV_JSON_CHANNEL, CONV_JSON_CHANNEL_ID, channel_id);
+ description.set(CONV_JSON_CHANNEL, CONV_JSON_CHANNEL_ID, channelId);
result.set(NULL, CONV_JSON_DESCRIPTION, description);
result.set(NULL, CONV_JSON_PAYLOAD, payload);
- (*request_obj)->publish(error, result);
+ (*requestObj)->publish(error, result);
}
}
};
- typedef vector<application_instance*> application_instance_list_t;
+ typedef vector<ApplicationInstance*> ApplicationInstanceList;
// service information to handle app-to-app service with specific device 'id'
class AppCommServiceInfo : public IServiceInfo, public Result_Base {
void onSuccess(Service service)
{
_D("getByUri : service name : %s", service.getName().c_str() ? service.getName().c_str() : "name is NULL");
- service_obj = service;
- get_service_result = true;
+ serviceObj = service;
+ readRequestResult = true;
}
void onError(Error)
{
_D("getByUri Error");
- get_service_result = false;
+ readRequestResult = false;
}
~AppCommServiceInfo()
{
- if (registered_request != NULL) {
- delete registered_request;
+ if (registeredRequest != NULL) {
+ delete registeredRequest;
}
- for (application_instance_list_t::iterator iter = application_instance_list.begin(); iter != application_instance_list.end(); ++iter) {
- application_instance *app_info = *iter;
- delete app_info;
- application_instance_list.erase(iter);
+ for (ApplicationInstanceList::iterator iter = applicationInstanceList.begin(); iter != applicationInstanceList.end(); ++iter) {
+ ApplicationInstance *appInfo = *iter;
+ delete appInfo;
+ applicationInstanceList.erase(iter);
}
}
std::string id;
- Service service_obj;
- bool is_local;
- bool get_service_result;
- conv::Request* registered_request;
+ Service serviceObj;
+ bool isLocal;
+ bool readRequestResult;
+ conv::Request* registeredRequest;
- application_instance_list_t application_instance_list;
+ ApplicationInstanceList applicationInstanceList;
};
}
return CONV_ERROR_NONE;
}
-int conv::AppCommServiceProvider::loadServiceInfo(Request* request_obj)
+int conv::AppCommServiceProvider::loadServiceInfo(Request* requestObj)
{
IF_FAIL_RETURN_TAG(__activationState == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
string client;
- conv::ClientInfo* client_obj = NULL;
- int is_local = 0;
+ conv::ClientInfo* clientObj = NULL;
+ int isLocal = 0;
Json service;
string name, version, type, id, uri;
- Json description = request_obj->getDescription();
+ Json description = requestObj->getDescription();
description.get(NULL, CONV_JSON_SERVICE, &service);
service.get(NULL, CONV_JSON_SERVICE_DATA_ID, &id);
service.get(NULL, CONV_JSON_SERVICE_DATA_URI, &uri);
- description.get(NULL, CONV_JSON_IS_LOCAL, &is_local);
+ description.get(NULL, CONV_JSON_IS_LOCAL, &isLocal);
- client = request_obj->getSender();
+ client = requestObj->getSender();
_D("client id : %s", client.c_str());
- client_obj = conv::client_manager::getClient(client);
- IF_FAIL_RETURN_TAG(client_obj, CONV_ERROR_OUT_OF_MEMORY, _E, "client info alloc failed");
+ clientObj = conv::client_manager::getClient(client);
+ IF_FAIL_RETURN_TAG(clientObj, CONV_ERROR_OUT_OF_MEMORY, _E, "client info alloc failed");
- AppCommServiceInfo *svc_info = NULL;
+ AppCommServiceInfo *svcInfo = NULL;
- if (is_local == 1) {
- IServiceInfo* svc_info_base = client_obj->getServiceInfo(__type, "LOCAL_HOST");
+ if (isLocal == 1) {
+ IServiceInfo* svcInfoBase = clientObj->getServiceInfo(__type, "LOCAL_HOST");
- if ( svc_info_base != NULL ) {
+ if ( svcInfoBase != NULL ) {
_D("local service instance already exists");
- svc_info = reinterpret_cast<AppCommServiceInfo*>(svc_info_base);
+ svcInfo = reinterpret_cast<AppCommServiceInfo*>(svcInfoBase);
- if (svc_info == NULL) {
+ if (svcInfo == NULL) {
_D("casting failed");
return CONV_ERROR_INVALID_OPERATION;
}
} else {
_D("allocating new service instance for local service");
- svc_info = new(std::nothrow) AppCommServiceInfo();
- ASSERT_ALLOC(svc_info);
+ svcInfo = new(std::nothrow) AppCommServiceInfo();
+ ASSERT_ALLOC(svcInfo);
- svc_info->is_local = true;
- client_obj->addServiceInfo(__type, "LOCAL_HOST", (IServiceInfo*)svc_info);
+ svcInfo->isLocal = true;
+ clientObj->addServiceInfo(__type, "LOCAL_HOST", (IServiceInfo*)svcInfo);
_D("MSF service is created");
}
} else {
- IServiceInfo* svc_info_base = client_obj->getServiceInfo(__type, id);
+ IServiceInfo* svcInfoBase = clientObj->getServiceInfo(__type, id);
- if ( svc_info_base != NULL ) {
+ if ( svcInfoBase != NULL ) {
_D("service instance already exists");
- svc_info = reinterpret_cast<AppCommServiceInfo*>(svc_info_base);
+ svcInfo = reinterpret_cast<AppCommServiceInfo*>(svcInfoBase);
- if (svc_info == NULL) {
+ if (svcInfo == NULL) {
_D("casting failed");
return CONV_ERROR_INVALID_OPERATION;
}
} else {
_D("allocating new service instance");
- svc_info = new(std::nothrow) AppCommServiceInfo();
- ASSERT_ALLOC(svc_info);
+ svcInfo = new(std::nothrow) AppCommServiceInfo();
+ ASSERT_ALLOC(svcInfo);
_D("uri : %s", uri.c_str());
- Service::getByURI(uri, 2000, svc_info);
- IF_FAIL_RETURN_TAG(svc_info->get_service_result == true, CONV_ERROR_INVALID_OPERATION, _E, "getByURI failed");
- svc_info->is_local = false;
- client_obj->addServiceInfo(__type, id, (IServiceInfo*)svc_info);
+ Service::getByURI(uri, 2000, svcInfo);
+ IF_FAIL_RETURN_TAG(svcInfo->readRequestResult == true, CONV_ERROR_INVALID_OPERATION, _E, "getByURI failed");
+ svcInfo->isLocal = false;
+ clientObj->addServiceInfo(__type, id, (IServiceInfo*)svcInfo);
_D("MSF service is created");
}
}
- request_obj->setServiceInfo(svc_info);
+ requestObj->setServiceInfo(svcInfo);
return CONV_ERROR_NONE;
}
-int conv::AppCommServiceProvider::startRequest(Request* request_obj)
+int conv::AppCommServiceProvider::startRequest(Request* requestObj)
{
IF_FAIL_RETURN_TAG(__activationState == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
_D("communcation/start requested");
- AppCommServiceInfo *svc_info = reinterpret_cast<AppCommServiceInfo*>(request_obj->getServiceInfo());
+ AppCommServiceInfo *svcInfo = reinterpret_cast<AppCommServiceInfo*>(requestObj->getServiceInfo());
Json channel;
- request_obj->getChannelFromDescription(&channel);
+ requestObj->getChannelFromDescription(&channel);
- string uri, channel_id;
+ string uri, channelId;
channel.get(NULL, CONV_JSON_URI, &uri);
- channel.get(NULL, CONV_JSON_CHANNEL_ID, &channel_id);
+ channel.get(NULL, CONV_JSON_CHANNEL_ID, &channelId);
- application_instance *app_info = NULL;
+ ApplicationInstance *appInfo = NULL;
- for (application_instance_list_t::iterator iter = svc_info->application_instance_list.begin(); iter != svc_info->application_instance_list.end(); ++iter) {
+ for (ApplicationInstanceList::iterator iter = svcInfo->applicationInstanceList.begin(); iter != svcInfo->applicationInstanceList.end(); ++iter) {
_D("iteration");
- if ( (*iter) != NULL && !(*iter)->uri.compare(uri) && !(*iter)->channel_id.compare(channel_id) ) {
+ if ( (*iter) != NULL && !(*iter)->uri.compare(uri) && !(*iter)->channelId.compare(channelId) ) {
if ( (*iter)->application != NULL ) {
_D("already started");
// check if it's connected and re-try if it's not
return CONV_ERROR_INVALID_OPERATION;
} else {
- _D("app_info exists but no application instance");
- app_info = (*iter);
+ _D("appInfo exists but no application instance");
+ appInfo = (*iter);
break;
}
}
}
- if ( app_info == NULL ) {
- app_info = new(std::nothrow) application_instance();
- ASSERT_ALLOC(app_info);
+ if ( appInfo == NULL ) {
+ appInfo = new(std::nothrow) ApplicationInstance();
+ ASSERT_ALLOC(appInfo);
- app_info->uri = uri;
- app_info->channel_id = channel_id;
+ appInfo->uri = uri;
+ appInfo->channelId = channelId;
}
// if it's local -> server application
- if ( svc_info->is_local ) {
- _D("COMMUNCATION_START : local channel. channel_id : %s", channel_id.c_str());
+ if ( svcInfo->isLocal ) {
+ _D("COMMUNCATION_START : local channel. channel_id : %s", channelId.c_str());
- app_info->local_service = Service::getLocal();
+ appInfo->localService = Service::getLocal();
- Channel* application = app_info->local_service.createChannel(channel_id);
+ Channel* application = appInfo->localService.createChannel(channelId);
// add listeners
- app_info->request_obj = &(svc_info->registered_request);
- application->setonConnectListener(app_info);
- application->setonClientConnectListener(app_info);
- application->setonClientDisconnectListener(app_info);
- application->setonErrorListener(app_info);
- application->setonDisconnectListener(app_info);
- application->addOnAllMessageListener(app_info);
- application->setonPublishListener(app_info);
-
- app_info->is_local = true;
- app_info->application = application;
+ appInfo->requestObj = &(svcInfo->registeredRequest);
+ application->setonConnectListener(appInfo);
+ application->setonClientConnectListener(appInfo);
+ application->setonClientDisconnectListener(appInfo);
+ application->setonErrorListener(appInfo);
+ application->setonDisconnectListener(appInfo);
+ application->addOnAllMessageListener(appInfo);
+ application->setonPublishListener(appInfo);
+
+ appInfo->isLocal = true;
+ appInfo->application = application;
application->connect();
_D("connect called");
- svc_info->application_instance_list.push_back(app_info);
+ svcInfo->applicationInstanceList.push_back(appInfo);
} else {
- _D("COMMUNCATION_START : uri : %s, channel_id : %s", uri.c_str(), channel_id.c_str());
- Application* application = new(std::nothrow) Application(&(svc_info->service_obj), uri, channel_id);
+ _D("COMMUNCATION_START : uri : %s, channel_id : %s", uri.c_str(), channelId.c_str());
+ Application* application = new(std::nothrow) Application(&(svcInfo->serviceObj), uri, channelId);
ASSERT_ALLOC(application);
// add listeners
- app_info->request_obj = &(svc_info->registered_request);
- application->setonConnectListener(app_info);
- application->setonClientConnectListener(app_info);
- application->setonClientDisconnectListener(app_info);
- application->setonErrorListener(app_info);
- application->setonDisconnectListener(app_info);
- ((Application*)application)->setonStartAppListener(app_info);
- ((Application*)application)->setonStopAppListener(app_info);
- application->addOnAllMessageListener(app_info);
- application->setonPublishListener(app_info);
-
- app_info->is_local = false;
- app_info->application = application;
+ appInfo->requestObj = &(svcInfo->registeredRequest);
+ application->setonConnectListener(appInfo);
+ application->setonClientConnectListener(appInfo);
+ application->setonClientDisconnectListener(appInfo);
+ application->setonErrorListener(appInfo);
+ application->setonDisconnectListener(appInfo);
+ ((Application*)application)->setonStartAppListener(appInfo);
+ ((Application*)application)->setonStopAppListener(appInfo);
+ application->addOnAllMessageListener(appInfo);
+ application->setonPublishListener(appInfo);
+
+ appInfo->isLocal = false;
+ appInfo->application = application;
application->connect();
- svc_info->application_instance_list.push_back(app_info);
+ svcInfo->applicationInstanceList.push_back(appInfo);
}
_D("connect requested");
return CONV_ERROR_NONE;
}
-int conv::AppCommServiceProvider::stopRequest(Request* request_obj)
+int conv::AppCommServiceProvider::stopRequest(Request* requestObj)
{
IF_FAIL_RETURN_TAG(__activationState == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
_D("communcation/stop requested");
- AppCommServiceInfo *svc_info = reinterpret_cast<AppCommServiceInfo*>(request_obj->getServiceInfo());
+ AppCommServiceInfo *svcInfo = reinterpret_cast<AppCommServiceInfo*>(requestObj->getServiceInfo());
Json channel;
- request_obj->getChannelFromDescription(&channel);
+ requestObj->getChannelFromDescription(&channel);
- string uri, channel_id;
+ string uri, channelId;
channel.get(NULL, CONV_JSON_URI, &uri);
- channel.get(NULL, CONV_JSON_CHANNEL_ID, &channel_id);
+ channel.get(NULL, CONV_JSON_CHANNEL_ID, &channelId);
- for (application_instance_list_t::iterator iter = svc_info->application_instance_list.begin(); iter != svc_info->application_instance_list.end(); ++iter) {
- _D("%s, %s", (*iter)->uri.c_str(), (*iter)->channel_id.c_str());
- if ( (*iter) != NULL && !(*iter)->uri.compare(uri) && !(*iter)->channel_id.compare(channel_id) ) {
- application_instance *app_info = *iter;
+ for (ApplicationInstanceList::iterator iter = svcInfo->applicationInstanceList.begin(); iter != svcInfo->applicationInstanceList.end(); ++iter) {
+ _D("%s, %s", (*iter)->uri.c_str(), (*iter)->channelId.c_str());
+ if ( (*iter) != NULL && !(*iter)->uri.compare(uri) && !(*iter)->channelId.compare(channelId) ) {
+ ApplicationInstance *appInfo = *iter;
- _D("COMMUNCATION_STOP : uri : %s, channel_id : %s", uri.c_str(), channel_id.c_str());
+ _D("COMMUNCATION_STOP : uri : %s, channel_id : %s", uri.c_str(), channelId.c_str());
if ( *iter == NULL ) {
_D("iter is NULL");
}
- if ( svc_info->is_local ) {
- app_info->application->disconnect();
- svc_info->application_instance_list.erase(iter);
+ if ( svcInfo->isLocal ) {
+ appInfo->application->disconnect();
+ svcInfo->applicationInstanceList.erase(iter);
} else {
- ((Application*)app_info->application)->stop();
- svc_info->application_instance_list.erase(iter);
+ ((Application*)appInfo->application)->stop();
+ svcInfo->applicationInstanceList.erase(iter);
}
return CONV_ERROR_NONE;
}
}
-int conv::AppCommServiceProvider::readRequest(Request* request_obj)
+int conv::AppCommServiceProvider::readRequest(Request* requestObj)
{
IF_FAIL_RETURN_TAG(__activationState == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
_D("communcation/get requested");
- AppCommServiceInfo *svc_info = reinterpret_cast<AppCommServiceInfo*>(request_obj->getServiceInfo());
+ AppCommServiceInfo *svcInfo = reinterpret_cast<AppCommServiceInfo*>(requestObj->getServiceInfo());
Json channel;
- request_obj->getChannelFromDescription(&channel);
+ requestObj->getChannelFromDescription(&channel);
- string uri, channel_id;
+ string uri, channelId;
channel.get(NULL, CONV_JSON_URI, &uri);
- channel.get(NULL, CONV_JSON_CHANNEL_ID, &channel_id);
+ channel.get(NULL, CONV_JSON_CHANNEL_ID, &channelId);
- application_instance *app_info = NULL;
+ ApplicationInstance *appInfo = NULL;
Json result;
- for (application_instance_list_t::iterator iter = svc_info->application_instance_list.begin(); iter != svc_info->application_instance_list.end(); ++iter) {
+ for (ApplicationInstanceList::iterator iter = svcInfo->applicationInstanceList.begin(); iter != svcInfo->applicationInstanceList.end(); ++iter) {
_D("iteration");
- if ( (*iter) != NULL && !(*iter)->uri.compare(uri) && !(*iter)->channel_id.compare(channel_id) ) {
+ if ( (*iter) != NULL && !(*iter)->uri.compare(uri) && !(*iter)->channelId.compare(channelId) ) {
if ( (*iter)->application != NULL ) {
- _D("app_info exists and application instance exists");
- app_info = (*iter);
+ _D("appInfo exists and application instance exists");
+ appInfo = (*iter);
- Clients* client_list = app_info->application->getclients();
+ Clients* client_list = appInfo->application->getclients();
- if ( svc_info->registered_request == NULL) {
+ if ( svcInfo->registeredRequest == NULL) {
_D("No callback is registered");
- sendReadResponse(result, CONV_JSON_GET_CLIENTS, CONV_ERROR_INVALID_OPERATION, svc_info->registered_request);
+ sendReadResponse(result, CONV_JSON_GET_CLIENTS, CONV_ERROR_INVALID_OPERATION, svcInfo->registeredRequest);
return CONV_ERROR_INVALID_OPERATION;
}
if (client_list == NULL) {
_D("No clients");
- sendReadResponse(result, CONV_JSON_GET_CLIENTS, CONV_ERROR_NO_DATA, svc_info->registered_request);
+ sendReadResponse(result, CONV_JSON_GET_CLIENTS, CONV_ERROR_NO_DATA, svcInfo->registeredRequest);
return CONV_ERROR_NO_DATA;
} else {
int cs_index = 0;
- Client client_obj;
+ Client clientObj;
_D("clients size = %d", client_list->size());
for (auto cs_itr = cl.begin(); cs_itr != cl.end(); cs_itr++) {
cs_index++;
result.appendArray(NULL, CONV_JSON_CLIENT_LIST, client);
}
- sendReadResponse(result, CONV_JSON_GET_CLIENTS, CONV_ERROR_NONE, svc_info->registered_request);
+ sendReadResponse(result, CONV_JSON_GET_CLIENTS, CONV_ERROR_NONE, svcInfo->registeredRequest);
return CONV_ERROR_NONE;
}
}
}
_D("service is not started");
- sendReadResponse(result, CONV_JSON_GET_CLIENTS, CONV_ERROR_INVALID_OPERATION, svc_info->registered_request);
+ sendReadResponse(result, CONV_JSON_GET_CLIENTS, CONV_ERROR_INVALID_OPERATION, svcInfo->registeredRequest);
return CONV_ERROR_INVALID_OPERATION;
}
-int conv::AppCommServiceProvider::sendReadResponse(Json payload, const char* read_type, conv_error_e error, Request* request_obj)
+int conv::AppCommServiceProvider::sendReadResponse(Json payload, const char* read_type, conv_error_e error, Request* requestObj)
{
_D(RED("publishing_response"));
- IF_FAIL_RETURN_TAG(request_obj != NULL, CONV_ERROR_INVALID_OPERATION, _E, "listener_cb is not registered");
+ IF_FAIL_RETURN_TAG(requestObj != NULL, CONV_ERROR_INVALID_OPERATION, _E, "listener_cb is not registered");
Json result;
- Json description = request_obj->getDescription();
+ Json description = requestObj->getDescription();
payload.set(NULL, CONV_JSON_RESULT_TYPE, CONV_JSON_ON_READ);
payload.set(NULL, CONV_JSON_READ_TYPE, read_type);
result.set(NULL, CONV_JSON_DESCRIPTION, description);
result.set(NULL, CONV_JSON_PAYLOAD, payload);
- request_obj->publish(error, result);
+ requestObj->publish(error, result);
return CONV_ERROR_NONE;
}
-int conv::AppCommServiceProvider::publishRequest(Request* request_obj)
+int conv::AppCommServiceProvider::publishRequest(Request* requestObj)
{
IF_FAIL_RETURN_TAG(__activationState == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
_D("communcation/set requested");
- AppCommServiceInfo *svc_info = reinterpret_cast<AppCommServiceInfo*>(request_obj->getServiceInfo());
+ AppCommServiceInfo *svcInfo = reinterpret_cast<AppCommServiceInfo*>(requestObj->getServiceInfo());
Json channel;
- request_obj->getChannelFromDescription(&channel);
+ requestObj->getChannelFromDescription(&channel);
- string uri, channel_id;
+ string uri, channelId;
channel.get(NULL, CONV_JSON_URI, &uri);
- channel.get(NULL, CONV_JSON_CHANNEL_ID, &channel_id);
+ channel.get(NULL, CONV_JSON_CHANNEL_ID, &channelId);
- for (application_instance_list_t::iterator iter = svc_info->application_instance_list.begin(); iter != svc_info->application_instance_list.end(); ++iter) {
+ for (ApplicationInstanceList::iterator iter = svcInfo->applicationInstanceList.begin(); iter != svcInfo->applicationInstanceList.end(); ++iter) {
_D("iteration");
- if ( (*iter) != NULL && !(*iter)->uri.compare(uri) && !(*iter)->channel_id.compare(channel_id) ) {
+ if ( (*iter) != NULL && !(*iter)->uri.compare(uri) && !(*iter)->channelId.compare(channelId) ) {
if ( (*iter)->application != NULL ) {
_D("publishing payload");
Json payload;
- request_obj->getPayloadFromDescription(&payload);
+ requestObj->getPayloadFromDescription(&payload);
char* message = new(std::nothrow) char[strlen(payload.str().c_str())+1];
ASSERT_ALLOC(message);
return CONV_ERROR_NONE;
}
-int conv::AppCommServiceProvider::registerRequest(Request* request_obj)
+int conv::AppCommServiceProvider::registerRequest(Request* requestObj)
{
IF_FAIL_RETURN_TAG(__activationState == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
_D("communcation/recv requested");
- AppCommServiceInfo *svc_info = reinterpret_cast<AppCommServiceInfo*>(request_obj->getServiceInfo());
+ AppCommServiceInfo *svcInfo = reinterpret_cast<AppCommServiceInfo*>(requestObj->getServiceInfo());
- switch (request_obj->getType()) {
+ switch (requestObj->getType()) {
case REQ_SUBSCRIBE:
- if ( svc_info->registered_request != NULL ) {
- delete svc_info->registered_request;
+ if ( svcInfo->registeredRequest != NULL ) {
+ delete svcInfo->registeredRequest;
}
- svc_info->registered_request = request_obj;
- request_obj->reply(CONV_ERROR_NONE);
+ svcInfo->registeredRequest = requestObj;
+ requestObj->reply(CONV_ERROR_NONE);
_D("subscribe requested");
break;
case REQ_UNSUBSCRIBE:
- svc_info->registered_request = NULL;
- request_obj->reply(CONV_ERROR_NONE);
- delete request_obj;
+ svcInfo->registeredRequest = NULL;
+ requestObj->reply(CONV_ERROR_NONE);
+ delete requestObj;
break;
default:
- request_obj->reply(CONV_ERROR_INVALID_OPERATION);
- delete request_obj;
+ requestObj->reply(CONV_ERROR_INVALID_OPERATION);
+ delete requestObj;
return CONV_ERROR_INVALID_OPERATION;
break;
}
return CONV_ERROR_NONE;
}
-int conv::AppCommServiceProvider::getServiceInfoForDiscovery(Json* json_obj)
+int conv::AppCommServiceProvider::getServiceInfoForDiscovery(Json* jsonObj)
{
IF_FAIL_RETURN_TAG(__activationState == 1, CONV_ERROR_NOT_SUPPORTED, _E, "service provider is not activated");
- json_obj->set(NULL, CONV_JSON_DISCOVERY_SERVICE_TYPE, CONV_SERVICE_APP_TO_APP_COMMUNICATION);
+ jsonObj->set(NULL, CONV_JSON_DISCOVERY_SERVICE_TYPE, CONV_SERVICE_APP_TO_APP_COMMUNICATION);
// set data for service handle
connection_h connection;
return CONV_ERROR_NOT_SUPPORTED;
} else {
char uri[200];
- Service local_service = Service::getLocal();
+ Service localService = Service::getLocal();
- if (local_service.getUri().empty()) {
+ if (localService.getUri().empty()) {
g_free(address);
return CONV_ERROR_NOT_SUPPORTED;
}
Json info;
info.set(NULL, CONV_JSON_SERVICE_DATA_URI, uri);
- info.set(NULL, CONV_JSON_SERVICE_DATA_VERSION, local_service.getVersion());
- info.set(NULL, CONV_JSON_SERVICE_DATA_TYPE, local_service.getType());
- info.set(NULL, CONV_JSON_SERVICE_DATA_ID, local_service.getId());
- info.set(NULL, CONV_JSON_SERVICE_DATA_NAME, local_service.getName());
+ info.set(NULL, CONV_JSON_SERVICE_DATA_VERSION, localService.getVersion());
+ info.set(NULL, CONV_JSON_SERVICE_DATA_TYPE, localService.getType());
+ info.set(NULL, CONV_JSON_SERVICE_DATA_ID, localService.getId());
+ info.set(NULL, CONV_JSON_SERVICE_DATA_NAME, localService.getName());
- json_obj->set(NULL, CONV_JSON_DISCOVERY_SERVICE_INFO, info);
+ jsonObj->set(NULL, CONV_JSON_DISCOVERY_SERVICE_INFO, info);
g_free(address);
}
int init();
int release();
- AppCommServiceInfo* get_svc_info(Request* request_obj);
- int startRequest(Request* request_obj);
- int stopRequest(Request* request_obj);
- int readRequest(Request* request_obj);
- int publishRequest(Request* request_obj);
- int registerRequest(Request* request_obj);
- int loadServiceInfo(Request* request_obj);
- int getServiceInfoForDiscovery(Json* json_obj);
+ AppCommServiceInfo* get_svc_info(Request* requestObj);
+ int startRequest(Request* requestObj);
+ int stopRequest(Request* requestObj);
+ int readRequest(Request* requestObj);
+ int publishRequest(Request* requestObj);
+ int registerRequest(Request* requestObj);
+ int loadServiceInfo(Request* requestObj);
+ int getServiceInfoForDiscovery(Json* jsonObj);
int handleVconfUpdate(keynode_t *node);
private:
- int sendReadResponse(Json payload, const char* read_type, conv_error_e error, Request* request_obj);
+ int sendReadResponse(Json payload, const char* read_type, conv_error_e error, Request* requestObj);
};
}
#endif /* __APP_COMMUNICATION_SERVICE_PROVIDER_H__ */
public:
~RemoteAppControlServiceInfo()
{
- if ( registered_request != NULL )
+ if ( registeredRequest != NULL )
{
- delete registered_request;
+ delete registeredRequest;
}
- if ( iotcon_info_obj.iotcon_resource_handle != NULL )
+ if ( iotconInfoObj.iotconResourceHandle != NULL )
{
- iotcon_remote_resource_destroy(iotcon_info_obj.iotcon_resource_handle);
+ iotcon_remote_resource_destroy(iotconInfoObj.iotconResourceHandle);
}
- if ( iotcon_info_obj.iotcon_representation_handle != NULL )
+ if ( iotconInfoObj.iotconRepresentationHandle != NULL )
{
- iotcon_representation_destroy(iotcon_info_obj.iotcon_representation_handle);
+ iotcon_representation_destroy(iotconInfoObj.iotconRepresentationHandle);
}
}
- std::string device_id;
- std::string device_name;
- std::string device_address;
- Request* registered_request;
- IotconCommunicationInfo iotcon_info_obj;
+ std::string deviceId;
+ std::string deviceName;
+ std::string deviceAddress;
+ Request* registeredRequest;
+ IotconCommunicationInfo iotconInfoObj;
};
}
struct response_cb_info_s {
int req_id;
- conv::Request* request_obj;
+ conv::Request* requestObj;
};
static int get_req_id()
return CONV_ERROR_NONE;
}
-int conv::RemoteAppControlServiceProvider::startRequest(Request* request_obj)
+int conv::RemoteAppControlServiceProvider::startRequest(Request* requestObj)
{
IF_FAIL_RETURN_TAG(__activationState == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
iotcon_resource_interfaces_h resource_ifaces = NULL;
iotcon_resource_types_h resource_types = NULL;
- RemoteAppControlServiceInfo *svc_info = reinterpret_cast<RemoteAppControlServiceInfo*>(request_obj->getServiceInfo());
+ RemoteAppControlServiceInfo *svcInfo = reinterpret_cast<RemoteAppControlServiceInfo*>(requestObj->getServiceInfo());
- if (svc_info->iotcon_info_obj.iotcon_resource_handle != NULL) {
+ if (svcInfo->iotconInfoObj.iotconResourceHandle != NULL) {
_D("already started");
- sendResponse(result, CONV_JSON_ON_START, CONV_ERROR_INVALID_OPERATION, svc_info->registered_request);
+ sendResponse(result, CONV_JSON_ON_START, CONV_ERROR_INVALID_OPERATION, svcInfo->registeredRequest);
return CONV_ERROR_INVALID_OPERATION;
}
error = iotcon_resource_types_create(&resource_types);
IF_FAIL_RETURN_TAG(error == IOTCON_ERROR_NONE, CONV_ERROR_INVALID_OPERATION, _E, "rt creation failed");
- iotcon_resource_types_add(resource_types, svc_info->iotcon_info_obj.resource_type.c_str());
+ iotcon_resource_types_add(resource_types, svcInfo->iotconInfoObj.resourceType.c_str());
error = iotcon_resource_interfaces_create(&resource_ifaces);
iotcon_resource_interfaces_add(resource_ifaces, IOTCON_INTERFACE_DEFAULT);
- error = iotcon_remote_resource_create(svc_info->iotcon_info_obj.address.c_str(), IOTCON_CONNECTIVITY_IPV4, svc_info->iotcon_info_obj.uri.c_str(), properties, resource_types, resource_ifaces,
- &(svc_info->iotcon_info_obj.iotcon_resource_handle));
+ error = iotcon_remote_resource_create(svcInfo->iotconInfoObj.address.c_str(), IOTCON_CONNECTIVITY_IPV4, svcInfo->iotconInfoObj.uri.c_str(), properties, resource_types, resource_ifaces,
+ &(svcInfo->iotconInfoObj.iotconResourceHandle));
- _D("remote resource created : %s, %s", svc_info->iotcon_info_obj.address.c_str(), svc_info->iotcon_info_obj.uri.c_str());
+ _D("remote resource created : %s, %s", svcInfo->iotconInfoObj.address.c_str(), svcInfo->iotconInfoObj.uri.c_str());
- IF_FAIL_RETURN_TAG(error == IOTCON_ERROR_NONE, CONV_ERROR_INVALID_OPERATION, _E, "remote resource creation failed %s, %s", svc_info->iotcon_info_obj.address.c_str(), svc_info->iotcon_info_obj.uri.c_str());
+ IF_FAIL_RETURN_TAG(error == IOTCON_ERROR_NONE, CONV_ERROR_INVALID_OPERATION, _E, "remote resource creation failed %s, %s", svcInfo->iotconInfoObj.address.c_str(), svcInfo->iotconInfoObj.uri.c_str());
iotcon_resource_types_destroy(resource_types);
iotcon_resource_interfaces_destroy(resource_ifaces);
- sendResponse(result, CONV_JSON_ON_START, CONV_ERROR_NONE, svc_info->registered_request);
+ sendResponse(result, CONV_JSON_ON_START, CONV_ERROR_NONE, svcInfo->registeredRequest);
return CONV_ERROR_NONE;
}
-int conv::RemoteAppControlServiceProvider::sendResponse(Json payload, const char* request_type, conv_error_e error, Request* request_obj)
+int conv::RemoteAppControlServiceProvider::sendResponse(Json payload, const char* request_type, conv_error_e error, Request* requestObj)
{
_D(RED("publishing_response"));
- IF_FAIL_RETURN_TAG(request_obj != NULL, CONV_ERROR_INVALID_OPERATION, _E, "listener_cb is not registered");
+ IF_FAIL_RETURN_TAG(requestObj != NULL, CONV_ERROR_INVALID_OPERATION, _E, "listener_cb is not registered");
Json result;
- Json description = request_obj->getDescription();
+ Json description = requestObj->getDescription();
payload.set(NULL, CONV_JSON_RESULT_TYPE, request_type);
result.set(NULL, CONV_JSON_DESCRIPTION, description);
result.set(NULL, CONV_JSON_PAYLOAD, payload);
- request_obj->publish(error, result);
+ requestObj->publish(error, result);
return CONV_ERROR_NONE;
}
-int conv::RemoteAppControlServiceProvider::stopRequest(Request* request_obj)
+int conv::RemoteAppControlServiceProvider::stopRequest(Request* requestObj)
{
IF_FAIL_RETURN_TAG(__activationState == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
_D("communcation/stop requested");
Json result;
- RemoteAppControlServiceInfo *svc_info = reinterpret_cast<RemoteAppControlServiceInfo*>(request_obj->getServiceInfo());
+ RemoteAppControlServiceInfo *svcInfo = reinterpret_cast<RemoteAppControlServiceInfo*>(requestObj->getServiceInfo());
- if (svc_info->iotcon_info_obj.iotcon_resource_handle == NULL) {
+ if (svcInfo->iotconInfoObj.iotconResourceHandle == NULL) {
_D("not even started");
- sendResponse(result, CONV_JSON_ON_STOP, CONV_ERROR_INVALID_OPERATION, svc_info->registered_request);
+ sendResponse(result, CONV_JSON_ON_STOP, CONV_ERROR_INVALID_OPERATION, svcInfo->registeredRequest);
return CONV_ERROR_INVALID_OPERATION;
}
- iotcon_remote_resource_destroy(svc_info->iotcon_info_obj.iotcon_resource_handle);
- svc_info->iotcon_info_obj.iotcon_resource_handle = NULL;
- sendResponse(result, CONV_JSON_ON_STOP, CONV_ERROR_NONE, svc_info->registered_request);
+ iotcon_remote_resource_destroy(svcInfo->iotconInfoObj.iotconResourceHandle);
+ svcInfo->iotconInfoObj.iotconResourceHandle = NULL;
+ sendResponse(result, CONV_JSON_ON_STOP, CONV_ERROR_NONE, svcInfo->registeredRequest);
return CONV_ERROR_NONE;
}
-int conv::RemoteAppControlServiceProvider::readRequest(Request* request_obj)
+int conv::RemoteAppControlServiceProvider::readRequest(Request* requestObj)
{
IF_FAIL_RETURN_TAG(__activationState == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
return CONV_ERROR_NONE;
}
-static void on_response(iotcon_remote_resource_h resource, iotcon_error_e err,
+static void __on_response(iotcon_remote_resource_h resource, iotcon_error_e err,
iotcon_request_type_e request_type, iotcon_response_h response, void *user_data)
{
int ret;
}
_D(RED("publishing_response"));
- if (cb_info.request_obj) {
+ if (cb_info.requestObj) {
conv::Json result;
conv::Json payload;
conv::Json description;
- if (cb_info.request_obj == NULL) {
+ if (cb_info.requestObj == NULL) {
_E("listener_cb is not registered");
} else {
payload.set(NULL, CONV_JSON_RESULT_TYPE, CONV_JSON_ON_PUBLISH);
payload.set(NULL, CONV_JSON_APP_CONTROL, appctl_char);
- result.set(NULL, CONV_JSON_DESCRIPTION, cb_info.request_obj->getDescription());
+ result.set(NULL, CONV_JSON_DESCRIPTION, cb_info.requestObj->getDescription());
result.set(NULL, CONV_JSON_PAYLOAD, payload);
- cb_info.request_obj->publish(CONV_ERROR_NONE, result);
+ cb_info.requestObj->publish(CONV_ERROR_NONE, result);
_D("response published");
}
}
response_cb_map.erase(find_iter);
}
-int conv::RemoteAppControlServiceProvider::publishRequest(Request* request_obj)
+int conv::RemoteAppControlServiceProvider::publishRequest(Request* requestObj)
{
IF_FAIL_RETURN_TAG(__activationState == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
- RemoteAppControlServiceInfo *svc_info = reinterpret_cast<RemoteAppControlServiceInfo*>(request_obj->getServiceInfo());
+ RemoteAppControlServiceInfo *svcInfo = reinterpret_cast<RemoteAppControlServiceInfo*>(requestObj->getServiceInfo());
int error;
- request_obj->setCommunicationInfo(&(svc_info->iotcon_info_obj));
+ requestObj->setCommunicationInfo(&(svcInfo->iotconInfoObj));
iotcon_representation_h representation;
iotcon_representation_create(&representation);
Json payload;
- request_obj->getPayloadFromDescription(&payload);
+ requestObj->getPayloadFromDescription(&payload);
string app_control;
int reply;
response_cb_info_s cb_info;
cb_info.req_id = req_id;
- cb_info.request_obj = svc_info->registered_request;
+ cb_info.requestObj = svcInfo->registeredRequest;
response_cb_map[req_id] = cb_info;
}
iotcon_representation_set_attributes(representation, attributes);
- svc_info->iotcon_info_obj.iotcon_representation_handle = representation;
+ svcInfo->iotconInfoObj.iotconRepresentationHandle = representation;
iotcon_attributes_destroy(attributes);
- error = iotcon_remote_resource_put(svc_info->iotcon_info_obj.iotcon_resource_handle, representation, NULL, on_response, NULL);
+ error = iotcon_remote_resource_put(svcInfo->iotconInfoObj.iotconResourceHandle, representation, NULL, __on_response, NULL);
IF_FAIL_RETURN_TAG(error == IOTCON_ERROR_NONE, CONV_ERROR_INVALID_OPERATION, _E, "iotcon_remote_resource_put failed");
if (reply != 1) {
Json result;
- sendResponse(result, CONV_JSON_ON_PUBLISH, CONV_ERROR_NONE, svc_info->registered_request);
+ sendResponse(result, CONV_JSON_ON_PUBLISH, CONV_ERROR_NONE, svcInfo->registeredRequest);
}
return CONV_ERROR_NONE;
}
-int conv::RemoteAppControlServiceProvider::registerRequest(Request* request_obj)
+int conv::RemoteAppControlServiceProvider::registerRequest(Request* requestObj)
{
IF_FAIL_RETURN_TAG(__activationState == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
_D("communcation/recv requested");
- RemoteAppControlServiceInfo *svc_info = reinterpret_cast<RemoteAppControlServiceInfo*>(request_obj->getServiceInfo());
+ RemoteAppControlServiceInfo *svcInfo = reinterpret_cast<RemoteAppControlServiceInfo*>(requestObj->getServiceInfo());
- switch (request_obj->getType()) {
+ switch (requestObj->getType()) {
case REQ_SUBSCRIBE:
- if (svc_info->registered_request != NULL) {
- delete svc_info->registered_request;
+ if (svcInfo->registeredRequest != NULL) {
+ delete svcInfo->registeredRequest;
}
- svc_info->registered_request = request_obj;
- request_obj->reply(CONV_ERROR_NONE);
+ svcInfo->registeredRequest = requestObj;
+ requestObj->reply(CONV_ERROR_NONE);
_D("subscribe requested");
break;
case REQ_UNSUBSCRIBE:
- svc_info->registered_request = NULL;
- request_obj->reply(CONV_ERROR_NONE);
- delete request_obj;
+ svcInfo->registeredRequest = NULL;
+ requestObj->reply(CONV_ERROR_NONE);
+ delete requestObj;
break;
default:
- request_obj->reply(CONV_ERROR_INVALID_OPERATION);
- delete request_obj;
+ requestObj->reply(CONV_ERROR_INVALID_OPERATION);
+ delete requestObj;
return CONV_ERROR_INVALID_OPERATION;
break;
}
}
-int conv::RemoteAppControlServiceProvider::loadServiceInfo(Request* request_obj)
+int conv::RemoteAppControlServiceProvider::loadServiceInfo(Request* requestObj)
{
IF_FAIL_RETURN_TAG(__activationState == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
string client;
- conv::ClientInfo* client_obj = NULL;
+ conv::ClientInfo* clientObj = NULL;
- client = request_obj->getSender();
+ client = requestObj->getSender();
_D("client id : %s", client.c_str());
- client_obj = conv::client_manager::getClient(client);
- IF_FAIL_RETURN_TAG(client_obj, CONV_ERROR_OUT_OF_MEMORY, _E, "client info alloc failed");
+ clientObj = conv::client_manager::getClient(client);
+ IF_FAIL_RETURN_TAG(clientObj, CONV_ERROR_OUT_OF_MEMORY, _E, "client info alloc failed");
- Json description = request_obj->getDescription();
+ Json description = requestObj->getDescription();
Json service;
Json device;
- string device_id;
- string device_name;
- string device_address;
+ string deviceId;
+ string deviceName;
+ string deviceAddress;
string uri;
description.get(NULL, CONV_JSON_SERVICE, &service);
service.get(NULL, CONV_SERVICE_ID, &uri);
- device.get(NULL, CONV_DEVICE_ID, &device_id);
- device.get(NULL, CONV_DEVICE_NAME, &device_name);
- device.get(NULL, CONV_JSON_DEVICE_ADDRESS, &device_address);
+ device.get(NULL, CONV_DEVICE_ID, &deviceId);
+ device.get(NULL, CONV_DEVICE_NAME, &deviceName);
+ device.get(NULL, CONV_JSON_DEVICE_ADDRESS, &deviceAddress);
- RemoteAppControlServiceInfo *svc_info = NULL;
- IServiceInfo* svc_info_base = client_obj->getServiceInfo(__type, device_id);
+ RemoteAppControlServiceInfo *svcInfo = NULL;
+ IServiceInfo* svcInfoBase = clientObj->getServiceInfo(__type, deviceId);
- if (svc_info_base != NULL) {
+ if (svcInfoBase != NULL) {
_D("service instance already exists");
- svc_info = reinterpret_cast<RemoteAppControlServiceInfo*>(svc_info_base);
+ svcInfo = reinterpret_cast<RemoteAppControlServiceInfo*>(svcInfoBase);
- if (svc_info == NULL)
+ if (svcInfo == NULL)
{
_D("casting failed");
return CONV_ERROR_INVALID_OPERATION;
}
} else {
_D("allocating new service instance");
- svc_info = new(std::nothrow) RemoteAppControlServiceInfo();
- IF_FAIL_RETURN_TAG(svc_info, CONV_ERROR_OUT_OF_MEMORY, _E, "svc_info alloc failed");
+ svcInfo = new(std::nothrow) RemoteAppControlServiceInfo();
+ IF_FAIL_RETURN_TAG(svcInfo, CONV_ERROR_OUT_OF_MEMORY, _E, "svcInfo alloc failed");
- svc_info->device_id = device_id;
- svc_info->device_name = device_name;
- svc_info->device_address = device_address;
+ svcInfo->deviceId = deviceId;
+ svcInfo->deviceName = deviceName;
+ svcInfo->deviceAddress = deviceAddress;
- svc_info->iotcon_info_obj.address = device_address;
- svc_info->iotcon_info_obj.uri = CONV_URI_REMOTE_APP_CONTROL;
- svc_info->iotcon_info_obj.resource_type = __resourceType;
+ svcInfo->iotconInfoObj.address = deviceAddress;
+ svcInfo->iotconInfoObj.uri = CONV_URI_REMOTE_APP_CONTROL;
+ svcInfo->iotconInfoObj.resourceType = __resourceType;
//save service info
- client_obj->addServiceInfo(__type, device_id, (IServiceInfo*)svc_info);
+ clientObj->addServiceInfo(__type, deviceId, (IServiceInfo*)svcInfo);
_D("remote app control service is created");
}
- request_obj->setServiceInfo(svc_info);
+ requestObj->setServiceInfo(svcInfo);
return CONV_ERROR_NONE;
}
-int conv::RemoteAppControlServiceProvider::getServiceInfoForDiscovery(Json* json_obj)
+int conv::RemoteAppControlServiceProvider::getServiceInfoForDiscovery(Json* jsonObj)
{
IF_FAIL_RETURN_TAG(__activationState == 1, CONV_ERROR_NOT_SUPPORTED, _E, "service provider is not activated");
- json_obj->set(NULL, CONV_JSON_DISCOVERY_SERVICE_TYPE, CONV_SERVICE_REMOTE_APP_CONTROL);
+ jsonObj->set(NULL, CONV_JSON_DISCOVERY_SERVICE_TYPE, CONV_SERVICE_REMOTE_APP_CONTROL);
// set data for service handle
Json info;
info.set(NULL, CONV_SERVICE_ID, __uri);
info.set(NULL, CONV_SERVICE_VERSION, "1.0");
- json_obj->set(NULL, CONV_JSON_DISCOVERY_SERVICE_INFO, info);
+ jsonObj->set(NULL, CONV_JSON_DISCOVERY_SERVICE_INFO, info);
return CONV_ERROR_NONE;
}
int init();
int release();
- int startRequest(Request* request_obj);
- int stopRequest(Request* request_obj);
- int readRequest(Request* request_obj);
- int publishRequest(Request* request_obj);
- int registerRequest(Request* request_obj);
- int loadServiceInfo(Request* request_obj);
- int getServiceInfoForDiscovery(Json* json_obj);
+ int startRequest(Request* requestObj);
+ int stopRequest(Request* requestObj);
+ int readRequest(Request* requestObj);
+ int publishRequest(Request* requestObj);
+ int registerRequest(Request* requestObj);
+ int loadServiceInfo(Request* requestObj);
+ int getServiceInfoForDiscovery(Json* jsonObj);
int handleVconfUpdate(keynode_t *node);
private:
iotcon_resource_h iotcon_resource;
- int sendResponse(Json payload, const char* request_type, conv_error_e error, Request* request_obj);
+ int sendResponse(Json payload, const char* request_type, conv_error_e error, Request* requestObj);
static void __iotcon_request_cb(iotcon_resource_h resource, iotcon_request_h request, void *user_data);
};