Skip to content

Commit

Permalink
[Applications.Cion] Fix namespace, ServerBase.DisplayName property, d…
Browse files Browse the repository at this point in the history
…ocfx (#3553)

* [Applications.Cion] Fix DisplayName property

Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>

* [Applications.Cion] Fix doxygen comments

Add missing description of exceptions.

Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>

* Fix ServerBase.DisplayName property

Add missing setting _displayName.

Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>

* Add privilege description at ClientBase.Discovery

Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>

* Add some remarks FilePayload class

Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>

* Add exception description of Client.TryDiscovery

Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>

* Add exception description at FilePayload class

Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>

* Add privlevel descriptions

Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>

* Fix typo

Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>

* Fix logging

- Remove debugging logs.
- Change log tag to "Tizen.Applications.Cion".

Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>

* Add remarks exceptions at SecurityInfo class

Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>

* Fix native error code

Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>

* Fix interop delegate name

Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>

* Fix cion

- Fix bad codes.
- Update native API changes.

Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>

* Fix typo

Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>

* Fix bug of ClientBase.SendPayloadAsync

Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>

* Adjust changes of native APIs

Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>

* Fix typo

ServerBase.OnConnentionRequest() -> ServerBase.OnConnectionRequest()

Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>

* Add missing privilege requirements

Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>

* Fix namespace

Fix namespace to Tizen.Applications.Cion from Tizen.Applications.

Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
  • Loading branch information
jeremy-jang committed Oct 13, 2021
1 parent c34d577 commit d63174d
Show file tree
Hide file tree
Showing 29 changed files with 253 additions and 112 deletions.
7 changes: 5 additions & 2 deletions src/Tizen.Applications.Cion/Interop/Interop.Cion.cs
Expand Up @@ -21,12 +21,15 @@ internal static partial class Cion
internal enum ErrorCode : int
{
None = Tizen.Internals.Errors.ErrorCode.None,
InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
IoError = Tizen.Internals.Errors.ErrorCode.IoError,
OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,
InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
InvalidOperation = Tizen.Internals.Errors.ErrorCode.InvalidOperation,
AlreadyInProgress = Tizen.Internals.Errors.ErrorCode.AlreadyInProgress,
NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported,
TimedOut = Tizen.Internals.Errors.ErrorCode.TimedOut,
OperationFailed = -0x030C0000 | 0x01,
}
}
}
23 changes: 16 additions & 7 deletions src/Tizen.Applications.Cion/Interop/Interop.CionClient.cs
Expand Up @@ -16,7 +16,7 @@

using System;
using System.Runtime.InteropServices;
using Tizen.Applications;
using Tizen.Applications.Cion;

using ErrorCode = Interop.Cion.ErrorCode;

