#define CONV_SUBJECT_COMMUNICATION_STOP "conv/communication/stop"
#define CONV_SUBJECT_COMMUNICATION_GET "conv/communication/get"
#define CONV_SUBJECT_COMMUNICATION_SET "conv/communication/set"
+#define CONV_SUBJECT_COMMUNICATION_CHECK_STATE "conv/communication/check_state"
#define CONV_SUBJECT_COMMUNICATION_WRITE "conv/communication/write"
#define CONV_SUBJECT_COMMUNICATION_READ "conv/communication/read"
virtual int readRequest(Request* requestObj) = 0;
virtual int publishRequest(Request* requestObj) = 0;
virtual int registerRequest(Request* requestObj) = 0;
+ virtual int checkStateRequest(Request* requestObj) = 0;
virtual int loadServiceInfo(Request* requestObj) = 0;
virtual int getServiceInfoForDiscovery(Json* jsonObj) = 0;
int checkActivationState() {
if (!strcmp(requestObj->getSubject(), CONV_SUBJECT_DISCOVERY_START) || !strcmp(requestObj->getSubject(), CONV_SUBJECT_DISCOVERY_STOP))
return discovery_manager::handleRequest (requestObj);
else if ( !strcmp(requestObj->getSubject(), CONV_SUBJECT_COMMUNICATION_START) || !strcmp(requestObj->getSubject(), CONV_SUBJECT_COMMUNICATION_STOP)
- || !strcmp(requestObj->getSubject(), CONV_SUBJECT_COMMUNICATION_SET) || !strcmp(requestObj->getSubject(), CONV_SUBJECT_COMMUNICATION_GET) )
+ || !strcmp(requestObj->getSubject(), CONV_SUBJECT_COMMUNICATION_SET) || !strcmp(requestObj->getSubject(), CONV_SUBJECT_COMMUNICATION_GET)
+ || !strcmp(requestObj->getSubject(), CONV_SUBJECT_COMMUNICATION_CHECK_STATE))
result = service_manager::handleRequest(requestObj);
else if ( !strcmp(requestObj->getSubject(), CONV_SUBJECT_CONNECTION_START) || !strcmp(requestObj->getSubject(), CONV_SUBJECT_CONNECTION_STOP) )
result = connection_manager::handleRequest(requestObj);
error = (*it)->publishRequest(requestObj);
} else if (!strcmp(requestObj->getSubject(), CONV_SUBJECT_COMMUNICATION_RECV)) {
return (*it)->registerRequest(requestObj);
+ } else if (!strcmp(requestObj->getSubject(), CONV_SUBJECT_COMMUNICATION_CHECK_STATE)) {
+ error = (*it)->checkStateRequest(requestObj);
}
IF_FAIL_CATCH_TAG(error == CONV_ERROR_NONE, _E, "service manager request handle error");
}
for (ApplicationInstanceList::iterator iter = svcInfo->applicationInstanceList.begin(); iter != svcInfo->applicationInstanceList.end(); ++iter) {
_D("iteration");
if ( (*iter) != NULL && !(*iter)->uri.compare(uri) && !(*iter)->channelId.compare(channelId) ) {
- if ( (*iter)->state == APP_COMM_STATE_STARTED || (*iter)->state == APP_COMM_STATE_STARTING ) {
- _D("already started or now starting");
+ if ( (*iter)->state == APP_COMM_STATE_STARTED ) {
+ _D("already started");
return CONV_ERROR_INVALID_OPERATION;
} else {
_D("appInfo exists but no application instance");
_D("subscribe requested");
break;
case REQ_UNSUBSCRIBE:
+ delete svcInfo->registeredRequest;
svcInfo->registeredRequest = NULL;
requestObj->reply(CONV_ERROR_NONE);
delete requestObj;
return CONV_ERROR_NONE;
}
+int conv::AppCommServiceProvider::checkStateRequest(Request* requestObj)
+{
+ _D("communcation/check_state requested");
+ AppCommServiceInfo *svcInfo = reinterpret_cast<AppCommServiceInfo*>(requestObj->getServiceInfo());
+
+ Json channel;
+ requestObj->getChannelFromDescription(&channel);
+
+ string uri, channelId;
+
+ channel.get(NULL, CONV_JSON_URI, &uri);
+ channel.get(NULL, CONV_JSON_CHANNEL_ID, &channelId);
+
+ IF_FAIL_RETURN_TAG(!uri.empty() || svcInfo->isLocal, CONV_ERROR_INVALID_PARAMETER, _E, "uri is empty");
+ IF_FAIL_RETURN_TAG(!channelId.empty(), CONV_ERROR_INVALID_PARAMETER, _E, "channelId is empty");
+
+ for (ApplicationInstanceList::iterator iter = svcInfo->applicationInstanceList.begin(); iter != svcInfo->applicationInstanceList.end(); ++iter) {
+ _D("%s, %s", (*iter)->uri.c_str(), (*iter)->channelId.c_str());
+ if ( (*iter) != NULL && !(*iter)->uri.compare(uri) && !(*iter)->channelId.compare(channelId) ) {
+ if ( (*iter)->state == APP_COMM_STATE_STARTED ) {
+ _D("service is started");
+ return CONV_ERROR_NONE;
+ } else {
+ _D("service is not started");
+ return CONV_ERROR_INVALID_OPERATION;
+ }
+ }
+ }
+
+ _D("no service found");
+ return CONV_ERROR_NONE;
+}
+
int conv::AppCommServiceProvider::getServiceInfoForDiscovery(Json* jsonObj)
{
jsonObj->set(NULL, CONV_JSON_DISCOVERY_SERVICE_TYPE, CONV_SERVICE_APP_TO_APP_COMMUNICATION);
int readRequest(Request* requestObj);
int publishRequest(Request* requestObj);
int registerRequest(Request* requestObj);
+ int checkStateRequest(Request* requestObj);
int loadServiceInfo(Request* requestObj);
int getServiceInfoForDiscovery(Json* jsonObj);
int handleVconfUpdate(keynode_t *node);
return CONV_ERROR_NONE;
}
+int conv::RemoteAppControlServiceProvider::checkStateRequest(Request* requestObj)
+{
+ _D("communcation/check_state requested");
+
+ RemoteAppControlServiceInfo *svcInfo = reinterpret_cast<RemoteAppControlServiceInfo*>(requestObj->getServiceInfo());
+
+ if (svcInfo->iotconInfoObj.iotconResourceHandle == NULL) {
+ _D("not started");
+ return CONV_ERROR_INVALID_OPERATION;
+ } else {
+ _D("started");
+ return CONV_ERROR_NONE;
+ }
+}
+
int conv::RemoteAppControlServiceProvider::readRequest(Request* requestObj)
{
return CONV_ERROR_NONE;
int readRequest(Request* requestObj);
int publishRequest(Request* requestObj);
int registerRequest(Request* requestObj);
+ int checkStateRequest(Request* requestObj);
int loadServiceInfo(Request* requestObj);
int getServiceInfoForDiscovery(Json* jsonObj);
int handleVconfUpdate(keynode_t *node);
json description;
json service = handle->jservice;
+ json device = handle->jdevice;
std::string service_type = convert_type_to_string(handle->service_type);
if (service_type.empty())
description.set(NULL, CONV_JSON_SERVICE, service);
description.set(NULL, CONV_JSON_TYPE, service_type);
+ description.set(NULL, CONV_JSON_DEVICE, device);
description.set(NULL, CONV_JSON_IS_LOCAL, handle->is_local);
int req_id;
}
return service_type;
}
+
+EXTAPI int conv_service_is_started(conv_service_h handle, conv_channel_h channel_handle, bool* started)
+{
+ ASSERT_NOT_NULL(handle);
+ ASSERT_NOT_NULL(started);
+
+ IF_FAIL_RETURN_TAG(conv::util::is_feature_supported(), CONV_ERROR_NOT_SUPPORTED, _E, "Not supported");
+
+ *started = false;
+
+ int req_id;
+
+ json description;
+ json channel;
+ json payload;
+
+ if (channel_handle != NULL)
+ channel = channel_handle->jchannel;
+
+ json service = handle->jservice;
+ json device = handle->jdevice;
+ std::string type = convert_type_to_string(handle->service_type);
+ if (type.empty())
+ return CONV_ERROR_INVALID_PARAMETER;
+
+ description.set(NULL, CONV_JSON_SERVICE, service);
+ description.set(NULL, CONV_JSON_CHANNEL, channel);
+ description.set(NULL, CONV_JSON_DEVICE, device);
+ 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_CHECK_STATE, description.str().c_str(), 0, NULL);
+ IF_FAIL_RETURN_TAG(err == CONV_ERROR_NONE, err, _E, "Failed to get started status");
+
+ *started = true;
+
+ return CONV_ERROR_NONE;
+}
+
//LCOV_EXCL_STOP
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);
- _D("%s", binary);
+
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, length, binary);
*/
int conv_payload_get_binary(conv_payload_h handle, int* length, const unsigned char** value);
+/**
+ * @brief Gets service start status.
+ * @since_tizen 3.0
+ *
+ * @param[in] handle The service handle
+ * @param[in] channel_handle The channel handle
+ * @param[out] started The boolean value of service started check
+ *
+ * @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
+ *
+ */
+int conv_service_is_started(conv_service_h handle, conv_channel_h channel_handle, bool* started);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */