func (m *EntryManager) mustGetEntry(nApp *NormalApp, rApp *RuntimeApp) *AppEntry { if rApp != nil { if e, ok := m.appEntries[rApp.Id]; ok { return e } else { e := NewAppEntryWithRuntimeApp(rApp) m.appEntries[rApp.Id] = e err := dbus.InstallOnSession(e) if err != nil { logger.Warning(err) } return e } } else if nApp != nil { if e, ok := m.appEntries[nApp.Id]; ok { return e } else { e := NewAppEntryWithNormalApp(nApp) m.appEntries[nApp.Id] = e err := dbus.InstallOnSession(e) if err != nil { logger.Warning(err) } return e } } panic("mustGetEntry: at least give one app") }
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 } }
func Start() { if _manager != nil { return } logger.BeginTracing() var err error _manager, err = NewManager() if err != nil { logger.Error("Create Manager failed:", err) logger.EndTracing() return } err = dbus.InstallOnSession(_manager) if err != nil { logger.Error("Install DBus failed:", err) _manager.destroy() _manager = nil logger.EndTracing() return } _manager.handlePropChanged() }
func initTrayManager() { composite.Init(TrayXU.Conn()) composite.QueryVersion(TrayXU.Conn(), 0, 4) damage.Init(TrayXU.Conn()) damage.QueryVersion(TrayXU.Conn(), 1, 1) xfixes.Init(TrayXU.Conn()) xfixes.QueryVersion(TrayXU.Conn(), 5, 0) visualId := findRGBAVisualID() TRAYMANAGER = &TrayManager{ owner: 0, visual: visualId, nameInfo: make(map[xproto.Window]string), notifyInfo: make(map[xproto.Window]bool), md5Info: make(map[xproto.Window][]byte), dmageInfo: make(map[xproto.Window]damage.Damage), } TRAYMANAGER.Manage() dbus.InstallOnSession(TRAYMANAGER) xfixes.SelectSelectionInput( TrayXU.Conn(), TrayXU.RootWin(), _NET_SYSTEM_TRAY_S0, xfixes.SelectionEventMaskSelectionClientClose, ) go TRAYMANAGER.startListener() }
func main() { if !lib.UniqueOnSession(DBUS_DEST) { logger.Warning("There is an Search running") return } logger.BeginTracing() defer logger.EndTracing() logger.SetRestartCommand("/usr/lib/deepin-daemon/search") if err := dbus.InstallOnSession(GetManager()); err != nil { logger.Fatal("Search Install DBus Failed:", err) return } dbus.DealWithUnhandledMessage() dbus.SetAutoDestroyHandler(time.Second*5, func() bool { if GetManager().writeStart { select { case <-GetManager().writeEnd: return true } } return true }) if err := dbus.Wait(); err != nil { logger.Warning("Search lost dbus:", err) os.Exit(-1) } else { os.Exit(0) } }
func Start() { if _m != nil { return } logger.BeginTracing() err := initDBusIFC() if err != nil { logger.Error("Create dbus interface failed:", err) logger.EndTracing() return } _m = newManager() err = dbus.InstallOnSession(_m) if err != nil { logger.Error("Install Zone Session Failed: ", err) finalize() return } _m.SetTopLeft(_m.TopLeftAction()) _m.SetBottomLeft(_m.BottomLeftAction()) _m.SetTopRight(_m.TopRightAction()) _m.SetBottomRight(_m.BottomRightAction()) }
func (m *Manager) rebuildThemes() { m.lock.Lock() defer m.lock.Unlock() m.destroyThemes() var curThemeValid bool for _, name := range m.ThemeList { info, err := m.dtheme.GetInfoByName(path.Base(name)) if err != nil { continue } t := NewTheme(info, m.applyTheme) err = dbus.InstallOnSession(t) if err != nil { logger.Warning("Install dbus failed:", info, err) continue } m.themeObjMap[info.BaseName] = t if info.BaseName == m.CurrentTheme.Get() { curThemeValid = true m.applyTheme(info.BaseName) } } if !curThemeValid { m.applyTheme(defaultDThemeId) } }
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 }
func (a *Audio) addSinkInput(idx uint32) { for _, si := range a.SinkInputs { if si.index == idx { return } } core, err := a.core.GetSinkInput(idx) if err != nil { logger.Warning(err) return } if filterSinkInput(core) { return } si := NewSinkInput(core) err = dbus.InstallOnSession(si) if err != nil { logger.Error(err) return } a.SinkInputs = append(a.SinkInputs, si) dbus.NotifyChange(a, "SinkInputs") }
func Start() { if power != nil { return } logger.BeginTracing() err := initializeLibs() if err != nil { logger.Error(err) logger.EndTracing() return } err = dbus.InstallOnSession(power) if err != nil { logger.Error("Failed InstallOnSession:", err) finalizeLibs() logger.EndTracing() return } workaround = newFullScreenWorkaround() go workaround.start() }
func (m *EntryProxyerManager) registerEntry(name string) { if !isEntryNameValid(name) { return } logger.Debugf("register entry: %s", name) entryId, ok := getEntryId(name) if !ok { return } logger.Debugf("register entry id: %s", entryId) entry, err := NewEntryProxyer(entryId) if err != nil { logger.Warningf("register entry failed: %v", err) return } err = dbus.InstallOnSession(entry) if err != nil { logger.Warningf("register entry failed: %v", err) return } m.Entries = append(m.Entries, entry) dbus.Emit(m, "Added", dbus.ObjectPath(entry.GetDBusInfo().ObjectPath)) logger.Infof("register entry success: %s", name) }
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) return } // initialize grub2 after dbus service installed to ensure // property changing signal send successful grub.initGrub2() }
func (s *Audio) setPropSinkInputs(v []*SinkInput) { for _, o := range s.SinkInputs { dbus.UnInstallObject(o) } for _, o := range v { dbus.InstallOnSession(o) } s.SinkInputs = v dbus.NotifyChange(s, "SinkInputs") }
func (s *Audio) setPropSources(v []*Source) { for _, o := range s.Sources { dbus.UnInstallObject(o) } for _, o := range v { dbus.InstallOnSession(o) } s.Sources = v dbus.NotifyChange(s, "Sources") }
func startMediaMount() error { _media = NewMediaMount() if _media == nil { return fmt.Errorf("Create MediaMount Failed") } err := dbus.InstallOnSession(_media) if err != nil { return err } return nil }
func (m *Manager) addConnectionSession(session *ConnectionSession) { m.connectionSessionsLock.Lock() defer m.connectionSessionsLock.Unlock() // install dbus session err := dbus.InstallOnSession(session) if err != nil { logger.Error(err) return } m.connectionSessions = append(m.connectionSessions, session) }
func Start() { if _manager != nil { return } logger.BeginTracing() initGSettings() err := StartKeyBinding() if err != nil { logger.Error("failed start keybinding:", err) logger.EndTracing() finiGSettings() return } _manager = newManager() if _manager == nil { logger.Error("Create keybinding manager failed") finiGSettings() endKeyBinding() return } err = dbus.InstallOnSession(_manager) if err != nil { logger.Error("Install DBus Failed:", err) finalize() return } err = dbus.InstallOnSession(_manager.mediaKey) if err != nil { logger.Error("Install DBus Failed:", err) finalize() return } go xevent.Main(X) }
func startDefaultApps() error { _dapp = NewDefaultApps() if _dapp == nil { return fmt.Errorf("Create DefaultApps Failed") } err := dbus.InstallOnSession(_dapp) if err != nil { return err } return nil }
func (s *Source) GetMeter() *Meter { id := fmt.Sprintf("source%d", s.core.Index) m, ok := meters[id] if !ok { core := pulse.NewSourceMeter(pulse.GetContext(), s.core.Index) core.ConnectChanged(func(v float64) { m.setPropVolume(v) }) m = NewMeter(id, core) dbus.InstallOnSession(m) meters[id] = m } return m }
func Start() { if _ssaver != nil { return } _ssaver = NewScreenSaver() err := dbus.InstallOnSession(_ssaver) if err != nil { _ssaver.destroy() _ssaver = nil return } }
func Start() { if _audio != nil { return } logger.BeginTracing() ctx := pulse.GetContext() _audio = NewAudio(ctx) if err := dbus.InstallOnSession(_audio); err != nil { logger.Error("Failed InstallOnSession:", err) finalize() return } }
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 } }
func Start() { if _manager != nil { return } _manager = NewManager() _manager.logger.BeginTracing() err := dbus.InstallOnSession(_manager) if err != nil { _manager.logger.Error("Install mounts dbus failed:", err) _manager.destroy() _manager = nil return } _manager.listenDiskChanged() go _manager.refrashDiskInfos() }
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) bluetooth = nil return } // initialize bluetooth after dbus interface installed bluetooth.initBluetooth() }
func Start() { if _manager != nil { return } logger.BeginTracing() _manager = NewManager() if _manager == nil { logger.Error("New Manager Failed") logger.EndTracing() return } err := dbus.InstallOnSession(_manager) if err != nil { logger.Error(err) finalize() return } }
func Start() { if manager != nil { return } logger.BeginTracing() initSlices() // initialize slice code manager = NewManager() err := dbus.InstallOnSession(manager) if err != nil { logger.Error("register dbus interface failed: ", err) manager = nil return } // initialize manager after dbus installed manager.initManager() initDbusDaemon() watchNetworkManagerRestart(manager) }
func Start() { if launcher != nil { return } var err error logger.BeginTracing() InitI18n() // DesktopAppInfo.ShouldShow does not know deepin. gio.DesktopAppInfoSetDesktopEnv("Deepin") soft, err := NewSoftwareCenter() if err != nil { startFailed(err) return } im := NewItemManager(soft) cm := NewCategoryManager() timeInfo, _ := im.GetAllTimeInstalled() appChan := make(chan *gio.AppInfo) go func() { allApps := gio.AppInfoGetAll() for _, app := range allApps { appChan <- app } close(appChan) }() dbPath, _ := GetDBPath(SoftwareCenterDataDir, CategoryNameDBPath) db, err := sql.Open("sqlite3", dbPath) var wg sync.WaitGroup const N = 20 wg.Add(N) for i := 0; i < N; i++ { go func() { for app := range appChan { if !app.ShouldShow() { app.Unref() continue } desktopApp := gio.ToDesktopAppInfo(app) item := NewItem(desktopApp) cid, err := QueryCategoryId(desktopApp, db) if err != nil { item.SetCategoryId(OtherID) } item.SetCategoryId(cid) item.SetTimeInstalled(timeInfo[item.Id()]) im.AddItem(item) cm.AddItem(item.Id(), item.GetCategoryId()) app.Unref() } wg.Done() }() } wg.Wait() if err == nil { db.Close() } launcher = NewLauncher() launcher.setItemManager(im) launcher.setCategoryManager(cm) store, err := storeApi.NewDStoreDesktop("com.deepin.store.Api", "/com/deepin/store/Api") if err == nil { launcher.setStoreApi(store) } names := []string{} for _, item := range im.GetAllItems() { names = append(names, item.Name()) } pinyinObj, err := NewPinYinSearchAdapter(names) launcher.setPinYinObject(pinyinObj) launcher.listenItemChanged() err = dbus.InstallOnSession(launcher) if err != nil { startFailed(err) return } coreSetting := gio.NewSettings("com.deepin.dde.launcher") if coreSetting == nil { startFailed(errors.New("get schema failed")) return } setting, err := NewSetting(coreSetting) if err != nil { startFailed(err) return } err = dbus.InstallOnSession(setting) if err != nil { startFailed(err) return } launcher.setSetting(setting) }
func Start() { if dockProperty != nil { return } logger.BeginTracing() initDeepin() if logger.GetLogLevel() == log.LevelDebug { os.Setenv("G_MESSAGES_DEBUG", "all") } if !initDisplay() { Stop() return } var err error XU, err = xgbutil.NewConn() if err != nil { startFailed(err) return } TrayXU, err = xgbutil.NewConn() if err != nil { startFailed(err) return } initAtom() dockProperty = NewDockProperty() err = dbus.InstallOnSession(dockProperty) if err != nil { startFailed("register dbus interface failed:", err) return } entryProxyerManager = NewEntryProxyerManager() err = dbus.InstallOnSession(entryProxyerManager) if err != nil { startFailed("register dbus interface failed:", err) return } entryProxyerManager.watchEntries() dockedAppManager = NewDockedAppManager() err = dbus.InstallOnSession(dockedAppManager) if err != nil { startFailed("register dbus interface failed:", err) return } setting = NewSetting() if setting == nil { startFailed("get setting failed") } err = dbus.InstallOnSession(setting) if err != nil { startFailed("register dbus interface failed:", err) return } dockProperty.updateDockHeight(DisplayModeType(setting.GetDisplayMode())) hideModemanager = NewHideStateManager(HideModeType(setting.GetHideMode())) err = dbus.InstallOnSession(hideModemanager) if err != nil { startFailed("register dbus interface failed:", err) return } hideModemanager.UpdateState() clientManager := NewClientManager() err = dbus.InstallOnSession(clientManager) if err != nil { startFailed("register dbus interface failed:", err) return } go clientManager.listenRootWindow() region = NewRegion() err = dbus.InstallOnSession(region) if err != nil { startFailed("register dbus interface failed:", err) return } areaImp, err = xmousearea.NewXMouseArea( "com.deepin.api.XMouseArea", "/com/deepin/api/XMouseArea", ) mouseArea, err = NewXMouseAreaProxyer(areaImp, err) if err != nil { startFailed("register xmouse area failed:", err) return } err = dbus.InstallOnSession(mouseArea) if err != nil { startFailed(err) return } dbus.Emit(mouseArea, "InvalidId") mouseArea.connectMotionInto(func(_, _ int32, id string) { if mouseAreaTimer != nil { mouseAreaTimer.Stop() mouseAreaTimer = nil } mouseAreaTimer = time.AfterFunc(TOGGLE_HIDE_TIME, func() { logger.Info("MouseIn:", id) mouseAreaTimer = nil hideModemanager.UpdateState() }) }) mouseArea.connectMotionOut(func(_, _ int32, id string) { if mouseAreaTimer != nil { mouseAreaTimer.Stop() mouseAreaTimer = nil } logger.Info("MouseOut:", id) hideModemanager.UpdateState() }) initialize() }
func StartFont() { if err := dbus.InstallOnSession(GetFontSettings()); err != nil { Logger.Fatal("Install DBus Failed:", err) return } }