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

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

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

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

	dbusRemoveMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.dde.daemon.Launcher',sender='" + obj.DestName + "',member='ItemChanged'")

	dbusRemoveMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.dde.daemon.Launcher',sender='" + obj.DestName + "',member='UninstallSuccess'")

	dbusRemoveMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.dde.daemon.Launcher',sender='" + obj.DestName + "',member='UninstallFailed'")

	dbusRemoveMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.dde.daemon.Launcher',sender='" + obj.DestName + "',member='SendToDesktopSuccess'")

	dbusRemoveMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.dde.daemon.Launcher',sender='" + obj.DestName + "',member='SendToDesktopFailed'")

	dbusRemoveMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.dde.daemon.Launcher',sender='" + obj.DestName + "',member='RemoveFromDesktopSuccess'")

	dbusRemoveMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.dde.daemon.Launcher',sender='" + obj.DestName + "',member='RemoveFromDesktopFailed'")

	dbusRemoveMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.dde.daemon.Launcher',sender='" + obj.DestName + "',member='SearchDone'")

	dbusRemoveMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.dde.daemon.Launcher',sender='" + obj.DestName + "',member='NewAppLaunched'")

	dbusRemoveMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.dde.daemon.Launcher',sender='" + obj.DestName + "',member='NewAppMarkedAsLaunched'")

}

