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
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use gio_sys;
use glib;
#[cfg(any(unix, feature = "dox"))]
use glib::object::IsA;
use glib::translate::*;
use glib::GString;
use std::fmt;
use DBusConnection;
use DBusMessage;
use DBusMethodInfo;
use DBusPropertyInfo;
#[cfg(any(unix, feature = "dox"))]
use UnixFDList;

glib_wrapper! {
    pub struct DBusMethodInvocation(Object<gio_sys::GDBusMethodInvocation, DBusMethodInvocationClass>);

    match fn {
        get_type => || gio_sys::g_dbus_method_invocation_get_type(),
    }
}

impl DBusMethodInvocation {
    pub fn get_connection(&self) -> Option<DBusConnection> {
        unsafe {
            from_glib_none(gio_sys::g_dbus_method_invocation_get_connection(
                self.to_glib_none().0,
            ))
        }
    }

    pub fn get_interface_name(&self) -> Option<GString> {
        unsafe {
            from_glib_none(gio_sys::g_dbus_method_invocation_get_interface_name(
                self.to_glib_none().0,
            ))
        }
    }

    pub fn get_message(&self) -> Option<DBusMessage> {
        unsafe {
            from_glib_none(gio_sys::g_dbus_method_invocation_get_message(
                self.to_glib_none().0,
            ))
        }
    }

    pub fn get_method_info(&self) -> Option<DBusMethodInfo> {
        unsafe {
            from_glib_none(gio_sys::g_dbus_method_invocation_get_method_info(
                self.to_glib_none().0,
            ))
        }
    }

    pub fn get_method_name(&self) -> Option<GString> {
        unsafe {
            from_glib_none(gio_sys::g_dbus_method_invocation_get_method_name(
                self.to_glib_none().0,
            ))
        }
    }

    pub fn get_object_path(&self) -> Option<GString> {
        unsafe {
            from_glib_none(gio_sys::g_dbus_method_invocation_get_object_path(
                self.to_glib_none().0,
            ))
        }
    }

    pub fn get_parameters(&self) -> Option<glib::Variant> {
        unsafe {
            from_glib_none(gio_sys::g_dbus_method_invocation_get_parameters(
                self.to_glib_none().0,
            ))
        }
    }

    pub fn get_property_info(&self) -> Option<DBusPropertyInfo> {
        unsafe {
            from_glib_none(gio_sys::g_dbus_method_invocation_get_property_info(
                self.to_glib_none().0,
            ))
        }
    }

    pub fn get_sender(&self) -> Option<GString> {
        unsafe {
            from_glib_none(gio_sys::g_dbus_method_invocation_get_sender(
                self.to_glib_none().0,
            ))
        }
    }

    //pub fn get_user_data(&self) -> /*Unimplemented*/Option<Fundamental: Pointer> {
    //    unsafe { TODO: call gio_sys:g_dbus_method_invocation_get_user_data() }
    //}

    pub fn return_dbus_error(&self, error_name: &str, error_message: &str) {
        unsafe {
            gio_sys::g_dbus_method_invocation_return_dbus_error(
                self.to_glib_full(),
                error_name.to_glib_none().0,
                error_message.to_glib_none().0,
            );
        }
    }

    //pub fn return_error(&self, domain: glib::Quark, code: i32, format: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
    //    unsafe { TODO: call gio_sys:g_dbus_method_invocation_return_error() }
    //}

    //pub fn return_error_valist(&self, domain: glib::Quark, code: i32, format: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
    //    unsafe { TODO: call gio_sys:g_dbus_method_invocation_return_error_valist() }
    //}

    pub fn return_value(&self, parameters: Option<&glib::Variant>) {
        unsafe {
            gio_sys::g_dbus_method_invocation_return_value(
                self.to_glib_full(),
                parameters.to_glib_none().0,
            );
        }
    }

    #[cfg(any(unix, feature = "dox"))]
    pub fn return_value_with_unix_fd_list<P: IsA<UnixFDList>>(
        &self,
        parameters: Option<&glib::Variant>,
        fd_list: Option<&P>,
    ) {
        unsafe {
            gio_sys::g_dbus_method_invocation_return_value_with_unix_fd_list(
                self.to_glib_full(),
                parameters.to_glib_none().0,
                fd_list.map(|p| p.as_ref()).to_glib_none().0,
            );
        }
    }
}

impl fmt::Display for DBusMethodInvocation {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "DBusMethodInvocation")
    }
}