// Code generated by "./generator ./com.deepin.system.inputdevices"; DO NOT EDIT.

// Copyright: 2018 - 2022 UnionTech Software Technology Co., Ltd.
//
// License-Identifier: GPL-3.0-or-later
package inputdevices

import "errors"
import "fmt"
import "github.com/godbus/dbus"

import "github.com/linuxdeepin/go-lib/dbusutil"
import "github.com/linuxdeepin/go-lib/dbusutil/proxy"
import "unsafe"

type InputDevices interface {
	inputDevices // interface com.deepin.system.InputDevices
	proxy.Object
}

type objectInputDevices struct {
	interfaceInputDevices // interface com.deepin.system.InputDevices
	proxy.ImplObject
}

func NewInputDevices(conn *dbus.Conn) InputDevices {
	obj := new(objectInputDevices)
	obj.ImplObject.Init_(conn, "com.deepin.system.InputDevices", "/com/deepin/system/InputDevices")
	return obj
}

type inputDevices interface {
	GoSetWakeupDevices(flags dbus.Flags, ch chan *dbus.Call, path string, value string) *dbus.Call
	SetWakeupDevices(flags dbus.Flags, path string, value string) error
	ConnectTouchscreenAdded(cb func(path dbus.ObjectPath)) (dbusutil.SignalHandlerId, error)
	ConnectTouchscreenRemoved(cb func(path dbus.ObjectPath)) (dbusutil.SignalHandlerId, error)
	Touchscreens() proxy.PropObjectPathArray
	SupportWakeupDevices() PropInputDevicesSupportWakupDevices
}

type interfaceInputDevices struct{}

func (v *interfaceInputDevices) GetObject_() *proxy.ImplObject {
	return (*proxy.ImplObject)(unsafe.Pointer(v))
}

func (*interfaceInputDevices) GetInterfaceName_() string {
	return "com.deepin.system.InputDevices"
}

// method SetWakeupDevices

func (v *interfaceInputDevices) GoSetWakeupDevices(flags dbus.Flags, ch chan *dbus.Call, path string, value string) *dbus.Call {
	return v.GetObject_().Go_(v.GetInterfaceName_()+".SetWakeupDevices", flags, ch, path, value)
}

func (v *interfaceInputDevices) SetWakeupDevices(flags dbus.Flags, path string, value string) error {
	return (<-v.GoSetWakeupDevices(flags, make(chan *dbus.Call, 1), path, value).Done).Err
}

// signal TouchscreenAdded

func (v *interfaceInputDevices) ConnectTouchscreenAdded(cb func(path dbus.ObjectPath)) (dbusutil.SignalHandlerId, error) {
	if cb == nil {
		return 0, errors.New("nil callback")
	}
	obj := v.GetObject_()
	rule := fmt.Sprintf(
		"type='signal',interface='%s',member='%s',path='%s',sender='%s'",
		v.GetInterfaceName_(), "TouchscreenAdded", obj.Path_(), obj.ServiceName_())

	sigRule := &dbusutil.SignalRule{
		Path: obj.Path_(),
		Name: v.GetInterfaceName_() + ".TouchscreenAdded",
	}
	handlerFunc := func(sig *dbus.Signal) {
		var path dbus.ObjectPath
		err := dbus.Store(sig.Body, &path)
		if err == nil {
			cb(path)
		}
	}

	return obj.ConnectSignal_(rule, sigRule, handlerFunc)
}

// signal TouchscreenRemoved

func (v *interfaceInputDevices) ConnectTouchscreenRemoved(cb func(path dbus.ObjectPath)) (dbusutil.SignalHandlerId, error) {
	if cb == nil {
		return 0, errors.New("nil callback")
	}
	obj := v.GetObject_()
	rule := fmt.Sprintf(
		"type='signal',interface='%s',member='%s',path='%s',sender='%s'",
		v.GetInterfaceName_(), "TouchscreenRemoved", obj.Path_(), obj.ServiceName_())

	sigRule := &dbusutil.SignalRule{
		Path: obj.Path_(),
		Name: v.GetInterfaceName_() + ".TouchscreenRemoved",
	}
	handlerFunc := func(sig *dbus.Signal) {
		var path dbus.ObjectPath
		err := dbus.Store(sig.Body, &path)
		if err == nil {
			cb(path)
		}
	}

	return obj.ConnectSignal_(rule, sigRule, handlerFunc)
}

// property Touchscreens ao

func (v *interfaceInputDevices) Touchscreens() proxy.PropObjectPathArray {
	return &proxy.ImplPropObjectPathArray{
		Impl: v,
		Name: "Touchscreens",
	}
}

type PropInputDevicesSupportWakupDevices interface {
	Get(flags dbus.Flags) (value map[string]string, err error)
	Set(flags dbus.Flags, value map[string]string) error
	ConnectChanged(cb func(hasValue bool, value map[string]string)) error
}

type implPropInputDevicesSupportWakupDevices struct {
	Impl proxy.Implementer
	Name string
}

func (p implPropInputDevicesSupportWakupDevices) Get(flags dbus.Flags) (value map[string]string, err error) {
	err = p.Impl.GetObject_().GetProperty_(flags, p.Impl.GetInterfaceName_(),
		p.Name, &value)
	return
}

func (p implPropInputDevicesSupportWakupDevices) Set(flags dbus.Flags, value map[string]string) error {
	return p.Impl.GetObject_().SetProperty_(flags, p.Impl.GetInterfaceName_(), p.Name, value)
}

