Esempio n. 1
0
// ConnectEvents registers to receive Dbus applet events.
//
func (cda *CDDbus) ConnectEvents(conn *dbus.Conn) (e error) {
	cda.dbusIcon, e = dbuscommon.GetClient(dockpath.DbusObject, string(cda.busPath), dockpath.DbusInterfaceApplet)
	if e != nil {
		return e
	}

	cda.dbusSub, e = dbuscommon.GetClient(dockpath.DbusObject, string(cda.busPath)+"/sub_icons", dockpath.DbusInterfaceSubapplet)
	if e != nil {
		return e
	}

	if cda.dbusIcon == nil || cda.dbusSub == nil {
		return errors.New("missing Dbus interface")
	}

	// Log all errors returned from DBus calls. Applets won't have to bother about that.
	cda.dbusIcon.SetTestErr(cda.testErr)
	cda.dbusSub.SetTestErr(cda.testErr)

	// Listen to all events emitted for the icon.
	matchIcon := "type='signal',path='" + string(cda.busPath) + "',interface='" + dockpath.DbusInterfaceApplet + "',sender='" + dockpath.DbusObject + "'"
	matchSubs := "type='signal',path='" + string(cda.busPath) + "/sub_icons',interface='" + dockpath.DbusInterfaceSubapplet + "',sender='" + dockpath.DbusObject + "'"

	e = conn.BusObject().Call("org.freedesktop.DBus.AddMatch", 0, matchIcon).Err
	if cda.log.Err(e, "connect to icon DBus events") {
		return e
	}
	e = conn.BusObject().Call("org.freedesktop.DBus.AddMatch", 0, matchSubs).Err
	cda.log.Err(e, "connect to subicons DBus events")

	return e
}
Esempio n. 2
0
// Action sends an action to the dlogbus server.
//
func Action(action func(*Client) error) error {
	client, e := dbuscommon.GetClient(SrvObj, SrvPath)
	if e != nil {
		return e
	}
	return action(&Client{client}) // we have a server, launch the provided action.
}
Esempio n. 3
0
// Upload forwards action upload data to the dock.
//
func Upload(data string) error {
	client, e := dbuscommon.GetClient(SrvObj, SrvPath)
	if e != nil {
		return e
	}
	return client.Call("Upload", data)
}
Esempio n. 4
0
// SourceCodeOpenFile forwards action open source code file to the dock.
//
func SourceCodeOpenFile(data string) error {
	client, e := dbuscommon.GetClient(SrvObj, SrvPath)
	if e != nil {
		return e
	}
	return client.Call("SourceCodeOpenFile", data)
}
Esempio n. 5
0
// SourceCodeBuildTarget forwards action open source code file to the dock.
//
func SourceCodeBuildTarget() error {
	client, e := dbuscommon.GetClient(SrvObj, SrvPath)
	if e != nil {
		return e
	}
	return client.Call("SourceCodeBuildTarget")
}
Esempio n. 6
0
// AppletDebug forwards action set debug to a remote applet.
//
func AppletDebug(applet string, state bool) error {
	client, e := dbuscommon.GetClient(SrvObj, SrvPath)
	if e != nil {
		return e
	}
	return client.Call("AppletDebug", applet, state)
}
Esempio n. 7
0
// NewClient creates a Client connected to the dock server.
//
func NewClient() (*Client, error) {
	cl, e := dbuscommon.GetClient(dockpath.DbusObject, string(dockpath.DbusPathDock))
	if e != nil {
		return nil, e
	}
	return &Client{cl}, nil
}
Esempio n. 8
0
// StartApplet forwards action to start a new applet.
// Args are those sent by the dock in the started applet command line.
//
func StartApplet(a, b, c, d, e, f, g string) error {
	client, err := dbuscommon.GetClient(srvdbus.SrvObj, srvdbus.SrvPath)
	if err != nil {
		return err
	}
	return client.Call("StartApplet", "", a, b, c, d, e, f, g)
}
Esempio n. 9
0
// ListServices forwards action to get the list of active services.
//
func ListServices() (string, error) {
	client, e := dbuscommon.GetClient(srvdbus.SrvObj, srvdbus.SrvPath)
	if e != nil {
		return "", e
	}
	var str string
	e = client.Get("ListServices", []interface{}{&str})
	return str, e
}
Esempio n. 10
0
// UpToShareLastLink forwards action upload data to the dock.
//
func UpToShareLastLink() (string, error) {
	client, e := dbuscommon.GetClient(SrvObj, SrvPath)
	if e != nil {
		return "", e
	}

	var link string
	e = client.Get("UpToShareLastLink", []interface{}{&link})
	return link, e
}