Expand All @@ -25,13 +25,13 @@ internal static partial class Interop
internal static partial class CionClient
{
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void CionClientDiscoveredCb(string serviceName, IntPtr peerInfo, IntPtr userData);
internal delegate void CionClientServerDiscoveredCb(string serviceName, IntPtr peerInfo, IntPtr userData);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void CionClientConnectionResultCb(string serviceName, IntPtr peerInfo, IntPtr result, IntPtr userData);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void CionClientPayloadRecievedCb(string serviceName, IntPtr peerInfo, IntPtr payload, int status, IntPtr userData);
internal delegate void CionClientPayloadReceivedCb(string serviceName, IntPtr peerInfo, IntPtr payload, int status, IntPtr userData);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void CionClientDisconnectedCb(string serviceName, IntPtr peerInfo, IntPtr userData);
Expand All @@ -42,11 +42,11 @@ internal static partial class CionClient
[DllImport(Libraries.Cion, EntryPoint = "cion_client_create")]
internal static extern ErrorCode CionClientCreate(out ClientSafeHandle client, string serviceName, IntPtr security);

[DllImport(Libraries.Cion, EntryPoint = "cion_client_destory")]
[DllImport(Libraries.Cion, EntryPoint = "cion_client_destroy")]
internal static extern ErrorCode CionClientDestroy(IntPtr client);

[DllImport(Libraries.Cion, EntryPoint = "cion_client_try_discovery")]
internal static extern ErrorCode CionClientTryDiscovery(ClientSafeHandle client, CionClientDiscoveredCb cb, IntPtr userData);
internal static extern ErrorCode CionClientTryDiscovery(ClientSafeHandle client, CionClientServerDiscoveredCb cb, IntPtr userData);

[DllImport(Libraries.Cion, EntryPoint = "cion_client_stop_discovery")]
internal static extern ErrorCode CionClientStopDiscovery(ClientSafeHandle client);
Expand All @@ -66,10 +66,19 @@ internal static partial class CionClient
[DllImport(Libraries.Cion, EntryPoint = "cion_client_add_connection_result_cb")]
internal static extern ErrorCode CionClientAddConnectionResultCb(ClientSafeHandle client, CionClientConnectionResultCb cb, IntPtr userData);

[DllImport(Libraries.Cion, EntryPoint = "cion_client_add_payload_recieved_cb")]
internal static extern ErrorCode CionClientAddPayloadReceivedCb(ClientSafeHandle client, CionClientPayloadRecievedCb cb, IntPtr userData);
[DllImport(Libraries.Cion, EntryPoint = "cion_client_remove_connection_result_cb")]
internal static extern ErrorCode CionClientRemoveConnectionResultCb(ClientSafeHandle client, CionClientConnectionResultCb cb);

[DllImport(Libraries.Cion, EntryPoint = "cion_client_add_payload_received_cb")]
internal static extern ErrorCode CionClientAddPayloadReceivedCb(ClientSafeHandle client, CionClientPayloadReceivedCb cb, IntPtr userData);

[DllImport(Libraries.Cion, EntryPoint = "cion_client_remove_payload_received_cb")]
internal static extern ErrorCode CionClientRemovePayloadReceivedCb(ClientSafeHandle client, CionClientPayloadReceivedCb cb);

[DllImport(Libraries.Cion, EntryPoint = "cion_client_add_disconnected_cb")]
internal static extern ErrorCode CionClientAddDisconnectedCb(ClientSafeHandle client, CionClientDisconnectedCb cb, IntPtr userData);

[DllImport(Libraries.Cion, EntryPoint = "cion_client_remove_disconnected_cb")]
internal static extern ErrorCode CionClientRemoveDisconnectedCb(ClientSafeHandle client, CionClientDisconnectedCb cb);
}
}
Expand Up @@ -16,7 +16,7 @@

using System;
using System.Runtime.InteropServices;
using Tizen.Applications;
using Tizen.Applications.Cion;

using ErrorCode = Interop.Cion.ErrorCode;

Expand Down
11 changes: 10 additions & 1 deletion src/Tizen.Applications.Cion/Interop/Interop.CionGroup.cs
Expand Up @@ -16,7 +16,7 @@

using System;
using System.Runtime.InteropServices;
using Tizen.Applications;
using Tizen.Applications.Cion;

using ErrorCode = Interop.Cion.ErrorCode;

Expand Down Expand Up @@ -51,10 +51,19 @@ internal static partial class CionGroup
[DllImport(Libraries.Cion, EntryPoint = "cion_group_add_payload_received_cb")]
internal static extern ErrorCode CionGroupAddPayloadReceivedCb(GroupSafeHandle group, CionGroupPayloadReceivedCb cb, IntPtr userData);

[DllImport(Libraries.Cion, EntryPoint = "cion_group_remove_payload_received_cb")]
internal static extern ErrorCode CionGroupRemovePayloadReceivedCb(GroupSafeHandle group, CionGroupPayloadReceivedCb cb);

[DllImport(Libraries.Cion, EntryPoint = "cion_group_add_joined_cb")]
internal static extern ErrorCode CionGroupAddJoinedCb(GroupSafeHandle group, CionGroupJoinedCb cb, IntPtr userData);

[DllImport(Libraries.Cion, EntryPoint = "cion_group_remove_joined_cb")]
internal static extern ErrorCode CionGroupRemoveJoinedCb(GroupSafeHandle group, CionGroupJoinedCb cb);

[DllImport(Libraries.Cion, EntryPoint = "cion_group_add_left_cb")]
internal static extern ErrorCode CionGroupAddLeftCb(GroupSafeHandle group, CionGroupLeftCb cb, IntPtr userData);

[DllImport(Libraries.Cion, EntryPoint = "cion_group_remove_left_cb")]
internal static extern ErrorCode CionGroupRemoveLeftCb(GroupSafeHandle group, CionGroupLeftCb cb);
}
}
2 changes: 1 addition & 1 deletion src/Tizen.Applications.Cion/Interop/Interop.CionPayload.cs
Expand Up @@ -16,7 +16,7 @@

