代码拉取完成,页面将自动刷新
同步操作将从 tupelo-shen/mysnapd 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
// -*- Mode: Go; indent-tabs-mode: t -*-
/*
* Copyright (C) 2017 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* 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 userd
import (
"fmt"
"github.com/godbus/dbus"
"github.com/godbus/dbus/introspect"
"gopkg.in/tomb.v2"
"gitee.com/mysnapcore/mysnapd/dbusutil"
"gitee.com/mysnapcore/mysnapd/logger"
)
type dbusInterface interface {
Interface() string
ObjectPath() dbus.ObjectPath
IntrospectionData() string
}
type Userd struct {
tomb tomb.Tomb
conn *dbus.Conn
dbusIfaces []dbusInterface
}
// userdBusNames contains the list of bus names userd will acquire on
// the session bus. It is unnecessary (and undesirable) to add more
// names here when adding new interfaces to the daemon.
var userdBusNames = []string{
"io.snapcraft.Launcher",
"io.snapcraft.Settings",
}
func (ud *Userd) Init() error {
var err error
ud.conn, err = dbusutil.SessionBusPrivate()
if err != nil {
return err
}
ud.dbusIfaces = []dbusInterface{
&Launcher{ud.conn},
&PrivilegedDesktopLauncher{ud.conn},
&Settings{ud.conn},
}
for _, iface := range ud.dbusIfaces {
// export the interfaces at the godbus API level first to avoid
// the race between being able to handle a call to an interface
// at the object level and the actual well-known object name
// becoming available on the bus
xml := "<node>" + iface.IntrospectionData() + introspect.IntrospectDataString + "</node>"
ud.conn.Export(iface, iface.ObjectPath(), iface.Interface())
ud.conn.Export(introspect.Introspectable(xml), iface.ObjectPath(), "org.freedesktop.DBus.Introspectable")
}
for _, name := range userdBusNames {
// beyond this point the name is available and all handlers must
// have been set up
reply, err := ud.conn.RequestName(name, dbus.NameFlagDoNotQueue)
if err != nil {
return err
}
if reply != dbus.RequestNameReplyPrimaryOwner {
return fmt.Errorf("cannot obtain bus name '%s'", name)
}
}
return nil
}
func (ud *Userd) Start() {
logger.Noticef("Starting snap userd")
ud.tomb.Go(func() error {
// Listen to keep our thread up and running. All DBus bits
// are running in the background
<-ud.tomb.Dying()
ud.conn.Close()
err := ud.tomb.Err()
if err != nil && err != tomb.ErrStillAlive {
return err
}
return nil
})
}
func (ud *Userd) Stop() error {
ud.tomb.Kill(nil)
return ud.tomb.Wait()
}
func (ud *Userd) Dying() <-chan struct{} {
return ud.tomb.Dying()
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。