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

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

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

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

	dbusRemoveMatch("type='signal',path='" + string(obj.Path) + "',interface='com.linuxdeepin.softwarecenter',sender='" + obj.DestName + "',member='update_signal'")

}

func (obj *SoftwareCenter) GetUpgradeDownloadSize(pkg_names []string) (arg1 []string, _err error) {
	_err = obj.core.Call("com.linuxdeepin.softwarecenter.get_upgrade_download_size", 0, pkg_names).Store(&arg1)
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *SoftwareCenter) GetPkgStartStatus(pkg_name string, start_pkg_names string) (arg2 string, _err error) {
	_err = obj.core.Call("com.linuxdeepin.softwarecenter.get_pkg_start_status", 0, pkg_name, start_pkg_names).Store(&arg2)
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *SoftwareCenter) RequestPkgsInstallVersion(pkg_names []string) (arg1 []string, _err error) {
	_err = obj.core.Call("com.linuxdeepin.softwarecenter.request_pkgs_install_version", 0, pkg_names).Store(&arg1)
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *SoftwareCenter) StopDownloadPkg(pkg_names []string) (_err error) {
	_err = obj.core.Call("com.linuxdeepin.softwarecenter.stop_download_pkg", 0, pkg_names).Store()
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *SoftwareCenter) RequestPkgsUninstallVersion(pkg_names []string) (arg1 []string, _err error) {
	_err = obj.core.Call("com.linuxdeepin.softwarecenter.request_pkgs_uninstall_version", 0, pkg_names).Store(&arg1)
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *SoftwareCenter) RequestUpgradePkgs() (arg0 []string, _err error) {
	_err = obj.core.Call("com.linuxdeepin.softwarecenter.request_upgrade_pkgs", 0).Store(&arg0)
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *SoftwareCenter) RemoveWaitDownloads(pkg_names []string) (_err error) {
	_err = obj.core.Call("com.linuxdeepin.softwarecenter.remove_wait_downloads", 0, pkg_names).Store()
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *SoftwareCenter) SetPkgStatus(pkg_status interface{}) (_err error) {
	_err = obj.core.Call("com.linuxdeepin.softwarecenter.set_pkg_status", 0, pkg_status).Store()
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *SoftwareCenter) UpgradePkgsWithNewPolicy(pkg_names []string) (_err error) {
	_err = obj.core.Call("com.linuxdeepin.softwarecenter.upgrade_pkgs_with_new_policy", 0, pkg_names).Store()
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *SoftwareCenter) UpgradePkg(pkg_names []string) (_err error) {
	_err = obj.core.Call("com.linuxdeepin.softwarecenter.upgrade_pkg", 0, pkg_names).Store()
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *SoftwareCenter) CancelUpgradeDownload() (_err error) {
	_err = obj.core.Call("com.linuxdeepin.softwarecenter.cancel_upgrade_download", 0).Store()
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *SoftwareCenter) ReadNoNotifyConfig(no_notify_config_path dbus.Variant) (arg1 []string, _err error) {
	_err = obj.core.Call("com.linuxdeepin.softwarecenter.read_no_notify_config", 0, no_notify_config_path).Store(&arg1)
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *SoftwareCenter) RequestQuit() (_err error) {
	_err = obj.core.Call("com.linuxdeepin.softwarecenter.request_quit", 0).Store()
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *SoftwareCenter) InstallPkg(pkg_names []string) (_err error) {
	_err = obj.core.Call("com.linuxdeepin.softwarecenter.install_pkg", 0, pkg_names).Store()
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *SoftwareCenter) SetDownloadDir(local_dir string) (_err error) {
	_err = obj.core.Call("com.linuxdeepin.softwarecenter.set_download_dir", 0, local_dir).Store()
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *SoftwareCenter) AddNoNotifyPkg(info []string) (_err error) {
	_err = obj.core.Call("com.linuxdeepin.softwarecenter.add_no_notify_pkg", 0, info).Store()
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *SoftwareCenter) RequestStatus() (arg0 []string, _err error) {
	_err = obj.core.Call("com.linuxdeepin.softwarecenter.request_status", 0).Store(&arg0)
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *SoftwareCenter) GetDownloadSize(pkg_name string) (arg1 []int32, _err error) {
	_err = obj.core.Call("com.linuxdeepin.softwarecenter.get_download_size", 0, pkg_name).Store(&arg1)
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *SoftwareCenter) GetPkgNameFromPath(path string) (arg1 string, _err error) {
	_err = obj.core.Call("com.linuxdeepin.softwarecenter.get_pkg_name_from_path", 0, path).Store(&arg1)
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *SoftwareCenter) UninstallPkg(pkg_name string, purge bool) (_err error) {
	_err = obj.core.Call("com.linuxdeepin.softwarecenter.uninstall_pkg", 0, pkg_name, purge).Store()
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *SoftwareCenter) RequestPkgShortDesc(pkg_name string) (arg1 string, _err error) {
	_err = obj.core.Call("com.linuxdeepin.softwarecenter.request_pkg_short_desc", 0, pkg_name).Store(&arg1)
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *SoftwareCenter) RemoveWaitMissions(pkg_infos []string) (_err error) {
	_err = obj.core.Call("com.linuxdeepin.softwarecenter.remove_wait_missions", 0, pkg_infos).Store()
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *SoftwareCenter) ChangeSourceList(repo_urls []string) (_err error) {
	_err = obj.core.Call("com.linuxdeepin.softwarecenter.change_source_list", 0, repo_urls).Store()
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *SoftwareCenter) IsPkgInCache(pkg_name string) (arg1 []string, _err error) {
	_err = obj.core.Call("com.linuxdeepin.softwarecenter.is_pkg_in_cache", 0, pkg_name).Store(&arg1)
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *SoftwareCenter) RequestPkgsInstallStatus(pkg_names []string) (arg1 []bool, _err error) {
	_err = obj.core.Call("com.linuxdeepin.softwarecenter.request_pkgs_install_status", 0, pkg_names).Store(&arg1)
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *SoftwareCenter) RequestUninstallPkgs() (arg0 string, _err error) {
	_err = obj.core.Call("com.linuxdeepin.softwarecenter.request_uninstall_pkgs", 0).Store(&arg0)
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *SoftwareCenter) SayHello(simulate bool) (_err error) {
	_err = obj.core.Call("com.linuxdeepin.softwarecenter.say_hello", 0, simulate).Store()
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *SoftwareCenter) StartUpdateList() (_err error) {
	_err = obj.core.Call("com.linuxdeepin.softwarecenter.start_update_list", 0).Store()
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *SoftwareCenter) InitDownloadManager(number int32) (_err error) {
	_err = obj.core.Call("com.linuxdeepin.softwarecenter.init_download_manager", 0, number).Store()
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *SoftwareCenter) CleanDownloadCache() (arg0 []int32, _err error) {
	_err = obj.core.Call("com.linuxdeepin.softwarecenter.clean_download_cache", 0).Store(&arg0)
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *SoftwareCenter) RemoveNoNotifyPkg(info []string) (_err error) {
	_err = obj.core.Call("com.linuxdeepin.softwarecenter.remove_no_notify_pkg", 0, info).Store()
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *SoftwareCenter) GetPkgInstalled(pkg_name string) (arg1 int32, _err error) {
	_err = obj.core.Call("com.linuxdeepin.softwarecenter.get_pkg_installed", 0, pkg_name).Store(&arg1)
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *SoftwareCenter) UninstallPkgFromDesktop(desktop_path string, purge bool) (_err error) {
	_err = obj.core.Call("com.linuxdeepin.softwarecenter.uninstall_pkg_from_desktop", 0, desktop_path, purge).Store()
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *SoftwareCenter) Connectupdate_signal(callback func(message [][]interface{})) func() {
	sigChan := obj._createSignalChan()
	go func() {
		for v := range sigChan {
			if v.Path != obj.Path || v.Name != "com.linuxdeepin.softwarecenter.update_signal" || 1 != len(v.Body) {
				continue
			}
			if reflect.TypeOf(v.Body[0]) != reflect.TypeOf((*[][]interface{})(nil)).Elem() {
				continue
			}

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

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

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

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

	dbusAddMatch("type='signal',path='" + string(obj.Path) + "',interface='com.linuxdeepin.softwarecenter',sender='" + obj.DestName + "',member='update_signal'")

	runtime.SetFinalizer(obj, func(_obj *SoftwareCenter) { DestroySoftwareCenter(_obj) })
	return obj, nil
}