using System;
using System.Runtime.InteropServices;
using Tizen.Applications;
using Tizen.Applications.Cion;

using ErrorCode = Interop.Cion.ErrorCode;

Expand Down
Expand Up @@ -16,7 +16,7 @@

using System;
using System.Runtime.InteropServices;
using Tizen.Applications;
using Tizen.Applications.Cion;

using ErrorCode = Interop.Cion.ErrorCode;

Expand Down
Expand Up @@ -16,7 +16,7 @@

using System;
using System.Runtime.InteropServices;
using Tizen.Applications;
using Tizen.Applications.Cion;

using ErrorCode = Interop.Cion.ErrorCode;

Expand Down
37 changes: 24 additions & 13 deletions src/Tizen.Applications.Cion/Interop/Interop.CionServer.cs
Expand Up @@ -16,7 +16,7 @@

using System;
using System.Runtime.InteropServices;
using Tizen.Applications;
using Tizen.Applications.Cion;

using ErrorCode = Interop.Cion.ErrorCode;

Expand All @@ -25,7 +25,7 @@ internal static partial class Interop
internal static partial class CionServer
{
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void CionServerPeerInfoIterator(IntPtr peerInfo, IntPtr userData);
internal delegate bool CionServerPeerInfoIterator(IntPtr peerInfo, IntPtr userData);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void CionServerPayloadAsyncResultCb(IntPtr result, IntPtr userData);
Expand All @@ -37,7 +37,7 @@ internal static partial class CionServer
internal delegate void CionServerDataReceivedCb(string serviceName, IntPtr peerInfo, byte[] data, int dataSize, out byte[] returnData, out int returnDataSize, IntPtr userData);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void CionServerPayloadRecievedCb(string serviceName, IntPtr peerInfo, IntPtr payload, int status, IntPtr userData);
internal delegate void CionServerPayloadReceivedCb(string serviceName, IntPtr peerInfo, IntPtr payload, int status, IntPtr userData);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void CionServerConnectionRequestCb(string serviceName, IntPtr peerInfo, IntPtr userData);
Expand All @@ -51,7 +51,7 @@ internal static partial class CionServer
[DllImport(Libraries.Cion, EntryPoint = "cion_server_create")]
internal static extern ErrorCode CionServerCreate(out ServerSafeHandle server, string serviceName, string displayName, IntPtr security);

[DllImport(Libraries.Cion, EntryPoint = "cion_server_destory")]
[DllImport(Libraries.Cion, EntryPoint = "cion_server_destroy")]
internal static extern ErrorCode CionServerDestroy(IntPtr server);

[DllImport(Libraries.Cion, EntryPoint = "cion_server_listen")]
Expand All @@ -70,28 +70,39 @@ internal static partial class CionServer
internal static extern ErrorCode CionServerDisconnect(ServerSafeHandle server, PeerInfoSafeHandle peerInfo);

[DllImport(Libraries.Cion, EntryPoint = "cion_server_send_payload_async")]
internal static extern ErrorCode CionServerSendPayloadAsync(ServerSafeHandle server, PeerInfoSafeHandle peerInfo, PayloadSafeHandle payload,
CionServerPayloadAsyncResultCb cb, IntPtr userData);
internal static extern ErrorCode CionServerSendPayloadAsync(ServerSafeHandle server, PeerInfoSafeHandle peerInfo, PayloadSafeHandle payload, CionServerPayloadAsyncResultCb cb, IntPtr userData);

[DllImport(Libraries.Cion, EntryPoint = "cion_server_foreach_connected_peer_info")]
internal static extern ErrorCode CionServerForeachConnectedPeerInfo(ServerSafeHandle server, CionServerPeerInfoIterator cb, IntPtr userData);

[DllImport(Libraries.Cion, EntryPoint = "cion_server_add_connection_result_cb")]
internal static extern ErrorCode CionServerAddConnectionResultCb(ServerSafeHandle server, CionServerConnectionResultCb cb, IntPtr userData);

[DllImport(Libraries.Cion, EntryPoint = "cion_server_add_payload_recieved_cb")]
internal static extern ErrorCode CionServerAddPayloadReceivedCb(ServerSafeHandle server, CionServerPayloadRecievedCb cb, IntPtr userData);
[DllImport(Libraries.Cion, EntryPoint = "cion_server_remove_connection_result_cb")]
internal static extern ErrorCode CionServerRemoveConnectionResultCb(ServerSafeHandle server, CionServerConnectionResultCb cb);

[DllImport(Libraries.Cion, EntryPoint = "cion_server_add_error_reported_cb")]
internal static extern ErrorCode CionServerAddErrorReportedCb(ServerSafeHandle server, CionServerErrorReportedCb cb, IntPtr userData);
[DllImport(Libraries.Cion, EntryPoint = "cion_server_add_payload_received_cb")]
internal static extern ErrorCode CionServerAddPayloadReceivedCb(ServerSafeHandle server, CionServerPayloadReceivedCb cb, IntPtr userData);

[DllImport(Libraries.Cion, EntryPoint = "cion_server_set_data_recieved_cb")]
[DllImport(Libraries.Cion, EntryPoint = "cion_server_remove_payload_received_cb")]
internal static extern ErrorCode CionServerRemovePayloadReceivedCb(ServerSafeHandle server, CionServerPayloadReceivedCb cb, IntPtr userData);

[DllImport(Libraries.Cion, EntryPoint = "cion_server_set_data_received_cb")]
internal static extern ErrorCode CionServerSetDataReceivedCb(ServerSafeHandle server, CionServerDataReceivedCb cb, IntPtr userData);

[DllImport(Libraries.Cion, EntryPoint = "cion_server_unset_data_received_cb")]
internal static extern ErrorCode CionServerUnsetDataReceivedCb(ServerSafeHandle server, CionServerDataReceivedCb cb);

[DllImport(Libraries.Cion, EntryPoint = "cion_server_add_disconnected_cb")]
internal static extern ErrorCode CionServerAddDisconnectedCb(ServerSafeHandle server, CionServerDisconnectedCb cb, IntPtr userData);

[DllImport(Libraries.Cion, EntryPoint = "cion_server_set_ondemand_launch_enable")]
internal static extern ErrorCode CionServerSetOndemandLaunchEnable(ServerSafeHandle server, bool enable);
[DllImport(Libraries.Cion, EntryPoint = "cion_server_remove_disconnected_cb")]
internal static extern ErrorCode CionServerRemoveDisconnectedCb(ServerSafeHandle server, CionServerDisconnectedCb cb);

[DllImport(Libraries.Cion, EntryPoint = "cion_server_set_on_demand_launch_enabled")]
internal static extern ErrorCode CionServerSetOnDemandLaunchEnabled(ServerSafeHandle server, bool enable);

[DllImport(Libraries.Cion, EntryPoint = "cion_server_set_display_name")]
internal static extern ErrorCode CionServerSetDisplayName(ServerSafeHandle server, string displayName);
}
}
Expand Up @@ -16,7 +16,7 @@

