internal static partial class Interop
{
- internal static partial class Push
+ internal static partial class PushClient
{
internal static string LogTag = "Tizen.Messaging.Push";
internal delegate void VoidResultCallback(Result result, IntPtr msg, IntPtr userData);
[DllImport(Libraries.Push, EntryPoint = "push_service_connect", CallingConvention = CallingConvention.Cdecl)]
- internal static extern Interop.Push.ServiceError ServiceConnect(string pushAppID, VoidStateChangedCallback stateCallback, VoidNotifyCallback notifyCallback, IntPtr userData, out IntPtr connection);
+ internal static extern Interop.PushClient.ServiceError ServiceConnect(string pushAppID, VoidStateChangedCallback stateCallback, VoidNotifyCallback notifyCallback, IntPtr userData, out IntPtr connection);
[DllImport(Libraries.Push, EntryPoint = "push_service_disconnect", CallingConvention = CallingConvention.Cdecl)]
internal static extern void ServiceDisconnect(IntPtr connection);
[DllImport(Libraries.Push, EntryPoint = "push_service_register", CallingConvention = CallingConvention.Cdecl)]
- internal static extern Interop.Push.ServiceError ServiceRegister(IntPtr connection, VoidResultCallback callback, IntPtr UserData);
+ internal static extern Interop.PushClient.ServiceError ServiceRegister(IntPtr connection, VoidResultCallback callback, IntPtr UserData);
[DllImport(Libraries.Push, EntryPoint = "push_service_deregister", CallingConvention = CallingConvention.Cdecl)]
- internal static extern Interop.Push.ServiceError ServiceDeregister(IntPtr connection, VoidResultCallback callback, IntPtr UserData);
+ internal static extern Interop.PushClient.ServiceError ServiceDeregister(IntPtr connection, VoidResultCallback callback, IntPtr UserData);
[DllImport(Libraries.Push, EntryPoint = "push_service_app_control_to_noti_data", CallingConvention = CallingConvention.Cdecl)]
internal static extern string AppControlToNotiData(IntPtr appControl, string operation);
[DllImport(Libraries.Push, EntryPoint = "push_service_app_control_to_notification", CallingConvention = CallingConvention.Cdecl)]
- internal static extern Interop.Push.ServiceError AppControlToNotification(IntPtr appControl, string operation, out IntPtr noti);
+ internal static extern Interop.PushClient.ServiceError AppControlToNotification(IntPtr appControl, string operation, out IntPtr noti);
[DllImport(Libraries.Push, EntryPoint = "push_service_get_notification_data", CallingConvention = CallingConvention.Cdecl)]
- internal static extern Interop.Push.ServiceError GetNotificationData(IntPtr notification, out string data);
+ internal static extern Interop.PushClient.ServiceError GetNotificationData(IntPtr notification, out string data);
[DllImport(Libraries.Push, EntryPoint = "push_service_get_notification_message", CallingConvention = CallingConvention.Cdecl)]
- internal static extern Interop.Push.ServiceError GetNotificationMessage(IntPtr notification, out string data);
+ internal static extern Interop.PushClient.ServiceError GetNotificationMessage(IntPtr notification, out string data);
[DllImport(Libraries.Push, EntryPoint = "push_service_get_notification_time", CallingConvention = CallingConvention.Cdecl)]
- internal static extern Interop.Push.ServiceError GetNotificationTime(IntPtr notification, out int receivedTime);
+ internal static extern Interop.PushClient.ServiceError GetNotificationTime(IntPtr notification, out int receivedTime);
[DllImport(Libraries.Push, EntryPoint = "push_service_get_notification_sender", CallingConvention = CallingConvention.Cdecl)]
- internal static extern Interop.Push.ServiceError GetNotificationSender(IntPtr notification, out string sender);
+ internal static extern Interop.PushClient.ServiceError GetNotificationSender(IntPtr notification, out string sender);
[DllImport(Libraries.Push, EntryPoint = "push_service_get_notification_session_info", CallingConvention = CallingConvention.Cdecl)]
- internal static extern Interop.Push.ServiceError GetNotificationSessionInfo(IntPtr notification, out string sessionInfo);
+ internal static extern Interop.PushClient.ServiceError GetNotificationSessionInfo(IntPtr notification, out string sessionInfo);
[DllImport(Libraries.Push, EntryPoint = "push_service_get_notification_request_id", CallingConvention = CallingConvention.Cdecl)]
- internal static extern Interop.Push.ServiceError GetNotificationRequestId(IntPtr notification, out string requestID);
+ internal static extern Interop.PushClient.ServiceError GetNotificationRequestId(IntPtr notification, out string requestID);
[DllImport(Libraries.Push, EntryPoint = "push_service_get_notification_type", CallingConvention = CallingConvention.Cdecl)]
- internal static extern Interop.Push.ServiceError GetNotificationType(IntPtr notification, out int type);
+ internal static extern Interop.PushClient.ServiceError GetNotificationType(IntPtr notification, out int type);
[DllImport(Libraries.Push, EntryPoint = "push_service_get_unread_notification", CallingConvention = CallingConvention.Cdecl)]
- internal static extern Interop.Push.ServiceError GetUnreadNotification(IntPtr connection, out IntPtr noti);
+ internal static extern Interop.PushClient.ServiceError GetUnreadNotification(IntPtr connection, out IntPtr noti);
[DllImport(Libraries.Push, EntryPoint = "push_service_request_unread_notification", CallingConvention = CallingConvention.Cdecl)]
- internal static extern Interop.Push.ServiceError RequestUnreadNotification(IntPtr connection);
+ internal static extern Interop.PushClient.ServiceError RequestUnreadNotification(IntPtr connection);
[DllImport(Libraries.Push, EntryPoint = "push_service_get_registration_id", CallingConvention = CallingConvention.Cdecl)]
- internal static extern Interop.Push.ServiceError GetRegistrationId(IntPtr connection, out string regID);
+ internal static extern Interop.PushClient.ServiceError GetRegistrationId(IntPtr connection, out string regID);
[DllImport(Libraries.Push, EntryPoint = "push_service_free_notification", CallingConvention = CallingConvention.Cdecl)]
- internal static extern Interop.Push.ServiceError FreeNotification(IntPtr connection);
+ internal static extern Interop.PushClient.ServiceError FreeNotification(IntPtr connection);
}
}
\ No newline at end of file
<Compile Include="Interop\Interop.Glib.cs" />\r
<Compile Include="Interop\Interop.Libc.cs" />\r
<Compile Include="Interop\Interop.Libraries.cs" />\r
- <Compile Include="Interop\Interop.Push.cs" />\r
+ <Compile Include="Interop\Interop.PushClient.cs" />\r
<Compile Include="Properties\AssemblyInfo.cs" />\r
- <Compile Include="Tizen.Messaging.Push\Push.cs" />\r
+ <Compile Include="Tizen.Messaging.Push\PushClient.cs" />\r
<Compile Include="Tizen.Messaging.Push\PushConnectionStateEventArgs.cs" />\r
<Compile Include="Tizen.Messaging.Push\PushExceptionFactory.cs" />\r
<Compile Include="Tizen.Messaging.Push\PushImpl.cs" />\r
<Target Name="AfterBuild">\r
</Target>\r
-->\r
-</Project>
\ No newline at end of file
+</Project>\r
<Compile Include="Interop\Interop.Glib.cs" />\r
<Compile Include="Interop\Interop.Libc.cs" />\r
<Compile Include="Interop\Interop.Libraries.cs" />\r
- <Compile Include="Interop\Interop.Push.cs" />\r
+ <Compile Include="Interop\Interop.PushClient.cs" />\r
<Compile Include="Properties\AssemblyInfo.cs" />\r
- <Compile Include="Tizen.Messaging.Push\Push.cs" />\r
+ <Compile Include="Tizen.Messaging.Push\PushClient.cs" />\r
<Compile Include="Tizen.Messaging.Push\PushConnectionStateEventArgs.cs" />\r
<Compile Include="Tizen.Messaging.Push\PushExceptionFactory.cs" />\r
<Compile Include="Tizen.Messaging.Push\PushImpl.cs" />\r
<_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory)</_FullFrameworkReferenceAssemblyPaths>\r
<AutoUnifyAssemblyReferences>true</AutoUnifyAssemblyReferences>\r
</PropertyGroup>\r
-</Project>
\ No newline at end of file
+</Project>\r
-/// This File contains the Api's related to the PushManager class
+/// This File contains the Api's related to the PushClient class
///
/// Copyright 2016 by Samsung Electronics, Inc.,
///
namespace Tizen.Messaging.Push
{
/// <summary>
- /// The PushManager API provides functions to connect to push service for receiving push messages.
+ /// The PushClient API provides functions to connect to push service for receiving push messages.
/// </summary>
/// <remarks>
- /// The PushManager API provides the way to connect with the push service.
+ /// The PushClient API provides the way to connect with the push service.
/// It provides api's to connect/disconnect from the push service.
/// Api's are provided so that an application can register itself
/// with the push server along with api's to request push message.
/// {
/// static void Main(string[] args)
/// {
- /// Push.PushServiceConnect("xxxxx");
- /// Task<ServerResponse> tr = Push.PushServerRegister();
+ /// PushClient.PushServiceConnect("xxxxx");
+ /// Task<ServerResponse> tr = PushClient.PushServerRegister();
/// tr.GetAwaiter().OnCompleted(() => {
/// ServerResponse res = tr.Result;
- /// Push.GetUnreadNotifications();
- /// Task<ServerResponse> tu = Push.PushServerUnregister();
+ /// PushClient.GetUnreadNotifications();
+ /// Task<ServerResponse> tu = PushClient.PushServerUnregister();
/// tu.GetAwaiter().OnCompleted(() => {
- /// Push.PushServiceDisconnect();
+ /// PushClient.PushServiceDisconnect();
/// });
/// });
- /// Push.NotificationReceived += EventHandlerNotificationReceived;
- /// Push.StateChanged += EventHandlerStateChanged;
+ /// PushClient.NotificationReceived += EventHandlerNotificationReceived;
+ /// PushClient.StateChanged += EventHandlerStateChanged;
/// }
/// }
/// static void EventHandlerNotificationReceived(object sender, PushMessageEventArgs e)
/// }
/// </code>
/// </example>
- public static class Push
+ public static class PushClient
{
/// <summary>
/// Event Handler for receiving the notifications.
{
class PushExceptionFactory
{
- internal static Exception CreateResponseException(Interop.Push.ServiceError result)
+ internal static Exception CreateResponseException(Interop.PushClient.ServiceError result)
{
Exception exp;
switch (result)
{
- case Interop.Push.ServiceError.OutOfMemory:
+ case Interop.PushClient.ServiceError.OutOfMemory:
{
- Tizen.Log.Error(Interop.Push.LogTag, "Interop.Push.ServiceError.OutOfMemory");
+ Tizen.Log.Error(Interop.PushClient.LogTag, "Interop.Push.ServiceError.OutOfMemory");
exp = new InvalidOperationException("Memory Not Sufficient for the current operation");
break;
}
- case Interop.Push.ServiceError.InvalidParameter:
+ case Interop.PushClient.ServiceError.InvalidParameter:
{
- Tizen.Log.Error(Interop.Push.LogTag, "Interop.Push.ServiceError.InvalidParameter");
+ Tizen.Log.Error(Interop.PushClient.LogTag, "Interop.Push.ServiceError.InvalidParameter");
exp = new InvalidOperationException("The Parameter Passed was Invalid or Invalid Operation Intented");
break;
}
- case Interop.Push.ServiceError.NotConnected:
+ case Interop.PushClient.ServiceError.NotConnected:
{
- Tizen.Log.Error(Interop.Push.LogTag, "Interop.Push.ServiceError.NotConnected");
+ Tizen.Log.Error(Interop.PushClient.LogTag, "Interop.Push.ServiceError.NotConnected");
exp = new InvalidOperationException("Not Connected to Server");
break;
}
- case Interop.Push.ServiceError.NoData:
+ case Interop.PushClient.ServiceError.NoData:
{
- Tizen.Log.Error(Interop.Push.LogTag, "Interop.Push.ServiceError.NoData");
+ Tizen.Log.Error(Interop.PushClient.LogTag, "Interop.Push.ServiceError.NoData");
exp = new InvalidOperationException("No Data");
break;
}
- case Interop.Push.ServiceError.OpearationFailed:
+ case Interop.PushClient.ServiceError.OpearationFailed:
{
- Tizen.Log.Error(Interop.Push.LogTag, "Interop.Push.ServiceError.OpearationFailed");
+ Tizen.Log.Error(Interop.PushClient.LogTag, "Interop.Push.ServiceError.OpearationFailed");
exp = new InvalidOperationException("Operation Failed");
break;
}
- case Interop.Push.ServiceError.PermissionDenied:
+ case Interop.PushClient.ServiceError.PermissionDenied:
{
- Tizen.Log.Error(Interop.Push.LogTag, "Interop.Push.ServiceError.PermissionDenied");
+ Tizen.Log.Error(Interop.PushClient.LogTag, "Interop.Push.ServiceError.PermissionDenied");
exp = new InvalidOperationException("Permission Denied");
break;
}
- case Interop.Push.ServiceError.NotSupported:
+ case Interop.PushClient.ServiceError.NotSupported:
{
- Tizen.Log.Error(Interop.Push.LogTag, "Interop.Push.ServiceError.NotSupported");
+ Tizen.Log.Error(Interop.PushClient.LogTag, "Interop.Push.ServiceError.NotSupported");
exp = new InvalidOperationException("Not Supported");
break;
}
default:
{
- Tizen.Log.Error(Interop.Push.LogTag, "Creating Exception for Default case for error code " + result);
+ Tizen.Log.Error(Interop.PushClient.LogTag, "Creating Exception for Default case for error code " + result);
exp = new Exception();
break;
}
{
if (_instance == null)
{
- Log.Info(Interop.Push.LogTag, "Creating New Instance");
+ Log.Info(Interop.PushClient.LogTag, "Creating New Instance");
_instance = new PushImpl();
}
}
internal void PushServiceConnect(string pushAppId)
{
- Interop.Push.VoidStateChangedCallback stateDelegate = (int state, string err, IntPtr userData) =>
+ Interop.PushClient.VoidStateChangedCallback stateDelegate = (int state, string err, IntPtr userData) =>
{
if (err == null)
{
err = "";
}
PushConnectionStateEventArgs args = new PushConnectionStateEventArgs((PushConnectionStateEventArgs.PushState)state, err);
- Push.StateChange(args);
+ PushClient.StateChange(args);
};
Interop.Push.VoidNotifyCallback notifyDelegate = (IntPtr notification, IntPtr userData) =>
{
- Interop.Push.ServiceError result;
+ Interop.PushClient.ServiceError result;
PushMessageEventArgs ob = new PushMessageEventArgs();
string data;
- result = Interop.Push.GetNotificationData(notification, out data);
- if ((result == Interop.Push.ServiceError.None) && !(String.IsNullOrEmpty(data)))
+ result = Interop.PushClient.GetNotificationData(notification, out data);
+ if ((result == Interop.PushClient.ServiceError.None) && !(String.IsNullOrEmpty(data)))
{
ob.AppData = data;
}
ob.AppData = "";
}
string message;
- result = Interop.Push.GetNotificationMessage(notification, out message);
- if ((result == Interop.Push.ServiceError.None) && !(String.IsNullOrEmpty(message)))
+ result = Interop.PushClient.GetNotificationMessage(notification, out message);
+ if ((result == Interop.PushClient.ServiceError.None) && !(String.IsNullOrEmpty(message)))
{
ob.Message = message;
}
ob.Message = "";
}
string sender;
- result = Interop.Push.GetNotificationSender(notification, out sender);
- if ((result == Interop.Push.ServiceError.None) && !(String.IsNullOrEmpty(sender)))
+ result = Interop.PushClient.GetNotificationSender(notification, out sender);
+ if ((result == Interop.PushClient.ServiceError.None) && !(String.IsNullOrEmpty(sender)))
{
ob.Sender = sender;
}
ob.Sender = "";
}
string sessioninfo;
- result = Interop.Push.GetNotificationSessionInfo(notification, out sessioninfo);
- if ((result == Interop.Push.ServiceError.None) && !(String.IsNullOrEmpty(sessioninfo)))
+ result = Interop.PushClient.GetNotificationSessionInfo(notification, out sessioninfo);
+ if ((result == Interop.PushClient.ServiceError.None) && !(String.IsNullOrEmpty(sessioninfo)))
{
ob.SessionInfo = sessioninfo;
}
ob.SessionInfo = "";
}
string requestid;
- result = Interop.Push.GetNotificationRequestId(notification, out requestid);
- if ((result == Interop.Push.ServiceError.None) && !(String.IsNullOrEmpty(requestid)))
+ result = Interop.PushClient.GetNotificationRequestId(notification, out requestid);
+ if ((result == Interop.PushClient.ServiceError.None) && !(String.IsNullOrEmpty(requestid)))
{
ob.RequestId = requestid;
}
ob.RequestId = "";
}
int time;
- result = Interop.Push.GetNotificationTime(notification, out time);
+ result = Interop.PushClient.GetNotificationTime(notification, out time);
DateTime utc;
- if ((result == Interop.Push.ServiceError.None) && (time != 0))
+ if ((result == Interop.PushClient.ServiceError.None) && (time != 0))
{
- Log.Info(Interop.Push.LogTag, "Ticks received: " + time);
+ Log.Info(Interop.PushClient.LogTag, "Ticks received: " + time);
utc = DateTime.SpecifyKind(new DateTime(1970, 1, 1).AddSeconds(time), DateTimeKind.Utc);
ob.ReceivedAt = utc.ToLocalTime();
}
else
{
- Log.Info(Interop.Push.LogTag, "No Date received");
+ Log.Info(Interop.PushClient.LogTag, "No Date received");
ob.ReceivedAt = DateTime.Now;
}
int type = -1;
- result = Interop.Push.GetNotificationType(notification, out type);
- if (result == Interop.Push.ServiceError.None)
+ result = Interop.PushClient.GetNotificationType(notification, out type);
+ if (result == Interop.PushClient.ServiceError.None)
{
ob.Type = type;
}
- Push.Notify(ob);
+ PushClient.Notify(ob);
//Interop.Push.FreeNotification(notification);
- Log.Info(Interop.Push.LogTag, "Free Notification Done");
+ Log.Info(Interop.PushClient.LogTag, "Free Notification Done");
};
- Interop.Push.ServiceError connectResult = Interop.Push.ServiceConnect(pushAppId, stateDelegate, notifyDelegate, IntPtr.Zero, out _connection);
- if (connectResult != Interop.Push.ServiceError.None)
+ Interop.PushClient.ServiceError connectResult = Interop.Push.ServiceConnect(pushAppId, stateDelegate, notifyDelegate, IntPtr.Zero, out _connection);
+ if (connectResult != Interop.PushClient.ServiceError.None)
{
- Log.Error(Interop.Push.LogTag, "Connect failed with " + connectResult);
+ Log.Error(Interop.PushClient.LogTag, "Connect failed with " + connectResult);
throw PushExceptionFactory.CreateResponseException(connectResult);
}
}
internal void PushServiceDisconnect()
{
- Interop.Push.ServiceDisconnect(_connection);
- Log.Info(Interop.Push.LogTag, "PushServiceDisconnect Completed");
+ Interop.PushClient.ServiceDisconnect(_connection);
+ Log.Info(Interop.PushClient.LogTag, "PushServiceDisconnect Completed");
}
internal async Task<ServerResponse> PushServerRegister()
{
- Log.Info(Interop.Push.LogTag, "Register Called");
+ Log.Info(Interop.PushClient.LogTag, "Register Called");
var task = new TaskCompletionSource<ServerResponse>();
- Interop.Push.VoidResultCallback registerResult = (Interop.Push.Result regResult, IntPtr msgPtr, IntPtr userData) =>
+ Interop.PushClient.VoidResultCallback registerResult = (Interop.PushClient.Result regResult, IntPtr msgPtr, IntPtr userData) =>
{
- Log.Info(Interop.Push.LogTag, "Register Callback Called");
+ Log.Info(Interop.PushClient.LogTag, "Register Callback Called");
string msg = "";
if (msgPtr != IntPtr.Zero)
{
response.ServerMessage = msg;
if (task.TrySetResult(response) == false)
{
- Log.Error(Interop.Push.LogTag, "Unable to set the Result for register");
+ Log.Error(Interop.PushClient.LogTag, "Unable to set the Result for register");
}
};
- Interop.Push.ServiceError result = Interop.Push.ServiceRegister(_connection, registerResult, IntPtr.Zero);
- Log.Info(Interop.Push.LogTag, "Interop.Push.ServiceRegister Completed");
- if (result != Interop.Push.ServiceError.None)
+ Interop.PushClient.ServiceError result = Interop.PushClient.ServiceRegister(_connection, registerResult, IntPtr.Zero);
+ Log.Info(Interop.PushClient.LogTag, "Interop.Push.ServiceRegister Completed");
+ if (result != Interop.PushClient.ServiceError.None)
{
- Log.Error(Interop.Push.LogTag, "Register failed with " + result);
+ Log.Error(Interop.PushClient.LogTag, "Register failed with " + result);
task.SetException(PushExceptionFactory.CreateResponseException(result));
}
return await task.Task;
internal async Task<ServerResponse> PushServerUnregister()
{
var task = new TaskCompletionSource<ServerResponse>();
- Interop.Push.VoidResultCallback registerResult = (Interop.Push.Result regResult, IntPtr msgPtr, IntPtr userData) =>
+ Interop.PushClient.VoidResultCallback registerResult = (Interop.PushClient.Result regResult, IntPtr msgPtr, IntPtr userData) =>
{
- Log.Info(Interop.Push.LogTag, "Unregister Callback Called");
+ Log.Info(Interop.PushClient.LogTag, "Unregister Callback Called");
string msg = "";
if (msgPtr != IntPtr.Zero)
{
response.ServerMessage = msg;
if (task.TrySetResult(response) == false)
{
- Log.Error(Interop.Push.LogTag, "Unable to set the Result for Unregister");
+ Log.Error(Interop.PushClient.LogTag, "Unable to set the Result for Unregister");
}
};
- Interop.Push.ServiceError result = Interop.Push.ServiceDeregister(_connection, registerResult, IntPtr.Zero);
- if (result != Interop.Push.ServiceError.None)
+ Interop.PushClient.ServiceError result = Interop.PushClient.ServiceDeregister(_connection, registerResult, IntPtr.Zero);
+ if (result != Interop.PushClient.ServiceError.None)
{
task.SetException(PushExceptionFactory.CreateResponseException(result));
}
internal string GetRegistrationId()
{
string regID = "";
- Interop.Push.ServiceError result = Interop.Push.GetRegistrationId(_connection, out regID);
- if (result != Interop.Push.ServiceError.None)
+ Interop.PushClient.ServiceError result = Interop.PushClient.GetRegistrationId(_connection, out regID);
+ if (result != Interop.PushClient.ServiceError.None)
{
throw PushExceptionFactory.CreateResponseException(result);
}
- Log.Info(Interop.Push.LogTag, "Returning Reg Id: " + regID);
+ Log.Info(Interop.PushClient.LogTag, "Returning Reg Id: " + regID);
return regID;
}
internal void GetUnreadNotifications()
{
- Interop.Push.ServiceError result = Interop.Push.RequestUnreadNotification(_connection);
- if (result != Interop.Push.ServiceError.None)
+ Interop.PushClient.ServiceError result = Interop.PushClient.RequestUnreadNotification(_connection);
+ if (result != Interop.PushClient.ServiceError.None)
{
throw PushExceptionFactory.CreateResponseException(result);
}
{
lock (_lock)
{
- Log.Info(Interop.Push.LogTag, "Making _instance as null");
+ Log.Info(Interop.PushClient.LogTag, "Making _instance as null");
_instance = null;
}
}