#define HANDLE_GERROR(Err) \
do { if ((Err)) { _E("GError: %s", Err->message); g_error_free(Err); Err = NULL; } } while (0)
-
#endif
* limitations under the License.
*/
-#ifndef __CONV_COMMON_H__
-#define __CONV_COMMON_H__
+#ifndef __CONV_TYPES_H__
+#define __CONV_TYPES_H__
#include <stdlib.h>
#include <tzplatform_config.h>
-#include "log.h"
+#include "Log.h"
#include "d2d_conv_manager.h"
#include "d2d_conv_internal.h"
* limitations under the License.
*/
-#include "client_mgr_impl.h"
+#include "ClientManager.h"
-static conv::client_manager_impl *_instance;
+static conv::ClientManager *_instance;
using namespace std;
-conv::client_manager_impl::client_manager_impl()
+conv::ClientManager::ClientManager()
{
}
-conv::client_manager_impl::~client_manager_impl()
+conv::ClientManager::~ClientManager()
{
}
-int conv::client_manager_impl::init()
+int conv::ClientManager::init()
{
return CONV_ERROR_NONE;
}
-int conv::client_manager_impl::release()
+int conv::ClientManager::release()
{
- for (client_list_t::iterator it = client_list.begin(); it != client_list.end(); ++it) {
+ for (ClientList::iterator it = clientList.begin(); it != clientList.end(); ++it) {
delete *it;
}
- client_list.clear();
+ clientList.clear();
return CONV_ERROR_NONE;
}
-void conv::client_manager::set_instance(conv::client_manager_impl* mgr)
+void conv::client_manager::setInstance(conv::ClientManager* mgr)
{
_instance = mgr;
}
-int conv::client_manager_impl::handle_request(request* request_obj)
+int conv::ClientManager::handleRequest(request* requestObj)
{
_D("handle_request called");
return CONV_ERROR_NONE;
}
-conv::client* conv::client_manager::get_client(std::string client_id)
+conv::client* conv::client_manager::getClient(std::string clientId)
{
IF_FAIL_RETURN_TAG(_instance, NULL, _E, "Not initialized");
- return _instance->get_client(client_id);
+ return _instance->getClient(clientId);
}
-conv::client* conv::client_manager_impl::get_client(std::string client_id)
+conv::client* conv::ClientManager::getClient(std::string clientId)
{
- for (client_list_t::iterator it = client_list.begin(); it != client_list.end(); ++it) {
- if ( !(*it)->get_id().compare(client_id) )
+ for (ClientList::iterator it = clientList.begin(); it != clientList.end(); ++it) {
+ if ( !(*it)->get_id().compare(clientId) )
{
// already exists
_D("client exists");
}
_D("new client obj created");
- client* client_obj = new(std::nothrow) conv::client(client_id, NULL);
+ client* clientObj = new(std::nothrow) conv::client(clientId, NULL);
- client_list.push_back(client_obj);
- return client_obj;
+ clientList.push_back(clientObj);
+ return clientObj;
}
#include <glib.h>
#include <vector>
#include <string>
-#include "manager_iface.h"
+#include "IManager.h"
#include "client.h"
namespace conv {
- class client_manager_impl : public manager_iface {
- typedef std::vector<client*> client_list_t;
+ class ClientManager : public IManager {
+ typedef std::vector<client*> ClientList;
public:
- client_manager_impl();
- ~client_manager_impl();
+ ClientManager();
+ ~ClientManager();
int init();
int release();
- int handle_request(request* request_obj);
- conv::client* get_client(std::string client_id);
+ int handleRequest(request* requestObj);
+ conv::client* getClient(std::string clientId);
private:
- client_list_t client_list;
+ ClientList clientList;
};
namespace client_manager {
- void set_instance(client_manager_impl* mgr);
- conv::client* get_client(std::string client_id);
+ void setInstance(ClientManager* mgr);
+ conv::client* getClient(std::string clientId);
}
}
* limitations under the License.
*/
-#include "connection_mgr_impl.h"
-#include "access_control/privilege.h"
+#include "ConnectionManager.h"
+#include "access_control/Privilege.h"
-static conv::connection_manager_impl *_instance;
+static conv::ConnectionManager *_instance;
static conv::request* cur_Req;
using namespace std;
-conv::connection_manager_impl::connection_manager_impl()
+conv::ConnectionManager::ConnectionManager()
{
}
-conv::connection_manager_impl::~connection_manager_impl()
+conv::ConnectionManager::~ConnectionManager()
{
}
-int conv::connection_manager_impl::init()
+int conv::ConnectionManager::init()
{
return CONV_ERROR_NONE;
}
-int conv::connection_manager_impl::release()
+int conv::ConnectionManager::release()
{
return CONV_ERROR_NONE;
}
-void conv::connection_manager::set_instance(conv::connection_manager_impl* mgr)
+void conv::connection_manager::setInstance(conv::ConnectionManager* mgr)
{
_instance = mgr;
}
-int conv::connection_manager_impl::handle_request(request* request_obj)
+int conv::ConnectionManager::handleRequest(request* requestObj)
{
_D("handle_request called");
int error = CONV_ERROR_INVALID_OPERATION;
- if ( !conv::privilege_manager::is_allowed(request_obj->get_creds(), CONV_PRIVILEGE_INTERNET) ||
- !conv::privilege_manager::is_allowed(request_obj->get_creds(), CONV_PRIVILEGE_BLUETOOTH) ) {
+ if ( !conv::privilege_manager::isAllowed(requestObj->get_creds(), CONV_PRIVILEGE_INTERNET) ||
+ !conv::privilege_manager::isAllowed(requestObj->get_creds(), CONV_PRIVILEGE_BLUETOOTH) ) {
_E("permission denied");
- request_obj->reply(CONV_ERROR_PERMISSION_DENIED);
- delete request_obj;
+ requestObj->reply(CONV_ERROR_PERMISSION_DENIED);
+ delete requestObj;
return CONV_ERROR_PERMISSION_DENIED;
}
- switch (request_obj->get_type()) {
+ switch (requestObj->get_type()) {
case REQ_SUBSCRIBE:
{
- cur_Req = request_obj;
+ cur_Req = requestObj;
error = CONV_ERROR_NONE;
}
break;
{
json cb_json, jservice, description, tmp_payload;
string did;
- description = request_obj->get_description();
+ description = requestObj->get_description();
description.get(NULL, CONV_JSON_SERVICE, &jservice);
jservice.get(CONV_JSON_SERVICE_DATA_PATH, CONV_JSON_SERVICE_DATA_ID, &did);
// TODO:
//make callback data and invoke
- cb_json.set(NULL, CONV_JSON_DESCRIPTION, request_obj->get_description());
+ cb_json.set(NULL, CONV_JSON_DESCRIPTION, requestObj->get_description());
cb_json.set(NULL, CONV_JSON_PAYLOAD, tmp_payload);
if (cur_Req != NULL) {
cur_Req->publish(CONV_ERROR_NONE, cb_json);
break;
}
- request_obj->reply(error);
- delete request_obj;
+ requestObj->reply(error);
+ delete requestObj;
return CONV_ERROR_NONE;
}
-int conv::connection_manager::handle_request(request* request_obj)
+int conv::connection_manager::handleRequest(request* requestObj)
{
IF_FAIL_RETURN_TAG(_instance, CONV_ERROR_INVALID_PARAMETER, _E, "Not initialized");
- _instance->handle_request(request_obj);
+ _instance->handleRequest(requestObj);
return CONV_ERROR_NONE;
}
#include <iotcon.h>
#include <glib.h>
#include <vector>
-#include "manager_iface.h"
+#include "IManager.h"
#include "request.h"
namespace conv {
- class connection_manager_impl : public manager_iface {
+ class ConnectionManager : public IManager {
public:
- connection_manager_impl();
- ~connection_manager_impl();
+ ConnectionManager();
+ ~ConnectionManager();
int init();
int release();
- int handle_request(request* request_obj);
+ int handleRequest(request* requestObj);
};
namespace connection_manager {
- void set_instance(connection_manager_impl* mgr);
- int handle_request(request* request_obj);
+ void setInstance(ConnectionManager* mgr);
+ int handleRequest(request* requestObj);
}
}
#include <gio/gio.h>
#include <app_manager.h>
-#include "server.h"
-#include "access_control/peer_creds.h"
-#include "dbus_server_impl.h"
+#include "Server.h"
+#include "access_control/PeerCreds.h"
+#include "DbusServer.h"
#define DEFAULT_APP_ID "Default"
-static bool conn_acquired = false;
-static bool name_acquired = false;
-static conv::dbus_server_impl *_instance = NULL;
-static GDBusConnection *dbus_connection = NULL;
-static guint dbus_owner_id = 0;
-static GDBusNodeInfo *dbus_node_info = NULL;
+static bool connAcquired = false;
+static bool nameAcquired = false;
+static conv::DbusServer *__instance = NULL;
+static GDBusConnection *dbusConnection = NULL;
+static guint dbusOwnerId = 0;
+static GDBusNodeInfo *dbusNodeInfo = NULL;
-static const gchar introspection_xml[] =
+static const gchar introspectionXml[] =
"<node>"
" <interface name='" DBUS_IFACE "'>"
" <method name='" METHOD_REQUEST "'>"
" </interface>"
"</node>";
-static const char* req_type_to_str(int req_type)
+static const char* __req_type_to_str(int reqType)
{
- switch (req_type) {
+ switch (reqType) {
case REQ_SUBSCRIBE:
return "Subscribe";
case REQ_UNSUBSCRIBE:
}
}
-static void handle_request(GDBusConnection* conn, const char *sender, GVariant *param, GDBusMethodInvocation *invocation)
+static void __handle_request(GDBusConnection* conn, const char *sender, GVariant *param, GDBusMethodInvocation *invocation)
{
gint req_type = 0;
const gchar *cookie = NULL;
IF_FAIL_VOID_TAG(req_type > 0 && req_id > 0 && cookie && subject && input, _E, "Invalid request");
_SD("Cookie: %s", cookie);
- _I("[%s] ReqId: %d, Subject: %s", req_type_to_str(req_type), req_id, subject);
+ _I("[%s] ReqId: %d, Subject: %s", __req_type_to_str(req_type), req_id, subject);
_SI("Input: %s", input);
- conv::credentials *creds = NULL;
+ conv::Credentials *creds = NULL;
if (!conv::peer_creds::get(conn, sender, &creds)) {
_E("Peer credentialing failed");
return;
}
- conv::request *recv_request = NULL;
+ conv::request *recvRequest = NULL;
try{
- recv_request = new conv::request(req_type, DEFAULT_APP_ID, req_id, subject, input, sender, creds, invocation);
+ recvRequest = new conv::request(req_type, DEFAULT_APP_ID, req_id, subject, input, sender, creds, invocation);
} catch (std::bad_alloc& ba) {
_E("Memory Allocation Failed..");
g_dbus_method_invocation_return_value(invocation, g_variant_new("(iss)", CONV_ERROR_INVALID_OPERATION, EMPTY_JSON_OBJECT, EMPTY_JSON_OBJECT));
return;
}
- if (!recv_request) {
+ if (!recvRequest) {
_E("Memory allocation failed");
g_dbus_method_invocation_return_value(invocation, g_variant_new("(iss)", CONV_ERROR_INVALID_OPERATION, EMPTY_JSON_OBJECT, EMPTY_JSON_OBJECT));
return;
}
- conv::send_request(recv_request);
+ conv::sendRequest(recvRequest);
}
-static void handle_method_call(GDBusConnection *conn, const gchar *sender,
+static void __handle_method_call(GDBusConnection *conn, const gchar *sender,
const gchar *obj_path, const gchar *iface, const gchar *method_name,
GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
{
IF_FAIL_VOID_TAG(STR_EQ(iface, DBUS_IFACE), _W, "Invalid interface: %s", obj_path);
if (STR_EQ(method_name, METHOD_REQUEST))
- handle_request(conn, sender, param, invocation);
+ __handle_request(conn, sender, param, invocation);
else
_W("Invalid method: %s", method_name);
- _D("end of handle_method_call");
+ _D("end of __handle_method_call");
}
-static void on_bus_acquired(GDBusConnection *conn, const gchar *name, gpointer user_data)
+static void __on_bus_acquired(GDBusConnection *conn, const gchar *name, gpointer user_data)
{
GError *error = NULL;
GDBusInterfaceVTable vtable;
- vtable.method_call = handle_method_call;
+ vtable.method_call = __handle_method_call;
vtable.get_property = NULL;
vtable.set_property = NULL;
guint reg_id = g_dbus_connection_register_object(conn, DBUS_PATH,
- dbus_node_info->interfaces[0], &vtable, NULL, NULL, &error);
+ dbusNodeInfo->interfaces[0], &vtable, NULL, NULL, &error);
if (reg_id <= 0) {
_E("Failed to acquire dbus gerror(%s)", error->message);
raise(SIGTERM);
}
- conn_acquired = true;
- dbus_connection = conn;
+ connAcquired = true;
+ dbusConnection = conn;
_I("Dbus connection acquired");
}
-static void on_name_acquired(GDBusConnection *conn, const gchar *name, gpointer user_data)
+static void __on_name_acquired(GDBusConnection *conn, const gchar *name, gpointer user_data)
{
- name_acquired = true;
+ nameAcquired = true;
_SI("Dbus name acquired: %s", name);
}
-static void on_name_lost(GDBusConnection *conn, const gchar *name, gpointer user_data)
+static void __on_name_lost(GDBusConnection *conn, const gchar *name, gpointer user_data)
{
_E("Dbus name lost");
raise(SIGTERM);
}
-conv::dbus_server_impl::dbus_server_impl()
+conv::DbusServer::DbusServer()
{
}
-conv::dbus_server_impl::~dbus_server_impl()
+conv::DbusServer::~DbusServer()
{
release();
}
-bool conv::dbus_server_impl::init()
+bool conv::DbusServer::init()
{
GError *error = NULL;
- _I("init with dbus_node_info : %x", dbus_node_info);
+ _I("init with dbusNodeInfo : %x", dbusNodeInfo);
- dbus_node_info = g_dbus_node_info_new_for_xml(introspection_xml, &error);
- if (dbus_node_info == NULL) {
- _E("g_dbus_node_info_new_for_xml() Fail(%s)", error->message);
+ dbusNodeInfo = g_dbus_node_info_new_for_xml(introspectionXml, &error);
+ if (dbusNodeInfo == NULL) {
+ _E("g_dbusNodeInfo_new_for_xml() Fail(%s)", error->message);
g_error_free(error);
return false;
}
- dbus_owner_id = g_bus_own_name(G_BUS_TYPE_SESSION, DBUS_DEST, G_BUS_NAME_OWNER_FLAGS_NONE,
- on_bus_acquired, on_name_acquired, on_name_lost, NULL, NULL);
+ dbusOwnerId = g_bus_own_name(G_BUS_TYPE_SESSION, DBUS_DEST, G_BUS_NAME_OWNER_FLAGS_NONE,
+ __on_bus_acquired, __on_name_acquired, __on_name_lost, NULL, NULL);
- if (dbus_owner_id == 0) {
- _E("dbus_owner_id Fail()");
+ if (dbusOwnerId == 0) {
+ _E("dbusOwnerId Fail()");
return false;
}
- _instance = this;
+ __instance = this;
return true;
}
-void conv::dbus_server_impl::release()
+void conv::DbusServer::release()
{
- if (dbus_connection)
- g_dbus_connection_flush_sync(dbus_connection, NULL, NULL);
+ if (dbusConnection)
+ g_dbus_connection_flush_sync(dbusConnection, NULL, NULL);
- if (dbus_owner_id > 0) {
- g_bus_unown_name(dbus_owner_id);
- dbus_owner_id = 0;
+ if (dbusOwnerId > 0) {
+ g_bus_unown_name(dbusOwnerId);
+ dbusOwnerId = 0;
}
- if (dbus_connection) {
- g_dbus_connection_close_sync(dbus_connection, NULL, NULL);
- g_object_unref(dbus_connection);
- dbus_connection = NULL;
+ if (dbusConnection) {
+ g_dbus_connection_close_sync(dbusConnection, NULL, NULL);
+ g_object_unref(dbusConnection);
+ dbusConnection = NULL;
}
- if (dbus_node_info) {
- g_dbus_node_info_unref(dbus_node_info);
- dbus_node_info = NULL;
+ if (dbusNodeInfo) {
+ g_dbus_node_info_unref(dbusNodeInfo);
+ dbusNodeInfo = NULL;
}
}
-void conv::dbus_server_impl::publish(const char* dest, int req_id, const char* subject, int error, const char* data)
+void conv::DbusServer::publish(const char* dest, int reqId, const char* subject, int error, const char* data)
{
IF_FAIL_VOID_TAG(dest && subject && data, _E, "Parameter null");
- _SI("Publish: %s, %d, %s, %#x, %s", dest, req_id, subject, error, data);
+ _SI("Publish: %s, %d, %s, %#x, %s", dest, reqId, subject, error, data);
- GVariant *param = g_variant_new("(isis)", req_id, subject, error, data);
+ GVariant *param = g_variant_new("(isis)", reqId, subject, error, data);
IF_FAIL_VOID_TAG(param, _E, "Memory allocation failed");
- _D("before g_dbus_connection_call..");
+ _D("before g_dbusConnection_call..");
GError *err = NULL;
- g_dbus_connection_call(dbus_connection, dest, DBUS_PATH, DBUS_IFACE,
+ g_dbus_connection_call(dbusConnection, dest, DBUS_PATH, DBUS_IFACE,
METHOD_RESPOND, param, NULL, G_DBUS_CALL_FLAGS_NONE, DBUS_TIMEOUT, NULL, NULL, &err);
if (err != NULL) {
- _D("dbus_connection_call Error msg : %s", err->message);
+ _D("dbusConnection_call Error msg : %s", err->message);
HANDLE_GERROR(err);
}
}
-static void handle_call_result(GObject *source, GAsyncResult *res, gpointer user_data)
+static void __handle_call_result(GObject *source, GAsyncResult *res, gpointer user_data)
{
_I("Call %u done", *static_cast<unsigned int*>(user_data));
HANDLE_GERROR(error);
}
-void conv::dbus_server_impl::call(const char *dest, const char *obj, const char *iface, const char *method, GVariant *param)
+void conv::DbusServer::call(const char *dest, const char *obj, const char *iface, const char *method, GVariant *param)
{
IF_FAIL_VOID_TAG(dest && obj && iface && method, _E, "Parameter null");
- static unsigned int call_count = 0;
- ++call_count;
+ static unsigned int callCount = 0;
+ ++callCount;
- _SI("Call %u: %s, %s, %s.%s", call_count, dest, obj, iface, method);
+ _SI("Call %u: %s, %s, %s.%s", callCount, dest, obj, iface, method);
- g_dbus_connection_call(dbus_connection, dest, obj, iface, method, param, NULL,
- G_DBUS_CALL_FLAGS_NONE, DBUS_TIMEOUT, NULL, handle_call_result, &call_count);
+ g_dbus_connection_call(dbusConnection, dest, obj, iface, method, param, NULL,
+ G_DBUS_CALL_FLAGS_NONE, DBUS_TIMEOUT, NULL, __handle_call_result, &callCount);
}
-void conv::dbus_server::publish(const char* dest, int req_id, const char* subject, int error, const char* data)
+void conv::dbus_server::publish(const char* dest, int reqId, const char* subject, int error, const char* data)
{
- _instance->publish(dest, req_id, subject, error, data);
+ __instance->publish(dest, reqId, subject, error, data);
}
void conv::dbus_server::call(const char *dest, const char *obj, const char *iface, const char *method, GVariant *param)
{
- _instance->call(dest, obj, iface, method, param);
+ __instance->call(dest, obj, iface, method, param);
}
-void conv::dbus_server::set_instance(conv::dbus_server_iface* svr)
+void conv::dbus_server::setInstance(conv::IDbusServer* svr)
{
- _instance = static_cast<dbus_server_impl*>(svr);
+ __instance = static_cast<DbusServer*>(svr);
}
#include <sys/types.h>
#include <string>
-#include "dbus_server_iface.h"
+#include "IDbusServer.h"
namespace conv {
- class dbus_server_impl : public dbus_server_iface {
+ class DbusServer : public IDbusServer {
public:
- dbus_server_impl();
- ~dbus_server_impl();
+ DbusServer();
+ ~DbusServer();
bool init();
void release();
namespace dbus_server {
void publish(const char *dest, int req_id, const char *subject, int error, const char *data);
void call(const char *dest, const char *obj, const char *iface, const char *method, GVariant *param);
- void set_instance(dbus_server_iface* svr);
+ void setInstance(IDbusServer* svr);
}
} /* namespace conv */
* limitations under the License.
*/
-#include "discovery_mgr_impl.h"
-#include "discovery_provider/smartview_discovery_provider.h"
-#include "discovery_provider/wifi_direct_discovery_provider.h"
-#include "discovery_provider/iotcon_discovery_provider.h"
-#include "access_control/privilege.h"
-
-#include "common.h"
-#include "util.h"
+#include "DiscoveryManager.h"
+#include "discovery_provider/SmartviewDiscoveryProvider.h"
+#include "discovery_provider/WifiDirectDiscoveryProvider.h"
+#include "discovery_provider/IotconDiscoveryProvider.h"
+#include "access_control/Privilege.h"
+
+#include "Types.h"
+#include "Util.h"
#include <algorithm>
#include <functional>
using namespace std;
-static conv::discovery_manager_impl *_instance = NULL;
-typedef std::map<std::string, conv::device_iface*> discovered_ones_map_t;
+static conv::DiscoveryManager *_instance = NULL;
+typedef std::map<std::string, conv::IDevice*> discovered_ones_map_t;
static discovered_ones_map_t discovered_results;
-conv::discovery_manager_impl::discovery_manager_impl()
+conv::DiscoveryManager::DiscoveryManager()
{
count_discovery_request = 0;
}
-conv::discovery_manager_impl::~discovery_manager_impl()
+conv::DiscoveryManager::~DiscoveryManager()
{
}
-int conv::discovery_manager_impl::init()
+int conv::DiscoveryManager::init()
{
_D("Discovery_Manager Init!!..");
- register_provider(new(std::nothrow) conv::smartview_discovery_provider());
- register_provider(new(std::nothrow) conv::wifi_direct_discovery_provider());
- register_provider(new(std::nothrow) conv::iotcon_discovery_provider());
+ register_provider(new(std::nothrow) conv::SmartviewDiscoveryProvider());
+ register_provider(new(std::nothrow) conv::WifiDirectDiscoveryProvider());
+ register_provider(new(std::nothrow) conv::IotconDiscoveryProvider());
request_map.clear();
request_timer_map.clear();
return CONV_ERROR_NONE;
}
-int conv::discovery_manager_impl::release()
+int conv::DiscoveryManager::release()
{
for (discovery_provider_list_t::iterator it = provider_list.begin(); it != provider_list.end(); ++it)
(*it)->stop();
return CONV_ERROR_NONE;
}
-void conv::discovery_manager::set_instance(conv::discovery_manager_impl* mgr)
+void conv::discovery_manager::set_instance(conv::DiscoveryManager* mgr)
{
_instance = mgr;
}
-int conv::discovery_manager_impl::notify_time_up(std::string client)
+int conv::DiscoveryManager::notify_time_up(std::string client)
{
// 1. When no client is using discovery, it should be stopped
_D("notify_time_up.. with current discovery count :%d", count_discovery_request);
if (timer_itr != request_timer_map.end()) {
int timer_id = timer_itr->second;
_D("timer_id[%d]", timer_id);
- conv::util::misc_stop_timer(reinterpret_cast<void*> (timer_id));
+ conv::util::miscStopTimer(reinterpret_cast<void*> (timer_id));
}
// 3. Notify the client that the requested discovery has been finished
return CONV_ERROR_NONE;
}
-void conv::discovery_manager_impl::timer_worker(void* data)
+void conv::DiscoveryManager::timer_worker(void* data)
{
gpointer* param = reinterpret_cast<gpointer*> (data);
std::string* req_client = reinterpret_cast<std::string*> (param[0]);
- conv::discovery_manager_impl* cur_disc_mgr = reinterpret_cast<conv::discovery_manager_impl*> (param[1]);
+ conv::DiscoveryManager* cur_disc_mgr = reinterpret_cast<conv::DiscoveryManager*> (param[1]);
_D("Timer_Worker.. req_client[%s] discovery_manager[%x]", (*req_client).c_str(), cur_disc_mgr);
cur_disc_mgr->notify_time_up(*req_client);
}
-int conv::discovery_manager_impl::checkBoundaryForTimeout(int givenTimeout)
+int conv::DiscoveryManager::checkBoundaryForTimeout(int givenTimeout)
{
if ( givenTimeout < CONV_DISCOVERY_MIN_VALUE )
return CONV_DISCOVERY_MIN_VALUE;
return givenTimeout;
}
-int conv::discovery_manager_impl::handle_request(request* request_obj)
+int conv::DiscoveryManager::handleRequest(request* requestObj)
{
- _D("handle_request called .. request:%x _instance:%x", request_obj, _instance);
+ _D("handle_request called .. request:%x _instance:%x", requestObj, _instance);
if ( _instance ) {
- if ( !strcmp(request_obj->get_subject(), CONV_SUBJECT_DISCOVERY_START) ) {
- if ( !conv::privilege_manager::is_allowed(request_obj->get_creds(), CONV_PRIVILEGE_INTERNET) ||
- !conv::privilege_manager::is_allowed(request_obj->get_creds(), CONV_PRIVILEGE_BLUETOOTH) ) {
+ if ( !strcmp(requestObj->get_subject(), CONV_SUBJECT_DISCOVERY_START) ) {
+ if ( !conv::privilege_manager::isAllowed(requestObj->get_creds(), CONV_PRIVILEGE_INTERNET) ||
+ !conv::privilege_manager::isAllowed(requestObj->get_creds(), CONV_PRIVILEGE_BLUETOOTH) ) {
_E("permission denied");
- request_obj->reply(CONV_ERROR_PERMISSION_DENIED);
- delete request_obj;
+ requestObj->reply(CONV_ERROR_PERMISSION_DENIED);
+ delete requestObj;
return CONV_ERROR_PERMISSION_DENIED;
}
// Discovery Provider Starts!!!!
(*it)->start();
- const char* client = request_obj->get_sender();
+ const char* client = requestObj->get_sender();
if (client == NULL) {
_D("client is empty..");
return CONV_ERROR_INVALID_OPERATION;
}
- _D("request_obj info .. client[%s]", client);
+ _D("requestObj info .. client[%s]", client);
int timeout = 0;
- json description = request_obj->get_description();
+ json description = requestObj->get_description();
description.get(NULL, "timeout", &timeout);
timeout = checkBoundaryForTimeout(timeout);
if ( map_itr == request_map.end()) {
// current request inserted into request_map..
- request_map.insert(request_map_t::value_type(string(client), request_obj));
+ request_map.insert(request_map_t::value_type(string(client), requestObj));
_D("client[%s] inserted into request_map", client);
count_discovery_request++;
} else {
_D("client[%s] already in request_map.. Replace!!!", client);
- map_itr->second = request_obj;
+ 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()) {
int timer_id = timer_itr->second;
_D("timer_id[%d]", timer_id);
- conv::util::misc_stop_timer(reinterpret_cast<void*> (timer_id));
+ conv::util::miscStopTimer(reinterpret_cast<void*> (timer_id));
}
}
param[0] = reinterpret_cast<void*>(new(std::nothrow) string(client));
param[1] = reinterpret_cast<void*>(this);
- int timer_id = reinterpret_cast<int>(conv::util::misc_start_timer(timer_worker, timeout, param));
+ int timer_id = reinterpret_cast<int>(conv::util::miscStartTimer(timer_worker, timeout, param));
request_timer_map[ string(client) ] = timer_id;
- request_obj->reply(CONV_ERROR_NONE);
- } else if ( !strcmp(request_obj->get_subject(), CONV_SUBJECT_DISCOVERY_STOP) ){
- const char* client = request_obj->get_sender();
+ requestObj->reply(CONV_ERROR_NONE);
+ } else if ( !strcmp(requestObj->get_subject(), CONV_SUBJECT_DISCOVERY_STOP) ){
+ const char* client = requestObj->get_sender();
if (count_discovery_request <= 0) {
_D("discovery is already stopped");
- request_obj->reply(CONV_ERROR_INVALID_OPERATION);
+ requestObj->reply(CONV_ERROR_INVALID_OPERATION);
} else {
notify_time_up(client);
- request_obj->reply(CONV_ERROR_NONE);
+ requestObj->reply(CONV_ERROR_NONE);
}
- delete request_obj;
+ delete requestObj;
}
return CONV_ERROR_NONE;
return CONV_ERROR_INVALID_OPERATION;;
}
-int conv::discovery_manager_impl::start_discovery()
+int conv::DiscoveryManager::start_discovery()
{
return CONV_ERROR_NONE;
}
-int conv::discovery_manager_impl::stop_discovery()
+int conv::DiscoveryManager::stop_discovery()
{
_D("Stop_Discovery...");
for (discovery_provider_list_t::iterator it = provider_list.begin(); it != provider_list.end(); ++it) {
return CONV_ERROR_NONE;
}
-int conv::discovery_manager_impl::register_provider(discovery_provider_base *provider)
+int conv::DiscoveryManager::register_provider(IDiscoveryProvider *provider)
{
if (!provider) {
_E("Provider NULL");
return CONV_ERROR_NONE;
}
-int conv::discovery_manager_impl::convert_device_into_json(conv::device_iface* device_info, json* json_data)
+int conv::DiscoveryManager::convert_device_into_json(conv::IDevice* device_info, json* json_data)
{
json_data->set(NULL, CONV_JSON_DEVICE_ID, device_info->getId());
json_data->set(NULL, CONV_JSON_DEVICE_NAME, device_info->getName());
return CONV_ERROR_NONE;
}
-int conv::discovery_manager_impl::convert_service_into_json(conv::service_iface* service_info, json* json_data)
+int conv::DiscoveryManager::convert_service_into_json(conv::IService* service_info, json* json_data)
{
string service_info_str = service_info->getServiceInfo();
_D("Service-2-Json Conversion : %s", service_info_str.c_str());
return CONV_ERROR_NONE;
}
-static bool serviceComparision(conv::service_iface* obj, int serviceType)
+static bool serviceComparision(conv::IService* obj, int serviceType)
{
if (obj->getServiceType() == serviceType)
return true;
return false;
}
-int conv::discovery_manager_impl::exclude_services(conv::device_iface* org_device, conv::device_iface* removed_device)
+int conv::DiscoveryManager::exclude_services(conv::IDevice* org_device, conv::IDevice* removed_device)
{
int remained_serv_count = 0;
- std::list<service_iface*> org_serv_list;
- std::list<service_iface*> removed_serv_list;
+ std::list<IService*> org_serv_list;
+ std::list<IService*> removed_serv_list;
org_device->get_services_list(&org_serv_list);
_D("[%d] Services in the origin device info[%s]", org_serv_list.size(), org_device->getName().c_str());
removed_device->get_services_list(&removed_serv_list);
_D("[%d] Services in the removed device info[%s]", removed_serv_list.size(), removed_device->getName().c_str());
- std::list<service_iface*>::iterator removed_itr = removed_serv_list.begin();
+ std::list<IService*>::iterator removed_itr = removed_serv_list.begin();
for (; removed_itr != removed_serv_list.end(); ++removed_itr) {
- service_iface* cur_removed_serv = *removed_itr;
- std::list<service_iface*>::iterator org_iter = std::find_if(org_serv_list.begin(), org_serv_list.end(), std::bind(serviceComparision, std::placeholders::_1, cur_removed_serv->getServiceType()));
+ 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()) {
- service_iface* cur_serv = *org_iter;
+ 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->remove_service(cur_serv);
remained_serv_count--;
// return value : the number of new services
-int conv::discovery_manager_impl::merge_exclude_services(conv::device_iface* org_device, conv::device_iface* new_device)
+int conv::DiscoveryManager::merge_exclude_services(conv::IDevice* org_device, conv::IDevice* new_device)
{
int new_serv_count = 0;
- std::list<service_iface*> org_serv_list;
- std::list<service_iface*> new_serv_list;
+ std::list<IService*> org_serv_list;
+ std::list<IService*> new_serv_list;
org_device->get_services_list(&org_serv_list);
_D("[%d] Services in the origin device info[%s]", org_serv_list.size(), org_device->getName().c_str() );
new_device->get_services_list(&new_serv_list);
_D("[%d] Services in the new device info[%s]", new_serv_list.size(), new_device->getName().c_str() );
- std::list<service_iface*>::iterator new_iter = new_serv_list.begin();
+ std::list<IService*>::iterator new_iter = new_serv_list.begin();
for (; new_iter != new_serv_list.end(); ++new_iter) {
- service_iface* cur_serv = *new_iter;
- std::list<service_iface*>::iterator org_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!!
return new_serv_count;
}
-int conv::discovery_manager_impl::notify_lost_device(device_iface* disc_device)
+int conv::DiscoveryManager::notify_lost_device(IDevice* disc_device)
{
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()) {
- device_iface* cur_device = itor_disc->second;
+ IDevice* cur_device = itor_disc->second;
num_remained_service = exclude_services(cur_device, disc_device);
} else {
_D("Lost Notify dismissed - No discovered results corresponding to id[%s]", disc_device->getId().c_str());
return CONV_ERROR_NONE;
}
-int conv::discovery_manager_impl::append_discovered_result(conv::device_iface* disc_device)
+int conv::DiscoveryManager::append_discovered_result(conv::IDevice* disc_device)
{
- conv::device_iface* publish_device_info = NULL;
+ conv::IDevice* publish_device_info = NULL;
_D("Append Discovered Result.. Device:%x, Service:%x");
- IF_FAIL_RETURN_TAG((disc_device != NULL), CONV_ERROR_INVALID_PARAMETER, _E, "device_iface not initialized..");
+ IF_FAIL_RETURN_TAG((disc_device != 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());
- device_iface* cur_device = itor_disc->second;
+ IDevice* cur_device = itor_disc->second;
int count_new_services = merge_exclude_services(cur_device, disc_device);
if (count_new_services == 0)
convert_device_into_json(publish_device_info, &device_json);
_D("Convert service info into json type..");
- typedef std::list<service_iface*> serv_list_t;
+ typedef std::list<IService*> serv_list_t;
serv_list_t serv_list;
publish_device_info->get_services_list(&serv_list);
for (serv_list_t::iterator iterPos = serv_list.begin(); iterPos != serv_list.end(); ++iterPos) {
- service_iface* cur_serv = *iterPos;
+ IService* cur_serv = *iterPos;
convert_service_into_json(cur_serv, &device_json);
}
return CONV_ERROR_NONE;
}
-int conv::discovery_manager_impl::set_discovery_filter(request* request_obj)
+int conv::DiscoveryManager::set_discovery_filter(request* request_obj)
{
json desc_data = request_obj->get_description();
json filter_data;
return CONV_ERROR_NONE;
}
-int conv::discovery_manager_impl::isvalid_discovery_on_filter(json& filter_json)
+int conv::DiscoveryManager::isvalid_discovery_on_filter(json& filter_json)
{
return CONV_ERROR_NONE;
}
-int conv::discovery_manager::handle_request(request* request_obj)
+int conv::discovery_manager::handleRequest(request* requestObj)
{
IF_FAIL_RETURN_TAG(_instance, CONV_ERROR_INVALID_PARAMETER, _E, "Not initialized");
- _instance->handle_request(request_obj);
+ _instance->handleRequest(requestObj);
return CONV_ERROR_NONE;
}
#include <vector>
#include <map>
-#include "manager_iface.h"
-#include "discovery_provider_base.h"
+#include "IManager.h"
+#include "IDiscoveryProvider.h"
#include "request.h"
-#include "device_iface.h"
-#include "service_iface.h"
+#include "IDevice.h"
+#include "IService.h"
namespace conv {
class request;
class device;
- class discovery_manager_impl : public manager_iface {
+ class DiscoveryManager : public IManager {
public:
- discovery_manager_impl();
- ~discovery_manager_impl();
+ DiscoveryManager();
+ ~DiscoveryManager();
int init();
int release();
- int handle_request(request* request_obj);
+ int handleRequest(request* requestObj);
// discovery_manager aggregates devices with services which have been discovered through the registered discover providers
- int append_discovered_result(device_iface* disc_device);
- int notify_lost_device(device_iface* disc_device);
+ int append_discovered_result(IDevice* disc_device);
+ int notify_lost_device(IDevice* disc_device);
int notify_time_up(std::string client);
int stop_discovery();
int start_discovery();
int count_discovery_request;
- typedef std::list<discovery_provider_base*> discovery_provider_list_t;
+ 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;
- int register_provider(discovery_provider_base *provider_base);
+ int register_provider(IDiscoveryProvider *provider_base);
discovery_provider_list_t provider_list;
request_map_t request_map;
filter_map_t discovery_filter_map;
timer_map_t request_timer_map;
// internal function
- int convert_service_into_json(conv::service_iface* service_info, json* json_data);
- int convert_device_into_json(conv::device_iface* service_info, json* json_data);
+ int convert_service_into_json(conv::IService* service_info, json* json_data);
+ int convert_device_into_json(conv::IDevice* service_info, json* json_data);
int set_discovery_filter(request* req_obj);
int isvalid_discovery_on_filter(json& filter_json);
int checkBoundaryForTimeout(int givenTimeout);
- int merge_exclude_services(conv::device_iface* org_device, conv::device_iface* new_device);
- int exclude_services(conv::device_iface* org_device, conv::device_iface* removed_device);
+ int merge_exclude_services(conv::IDevice* org_device, conv::IDevice* new_device);
+ int exclude_services(conv::IDevice* org_device, conv::IDevice* removed_device);
};
namespace discovery_manager {
- void set_instance(discovery_manager_impl* mgr);
- int handle_request(request* request_obj);
+ void set_instance(DiscoveryManager* mgr);
+ int handleRequest(request* requestObj);
int set_result(device* device_obj);
};
}
namespace conv
{
- class communication_info_base {
+ class ICommunicationInfo {
public:
- virtual ~communication_info_base() {}
+ virtual ~ICommunicationInfo() {}
};
}
#include <sys/types.h>
namespace conv {
- class dbus_server_iface {
+ class IDbusServer {
public:
- virtual ~dbus_server_iface() {}
- }; /* class conv::dbus_server */
+ virtual ~IDbusServer() {}
+ }; /* class conv::IDbusServer */
-} /* namespace ctx */
+} /* namespace conv */
#endif /* End of __CONV_DBUS_SERVER_INTERFACE_H__ */
#ifndef _DEVICE_INTERFACE_H__
#define _DEVICE_INTERFACE_H__
-#include "service_iface.h"
+#include "IService.h"
#include <string>
#include <list>
using namespace std;
namespace conv {
- class device_iface {
+ class IDevice {
public:
- virtual ~device_iface() {}
+ virtual ~IDevice() {}
- virtual int add_service(service_iface* service_obj) = 0;
- virtual int remove_service(service_iface* service_obj) = 0;
- virtual int get_services_list(std::list<service_iface*> *list) = 0;
+ virtual int add_service(IService* service_obj) = 0;
+ virtual int remove_service(IService* service_obj) = 0;
+ virtual int get_services_list(std::list<IService*> *list) = 0;
virtual string getName() = 0;
virtual string getId() = 0;
* limitations under the License.
*/
-#include "discovery_mgr_impl.h"
+#include "DiscoveryManager.h"
-conv::discovery_manager_impl* conv::discovery_provider_base::_discovery_manager = NULL;
+conv::DiscoveryManager* conv::IDiscoveryProvider::_discovery_manager = NULL;
-int conv::discovery_provider_base::set_manager(discovery_manager_impl* discovery_manager)
+int conv::IDiscoveryProvider::set_manager(DiscoveryManager* discovery_manager)
{
_discovery_manager = discovery_manager;
return CONV_ERROR_NONE;
#include <string>
#include "conv_json.h"
-
namespace conv {
- class discovery_manager_impl;
+ class DiscoveryManager;
- class discovery_provider_base {
+ class IDiscoveryProvider {
public:
- virtual ~discovery_provider_base() {}
+ virtual ~IDiscoveryProvider() {}
virtual int init() = 0;
virtual int release() = 0;
virtual int start() = 0;
virtual int stop() = 0;
- int set_manager(discovery_manager_impl* discovery_manager);
+ int set_manager(DiscoveryManager* discovery_manager);
protected:
- static discovery_manager_impl* _discovery_manager;
- }; /* class discovery_provider_base */
+ static DiscoveryManager* _discovery_manager;
+ }; /* class IDiscoveryProvider */
}
#endif /* End of __DISCOVERY_PROVIDER_BASE_H__ */
namespace conv {
class request;
- class manager_iface {
+ class IManager {
public:
- virtual ~manager_iface() {}
+ virtual ~IManager() {}
virtual int init() = 0;
virtual int release() = 0;
- virtual int handle_request(request* request_obj) = 0;
- }; /* class manager_iface */
+ virtual int handleRequest(request* requestObj) = 0;
+ }; /* class IManager */
}
#endif /* End of __CONV_MANAGER_INTERFACE_H__ */
using namespace std;
namespace conv {
- class service_iface {
+ class IService {
public:
- virtual ~service_iface() {}
+ virtual ~IService() {}
virtual string getName() = 0;
virtual string getVersion() = 0;
virtual string getType() = 0;
namespace conv
{
- class service_info_base {
+ class IServiceInfo {
public:
- virtual ~service_info_base() {}
+ virtual ~IServiceInfo() {}
};
}
#include "conv_json.h"
namespace conv {
- class service_provider_base {
+ class IServiceProvider {
public:
- virtual ~service_provider_base() {}
+ virtual ~IServiceProvider() {}
virtual int init() = 0;
virtual int release() = 0;
std::string _resource_type;
std::string _uri;
int _activation_state;
- }; /* class service_provider_base */
+ }; /* class IServiceProvider */
}
#endif /* End of __SERVICE_PROVIDER_BASE_H__ */
#include <glib.h>
#include <iotcon.h>
#include <string>
-#include "communication_info_base.h"
+#include "ICommunicationInfo.h"
namespace conv {
- class iotcon_communication_info : public communication_info_base {
+ class IotconCommunicationInfo : public ICommunicationInfo {
public:
std::string address;
std::string uri;
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "RequestHandler.h"
+#include "DiscoveryManager.h"
+#include "ServiceManager.h"
+#include "ConnectionManager.h"
+
+using namespace std;
+
+conv::RequestHandler::RequestHandler()
+{
+}
+
+conv::RequestHandler::~RequestHandler()
+{
+}
+
+int conv::RequestHandler::init()
+{
+ return CONV_ERROR_NONE;
+}
+
+int conv::RequestHandler::release()
+{
+ return CONV_ERROR_NONE;
+}
+
+int conv::RequestHandler::handleRequest(request* requestObj)
+{
+ _D("handleRequest called");
+ int result = CONV_ERROR_INVALID_OPERATION;
+
+ switch (requestObj->get_type()) {
+ case REQ_SUBSCRIBE:
+ _D("Requested type : REQ_SUBSCRIBE..");
+ if ( !strcmp(requestObj->get_subject(), CONV_SUBJECT_COMMUNICATION_RECV) )
+ result = service_manager::handleRequest(requestObj);
+ else if ( !strcmp(requestObj->get_subject(), CONV_SUBJECT_CONNECTION_START) )
+ result = connection_manager::handleRequest(requestObj);
+ break;
+ case REQ_UNSUBSCRIBE:
+ if (!strcmp(requestObj->get_subject(), CONV_SUBJECT_COMMUNICATION_RECV) )
+ result = service_manager::handleRequest(requestObj);
+ else if ( !strcmp(requestObj->get_subject(), CONV_SUBJECT_CONNECTION_START) )
+ result = connection_manager::handleRequest(requestObj);
+ break;
+ case REQ_READ:
+ break;
+ case REQ_READ_SYNC:
+ break;
+ case REQ_WRITE:
+ _D("Requested type : REQ_WRITE..");
+ if (!strcmp(requestObj->get_subject(), CONV_SUBJECT_DISCOVERY_START) || !strcmp(requestObj->get_subject(), CONV_SUBJECT_DISCOVERY_STOP))
+ return discovery_manager::handleRequest (requestObj);
+ else if ( !strcmp(requestObj->get_subject(), CONV_SUBJECT_COMMUNICATION_START) || !strcmp(requestObj->get_subject(), CONV_SUBJECT_COMMUNICATION_STOP)
+ || !strcmp(requestObj->get_subject(), CONV_SUBJECT_COMMUNICATION_SET) || !strcmp(requestObj->get_subject(), CONV_SUBJECT_COMMUNICATION_GET))
+ result = service_manager::handleRequest(requestObj);
+ else if ( !strcmp(requestObj->get_subject(), CONV_SUBJECT_CONNECTION_START) || !strcmp(requestObj->get_subject(), CONV_SUBJECT_CONNECTION_STOP) )
+ result = connection_manager::handleRequest(requestObj);
+ break;
+ case REQ_SUPPORT:
+ break;
+ default:
+ _E("Invalid type of request");
+ requestObj->reply(result);
+ delete requestObj;
+ }
+
+ return result;
+}
#include "request.h"
namespace conv {
- class request_handler {
+ class RequestHandler {
public:
- request_handler();
- ~request_handler();
+ RequestHandler();
+ ~RequestHandler();
int init();
int release();
- int handle_request(request* request_obj);
+ int handleRequest(request* requestObj);
};
}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <new>
+#include <gio/gio.h>
+
+
+#include "d2d_conv_manager.h"
+#include "Server.h"
+#include "DbusServer.h"
+#include "DiscoveryManager.h"
+#include "ConnectionManager.h"
+#include "ClientManager.h"
+#include "ServiceManager.h"
+#include "RequestHandler.h"
+
+using namespace std;
+
+static GMainLoop *mainLoop = NULL;
+static gboolean started = FALSE;
+static conv::DbusServer *dbusHandle = NULL;
+static conv::DiscoveryManager *discoveryMgr = NULL;
+static conv::ConnectionManager *connectionMgr = NULL;
+static conv::ClientManager *clientMgr = NULL;
+static conv::ServiceManager *serviceMgr = NULL;
+static conv::RequestHandler *requestMgr = NULL;
+
+void conv::initialize()
+{
+ int result;
+
+ if (started) {
+ _D("flowd is started already");
+ return;
+ }
+
+ mainLoop = g_main_loop_new(NULL, FALSE);
+
+ _I("Init Discovery Manager");
+ discoveryMgr = new(std::nothrow) conv::DiscoveryManager();
+ IF_FAIL_CATCH_TAG(discoveryMgr, _E, "Memory allocation failed");
+ discovery_manager::set_instance(discoveryMgr);
+ result = discoveryMgr->init();
+ IF_FAIL_CATCH_TAG(result == CONV_ERROR_NONE, _E, "Initialization Failed");
+
+ _I("Init Connection Manager");
+ connectionMgr = new(std::nothrow) conv::ConnectionManager();
+ IF_FAIL_CATCH_TAG(connectionMgr, _E, "Memory allocation failed");
+ connection_manager::setInstance(connectionMgr);
+ result = connectionMgr->init();
+ IF_FAIL_CATCH_TAG(result == CONV_ERROR_NONE, _E, "Initialization Failed");
+
+ _I("Init Client Manager");
+ clientMgr = new(std::nothrow) conv::ClientManager();
+ IF_FAIL_CATCH_TAG(clientMgr, _E, "Memory allocation failed");
+ client_manager::setInstance(clientMgr);
+ result = clientMgr->init();
+ IF_FAIL_CATCH_TAG(result == CONV_ERROR_NONE, _E, "Initialization Failed");
+
+ _I("Init Service Manager");
+ serviceMgr = new(std::nothrow) conv::ServiceManager();
+ IF_FAIL_CATCH_TAG(serviceMgr, _E, "Memory allocation failed");
+ service_manager::set_instance(serviceMgr);
+ result = serviceMgr->init();
+ IF_FAIL_CATCH_TAG(result == CONV_ERROR_NONE, _E, "Initialization Failed");
+
+ _I("Init Request Manager");
+ requestMgr = new(std::nothrow) RequestHandler();
+ IF_FAIL_CATCH_TAG(requestMgr, _E, "Memory allocation failed");
+ result = requestMgr->init();
+ IF_FAIL_CATCH_TAG(result == CONV_ERROR_NONE, _E, "Initialization Failed");
+
+ _I("Init Dbus Server");
+ dbusHandle = new(std::nothrow) conv::DbusServer();
+ IF_FAIL_CATCH_TAG(discoveryMgr, _E, "Memory allocation failed");
+ dbus_server::setInstance(dbusHandle);
+ result = dbusHandle->init();
+ IF_FAIL_CATCH_TAG(result == true, _E, "Initialization Failed");
+
+ _I("Start main loop");
+ started = TRUE;
+
+ g_main_loop_run(mainLoop);
+
+ return;
+
+CATCH:
+ _E(RED("Launching Failed"));
+
+ g_main_loop_quit(mainLoop);
+}
+
+void conv::release()
+{
+ _I(CYAN("Terminating flow-daemon"));
+ _I("Release discovery manager");
+ if (discoveryMgr)
+ discoveryMgr->release();
+
+ _I("Release connection manager");
+ if (connectionMgr)
+ connectionMgr->release();
+
+ _I("Release dbus server");
+ if (dbusHandle)
+ dbusHandle->release();
+
+ _I("Release client manager");
+ if (clientMgr)
+ clientMgr->release();
+
+ _I("Release service manager");
+ if (serviceMgr)
+ serviceMgr->release();
+
+ _I("Release request handler");
+ if (requestMgr)
+ requestMgr->release();
+
+ g_main_loop_unref(mainLoop);
+
+ delete discoveryMgr;
+ delete connectionMgr;
+ delete dbusHandle;
+ delete clientMgr;
+ delete requestMgr;
+ delete serviceMgr;
+ started = FALSE;
+}
+
+
+void conv::sendRequest(request* requestObj)
+{
+ _D("send_request requestObj:%x request_mg:%x", requestObj, requestMgr);
+ if (requestMgr) {
+ requestMgr->handleRequest(requestObj);
+ } else if (requestObj) {
+ requestObj->reply(CONV_ERROR_NONE);
+ }
+
+ _D("request handling done");
+}
+
+static void signal_handler(int signo)
+{
+ _I("SIGNAL %d received", signo);
+
+ // Stop the main loop
+ g_main_loop_quit(mainLoop);
+}
+
+int main(int argc, char **argv)
+{
+ static struct sigaction signal_action;
+ signal_action.sa_handler = signal_handler;
+ sigemptyset(&signal_action.sa_mask);
+
+ sigaction(SIGINT, &signal_action, NULL);
+ sigaction(SIGHUP, &signal_action, NULL);
+ sigaction(SIGTERM, &signal_action, NULL);
+ sigaction(SIGQUIT, &signal_action, NULL);
+ sigaction(SIGABRT, &signal_action, NULL);
+
+#if !defined(GLIB_VERSION_2_36)
+ g_type_init();
+#endif
+
+ conv::initialize();
+ conv::release();
+
+ return EXIT_SUCCESS;
+}
#define __CONV_SERVER_H__
#define CONV_DAEMON
-#include "log.h"
+#include "Log.h"
#include "request.h"
namespace conv {
void initialize();
void release();
- void send_request(request* request_obj);
+ void sendRequest(request* requestObj);
}
#endif
* limitations under the License.
*/
-#include "service_mgr_impl.h"
-#include "service_provider/app_comm_service_provider.h"
-#include "service_provider/remote_app_control_service_provider.h"
-#include "connection_mgr_impl.h"
-#include "access_control/privilege.h"
-#include "util.h"
+#include "ServiceManager.h"
+#include "service_provider/AppCommServiceProvider.h"
+#include "service_provider/RemoteAppControlServiceProvider.h"
+#include "access_control/Privilege.h"
+#include "Util.h"
#include <iotcon.h>
-static conv::service_manager_impl *_instance;
+static conv::ServiceManager *_instance;
static iotcon_resource_h iotcon_resource = NULL;
using namespace std;
-conv::service_manager_impl::service_manager_impl()
+conv::ServiceManager::ServiceManager()
{
}
-conv::service_manager_impl::~service_manager_impl()
+conv::ServiceManager::~ServiceManager()
{
}
-int conv::service_manager_impl::handle_vconf_update(keynode_t *node)
+int conv::ServiceManager::handle_vconf_update(keynode_t *node)
{
activation_state = vconf_keynode_get_int(node);
static void vconf_update_cb(keynode_t *node, void* user_data)
{
- conv::service_manager_impl* instance = static_cast<conv::service_manager_impl*>(user_data);
+ conv::ServiceManager* instance = static_cast<conv::ServiceManager*>(user_data);
IF_FAIL_VOID_TAG(instance, _E, "static_cast failed");
instance->handle_vconf_update(node);
}
-int conv::service_manager_impl::init()
+int conv::ServiceManager::init()
{
- register_provider(new(std::nothrow) conv::app_comm_service_provider());
- register_provider(new(std::nothrow) conv::remote_app_control_service_provider());
+ register_provider(new(std::nothrow) conv::AppCommServiceProvider());
+ register_provider(new(std::nothrow) conv::RemoteAppControlServiceProvider());
int error = vconf_get_int(VCONFKEY_SETAPPL_D2D_CONVERGENCE, &activation_state);
return CONV_ERROR_NONE;
}
-int conv::service_manager_impl::release()
+int conv::ServiceManager::release()
{
unregister_discovery_info();
return CONV_ERROR_NONE;
}
-int conv::service_manager_impl::handle_request(request* request_obj)
+int conv::ServiceManager::handleRequest(request* requestObj)
{
_D("handle_request called");
string type;
int error = CONV_ERROR_INVALID_OPERATION;
bool json_return;
- json description = request_obj->get_description();
+ json description = requestObj->get_description();
json_return = description.get(NULL, CONV_JSON_TYPE, &type);
IF_FAIL_CATCH_TAG(json_return, _E, "json parse error : no type info");
error = (*it)->check_activation_state();
IF_FAIL_CATCH_TAG(error == CONV_ERROR_NONE, _E, "service provider is not activated");
- error = (*it)->load_service_info(request_obj);
+ error = (*it)->load_service_info(requestObj);
IF_FAIL_CATCH_TAG(error == CONV_ERROR_NONE, _E, "%d, service_info load error", error);
- if (!strcmp(request_obj->get_subject(), CONV_SUBJECT_COMMUNICATION_START)) {
- if ( !conv::privilege_manager::is_allowed(request_obj->get_creds(), CONV_PRIVILEGE_INTERNET) ||
- !conv::privilege_manager::is_allowed(request_obj->get_creds(), CONV_PRIVILEGE_BLUETOOTH) ||
- !conv::privilege_manager::is_allowed(request_obj->get_creds(), CONV_PRIVILEGE_D2D_DATA_SHARING) )
+ if (!strcmp(requestObj->get_subject(), CONV_SUBJECT_COMMUNICATION_START)) {
+ if ( !conv::privilege_manager::isAllowed(requestObj->get_creds(), CONV_PRIVILEGE_INTERNET) ||
+ !conv::privilege_manager::isAllowed(requestObj->get_creds(), CONV_PRIVILEGE_BLUETOOTH) ||
+ !conv::privilege_manager::isAllowed(requestObj->get_creds(), CONV_PRIVILEGE_D2D_DATA_SHARING) )
{
_E("permission denied");
- request_obj->reply(CONV_ERROR_PERMISSION_DENIED);
- delete request_obj;
+ requestObj->reply(CONV_ERROR_PERMISSION_DENIED);
+ delete requestObj;
return CONV_ERROR_PERMISSION_DENIED;
}
- error = (*it)->start_request(request_obj);
- } else if (!strcmp(request_obj->get_subject(), CONV_SUBJECT_COMMUNICATION_STOP)) {
- if ( !conv::privilege_manager::is_allowed(request_obj->get_creds(), CONV_PRIVILEGE_INTERNET) ||
- !conv::privilege_manager::is_allowed(request_obj->get_creds(), CONV_PRIVILEGE_BLUETOOTH) )
+ error = (*it)->start_request(requestObj);
+ } else if (!strcmp(requestObj->get_subject(), CONV_SUBJECT_COMMUNICATION_STOP)) {
+ if ( !conv::privilege_manager::isAllowed(requestObj->get_creds(), CONV_PRIVILEGE_INTERNET) ||
+ !conv::privilege_manager::isAllowed(requestObj->get_creds(), CONV_PRIVILEGE_BLUETOOTH) )
{
_E("permission denied");
- request_obj->reply(CONV_ERROR_PERMISSION_DENIED);
- delete request_obj;
+ requestObj->reply(CONV_ERROR_PERMISSION_DENIED);
+ delete requestObj;
return CONV_ERROR_PERMISSION_DENIED;
}
- error = (*it)->stop_request(request_obj);
- } else if (!strcmp(request_obj->get_subject(), CONV_SUBJECT_COMMUNICATION_GET)) {
- if ( !conv::privilege_manager::is_allowed(request_obj->get_creds(), CONV_PRIVILEGE_INTERNET) ||
- !conv::privilege_manager::is_allowed(request_obj->get_creds(), CONV_PRIVILEGE_BLUETOOTH) )
+ error = (*it)->stop_request(requestObj);
+ } else if (!strcmp(requestObj->get_subject(), CONV_SUBJECT_COMMUNICATION_GET)) {
+ if ( !conv::privilege_manager::isAllowed(requestObj->get_creds(), CONV_PRIVILEGE_INTERNET) ||
+ !conv::privilege_manager::isAllowed(requestObj->get_creds(), CONV_PRIVILEGE_BLUETOOTH) )
{
_E("permission denied");
- request_obj->reply(CONV_ERROR_PERMISSION_DENIED);
- delete request_obj;
+ requestObj->reply(CONV_ERROR_PERMISSION_DENIED);
+ delete requestObj;
return CONV_ERROR_PERMISSION_DENIED;
}
- error = (*it)->get_request(request_obj);
- } else if (!strcmp(request_obj->get_subject(), CONV_SUBJECT_COMMUNICATION_SET)) {
- if ( !conv::privilege_manager::is_allowed(request_obj->get_creds(), CONV_PRIVILEGE_INTERNET) ||
- !conv::privilege_manager::is_allowed(request_obj->get_creds(), CONV_PRIVILEGE_BLUETOOTH) ||
- !conv::privilege_manager::is_allowed(request_obj->get_creds(), CONV_PRIVILEGE_D2D_DATA_SHARING) )
+ error = (*it)->get_request(requestObj);
+ } else if (!strcmp(requestObj->get_subject(), CONV_SUBJECT_COMMUNICATION_SET)) {
+ if ( !conv::privilege_manager::isAllowed(requestObj->get_creds(), CONV_PRIVILEGE_INTERNET) ||
+ !conv::privilege_manager::isAllowed(requestObj->get_creds(), CONV_PRIVILEGE_BLUETOOTH) ||
+ !conv::privilege_manager::isAllowed(requestObj->get_creds(), CONV_PRIVILEGE_D2D_DATA_SHARING) )
{
_E("permission denied");
- request_obj->reply(CONV_ERROR_PERMISSION_DENIED);
- delete request_obj;
+ requestObj->reply(CONV_ERROR_PERMISSION_DENIED);
+ delete requestObj;
return CONV_ERROR_PERMISSION_DENIED;
}
- error = (*it)->set_request(request_obj);
- } else if (!strcmp(request_obj->get_subject(), CONV_SUBJECT_COMMUNICATION_RECV)) {
- return (*it)->register_request(request_obj);
+ error = (*it)->set_request(requestObj);
+ } else if (!strcmp(requestObj->get_subject(), CONV_SUBJECT_COMMUNICATION_RECV)) {
+ return (*it)->register_request(requestObj);
}
IF_FAIL_CATCH_TAG(error == CONV_ERROR_NONE, _E, "service manager request handle error");
}
}
- request_obj->reply(CONV_ERROR_NONE);
- delete request_obj;
- _D("request_obj deleted");
+ requestObj->reply(CONV_ERROR_NONE);
+ delete requestObj;
+ _D("requestObj deleted");
return CONV_ERROR_NONE;
CATCH:
- request_obj->reply(error);
- delete request_obj;
+ requestObj->reply(error);
+ delete requestObj;
return error;
}
-void conv::service_manager::set_instance(conv::service_manager_impl* mgr)
+void conv::service_manager::set_instance(conv::ServiceManager* mgr)
{
_instance = mgr;
}
-int conv::service_manager::handle_request(request* request_obj)
+int conv::service_manager::handleRequest(request* requestObj)
{
IF_FAIL_RETURN_TAG(_instance, CONV_ERROR_INVALID_PARAMETER, _E, "Not initialized");
- _instance->handle_request(request_obj);
+ _instance->handleRequest(requestObj);
return CONV_ERROR_NONE;
}
-int conv::service_manager_impl::register_provider(conv::service_provider_base *provider)
+int conv::ServiceManager::register_provider(conv::IServiceProvider *provider)
{
if (!provider) {
_E("Provider NULL");
}
-static iotcon_representation_h _get_d2d_service_representation(conv::service_manager_impl* instance)
+static iotcon_representation_h _get_d2d_service_representation(conv::ServiceManager* instance)
{
int ret;
iotcon_attributes_h attributes;
return NULL;
}
- char* device_id = (char*) conv::util::get_device_id().c_str();
- char* device_name = (char*) conv::util::get_device_name().c_str();
+ char* device_id = (char*) conv::util::getDeviceId().c_str();
+ char* device_name = (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);
return repr;
}
-int conv::service_manager_impl::get_service_info_for_discovery(json* service_json)
+int conv::ServiceManager::get_service_info_for_discovery(json* service_json)
{
IF_FAIL_RETURN_TAG(service_json, CONV_ERROR_INVALID_OPERATION, _E, "service_json is NULL");
iotcon_request_type_e type;
char *host_address;
- conv::service_manager_impl *instance = (conv::service_manager_impl*)user_data;
+ conv::ServiceManager *instance = (conv::ServiceManager*)user_data;
IF_FAIL_VOID_TAG(request, _E, "request is NULL");
}
}
-int conv::service_manager_impl::register_discovery_info()
+int conv::ServiceManager::register_discovery_info()
{
IF_FAIL_RETURN_TAG(iotcon_resource == NULL, CONV_ERROR_INVALID_PARAMETER, _E, "resource for discovery is already registered");
return CONV_ERROR_NONE;
}
-int conv::service_manager_impl::unregister_discovery_info()
+int conv::ServiceManager::unregister_discovery_info()
{
IF_FAIL_RETURN_TAG(iotcon_resource != NULL, CONV_ERROR_INVALID_PARAMETER, _E, "resource for discovery is already unregistered");
#include <glib.h>
#include <vector>
#include <vconf.h>
-#include "manager_iface.h"
+#include "IManager.h"
#include "request.h"
-#include "service_provider_base.h"
+#include "IServiceProvider.h"
namespace conv {
- class service_manager_impl : public manager_iface {
+ class ServiceManager : public IManager {
public:
- service_manager_impl();
- ~service_manager_impl();
+ ServiceManager();
+ ~ServiceManager();
int init();
int release();
- int handle_request(request* request_obj);
+ int handleRequest(request* requestObj);
int get_service_info_for_discovery(json* service_json);
int handle_vconf_update(keynode_t *node);
private:
int activation_state;
- typedef std::list<service_provider_base*> service_provider_list_t;
+ typedef std::list<IServiceProvider*> service_provider_list_t;
- int register_provider(service_provider_base *provider_base);
+ int register_provider(IServiceProvider *provider_base);
int register_discovery_info();
int unregister_discovery_info();
service_provider_list_t provider_list;
};
namespace service_manager {
- void set_instance(service_manager_impl* mgr);
- int handle_request(request* request_obj);
+ void set_instance(ServiceManager* mgr);
+ int handleRequest(request* requestObj);
}
}
* limitations under the License.
*/
-#include "util.h"
+#include "Util.h"
#include <bluetooth.h>
#include <bluetooth_internal.h>
#include <vconf.h>
-#include "log.h"
+#include "Log.h"
#include <glib.h>
#include <pthread.h>
using namespace std;
-std::string conv::util::get_bt_mac_address()
+std::string conv::util::getBtMacAddress()
{
static std::string g_mac_address;
if(g_mac_address.empty()) {
}
-std::string conv::util::get_device_name()
+std::string conv::util::getDeviceName()
{
static std::string g_device_name;
if(g_device_name.empty()) {
return g_device_name;
}
-static char make_p2p_mac(char c)
+static char __make_p2p_mac(char c)
{
char convert_c = c;
if ((convert_c >= 'A') && (convert_c <= 'F')) {
return convert_c;
}
-std::string conv::util::get_p2p_mac_address()
+std::string conv::util::getP2pMacAddress()
{
static std::string g_p2p_mac_address;
if(g_p2p_mac_address.empty()) {
_E("vconf_get_str Failed for %s", VCONFKEY_WIFI_BSSID_ADDRESS);
} else {
memcpy(p2p_mac, temp_addr, MAC_ADDR_STR_LEN-1);
- p2p_mac[1] = make_p2p_mac(p2p_mac[1]);
+ p2p_mac[1] = __make_p2p_mac(p2p_mac[1]);
_I("P2P mac is %s", p2p_mac);
free(temp_addr);
return g_p2p_mac_address;
}
-static gboolean misc_timer_worker(gpointer ud)
+static gboolean __misc_timer_worker(gpointer ud)
{
_D("timer_work..");
gpointer *tdata = (gpointer*)ud;
return TRUE;
}
-void* conv::util::misc_start_timer(timer_function function, unsigned int interval, void *data)
+void* conv::util::miscStartTimer(timer_function function, unsigned int interval, void *data)
{
guint id = 0;
GSource *src = NULL;
tdata[0] = (void*)function;
tdata[1] = data;
- g_source_set_callback(src, misc_timer_worker, tdata, g_free);
+ g_source_set_callback(src, __misc_timer_worker, tdata, g_free);
id = g_source_attach(src, NULL);
g_source_unref(src);
return (void*)id;
}
-void conv::util::misc_stop_timer(void *timer)
+void conv::util::miscStopTimer(void *timer)
{
guint id = (guint) timer;
_D("Requested Stop Timer[%d]", id);
}
}
-std::string conv::util::get_device_id()
+std::string conv::util::getDeviceId()
{
static std::string g_device_id;
if(g_device_id.empty()) {
if(g_device_id.empty())
#ifdef _TV_
- g_device_id = get_bt_mac_address();
+ g_device_id = getBtMacAddress();
#else
- g_device_id = get_p2p_mac_address();
+ g_device_id = getP2pMacAddress();
#endif
}
_D("device id : %s", g_device_id.c_str());
return g_device_id;
}
-bool conv::util::is_service_activated(int service_value)
+bool conv::util::isServiceActivated(int serviceValue)
{
- int current_state;
- int error = vconf_get_int(VCONFKEY_SETAPPL_D2D_CONVERGENCE_SERVICE, ¤t_state);
+ int currentState;
+ int error = vconf_get_int(VCONFKEY_SETAPPL_D2D_CONVERGENCE_SERVICE, ¤tState);
if (error != 0) {
_D("vconf_get_int failed %d", error);
return false;
}
- if ((service_value & current_state) > 0) {
+ if ((serviceValue & currentState) > 0) {
return true;
} else {
return false;
namespace conv {
namespace util {
- std::string get_bt_mac_address();
- std::string get_device_name();
- std::string get_p2p_mac_address();
- std::string get_device_id();
- bool is_service_activated(int service_value);
+ std::string getBtMacAddress();
+ std::string getDeviceName();
+ std::string getP2pMacAddress();
+ std::string getDeviceId();
+ bool isServiceActivated(int serviceValue);
typedef void (*timer_function)(void *data);
- void* misc_start_timer(timer_function function, unsigned int interval, void *data);
- void misc_stop_timer(void *timer);
+ void* miscStartTimer(timer_function function, unsigned int interval, void *data);
+ void miscStopTimer(void *timer);
}
}
#endif
*/
#include <glib.h>
-#include "common.h"
-#include "peer_creds.h"
+#include "Types.h"
+#include "PeerCreds.h"
#include <cynara-creds-gdbus.h>
#include <cynara-session.h>
#include <app_manager.h>
#include <package_manager.h>
-conv::credentials::credentials(char *pkg_id, char *cli, char *sess, char *usr) :
- package_id(pkg_id),
+conv::Credentials::Credentials(char *pkgId, char *cli, char *sess, char *usr) :
+ packageId(pkgId),
client(cli),
session(sess),
user(usr)
{
}
-conv::credentials::~credentials()
+conv::Credentials::~Credentials()
{
- g_free(package_id);
+ g_free(packageId);
g_free(client);
g_free(session);
g_free(user);
}
-bool conv::peer_creds::get(GDBusConnection *connection, const char *unique_name, conv::credentials **creds)
+bool conv::peer_creds::get(GDBusConnection *connection, const char *unique_name, conv::Credentials **creds)
{
pid_t pid = 0;
- char *app_id = NULL;
- char *package_id = NULL;
+ char *appId = NULL;
+ char *packageId = NULL;
gchar *client = NULL;
char *session = NULL;
gchar *user = NULL;
err = cynara_creds_gdbus_get_pid(connection, unique_name, &pid);
IF_FAIL_RETURN_TAG(err == CYNARA_API_SUCCESS, false, _E, "Peer credentialing failed");
- app_manager_get_app_id(pid, &app_id);
- package_manager_get_package_id_by_app_id(app_id, &package_id);
- _D("AppId: %s, PackageId: %s", app_id, package_id);
+ app_manager_get_app_id(pid, &appId);
+ package_manager_get_package_id_by_app_id(appId, &packageId);
+ _D("AppId: %s, PackageId: %s", appId, packageId);
err = cynara_creds_gdbus_get_client(connection, unique_name, CLIENT_METHOD_DEFAULT, &client);
IF_FAIL_CATCH_TAG(err == CYNARA_API_SUCCESS, _E, "Peer credentialing failed");
err = cynara_creds_gdbus_get_user(connection, unique_name, USER_METHOD_DEFAULT, &user);
IF_FAIL_CATCH_TAG(err == CYNARA_API_SUCCESS, _E, "Peer credentialing failed");
- *creds = new(std::nothrow) credentials(package_id, client, session, user);
+ *creds = new(std::nothrow) Credentials(packageId, client, session, user);
IF_FAIL_CATCH_TAG(*creds, _E, "Memory allocation failed");
- g_free(app_id);
+ g_free(appId);
return true;
CATCH:
- g_free(app_id);
- g_free(package_id);
+ g_free(appId);
+ g_free(packageId);
g_free(client);
g_free(session);
g_free(user);
#include <string>
namespace conv {
- class credentials {
+ class Credentials {
public:
- char *package_id;
+ char *packageId;
char *client; /* default: smack label */
char *session;
char *user; /* default: UID */
- credentials(char *package_id, char *client, char *session, char *user);
- ~credentials();
+ Credentials(char *package_id, char *client, char *session, char *user);
+ ~Credentials();
};
namespace peer_creds {
- bool get(GDBusConnection *connection, const char *uniqueName, conv::credentials **creds);
+ bool get(GDBusConnection *connection, const char *uniqueName, conv::Credentials **creds);
}
} /* namespace conv */
#include <string>
#include <cynara-client.h>
-#include "common.h"
-#include "privilege.h"
+#include "Types.h"
+#include "Privilege.h"
-class permission_checker {
+class PermissionChecker {
private:
cynara *__cynara;
- permission_checker()
+ PermissionChecker()
{
if (cynara_initialize(&__cynara, NULL) != CYNARA_API_SUCCESS) {
_E("Cynara initialization failed");
_I("Cynara initialized");
}
- ~permission_checker()
+ ~PermissionChecker()
{
if (__cynara)
cynara_finish(__cynara);
}
public:
- static permission_checker& get_instance()
+ static PermissionChecker& getInstance()
{
- static permission_checker instance;
+ static PermissionChecker instance;
return instance;
}
- bool has_permission(const conv::credentials *creds, const char *privilege)
+ bool hasPermission(const conv::Credentials *creds, const char *privilege)
{
IF_FAIL_RETURN_TAG(__cynara, false, _E, "Cynara not initialized");
int ret = cynara_check(__cynara, creds->client, creds->session, creds->user, privilege);
}
};
-bool conv::privilege_manager::is_allowed(const conv::credentials *creds, const char *privilege)
+bool conv::privilege_manager::isAllowed(const conv::Credentials *creds, const char *privilege)
{
IF_FAIL_RETURN(creds && privilege, true);
std::string priv = "http://tizen.org/privilege/";
priv += privilege;
- return permission_checker::get_instance().has_permission(creds, priv.c_str());
+ return PermissionChecker::getInstance().hasPermission(creds, priv.c_str());
}
#define __CONV_PRIVILEGE_MANAGER_H__
#include <string>
-#include "peer_creds.h"
+#include "PeerCreds.h"
namespace conv {
namespace privilege_manager {
- bool is_allowed(const conv::credentials *creds, const char *privilege);
+ bool isAllowed(const conv::Credentials *creds, const char *privilege);
} /* namespace conv::privilege_manager */
} /* namespace conv */
#include <glib.h>
#include "client.h"
-#include "log.h"
+#include "Log.h"
#include "d2d_conv_manager.h"
using namespace std;
return id;
}
-conv::service_info_base* conv::client::get_service_info(string type, string id)
+conv::IServiceInfo* conv::client::get_service_info(string type, string id)
{
service_info_map_t::iterator it;
it = service_info_map.find(std::pair<string, string>(type, id));
if ( it != service_info_map.end() ) {
_D("service info found : %s, %s", type.c_str(), id.c_str());
- return (service_info_base*)(it->second);
+ return (IServiceInfo*)(it->second);
} else {
_D("service info not found : %s, %s", type.c_str(), id.c_str());
return NULL;
}
}
-int conv::client::add_service_info(string type, string id, service_info_base* info)
+int conv::client::add_service_info(string type, string id, IServiceInfo* info)
{
- service_info_map.insert(std::pair<service_key_t, service_info_base*>(std::pair<string, string>(type, id), info));
+ service_info_map.insert(std::pair<service_key_t, 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;
#include <gio/gio.h>
#include "client.h"
#include "conv_json.h"
-#include "device_iface.h"
-#include "service_info_base.h"
+#include "IDevice.h"
+#include "IServiceInfo.h"
namespace conv {
class client {
- typedef std::vector<device_iface*> device_list_t;
+ typedef std::vector<IDevice*> device_list_t;
typedef std::pair<std::string, std::string> service_key_t;
- typedef std::map<service_key_t, service_info_base*> service_info_map_t;
+ typedef std::map<service_key_t, IServiceInfo*> service_info_map_t;
public:
client(std::string id, GDBusMethodInvocation *inv);
std::string get_id();
- service_info_base* get_service_info(std::string type, std::string id);
- int add_service_info(std::string type, std::string id, service_info_base* info);
+ IServiceInfo* get_service_info(std::string type, std::string id);
+ int add_service_info(std::string type, std::string id, IServiceInfo* info);
private:
device_list_t device_list;
service_info_map_t service_info_map;
#include <glib.h>
#include <string>
#include <list>
-#include "common.h"
+#include "Types.h"
#define _J(cmt, jobj) \
do { \
* limitations under the License.
*/
-#include "iotcon_discovery_provider.h"
+#include "IotconDiscoveryProvider.h"
#include <iotcon.h>
#include <map>
#include <algorithm>
-#include "iotcon/resource_handle.h"
+#include "iotcon/ResourceHandle.h"
#include "../conv_json.h"
-#include "../discovery_mgr_impl.h"
-#include "iotcon/service_adapter.h"
-#include "iotcon/device_adapter.h"
+#include "../DiscoveryManager.h"
+#include "iotcon/ServiceAdapter.h"
+#include "iotcon/DeviceAdapter.h"
-#include "../util.h"
+#include "../Util.h"
using namespace std;
-typedef std::map<std::string, conv::resource_handle> resource_h_map_t;
+typedef std::map<std::string, conv::ResourceHandle> resource_h_map_t;
static resource_h_map_t* resource_h_map = NULL;
typedef std::list <string> discovery_complete_list_t;
-typedef std::map <string, conv::resource_handle> discovery_process_map_t;
+typedef std::map <string, conv::ResourceHandle> discovery_process_map_t;
static discovery_complete_list_t discovery_complete_list;
static discovery_process_map_t discovery_process_map;
-conv::iotcon_discovery_provider::iotcon_discovery_provider()
+conv::IotconDiscoveryProvider::IotconDiscoveryProvider()
{
}
-conv::iotcon_discovery_provider::~iotcon_discovery_provider()
+conv::IotconDiscoveryProvider::~IotconDiscoveryProvider()
{
}
-int conv::iotcon_discovery_provider::init()
+int conv::IotconDiscoveryProvider::init()
{
int ret = iotcon_initialize(CONV_IOTCON_FILEPATH);
if (ret != IOTCON_ERROR_NONE) {
delete resource_h_map;
resource_h_map = new(std::nothrow) resource_h_map_t;
- _D("iotcon_discovery_provider init done");
+ _D("IotconDiscoveryProvider init done");
return CONV_ERROR_NONE;
}
-int conv::iotcon_discovery_provider::release()
+int conv::IotconDiscoveryProvider::release()
{
iotcon_deinitialize();
return true;
}
-int conv::iotcon_discovery_provider::notice_discovered(service_iface* service)
+int conv::IotconDiscoveryProvider::notice_discovered(IService* service)
{
return CONV_ERROR_NONE;
}
-void conv::iotcon_discovery_provider::_on_response_get(iotcon_remote_resource_h resource,
+void conv::IotconDiscoveryProvider::_on_response_get(iotcon_remote_resource_h resource,
iotcon_response_h response, void* user_data)
{
_D("On Response Get..");
return; // Already done pushing upwards..
// Retreive info from process_map..
- resource_handle cur_resource_h;
+ ResourceHandle cur_resource_h;
discovery_process_map_t::iterator itor_process;
itor_process = discovery_process_map.find(discoveryKey);
_D("Check if key[%s] exists in process_map", discoveryKey.c_str());
IF_FAIL_VOID_TAG((ret == IOTCON_ERROR_NONE), _E, "iotcon_attributes_get_str() Fail[%d]", ret);
cur_resource_h.set_device_id(string(device_id));
- if ( conv::util::get_device_id().compare(device_id) == 0 ) {
+ if ( conv::util::getDeviceId().compare(device_id) == 0 ) {
_D("the device has found itself..[device_id:%s].. out!", device_id);
return;
}
, device_id, device_name, device_type, version, service_list);
if (_discovery_manager != NULL) {
- device_adapter* device = new(std::nothrow) device_adapter (cur_resource_h);
+ DeviceAdapter* device = new(std::nothrow) DeviceAdapter (cur_resource_h);
int num_service = service_list_json.array_get_size(NULL, "service_list");
for (int index = 0; index < num_service; index++) {
continue;
}
- service_adapter* serv = new(std::nothrow) service_adapter(cur_resource_h);
+ ServiceAdapter* serv = new(std::nothrow) ServiceAdapter(cur_resource_h);
json serv_info_json;
cur_service_json.get(NULL, CONV_JSON_DISCOVERY_SERVICE_TYPE, &serv_type_int);
discovery_complete_list.push_back(discoveryKey);
}
-bool conv::iotcon_discovery_provider::_get_str_list_cb(int pos, const char* value, void* user_data)
+bool conv::IotconDiscoveryProvider::_get_str_list_cb(int pos, const char* value, void* user_data)
{
json* service_list = (json*) user_data;
service_list->array_append(NULL, "services_list", string(value));
return IOTCON_FUNC_CONTINUE;
}
-void conv::iotcon_discovery_provider::on_received_detail_info(iotcon_remote_resource_h resource, iotcon_error_e error,
+void conv::IotconDiscoveryProvider::on_received_detail_info(iotcon_remote_resource_h resource, iotcon_error_e error,
iotcon_request_type_e request_type, iotcon_response_h response,
void* user_data)
{
}
}
-void conv::iotcon_discovery_provider::_get_detail_info(iotcon_remote_resource_h resource)
+void conv::IotconDiscoveryProvider::_get_detail_info(iotcon_remote_resource_h resource)
{
iotcon_query_h query;
iotcon_remote_resource_h resource_clone = NULL;
}
}
-string conv::iotcon_discovery_provider::generateDiscoveryKey(char* uri_path, char* host_address)
+string conv::IotconDiscoveryProvider::generateDiscoveryKey(char* uri_path, char* host_address)
{
return string(host_address) + string(uri_path);
}
-int conv::iotcon_discovery_provider::add_iot_resource(iotcon_remote_resource_h resource)
+int conv::IotconDiscoveryProvider::add_iot_resource(iotcon_remote_resource_h resource)
{
_D("add_iot_resource called..");
- resource_handle iot_resource_h;
+ ResourceHandle iot_resource_h;
char* resource_uri_path = NULL;
char* resource_host = NULL;
// interface - IOTCON_INTERFACE_ DEFAULT / LINK / BATCH / GROUP
iotcon_remote_resource_get_interfaces(resource, &resource_interfaces);
- resource_handle res_handle;
+ ResourceHandle res_handle;
// uri_path
res_handle.set_uri_path(string(resource_uri_path));
// host_address
return CONV_ERROR_NONE;
}
-bool conv::iotcon_discovery_provider::_found_resource(iotcon_remote_resource_h resource, iotcon_error_e result, void *user_data)
+bool conv::IotconDiscoveryProvider::_found_resource(iotcon_remote_resource_h resource, iotcon_error_e result, void *user_data)
{
_D("_found_resource called..");
return IOTCON_FUNC_CONTINUE;
}
-int conv::iotcon_discovery_provider::start()
+int conv::IotconDiscoveryProvider::start()
{
int ret;
_D("iotcon discovery provider start..");
return CONV_ERROR_NONE;
}
-int conv::iotcon_discovery_provider::stop()
+int conv::IotconDiscoveryProvider::stop()
{
return CONV_ERROR_NONE;
}
#include <glib.h>
#include <vector>
#include <map>
-#include "../discovery_provider_base.h"
+#include "../IDiscoveryProvider.h"
#include "../request.h"
-#include "../service_iface.h"
-#include "iotcon/resource_handle.h"
-
-using namespace std;
+#include "../IService.h"
+#include "iotcon/ResourceHandle.h"
namespace conv {
- class iotcon_discovery_provider : public discovery_provider_base {
+ class IotconDiscoveryProvider : public IDiscoveryProvider {
private:
static bool _found_resource(iotcon_remote_resource_h resource, iotcon_error_e result,
static bool _get_str_list_cb(int pos, const char* value, void* user_data);
public:
- iotcon_discovery_provider();
- ~iotcon_discovery_provider();
+ IotconDiscoveryProvider();
+ ~IotconDiscoveryProvider();
int init();
int release();
int start();
int stop();
- static int notice_discovered(service_iface* service);
+ static int notice_discovered(IService* service);
};
}
#endif /* __SMARTVIEW_DISCOVERY_PROVIDER_H__ */
* limitations under the License.
*/
-#include "smartview_discovery_provider.h"
+#include "SmartviewDiscoveryProvider.h"
-#include "../discovery_mgr_impl.h"
+#include "../DiscoveryManager.h"
#include "../conv_json.h"
-#include "../util.h"
+#include "../Util.h"
using namespace std;
class SearchListenerImpl : public SearchListener {
private:
- conv::discovery_manager_impl* disc_manager;
- conv::smartview_discovery_provider* disc_provider;
+ conv::DiscoveryManager* disc_manager;
+ conv::SmartviewDiscoveryProvider* disc_provider;
public:
- void set_discovery_manager(conv::discovery_manager_impl* discovery_manager)
+ void set_discovery_manager(conv::DiscoveryManager* discovery_manager)
{
this->disc_manager = discovery_manager;
}
- void set_discovery_provider(conv::smartview_discovery_provider* discovery_provider)
+ void set_discovery_provider(conv::SmartviewDiscoveryProvider* discovery_provider)
{
this->disc_provider = discovery_provider;
}
static SearchListenerImpl* listener_impl = NULL;
-conv::smartview_discovery_provider::smartview_discovery_provider()
+conv::SmartviewDiscoveryProvider::SmartviewDiscoveryProvider()
{
}
-conv::smartview_discovery_provider::~smartview_discovery_provider()
+conv::SmartviewDiscoveryProvider::~SmartviewDiscoveryProvider()
{
}
-int conv::smartview_discovery_provider::init()
+int conv::SmartviewDiscoveryProvider::init()
{
_D("smartview_discovery init");
search = new(std::nothrow) Search();
return CONV_ERROR_NONE;
}
-int conv::smartview_discovery_provider::release()
+int conv::SmartviewDiscoveryProvider::release()
{
if ( search != NULL ) {
delete search;
return CONV_ERROR_NONE;
}
-int conv::smartview_discovery_provider::start()
+int conv::SmartviewDiscoveryProvider::start()
{
// Cache init..
cache.clear();
return CONV_ERROR_NONE;
}
-int conv::smartview_discovery_provider::stop()
+int conv::SmartviewDiscoveryProvider::stop()
{
_D("smartview_discovery stop");
search->stop();
return CONV_ERROR_NONE;
}
-conv::device* conv::smartview_discovery_provider::convert_into_conv_device(Service* smartview_service)
+conv::device* conv::SmartviewDiscoveryProvider::convert_into_conv_device(Service* smartview_service)
{
string serv_name, serv_version, serv_type, serv_id, serv_uri;
return device_info;
}
-conv::service* conv::smartview_discovery_provider::convert_into_conv_service(Service* smartview_service)
+conv::service* conv::SmartviewDiscoveryProvider::convert_into_conv_service(Service* smartview_service)
{
string serv_name, serv_version, serv_type, serv_id, serv_uri;
return conv_service;
}
-int conv::smartview_discovery_provider::removeFromCache(conv::service* conv_service)
+int conv::SmartviewDiscoveryProvider::removeFromCache(conv::service* conv_service)
{
string cache_key = conv_service->getUri();
cache.erase(cache_key);
return CONV_ERROR_NONE;
}
-int conv::smartview_discovery_provider::checkExistence(conv::service* conv_service)
+int conv::SmartviewDiscoveryProvider::checkExistence(conv::service* conv_service)
{
_D("Check Existence : ");
conv_service->printInfo();
}
}
-int conv::smartview_discovery_provider::notice_discovered(Service* service, bool bDiscovered)
+int conv::SmartviewDiscoveryProvider::notice_discovered(Service* service, bool bDiscovered)
{
_D("Notice Discovered called with service[%x]", service);
_D("Success in converting into flow.service[%x] .device[%x]", conv_service, conv_device);
- if ( conv::util::get_device_id().compare(conv_service->getId()) == 0 ) {
+ if ( conv::util::getDeviceId().compare(conv_service->getId()) == 0 ) {
_D("the device has found itself..[device_id:%s].. out!", conv_service->getId().c_str());
if(conv_device != NULL) delete conv_device;
if(conv_service != NULL) delete conv_service;
#include <vector>
#include <map>
-#include "../discovery_provider_base.h"
+#include "../IDiscoveryProvider.h"
#include "../request.h"
#include "smartview/service.h"
#include "smartview/device.h"
namespace conv {
- class smartview_discovery_provider : public discovery_provider_base {
+ class SmartviewDiscoveryProvider : public IDiscoveryProvider {
public:
- smartview_discovery_provider();
- ~smartview_discovery_provider();
+ SmartviewDiscoveryProvider();
+ ~SmartviewDiscoveryProvider();
int init();
int release();
* limitations under the License.
*/
-#include "wifi_direct_discovery_provider.h"
-#include "../discovery_mgr_impl.h"
+#include "WifiDirectDiscoveryProvider.h"
+#include "../DiscoveryManager.h"
#include <net_connection.h>
#include <wifi-direct.h>
using namespace std;
-conv::wifi_direct_discovery_provider::wifi_direct_discovery_provider()
+conv::WifiDirectDiscoveryProvider::WifiDirectDiscoveryProvider()
{
}
-conv::wifi_direct_discovery_provider::~wifi_direct_discovery_provider()
+conv::WifiDirectDiscoveryProvider::~WifiDirectDiscoveryProvider()
{
}
#endif
#if 0 // TODO: make and notice if it's device support d2d
- conv::wifi_direct_discovery_provider* disc_provider = (conv::wifi_direct_discovery_provider*)user_data;
+ conv::WifiDirectDiscoveryProvider* disc_provider = (conv::WifiDirectDiscoveryProvider*)user_data;
conv::service *conv_service = new(std::nothrow) conv::service;
conv_service->setName(peer->device_name);
return result;
}
-int conv::wifi_direct_discovery_provider::init()
+int conv::WifiDirectDiscoveryProvider::init()
{
//init_wfd_client((void*)this);
- _D("wifi_direct_discovery_provider init done");
+ _D("WifiDirectDiscoveryProvider init done");
return CONV_ERROR_NONE;
}
-int conv::wifi_direct_discovery_provider::release()
+int conv::WifiDirectDiscoveryProvider::release()
{
return CONV_ERROR_NONE;
}
-int conv::wifi_direct_discovery_provider::start()
+int conv::WifiDirectDiscoveryProvider::start()
{
//return start_wfd_discovery();
return CONV_ERROR_NONE;
}
-int conv::wifi_direct_discovery_provider::stop()
+int conv::WifiDirectDiscoveryProvider::stop()
{
return CONV_ERROR_NONE;
}
-int conv::wifi_direct_discovery_provider::checkExistence(conv::service* conv_service)
+int conv::WifiDirectDiscoveryProvider::checkExistence(conv::service* conv_service)
{
// print conv_service Info..
_D("Check Existence : %s", conv_service->getName().c_str());
}
}
-int conv::wifi_direct_discovery_provider::notice_discovered(conv::service* conv_service)
+int conv::WifiDirectDiscoveryProvider::notice_discovered(conv::service* conv_service)
{
_D("Notice Discovered called with service[%x]", conv_service);
#include <vector>
#include <map>
-#include "../discovery_provider_base.h"
+#include "../IDiscoveryProvider.h"
#include "../request.h"
#include "smartview/service.h"
namespace conv {
- class wifi_direct_discovery_provider : public discovery_provider_base {
+ class WifiDirectDiscoveryProvider : public IDiscoveryProvider {
public:
- wifi_direct_discovery_provider();
- ~wifi_direct_discovery_provider();
+ WifiDirectDiscoveryProvider();
+ ~WifiDirectDiscoveryProvider();
int init();
int release();
* limitations under the License.
*/
-#include "device_adapter.h"
+#include "DeviceAdapter.h"
#include <algorithm>
#include <functional>
using namespace std;
-conv::device_adapter::device_adapter(resource_handle res_h)
+conv::DeviceAdapter::DeviceAdapter(ResourceHandle resourceHandle)
{
- this->m_resource_h = res_h;
+ this->m_resource_h = resourceHandle;
}
-conv::device_adapter::~device_adapter()
+conv::DeviceAdapter::~DeviceAdapter()
{
}
-static bool serviceComparision(conv::service_iface* obj, int serviceType)
+static bool serviceComparision(conv::IService* obj, int serviceType)
{
if (obj->getServiceType() == serviceType)
return true;
return false;
}
-int conv::device_adapter::add_service(service_iface* service_obj)
+int conv::DeviceAdapter::add_service(IService* service_obj)
{
service_list_t::iterator itr;
itr = std::find_if(service_list.begin(), service_list.end(), std::bind(serviceComparision, std::placeholders::_1, service_obj->getServiceType()));
return CONV_ERROR_NONE;
}
-int conv::device_adapter::remove_service(service_iface* service_obj)
+int conv::DeviceAdapter::remove_service(IService* service_obj)
{
service_list.remove(service_obj);
return CONV_ERROR_NONE;
}
-string conv::device_adapter::getName()
+string conv::DeviceAdapter::getName()
{
return m_resource_h.get_device_name();
}
-string conv::device_adapter::getId()
+string conv::DeviceAdapter::getId()
{
return m_resource_h.get_device_id();
}
-string conv::device_adapter::getAddress()
+string conv::DeviceAdapter::getAddress()
{
return m_resource_h.get_host_address();
}
-int conv::device_adapter::get_services_list(std::list<service_iface*> *list)
+int conv::DeviceAdapter::get_services_list(std::list<IService*> *list)
{
for (service_list_t::iterator iterPos = service_list.begin(); iterPos != service_list.end(); ++iterPos) {
list->push_back(*iterPos);
#ifndef __DEVICE_ADAPTER_H__
#define __DEVICE_ADAPTER_H__
-#include "../../device_iface.h"
-#include "resource_handle.h"
+#include "../../IDevice.h"
+#include "ResourceHandle.h"
#include <list>
#include <string>
namespace conv {
- class device_adapter : public device_iface {
+ class DeviceAdapter : public IDevice {
public :
- typedef std::list<service_iface*> service_list_t;
- device_adapter(resource_handle res_h);
- ~device_adapter();
+ typedef std::list<IService*> service_list_t;
+ DeviceAdapter(ResourceHandle res_h);
+ ~DeviceAdapter();
- int add_service(service_iface* service_obj);
- int remove_service(service_iface* service_obj);
- int get_services_list(std::list<service_iface*> *list);
+ int add_service(IService* service_obj);
+ int remove_service(IService* service_obj);
+ int get_services_list(std::list<IService*> *list);
string getName();
string getId();
string getAddress();
private :
- resource_handle m_resource_h;
+ ResourceHandle m_resource_h;
service_list_t service_list;
};
}
* limitations under the License.
*/
-#include "resource_handle.h"
+#include "ResourceHandle.h"
#include "d2d_conv_manager.h"
using namespace std;
-int conv::resource_handle::set_device_id(string dev_id)
+int conv::ResourceHandle::set_device_id(string dev_id)
{
this->device_id = dev_id;
return CONV_ERROR_NONE;
}
-string conv::resource_handle::get_device_id()
+string conv::ResourceHandle::get_device_id()
{
return this->device_id;
}
-int conv::resource_handle::set_device_name(string dev_name)
+int conv::ResourceHandle::set_device_name(string dev_name)
{
this->device_name = dev_name;
return CONV_ERROR_NONE;
}
-string conv::resource_handle::get_device_name()
+string conv::ResourceHandle::get_device_name()
{
return device_name;
}
-int conv::resource_handle::set_device_type(string dev_type)
+int conv::ResourceHandle::set_device_type(string dev_type)
{
this->device_type = dev_type;
return CONV_ERROR_NONE;
}
-string conv::resource_handle::get_device_type()
+string conv::ResourceHandle::get_device_type()
{
return device_type;
}
-int conv::resource_handle::set_version(string ver)
+int conv::ResourceHandle::set_version(string ver)
{
this->version = ver;
return CONV_ERROR_NONE;
}
-string conv::resource_handle::get_version()
+string conv::ResourceHandle::get_version()
{
return version;
}
-int conv::resource_handle::set_services_list(string list)
+int conv::ResourceHandle::set_services_list(string list)
{
this->services_list = json(list);
return CONV_ERROR_NONE;
}
-int conv::resource_handle::set_uri_path(string uri_path)
+int conv::ResourceHandle::set_uri_path(string uri_path)
{
this->uri_path = uri_path;
return CONV_ERROR_NONE;
}
-string conv::resource_handle::get_uri_path()
+string conv::ResourceHandle::get_uri_path()
{
return uri_path;
}
-int conv::resource_handle::set_host_address(string host_address)
+int conv::ResourceHandle::set_host_address(string host_address)
{
this->host_address = host_address;
return CONV_ERROR_NONE;
}
-string conv::resource_handle::get_host_address()
+string conv::ResourceHandle::get_host_address()
{
return host_address;
}
-list<string>& conv::resource_handle::get_types()
+list<string>& conv::ResourceHandle::get_types()
{
return types;
}
-int conv::resource_handle::add_types(string type)
+int conv::ResourceHandle::add_types(string type)
{
types.push_back(type);
return CONV_ERROR_NONE;
}
-list<string>& conv::resource_handle::get_interfaces()
+list<string>& conv::ResourceHandle::get_interfaces()
{
return interfaces;
}
-int conv::resource_handle::add_interfaces(string interface)
+int conv::ResourceHandle::add_interfaces(string interface)
{
interfaces.push_back(interface);
return CONV_ERROR_NONE;
}
-
-
* limitations under the License.
*/
-#ifndef _RESOURCE_HANDLE_H__
-#define _RESOURCE_HANDLE_H__
+#ifndef __RESOURCE_HANDLE_H__
+#define __RESOURCE_HANDLE_H__
#include <list>
#include <string>
using namespace std;
namespace conv{
-class resource_handle {
+class ResourceHandle {
private:
string uri_path;
string host_address;
* limitations under the License.
*/
-#include "service_adapter.h"
+#include "ServiceAdapter.h"
using namespace std;
-conv::service_adapter::service_adapter(resource_handle res_h)
+conv::ServiceAdapter::ServiceAdapter(ResourceHandle resourceHandle)
{
- this->m_resource_h = res_h;
+ this->m_resource_h = resourceHandle;
}
-conv::service_adapter::~service_adapter()
+conv::ServiceAdapter::~ServiceAdapter()
{
}
-string conv::service_adapter::getName()
+string conv::ServiceAdapter::getName()
{
return m_resource_h.get_device_name();
}
-string conv::service_adapter::getVersion()
+string conv::ServiceAdapter::getVersion()
{
return m_resource_h.get_version();
}
-string conv::service_adapter::getType()
+string conv::ServiceAdapter::getType()
{
return m_resource_h.get_device_type();
}
-string conv::service_adapter::getId()
+string conv::ServiceAdapter::getId()
{
return m_resource_h.get_device_id();
}
-string conv::service_adapter::getUri()
+string conv::ServiceAdapter::getUri()
{
string uri_path = m_resource_h.get_uri_path();
string host_address = m_resource_h.get_host_address();
return host_address + uri_path;
}
-int conv::service_adapter::getServiceType()
+int conv::ServiceAdapter::getServiceType()
{
return service_type;
}
-int conv::service_adapter::setServiceType(int serviceType)
+int conv::ServiceAdapter::setServiceType(int serviceType)
{
this->service_type = serviceType;
return CONV_ERROR_NONE;
}
-int conv::service_adapter::setServiceInfo(string serviceInfo)
+int conv::ServiceAdapter::setServiceInfo(string serviceInfo)
{
this->service_info = serviceInfo;
return CONV_ERROR_NONE;
}
-string conv::service_adapter::getServiceInfo()
+string conv::ServiceAdapter::getServiceInfo()
{
return service_info;
}
#ifndef __SERVICE_ADAPTER_H__
#define __SERVICE_ADAPTER_H__
-#include "../../service_iface.h"
-#include "resource_handle.h"
+#include "../../IService.h"
+#include "ResourceHandle.h"
namespace conv {
- class service_adapter : public service_iface {
+ class ServiceAdapter : public IService {
public:
- service_adapter(resource_handle res_h);
- ~service_adapter();
+ ServiceAdapter(ResourceHandle resourceHandle);
+ ~ServiceAdapter();
string getName();
string getVersion();
int setServiceInfo(string serviceInfo);
private:
- resource_handle m_resource_h;
+ ResourceHandle m_resource_h;
int service_type;
string service_info;
#include <glib.h>
#include "device.h"
-#include "log.h"
+#include "Log.h"
#include "d2d_conv_manager.h"
#include <algorithm>
#include <functional>
}
};
-static bool serviceComparision(conv::service_iface* obj, int serviceType)
+static bool serviceComparision(conv::IService* obj, int serviceType)
{
if (obj->getServiceType() == serviceType)
return true;
return false;
}
-int conv::device::add_service(service_iface* service_obj)
+int conv::device::add_service(IService* service_obj)
{
service_list_t::iterator itr;
itr = std::find_if(service_list.begin(), service_list.end(), std::bind(serviceComparision, std::placeholders::_1, service_obj->getServiceType()));
return CONV_ERROR_NONE;
}
-int conv::device::remove_service(service_iface* service_obj)
+int conv::device::remove_service(IService* service_obj)
{
service_list.remove(service_obj);
return CONV_ERROR_NONE;
return ip_address;
}
-int conv::device::get_services_list(std::list<service_iface*> *list)
+int conv::device::get_services_list(std::list<IService*> *list)
{
for (service_list_t::iterator iterPos = service_list.begin(); iterPos != service_list.end(); ++iterPos)
{
#include <string>
#include <vector>
-#include "../../service_iface.h"
+#include "../../IService.h"
#include "../../conv_json.h"
-#include "../../device_iface.h"
+#include "../../IDevice.h"
namespace conv {
- class device : public device_iface {
+ class device : public IDevice {
public:
- typedef std::list<service_iface*> service_list_t;
+ typedef std::list<IService*> service_list_t;
device();
~device();
- // functions from device_iface
- int add_service(service_iface* service_obj);
- int remove_service(service_iface* service_obj);
- int get_services_list(std::list<service_iface*> *list);
+ // functions from IDevice
+ int add_service(IService* service_obj);
+ int remove_service(IService* service_obj);
+ int get_services_list(std::list<IService*> *list);
std::string getName();
std::string getId();
std::string getAddress();
#include <string>
#include "../../conv_json.h"
-#include "../../service_iface.h"
+#include "../../IService.h"
using namespace std;
namespace conv
{
- class service : public service_iface {
+ class service : public IService {
public:
service();
~service();
- // functions from service_iface
+ // functions from IService
string getName();
string getVersion();
string getType();
*/
#include <glib.h>
-#include "common.h"
+#include "Types.h"
#include "request.h"
-#include "dbus_server_impl.h"
+#include "DbusServer.h"
conv::request::request(int type, const char* client, int req_id, const char* subj, const char* desc)
: _type(type)
conv::request::request(int type,
const char *client, int req_id, const char *subj, const char *desc,
- const char *sender, credentials *creds, GDBusMethodInvocation *inv)
+ const char *sender, Credentials *creds, GDBusMethodInvocation *inv)
: _type(type)
, _req_id(req_id)
, _client(client)
return _description;
}
-conv::credentials* conv::request::get_creds()
+conv::Credentials* conv::request::get_creds()
{
return __creds;
}
#include <string>
#include <gio/gio.h>
-#include "common.h"
+#include "Types.h"
#include "conv_json.h"
-#include "service_info_base.h"
-#include "communication_info_base.h"
-#include "access_control/peer_creds.h"
+#include "IServiceInfo.h"
+#include "ICommunicationInfo.h"
+#include "access_control/PeerCreds.h"
namespace conv {
class request {
request(int type, const char *client, int req_id, const char *subj, const char *desc);
request(int type,
const char *client, int req_id, const char *subj, const char *desc,
- const char *sender, credentials *creds, GDBusMethodInvocation *inv);
+ const char *sender, Credentials *creds, GDBusMethodInvocation *inv);
~request();
int get_type();
const char *get_sender();
const char *get_subject();
json& get_description();
- credentials *get_creds();
+ Credentials *get_creds();
bool reply(int error);
bool reply(int error, json &request_result);
bool reply(int error, json &request_result, json &data_read);
std::string service_type;
std::string connection_type;
- service_info_base* service_info;
- communication_info_base* communication_info;
+ IServiceInfo* service_info;
+ ICommunicationInfo* communication_info;
protected:
int _type;
std::string _client;
std::string _subject;
json _description;
- credentials *__creds;
+ Credentials *__creds;
std::string __sender;
GDBusMethodInvocation *__invocation;
};
+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "request_handler.h"
-#include "discovery_mgr_impl.h"
-#include "service_mgr_impl.h"
-#include "connection_mgr_impl.h"
-
-using namespace std;
-
-conv::request_handler::request_handler()
-{
-}
-
-conv::request_handler::~request_handler()
-{
-}
-
-int conv::request_handler::init()
-{
- return CONV_ERROR_NONE;
-}
-
-int conv::request_handler::release()
-{
- return CONV_ERROR_NONE;
-}
-
-int conv::request_handler::handle_request(request* request_obj)
-{
- _D("handle_request called");
- int result = CONV_ERROR_INVALID_OPERATION;
-
- switch (request_obj->get_type()) {
- case REQ_SUBSCRIBE:
- _D("Requested type : REQ_SUBSCRIBE..");
- if ( !strcmp(request_obj->get_subject(), CONV_SUBJECT_COMMUNICATION_RECV) )
- result = service_manager::handle_request(request_obj);
- else if ( !strcmp(request_obj->get_subject(), CONV_SUBJECT_CONNECTION_START) )
- result = connection_manager::handle_request(request_obj);
- break;
- case REQ_UNSUBSCRIBE:
- if (!strcmp(request_obj->get_subject(), CONV_SUBJECT_COMMUNICATION_RECV) )
- result = service_manager::handle_request(request_obj);
- else if ( !strcmp(request_obj->get_subject(), CONV_SUBJECT_CONNECTION_START) )
- result = connection_manager::handle_request(request_obj);
- break;
- case REQ_READ:
- break;
- case REQ_READ_SYNC:
- break;
- case REQ_WRITE:
- _D("Requested type : REQ_WRITE..");
- if (!strcmp(request_obj->get_subject(), CONV_SUBJECT_DISCOVERY_START) || !strcmp(request_obj->get_subject(), CONV_SUBJECT_DISCOVERY_STOP))
- return discovery_manager::handle_request (request_obj);
- else if ( !strcmp(request_obj->get_subject(), CONV_SUBJECT_COMMUNICATION_START) || !strcmp(request_obj->get_subject(), CONV_SUBJECT_COMMUNICATION_STOP)
- || !strcmp(request_obj->get_subject(), CONV_SUBJECT_COMMUNICATION_SET) || !strcmp(request_obj->get_subject(), CONV_SUBJECT_COMMUNICATION_GET))
- result = service_manager::handle_request(request_obj);
- else if ( !strcmp(request_obj->get_subject(), CONV_SUBJECT_CONNECTION_START) || !strcmp(request_obj->get_subject(), CONV_SUBJECT_CONNECTION_STOP) )
- result = connection_manager::handle_request(request_obj);
- break;
- case REQ_SUPPORT:
- break;
- default:
- _E("Invalid type of request");
- request_obj->reply(result);
- delete request_obj;
- }
-
- return result;
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <new>
-#include <gio/gio.h>
-
-
-#include "d2d_conv_manager.h"
-#include "server.h"
-#include "dbus_server_impl.h"
-#include "discovery_mgr_impl.h"
-#include "connection_mgr_impl.h"
-#include "client_mgr_impl.h"
-#include "service_mgr_impl.h"
-#include "request_handler.h"
-
-using namespace std;
-
-static GMainLoop *mainloop = NULL;
-static gboolean started = FALSE;
-static conv::dbus_server_impl *dbus_handle = NULL;
-static conv::discovery_manager_impl *discovery_mgr = NULL;
-static conv::connection_manager_impl *connection_mgr = NULL;
-static conv::client_manager_impl *client_mgr = NULL;
-static conv::service_manager_impl *service_mgr = NULL;
-static conv::request_handler *request_mgr = NULL;
-
-void conv::initialize()
-{
- int result;
-
- if (started) {
- _D("flowd is started already");
- return;
- }
-
- mainloop = g_main_loop_new(NULL, FALSE);
-
- _I("Init Discovery Manager");
- discovery_mgr = new(std::nothrow) conv::discovery_manager_impl();
- IF_FAIL_CATCH_TAG(discovery_mgr, _E, "Memory allocation failed");
- discovery_manager::set_instance(discovery_mgr);
- result = discovery_mgr->init();
- IF_FAIL_CATCH_TAG(result == CONV_ERROR_NONE, _E, "Initialization Failed");
-
- _I("Init Connection Manager");
- connection_mgr = new(std::nothrow) conv::connection_manager_impl();
- IF_FAIL_CATCH_TAG(connection_mgr, _E, "Memory allocation failed");
- connection_manager::set_instance(connection_mgr);
- result = connection_mgr->init();
- IF_FAIL_CATCH_TAG(result == CONV_ERROR_NONE, _E, "Initialization Failed");
-
- _I("Init Client Manager");
- client_mgr = new(std::nothrow) conv::client_manager_impl();
- IF_FAIL_CATCH_TAG(client_mgr, _E, "Memory allocation failed");
- client_manager::set_instance(client_mgr);
- result = client_mgr->init();
- IF_FAIL_CATCH_TAG(result == CONV_ERROR_NONE, _E, "Initialization Failed");
-
- _I("Init Service Manager");
- service_mgr = new(std::nothrow) conv::service_manager_impl();
- IF_FAIL_CATCH_TAG(service_mgr, _E, "Memory allocation failed");
- service_manager::set_instance(service_mgr);
- result = service_mgr->init();
- IF_FAIL_CATCH_TAG(result == CONV_ERROR_NONE, _E, "Initialization Failed");
-
- _I("Init Request Manager");
- request_mgr = new(std::nothrow) request_handler();
- IF_FAIL_CATCH_TAG(request_mgr, _E, "Memory allocation failed");
- result = request_mgr->init();
- IF_FAIL_CATCH_TAG(result == CONV_ERROR_NONE, _E, "Initialization Failed");
-
- _I("Init Dbus Server");
- dbus_handle = new(std::nothrow) conv::dbus_server_impl();
- IF_FAIL_CATCH_TAG(discovery_mgr, _E, "Memory allocation failed");
- dbus_server::set_instance(dbus_handle);
- result = dbus_handle->init();
- IF_FAIL_CATCH_TAG(result == true, _E, "Initialization Failed");
-
- _I("Start main loop");
- started = TRUE;
-
- g_main_loop_run(mainloop);
-
- return;
-
-CATCH:
- _E(RED("Launching Failed"));
-
- g_main_loop_quit(mainloop);
-}
-
-void conv::release()
-{
- _I(CYAN("Terminating flow-daemon"));
- _I("Release discovery manager");
- if (discovery_mgr)
- discovery_mgr->release();
-
- _I("Release connection manager");
- if (connection_mgr)
- connection_mgr->release();
-
- _I("Release dbus server");
- if (dbus_handle)
- dbus_handle->release();
-
- _I("Release client manager");
- if (client_mgr)
- client_mgr->release();
-
- _I("Release service manager");
- if (service_mgr)
- service_mgr->release();
-
- _I("Release request handler");
- if (request_mgr)
- request_mgr->release();
-
- g_main_loop_unref(mainloop);
-
- delete discovery_mgr;
- delete connection_mgr;
- delete dbus_handle;
- delete client_mgr;
- delete request_mgr;
- delete service_mgr;
- started = FALSE;
-}
-
-
-void conv::send_request(request* request_obj)
-{
- _D("send_request request_obj:%x request_mg:%x", request_obj, request_mgr);
- if (request_mgr) {
- request_mgr->handle_request(request_obj);
- } else if (request_obj) { //jhp27.park temp code..
- request_obj->reply(CONV_ERROR_NONE);
- }
-
- _D("request handling done");
-}
-
-static void signal_handler(int signo)
-{
- _I("SIGNAL %d received", signo);
-
- // Stop the main loop
- g_main_loop_quit(mainloop);
-}
-
-int main(int argc, char **argv)
-{
- static struct sigaction signal_action;
- signal_action.sa_handler = signal_handler;
- sigemptyset(&signal_action.sa_mask);
-
- sigaction(SIGINT, &signal_action, NULL);
- sigaction(SIGHUP, &signal_action, NULL);
- sigaction(SIGTERM, &signal_action, NULL);
- sigaction(SIGQUIT, &signal_action, NULL);
- sigaction(SIGABRT, &signal_action, NULL);
-
-#if !defined(GLIB_VERSION_2_36)
- g_type_init();
-#endif
-
- conv::initialize();
- conv::release();
-
- return EXIT_SUCCESS;
-}
#include <iotcon.h>
#include <glib.h>
#include <vector>
-#include "../service_info_base.h"
+#include "../IServiceInfo.h"
#include "../request.h"
#include "Service.h"
#include "Clients.h"
typedef vector<application_instance*> application_instance_list_t;
// service information to handle app-to-app service with specific device 'id'
- class app_comm_service_info : public service_info_base, public Result_Base {
+ class AppCommServiceInfo : public IServiceInfo, public Result_Base {
public:
void onSuccess(Service service)
{
get_service_result = false;
}
- ~app_comm_service_info()
+ ~AppCommServiceInfo()
{
if (registered_request != NULL) {
delete registered_request;
*/
#include <net_connection.h>
-#include "app_comm_service_provider.h"
-#include "../client_mgr_impl.h"
-#include "../util.h"
+#include "AppCommServiceProvider.h"
+#include "../ClientManager.h"
+#include "../Util.h"
using namespace std;
static void vconf_update_cb(keynode_t *node, void* user_data)
{
- conv::app_comm_service_provider* instance = static_cast<conv::app_comm_service_provider*>(user_data);
+ conv::AppCommServiceProvider* instance = static_cast<conv::AppCommServiceProvider*>(user_data);
IF_FAIL_VOID_TAG(instance, _E, "static_cast failed");
instance->handle_vconf_update(node);
}
-conv::app_comm_service_provider::app_comm_service_provider()
+conv::AppCommServiceProvider::AppCommServiceProvider()
{
_type = CONV_SERVICE_TYPE_SMARTVIEW_APP_COMMUNICATION;
_resource_type = CONV_RESOURCE_TYPE_SMARTVIEW_APP_COMMUNICATION;
_uri = CONV_URI_SMARTVIEW_APP_COMMUNICATION;
- if (conv::util::is_service_activated(CONV_INTERNAL_SERVICE_APP_TO_APP_COMMUNICATION))
+ if (conv::util::isServiceActivated(CONV_INTERNAL_SERVICE_APP_TO_APP_COMMUNICATION))
_activation_state = 1;
else
_activation_state = 0;
vconf_notify_key_changed(VCONFKEY_SETAPPL_D2D_CONVERGENCE_SERVICE, vconf_update_cb, this);
}
-int conv::app_comm_service_provider::handle_vconf_update(keynode_t *node)
+int conv::AppCommServiceProvider::handle_vconf_update(keynode_t *node)
{
int current_state = vconf_keynode_get_int(node);
return CONV_ERROR_NONE;
}
-conv::app_comm_service_provider::~app_comm_service_provider()
+conv::AppCommServiceProvider::~AppCommServiceProvider()
{
}
-int conv::app_comm_service_provider::init()
+int conv::AppCommServiceProvider::init()
{
- _D("app_comm_service_provider init done");
+ _D("AppCommServiceProvider init done");
return CONV_ERROR_NONE;
}
-int conv::app_comm_service_provider::release()
+int conv::AppCommServiceProvider::release()
{
- _D("app_comm_service_provider release done");
+ _D("AppCommServiceProvider release done");
return CONV_ERROR_NONE;
}
-int conv::app_comm_service_provider::load_service_info(request* request_obj)
+int conv::AppCommServiceProvider::load_service_info(request* request_obj)
{
IF_FAIL_RETURN_TAG(_activation_state == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
client = request_obj->get_sender();
_D("client id : %s", client.c_str());
- client_obj = conv::client_manager::get_client(client);
+ client_obj = conv::client_manager::getClient(client);
IF_FAIL_RETURN_TAG(client_obj, CONV_ERROR_OUT_OF_MEMORY, _E, "client info alloc failed");
- app_comm_service_info *svc_info = NULL;
+ AppCommServiceInfo *svc_info = NULL;
if (is_local == 1) {
- service_info_base* svc_info_base = client_obj->get_service_info(_type, "LOCAL_HOST");
+ IServiceInfo* svc_info_base = client_obj->get_service_info(_type, "LOCAL_HOST");
if ( svc_info_base != NULL ) {
_D("local service instance already exists");
- svc_info = reinterpret_cast<app_comm_service_info*>(svc_info_base);
+ svc_info = reinterpret_cast<AppCommServiceInfo*>(svc_info_base);
if (svc_info == NULL) {
_D("casting failed");
}
} else {
_D("allocating new service instance for local service");
- svc_info = new(std::nothrow) app_comm_service_info();
+ svc_info = new(std::nothrow) AppCommServiceInfo();
ASSERT_ALLOC(svc_info);
svc_info->is_local = true;
- client_obj->add_service_info(_type, "LOCAL_HOST", (service_info_base*)svc_info);
+ client_obj->add_service_info(_type, "LOCAL_HOST", (IServiceInfo*)svc_info);
_D("MSF service is created");
}
} else {
- service_info_base* svc_info_base = client_obj->get_service_info(_type, id);
+ IServiceInfo* svc_info_base = client_obj->get_service_info(_type, id);
if ( svc_info_base != NULL ) {
_D("service instance already exists");
- svc_info = reinterpret_cast<app_comm_service_info*>(svc_info_base);
+ svc_info = reinterpret_cast<AppCommServiceInfo*>(svc_info_base);
if (svc_info == NULL) {
_D("casting failed");
}
} else {
_D("allocating new service instance");
- svc_info = new(std::nothrow) app_comm_service_info();
+ svc_info = new(std::nothrow) AppCommServiceInfo();
ASSERT_ALLOC(svc_info);
_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->add_service_info(_type, id, (service_info_base*)svc_info);
+ client_obj->add_service_info(_type, id, (IServiceInfo*)svc_info);
_D("MSF service is created");
}
return CONV_ERROR_NONE;
}
-int conv::app_comm_service_provider::start_request(request* request_obj)
+int conv::AppCommServiceProvider::start_request(request* request_obj)
{
IF_FAIL_RETURN_TAG(_activation_state == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
_D("communcation/start requested");
- app_comm_service_info *svc_info = reinterpret_cast<app_comm_service_info*>(request_obj->service_info);
+ AppCommServiceInfo *svc_info = reinterpret_cast<AppCommServiceInfo*>(request_obj->service_info);
json channel;
request_obj->get_channel_from_description(&channel);
return CONV_ERROR_NONE;
}
-int conv::app_comm_service_provider::stop_request(request* request_obj)
+int conv::AppCommServiceProvider::stop_request(request* request_obj)
{
IF_FAIL_RETURN_TAG(_activation_state == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
_D("communcation/stop requested");
- app_comm_service_info *svc_info = reinterpret_cast<app_comm_service_info*>(request_obj->service_info);
+ AppCommServiceInfo *svc_info = reinterpret_cast<AppCommServiceInfo*>(request_obj->service_info);
json channel;
request_obj->get_channel_from_description(&channel);
}
-int conv::app_comm_service_provider::get_request(request* request_obj)
+int conv::AppCommServiceProvider::get_request(request* request_obj)
{
IF_FAIL_RETURN_TAG(_activation_state == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
_D("communcation/get requested");
- app_comm_service_info *svc_info = reinterpret_cast<app_comm_service_info*>(request_obj->service_info);
+ AppCommServiceInfo *svc_info = reinterpret_cast<AppCommServiceInfo*>(request_obj->service_info);
json channel;
request_obj->get_channel_from_description(&channel);
return CONV_ERROR_INVALID_OPERATION;
}
-int conv::app_comm_service_provider::send_read_response(json payload, const char* read_type, conv_error_e error, request* request_obj)
+int conv::AppCommServiceProvider::send_read_response(json payload, const char* read_type, conv_error_e error, request* request_obj)
{
_D(RED("publishing_response"));
IF_FAIL_RETURN_TAG(request_obj != NULL, CONV_ERROR_INVALID_OPERATION, _E, "listener_cb is not registered");
return CONV_ERROR_NONE;
}
-int conv::app_comm_service_provider::set_request(request* request_obj)
+int conv::AppCommServiceProvider::set_request(request* request_obj)
{
IF_FAIL_RETURN_TAG(_activation_state == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
_D("communcation/set requested");
- app_comm_service_info *svc_info = reinterpret_cast<app_comm_service_info*>(request_obj->service_info);
+ AppCommServiceInfo *svc_info = reinterpret_cast<AppCommServiceInfo*>(request_obj->service_info);
json channel;
request_obj->get_channel_from_description(&channel);
return CONV_ERROR_NONE;
}
-int conv::app_comm_service_provider::register_request(request* request_obj)
+int conv::AppCommServiceProvider::register_request(request* request_obj)
{
IF_FAIL_RETURN_TAG(_activation_state == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
_D("communcation/recv requested");
- app_comm_service_info *svc_info = reinterpret_cast<app_comm_service_info*>(request_obj->service_info);
+ AppCommServiceInfo *svc_info = reinterpret_cast<AppCommServiceInfo*>(request_obj->service_info);
switch (request_obj->get_type()) {
case REQ_SUBSCRIBE:
return CONV_ERROR_NONE;
}
-int conv::app_comm_service_provider::get_service_info_for_discovery(json* json_obj)
+int conv::AppCommServiceProvider::get_service_info_for_discovery(json* json_obj)
{
IF_FAIL_RETURN_TAG(_activation_state == 1, CONV_ERROR_NOT_SUPPORTED, _E, "service provider is not activated");
#include <glib.h>
#include <vector>
#include <vconf.h>
-#include "../service_provider_base.h"
-#include "app_comm_service_info.h"
+#include "../IServiceProvider.h"
+#include "AppCommServiceInfo.h"
namespace conv {
- class app_comm_service_provider : public service_provider_base {
+ class AppCommServiceProvider : public IServiceProvider {
public:
- app_comm_service_provider();
- ~app_comm_service_provider();
+ AppCommServiceProvider();
+ ~AppCommServiceProvider();
int init();
int release();
- app_comm_service_info* get_svc_info(request* request_obj);
+ AppCommServiceInfo* get_svc_info(request* request_obj);
int start_request(request* request_obj);
int stop_request(request* request_obj);
int get_request(request* request_obj);
#include <iotcon.h>
#include <glib.h>
#include <vector>
-#include "../service_info_base.h"
-#include "../iotcon_communication_info.h"
+#include "../IServiceInfo.h"
+#include "../IotconCommunicationInfo.h"
#include "../request.h"
#include <iotcon.h>
namespace conv {
- class remote_app_control_service_info : public service_info_base {
+ class RemoteAppControlServiceInfo : public IServiceInfo {
public:
- ~remote_app_control_service_info()
+ ~RemoteAppControlServiceInfo()
{
if ( registered_request != NULL )
{
std::string device_name;
std::string device_address;
request* registered_request;
- iotcon_communication_info iotcon_info_obj;
+ IotconCommunicationInfo iotcon_info_obj;
};
}
#include <bundle.h>
#include <bundle_internal.h>
#include <app_control_internal.h>
-#include "remote_app_control_service_provider.h"
-#include "../client_mgr_impl.h"
-#include "../util.h"
+#include "RemoteAppControlServiceProvider.h"
+#include "../ClientManager.h"
+#include "../Util.h"
using namespace std;
static void vconf_update_cb(keynode_t *node, void* user_data)
{
- conv::remote_app_control_service_provider* instance = static_cast<conv::remote_app_control_service_provider*>(user_data);
+ conv::RemoteAppControlServiceProvider* instance = static_cast<conv::RemoteAppControlServiceProvider*>(user_data);
IF_FAIL_VOID_TAG(instance, _E, "static_cast failed");
instance->handle_vconf_update(node);
}
-conv::remote_app_control_service_provider::remote_app_control_service_provider()
+conv::RemoteAppControlServiceProvider::RemoteAppControlServiceProvider()
{
_type = CONV_SERVICE_TYPE_REMOTE_APP_CONTROL;
_resource_type = CONV_RESOURCE_TYPE_REMOTE_APP_CONTROL;
_uri = CONV_URI_REMOTE_APP_CONTROL;
iotcon_resource = NULL;
- if (conv::util::is_service_activated(CONV_INTERNAL_SERVICE_REMOTE_APP_CONTROL))
+ if (conv::util::isServiceActivated(CONV_INTERNAL_SERVICE_REMOTE_APP_CONTROL))
_activation_state = 1;
else
_activation_state = 0;
vconf_notify_key_changed(VCONFKEY_SETAPPL_D2D_CONVERGENCE_SERVICE, vconf_update_cb, this);
}
-conv::remote_app_control_service_provider::~remote_app_control_service_provider()
+conv::RemoteAppControlServiceProvider::~RemoteAppControlServiceProvider()
{
app_control_cb_map.clear();
response_cb_map.clear();
}
-int conv::remote_app_control_service_provider::handle_vconf_update(keynode_t *node)
+int conv::RemoteAppControlServiceProvider::handle_vconf_update(keynode_t *node)
{
int current_state = vconf_keynode_get_int(node);
return CONV_ERROR_NONE;
}
-void conv::remote_app_control_service_provider::iotcon_request_cb(iotcon_resource_h resource, iotcon_request_h request, void *user_data)
+void conv::RemoteAppControlServiceProvider::iotcon_request_cb(iotcon_resource_h resource, iotcon_request_h request, void *user_data)
{
_D("request cb called");
}
}
-int conv::remote_app_control_service_provider::init()
+int conv::RemoteAppControlServiceProvider::init()
{
if (iotcon_resource == NULL) {
// register resource
iotcon_resource_types_destroy(resource_types);
iotcon_resource_interfaces_destroy(resource_ifaces);
- _D("remote_app_control_service_provider init done");
+ _D("RemoteAppControlServiceProvider init done");
} else {
- _D("remote_app_control_service_provider is already initiated");
+ _D("RemoteAppControlServiceProvider is already initiated");
}
return CONV_ERROR_NONE;
}
-int conv::remote_app_control_service_provider::release()
+int conv::RemoteAppControlServiceProvider::release()
{
if (iotcon_resource == NULL) {
- _D("remote_app_control_service_provider is already released");
+ _D("RemoteAppControlServiceProvider is already released");
} else {
// unregister resource
int error = iotcon_resource_destroy(iotcon_resource);
return CONV_ERROR_NONE;
}
-int conv::remote_app_control_service_provider::start_request(request* request_obj)
+int conv::RemoteAppControlServiceProvider::start_request(request* request_obj)
{
IF_FAIL_RETURN_TAG(_activation_state == 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;
- remote_app_control_service_info *svc_info = reinterpret_cast<remote_app_control_service_info*>(request_obj->service_info);
+ RemoteAppControlServiceInfo *svc_info = reinterpret_cast<RemoteAppControlServiceInfo*>(request_obj->service_info);
if (svc_info->iotcon_info_obj.iotcon_resource_handle != NULL) {
_D("already started");
return CONV_ERROR_NONE;
}
-int conv::remote_app_control_service_provider::send_response(json payload, const char* request_type, conv_error_e error, request* request_obj)
+int conv::RemoteAppControlServiceProvider::send_response(json payload, const char* request_type, conv_error_e error, request* request_obj)
{
_D(RED("publishing_response"));
IF_FAIL_RETURN_TAG(request_obj != NULL, CONV_ERROR_INVALID_OPERATION, _E, "listener_cb is not registered");
return CONV_ERROR_NONE;
}
-int conv::remote_app_control_service_provider::stop_request(request* request_obj)
+int conv::RemoteAppControlServiceProvider::stop_request(request* request_obj)
{
IF_FAIL_RETURN_TAG(_activation_state == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
_D("communcation/stop requested");
json result;
- remote_app_control_service_info *svc_info = reinterpret_cast<remote_app_control_service_info*>(request_obj->service_info);
+ RemoteAppControlServiceInfo *svc_info = reinterpret_cast<RemoteAppControlServiceInfo*>(request_obj->service_info);
if (svc_info->iotcon_info_obj.iotcon_resource_handle == NULL) {
_D("not even started");
return CONV_ERROR_NONE;
}
-int conv::remote_app_control_service_provider::get_request(request* request_obj)
+int conv::RemoteAppControlServiceProvider::get_request(request* request_obj)
{
IF_FAIL_RETURN_TAG(_activation_state == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
response_cb_map.erase(find_iter);
}
-int conv::remote_app_control_service_provider::set_request(request* request_obj)
+int conv::RemoteAppControlServiceProvider::set_request(request* request_obj)
{
IF_FAIL_RETURN_TAG(_activation_state == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
- remote_app_control_service_info *svc_info = reinterpret_cast<remote_app_control_service_info*>(request_obj->service_info);
+ RemoteAppControlServiceInfo *svc_info = reinterpret_cast<RemoteAppControlServiceInfo*>(request_obj->service_info);
int error;
request_obj->communication_info = &(svc_info->iotcon_info_obj);
return CONV_ERROR_NONE;
}
-int conv::remote_app_control_service_provider::register_request(request* request_obj)
+int conv::RemoteAppControlServiceProvider::register_request(request* request_obj)
{
IF_FAIL_RETURN_TAG(_activation_state == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
_D("communcation/recv requested");
- remote_app_control_service_info *svc_info = reinterpret_cast<remote_app_control_service_info*>(request_obj->service_info);
+ RemoteAppControlServiceInfo *svc_info = reinterpret_cast<RemoteAppControlServiceInfo*>(request_obj->service_info);
switch (request_obj->get_type()) {
case REQ_SUBSCRIBE:
}
-int conv::remote_app_control_service_provider::load_service_info(request* request_obj)
+int conv::RemoteAppControlServiceProvider::load_service_info(request* request_obj)
{
IF_FAIL_RETURN_TAG(_activation_state == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
client = request_obj->get_sender();
_D("client id : %s", client.c_str());
- client_obj = conv::client_manager::get_client(client);
+ client_obj = conv::client_manager::getClient(client);
IF_FAIL_RETURN_TAG(client_obj, CONV_ERROR_OUT_OF_MEMORY, _E, "client info alloc failed");
json description = request_obj->get_description();
device.get(NULL, CONV_DEVICE_NAME, &device_name);
device.get(NULL, CONV_JSON_DEVICE_ADDRESS, &device_address);
- remote_app_control_service_info *svc_info = NULL;
- service_info_base* svc_info_base = client_obj->get_service_info(_type, device_id);
+ RemoteAppControlServiceInfo *svc_info = NULL;
+ IServiceInfo* svc_info_base = client_obj->get_service_info(_type, device_id);
if (svc_info_base != NULL) {
_D("service instance already exists");
- svc_info = reinterpret_cast<remote_app_control_service_info*>(svc_info_base);
+ svc_info = reinterpret_cast<RemoteAppControlServiceInfo*>(svc_info_base);
if (svc_info == NULL)
{
}
} else {
_D("allocating new service instance");
- svc_info = new(std::nothrow) remote_app_control_service_info();
+ svc_info = new(std::nothrow) RemoteAppControlServiceInfo();
IF_FAIL_RETURN_TAG(svc_info, CONV_ERROR_OUT_OF_MEMORY, _E, "svc_info alloc failed");
svc_info->device_id = device_id;
svc_info->iotcon_info_obj.resource_type = _resource_type;
//save service info
- client_obj->add_service_info(_type, device_id, (service_info_base*)svc_info);
+ client_obj->add_service_info(_type, device_id, (IServiceInfo*)svc_info);
_D("remote app control service is created");
}
return CONV_ERROR_NONE;
}
-int conv::remote_app_control_service_provider::get_service_info_for_discovery(json* json_obj)
+int conv::RemoteAppControlServiceProvider::get_service_info_for_discovery(json* json_obj)
{
IF_FAIL_RETURN_TAG(_activation_state == 1, CONV_ERROR_NOT_SUPPORTED, _E, "service provider is not activated");
#include <glib.h>
#include <vector>
#include <vconf.h>
-#include "../service_provider_base.h"
-#include "remote_app_control_service_info.h"
+#include "../IServiceProvider.h"
+#include "RemoteAppControlServiceInfo.h"
namespace conv {
- class remote_app_control_service_provider : public service_provider_base {
+ class RemoteAppControlServiceProvider : public IServiceProvider {
public:
- remote_app_control_service_provider();
- ~remote_app_control_service_provider();
+ RemoteAppControlServiceProvider();
+ ~RemoteAppControlServiceProvider();
int init();
int release();
#include <cstring>
#include <vconf.h>
-#include "common.h"
+#include "Types.h"
#include "d2d_conv_service.h"
#include "conv_lib_json.h"
#include "internal_types.h"
#include <string>
#include <cstring>
-#include "common.h"
+#include "Types.h"
#include "d2d_conv_manager.h"
#include "d2d_conv_internal.h"
#include "conv_lib_json.h"
#include <glib.h>
#include <string>
#include <list>
-#include "common.h"
+#include "Types.h"
#define _J(cmt, jobj) \
do { \
#include <bundle.h>
#include <bundle_internal.h>
-#include "common.h"
+#include "Types.h"
#include "d2d_conv_manager.h"
#include "d2d_conv_internal.h"
#include "conv_lib_json.h"
#include <string>
#include <cstring>
-#include "common.h"
+#include "Types.h"
#include "d2d_conv_manager.h"
#include "conv_lib_json.h"
#include "internal_types.h"
* limitations under the License.
*/
-#include "common.h"
+#include "Types.h"
#include "conv_lib_util.h"
#include <system_info.h>