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

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 XMouseArea struct {
	Path     dbus.ObjectPath
	DestName string
	core     *dbus.Object

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

func (obj *XMouseArea) _createSignalChan() <-chan *dbus.Signal {
	obj.signalsLocker.Lock()
	ch := getBus().Signal()
	obj.signals[ch] = struct{}{}
	obj.signalsLocker.Unlock()
	return ch
}
func (obj *XMouseArea) _deleteSignalChan(ch <-chan *dbus.Signal) {
	obj.signalsLocker.Lock()
	delete(obj.signals, ch)
	getBus().DetachSignal(ch)
	obj.signalsLocker.Unlock()
}
func DestroyXMouseArea(obj *XMouseArea) {
	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='com.deepin.api.XMouseArea',sender='" + obj.DestName + "',member='PropertiesChanged'")

	dbusRemoveMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.api.XMouseArea',sender='" + obj.DestName + "',member='CursorInto'")

	dbusRemoveMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.api.XMouseArea',sender='" + obj.DestName + "',member='CursorOut'")

	dbusRemoveMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.api.XMouseArea',sender='" + obj.DestName + "',member='CursorMove'")

	dbusRemoveMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.api.XMouseArea',sender='" + obj.DestName + "',member='ButtonPress'")

	dbusRemoveMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.api.XMouseArea',sender='" + obj.DestName + "',member='ButtonRelease'")

	dbusRemoveMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.api.XMouseArea',sender='" + obj.DestName + "',member='KeyPress'")

	dbusRemoveMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.api.XMouseArea',sender='" + obj.DestName + "',member='KeyRelease'")

	dbusRemoveMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.api.XMouseArea',sender='" + obj.DestName + "',member='CancelArea'")

	dbusRemoveMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.api.XMouseArea',sender='" + obj.DestName + "',member='CancelAllArea'")

}

func (obj *XMouseArea) RegisterArea(arg0 int32, arg1 int32, arg2 int32, arg3 int32, arg4 int32) (arg5 string, _err error) {
	_err = obj.core.Call("com.deepin.api.XMouseArea.RegisterArea", 0, arg0, arg1, arg2, arg3, arg4).Store(&arg5)
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *XMouseArea) RegisterAreas(arg0 interface{}, arg1 int32) (arg2 string, _err error) {
	_err = obj.core.Call("com.deepin.api.XMouseArea.RegisterAreas", 0, arg0, arg1).Store(&arg2)
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *XMouseArea) RegisterFullScreen() (arg0 string, _err error) {
	_err = obj.core.Call("com.deepin.api.XMouseArea.RegisterFullScreen", 0).Store(&arg0)
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *XMouseArea) UnregisterArea(arg0 string) (_err error) {
	_err = obj.core.Call("com.deepin.api.XMouseArea.UnregisterArea", 0, arg0).Store()
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *XMouseArea) ConnectCursorInto(callback func(arg0 int32, arg1 int32, arg2 string)) func() {
	sigChan := obj._createSignalChan()
	go func() {
		for v := range sigChan {
			if v.Path != obj.Path || v.Name != "com.deepin.api.XMouseArea.CursorInto" || 3 != len(v.Body) {
				continue
			}
			if reflect.TypeOf(v.Body[0]) != reflect.TypeOf((*int32)(nil)).Elem() {
				continue
			}
			if reflect.TypeOf(v.Body[1]) != reflect.TypeOf((*int32)(nil)).Elem() {
				continue
			}
			if reflect.TypeOf(v.Body[2]) != reflect.TypeOf((*string)(nil)).Elem() {
				continue
			}

			callback(v.Body[0].(int32), v.Body[1].(int32), v.Body[2].(string))
		}
	}()
	return func() {
		obj._deleteSignalChan(sigChan)
	}
}

func (obj *XMouseArea) ConnectCursorOut(callback func(arg0 int32, arg1 int32, arg2 string)) func() {
	sigChan := obj._createSignalChan()
	go func() {
		for v := range sigChan {
			if v.Path != obj.Path || v.Name != "com.deepin.api.XMouseArea.CursorOut" || 3 != len(v.Body) {
				continue
			}
			if reflect.TypeOf(v.Body[0]) != reflect.TypeOf((*int32)(nil)).Elem() {
				continue
			}
			if reflect.TypeOf(v.Body[1]) != reflect.TypeOf((*int32)(nil)).Elem() {
				continue
			}
			if reflect.TypeOf(v.Body[2]) != reflect.TypeOf((*string)(nil)).Elem() {
				continue
			}

			callback(v.Body[0].(int32), v.Body[1].(int32), v.Body[2].(string))
		}
	}()
	return func() {
		obj._deleteSignalChan(sigChan)
	}
}

func (obj *XMouseArea) ConnectCursorMove(callback func(arg0 int32, arg1 int32, arg2 string)) func() {
	sigChan := obj._createSignalChan()
	go func() {
		for v := range sigChan {
			if v.Path != obj.Path || v.Name != "com.deepin.api.XMouseArea.CursorMove" || 3 != len(v.Body) {
				continue
			}
			if reflect.TypeOf(v.Body[0]) != reflect.TypeOf((*int32)(nil)).Elem() {
				continue
			}
			if reflect.TypeOf(v.Body[1]) != reflect.TypeOf((*int32)(nil)).Elem() {
				continue
			}
			if reflect.TypeOf(v.Body[2]) != reflect.TypeOf((*string)(nil)).Elem() {
				continue
			}

			callback(v.Body[0].(int32), v.Body[1].(int32), v.Body[2].(string))
		}
	}()
	return func() {
		obj._deleteSignalChan(sigChan)
	}
}

func (obj *XMouseArea) ConnectButtonPress(callback func(arg0 int32, arg1 int32, arg2 int32, arg3 string)) func() {
	sigChan := obj._createSignalChan()
	go func() {
		for v := range sigChan {
			if v.Path != obj.Path || v.Name != "com.deepin.api.XMouseArea.ButtonPress" || 4 != len(v.Body) {
				continue
			}
			if reflect.TypeOf(v.Body[0]) != reflect.TypeOf((*int32)(nil)).Elem() {
				continue
			}
			if reflect.TypeOf(v.Body[1]) != reflect.TypeOf((*int32)(nil)).Elem() {
				continue
			}
			if reflect.TypeOf(v.Body[2]) != reflect.TypeOf((*int32)(nil)).Elem() {
				continue
			}
			if reflect.TypeOf(v.Body[3]) != reflect.TypeOf((*string)(nil)).Elem() {
				continue
			}

			callback(v.Body[0].(int32), v.Body[1].(int32), v.Body[2].(int32), v.Body[3].(string))
		}
	}()
	return func() {
		obj._deleteSignalChan(sigChan)
	}
}

func (obj *XMouseArea) ConnectButtonRelease(callback func(arg0 int32, arg1 int32, arg2 int32, arg3 string)) func() {
	sigChan := obj._createSignalChan()
	go func() {
		for v := range sigChan {
			if v.Path != obj.Path || v.Name != "com.deepin.api.XMouseArea.ButtonRelease" || 4 != len(v.Body) {
				continue
			}
			if reflect.TypeOf(v.Body[0]) != reflect.TypeOf((*int32)(nil)).Elem() {
				continue
			}
			if reflect.TypeOf(v.Body[1]) != reflect.TypeOf((*int32)(nil)).Elem() {
				continue
			}
			if reflect.TypeOf(v.Body[2]) != reflect.TypeOf((*int32)(nil)).Elem() {
				continue
			}
			if reflect.TypeOf(v.Body[3]) != reflect.TypeOf((*string)(nil)).Elem() {
				continue
			}

			callback(v.Body[0].(int32), v.Body[1].(int32), v.Body[2].(int32), v.Body[3].(string))
		}
	}()
	return func() {
		obj._deleteSignalChan(sigChan)
	}
}

func (obj *XMouseArea) ConnectKeyPress(callback func(arg0 string, arg1 int32, arg2 int32, arg3 string)) func() {
	sigChan := obj._createSignalChan()
	go func() {
		for v := range sigChan {
			if v.Path != obj.Path || v.Name != "com.deepin.api.XMouseArea.KeyPress" || 4 != len(v.Body) {
				continue
			}
			if reflect.TypeOf(v.Body[0]) != reflect.TypeOf((*string)(nil)).Elem() {
				continue
			}
			if reflect.TypeOf(v.Body[1]) != reflect.TypeOf((*int32)(nil)).Elem() {
				continue
			}
			if reflect.TypeOf(v.Body[2]) != reflect.TypeOf((*int32)(nil)).Elem() {
				continue
			}
			if reflect.TypeOf(v.Body[3]) != reflect.TypeOf((*string)(nil)).Elem() {
				continue
			}

			callback(v.Body[0].(string), v.Body[1].(int32), v.Body[2].(int32), v.Body[3].(string))
		}
	}()
	return func() {
		obj._deleteSignalChan(sigChan)
	}
}

func (obj *XMouseArea) ConnectKeyRelease(callback func(arg0 string, arg1 int32, arg2 int32, arg3 string)) func() {
	sigChan := obj._createSignalChan()
	go func() {
		for v := range sigChan {
			if v.Path != obj.Path || v.Name != "com.deepin.api.XMouseArea.KeyRelease" || 4 != len(v.Body) {
				continue
			}
			if reflect.TypeOf(v.Body[0]) != reflect.TypeOf((*string)(nil)).Elem() {
				continue
			}
			if reflect.TypeOf(v.Body[1]) != reflect.TypeOf((*int32)(nil)).Elem() {
				continue
			}
			if reflect.TypeOf(v.Body[2]) != reflect.TypeOf((*int32)(nil)).Elem() {
				continue
			}
			if reflect.TypeOf(v.Body[3]) != reflect.TypeOf((*string)(nil)).Elem() {
				continue
			}

			callback(v.Body[0].(string), v.Body[1].(int32), v.Body[2].(int32), v.Body[3].(string))
		}
	}()
	return func() {
		obj._deleteSignalChan(sigChan)
	}
}

func (obj *XMouseArea) ConnectCancelArea(callback func(arg0 string)) func() {
	sigChan := obj._createSignalChan()
	go func() {
		for v := range sigChan {
			if v.Path != obj.Path || v.Name != "com.deepin.api.XMouseArea.CancelArea" || 1 != len(v.Body) {
				continue
			}
			if reflect.TypeOf(v.Body[0]) != reflect.TypeOf((*string)(nil)).Elem() {
				continue
			}

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

func (obj *XMouseArea) ConnectCancelAllArea(callback func()) func() {
	sigChan := obj._createSignalChan()
	go func() {
		for v := range sigChan {
			if v.Path != obj.Path || v.Name != "com.deepin.api.XMouseArea.CancelAllArea" || 0 != len(v.Body) {
				continue
			}

			callback()
		}
	}()
	return func() {
		obj._deleteSignalChan(sigChan)
	}
}

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

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

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

	dbusAddMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.api.XMouseArea',sender='" + obj.DestName + "',member='CursorInto'")

	dbusAddMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.api.XMouseArea',sender='" + obj.DestName + "',member='CursorOut'")

	dbusAddMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.api.XMouseArea',sender='" + obj.DestName + "',member='CursorMove'")

	dbusAddMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.api.XMouseArea',sender='" + obj.DestName + "',member='ButtonPress'")

	dbusAddMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.api.XMouseArea',sender='" + obj.DestName + "',member='ButtonRelease'")

	dbusAddMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.api.XMouseArea',sender='" + obj.DestName + "',member='KeyPress'")

	dbusAddMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.api.XMouseArea',sender='" + obj.DestName + "',member='KeyRelease'")

	dbusAddMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.api.XMouseArea',sender='" + obj.DestName + "',member='CancelArea'")

	dbusAddMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.api.XMouseArea',sender='" + obj.DestName + "',member='CancelAllArea'")

	runtime.SetFinalizer(obj, func(_obj *XMouseArea) { DestroyXMouseArea(_obj) })
	return obj, nil
}
