/*This file is automatically generated by pkg.deepin.io/dbus-generator. Don't edit it*/
package networkmanager

import "pkg.deepin.io/lib/dbus"
import "pkg.deepin.io/lib/dbus/property"
import "reflect"
import "sync"
import "runtime"
import "fmt"
import "errors"

/*prevent compile error*/
var _ = fmt.Println
var _ = runtime.SetFinalizer
var _ = sync.NewCond
var _ = reflect.TypeOf
var _ = property.BaseObserver{}

type IP6Config struct {
	Path     dbus.ObjectPath
	DestName string
	core     *dbus.Object

	signals       map[<-chan *dbus.Signal]struct{}
	signalsLocker sync.Mutex

	Addresses   *dbusPropertyIP6ConfigAddresses
	AddressData *dbusPropertyIP6ConfigAddressData
	Gateway     *dbusPropertyIP6ConfigGateway
	Routes      *dbusPropertyIP6ConfigRoutes
	RouteData   *dbusPropertyIP6ConfigRouteData
	Nameservers *dbusPropertyIP6ConfigNameservers
	Domains     *dbusPropertyIP6ConfigDomains
	Searches    *dbusPropertyIP6ConfigSearches
	DnsOptions  *dbusPropertyIP6ConfigDnsOptions
	DnsPriority *dbusPropertyIP6ConfigDnsPriority
}

func (obj *IP6Config) _createSignalChan() <-chan *dbus.Signal {
	obj.signalsLocker.Lock()
	ch := getBus().Signal()
	obj.signals[ch] = struct{}{}
	obj.signalsLocker.Unlock()
	return ch
}
func (obj *IP6Config) _deleteSignalChan(ch <-chan *dbus.Signal) {
	obj.signalsLocker.Lock()
	delete(obj.signals, ch)
	getBus().DetachSignal(ch)
	obj.signalsLocker.Unlock()
}
func DestroyIP6Config(obj *IP6Config) {
	obj.signalsLocker.Lock()
	defer obj.signalsLocker.Unlock()
	if obj.signals == nil {
		return
	}
	for ch, _ := range obj.signals {
		getBus().DetachSignal(ch)
	}
	obj.signals = nil

	runtime.SetFinalizer(obj, nil)

	dbusRemoveMatch("type='signal',path='" + string(obj.Path) + "',interface='org.freedesktop.DBus.Properties',sender='" + obj.DestName + "',member='PropertiesChanged'")
	dbusRemoveMatch("type='signal',path='" + string(obj.Path) + "',interface='org.freedesktop.NetworkManager.IP6Config',sender='" + obj.DestName + "',member='PropertiesChanged'")

	dbusRemoveMatch("type='signal',path='" + string(obj.Path) + "',interface='org.freedesktop.NetworkManager.IP6Config',sender='" + obj.DestName + "',member='PropertiesChanged'")

	obj.Addresses.Reset()
	obj.AddressData.Reset()
	obj.Gateway.Reset()
	obj.Routes.Reset()
	obj.RouteData.Reset()
	obj.Nameservers.Reset()
	obj.Domains.Reset()
	obj.Searches.Reset()
	obj.DnsOptions.Reset()
	obj.DnsPriority.Reset()
}

func (obj *IP6Config) ConnectPropertiesChanged(callback func(properties map[string]dbus.Variant)) func() {
	sigChan := obj._createSignalChan()
	go func() {
		for v := range sigChan {
			if v.Path != obj.Path || v.Name != "org.freedesktop.NetworkManager.IP6Config.PropertiesChanged" || 1 != len(v.Body) {
				continue
			}
			if reflect.TypeOf(v.Body[0]) != reflect.TypeOf((*map[string]dbus.Variant)(nil)).Elem() {
				continue
			}

			callback(v.Body[0].(map[string]dbus.Variant))
		}
	}()
	return func() {
		obj._deleteSignalChan(sigChan)
	}
}

