Пример #1
0
func Start() *LangSelector {
	var logger = log.NewLogger(dbusSender)

	if !lib.UniqueOnSession(dbusSender) {
		logger.Warning("There is a LangSelector running...")
		return nil
	}

	logger.BeginTracing()

	_lang = newLangSelector(logger)
	if _lang == nil {
		logger.Error("Create LangSelector Failed")
		return nil
	}

	err := dbus.InstallOnSession(_lang)
	if err != nil {
		logger.Error("Install Session DBus Failed:", err)
		Stop()
		return nil
	}

	_lang.onLocaleSuccess()

	return _lang
}
Пример #2
0
func init() {
	if logger == nil {
		logger = log.NewLogger("com.deepin.daemon.Power")
	}

	C.Suite(&DBusInterfaceTest{})
}
Пример #3
0
func main() {
	logger := log.NewLogger("dde-daemon/desktop-toggle")
	logger.BeginTracing()
	defer logger.EndTracing()

	X, err := xgbutil.NewConn()
	if err != nil {
		logger.Error("New xgbutil connection failed: ", err)
		panic(err)
	}

	if ret, err := ewmh.ShowingDesktopGet(X); err == nil {
		// !!! NOT using ewmh.ShowingDesktopReq
		// because ewmh.ShowingDesktopReq passes a uint argument,
		// and int is used on xevent.NewClientMessage.
		logger.Info("Show Desktop Status: ", ret)
		var showInt int
		if ret {
			showInt = 0
		} else {
			showInt = 1
		}
		ewmh.ClientEvent(X, X.RootWin(), "_NET_SHOWING_DESKTOP", showInt)
	}
	X.Sync()
}
Пример #4
0
func NewManager() *Manager {
	var m = Manager{}

	m.logger = log.NewLogger(dbusSender)
	m.monitor = gio.VolumeMonitorGet()
	m.setting, _ = dutils.CheckAndNewGSettings(mediaHandlerSchema)
	m.diskCache = make(map[string]*diskObjectInfo)
	m.endFlag = make(chan struct{})

	m.DiskList = m.getDiskInfos()

	return &m
}
Пример #5
0
func Start() {
	if _m != nil {
		return
	}

	var logger = log.NewLogger("com.deepin.daemon.InputDevices")
	logger.BeginTracing()

	if !initDeviceChangedWatcher() {
		logger.Error("Init device changed wacher failed")
		logger.EndTracing()
		return
	}

	_m := NewManager(logger)
	err := dbus.InstallOnSession(_m)
	if err != nil {
		logger.Error("Install Manager DBus Failed:", err)
		finalize()
		return
	}

	err = dbus.InstallOnSession(_m.mouse)
	if err != nil {
		logger.Error("Install Mouse DBus Failed:", err)
		finalize()
		return
	}

	err = dbus.InstallOnSession(_m.touchpad)
	if err != nil {
		logger.Error("Install Touchpad DBus Failed:", err)
		finalize()
		return
	}

	err = dbus.InstallOnSession(_m.kbd)
	if err != nil {
		logger.Error("Install Keyboard DBus Failed:", err)
		finalize()
		return
	}

	err = dbus.InstallOnSession(_m.wacom)
	if err != nil {
		logger.Error("Install Wacom DBus Failed:", err)
		finalize()
		return
	}
}
Пример #6
0
func Start() {
	if _sysInfo != nil {
		return
	}

	logger := log.NewLogger("com.deepin.daemon.SystemInfo")
	logger.BeginTracing()

	_sysInfo = NewSystemInfo(logger)
	err := dbus.InstallOnSession(_sysInfo)
	if err != nil {
		logger.Error(err)
		_sysInfo = nil
		logger.EndTracing()
		return
	}
}
Пример #7
0
func NewSystemInfo(l *log.Logger) *SystemInfo {
	sys := &SystemInfo{}

	if l == nil {
		l = log.NewLogger("com.deepin.daemon.SystemInfo")
	}
	sys.logger = l

	var err error
	sys.Version, err = getVersionFromDeepin("/etc/deepin-version")
	if err != nil {
		sys.logger.Warning(err)
		sys.Version, err = getVersionFromLsb("/etc/lsb-release")
		if err != nil {
			sys.logger.Error(err)
			return nil
		}
	}

	sys.Processor, err = getCPUInfoFromFile("/proc/cpuinfo")
	if err != nil {
		sys.logger.Error(err)
		return nil
	}

	sys.MemoryCap, err = getMemoryCapFromFile("/proc/meminfo")
	if err != nil {
		sys.logger.Error(err)
		return nil
	}

	sys.SystemType, err = getSystemType()
	if err != nil {
		sys.logger.Error(err)
		return nil
	}

	sys.DiskCap, err = getDiskCap()
	if err != nil {
		sys.logger.Error(err)
		return nil
	}

	return sys
}
Пример #8
0
func runAsDaemon() {
	logger := log.NewLogger(grub2.DbusGrubDest + ".Runner")
	logger.BeginTracing()
	defer logger.EndTracing()

	if !lib.UniqueOnSession(grub2.DbusGrubDest) {
		logger.Error("dbus unique:", grub2.DbusGrubDest)
		return
	}
	grub2.Start()
	dbus.SetAutoDestroyHandler(60*time.Second, func() bool {
		return !grub2.IsUpdating()
	})
	dbus.DealWithUnhandledMessage()
	if err := dbus.Wait(); err != nil {
		logger.Error("lost dbus session:", err)
		os.Exit(1)
	}
}
Пример #9
0
func newLangSelector(l *log.Logger) *LangSelector {
	lang := LangSelector{LocaleState: LocaleStateChanged}

	if l != nil {
		lang.logger = l
	} else {
		lang.logger = log.NewLogger(dbusSender)
	}

	var err error
	lang.lhelper, err = localehelper.NewLocaleHelper(
		"com.deepin.api.LocaleHelper",
		"/com/deepin/api/LocaleHelper")
	if err != nil {
		lang.logger.Warning("New LocaleHelper Failed:", err)
		return nil
	}

	lang.setPropCurrentLocale(getLocale())

	return &lang
}
Пример #10
0
	"time"
)

