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
// 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::object::Cast;
use glib::object::IsA;
use glib::translate::*;
use glib::GString;
use std::fmt;
use InetAddress;
use InetSocketAddress;
use SocketAddress;
use SocketConnectable;

glib_wrapper! {
    pub struct ProxyAddress(Object<gio_sys::GProxyAddress, gio_sys::GProxyAddressClass, ProxyAddressClass>) @extends InetSocketAddress, SocketAddress, @implements SocketConnectable;

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

impl ProxyAddress {
    pub fn new<P: IsA<InetAddress>>(
        inetaddr: &P,
        port: u16,
        protocol: &str,
        dest_hostname: &str,
        dest_port: u16,
        username: Option<&str>,
        password: Option<&str>,
    ) -> ProxyAddress {
        unsafe {
            SocketAddress::from_glib_full(gio_sys::g_proxy_address_new(
                inetaddr.as_ref().to_glib_none().0,
                port,
                protocol.to_glib_none().0,
                dest_hostname.to_glib_none().0,
                dest_port,
                username.to_glib_none().0,
                password.to_glib_none().0,
            ))
            .unsafe_cast()
        }
    }
}

unsafe impl Send for ProxyAddress {}
unsafe impl Sync for ProxyAddress {}

pub const NONE_PROXY_ADDRESS: Option<&ProxyAddress> = None;

pub trait ProxyAddressExt: 'static {
    fn get_destination_hostname(&self) -> GString;

    fn get_destination_port(&self) -> u16;

    fn get_destination_protocol(&self) -> Option<GString>;

    fn get_password(&self) -> Option<GString>;

    fn get_protocol(&self) -> GString;

    fn get_uri(&self) -> Option<GString>;

    fn get_username(&self) -> Option<GString>;
}

impl<O: IsA<ProxyAddress>> ProxyAddressExt for O {
    fn get_destination_hostname(&self) -> GString {
        unsafe {
            from_glib_none(gio_sys::g_proxy_address_get_destination_hostname(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn get_destination_port(&self) -> u16 {
        unsafe { gio_sys::g_proxy_address_get_destination_port(self.as_ref().to_glib_none().0) }
    }

    fn get_destination_protocol(&self) -> Option<GString> {
        unsafe {
            from_glib_none(gio_sys::g_proxy_address_get_destination_protocol(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn get_password(&self) -> Option<GString> {
        unsafe {
            from_glib_none(gio_sys::g_proxy_address_get_password(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn get_protocol(&self) -> GString {
        unsafe {
            from_glib_none(gio_sys::g_proxy_address_get_protocol(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn get_uri(&self) -> Option<GString> {
        unsafe {
            from_glib_none(gio_sys::g_proxy_address_get_uri(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn get_username(&self) -> Option<GString> {
        unsafe {
            from_glib_none(gio_sys::g_proxy_address_get_username(
                self.as_ref().to_glib_none().0,
            ))
        }
    }
}

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