type dbusPropertyIP6ConfigAddresses struct {
	*property.BaseObserver
	core *dbus.Object
}

func (this *dbusPropertyIP6ConfigAddresses) SetValue(notwritable interface{}) {
	fmt.Println("org.freedesktop.NetworkManager.IP6Config.Addresses is not writable")
}

func (this *dbusPropertyIP6ConfigAddresses) Get() [][]interface{} {
	v, _ := this.GetValue()
	return v.([][]interface{})
}
func (this *dbusPropertyIP6ConfigAddresses) GetValue() (interface{} /*[][]interface {}*/, error) {
	var r dbus.Variant
	err := this.core.Call("org.freedesktop.DBus.Properties.Get", 0, "org.freedesktop.NetworkManager.IP6Config", "Addresses").Store(&r)
	if err == nil && r.Signature().String() == "a(ayuay)" {
		return r.Value().([][]interface{}), nil
	}
	return *new([][]interface{}), err
}
func (this *dbusPropertyIP6ConfigAddresses) GetType() reflect.Type {
	return reflect.TypeOf((*[][]interface{})(nil)).Elem()
}

type dbusPropertyIP6ConfigAddressData struct {
	*property.BaseObserver
	core *dbus.Object
}

func (this *dbusPropertyIP6ConfigAddressData) SetValue(notwritable interface{}) {
	fmt.Println("org.freedesktop.NetworkManager.IP6Config.AddressData is not writable")
}

func (this *dbusPropertyIP6ConfigAddressData) Get() []map[string]dbus.Variant {
	v, _ := this.GetValue()
	return v.([]map[string]dbus.Variant)
}
func (this *dbusPropertyIP6ConfigAddressData) GetValue() (interface{} /*[]map[string]dbus.Variant*/, error) {
	var r dbus.Variant
	err := this.core.Call("org.freedesktop.DBus.Properties.Get", 0, "org.freedesktop.NetworkManager.IP6Config", "AddressData").Store(&r)
	if err == nil && r.Signature().String() == "aa{sv}" {
		return r.Value().([]map[string]dbus.Variant), nil
	}
	return *new([]map[string]dbus.Variant), err
}
func (this *dbusPropertyIP6ConfigAddressData) GetType() reflect.Type {
	return reflect.TypeOf((*[]map[string]dbus.Variant)(nil)).Elem()
}

type dbusPropertyIP6ConfigGateway struct {
	*property.BaseObserver
	core *dbus.Object
}

func (this *dbusPropertyIP6ConfigGateway) SetValue(notwritable interface{}) {
	fmt.Println("org.freedesktop.NetworkManager.IP6Config.Gateway is not writable")
}

func (this *dbusPropertyIP6ConfigGateway) Get() string {
	v, _ := this.GetValue()
	return v.(string)
}
func (this *dbusPropertyIP6ConfigGateway) GetValue() (interface{} /*string*/, error) {
	var r dbus.Variant
	err := this.core.Call("org.freedesktop.DBus.Properties.Get", 0, "org.freedesktop.NetworkManager.IP6Config", "Gateway").Store(&r)
	if err == nil && r.Signature().String() == "s" {
		return r.Value().(string), nil
	}
	return *new(string), err
}
func (this *dbusPropertyIP6ConfigGateway) GetType() reflect.Type {
	return reflect.TypeOf((*string)(nil)).Elem()
}

type dbusPropertyIP6ConfigRoutes struct {
	*property.BaseObserver
	core *dbus.Object
}

func (this *dbusPropertyIP6ConfigRoutes) SetValue(notwritable interface{}) {
	fmt.Println("org.freedesktop.NetworkManager.IP6Config.Routes is not writable")
}

