From: Inkyun Kil Date: Thu, 21 Oct 2021 04:20:30 +0000 (+0900) Subject: Updates cpp cion X-Git-Tag: submit/tizen/20211028.054746~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F78%2F265678%2F5;p=platform%2Fcore%2Fappfw%2Ftidl.git Updates cpp cion - Updates comments - Adds missed methods - Fix exceptions - Fix issue for OnFileReceived Change-Id: Iff45a03846849a0541910e687202cad9c118d0c8 Signed-off-by: Inkyun Kil --- diff --git a/idlc/gen_cion/cpp_cion_proxy_body_gen_cb.h b/idlc/gen_cion/cpp_cion_proxy_body_gen_cb.h index 131cfbc8..1a628ce4 100644 --- a/idlc/gen_cion/cpp_cion_proxy_body_gen_cb.h +++ b/idlc/gen_cion/cpp_cion_proxy_body_gen_cb.h @@ -44,7 +44,7 @@ R"__cpp_cb( ret = cion_client_send_data(cion_client_, (unsigned char *)data, size, 100, &return_data, &return_data_size); if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to cion_client_send_data : error(%d)", ret); + _E("Failed to cion_client_send_data : error(%d)", ret); rpc_port_parcel_destroy(p); throw InvalidIOException(); } @@ -154,10 +154,18 @@ void ##::Connect() { int ret = cion_client_connect(cion_client_, peer_); if (ret != CION_ERROR_NONE) { _E("Failed to connect to stub. error(%d)", ret); - return; + switch(ret) { + case CION_ERROR_PERMISSION_DENIED : + throw UnauthorizedAccessException(); + break; + case CION_ERROR_INVALID_PARAMETER : + throw NotConnectedSocketException(); + break; + default : + throw InvalidIOException(); + } } - } - else { + } else { _E("Not discovered"); } } @@ -191,13 +199,24 @@ void ##::ProcessReceivedEvent(rpc_port_parcel_h parcel) { } void ##::Disconnect() { + int ret = cion_client_disconnect(cion_client_); + if (ret != CION_ERROR_NONE) { + _E("Failed to disconnect to stub. error(%d)", ret); + throw NotConnectedSocketException(); + } } void ##::Discovery() { int ret = cion_client_try_discovery(cion_client_, OnDiscoveredCB, this); if (ret != CION_ERROR_NONE) { _E("Failed to discovery to stub. error(%d)", ret); - return; + switch(ret) { + case CION_ERROR_PERMISSION_DENIED : + throw UnauthorizedAccessException(); + break; + default : + throw InvalidIOException(); + } } } @@ -284,7 +303,7 @@ void ##::OnPayloadReceivedCB(const char *service_name, } if (type == CION_PAYLOAD_TYPE_FILE) { - cl->listener_->OnFileReceived(payload, peer_info, status); + cl->listener_->OnFileReceived(peer_info, payload, status); return; } diff --git a/idlc/gen_cion/cpp_cion_proxy_header_gen_cb.h b/idlc/gen_cion/cpp_cion_proxy_header_gen_cb.h index d09e7e1b..9a73fcd0 100644 --- a/idlc/gen_cion/cpp_cion_proxy_header_gen_cb.h +++ b/idlc/gen_cion/cpp_cion_proxy_header_gen_cb.h @@ -23,8 +23,7 @@ class Exception {}; class NotConnectedSocketException : public Exception {}; class InvalidProtocolException : public Exception {}; class InvalidIOException : public Exception {}; -class PermissionDeniedException : public Exception {}; -class InvalidIDException : public Exception {}; +class UnauthorizedAccessException : public Exception {}; )__cpp_cb"; const char CB_PUBLIC_MEMBERS[] = @@ -61,7 +60,12 @@ R"__cpp_cb( /// /// Constructor for this class /// - /// The service name for + /// The listener for events + /// The service name to connect + /// The service app ID to connect + /// + /// Thrown when internal I/O error happen. + /// explicit $$(IEventListener* listener, const std::string& service_name, const std::string& target_appid); @@ -73,14 +77,43 @@ R"__cpp_cb( /// /// Connects to the service app. /// + /// http://tizen.org/privilege/d2d.datasharing + /// http://tizen.org/privilege/internet + /// + /// Thrown when an application does not have the privilege to access this method. + /// + /// + /// Thrown when a service app was not discovered. + /// + /// + /// Thrown when internal I/O error happen. + /// void Connect(); /// /// Disconnects to the service app. /// + /// + /// Thrown when a service app was not connected. + /// void Disconnect(); + /// + /// Tries to discover a Cion server. + /// + /// http://tizen.org/privilege/d2d.datasharing + /// http://tizen.org/privilege/internet + /// + /// Thrown when an application does not have the privilege to access this method. + /// + /// + /// Thrown when internal I/O error happen. + /// void Discovery(); + + /// + /// Stops discovering. + /// void StopDiscovery(); /// diff --git a/idlc/gen_cion/cpp_cion_stub_body_gen_cb.h b/idlc/gen_cion/cpp_cion_stub_body_gen_cb.h index d521640c..929564cf 100644 --- a/idlc/gen_cion/cpp_cion_stub_body_gen_cb.h +++ b/idlc/gen_cion/cpp_cion_stub_body_gen_cb.h @@ -75,7 +75,13 @@ void ##::Listen(std::shared_ptr<##::ServiceBase::Factory> service_factory) { int ret = cion_server_listen(cion_server_, OnConnectionRequestCB, this); if (ret != CION_ERROR_NONE) { _E("Failed to cion_server_listen. error(%d)", ret); - throw InvalidIOException(); + switch(ret) { + case CION_ERROR_PERMISSION_DENIED : + throw UnauthorizedAccessException(); + break; + default : + throw InvalidIOException(); + } } } @@ -109,6 +115,28 @@ void ##::Disconnect(std::shared_ptr service) { } } +void ##::SetDisplayName(std::string display_name) { + int ret = cion_server_set_display_name(cion_server_, display_name.c_str()); + if (ret != CION_ERROR_NONE) { + _E("Failed to cion_server_set_display_name. error(%d)", ret); + InvalidIOException(); + } +} + +void ##::SetOndemandLaunchEnable(bool enabled) { + int ret = cion_server_set_on_demand_launch_enabled(cion_server_, enabled); + if (ret != CION_ERROR_NONE) { + _E("Failed to cion_server_set_on_demand_launch_enabled. error(%d)", ret); + switch(ret) { + case CION_ERROR_PERMISSION_DENIED : + throw UnauthorizedAccessException(); + break; + default : + throw InvalidIOException(); + } + } +} + void ##::OnConnectionResultCB(const char *service_name, const cion_peer_info_h peer_info, const cion_connection_result_h result, void *user_data) { @@ -311,7 +339,7 @@ void $$::OnPayloadReceivedCB(const char *service_name, } if (type == CION_PAYLOAD_TYPE_FILE) { - b->OnFileReceived(payload, peer_info, status); + b->OnFileReceived(peer_info, payload, status); return; } diff --git a/idlc/gen_cion/cpp_cion_stub_header_gen_cb.h b/idlc/gen_cion/cpp_cion_stub_header_gen_cb.h index 5cb1e344..ab47e686 100644 --- a/idlc/gen_cion/cpp_cion_stub_header_gen_cb.h +++ b/idlc/gen_cion/cpp_cion_stub_header_gen_cb.h @@ -23,6 +23,7 @@ class Exception {}; class NotConnectedSocketException : public Exception {}; class InvalidProtocolException : public Exception {}; class InvalidIOException : public Exception {}; +class UnauthorizedAccessException : public Exception {}; class InvalidCallbackException : public Exception {}; )__cpp_cb"; @@ -57,6 +58,8 @@ R"__cpp_cb( public: class Factory { public: + virtual ~Factory() = default; + /// /// The method for making service instances /// @@ -128,33 +131,68 @@ R"__cpp_cb( )__cpp_cb"; const char CB_PUBLIC_METHODS[] = -R"__cpp_cb( ##(const std::string& service_name, const std::string& display_name); +R"__cpp_cb( + /// + /// Constructor for this class + /// + /// The service name of server + /// The display name of server + /// + /// Thrown when internal I/O error happen. + /// + ##(const std::string& service_name, const std::string& display_name); ~##(); /// /// Listens to client apps /// + /// http://tizen.org/privilege/d2d.datasharing + /// http://tizen.org/privilege/internet /// The factory object for making service instances /// /// Thrown when internal I/O error happen. /// + /// + /// Thrown when an application does not have the privilege to access this method. + /// void Listen(std::shared_ptr service_factory); /// /// Accepts client apps /// + /// The service object to accept cion client void Accept(std::shared_ptr service); /// /// Rejects client apps /// + /// The service object to reject cion client + /// The reason message for rejection void Reject(std::shared_ptr service, std::string reason); /// /// Disconnects client apps /// + /// The service object to disconnect cion client void Disconnect(std::shared_ptr service); + /// + /// Sets the stub display name. + /// The display name is a customized name for stub. + void SetDisplayName(std::string display_name); + + /// + /// Sets on-demand launch state + /// + /// http://tizen.org/privilege/d2d.remotelaunch + /// + /// Thrown when internal I/O error happen. + /// + /// + /// Thrown when an application does not have the privilege to access this method. + /// + void SetOndemandLaunchEnable(bool enabled); + /// /// Gets service objects which are connected ///