func (obj *Launcher) GetAllCategoryInfos() (arg0 [][]interface{}, _err error) {
	_err = obj.core.Call("com.deepin.dde.daemon.Launcher.GetAllCategoryInfos", 0).Store(&arg0)
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *Launcher) GetAllFrequency() (arg0 [][]interface{}, _err error) {
	_err = obj.core.Call("com.deepin.dde.daemon.Launcher.GetAllFrequency", 0).Store(&arg0)
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *Launcher) GetAllItemInfos() (arg0 [][]interface{}, _err error) {
	_err = obj.core.Call("com.deepin.dde.daemon.Launcher.GetAllItemInfos", 0).Store(&arg0)
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *Launcher) GetAllNewInstalledApps() (arg0 []string, _err error) {
	_err = obj.core.Call("com.deepin.dde.daemon.Launcher.GetAllNewInstalledApps", 0).Store(&arg0)
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *Launcher) GetAllTimeInstalled() (arg0 [][]interface{}, _err error) {
	_err = obj.core.Call("com.deepin.dde.daemon.Launcher.GetAllTimeInstalled", 0).Store(&arg0)
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *Launcher) GetCategoryInfo(arg0 int64) (arg1 []interface{}, _err error) {
	_err = obj.core.Call("com.deepin.dde.daemon.Launcher.GetCategoryInfo", 0, arg0).Store(&arg1)
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *Launcher) GetItemInfo(arg0 string) (arg1 []interface{}, _err error) {
	_err = obj.core.Call("com.deepin.dde.daemon.Launcher.GetItemInfo", 0, arg0).Store(&arg1)
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *Launcher) IsItemOnDesktop(arg0 string) (arg1 bool, _err error) {
	_err = obj.core.Call("com.deepin.dde.daemon.Launcher.IsItemOnDesktop", 0, arg0).Store(&arg1)
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *Launcher) MarkLaunched(arg0 string) (_err error) {
	_err = obj.core.Call("com.deepin.dde.daemon.Launcher.MarkLaunched", 0, arg0).Store()
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *Launcher) RecordFrequency(arg0 string) (_err error) {
	_err = obj.core.Call("com.deepin.dde.daemon.Launcher.RecordFrequency", 0, arg0).Store()
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *Launcher) RecordRate(arg0 string) (_err error) {
	_err = obj.core.Call("com.deepin.dde.daemon.Launcher.RecordRate", 0, arg0).Store()
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *Launcher) RefreshItem(arg0 string) (arg1 []interface{}, _err error) {
	_err = obj.core.Call("com.deepin.dde.daemon.Launcher.RefreshItem", 0, arg0).Store(&arg1)
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *Launcher) RequestRemoveFromDesktop(arg0 string) (arg1 bool, _err error) {
	_err = obj.core.Call("com.deepin.dde.daemon.Launcher.RequestRemoveFromDesktop", 0, arg0).Store(&arg1)
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *Launcher) RequestSendToDesktop(arg0 string) (arg1 bool, _err error) {
	_err = obj.core.Call("com.deepin.dde.daemon.Launcher.RequestSendToDesktop", 0, arg0).Store(&arg1)
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *Launcher) RequestUninstall(arg0 string, arg1 bool) (_err error) {
	_err = obj.core.Call("com.deepin.dde.daemon.Launcher.RequestUninstall", 0, arg0, arg1).Store()
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *Launcher) Search(arg0 string) (_err error) {
	_err = obj.core.Call("com.deepin.dde.daemon.Launcher.Search", 0, arg0).Store()
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *Launcher) ConnectItemChanged(callback func(arg0 string, arg1 []interface{}, arg2 int64)) func() {
	sigChan := obj._createSignalChan()
	go func() {
		for v := range sigChan {
			if v.Path != obj.Path || v.Name != "com.deepin.dde.daemon.Launcher.ItemChanged" || 3 != len(v.Body) {
				continue
			}
			if reflect.TypeOf(v.Body[0]) != reflect.TypeOf((*string)(nil)).Elem() {
				continue
			}
			if reflect.TypeOf(v.Body[1]) != reflect.TypeOf((*[]interface{})(nil)).Elem() {
				continue
			}
			if reflect.TypeOf(v.Body[2]) != reflect.TypeOf((*int64)(nil)).Elem() {
				continue
			}

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

func (obj *Launcher) ConnectUninstallSuccess(callback func(arg0 string)) func() {
	sigChan := obj._createSignalChan()
	go func() {
		for v := range sigChan {
			if v.Path != obj.Path || v.Name != "com.deepin.dde.daemon.Launcher.UninstallSuccess" || 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 *Launcher) ConnectUninstallFailed(callback func(arg0 string, arg1 string)) func() {
	sigChan := obj._createSignalChan()
	go func() {
		for v := range sigChan {
			if v.Path != obj.Path || v.Name != "com.deepin.dde.daemon.Launcher.UninstallFailed" || 2 != len(v.Body) {
				continue
			}
			if reflect.TypeOf(v.Body[0]) != reflect.TypeOf((*string)(nil)).Elem() {
				continue
			}
			if reflect.TypeOf(v.Body[1]) != reflect.TypeOf((*string)(nil)).Elem() {
				continue
			}

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

func (obj *Launcher) ConnectSendToDesktopSuccess(callback func(arg0 string)) func() {
	sigChan := obj._createSignalChan()
	go func() {
		for v := range sigChan {
			if v.Path != obj.Path || v.Name != "com.deepin.dde.daemon.Launcher.SendToDesktopSuccess" || 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 *Launcher) ConnectSendToDesktopFailed(callback func(arg0 string, arg1 string)) func() {
	sigChan := obj._createSignalChan()
	go func() {
		for v := range sigChan {
			if v.Path != obj.Path || v.Name != "com.deepin.dde.daemon.Launcher.SendToDesktopFailed" || 2 != len(v.Body) {
				continue
			}
			if reflect.TypeOf(v.Body[0]) != reflect.TypeOf((*string)(nil)).Elem() {
				continue
			}
			if reflect.TypeOf(v.Body[1]) != reflect.TypeOf((*string)(nil)).Elem() {
				continue
			}

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

func (obj *Launcher) ConnectRemoveFromDesktopSuccess(callback func(arg0 string)) func() {
	sigChan := obj._createSignalChan()
	go func() {
		for v := range sigChan {
			if v.Path != obj.Path || v.Name != "com.deepin.dde.daemon.Launcher.RemoveFromDesktopSuccess" || 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 *Launcher) ConnectRemoveFromDesktopFailed(callback func(arg0 string, arg1 string)) func() {
	sigChan := obj._createSignalChan()
	go func() {
		for v := range sigChan {
			if v.Path != obj.Path || v.Name != "com.deepin.dde.daemon.Launcher.RemoveFromDesktopFailed" || 2 != len(v.Body) {
				continue
			}
			if reflect.TypeOf(v.Body[0]) != reflect.TypeOf((*string)(nil)).Elem() {
				continue
			}
			if reflect.TypeOf(v.Body[1]) != reflect.TypeOf((*string)(nil)).Elem() {
				continue
			}

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

func (obj *Launcher) ConnectSearchDone(callback func(arg0 []string)) func() {
	sigChan := obj._createSignalChan()
	go func() {
		for v := range sigChan {
			if v.Path != obj.Path || v.Name != "com.deepin.dde.daemon.Launcher.SearchDone" || 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 *Launcher) ConnectNewAppLaunched(callback func(arg0 string)) func() {
	sigChan := obj._createSignalChan()
	go func() {
		for v := range sigChan {
			if v.Path != obj.Path || v.Name != "com.deepin.dde.daemon.Launcher.NewAppLaunched" || 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 *Launcher) ConnectNewAppMarkedAsLaunched(callback func(arg0 string)) func() {
	sigChan := obj._createSignalChan()
	go func() {
		for v := range sigChan {
			if v.Path != obj.Path || v.Name != "com.deepin.dde.daemon.Launcher.NewAppMarkedAsLaunched" || 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 NewLauncher(destName string, path dbus.ObjectPath) (*Launcher, error) {
	if !path.IsValid() {
		return nil, errors.New("The path of '" + string(path) + "' is invalid.")
	}

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

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

	dbusAddMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.dde.daemon.Launcher',sender='" + obj.DestName + "',member='ItemChanged'")

	dbusAddMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.dde.daemon.Launcher',sender='" + obj.DestName + "',member='UninstallSuccess'")

	dbusAddMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.dde.daemon.Launcher',sender='" + obj.DestName + "',member='UninstallFailed'")

	dbusAddMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.dde.daemon.Launcher',sender='" + obj.DestName + "',member='SendToDesktopSuccess'")

	dbusAddMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.dde.daemon.Launcher',sender='" + obj.DestName + "',member='SendToDesktopFailed'")

	dbusAddMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.dde.daemon.Launcher',sender='" + obj.DestName + "',member='RemoveFromDesktopSuccess'")

	dbusAddMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.dde.daemon.Launcher',sender='" + obj.DestName + "',member='RemoveFromDesktopFailed'")

	dbusAddMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.dde.daemon.Launcher',sender='" + obj.DestName + "',member='SearchDone'")

	dbusAddMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.dde.daemon.Launcher',sender='" + obj.DestName + "',member='NewAppLaunched'")

	dbusAddMatch("type='signal',path='" + string(obj.Path) + "',interface='com.deepin.dde.daemon.Launcher',sender='" + obj.DestName + "',member='NewAppMarkedAsLaunched'")

	runtime.SetFinalizer(obj, func(_obj *Launcher) { DestroyLauncher(_obj) })
	return obj, nil
}