func (this *dbusPropertyIP6ConfigRoutes) Get() [][]interface{} {
	v, _ := this.GetValue()
	return v.([][]interface{})
}
func (this *dbusPropertyIP6ConfigRoutes) GetValue() (interface{} /*[][]interface {}*/, error) {
	var r dbus.Variant
	err := this.core.Call("org.freedesktop.DBus.Properties.Get", 0, "org.freedesktop.NetworkManager.IP6Config", "Routes").Store(&r)
	if err == nil && r.Signature().String() == "a(ayuayu)" {
		return r.Value().([][]interface{}), nil
	}
	return *new([][]interface{}), err
}
func (this *dbusPropertyIP6ConfigRoutes) GetType() reflect.Type {
	return reflect.TypeOf((*[][]interface{})(nil)).Elem()
}

type dbusPropertyIP6ConfigRouteData struct {
	*property.BaseObserver
	core *dbus.Object
}

func (this *dbusPropertyIP6ConfigRouteData) SetValue(notwritable interface{}) {
	fmt.Println("org.freedesktop.NetworkManager.IP6Config.RouteData is not writable")
}

func (this *dbusPropertyIP6ConfigRouteData) Get() []map[string]dbus.Variant {
	v, _ := this.GetValue()
	return v.([]map[string]dbus.Variant)
}
func (this *dbusPropertyIP6ConfigRouteData) GetValue() (interface{} /*[]map[string]dbus.Variant*/, error) {
	var r dbus.Variant
	err := this.core.Call("org.freedesktop.DBus.Properties.Get", 0, "org.freedesktop.NetworkManager.IP6Config", "RouteData").Store(&r)
	if err == nil && r.Signature().String() == "aa{sv}" {
		return r.Value().([]map[string]dbus.Variant), nil
	}
	return *new([]map[string]dbus.Variant), err
}
func (this *dbusPropertyIP6ConfigRouteData) GetType() reflect.Type {
	return reflect.TypeOf((*[]map[string]dbus.Variant)(nil)).Elem()
}

type dbusPropertyIP6ConfigNameservers struct {
	*property.BaseObserver
	core *dbus.Object
}

func (this *dbusPropertyIP6ConfigNameservers) SetValue(notwritable interface{}) {
	fmt.Println("org.freedesktop.NetworkManager.IP6Config.Nameservers is not writable")
}

func (this *dbusPropertyIP6ConfigNameservers) Get() [][]uint8 {
	v, _ := this.GetValue()
	return v.([][]uint8)
}
func (this *dbusPropertyIP6ConfigNameservers) GetValue() (interface{} /*[][]uint8*/, error) {
	var r dbus.Variant
	err := this.core.Call("org.freedesktop.DBus.Properties.Get", 0, "org.freedesktop.NetworkManager.IP6Config", "Nameservers").Store(&r)
	if err == nil && r.Signature().String() == "aay" {
		return r.Value().([][]uint8), nil
	}
	return *new([][]uint8), err
}
func (this *dbusPropertyIP6ConfigNameservers) GetType() reflect.Type {
	return reflect.TypeOf((*[][]uint8)(nil)).Elem()
}

type dbusPropertyIP6ConfigDomains struct {
	*property.BaseObserver
	core *dbus.Object
}

func (this *dbusPropertyIP6ConfigDomains) SetValue(notwritable interface{}) {
	fmt.Println("org.freedesktop.NetworkManager.IP6Config.Domains is not writable")
}

func (this *dbusPropertyIP6ConfigDomains) Get() []string {
	v, _ := this.GetValue()
	return v.([]string)
}
func (this *dbusPropertyIP6ConfigDomains) GetValue() (interface{} /*[]string*/, error) {
	var r dbus.Variant
	err := this.core.Call("org.freedesktop.DBus.Properties.Get", 0, "org.freedesktop.NetworkManager.IP6Config", "Domains").Store(&r)
	if err == nil && r.Signature().String() == "as" {
		return r.Value().([]string), nil
	}
	return *new([]string), err
}
func (this *dbusPropertyIP6ConfigDomains) GetType() reflect.Type {
	return reflect.TypeOf((*[]string)(nil)).Elem()
}

type dbusPropertyIP6ConfigSearches struct {
	*property.BaseObserver
	core *dbus.Object
}

