From: sangrae.kim Date: Wed, 21 Sep 2016 02:07:59 +0000 (+0900) Subject: [Convergence] Change the channel interface name, Channel->ChannelInfo X-Git-Tag: submit/tizen/20160921.085548~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F42%2F88842%2F2;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Convergence] Change the channel interface name, Channel->ChannelInfo SE TC Issue : Channel_notexist...(PASS) Change-Id: I5e39d2d71c717c8934c8496a49ad52ca2c885435 Signed-off-by: sangrae.kim --- diff --git a/src/convergence/convergence.gyp b/src/convergence/convergence.gyp index 1ab30fcd..1f6f14b3 100644 --- a/src/convergence/convergence.gyp +++ b/src/convergence/convergence.gyp @@ -27,8 +27,8 @@ 'convergence_remote_app_control_service.h', 'convergence_app_communication_service.cc', 'convergence_app_communication_service.h', - 'convergence_channel.cc', - 'convergence_channel.h', + 'convergence_channel_info.cc', + 'convergence_channel_info.h', 'convergence_payload.cc', 'convergence_payload.h', 'convergence_client_info.cc', diff --git a/src/convergence/convergence_api.js b/src/convergence/convergence_api.js index 1d048f7b..e570e070 100644 --- a/src/convergence/convergence_api.js +++ b/src/convergence/convergence_api.js @@ -540,15 +540,15 @@ native_.addListener('APP_COMMUNICATION_SERVICE_LISTENER', function(result) { break; case 'onStart': native_.callIfPossible(s._startCallback, - new Channel(result.channel.uri, result.channel.id), null); + new ChannelInfo(result.channel.uri, result.channel.id), null); break; case 'onPublish': native_.callIfPossible(s._sendCallback, - new Channel(result.channel.uri, result.channel.id), null); + new ChannelInfo(result.channel.uri, result.channel.id), null); break; case 'onStop': native_.callIfPossible(s._stopCallback, - new Channel(result.channel.uri, result.channel.id), null); + new ChannelInfo(result.channel.uri, result.channel.id), null); break; case 'onMessage': { var payload = []; @@ -568,7 +568,7 @@ native_.addListener('APP_COMMUNICATION_SERVICE_LISTENER', function(result) { } native_.callIfPossible(s._listenerCallback, - new Channel(result.channel.uri, result.channel.id), + new ChannelInfo(result.channel.uri, result.channel.id), payload, result.senderId); } break; @@ -595,7 +595,7 @@ AppCommunicationService.prototype.start = function(channel, successCallback, err { name: 'channel', type: types_.PLATFORM_OBJECT, - values: tizen.Channel, + values: tizen.ChannelInfo, optional: false, nullable: false }, @@ -641,7 +641,7 @@ AppCommunicationService.prototype.stop = function(channel, successCallback, erro { name: 'channel', type: types_.PLATFORM_OBJECT, - values: tizen.Channel, + values: tizen.ChannelInfo, optional: false, nullable: false }, @@ -690,7 +690,7 @@ AppCommunicationService.prototype.send = function(channel, payload, successCallb { name: 'channel', type: types_.PLATFORM_OBJECT, - values: tizen.Channel, + values: tizen.ChannelInfo, optional: false, nullable: false }, @@ -880,8 +880,8 @@ AppCommunicationClientService.prototype.disconnect = function(successCallback, e native_.callIfPossible(successCallback, this); }; -function Channel(uri, id) { - validator_.isConstructorCall(this, Channel); +function ChannelInfo(uri, id) { + validator_.isConstructorCall(this, ChannelInfo); this.uri = uri; this.id = id; } @@ -911,6 +911,6 @@ exports = new ConvergenceManager(); tizen.RemoteAppControlService = RemoteAppControlService; tizen.AppCommunicationServerService = AppCommunicationServerService; tizen.AppCommunicationClientService = AppCommunicationClientService; -tizen.Channel = Channel; +tizen.ChannelInfo = ChannelInfo; tizen.PayloadString = PayloadString; tizen.PayloadRawBytes = PayloadRawBytes; diff --git a/src/convergence/convergence_app_communication_service.cc b/src/convergence/convergence_app_communication_service.cc index 0cc7bd60..0be7f1d5 100644 --- a/src/convergence/convergence_app_communication_service.cc +++ b/src/convergence/convergence_app_communication_service.cc @@ -22,7 +22,7 @@ #include #include "convergence/convergence_instance.h" -#include "convergence/convergence_channel.h" +#include "convergence/convergence_channel_info.h" #include "convergence/convergence_payload.h" #include "convergence/convergence_client_info.h" #include "common/logger.h" diff --git a/src/convergence/convergence_channel.cc b/src/convergence/convergence_channel.cc deleted file mode 100644 index 45e77c85..00000000 --- a/src/convergence/convergence_channel.cc +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ - -// TODO check includes -#include "convergence/convergence_channel.h" - -#include -#include - -#include "convergence/convergence_instance.h" -#include "convergence/convergence_utils.h" -#include "common/logger.h" - -namespace extension { -namespace convergence { - -namespace { -// Channel keys -static const std::string kId = "id"; // This id is used in arguments (comes from JS layer) -static const std::string kChannelId = "channel_id"; // This id is used in the App Comm Service engine -static const std::string kUri = "uri"; -} // namespace - -ConvergenceChannel::ConvergenceChannel() - : channel_handle_(nullptr) { - ScopeLogger(); -} - -ConvergenceChannel::ConvergenceChannel(const picojson::value &channel_json) - : channel_handle_(nullptr) { - ScopeLogger(); - FromJson(channel_json); -} - -ConvergenceChannel::~ConvergenceChannel() { - ScopeLogger(); - - if (channel_handle_) { - conv_channel_destroy(channel_handle_); - channel_handle_ = NULL; - } -} - -conv_channel_h ConvergenceChannel::GetHandle() const { - ScopeLogger(); - return channel_handle_; -} - - -void ConvergenceChannel::FromJson(const picojson::value &channel_json) { - ScopeLogger(); - if (channel_json.is()) { - LoggerE("ERROR: Channel json value is NULL"); - return; - } - - if (channel_handle_) { - conv_channel_destroy(channel_handle_); - channel_handle_ = NULL; - } - - int error = conv_channel_create(&channel_handle_); - if ((CONV_ERROR_NONE != error) || !channel_handle_) { - trace_conv_error(error, __LINE__, "creating channel handle"); - return; - } - - const std::string id = channel_json.get(kId).to_str(); - error = conv_channel_set_string(channel_handle_, kChannelId.c_str(), id.c_str()); - if (CONV_ERROR_NONE != error) { - trace_conv_error(error, __LINE__, "setting channel string Id"); - } - - const std::string uri = channel_json.get(kUri).to_str(); - error = conv_channel_set_string(channel_handle_, kUri.c_str(), uri.c_str()); - if (CONV_ERROR_NONE != error) { - trace_conv_error(error, __LINE__, "setting channel string URI"); - } -} - -picojson::value ConvergenceChannel::ToJson(conv_channel_h channel_handle) { - ScopeLogger(); - - picojson::object channel_object; - if (!channel_handle) { - LoggerE("Error: trying to convert NULL channel handle to json"); - return picojson::value(channel_object); - } - - { // Extracting channel ID - char *id = nullptr; - const int error = conv_channel_get_string(channel_handle, kChannelId.c_str(), &id); - if (CONV_ERROR_NONE != error) { - trace_conv_error(error, __LINE__, "getting channel string Id"); - } else { - channel_object[kId] = picojson::value(id); - free(id); - } - } - - { // Extracting channel URI - char *uri = nullptr; - const int error = conv_channel_get_string(channel_handle, kUri.c_str(), &uri); - if (CONV_ERROR_NONE != error) { - trace_conv_error(error, __LINE__, "getting channel string URI"); - } else { - channel_object[kUri] = picojson::value(uri); - free(uri); - } - }; - - return picojson::value(channel_object); -} - - -} // namespace convergence -} // namespace extension diff --git a/src/convergence/convergence_channel.h b/src/convergence/convergence_channel.h deleted file mode 100644 index 952838cf..00000000 --- a/src/convergence/convergence_channel.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ - -#ifndef CONVERGENCE_CONVERGENCE_CHANNEL_H__ -#define CONVERGENCE_CONVERGENCE_CHANNEL_H__ - -// TODO check includes -#include - -#include -#include - -#include "common/tizen_result.h" - -namespace extension { -namespace convergence { - -class ConvergenceChannel { - - public: - ConvergenceChannel(); - ConvergenceChannel(const picojson::value &channel_json); - virtual ~ConvergenceChannel(); - ConvergenceChannel(const ConvergenceChannel&) = delete; - ConvergenceChannel(ConvergenceChannel&&) = delete; - ConvergenceChannel& operator=(const ConvergenceChannel&) = delete; - ConvergenceChannel& operator=(ConvergenceChannel&&) = delete; - - public: - conv_channel_h GetHandle() const; - void FromJson(const picojson::value &channel_json); - - public: - static picojson::value ToJson(conv_channel_h channel_handle); - - private: - conv_channel_h channel_handle_; -}; - -} // namespace convergence -} // namespace extension - -#endif // CONVERGENCE_CONVERGENCE_CHANNEL_H__ diff --git a/src/convergence/convergence_channel_info.cc b/src/convergence/convergence_channel_info.cc new file mode 100644 index 00000000..ef4d5795 --- /dev/null +++ b/src/convergence/convergence_channel_info.cc @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +// TODO check includes +#include "convergence/convergence_channel_info.h" + +#include +#include + +#include "convergence/convergence_instance.h" +#include "convergence/convergence_utils.h" +#include "common/logger.h" + +namespace extension { +namespace convergence { + +namespace { +// Channel keys +static const std::string kId = "id"; // This id is used in arguments (comes from JS layer) +static const std::string kChannelId = "channel_id"; // This id is used in the App Comm Service engine +static const std::string kUri = "uri"; +} // namespace + +ConvergenceChannel::ConvergenceChannel() + : channel_handle_(nullptr) { + ScopeLogger(); +} + +ConvergenceChannel::ConvergenceChannel(const picojson::value &channel_json) + : channel_handle_(nullptr) { + ScopeLogger(); + FromJson(channel_json); +} + +ConvergenceChannel::~ConvergenceChannel() { + ScopeLogger(); + + if (channel_handle_) { + conv_channel_destroy(channel_handle_); + channel_handle_ = NULL; + } +} + +conv_channel_h ConvergenceChannel::GetHandle() const { + ScopeLogger(); + return channel_handle_; +} + + +void ConvergenceChannel::FromJson(const picojson::value &channel_json) { + ScopeLogger(); + if (channel_json.is()) { + LoggerE("ERROR: Channel json value is NULL"); + return; + } + + if (channel_handle_) { + conv_channel_destroy(channel_handle_); + channel_handle_ = NULL; + } + + int error = conv_channel_create(&channel_handle_); + if ((CONV_ERROR_NONE != error) || !channel_handle_) { + trace_conv_error(error, __LINE__, "creating channel handle"); + return; + } + + const std::string id = channel_json.get(kId).to_str(); + error = conv_channel_set_string(channel_handle_, kChannelId.c_str(), id.c_str()); + if (CONV_ERROR_NONE != error) { + trace_conv_error(error, __LINE__, "setting channel string Id"); + } + + const std::string uri = channel_json.get(kUri).to_str(); + error = conv_channel_set_string(channel_handle_, kUri.c_str(), uri.c_str()); + if (CONV_ERROR_NONE != error) { + trace_conv_error(error, __LINE__, "setting channel string URI"); + } +} + +picojson::value ConvergenceChannel::ToJson(conv_channel_h channel_handle) { + ScopeLogger(); + + picojson::object channel_object; + if (!channel_handle) { + LoggerE("Error: trying to convert NULL channel handle to json"); + return picojson::value(channel_object); + } + + { // Extracting channel ID + char *id = nullptr; + const int error = conv_channel_get_string(channel_handle, kChannelId.c_str(), &id); + if (CONV_ERROR_NONE != error) { + trace_conv_error(error, __LINE__, "getting channel string Id"); + } else { + channel_object[kId] = picojson::value(id); + free(id); + } + } + + { // Extracting channel URI + char *uri = nullptr; + const int error = conv_channel_get_string(channel_handle, kUri.c_str(), &uri); + if (CONV_ERROR_NONE != error) { + trace_conv_error(error, __LINE__, "getting channel string URI"); + } else { + channel_object[kUri] = picojson::value(uri); + free(uri); + } + }; + + return picojson::value(channel_object); +} + + +} // namespace convergence +} // namespace extension diff --git a/src/convergence/convergence_channel_info.h b/src/convergence/convergence_channel_info.h new file mode 100644 index 00000000..952838cf --- /dev/null +++ b/src/convergence/convergence_channel_info.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +#ifndef CONVERGENCE_CONVERGENCE_CHANNEL_H__ +#define CONVERGENCE_CONVERGENCE_CHANNEL_H__ + +// TODO check includes +#include + +#include +#include + +#include "common/tizen_result.h" + +namespace extension { +namespace convergence { + +class ConvergenceChannel { + + public: + ConvergenceChannel(); + ConvergenceChannel(const picojson::value &channel_json); + virtual ~ConvergenceChannel(); + ConvergenceChannel(const ConvergenceChannel&) = delete; + ConvergenceChannel(ConvergenceChannel&&) = delete; + ConvergenceChannel& operator=(const ConvergenceChannel&) = delete; + ConvergenceChannel& operator=(ConvergenceChannel&&) = delete; + + public: + conv_channel_h GetHandle() const; + void FromJson(const picojson::value &channel_json); + + public: + static picojson::value ToJson(conv_channel_h channel_handle); + + private: + conv_channel_h channel_handle_; +}; + +} // namespace convergence +} // namespace extension + +#endif // CONVERGENCE_CONVERGENCE_CHANNEL_H__ diff --git a/src/convergence/convergence_extension.cc b/src/convergence/convergence_extension.cc index 6ddea572..08999335 100644 --- a/src/convergence/convergence_extension.cc +++ b/src/convergence/convergence_extension.cc @@ -33,7 +33,7 @@ ConvergenceExtension::ConvergenceExtension() { "tizen.RemoteAppControlService", "tizen.AppCommunicationServerService", "tizen.AppCommunicationClientService", - "tizen.Channel", + "tizen.ChannelInfo", "tizen.PayloadString", "tizen.PayloadRawBytes", nullptr diff --git a/src/convergence/convergence_instance.cc b/src/convergence/convergence_instance.cc index 22bd337a..48b589b6 100644 --- a/src/convergence/convergence_instance.cc +++ b/src/convergence/convergence_instance.cc @@ -22,7 +22,7 @@ #include "convergence/convergence_manager.h" #include "convergence/convergence_remote_app_control_service.h" #include "convergence/convergence_app_communication_service.h" -#include "convergence/convergence_channel.h" +#include "convergence/convergence_channel_info.h" #include "convergence/convergence_payload.h" #include "common/logger.h" #include "common/picojson.h"