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();
}
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");
}
}
}
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();
+ }
}
}
}
if (type == CION_PAYLOAD_TYPE_FILE) {
- cl->listener_->OnFileReceived(payload, peer_info, status);
+ cl->listener_->OnFileReceived(peer_info, payload, status);
return;
}
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[] =
/// <summary>
/// Constructor for this class
/// </summary>
- /// <param name="service_name">The service name for </param>
+ /// <param name="listener">The listener for events</param>
+ /// <param name="service_name">The service name to connect</param>
+ /// <param name="target_appid">The service app ID to connect</param>
+ /// <exception cref="InvalidIOException">
+ /// Thrown when internal I/O error happen.
+ /// </exception>
explicit $$(IEventListener* listener, const std::string& service_name,
const std::string& target_appid);
/// <summary>
/// Connects to the service app.
/// </summary>
+ /// <privilege>http://tizen.org/privilege/d2d.datasharing</privilege>
+ /// <privilege>http://tizen.org/privilege/internet</privilege>
+ /// <exception cref="UnauthorizedAccessException">
+ /// Thrown when an application does not have the privilege to access this method.
+ /// </exception>
+ /// <exception cref="NotConnectedSocketException">
+ /// Thrown when a service app was not discovered.
+ /// </exception>
+ /// <exception cref="InvalidIOException">
+ /// Thrown when internal I/O error happen.
+ /// </exception>
void Connect();
/// <summary>
/// Disconnects to the service app.
/// </summary>
+ /// <exception cref="NotConnectedSocketException">
+ /// Thrown when a service app was not connected.
+ /// </exception>
void Disconnect();
+ /// <summary>
+ /// Tries to discover a Cion server.
+ /// </summary>
+ /// <privilege>http://tizen.org/privilege/d2d.datasharing</privilege>
+ /// <privilege>http://tizen.org/privilege/internet</privilege>
+ /// <exception cref="UnauthorizedAccessException">
+ /// Thrown when an application does not have the privilege to access this method.
+ /// </exception>
+ /// <exception cref="InvalidIOException">
+ /// Thrown when internal I/O error happen.
+ /// </exception>
void Discovery();
+
+ /// <summary>
+ /// Stops discovering.
+ /// </summary>
void StopDiscovery();
/// <summary>
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();
+ }
}
}
}
}
+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) {
}
if (type == CION_PAYLOAD_TYPE_FILE) {
- b->OnFileReceived(payload, peer_info, status);
+ b->OnFileReceived(peer_info, payload, status);
return;
}
class NotConnectedSocketException : public Exception {};
class InvalidProtocolException : public Exception {};
class InvalidIOException : public Exception {};
+class UnauthorizedAccessException : public Exception {};
class InvalidCallbackException : public Exception {};
)__cpp_cb";
public:
class Factory {
public:
+ virtual ~Factory() = default;
+
/// <summary>
/// The method for making service instances
/// </summary>
)__cpp_cb";
const char CB_PUBLIC_METHODS[] =
-R"__cpp_cb( ##(const std::string& service_name, const std::string& display_name);
+R"__cpp_cb(
+ /// <summary>
+ /// Constructor for this class
+ /// </summary>
+ /// <param name="service_name">The service name of server</param>
+ /// <param name="display_name">The display name of server</param>
+ /// <exception cref="InvalidIOException">
+ /// Thrown when internal I/O error happen.
+ /// </exception>
+ ##(const std::string& service_name, const std::string& display_name);
~##();
/// <summary>
/// Listens to client apps
/// </summary>
+ /// <privilege>http://tizen.org/privilege/d2d.datasharing</privilege>
+ /// <privilege>http://tizen.org/privilege/internet</privilege>
/// <param name="service_factory">The factory object for making service instances</param>
/// <exception cref="InvalidIOException">
/// Thrown when internal I/O error happen.
/// </exception>
+ /// <exception cref="UnauthorizedAccessException">
+ /// Thrown when an application does not have the privilege to access this method.
+ /// </exception>
void Listen(std::shared_ptr<ServiceBase::Factory> service_factory);
/// <summary>
/// Accepts client apps
/// </summary>
+ /// <param name="service">The service object to accept cion client</param>
void Accept(std::shared_ptr<ServiceBase> service);
/// <summary>
/// Rejects client apps
/// </summary>
+ /// <param name="service">The service object to reject cion client</param>
+ /// <param name="reason">The reason message for rejection</param>
void Reject(std::shared_ptr<ServiceBase> service, std::string reason);
/// <summary>
/// Disconnects client apps
/// </summary>
+ /// <param name="service">The service object to disconnect cion client</param>
void Disconnect(std::shared_ptr<ServiceBase> service);
/// <summary>
+ /// Sets the stub display name.
+ /// The display name is a customized name for stub.
+ void SetDisplayName(std::string display_name);
+
+ /// <summary>
+ /// Sets on-demand launch state
+ /// </summary>
+ /// <privilege>http://tizen.org/privilege/d2d.remotelaunch</privilege>
+ /// <exception cref="InvalidIOException">
+ /// Thrown when internal I/O error happen.
+ /// </exception>
+ /// <exception cref="UnauthorizedAccessException">
+ /// Thrown when an application does not have the privilege to access this method.
+ /// </exception>
+ void SetOndemandLaunchEnable(bool enabled);
+
+ /// <summary>
/// Gets service objects which are connected
/// </summary>
/// <returns>The list of service objects which are connected</returns>