1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
//
// MessageData.custom
//
// Author(s):
// Stephane Delcroix <stephane@delcroix.org>
//
// Copyright (c) 2009 Stephane Delcroix
//
// This is open source software.
//
public object Clone ()
{
return (object)Copy ();
}
[DllImport("libunique-1.0-0.dll")]
static extern bool unique_message_data_set_text(IntPtr raw, IntPtr str, IntPtr length);
[DllImport("libunique-1.0-0.dll")]
static extern IntPtr unique_message_data_get_text(IntPtr raw);
public string Text {
set {
IntPtr native_str = GLib.Marshaller.StringToPtrGStrdup (value);
bool raw_ret = unique_message_data_set_text(Handle, native_str, new IntPtr ((long) System.Text.Encoding.UTF8.GetByteCount (value)));
bool ret = raw_ret;
GLib.Marshaller.Free (native_str);
if (!ret)
throw new Exception ("Failed to convert the text to UTF-8");
}
get {
IntPtr raw_ret = unique_message_data_get_text(Handle);
string ret = GLib.Marshaller.PtrToStringGFree(raw_ret);
return ret;
}
}
[DllImport("libunique-1.0-0.dll")]
static extern byte[] unique_message_data_get(IntPtr raw, out UIntPtr length);
[DllImport("libunique-1.0-0.dll")]
static extern void unique_message_data_set(IntPtr raw, byte[] data, UIntPtr n_data);
public byte[] Data {
set { unique_message_data_set(Handle, value, new UIntPtr ((ulong) (value == null ? -1 : value.Length))); }
get {
UIntPtr native_length;
return unique_message_data_get(Handle, out native_length);
}
}
|