Exemple #1
0
func (load *Loader) uploaderAction(call func(sc uploader)) *dbus.Error {
	if load.apps == nil {
		return dbuscommon.NewError("no active application")
	}

	uncasts := load.apps.GetApplets("NetActivity")
	if len(uncasts) == 0 {
		return dbuscommon.NewError("no active uploader found")
	}
	app := uncasts[0].(uploader) // Send it to the first found. Should be safe for now, we can launch only one.
	call(app)
	return nil
}
Exemple #2
0
// Restart restarts the dock.
//
func (o *Server) Restart() *dbus.Error {
	e := o.DockRestart()
	if o.Log.Err(e, "DockRestart") {
		return dbuscommon.NewError(e.Error())
	}
	return nil
}
Exemple #3
0
// AppletDebug change the debug state of an active applet.
//
func (load *Loader) AppletDebug(applet string, state bool) *dbus.Error {
	if load.apps == nil {
		return dbuscommon.NewError("no active application")
	}

	found := false
	for _, app := range load.apps.GetApplets(applet) {
		app.Log().SetDebug(state)
		found = true
	}
	if !found {
		load.Log.NewWarn("applet not found = "+applet, "set applet debug")
		return dbuscommon.NewError("applet not found = " + applet)
	}

	load.Log.Info("set applet debug", applet, state)
	return nil
}
Exemple #4
0
// StartApplet creates a new applet instance with args from command line.
//
func (load *Manager) StartApplet(a, b, c, d, e, f, g, h string) *dbus.Error {
	split := strings.Split(c, "/")
	if len(split) < 4 {
		load.log.NewErr("StartApplet: incorrect dbus path", c)
		return dbuscommon.NewError("StartApplet: incorrect dbus path " + c)
	}
	name := split[4] //path is /org/cairodock/CairoDock/appletName or  /org/cairodock/CairoDock/appletName/sub_icons

	a = "./" + name // reformat the launcher name as if it was directly called from shell.
	args := []string{a, b, c, d, e, f, g, h}

	if _, ok := load.actives[c]; ok {
		load.log.NewErr("StartApplet: applet already started", name)
		return dbuscommon.NewError("StartApplet: applet already started " + name)
	}

	if cdtype.Applets.GetNewFunc(name) == nil {
		load.log.NewErr(strings.Join(args, " "), "StartApplet: applet unknown (maybe not enabled at compile)")
		return dbuscommon.NewError("StartApplet: applet unknown (maybe not enabled at compile) " + strings.Join(args, " "))
	}

	// Create applet instance.
	// name := args[0][2:] // Strip ./ in the beginning.
	callnew := cdtype.Applets.GetNewFunc(name)
	app, backend, callinit := appdbus.New(callnew, args, h)
	if app == nil {
		load.log.NewErr(name, "failed to create applet")
		return dbuscommon.NewError("failed to create applet" + name)
	}

	er := backend.ConnectEvents(load.Loader.Conn)
	if app.Log().Err(er, "ConnectEvents") {
		return dbuscommon.NewError("ConnectEvents: " + er.Error())
	}

	load.actives[c] = &activeApp{
		app:     app,
		name:    name,
		backend: backend,
	}

	if load.log.GetDebug() { // If the service debug is active, force it also on applets.
		app.Log().SetDebug(true)
	}
	load.log.Debug("StartApplet", name)

	// Initialise applet: Load config and apply user settings.
	// Find a way to unload the applet without the crash in dock and DBus service mode.
	er = callinit()
	if load.log.Err(er, "init applet") {
		return dbuscommon.NewError("failed to create applet" + name)
	}

	return nil
}