summaryrefslogtreecommitdiffstats
path: root/mono/ErrorMessage.cs
blob: 773a05b6d8042bbb0944ffbff4a1331bf33b7d5c (plain)
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
namespace DBus
{
  using System;
  using System.Runtime.InteropServices;
  using System.Diagnostics;
  
  public class ErrorMessage : Message
  {    
    public ErrorMessage() : base(MessageType.Error)
    {  
    }

    internal ErrorMessage(IntPtr rawMessage, Service service) : base(rawMessage, service)
    {
    }

    public ErrorMessage(Service service) : base(MessageType.Error, service) 
    {
    }

    public new string Name
    {
      get {
	if (this.name == null) {
	  this.name = Marshal.PtrToStringAnsi(dbus_message_get_error_name(RawMessage));
	}
	
	return this.name;
      }
      
      set {
	if (value != this.name) {
	  dbus_message_set_error_name(RawMessage, value);
	  this.name = value;
	}
      }
    }

    [DllImport("dbus-1")]
    private extern static bool dbus_message_set_error_name(IntPtr rawMessage, string name);

    [DllImport("dbus-1")]
    private extern static IntPtr dbus_message_get_error_name(IntPtr rawMessage);
  }
}