#include "ConnectionManager.h"
#include "access_control/Privilege.h"
+#include "Util.h"
static conv::ConnectionManager *_instance;
static conv::Request* cur_Req;
return CONV_ERROR_PERMISSION_DENIED;
}
+ if ( !conv::util::isApiActivated()) {
+ _E("API is not activated");
+ requestObj->reply(CONV_ERROR_INVALID_OPERATION);
+ delete requestObj;
+ return CONV_ERROR_INVALID_OPERATION;
+ }
+
switch (requestObj->getType()) {
case REQ_SUBSCRIBE:
{
return CONV_ERROR_PERMISSION_DENIED;
}
+ if ( !conv::util::isApiActivated()) {
+ _E("API is not activated");
+ requestObj->reply(CONV_ERROR_INVALID_OPERATION);
+ delete requestObj;
+ return CONV_ERROR_INVALID_OPERATION;
+ }
+
discoveredResults.clear();
for (DiscoveryProviderList::iterator it = __providerList.begin(); it != __providerList.end(); ++it)
registerProvider(new(std::nothrow) conv::AppCommServiceProvider());
registerProvider(new(std::nothrow) conv::RemoteAppControlServiceProvider());
- int error = vconf_get_int(VCONFKEY_SETAPPL_D2D_CONVERGENCE, &__activationState);
-
- if ( error < 0 ) {
- _E("vconf error (%d)", error);
- }
-
- if ( __activationState == 1 ) {
+ if (conv::util::isServiceActivated()) {
+ __activationState = 1;
registerDiscoveryInfo();
} else {
+ __activationState = 0;
unregisterDiscoveryInfo();
}
- error = vconf_notify_key_changed(VCONFKEY_SETAPPL_D2D_CONVERGENCE, vconf_update_cb, this);
+ int error = vconf_notify_key_changed(VCONFKEY_SETAPPL_D2D_CONVERGENCE_SERVICE, vconf_update_cb, this);
IF_FAIL_RETURN_TAG(error >= 0, CONV_ERROR_INVALID_OPERATION, _E, "vconf error (%d)", error);
delete requestObj;
return CONV_ERROR_PERMISSION_DENIED;
}
+ if ( !conv::util::isApiActivated()) {
+ _E("API is not activated");
+ requestObj->reply(CONV_ERROR_INVALID_OPERATION);
+ delete requestObj;
+ return CONV_ERROR_INVALID_OPERATION;
+ }
+
error = (*it)->startRequest(requestObj);
} else if (!strcmp(requestObj->getSubject(), CONV_SUBJECT_COMMUNICATION_STOP)) {
if ( !conv::privilege_manager::isAllowed(requestObj->getCreds(), CONV_PRIVILEGE_INTERNET) ||
delete requestObj;
return CONV_ERROR_PERMISSION_DENIED;
}
+ if ( !conv::util::isApiActivated()) {
+ _E("API is not activated");
+ requestObj->reply(CONV_ERROR_INVALID_OPERATION);
+ delete requestObj;
+ return CONV_ERROR_INVALID_OPERATION;
+ }
+
error = (*it)->stopRequest(requestObj);
} else if (!strcmp(requestObj->getSubject(), CONV_SUBJECT_COMMUNICATION_GET)) {
if ( !conv::privilege_manager::isAllowed(requestObj->getCreds(), CONV_PRIVILEGE_INTERNET) ||
delete requestObj;
return CONV_ERROR_PERMISSION_DENIED;
}
+ if ( !conv::util::isApiActivated()) {
+ _E("API is not activated");
+ requestObj->reply(CONV_ERROR_INVALID_OPERATION);
+ delete requestObj;
+ return CONV_ERROR_INVALID_OPERATION;
+ }
+
error = (*it)->readRequest(requestObj);
} else if (!strcmp(requestObj->getSubject(), CONV_SUBJECT_COMMUNICATION_SET)) {
if ( !conv::privilege_manager::isAllowed(requestObj->getCreds(), CONV_PRIVILEGE_INTERNET) ||
delete requestObj;
return CONV_ERROR_PERMISSION_DENIED;
}
+ if ( !conv::util::isApiActivated()) {
+ _E("API is not activated");
+ requestObj->reply(CONV_ERROR_INVALID_OPERATION);
+ delete requestObj;
+ return CONV_ERROR_INVALID_OPERATION;
+ }
+
error = (*it)->publishRequest(requestObj);
} else if (!strcmp(requestObj->getSubject(), CONV_SUBJECT_COMMUNICATION_RECV)) {
return (*it)->registerRequest(requestObj);
return __deviceId;
}
-bool conv::util::isServiceActivated(int serviceValue)
+bool conv::util::isServiceActivated()
{
int currentState;
int error = vconf_get_int(VCONFKEY_SETAPPL_D2D_CONVERGENCE_SERVICE, ¤tState);
return false;
}
- if ((serviceValue & currentState) > 0) {
+ if (currentState > 0) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+bool conv::util::isApiActivated()
+{
+ int currentState;
+ int error = vconf_get_int(VCONFKEY_SETAPPL_D2D_CONVERGENCE, ¤tState);
+
+ if (error != 0) {
+ _D("vconf_get_int failed %d", error);
+ return false;
+ }
+
+ if (currentState > 0) {
return true;
} else {
return false;
myarp.arp_dev[sizeof(myarp.arp_dev) - 1] = 0;
if(ioctl(sockfd, SIOCGARP, &myarp) != -1) {
unsigned char *ptr = (unsigned char*)(&myarp.arp_ha.sa_data[0]);
- snprintf(buf, 18,"%02X-%02X-%02X-%02X-%02X-%02X", *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4), *(ptr+5));
+ snprintf(buf, 18, "%02X-%02X-%02X-%02X-%02X-%02X", *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4), *(ptr+5));
_D("%s MAC = %s\n", myarp.arp_dev, buf);
if_freenameindex(head);
if(sockfd >= 0)
close(sockfd);
return true;
} else {
- _D( "Device:%s error ioctl %d", myarp.arp_dev, errno);
+ _D("Device:%s error ioctl %d", myarp.arp_dev, errno);
}
interface++;
}
std::string getDeviceName();
std::string getP2pMacAddress();
std::string getDeviceId();
- bool isServiceActivated(int serviceValue);
+ bool isServiceActivated();
+ bool isApiActivated();
typedef void (*timer_function)(void *data);
int miscStartTimer(timer_function function, unsigned int interval, void *data);
__type = CONV_SERVICE_TYPE_SMARTVIEW_APP_COMMUNICATION;
__resourceType = CONV_RESOURCE_TYPE_SMARTVIEW_APP_COMMUNICATION;
__uri = CONV_URI_SMARTVIEW_APP_COMMUNICATION;
- if (conv::util::isServiceActivated(CONV_INTERNAL_SERVICE_APP_TO_APP_COMMUNICATION))
+
+ if (conv::util::isServiceActivated()) {
__activationState = 1;
- else
+ } else {
__activationState = 0;
+ }
vconf_notify_key_changed(VCONFKEY_SETAPPL_D2D_CONVERGENCE_SERVICE, vconf_update_cb, this);
}
{
int current_state = vconf_keynode_get_int(node);
- if ((CONV_INTERNAL_SERVICE_APP_TO_APP_COMMUNICATION & current_state) > 0) {
+ if (current_state > 0) {
__activationState = 1;
init();
} else {
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* clientObj = NULL;
int isLocal = 0;
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 *svcInfo = reinterpret_cast<AppCommServiceInfo*>(requestObj->getServiceInfo());
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 *svcInfo = reinterpret_cast<AppCommServiceInfo*>(requestObj->getServiceInfo());
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 *svcInfo = reinterpret_cast<AppCommServiceInfo*>(requestObj->getServiceInfo());
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 *svcInfo = reinterpret_cast<AppCommServiceInfo*>(requestObj->getServiceInfo());
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 *svcInfo = reinterpret_cast<AppCommServiceInfo*>(requestObj->getServiceInfo());
int conv::AppCommServiceProvider::getServiceInfoForDiscovery(Json* jsonObj)
{
- IF_FAIL_RETURN_TAG(__activationState == 1, CONV_ERROR_NOT_SUPPORTED, _E, "service provider is not activated");
-
jsonObj->set(NULL, CONV_JSON_DISCOVERY_SERVICE_TYPE, CONV_SERVICE_APP_TO_APP_COMMUNICATION);
// set data for service handle
__resourceType = CONV_RESOURCE_TYPE_REMOTE_APP_CONTROL;
__uri = CONV_URI_REMOTE_APP_CONTROL;
iotcon_resource = NULL;
- if (conv::util::isServiceActivated(CONV_INTERNAL_SERVICE_REMOTE_APP_CONTROL))
+
+ if (conv::util::isServiceActivated()) {
__activationState = 1;
- else
+ } else {
__activationState = 0;
+ }
vconf_notify_key_changed(VCONFKEY_SETAPPL_D2D_CONVERGENCE_SERVICE, vconf_update_cb, this);
}
{
int current_state = vconf_keynode_get_int(node);
- if ((CONV_INTERNAL_SERVICE_REMOTE_APP_CONTROL & current_state) > 0) {
+ if (current_state > 0) {
__activationState = 1;
init();
} else {
int error = iotcon_resource_destroy(iotcon_resource);
IF_FAIL_RETURN_TAG(error == IOTCON_ERROR_NONE, CONV_ERROR_INVALID_OPERATION, _E, "resource destroy failed");
iotcon_resource = NULL;
+ _D("RemoteAppControlServiceProvider release done");
}
return CONV_ERROR_NONE;
int conv::RemoteAppControlServiceProvider::startRequest(Request* requestObj)
{
- IF_FAIL_RETURN_TAG(__activationState == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
-
_D("communcation/start requested");
int error;
Json result;
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;
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;
}
int conv::RemoteAppControlServiceProvider::publishRequest(Request* requestObj)
{
- IF_FAIL_RETURN_TAG(__activationState == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
-
RemoteAppControlServiceInfo *svcInfo = reinterpret_cast<RemoteAppControlServiceInfo*>(requestObj->getServiceInfo());
int error;
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 *svcInfo = reinterpret_cast<RemoteAppControlServiceInfo*>(requestObj->getServiceInfo());
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* clientObj = NULL;
int conv::RemoteAppControlServiceProvider::getServiceInfoForDiscovery(Json* jsonObj)
{
- IF_FAIL_RETURN_TAG(__activationState == 1, CONV_ERROR_NOT_SUPPORTED, _E, "service provider is not activated");
-
jsonObj->set(NULL, CONV_JSON_DISCOVERY_SERVICE_TYPE, CONV_SERVICE_REMOTE_APP_CONTROL);
// set data for service handle