func (this *dbusPropertyIP6ConfigSearches) SetValue(notwritable interface{}) {
	fmt.Println("org.freedesktop.NetworkManager.IP6Config.Searches is not writable")
}

func (this *dbusPropertyIP6ConfigSearches) Get() []string {
	v, _ := this.GetValue()
	return v.([]string)
}
func (this *dbusPropertyIP6ConfigSearches) GetValue() (interface{} /*[]string*/, error) {
	var r dbus.Variant
	err := this.core.Call("org.freedesktop.DBus.Properties.Get", 0, "org.freedesktop.NetworkManager.IP6Config", "Searches").Store(&r)
	if err == nil && r.Signature().String() == "as" {
		return r.Value().([]string), nil
	}
	return *new([]string), err
}
func (this *dbusPropertyIP6ConfigSearches) GetType() reflect.Type {
	return reflect.TypeOf((*[]string)(nil)).Elem()
}

type dbusPropertyIP6ConfigDnsOptions struct {
	*property.BaseObserver
	core *dbus.Object
}

func (this *dbusPropertyIP6ConfigDnsOptions) SetValue(notwritable interface{}) {
	fmt.Println("org.freedesktop.NetworkManager.IP6Config.DnsOptions is not writable")
}

func (this *dbusPropertyIP6ConfigDnsOptions) Get() []string {
	v, _ := this.GetValue()
	return v.([]string)
}
func (this *dbusPropertyIP6ConfigDnsOptions) GetValue() (interface{} /*[]string*/, error) {
	var r dbus.Variant
	err := this.core.Call("org.freedesktop.DBus.Properties.Get", 0, "org.freedesktop.NetworkManager.IP6Config", "DnsOptions").Store(&r)
	if err == nil && r.Signature().String() == "as" {
		return r.Value().([]string), nil
	}
	return *new([]string), err
}
func (this *dbusPropertyIP6ConfigDnsOptions) GetType() reflect.Type {
	return reflect.TypeOf((*[]string)(nil)).Elem()
}

type dbusPropertyIP6ConfigDnsPriority struct {
	*property.BaseObserver
	core *dbus.Object
}

func (this *dbusPropertyIP6ConfigDnsPriority) SetValue(notwritable interface{}) {
	fmt.Println("org.freedesktop.NetworkManager.IP6Config.DnsPriority is not writable")
}

func (this *dbusPropertyIP6ConfigDnsPriority) Get() int32 {
	v, _ := this.GetValue()
	return v.(int32)
}
func (this *dbusPropertyIP6ConfigDnsPriority) GetValue() (interface{} /*int32*/, error) {
	var r dbus.Variant
	err := this.core.Call("org.freedesktop.DBus.Properties.Get", 0, "org.freedesktop.NetworkManager.IP6Config", "DnsPriority").Store(&r)
	if err == nil && r.Signature().String() == "i" {
		return r.Value().(int32), nil
	}
	return *new(int32), err
}
func (this *dbusPropertyIP6ConfigDnsPriority) GetType() reflect.Type {
	return reflect.TypeOf((*int32)(nil)).Elem()
}