func (p implPropInputDevicesSupportWakupDevices) ConnectChanged(cb func(hasValue bool, value map[string]string)) error {
	if cb == nil {
		return errors.New("nil callback")
	}
	cb0 := func(hasValue bool, value interface{}) {
		if hasValue {
			var v map[string]string
			err := dbus.Store([]interface{}{value}, &v)
			if err != nil {
				return
			}
			cb(true, v)
		} else {
			cb(false, nil)
		}
	}
	return p.Impl.GetObject_().ConnectPropertyChanged_(p.Impl.GetInterfaceName_(),
		p.Name, cb0)
}

// property SupportWakeupDevices a{ss}

func (v *interfaceInputDevices) SupportWakeupDevices() PropInputDevicesSupportWakupDevices {
	return &implPropInputDevicesSupportWakupDevices{
		Impl: v,
		Name: "SupportWakeupDevices",
	}
}

type Touchscreen interface {
	touchscreen // interface com.deepin.system.InputDevices.Touchscreen
	proxy.Object
}

type objectTouchscreen struct {
	interfaceTouchscreen // interface com.deepin.system.InputDevices.Touchscreen
	proxy.ImplObject
}

func NewTouchscreen(conn *dbus.Conn, path dbus.ObjectPath) (Touchscreen, error) {
	if !path.IsValid() {
		return nil, errors.New("path is invalid")
	}
	obj := new(objectTouchscreen)
	obj.ImplObject.Init_(conn, "com.deepin.system.InputDevices", path)
	return obj, nil
}

type touchscreen interface {
	DevNode() proxy.PropString
	BusType() proxy.PropString
	UUID() proxy.PropString
	Phys() proxy.PropString
	OutputName() proxy.PropString
	Width() proxy.PropDouble
	Height() proxy.PropDouble
	Name() proxy.PropString
	Serial() proxy.PropString
}

type interfaceTouchscreen struct{}

func (v *interfaceTouchscreen) GetObject_() *proxy.ImplObject {
	return (*proxy.ImplObject)(unsafe.Pointer(v))
}

func (*interfaceTouchscreen) GetInterfaceName_() string {
	return "com.deepin.system.InputDevices.Touchscreen"
}

// property DevNode s

func (v *interfaceTouchscreen) DevNode() proxy.PropString {
	return &proxy.ImplPropString{
		Impl: v,
		Name: "DevNode",
	}
}

// property BusType s

func (v *interfaceTouchscreen) BusType() proxy.PropString {
	return &proxy.ImplPropString{
		Impl: v,
		Name: "BusType",
	}
}

// property UUID s

func (v *interfaceTouchscreen) UUID() proxy.PropString {
	return &proxy.ImplPropString{
		Impl: v,
		Name: "UUID",
	}
}

// property Phys s

func (v *interfaceTouchscreen) Phys() proxy.PropString {
	return &proxy.ImplPropString{
		Impl: v,
		Name: "Phys",
	}
}

// property OutputName s

func (v *interfaceTouchscreen) OutputName() proxy.PropString {
	return &proxy.ImplPropString{
		Impl: v,
		Name: "OutputName",
	}
}

// property Width d

func (v *interfaceTouchscreen) Width() proxy.PropDouble {
	return &proxy.ImplPropDouble{
		Impl: v,
		Name: "Width",
	}
}

// property Height d

func (v *interfaceTouchscreen) Height() proxy.PropDouble {
	return &proxy.ImplPropDouble{
		Impl: v,
		Name: "Height",
	}
}

// property Name s

func (v *interfaceTouchscreen) Name() proxy.PropString {
	return &proxy.ImplPropString{
		Impl: v,
		Name: "Name",
	}
}

// property Serial s

func (v *interfaceTouchscreen) Serial() proxy.PropString {
	return &proxy.ImplPropString{
		Impl: v,
		Name: "Serial",
	}
}

type Touchpad interface {
	touchpad // interface com.deepin.system.InputDevices.Touchpad
	proxy.Object
}

type objectTouchpad struct {
	interfaceTouchpad // interface com.deepin.system.InputDevices.Touchpad
	proxy.ImplObject
}

func NewTouchpad(conn *dbus.Conn, path dbus.ObjectPath) (Touchpad, error) {
	if !path.IsValid() {
		return nil, errors.New("path is invalid")
	}
	obj := new(objectTouchpad)
	obj.ImplObject.Init_(conn, "com.deepin.system.InputDevices", path)
	return obj, nil
}

type touchpad interface {
	GoSetTouchpadEnable(flags dbus.Flags, ch chan *dbus.Call, enabled bool) *dbus.Call
	SetTouchpadEnable(flags dbus.Flags, enabled bool) error
	IsExist() proxy.PropBool
	Enable() proxy.PropBool
}

type interfaceTouchpad struct{}

func (v *interfaceTouchpad) GetObject_() *proxy.ImplObject {
	return (*proxy.ImplObject)(unsafe.Pointer(v))
}

func (*interfaceTouchpad) GetInterfaceName_() string {
	return "com.deepin.system.InputDevices.Touchpad"
}

// method SetTouchpadEnable

func (v *interfaceTouchpad) GoSetTouchpadEnable(flags dbus.Flags, ch chan *dbus.Call, enabled bool) *dbus.Call {
	return v.GetObject_().Go_(v.GetInterfaceName_()+".SetTouchpadEnable", flags, ch, enabled)
}

func (v *interfaceTouchpad) SetTouchpadEnable(flags dbus.Flags, enabled bool) error {
	return (<-v.GoSetTouchpadEnable(flags, make(chan *dbus.Call, 1), enabled).Done).Err
}

// property isExist b

func (v *interfaceTouchpad) IsExist() proxy.PropBool {
	return &proxy.ImplPropBool{
		Impl: v,
		Name: "isExist",
	}
}

// property Enable b

func (v *interfaceTouchpad) Enable() proxy.PropBool {
	return &proxy.ImplPropBool{
		Impl: v,
		Name: "Enable",
	}
}