using System;

namespace Tizen.Applications
namespace Tizen.Applications.Cion
{
internal static class CionErrorFactory
{
Expand All @@ -25,21 +25,27 @@ internal static Exception GetException(Interop.Cion.ErrorCode err, string messag
string errMessage = string.Format("{0} err = {1}", message, err);
switch (err)
{
case Interop.Cion.ErrorCode.InvalidParameter:
return new ArgumentException(errMessage);
case Interop.Cion.ErrorCode.IoError:
return new InvalidOperationException(errMessage);
case Interop.Cion.ErrorCode.OutOfMemory:
return new InvalidOperationException(errMessage);
case Interop.Cion.ErrorCode.IoError:
return new global::System.IO.IOException(errMessage);
case Interop.Cion.ErrorCode.PermissionDenied:
return new UnauthorizedAccessException(errMessage);
case Interop.Cion.ErrorCode.InvalidParameter:
return new ArgumentException(errMessage);
case Interop.Cion.ErrorCode.InvalidOperation:
return new InvalidOperationException(errMessage);
case Interop.Cion.ErrorCode.AlreadyInProgress:
return new InvalidOperationException(errMessage);
case Interop.Cion.ErrorCode.NotSupported:
return new NotSupportedException(errMessage);
case Interop.Cion.ErrorCode.TimedOut:
return new TimeoutException(errMessage);
case Interop.Cion.ErrorCode.OperationFailed:
return new InvalidOperationException(errMessage);
default:
return new InvalidOperationException(errMessage);
}
}
}
}
}

0 comments on commit d63174d

Please sign in to comment.