type Manager struct {
	writeStart bool
	writeEnd   chan bool
}

const (
	DBUS_DEST = "com.deepin.daemon.Search"
	DBUS_PATH = "/com/deepin/daemon/Search"
	DBUS_IFC  = "com.deepin.daemon.Search"
)

var (
	logger = log.NewLogger(DBUS_DEST)
)

func newManager() *Manager {
	m := Manager{}

	m.writeStart = false

	return &m
}

var _manager *Manager

func GetManager() *Manager {
	if _manager == nil {
		_manager = newManager()
Пример #11
0
	C.set_backlight(C.double(v))
}
func (h *BacklightHelper) GetBrightness() float64 {
	h.lock.Lock()
	defer h.lock.Unlock()
	return (float64)(C.get_backlight())
}
func (*BacklightHelper) GetDBusInfo() dbus.DBusInfo {
	return dbus.DBusInfo{
		"com.deepin.daemon.helper.Backlight",
		"/com/deepin/daemon/helper/Backlight",
		"com.deepin.daemon.helper.Backlight",
	}
}

var logger = log.NewLogger("com.deepin.daemon.helper.Backlight")

func main() {
	helper := NewBacklightHelper()
	err := dbus.InstallOnSystem(helper)
	if err != nil {
		logger.Errorf("register dbus interface failed: %v", err)
		os.Exit(1)
	}

	dbus.SetAutoDestroyHandler(time.Second*1, nil)

	dbus.DealWithUnhandledMessage()
	if err := dbus.Wait(); err != nil {
		logger.Errorf("lost dbus session: %v", err)
		os.Exit(1)
Пример #12
0
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 **/

package main

import (
	"flag"
	"os"
	"pkg.linuxdeepin.com/dde-daemon/grub2"
	"pkg.linuxdeepin.com/lib"
	"pkg.linuxdeepin.com/lib/dbus"
	"pkg.linuxdeepin.com/lib/log"
	"time"
)

var logger = log.NewLogger(grub2.DbusGrub2ExtDest + ".Runner")
var argDebug bool

func main() {
	logger.BeginTracing()
	defer logger.EndTracing()

	if !lib.UniqueOnSystem(grub2.DbusGrub2ExtDest) {
		logger.Warning("There already has an Grub2 daemon running.")
		return
	}

	flag.BoolVar(&argDebug, "d", false, "debug mode")
	flag.BoolVar(&argDebug, "debug", false, "debug mode")
	flag.Parse()
	if argDebug {
Пример #13
0
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 **/

package network

import (
	"pkg.linuxdeepin.com/lib/dbus"
	"pkg.linuxdeepin.com/lib/log"
)

var (
	logger  = log.NewLogger(dbusNetworkDest)
	manager *Manager
)

func Start() {
	if manager != nil {
		return
	}

	logger.BeginTracing()

	initSlices() // initialize slice code

	manager = NewManager()
	err := dbus.InstallOnSession(manager)
	if err != nil {
Пример #14
0
import (
	libarea "dbus/com/deepin/api/xmousearea"
	libdsp "dbus/com/deepin/daemon/display"
	"dbus/com/deepin/dde/launcher"
	"pkg.linuxdeepin.com/lib/dbus"
	"pkg.linuxdeepin.com/lib/gio-2.0"
	"pkg.linuxdeepin.com/lib/log"
	"sync"
)

var (
	dspObj    *libdsp.Display
	areaObj   *libarea.XMouseArea
	launchObj *launcher.Launcher
	logger    = log.NewLogger(ZONE_DEST)

	mutex         = new(sync.Mutex)
	edgeActionMap = make(map[string]string)
)
var zoneSettings = func() func() *gio.Settings {
	var initZoneSettings sync.Once
	var _zoneSettings *gio.Settings

	return func() *gio.Settings {
		initZoneSettings.Do(func() {
			_zoneSettings = gio.NewSettings("com.deepin.dde.zone")
		})
		return _zoneSettings
	}
}()
Пример #15
0
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 **/

package bluetooth

import (
	"pkg.linuxdeepin.com/lib/dbus"
	"pkg.linuxdeepin.com/lib/log"
)

var (
	logger    = log.NewLogger(dbusBluetoothDest)
	bluetooth *Bluetooth
)

func Start() {
	if bluetooth != nil {
		return
	}

	logger.BeginTracing()

	bluetooth = NewBluetooth()
	err := dbus.InstallOnSession(bluetooth)
	if err != nil {
		// don't panic or fatal here
		logger.Error("register dbus interface failed: ", err)
Пример #16
0
package main

import (
	"os"
	"pkg.linuxdeepin.com/lib"
	"pkg.linuxdeepin.com/lib/dbus"
	"pkg.linuxdeepin.com/lib/log"
	"time"
)

const (
	DEST = "com.deepin.daemon.Personalization"
)

var (
	Logger = log.NewLogger(DEST)
)

func main() {
	if !lib.UniqueOnSession(DEST) {
		Logger.Warning("There has an set-fonts running...")
		return
	}

	Logger.BeginTracing()
	defer Logger.EndTracing()
	Logger.SetRestartCommand("/usr/lib/deepin-daemon/personalization")

	StartFont()
	dbus.DealWithUnhandledMessage()
Пример #17
0
package screensaver

import (
	"github.com/BurntSushi/xgb/dpms"
	"github.com/BurntSushi/xgb/screensaver"
	"github.com/BurntSushi/xgb/xproto"
	"github.com/BurntSushi/xgbutil"
	"pkg.linuxdeepin.com/lib/dbus"
	"pkg.linuxdeepin.com/lib/log"
	"sync"
)

var logger = log.NewLogger("org.freedesktop.ScreenSaver")

type inhibitor struct {
	cookie uint32
	name   string
	reason string
}
type ScreenSaver struct {
	xu *xgbutil.XUtil

	IdleOn      func()
	CycleActive func()
	IdleOff     func()

	blank        byte
	idleTime     uint32
	idleInterval uint32

	inhibitors  map[uint32]inhibitor
Пример #18
0
package audio

import "pkg.linuxdeepin.com/lib/dbus"
import "pkg.linuxdeepin.com/lib/log"
import "pkg.linuxdeepin.com/lib/pulse"
import libsound "dbus/com/deepin/api/sound"

var logger = log.NewLogger("com.deepin.daemon.Audio")

type Audio struct {
	init bool
	core *pulse.Context

	Sinks         []*Sink
	Sources       []*Source
	SinkInputs    []*SinkInput
	DefaultSink   string
	DefaultSource string

	MaxUIVolume float64

	siEventChan  chan func()
	siPollerExit chan struct{}
}

func (a *Audio) Reset() {
	for _, s := range a.Sinks {
		s.SetVolume(s.BaseVolume, false)
		s.SetBalance(0, false)
		s.SetFade(0)
	}
Пример #19
0
package main

import "pkg.linuxdeepin.com/lib/log"

import "pkg.linuxdeepin.com/lib"
import "pkg.linuxdeepin.com/lib/dbus"
import "os"
import _ "pkg.linuxdeepin.com/dde-daemon/accounts"
import "pkg.linuxdeepin.com/dde-daemon"
import . "pkg.linuxdeepin.com/lib/gettext"

var logger = log.NewLogger("com.deepin.daemon")

func main() {
	logger.BeginTracing()
	defer logger.EndTracing()

	if !lib.UniqueOnSystem("com.deepin.daemon") {
		logger.Warning("There already has an dde-daemon running.")
		return
	}

	InitI18n()
	Textdomain("dde-daemon")

	logger.SetRestartCommand("/usr/lib/deepin-daemon/dde-system-daemon")

	loader.StartAll()
	defer loader.StopAll()

	dbus.DealWithUnhandledMessage()
Пример #20
0
	"pkg.linuxdeepin.com/lib/log"
	"strings"
)

const (
	MPRIS_FILTER_KEY = "org.mpris.MediaPlayer2"
	MPRIS_PATH       = "/org/mpris/MediaPlayer2"
	SEEK_DISTANCE    = int64(5000000) // 5s

	MIME_TYPE_BROWSER = "x-scheme-handler/http"
	MIME_TYPE_EMAIL   = "x-scheme-handler/mailto"
	CALCULATOR_CMD    = "/usr/bin/gnome-calculator"
)

var (
	logger      = log.NewLogger("dde-daemon/mpris")
	dbusObj     *libdbus.DBusDaemon
	mediaKeyObj *libkeybind.MediaKey
	loginObj    *liblogin1.Manager
	prevSender  = ""
)

func getCommandByMimeType(mimeType string) (string, bool) {
	if appInfo := gio.AppInfoGetDefaultForType(mimeType, false); appInfo != nil {
		return appInfo.GetExecutable(), true
	}

	return "", false
}

func getMprisClients() ([]string, bool) {
Пример #21
0
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 **/

package sessionwatcher

import (
	"pkg.linuxdeepin.com/lib/log"
	"time"
)

var (
	logger = log.NewLogger("dde-daemon/sessionwatcher")
)

type Manager struct {
	dock      *Dock
	appelt    *DockApplet
	exitTimer chan struct{}
}

func NewManager() *Manager {
	m := &Manager{}

	m.dock = NewDock()
	m.appelt = NewDockApplet()
	m.exitTimer = make(chan struct{})
Пример #22
0
package dock

import (
	"dbus/com/deepin/api/xmousearea"
	"dbus/com/deepin/daemon/display"
	"github.com/BurntSushi/xgbutil"
	"github.com/BurntSushi/xgbutil/xprop"
	"os"
	"pkg.linuxdeepin.com/lib/dbus"
	"pkg.linuxdeepin.com/lib/log"
	"time"
)

var (
	logger                                     = log.NewLogger("com.deepin.daemon.Dock")
	region              *Region                = nil
	setting             *Setting               = nil
	hideModemanager     *HideStateManager      = nil
	dpy                 *display.Display       = nil
	dockProperty        *DockProperty          = nil
	entryProxyerManager *EntryProxyerManager   = nil
	dockedAppManager    *DockedAppManager      = nil
	areaImp             *xmousearea.XMouseArea = nil
	mouseArea           *XMouseAreaProxyer     = nil
)

func Stop() {
	if dockProperty != nil {
		dockProperty.destroy()
		dockProperty = nil
	}
Пример #23
0
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 **/

package appearance

import (
	"pkg.linuxdeepin.com/lib/dbus"
	"pkg.linuxdeepin.com/lib/log"
)

var (
	logger = log.NewLogger("com.deepin.daemon.Themes")
)

var _manager *Manager

func finalize() {
	logger.EndTracing()
	_manager.destroy()
	_manager = nil
}

func Start() {
	if _manager != nil {
		return
	}
Пример #24
0
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 **/

package grub2

import (
	"pkg.linuxdeepin.com/lib/dbus"
	"pkg.linuxdeepin.com/lib/log"
)

var (
	logger = log.NewLogger(DbusGrubDest)
	grub   *Grub2
)

func Start() {
	logger.BeginTracing()

	grub = NewGrub2()
	err := dbus.InstallOnSession(grub)
	if err != nil {
		logger.Errorf("register dbus interface failed: %v", err)
		return
	}
	err = dbus.InstallOnSession(grub.theme)
	if err != nil {
		logger.Errorf("register dbus interface failed: %v", err)
Пример #25
0
package main

import "io/ioutil"
import "pkg.linuxdeepin.com/lib/dbus"
import log "pkg.linuxdeepin.com/lib/log"
import "os"
import "os/exec"

var logger = log.NewLogger("com.deepin.helper.LanguageSelector")

type LanguageSelector struct {
}

func run_shell_content(code string, argv ...string) {
	f, err := ioutil.TempFile(os.TempDir(), "shell_code")
	if err != nil {
		logger.Warning("can't create temp file: ", err)
		return
	}
	f.Close()
	os.Remove(f.Name())

	ioutil.WriteFile(f.Name(), ([]byte)(code), 0755)
	argv = append([]string{f.Name()}, argv...)
	cmd := exec.Command("/bin/sh", argv...)
	d, err := cmd.Output()
	logger.Info(string(d))
	if err != nil {
		logger.Error("Can't run shell code:", err)
	}
	defer os.Remove(f.Name())
Пример #26
0
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 **/

package keybinding

import (
	"github.com/BurntSushi/xgbutil"
	"github.com/BurntSushi/xgbutil/keybind"
	"github.com/BurntSushi/xgbutil/xevent"
	"pkg.linuxdeepin.com/lib/dbus"
	"pkg.linuxdeepin.com/lib/gio-2.0"
	"pkg.linuxdeepin.com/lib/log"
)

var (
	logger = log.NewLogger("daemon/keybinding")
	X      *xgbutil.XUtil

	grabKeyBindsMap = make(map[KeycodeInfo]string)
	PrevSystemPairs = make(map[string]string)
	PrevCustomPairs = make(map[string]string)

	bindGSettings  *gio.Settings
	sysGSettings   *gio.Settings
	mediaGSettings *gio.Settings
)

func initGSettings() {
	bindGSettings = gio.NewSettings("com.deepin.dde.keybinding")
	sysGSettings = gio.NewSettings("com.deepin.dde.keybinding.system")
	mediaGSettings = gio.NewSettings("com.deepin.dde.keybinding.mediakey")
Пример #27
0
	"database/sql"
	storeApi "dbus/com/deepin/store/api"
	"errors"
	"sync"
	// . "pkg.linuxdeepin.com/dde-daemon/launcher/interfaces"
	. "pkg.linuxdeepin.com/dde-daemon/launcher/category"
	. "pkg.linuxdeepin.com/dde-daemon/launcher/item"
	. "pkg.linuxdeepin.com/dde-daemon/launcher/item/search"
	. "pkg.linuxdeepin.com/dde-daemon/launcher/item/softwarecenter"
	"pkg.linuxdeepin.com/lib/dbus"
	. "pkg.linuxdeepin.com/lib/gettext"
	"pkg.linuxdeepin.com/lib/gio-2.0"
	"pkg.linuxdeepin.com/lib/log"
)

var logger = log.NewLogger("dde-daemon/launcher-daemon")
var launcher *Launcher = nil

func Stop() {
	if launcher == nil {
		return
	}

	launcher.destroy()
	launcher = nil

	logger.EndTracing()
}

func startFailed(err error) {
	logger.Error(err)
Пример #28
0
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 **/

package accounts

import (
	"pkg.linuxdeepin.com/lib/dbus"
	"pkg.linuxdeepin.com/lib/log"
)

var (
	_m     *Manager
	logger = log.NewLogger(dbusSender)
)

func Start() {
	if _m != nil {
		return
	}

	logger.BeginTracing()
	_m = NewManager()
	err := dbus.InstallOnSystem(_m)
	if err != nil {
		logger.Error("Install manager dbus failed:", err)
		if _m.watcher != nil {
			_m.watcher.EndWatch()
			_m.watcher = nil
Пример #29
0
package loader

import (
	"pkg.linuxdeepin.com/lib/log"
)

var logger = log.NewLogger("dde.daemon.loader")

type Module struct {
	Name   string
	Start  func()
	Stop   func()
	Enable bool
}

var modules = make([]*Module, 0)

func getModule(name string) (module *Module) {
	for _, m := range modules {
		if m.Name == name {
			module = m
			break
		}
	}
	if module == nil {
		logger.Warning("target module not found:", name)
	}
	return
}
func isModuleExist(name string) (ok bool) {
	for _, m := range modules {
Пример #30
0
import (
	"math/rand"
	"os"
	"os/exec"
	"path"
	"pkg.linuxdeepin.com/lib/graphic"
	"pkg.linuxdeepin.com/lib/log"
	dutils "pkg.linuxdeepin.com/lib/utils"
	"strings"
	"time"
	"unsafe"
)

var (
	forceFlag = false
	logger    = log.NewLogger("theme-thumb-tool")
)

const (
	_CMD_           = "theme-thumb-tool"
	_GTK_THUMB_CMD_ = "/usr/lib/deepin-daemon/gtk-thumb-tool"

	THUMB_CACHE_DIR = "autogen"
)

func getUserPictureDir() string {
	str := C.get_user_pictures_dir()
	//defer C.free(unsafe.Pointer(str))

	ret := C.GoString(str)