func NewIP6Config(destName string, path dbus.ObjectPath) (*IP6Config, error) {
	if !path.IsValid() {
		return nil, errors.New("The path of '" + string(path) + "' is invalid.")
	}

	core := getBus().Object(destName, path)

	obj := &IP6Config{Path: path, DestName: destName, core: core, signals: make(map[<-chan *dbus.Signal]struct{})}

	obj.Addresses = &dbusPropertyIP6ConfigAddresses{&property.BaseObserver{}, core}
	obj.AddressData = &dbusPropertyIP6ConfigAddressData{&property.BaseObserver{}, core}
	obj.Gateway = &dbusPropertyIP6ConfigGateway{&property.BaseObserver{}, core}
	obj.Routes = &dbusPropertyIP6ConfigRoutes{&property.BaseObserver{}, core}
	obj.RouteData = &dbusPropertyIP6ConfigRouteData{&property.BaseObserver{}, core}
	obj.Nameservers = &dbusPropertyIP6ConfigNameservers{&property.BaseObserver{}, core}
	obj.Domains = &dbusPropertyIP6ConfigDomains{&property.BaseObserver{}, core}
	obj.Searches = &dbusPropertyIP6ConfigSearches{&property.BaseObserver{}, core}
	obj.DnsOptions = &dbusPropertyIP6ConfigDnsOptions{&property.BaseObserver{}, core}
	obj.DnsPriority = &dbusPropertyIP6ConfigDnsPriority{&property.BaseObserver{}, core}

	dbusAddMatch("type='signal',path='" + string(path) + "',interface='org.freedesktop.DBus.Properties',sender='" + destName + "',member='PropertiesChanged'")
	dbusAddMatch("type='signal',path='" + string(path) + "',interface='org.freedesktop.NetworkManager.IP6Config',sender='" + destName + "',member='PropertiesChanged'")
	sigChan := obj._createSignalChan()
	go func() {
		typeString := reflect.TypeOf("")
		typeKeyValues := reflect.TypeOf(map[string]dbus.Variant{})
		typeArrayValues := reflect.TypeOf([]string{})
		for v := range sigChan {
			if v.Name == "org.freedesktop.DBus.Properties.PropertiesChanged" &&
				len(v.Body) == 3 &&
				reflect.TypeOf(v.Body[0]) == typeString &&
				reflect.TypeOf(v.Body[1]) == typeKeyValues &&
				reflect.TypeOf(v.Body[2]) == typeArrayValues &&
				v.Body[0].(string) == "org.freedesktop.NetworkManager.IP6Config" {
				props := v.Body[1].(map[string]dbus.Variant)
				for key, _ := range props {
					if false {
					} else if key == "Addresses" {
						obj.Addresses.Notify()

					} else if key == "AddressData" {
						obj.AddressData.Notify()

					} else if key == "Gateway" {
						obj.Gateway.Notify()

					} else if key == "Routes" {
						obj.Routes.Notify()

					} else if key == "RouteData" {
						obj.RouteData.Notify()

					} else if key == "Nameservers" {
						obj.Nameservers.Notify()

					} else if key == "Domains" {
						obj.Domains.Notify()

					} else if key == "Searches" {
						obj.Searches.Notify()

					} else if key == "DnsOptions" {
						obj.DnsOptions.Notify()

					} else if key == "DnsPriority" {
						obj.DnsPriority.Notify()
					}
				}
			} else if v.Name == "org.freedesktop.NetworkManager.IP6Config.PropertiesChanged" && len(v.Body) == 1 && reflect.TypeOf(v.Body[0]) == typeKeyValues {
				for key, _ := range v.Body[0].(map[string]dbus.Variant) {
					if false {
					} else if key == "Addresses" {
						obj.Addresses.Notify()

					} else if key == "AddressData" {
						obj.AddressData.Notify()

					} else if key == "Gateway" {
						obj.Gateway.Notify()

					} else if key == "Routes" {
						obj.Routes.Notify()

					} else if key == "RouteData" {
						obj.RouteData.Notify()

					} else if key == "Nameservers" {
						obj.Nameservers.Notify()

					} else if key == "Domains" {
						obj.Domains.Notify()

					} else if key == "Searches" {
						obj.Searches.Notify()

					} else if key == "DnsOptions" {
						obj.DnsOptions.Notify()

					} else if key == "DnsPriority" {
						obj.DnsPriority.Notify()
					}
				}
			}
		}
	}()

	dbusAddMatch("type='signal',path='" + string(obj.Path) + "',interface='org.freedesktop.NetworkManager.IP6Config',sender='" + obj.DestName + "',member='PropertiesChanged'")

	runtime.SetFinalizer(obj, func(_obj *IP6Config) { DestroyIP6Config(_obj) })
	return obj, nil
}
