{
internal static partial class AppControl
{
+ internal const int AppStartedStatus = 1;
+
internal delegate bool ExtraDataCallback(SafeAppControlHandle handle, string key, IntPtr userData);
internal delegate bool AppMatchedCallback(SafeAppControlHandle handle, string applicationId, IntPtr userData);
internal delegate void ReplyCallback(IntPtr request, IntPtr reply, int result, IntPtr userData);
<Compile Include="Tizen.Applications.Managers\RunningApplication.cs" />
<Compile Include="Tizen.Applications\AppControl.cs" />
<Compile Include="Tizen.Applications\AppControlLaunchMode.cs" />
- <Compile Include="Tizen.Applications\AppControlLaunchResult.cs" />
+ <Compile Include="Tizen.Applications\AppControlReplyResult.cs" />
<Compile Include="Tizen.Applications\AppControlOperations.cs" />
<Compile Include="Tizen.Applications\Application.cs" />
<Compile Include="Tizen.Applications\Bundle.cs" />
<Target Name="AfterBuild">
</Target>
-->
-</Project>
\ No newline at end of file
+</Project>
private ExtraDataCollection _extraData = null;
+ static private Dictionary<int, Interop.AppControl.ReplyCallback> _replyNativeCallbackMaps = new Dictionary<int, Interop.AppControl.ReplyCallback>();
+ static private int _replyNativeCallbackId = 0;
+
/// <summary>
///
/// </summary>
}
/// <summary>
- ///
+ ///
/// </summary>
- /// <param name="receiver"></param>
- /// <param name="replyCallback"></param>
+ /// <param name="launchRequest"></param>
+ /// <param name="replyAfterLaunching"></param>
public static void SendLaunchRequest(AppControl launchRequest, AppControlReplyCallback replyAfterLaunching = null)
{
Interop.AppControl.ErrorCode err;
if (replyAfterLaunching != null)
{
- Interop.AppControl.ReplyCallback replyNativeCallback = (launchRequestHandle, replyRequestHandle, result, userData) =>
+ int id = 0;
+ lock (_replyNativeCallbackMaps)
{
- AppControlReplyCallback replyCallbackAfterLaunching = Marshal.GetObjectForIUnknown(userData) as AppControlReplyCallback;
- if (replyCallbackAfterLaunching != null)
- replyCallbackAfterLaunching(new AppControl(launchRequestHandle), new AppControl(replyRequestHandle), (AppControlLaunchResult)result);
- };
- err = Interop.AppControl.SendLaunchRequest(launchRequest._handle, replyNativeCallback, Marshal.GetIUnknownForObject(replyAfterLaunching));
+ id = _replyNativeCallbackId++;
+ _replyNativeCallbackMaps[id] = (launchRequestHandle, replyRequestHandle, result, userData) =>
+ {
+ if (result == Interop.AppControl.AppStartedStatus)
+ {
+ Log.Debug(LogTag, "Callee App is started");
+ return;
+ }
+
+ if (replyAfterLaunching != null)
+ {
+ Log.Debug(LogTag, "Reply Callback is launched");
+ replyAfterLaunching(new AppControl(launchRequestHandle), new AppControl(replyRequestHandle), (AppControlReplyResult)result);
+ lock (_replyNativeCallbackMaps)
+ {
+ _replyNativeCallbackMaps.Remove(id);
+ }
+ }
+ };
+ }
+ err = Interop.AppControl.SendLaunchRequest(launchRequest._handle, _replyNativeCallbackMaps[id], IntPtr.Zero);
}
else
{
namespace Tizen.Applications
{
- public delegate void AppControlReplyCallback(AppControl launchRequest, AppControl replyRequest, AppControlLaunchResult result);
+ public delegate void AppControlReplyCallback(AppControl launchRequest, AppControl replyRequest, AppControlReplyResult result);
}
/// <summary>
/// Enumeration for App Control Result.
/// </summary>
- public enum AppControlLaunchResult
+ public enum AppControlReplyResult
{
/// <summary>
- /// Callee application is launched actually.
- /// </summary>
- AppStarted = 1,
-
- /// <summary>
/// Operation is succeeded
/// </summary>
Succeeded = 0,
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
+using Tizen.Internals.Errors;
namespace Tizen.Applications
{
/// A bundle holds items (key-value pairs) and can be used with other Tizen APIs.
/// Keys can be used to access values.
/// This class is accessed by using a constructor to create a new instance of this object.
+ /// A bundle instance is not guaranteed to be thread safe if the instance is modified by multiple threads.
/// </summary>
public class Bundle : IDisposable
{
public Bundle()
{
_handle = Interop.Bundle.Create();
- BundleErrorFactory.CheckAndThrowException(Internals.Errors.ErrorFacts.GetLastResult(), _handle);
+ BundleErrorFactory.CheckAndThrowException(ErrorFacts.GetLastResult(), _handle);
_keys = new HashSet<string>();
}
};
Interop.Bundle.Foreach(_handle, iterator, IntPtr.Zero);
- if ((BundleErrorFactory.BundleError)Internals.Errors.ErrorFacts.GetLastResult() == BundleErrorFactory.BundleError.InvalidParameter)
+ if ((BundleErrorFactory.BundleError)ErrorFacts.GetLastResult() == BundleErrorFactory.BundleError.InvalidParameter)
{
throw new ArgumentException("Invalid parameter - cannot create bundle instance");
}
if (_keys.Contains(key))
{
int type = Interop.Bundle.GetType(_handle, key);
- BundleErrorFactory.CheckAndThrowException(Internals.Errors.ErrorFacts.GetLastResult(), _handle);
+ BundleErrorFactory.CheckAndThrowException(ErrorFacts.GetLastResult(), _handle);
switch (type)
{
case (int)BundleType.String:
// get string array
int stringArraySize;
IntPtr stringArrayPtr = Interop.Bundle.GetStringArray(_handle, key, out stringArraySize);
- BundleErrorFactory.CheckAndThrowException(Internals.Errors.ErrorFacts.GetLastResult(), _handle);
+ BundleErrorFactory.CheckAndThrowException(ErrorFacts.GetLastResult(), _handle);
string[] stringArray;
IntPtrToStringArray(stringArrayPtr, stringArraySize, out stringArray);
return stringArray;
}
else
{
- if (_keys.Contains(key) && Internals.Errors.ErrorFacts.GetLastResult() == (int)BundleErrorFactory.BundleError.InvalidParameter)
+ if (_keys.Contains(key) && ErrorFacts.GetLastResult() == (int)BundleErrorFactory.BundleError.InvalidParameter)
{
throw new InvalidOperationException("Invalid bundle instance (object may have been disposed or released)");
}
}
else
{
- if (_keys.Contains(key) && Internals.Errors.ErrorFacts.GetLastResult() == (int)BundleErrorFactory.BundleError.InvalidParameter)
+ if (_keys.Contains(key) && ErrorFacts.GetLastResult() == (int)BundleErrorFactory.BundleError.InvalidParameter)
{
throw new InvalidOperationException("Invalid bundle instance (object may have been disposed or released)");
}
}
else
{
- if (_keys.Contains(key) && Internals.Errors.ErrorFacts.GetLastResult() == (int)BundleErrorFactory.BundleError.InvalidParameter)
+ if (_keys.Contains(key) && ErrorFacts.GetLastResult() == (int)BundleErrorFactory.BundleError.InvalidParameter)
{
throw new InvalidOperationException("Invalid bundle instance (object may have been disposed or released)");
}
{
internal enum BundleError
{
- None = Internals.Errors.ErrorCode.None,
- OutOfMemory = Internals.Errors.ErrorCode.OutOfMemory,
- InvalidParameter = Internals.Errors.ErrorCode.InvalidParameter,
- KeyNotAvailable = Internals.Errors.ErrorCode.KeyNotAvailable,
+ None = ErrorCode.None,
+ OutOfMemory = ErrorCode.OutOfMemory,
+ InvalidParameter = ErrorCode.InvalidParameter,
+ KeyNotAvailable = ErrorCode.KeyNotAvailable,
KeyExists = -0x01180000 | 0x01
}
/// <param name="replyRequest"></param>
/// <param name="launchRequest"></param>
/// <param name="result"></param>
- public void ReplyToLaunchRequest(AppControl replyRequest, AppControlLaunchResult result)
+ public void ReplyToLaunchRequest(AppControl replyRequest, AppControlReplyResult result)
{
Interop.AppControl.ErrorCode err = Interop.AppControl.ReplyToLaunchRequest(replyRequest._handle, this._handle, (int)result);
if (err == Interop.AppControl.ErrorCode.InvalidParameter)