[DllImport(Libraries.Convergence, EntryPoint = "conv_payload_get_byte")]
internal static extern int GetByte(ConvPayloadHandle /* conv_payload_h */ handle, string key, out int length, out IntPtr value);
+ [DllImport(Libraries.Convergence, EntryPoint = "conv_payload_set_binary")]
+ internal static extern int SetBinary(ConvPayloadHandle /* conv_payload_h */ handle, int length, byte[] value);
+ [DllImport(Libraries.Convergence, EntryPoint = "conv_payload_get_binary")]
+ internal static extern int GetBinary(ConvPayloadHandle /* conv_payload_h */ handle, out int length, out IntPtr value);
}
internal class ConvPayloadHandle : TizenSafeHandle
{
if (_ownsHandle && handle != IntPtr.Zero)
{
- var err = ConvPayload.Destroy(this.handle);\r
- if (err != (int)ConvErrorCode.None)\r
- {\r
- Log.Error(ErrorFactory.LogTag, "Failed to destroy conv payload handle");\r
- throw ErrorFactory.GetException(err);\r
- }\r
+ var err = ConvPayload.Destroy(this.handle);
+ if (err != (int)ConvErrorCode.None)
+ {
+ Log.Error(ErrorFactory.LogTag, "Failed to destroy conv payload handle");
+ throw ErrorFactory.GetException(err);
+ }
}
}
}
}
}
+
+ /// <summary>
+ /// Sets binary to payload.
+ /// </summary>
+ /// <param name="value">The binary to set</param>
+ /// <feature>http://tizen.org/feature/convergence.d2d</feature>
+ /// <exception cref="NotSupportedException">Thrown if the required feature is not supported.</exception>
+ /// <exception cref="ArgumentNullException">Thrown if the arguments passed are null </exception>
+ public void Set(byte[] value)
+ {
+ if (value == null)
+ {
+ throw new ArgumentNullException();
+ }
+
+ int ret = 0;
+ ret = Interop.ConvPayload.SetBinary(_payloadHandle, value.Length, value);
+ if (ret != (int)ConvErrorCode.None)
+ {
+ Log.Error(ErrorFactory.LogTag, "Failed to add binary to payload");
+ throw ErrorFactory.GetException(ret);
+ }
+ }
+
/// <summary>
/// Gets the value of the key from payload
/// </summary>
}
/// <summary>
+ /// Gets binary from payload
+ /// </summary>
+ /// <param name="value">The result value</param>
+ /// <feature>http://tizen.org/feature/convergence.d2d</feature>
+ /// <exception cref="NotSupportedException">Thrown if the required feature is not supported.</exception>
+ public void Get(out byte[] value)
+ {
+ int ret = 0;
+ IntPtr byteArrayPtr;
+ int byteArraySize;
+ ret = Interop.ConvPayload.GetBinary(_payloadHandle, out byteArraySize, out byteArrayPtr);
+ if (ret != (int)ConvErrorCode.None)
+ {
+ Log.Error(ErrorFactory.LogTag, "Failed to get binary from payload");
+ throw ErrorFactory.GetException(ret);
+ }
+
+ byte[] byteArray = new byte[byteArraySize];
+ Marshal.Copy(byteArrayPtr, byteArray, 0, byteArraySize);
+ value = byteArray;
+ Interop.Libc.Free(byteArrayPtr);
+ }
+
+ /// <summary>
/// The dispose method
/// </summary>
public void Dispose()