#define ARG_RESULT_ERR "r_err"
#define ARG_RESULT_ADD "r_add"
#define ARG_OUTPUT "output"
+#define ARG_INPUT_BINARY "input_binary"
+#define ARG_OUTPUT_BINARY "output_binary"
+#define ARG_INPUT_BINARY_LENGTH "input_binary_length"
+#define ARG_OUTPUT_BINARY_LENGTH "output_binary_length"
#define CONV_METHOD_REQUEST "CONV_Request"
#define CONV_METHOD_RESPOND "CONV_Respond"
#define CONV_JSON_RESULT_TYPE "result_type"
#define CONV_JSON_READ_TYPE "read_type"
#define CONV_JSON_MESSAGE "message_smartview"
-#define CONV_JSON_DATA "data"
+#define CONV_JSON_DATA "data_smartview"
#define CONV_JSON_CLIENT "client"
#define CONV_JSON_PAYLOAD_SIZE "payload_size_smartview"
-#define CONV_JSON_EVENT "event"
+#define CONV_JSON_EVENT "event_smartview"
#define CONV_JSON_FROM "from"
#define CONV_JSON_IS_HOST "isHost"
#define CONV_JSON_CONNECT_TIME "connectTime"
FILE(GLOB DAEMON_SRCS ${DAEMON_SRCS} discovery_provider/smartview/*.cpp)
FILE(GLOB DAEMON_SRCS ${DAEMON_SRCS} ../msf_tizen_client/src/*.cpp)
-SET(provider_deps "glib-2.0 dlog json-glib-1.0 iotcon capi-appfw-app-manager iotcon vconf capi-network-bluetooth capi-network-wifi-direct capi-appfw-application bundle capi-network-connection cynara-creds-gdbus cynara-client cynara-session capi-appfw-package-manager sqlite3 syspopup-caller")
+SET(provider_deps "glib-2.0 dlog json-glib-1.0 iotcon capi-appfw-app-manager vconf capi-network-bluetooth capi-appfw-application bundle capi-network-connection cynara-creds-gdbus cynara-client cynara-session capi-appfw-package-manager sqlite3 syspopup-caller")
SET(provider_deps "${provider_deps} openssl libwebsockets libcurl nsd-dns-sd")
+#SET(provider_deps "${provider_deps} capi-network-wifi-direct")
# Wearable profile
IF("${PROFILE}" STREQUAL "wearable")
cb_json.set(NULL, CONV_JSON_DESCRIPTION, requestObj->getDescription());
cb_json.set(NULL, CONV_JSON_PAYLOAD, tmp_payload);
if (cur_Req != NULL) {
- cur_Req->publish(CONV_ERROR_NONE, cb_json);
+ cur_Req->publish(CONV_ERROR_NONE, cb_json, 0, NULL);
}
error = CONV_ERROR_NONE;
}
" <arg type='i' name='" ARG_REQID "' direction='in'/>"
" <arg type='s' name='" ARG_SUBJECT "' direction='in'/>"
" <arg type='s' name='" ARG_INPUT "' direction='in'/>"
+ " <arg type='i' name='" ARG_INPUT_BINARY_LENGTH "' direction='in'/>"
+ " <arg type='a(y)' name='" ARG_INPUT_BINARY "' direction='in'/>"
" <arg type='i' name='" ARG_RESULT_ERR "' direction='out'/>"
" </method>"
" <method name='" METHOD_CHK_PRIV_NETWORK_GET "'>"
gint req_id = 0;
const gchar *subject = NULL;
const gchar *input = NULL;
+ gint length = 0;
+ GVariant *binaryArray = NULL;
- g_variant_get(param, "(ii&s&s)", &req_type, &req_id, &subject, &input);
+ g_variant_get(param, "(ii&s&si@a(y))", &req_type, &req_id, &subject, &input, &length, &binaryArray);
IF_FAIL_VOID_TAG(req_type > 0 && req_id > 0 && subject && input, _E, "Invalid request");
+ const unsigned char *binary = (const unsigned char*)g_variant_get_data(binaryArray);
_I("[%s] ReqId: %d, Subject: %s", __req_type_to_str(req_type), req_id, subject);
_SI("Input: %s", input);
+ _I("binary length:%d", length);
conv::Credentials *creds = NULL;
g_dbus_method_invocation_return_value(invocation, g_variant_new("(i)", CONV_ERROR_INVALID_OPERATION));
return;
}
-
conv::Request *recvRequest = NULL;
try{
- recvRequest = 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, length, binary);
} catch (std::bad_alloc& ba) {
_E("Memory Allocation Failed..");
g_dbus_method_invocation_return_value(invocation, g_variant_new("(i)", CONV_ERROR_INVALID_OPERATION));
delete creds;
return;
}
-
conv::sendRequest(recvRequest);
}
}
}
-void conv::DbusServer::publish(const char* dest, int reqId, 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, int binaryLength, const unsigned char* binary)
{
IF_FAIL_VOID_TAG(dest && subject && data, _E, "Parameter null");
- _SI("Publish: %s, %d, %s, %#x, %s", dest, reqId, subject, error, data);
+ _SI("Publish: %s, %d, %s, %#x, %s, %d", dest, reqId, subject, error, data, binaryLength);
+
+ GVariant *binaryVariant = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"), binary, binaryLength, true, NULL, NULL);
- GVariant *param = g_variant_new("(isis)", reqId, subject, error, data);
+ GVariant *param = g_variant_new("(isisi@a(y))", reqId, subject, error, data, binaryLength, binaryVariant);
IF_FAIL_VOID_TAG(param, _E, "Memory allocation failed");
_D("before g_dbusConnection_call..");
G_DBUS_CALL_FLAGS_NONE, DBUS_TIMEOUT, NULL, __handle_call_result, &callCount);
}
-void conv::dbus_server::publish(const char* dest, int reqId, 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, int binaryLength, const unsigned char* binary)
{
- __instance->publish(dest, reqId, subject, error, data);
+ __instance->publish(dest, reqId, subject, error, data, binaryLength, binary);
}
void conv::dbus_server::call(const char *dest, const char *obj, const char *iface, const char *method, GVariant *param)
bool init();
void release();
- void publish(const char *dest, int req_id, const char *subject, int error, const char *data);
+ void publish(const char *dest, int req_id, const char *subject, int error, const char *data, int binaryLength, const unsigned char* binary);
void call(const char *dest, const char *obj, const char *iface, const char *method, GVariant *param);
}; /* class conv::dbus_server */
namespace dbus_server {
- void publish(const char *dest, int req_id, const char *subject, int error, const char *data);
+ void publish(const char *dest, int req_id, const char *subject, int error, const char *data, int binaryLength, const unsigned char* binary);
void call(const char *dest, const char *obj, const char *iface, const char *method, GVariant *param);
void setInstance(IDbusServer* svr);
}
if (requestIter != __requestMap.end()) {
Json noData;
Request* currentRequest = requestIter->second;
- currentRequest->publish(CONV_DISCOVERY_FINISHED, noData);
+ currentRequest->publish(CONV_DISCOVERY_FINISHED, noData, 0, NULL);
__requestMap.erase(requestIter);
}
convertDeviceIntoJson(discoveredDevice, &deviceJson);
for (IterPos = __requestMap.begin(); IterPos != __requestMap.end(); ++IterPos) {
Request* currentRequest = IterPos->second;
- currentRequest->publish(CONV_DISCOVERY_DEVICE_LOST, deviceJson);
+ currentRequest->publish(CONV_DISCOVERY_DEVICE_LOST, deviceJson, 0, NULL);
}
}
RequestMap::iterator IterPos;
for (IterPos = __requestMap.begin(); IterPos != __requestMap.end(); ++IterPos) {
Request* currentRequest = IterPos->second;
- currentRequest->publish(CONV_ERROR_NONE, deviceJson);
+ currentRequest->publish(CONV_ERROR_NONE, deviceJson, 0, NULL);
index++;
}
return true;
}
+
+std::string conv::Json::serializedStr()
+{
+ std::string jsonStr = str();
+ std::string from = "\"";
+ std::string to = "\\\"";
+ unsigned int startIndex = 0;
+ startIndex = jsonStr.find(from, startIndex);
+ while (startIndex != std::string::npos) {
+ jsonStr.replace(startIndex, from.length(), to);
+ startIndex += to.length();
+ startIndex = jsonStr.find(from, startIndex);
+ }
+ return jsonStr;
+}
+
char* dupCstr();
std::string str();
+ std::string serializedStr();
bool getKeys(std::list<std::string>* list);
#include "Request.h"
#include "DbusServer.h"
+conv::Request::Request(int type, const char *client, int reqId, const char *subj, const char *desc,
+ const char *sender, Credentials *creds, GDBusMethodInvocation *inv,
+ int binaryLength, const unsigned char* binary)
+ : __type(type)
+ , __reqId(reqId)
+ , __client(client)
+ , __subject(subj)
+ , __description(desc)
+ , __creds(creds)
+ , __sender(sender)
+ , __invocation(inv)
+ , __binaryLength(binaryLength)
+ , __binary(binary)
+{
+}
+
conv::Request::Request(int type, const char* client, int reqId, const char* subj, const char* desc)
: __type(type)
, __reqId(reqId)
return __reqId;
}
+int conv::Request::getBinaryLength()
+{
+ return __binaryLength;
+}
+
+const unsigned char* conv::Request::getBinary()
+{
+ return __binary;
+}
+
const char* conv::Request::getClient()
{
return __client.c_str();
return true;
}
-bool conv::Request::publish(int error, conv::Json& data)
+bool conv::Request::publish(int error, conv::Json& data, int binaryLength, const unsigned char* binary)
{
char *dataStr = data.dupCstr();
IF_FAIL_RETURN_TAG(dataStr, false, _E, "Memory allocation failed");
_D("info : subject %s", __subject.c_str());
_D("info : error %d", error);
_D("info : data %s", dataStr);
+ _D("info : binary length %d", binaryLength);
_D("info : description %s", __description.str().c_str());
- _D("publish info : sender[%s] reqId[%d] subject[%s] error[%d] data[%s]"
- , __sender.c_str(), __reqId, __subject.c_str(), error, dataStr);
- conv::dbus_server::publish(__sender.c_str(), __reqId, __subject.c_str(), error, dataStr);
+ conv::dbus_server::publish(__sender.c_str(), __reqId, __subject.c_str(), error, dataStr, binaryLength, binary);
g_free(dataStr);
return true;
public:
Request(int type, const char *client, int reqId, const char *subj, const char *desc);
Request(int type,
- const char *client, int reqId, const char *subj, const char *desc,
- const char *sender, Credentials *creds, GDBusMethodInvocation *inv);
+ const char *client, int reqId, const char *subj, const char *desc,
+ const char *sender, Credentials *creds, GDBusMethodInvocation *inv);
+ Request(int type, const char *client, int reqId, const char *subj, const char *desc,
+ const char *sender, Credentials *creds, GDBusMethodInvocation *inv,
+ int binaryLength, const unsigned char* binary);
~Request();
int getType();
int getId();
+ int getBinaryLength();
const char *getClient();
const char *getSender();
const char *getSubject();
+ const unsigned char *getBinary();
Json& getDescription();
Credentials *getCreds();
bool reply(int error);
- bool publish(int error, Json &data);
+ bool publish(int error, Json &data, int binaryLength, const unsigned char* binary);
bool getChannelFromDescription(Json* target);
bool getPayloadFromDescription(Json* target);
IServiceInfo* __serviceInfo;
ICommunicationInfo* __communicationInfo;
+ int __binaryLength;
+ const unsigned char* __binary;
};
}
result_data.set(NULL, CONV_JSON_DEVICE_TYPE, deviceType);
result_data.set(NULL, CONV_JSON_DEVICE_NAME, deviceName);
result_data.set(NULL, CONV_JSON_ACCESS_CONTROL_STATE, aclState);
- requestObj->publish(CONV_ERROR_NONE, result_data);
+ requestObj->publish(CONV_ERROR_NONE, result_data, 0, NULL);
}
ret = database_finalize(database, stmt);
#include "../DiscoveryManager.h"
#include <net_connection.h>
-#include <wifi-direct.h>
+//#include <wifi-direct.h>
#define TEMP_TEST
conv::WifiDirectDiscoveryProvider::~WifiDirectDiscoveryProvider()
{
}
-
+#if 0
void _cb_activation(int error_code, wifi_direct_device_state_e device_state, void *user_data)
{
switch (device_state) {
return result;
}
+#endif
+
int conv::WifiDirectDiscoveryProvider::init()
{
//init_wfd_client((void*)this);
result.set(NULL, CONV_JSON_DESCRIPTION, description);
result.set(NULL, CONV_JSON_PAYLOAD, payload);
if (start_result)
- (*requestObj)->publish(CONV_ERROR_NONE, result);
+ (*requestObj)->publish(CONV_ERROR_NONE, result, 0, NULL);
else
- (*requestObj)->publish(CONV_ERROR_INVALID_OPERATION, result);
+ (*requestObj)->publish(CONV_ERROR_INVALID_OPERATION, result, 0, NULL);
}
}
result.set(NULL, CONV_JSON_DESCRIPTION, description);
result.set(NULL, CONV_JSON_PAYLOAD, payload);
if (stop_result)
- (*requestObj)->publish(CONV_ERROR_NONE, result);
+ (*requestObj)->publish(CONV_ERROR_NONE, result, 0, NULL);
else
- (*requestObj)->publish(CONV_ERROR_INVALID_OPERATION, result);
+ (*requestObj)->publish(CONV_ERROR_INVALID_OPERATION, result, 0, NULL);
}
}
if ((*requestObj) != NULL) {
_D(RED("publishing_response"));
Json result;
- Json message_json;
Json description;
_D("size %d", message.m_payload_size);
- _D("payload %s", message.m_payload);
-
- message_json.set(NULL, CONV_JSON_EVENT, message.m_event);
- message_json.set(NULL, CONV_JSON_DATA, message.m_data);
- message_json.set(NULL, CONV_JSON_FROM, message.m_from);
- string payload_str(reinterpret_cast<const char*>(message.m_payload), message.m_payload_size);
+ string payload_str(message.m_data);
Json payload = payload_str;
+ payload.set(NULL, CONV_JSON_DATA, message.m_data);
payload.set(NULL, CONV_JSON_PAYLOAD_SIZE, message.m_payload_size);
payload.set(NULL, CONV_JSON_RESULT_TYPE, CONV_JSON_ON_MESSAGE);
-// payload.set(NULL, CONV_JSON_MESSAGE, message_json);
- payload.set(NULL, CONV_JSON_MESSAGE, message_json.dupCstr());
payload.set(NULL, CONV_JSON_FROM, message.m_from);
+ payload.set(NULL, CONV_JSON_EVENT, message.m_event);
description = (*requestObj)->getDescription();
result.set(NULL, CONV_JSON_PAYLOAD, payload);
_D("size of msg:%d", result.str().length());
- (*requestObj)->publish(CONV_ERROR_NONE, result);
+ (*requestObj)->publish(CONV_ERROR_NONE, result, message.m_payload_size, message.m_payload);
_D("publishing done");
}
}
result.set(NULL, CONV_JSON_DESCRIPTION, description);
result.set(NULL, CONV_JSON_PAYLOAD, payload);
- (*requestObj)->publish(CONV_ERROR_INVALID_OPERATION, result);
+ (*requestObj)->publish(CONV_ERROR_INVALID_OPERATION, result, 0, NULL);
}
}
result.set(NULL, CONV_JSON_DESCRIPTION, description);
result.set(NULL, CONV_JSON_PAYLOAD, payload);
if (publish_result)
- (*requestObj)->publish(CONV_ERROR_NONE, result);
+ (*requestObj)->publish(CONV_ERROR_NONE, result, 0, NULL);
else
- (*requestObj)->publish(CONV_ERROR_INVALID_OPERATION, result);
+ (*requestObj)->publish(CONV_ERROR_INVALID_OPERATION, result, 0, NULL);
}
}
result.set(NULL, CONV_JSON_DESCRIPTION, description);
result.set(NULL, CONV_JSON_PAYLOAD, payload);
- (*requestObj)->publish(error, result);
+ (*requestObj)->publish(error, result, 0, NULL);
}
}
client.set(NULL, CONV_JSON_CHANNEL_URI, cha->getChannelUri(NULL).c_str());
// result.appendArray(NULL, CONV_JSON_CLIENT_LIST, client);
- result.set(NULL, CONV_JSON_CLIENT_LIST, client.dupCstr());
+ char* client_char = client.dupCstr();
+ result.set(NULL, CONV_JSON_CLIENT_LIST, client_char);
+ if (client_char != NULL) {
+ g_free(client_char);
+ }
}
sendReadResponse(result, CONV_JSON_GET_CLIENTS, CONV_ERROR_NONE, svcInfo->registeredRequest);
result.set(NULL, CONV_JSON_DESCRIPTION, description);
result.set(NULL, CONV_JSON_PAYLOAD, payload);
- requestObj->publish(error, result);
+ requestObj->publish(error, result, 0, NULL);
return CONV_ERROR_NONE;
}
requestObj->getPayloadFromDescription(&payload);
- char* message = new(std::nothrow) char[strlen(payload.str().c_str())+1];
- ASSERT_ALLOC(message);
-
- strncpy(message, payload.str().c_str(), strlen(payload.str().c_str())+1);
-
- string payload_str = payload.str();
- _D("payload : %s, size : %d", message, strlen(message));
-
- (*iter)->application->publish("d2d_service_message", NULL, reinterpret_cast<unsigned char*>(message), strlen(message), NULL);
+ (*iter)->application->publish("d2d_service_message", payload.serializedStr().c_str(), requestObj->getBinary(), requestObj->getBinaryLength(), NULL);
_D("publishing done");
-
- delete[] message;
return CONV_ERROR_NONE;
}
}
result.set(NULL, CONV_JSON_DESCRIPTION, description);
result.set(NULL, CONV_JSON_PAYLOAD, payload);
- requestObj->publish(error, result);
+ requestObj->publish(error, result, 0, NULL);
return CONV_ERROR_NONE;
}
result.set(NULL, CONV_JSON_DESCRIPTION, cb_info.requestObj->getDescription());
result.set(NULL, CONV_JSON_PAYLOAD, payload);
- cb_info.requestObj->publish(CONV_ERROR_NONE, result);
+ cb_info.requestObj->publish(CONV_ERROR_NONE, result, 0, NULL);
_D("response published");
}
}
INCLUDE_DIRECTORIES(${client_pkgs_INCLUDE_DIRS})
LINK_DIRECTORIES(${client_pkgs_LIBRARY_DIRS})
-ADD_DEFINITIONS("-DBROKER_DBUS_INTERFACE=\"${DBUS_INTERFACE}\"")
+ADD_DEFINITIONS("-DCONV_DBUS_INTERFACE=\"${DBUS_INTERFACE}\"")
ADD_LIBRARY(${CLIENT} SHARED ${CLIENT_SRCS})
TARGET_LINK_LIBRARIES(${CLIENT} ${client_pkgs_LIBRARIES})
static callback_map_t callback_map;
//LCOV_EXCL_START
-static void conv_subject_cb(const char* subject, int req_id, int error, json data)
+static void conv_subject_cb(const char* subject, int req_id, int error, json data, int binary_length, const unsigned char* binary)
{
_D("Callback response %d : subject[%s] json_data[%s]", req_id, subject, data.str().c_str());
int req_id;
const char* input = const_cast<const char*> (input_data.str().c_str());
_D("input:%s", input);
- int err = conv::dbus_client::request(REQ_WRITE, &req_id, CONV_SUBJECT_DISCOVERY_START, input_data.str().c_str());
+ int err = conv::dbus_client::request(REQ_WRITE, &req_id, CONV_SUBJECT_DISCOVERY_START, input_data.str().c_str(), 0, NULL);
IF_FAIL_RETURN_TAG(err == CONV_ERROR_NONE, err, _E, "Failed in starting flow service");
callback_map[req_id] = cb_info;
ASSERT_NOT_NULL(handle);
int req_id;
- int err = conv::dbus_client::request(REQ_WRITE, &req_id, CONV_SUBJECT_DISCOVERY_STOP, NULL);
+ int err = conv::dbus_client::request(REQ_WRITE, &req_id, CONV_SUBJECT_DISCOVERY_STOP, NULL, 0, NULL);
IF_FAIL_RETURN_TAG(err == CONV_ERROR_NONE, err, _E, "Failed in starting flow service");
return CONV_ERROR_NONE;
const char* input = const_cast<const char*> (input_data.str().c_str());
_D("input:%s", input);
- int err = conv::dbus_client::request(REQ_WRITE, &req_id, CONV_SUBJECT_ACCESS_CONTROL_REGIST, input_data.str().c_str());
+ int err = conv::dbus_client::request(REQ_WRITE, &req_id, CONV_SUBJECT_ACCESS_CONTROL_REGIST, input_data.str().c_str(), 0, NULL);
IF_FAIL_RETURN_TAG(err == CONV_ERROR_NONE, err, _E, "Failed in conv_internal_regist_acl_device()");
return CONV_ERROR_NONE;
const char* input = const_cast<const char*> (input_data.str().c_str());
_D("input:%s", input);
- int err = conv::dbus_client::request(REQ_WRITE, &req_id, CONV_SUBJECT_ACCESS_CONTROL_SET, input_data.str().c_str());
+ int err = conv::dbus_client::request(REQ_WRITE, &req_id, CONV_SUBJECT_ACCESS_CONTROL_SET, input_data.str().c_str(), 0, NULL);
IF_FAIL_RETURN_TAG(err == CONV_ERROR_NONE, err, _E, "Failed in conv_internal_set_acl_state()");
return CONV_ERROR_NONE;
const char* input = const_cast<const char*> (input_data.str().c_str());
_D("input:%s", input);
- int err = conv::dbus_client::request(REQ_WRITE, &req_id, CONV_SUBJECT_ACCESS_CONTROL_REMOVE, input_data.str().c_str());
+ int err = conv::dbus_client::request(REQ_WRITE, &req_id, CONV_SUBJECT_ACCESS_CONTROL_REMOVE, input_data.str().c_str(), 0, NULL);
IF_FAIL_RETURN_TAG(err == CONV_ERROR_NONE, err, _E, "Failed in conv_internal_remove_acl_device())");
return CONV_ERROR_NONE;
typedef std::map<int, access_control_callback_info_s*> callback_map_t;
static callback_map_t callback_map;
-static void conv_subject_cb(const char *subject, int req_id, int error, json data)
+static void conv_subject_cb(const char *subject, int req_id, int error, json data, int binary_length, const unsigned char* binary)
{
std::string mac_address;
std::string device_type;
cb_info->user_data = user_data;
int req_id;
- int err = conv::dbus_client::request(REQ_WRITE, &req_id, CONV_SUBJECT_ACCESS_CONTROL_GET, NULL);
+ int err = conv::dbus_client::request(REQ_WRITE, &req_id, CONV_SUBJECT_ACCESS_CONTROL_GET, NULL, 0, NULL);
IF_FAIL_RETURN_TAG(err == CONV_ERROR_NONE, err, _E, "Failed in conv_internal_get_acl_list()");
callback_map[req_id] = cb_info;
return CONV_ERROR_NONE;
-}
\ No newline at end of file
+}
*handle = new(std::nothrow) _conv_payload_handle();
ASSERT_ALLOC(*handle);
+ (*handle)->binary = NULL;
+ (*handle)->binary_length = 0;
+
return CONV_ERROR_NONE;
}
{
IF_FAIL_RETURN_TAG(conv::util::is_feature_supported(), CONV_ERROR_NOT_SUPPORTED, _E, "Not supported");
ASSERT_NOT_NULL(handle);
+
delete handle;
return CONV_ERROR_NONE;
return CONV_ERROR_NONE;
}
+
+EXTAPI int conv_payload_set_binary(conv_payload_h handle, int length, const unsigned char* value)
+{
+ IF_FAIL_RETURN_TAG(conv::util::is_feature_supported(), CONV_ERROR_NOT_SUPPORTED, _E, "Not supported");
+ ASSERT_NOT_NULL(handle);
+ ASSERT_NOT_NULL(value);
+
+ handle->binary_length = length;
+ handle->binary = value;
+
+ return CONV_ERROR_NONE;
+}
+
+EXTAPI int conv_payload_get_binary(conv_payload_h handle, int* length, const unsigned char** value)
+{
+ IF_FAIL_RETURN_TAG(conv::util::is_feature_supported(), CONV_ERROR_NOT_SUPPORTED, _E, "Not supported");
+ ASSERT_NOT_NULL(handle);
+ ASSERT_NOT_NULL(value);
+
+ IF_FAIL_RETURN_TAG(handle->binary_length > 0, CONV_ERROR_NO_DATA, _E, "No data");
+
+ *value = handle->binary;
+ *length = handle->binary_length;
+
+ return CONV_ERROR_NONE;
+}
//LCOV_EXCL_STOP
conv_service_e convert_string_to_type(std::string type_name);
//LCOV_EXCL_START
-static void conv_subject_cb(const char* subject, int req_id, int error, json data)
+static void conv_subject_cb(const char* subject, int req_id, int error, json data, int binary_length, const unsigned char* binary)
{
_D("Callback response %d", req_id);
IF_FAIL_VOID_TAG(payload_handle, _E, "Memory allocation failed");
payload_handle->jpayload = payload;
+ payload_handle->binary_length = binary_length;
+ payload_handle->binary = binary;
+ conv_error_e conv_error = (conv_error_e)error;
- callback_info->cb(service_handle, channel_handle, CONV_ERROR_NONE, payload_handle, callback_info->user_data);
+ callback_info->cb(service_handle, channel_handle, conv_error, payload_handle, callback_info->user_data);
delete payload_handle;
delete channel_handle;
delete service_handle;
}
-static void conv_connect_subject_cb(const char* subject, int req_id, int error, json data)
+static void conv_connect_subject_cb(const char* subject, int req_id, int error, json data, int binary_length, const unsigned char* binary)
{
_D("Callback response %d", req_id);
int req_id;
- int err = conv::dbus_client::request(REQ_SUBSCRIBE, &req_id, CONV_SUBJECT_COMMUNICATION_RECV, description.str().c_str());
+ int err = conv::dbus_client::request(REQ_SUBSCRIBE, &req_id, CONV_SUBJECT_COMMUNICATION_RECV, description.str().c_str(), 0, NULL);
IF_FAIL_RETURN_TAG(err == CONV_ERROR_NONE, err, _E, "Getting list failed");
return CONV_ERROR_NONE;
description.set(NULL, CONV_JSON_IS_LOCAL, handle->is_local);
int req_id;
- int err = conv::dbus_client::request(REQ_UNSUBSCRIBE, &req_id, CONV_SUBJECT_COMMUNICATION_RECV, description.str().c_str());
+ int err = conv::dbus_client::request(REQ_UNSUBSCRIBE, &req_id, CONV_SUBJECT_COMMUNICATION_RECV, description.str().c_str(), 0, NULL);
IF_FAIL_RETURN_TAG(err == CONV_ERROR_NONE, err, _E, "Unset observe failed");
std::map<std::string, _conv_service_callback_info*>::iterator it = callback_map.find(description.str());
json description;
json channel;
json payload;
+ int binary_length = 0;
+ const unsigned char* binary = NULL;
- if ( channel_handle != NULL )
+ if (channel_handle != NULL)
channel = channel_handle->jchannel;
- if ( payload_handle != NULL)
+ if (payload_handle != NULL) {
payload = payload_handle->jpayload;
+ binary_length = payload_handle->binary_length;
+ binary = payload_handle->binary;
+ }
json service = handle->jservice;
json device = handle->jdevice;
description.set(NULL, CONV_JSON_TYPE, type);
description.set(NULL, CONV_JSON_IS_LOCAL, handle->is_local);
- int err = conv::dbus_client::request(REQ_WRITE, &req_id, CONV_SUBJECT_COMMUNICATION_START, description.str().c_str());
+ int err = conv::dbus_client::request(REQ_WRITE, &req_id, CONV_SUBJECT_COMMUNICATION_START, description.str().c_str(), binary_length, binary);
IF_FAIL_RETURN_TAG(err == CONV_ERROR_NONE, err, _E, "Failed in starting flow service");
return CONV_ERROR_NONE;
json description;
json channel;
+ json payload;
+ int binary_length = 0;
+ const unsigned char* binary = NULL;
- if ( channel_handle != NULL )
+ if (channel_handle != NULL)
channel = channel_handle->jchannel;
- json payload;
-
- if ( payload_handle != NULL)
+ if (payload_handle != NULL) {
payload = payload_handle->jpayload;
+ binary_length = payload_handle->binary_length;
+ binary = payload_handle->binary;
+ }
json service = handle->jservice;
json device = handle->jdevice;
description.set(NULL, CONV_JSON_TYPE, type);
description.set(NULL, CONV_JSON_IS_LOCAL, handle->is_local);
- int err = conv::dbus_client::request(REQ_WRITE, &req_id, CONV_SUBJECT_COMMUNICATION_GET, description.str().c_str());
+ int err = conv::dbus_client::request(REQ_WRITE, &req_id, CONV_SUBJECT_COMMUNICATION_GET, description.str().c_str(), binary_length, binary);
IF_FAIL_RETURN_TAG(err == CONV_ERROR_NONE, err, _E, "Failed in starting flow service");
return CONV_ERROR_NONE;
json description;
json channel;
json payload;
+ int binary_length = 0;
+ const unsigned char* binary = NULL;
- if ( channel_handle != NULL )
+ if (channel_handle != NULL)
channel = channel_handle->jchannel;
- if (payload_handle != NULL)
+ if (payload_handle != NULL) {
payload = payload_handle->jpayload;
+ binary_length = payload_handle->binary_length;
+ binary = payload_handle->binary;
+ }
json service = handle->jservice;
json device = handle->jdevice;
description.set(NULL, CONV_JSON_TYPE, type);
description.set(NULL, CONV_JSON_IS_LOCAL, handle->is_local);
- int err = conv::dbus_client::request(REQ_WRITE, &req_id, CONV_SUBJECT_COMMUNICATION_STOP, description.str().c_str());
+ int err = conv::dbus_client::request(REQ_WRITE, &req_id, CONV_SUBJECT_COMMUNICATION_STOP, description.str().c_str(), binary_length, binary);
IF_FAIL_RETURN_TAG(err == CONV_ERROR_NONE, err, _E, "Failed in starting flow service");
return CONV_ERROR_NONE;
json description;
json channel;
json payload;
+ int binary_length = 0;
+ const unsigned char* binary = NULL;
if (channel_handle != NULL)
channel = channel_handle->jchannel;
- if (payload_handle != NULL)
+ if (payload_handle != NULL) {
payload = payload_handle->jpayload;
+ binary_length = payload_handle->binary_length;
+ binary = payload_handle->binary;
+ }
json service = handle->jservice;
json device = handle->jdevice;
description.set(NULL, CONV_JSON_TYPE, type);
description.set(NULL, CONV_JSON_IS_LOCAL, handle->is_local);
- int err = conv::dbus_client::request(REQ_WRITE, &req_id, CONV_SUBJECT_COMMUNICATION_SET, description.str().c_str());
+ int err = conv::dbus_client::request(REQ_WRITE, &req_id, CONV_SUBJECT_COMMUNICATION_SET, description.str().c_str(), binary_length, binary);
IF_FAIL_RETURN_TAG(err == CONV_ERROR_NONE, err, _E, "Failed in starting flow service");
return CONV_ERROR_NONE;
int req_id;
- int err = conv::dbus_client::request(REQ_SUBSCRIBE, &req_id, CONV_SUBJECT_CONNECTION_START, description.str().c_str());
+ int err = conv::dbus_client::request(REQ_SUBSCRIBE, &req_id, CONV_SUBJECT_CONNECTION_START, description.str().c_str(), 0, NULL);
IF_FAIL_RETURN_TAG(err == CONV_ERROR_NONE, err, _E, "Getting list failed");
return CONV_ERROR_NONE;
description.set(NULL, CONV_JSON_IS_LOCAL, handle->is_local);
int req_id;
- int err = conv::dbus_client::request(REQ_UNSUBSCRIBE, &req_id, CONV_SUBJECT_CONNECTION_START, NULL);
+ int err = conv::dbus_client::request(REQ_UNSUBSCRIBE, &req_id, CONV_SUBJECT_CONNECTION_START, NULL, 0, NULL);
IF_FAIL_RETURN_TAG(err == CONV_ERROR_NONE, err, _E, "Unset observe failed");
std::map<std::string, _conv_service_connect_callback_info*>::iterator it = connect_callback_map.find(description.str());
conv_service_set_connected_cb(handle, description, callback, user_data);
- int err = conv::dbus_client::request(REQ_WRITE, &req_id, CONV_SUBJECT_CONNECTION_START, description.str().c_str());
+ int err = conv::dbus_client::request(REQ_WRITE, &req_id, CONV_SUBJECT_CONNECTION_START, description.str().c_str(), 0, NULL);
IF_FAIL_RETURN_TAG(err == CONV_ERROR_NONE, err, _E, "Failed in starting flow service");
return CONV_ERROR_NONE;
description.set(NULL, CONV_JSON_DEVICE, device);
description.set(NULL, CONV_JSON_IS_LOCAL, handle->is_local);
- int err = conv::dbus_client::request(REQ_WRITE, &req_id, CONV_SUBJECT_CONNECTION_STOP, description.str().c_str());
+ int err = conv::dbus_client::request(REQ_WRITE, &req_id, CONV_SUBJECT_CONNECTION_STOP, description.str().c_str(), 0, NULL);
IF_FAIL_RETURN_TAG(err == CONV_ERROR_NONE, err, _E, "Failed in starting flow service");
return CONV_ERROR_NONE;
" <arg type='s' name='" ARG_SUBJECT "' direction='in'/>"
" <arg type='i' name='" ARG_RESULT_ERR "' direction='in'/>"
" <arg type='s' name='" ARG_OUTPUT "' direction='in'/>"
+ " <arg type='i' name='" ARG_OUTPUT_BINARY_LENGTH "' direction='in'/>"
+ " <arg type='a(y)' name='" ARG_OUTPUT_BINARY "' direction='in'/>"
" </method>"
" </interface>"
"</node>";
const gchar *subject = NULL;
gint error = 0;
const gchar *data = NULL;
+ gint length = 0;
+ GVariant *binary_array = NULL;
- g_variant_get(param, "(i&si&s)", &req_id, &subject, &error, &data);
+ g_variant_get(param, "(i&si&si@a(y))", &req_id, &subject, &error, &data, &length, &binary_array);
_D("[Response] ReqId: %d, Subject: %s, Error: %d", req_id, subject, error);
+ const unsigned char *binary = (const unsigned char*)g_variant_get_data(binary_array);
response_cb_map_t::iterator it = response_cb_map->find(subject);
IF_FAIL_VOID_TAG(it!= response_cb_map->end(), _E, "Unknown subject'%s'", subject);
- it->second(subject, req_id, error, data);
+ it->second(subject, req_id, error, data, length, binary);
g_dbus_method_invocation_return_value(invocation, NULL);
}
}
int conv::dbus_client::request(
- int type, int* req_id, const char* subject, const char* input)
+ int type, int* req_id, const char* subject, const char* input, const int binary_length, const unsigned char* binary)
{
_D("Requesting: %d, %s", type, subject);
IF_FAIL_RETURN_TAG(init(), CONV_ERROR_INVALID_OPERATION, _E, "Connection failed");
}
*req_id = get_req_id();
- // second param is security cookie which is deprecated in 3.0
- GVariant *param = g_variant_new("(iiss)", type, *req_id, subject, input);
+ GVariant *binary_variant = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"), binary, binary_length, true, NULL, NULL);
+
+ GVariant *param = g_variant_new("(iissi@a(y))", type, *req_id, subject, input, binary_length, binary_variant);
IF_FAIL_RETURN_TAG(param, CONV_ERROR_OUT_OF_MEMORY, _E, "Memory allocation failed");
GError *err = NULL;
+ _D("call start");
GVariant *response = g_dbus_connection_call_sync(dbus_connection, DBUS_DEST, DBUS_PATH, DBUS_IFACE,
METHOD_REQUEST, param, NULL, G_DBUS_CALL_FLAGS_NONE, DBUS_TIMEOUT, NULL, &err);
//LCOV_EXCL_START
int conv::dbus_client::request_with_no_reply(
- int type, int* req_id, const char* subject, const char* input)
+ int type, int* req_id, const char* subject, const char* input, const int binary_length, const unsigned char* binary)
{
_D("Requesting: %d, %d, %s", type, req_id, subject);
IF_FAIL_RETURN_TAG(init(), CONV_ERROR_INVALID_OPERATION, _E, "Connection failed");
*req_id = get_req_id();
- // second param is security cookie which is deprecated in 3.0
- GVariant *param = g_variant_new("(iiss)", type, req_id, subject, input);
+ GVariant *binary_variant = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"), binary, binary_length, true, NULL, NULL);
+
+ GVariant *param = g_variant_new("(iissi@a(y))", type, *req_id, subject, input, binary_length, binary_variant);
IF_FAIL_RETURN_TAG(param, CONV_ERROR_OUT_OF_MEMORY, _E, "Memory allocation failed");
GError *err = NULL;
#include <string>
-typedef void(* subject_response_cb)(const char* subject, int req_id, int error, json response);
+typedef void(* subject_response_cb)(const char* subject, int req_id, int error, json response, int binary_length, const unsigned char* binary);
namespace conv {
bool init();
void release();
- int request(int type, int* req_id, const char* subject, const char* input);
- int request_with_no_reply(int type, int* req_id, const char* subject, const char* input);
+ int request(int type, int* req_id, const char* subject, const char* input, const int binary_length, const unsigned char* binary);
+ int request_with_no_reply(int type, int* req_id, const char* subject, const char* input, const int binary_length, const unsigned char* binary);
int register_callback(const char* subject, subject_response_cb callback);
int call(const char* subject);
}
*/
int conv_internal_get_acl_list(conv_access_control_list_foreach_cb callback, void *user_data);
+/**
+ * @brief Sets binary to payload.
+ * @since_tizen 3.0
+ *
+ * @param[in] handle The payload handle
+ * @param[in] length The length of binary to set
+ * @param[in] value The binary to set
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #CONV_ERROR_NONE Successful
+ * @retval #CONV_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONV_ERROR_NOT_SUPPORTED Not supported
+ *
+ * @see conv_payload_get_binary()
+ */
+int conv_payload_set_binary(conv_payload_h handle, int length, const unsigned char* value);
+
+/**
+ * @brief Gets binary from payload.
+ * @since_tizen 3.0
+ * @remarks The @a value must be released using free().
+ *
+ * @param[in] handle The payload handle
+ * @param[out] length The length of binary
+ * @param[out] value The result value
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #CONV_ERROR_NONE Successful
+ * @retval #CONV_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONV_ERROR_NOT_SUPPORTED Not supported
+ * @retval #CONV_ERROR_NO_DATA No Data
+ *
+ * @see conv_payload_set_binary()
+ */
+int conv_payload_get_binary(conv_payload_h handle, int* length, const unsigned char** value);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
typedef struct _conv_payload_handle_s {
json jpayload;
+ const unsigned char* binary;
+ int binary_length;
} _conv_payload_handle;
typedef struct _conv_service_handle_s {
void setonPublishListener(OnPublishListener *);
void unsetonPublishListener();
void publish(string event, const char *data, void *user_data);
- void publish(string event, const char *data, unsigned char payload[],
+ void publish(string event, const char *data, const unsigned char payload[],
int payload_size, void *user_data);
void publish(string event, const char *data, const char *target, void *user_data);
void publish(string event, const char *data, const char *target,
- unsigned char payload[], int payload_size, void *user_data);
+ const unsigned char payload[], int payload_size, void *user_data);
void publish(string event, const char *data, Client client, void *user_data);
void publish(string event, const char *data, Client client,
- unsigned char payload[], int payload_size, void *user_data);
+ const unsigned char payload[], int payload_size, void *user_data);
void publish(string event, const char *data, list<Client> clients, void *user_data);
void publish(string event, const char *data, list<Client> clients,
- unsigned char payload[], int payload_size, void *user_data);
+ const unsigned char payload[], int payload_size, void *user_data);
void publishMessage(string event, const char *data, const char *to,
- unsigned char payload[], int payload_size, void *user_data);
+ const unsigned char payload[], int payload_size, void *user_data);
void publishMessage(string method, string event, const char *data,
- const char *to, unsigned char payload[],
+ const char *to, const unsigned char payload[],
int payload_size, void *user_data);
void handleWsiDestroy();
void setCommunicated(bool value);
void create_websocket(void *att);
unsigned char *prepareMessageMap(string, string, const char *data,
const char *to, long *,
- unsigned char payload[], int payload_size);
+ const unsigned char payload[], int payload_size);
static string ROUTE;
static string ERROR_EVENT;
static pthread_t connect_thread;
int mirror_lifetime;
int force_exit;
- char *messagedata;
+ unsigned char *cl_data;
+ int cl_data_size;
//bool isWrite;
//bool binary_message;
bool disconnecting;
write_buf_index = 0;
write_buf_last_sent_index = 0;
cl_payload = NULL;
+ cl_data = NULL;
+ cl_data_size = 0;
is_header_parsed = false;
eventType = "";
+ resultobj = NULL;
}
Channel::Channel(Service *service1, string uri1) {
write_buf_index = 0;
write_buf_last_sent_index = 0;
cl_payload = NULL;
+ cl_data = NULL;
+ cl_data_size = 0;
is_header_parsed = false;
eventType = "";
+ resultobj = NULL;
}
Channel *Channel::create(Service *service, string uri) {
free(cl_payload);
cl_payload = NULL;
}
+
+ if (cl_data != NULL) {
+ free(cl_data);
+ cl_data = NULL;
+ }
+
+ if (resultobj) {
+ g_free(resultobj);
+ resultobj = NULL;
+ }
}
void Channel::init_json_key_map() {
p->msg_subject = Message::PROPERTY_RESULT;
} else if (json_node_get_node_type(node) == JSON_NODE_OBJECT) {
MSF_DBG("set resultobj");
- g_free(p->resultobj);
+ if (p->resultobj) {
+ g_free(p->resultobj);
+ p->resultobj = NULL;
+ }
p->resultobj = json_node_dup_object(node);
}
} break;
}
void Channel::doApplicationCallback(Result_Base *result1) {
- if (resultobj != NULL) {
- }
-
bool errorMap = errobj;
if (errorMap != false) {
}
} else {
MSF_DBG("TEXT MESSAGE ARRIVED. len:%d", len);
- this_ptr->eventType = "";
- this_ptr->json_parse((char *)in);
+ if (this_ptr->cl_data == NULL) {
+ this_ptr->cl_data = (unsigned char*)calloc(1, sizeof(unsigned char));
+ this_ptr->cl_data_size = 0;
+ }
+
+ this_ptr->cl_data = (unsigned char*)realloc(this_ptr->cl_data, this_ptr->cl_data_size + len + 1);
+ memcpy(&(this_ptr->cl_data[this_ptr->cl_data_size]), (char*)in, len);
+ this_ptr->cl_data_size += len;
+ this_ptr->cl_data[this_ptr->cl_data_size] = '\0';
this_ptr->connectionHandler->resetLastPingReceived();
- if (this_ptr->eventType == CONNECT_EVENT) {
- this_ptr->handleConnectMessage(this_ptr->UID);
- } else {
- // this_ptr->handleMessage(this_ptr->UID);
- this_ptr->handleMessage(this_ptr->UID, NULL);
+ if (lws_remaining_packet_payload(wsi) == 0) {
+ this_ptr->json_parse((char*)this_ptr->cl_data);
+
+ if (this_ptr->eventType == CONNECT_EVENT) {
+ this_ptr->handleConnectMessage(this_ptr->UID);
+ } else {
+ // this_ptr->handleMessage(this_ptr->UID);
+ this_ptr->handleMessage(this_ptr->UID, NULL);
+ }
+
+ if (this_ptr->cl_data) {
+ free(this_ptr->cl_data);
+ this_ptr->cl_data = NULL;
+ this_ptr->cl_data_size = 0;
+ this_ptr->eventType.clear();
+ }
}
}
break;
publishMessage(event, data, to.c_str(), NULL, 0, user_data);
}
-void Channel::publish(string event, const char *data, unsigned char payload[],
+void Channel::publish(string event, const char *data, const unsigned char payload[],
int payload_size, void *user_data)
{
string to = "\"";
}
void Channel::publish(string event, const char *data, const char *target,
- unsigned char payload[], int payload_size, void *user_data)
+ const unsigned char payload[], int payload_size, void *user_data)
{
string to = "\"";
to.append(target);
}
void Channel::publish(string event, const char *data, Client client,
- unsigned char payload[], int payload_size, void *user_data)
+ const unsigned char payload[], int payload_size, void *user_data)
{
string to = "\"";
to.append(client.getId());
}
void Channel::publish(string event, const char *data, list<Client> clients,
- unsigned char payload[], int payload_size, void *user_data)
+ const unsigned char payload[], int payload_size, void *user_data)
{
string to = "[";
}
void Channel::publishMessage(string event, const char *data, const char *to,
- unsigned char payload[], int payload_size, void *user_data) {
+ const unsigned char payload[], int payload_size, void *user_data) {
publishMessage(Message::METHOD_EMIT, event, data, to, payload,
payload_size, user_data);
}
void Channel::publishMessage(string method, string event, const char *data,
- const char *to, unsigned char payload[],
+ const char *to, const unsigned char payload[],
int payload_size, void *user_data) {
+ if (data)
+ MSF_DBG("data len %d, payload len %d", strlen(data), payload_size);
+
if (!isWebSocketOpen()) {
handleError(string(), Error::create("Not Connected"));
return;
unsigned char *Channel::prepareMessageMap(string method, string event,
const char *data, const char *to,
long *prepare_buf_len,
- unsigned char payload[],
+ const unsigned char payload[],
int payload_size) {
int l = 0;
int header_size = 0;
- int prepare_buf_size = LWS_SEND_BUFFER_PRE_PADDING + payload_size + LWS_SEND_BUFFER_POST_PADDING + 128;
+ int prepare_buf_size = LWS_SEND_BUFFER_PRE_PADDING + strlen(data) + payload_size + 512 + LWS_SEND_BUFFER_POST_PADDING;
unsigned char *prepare_buf = new unsigned char[prepare_buf_size];
if (payload) {
payload_size);
l += payload_size;
-
//binary_message = true;
} else {
l += snprintf((char *)&prepare_buf[LWS_SEND_BUFFER_PRE_PADDING],
BuildRequires: pkgconfig(iotcon)
BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(capi-network-bluetooth)
-BuildRequires: pkgconfig(capi-network-wifi-direct)
+#BuildRequires: pkgconfig(capi-network-wifi-direct)
BuildRequires: pkgconfig(capi-appfw-application)
BuildRequires: pkgconfig(capi-network-connection)
BuildRequires: pkgconfig(bundle)