Use dbus-launch with the --exit-with-session. dbus not exiting still not fully solved.
This commit is contained in:
parent
c5fb39875c
commit
fc1aefc72c
@ -212,7 +212,7 @@ class PresenceServiceDBusHelper(dbus.service.Object):
|
|||||||
in_signature="o", out_signature="")
|
in_signature="o", out_signature="")
|
||||||
def unregisterService(self, service_op):
|
def unregisterService(self, service_op):
|
||||||
found_serv = None
|
found_serv = None
|
||||||
serv = self._parent.get_services()
|
services = self._parent.get_services()
|
||||||
for serv in services:
|
for serv in services:
|
||||||
if serv.object_path() == service_op:
|
if serv.object_path() == service_op:
|
||||||
found_serv = serv
|
found_serv = serv
|
||||||
@ -688,12 +688,13 @@ class PresenceService(object):
|
|||||||
if stype in self._registered_service_types:
|
if stype in self._registered_service_types:
|
||||||
self._registered_service_types.remove(stype)
|
self._registered_service_types.remove(stype)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
loop = gobject.MainLoop()
|
loop = gobject.MainLoop()
|
||||||
ps = PresenceService()
|
ps = PresenceService()
|
||||||
|
try:
|
||||||
loop.run()
|
loop.run()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print 'Ctrl+C pressed, exiting...'
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
@ -2,6 +2,8 @@ import os
|
|||||||
import gtk
|
import gtk
|
||||||
import gobject
|
import gobject
|
||||||
import time
|
import time
|
||||||
|
import re
|
||||||
|
|
||||||
import dbus
|
import dbus
|
||||||
import dbus.dbus_bindings
|
import dbus.dbus_bindings
|
||||||
|
|
||||||
@ -13,7 +15,7 @@ import sugar.env
|
|||||||
class DbusProcess(Process):
|
class DbusProcess(Process):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
config = sugar.env.get_dbus_config()
|
config = sugar.env.get_dbus_config()
|
||||||
cmd = "dbus-daemon --print-address --config-file %s" % config
|
cmd = "dbus-launch --exit-with-session --config-file %s" % config
|
||||||
Process.__init__(self, cmd)
|
Process.__init__(self, cmd)
|
||||||
|
|
||||||
def get_name(self):
|
def get_name(self):
|
||||||
@ -22,8 +24,8 @@ class DbusProcess(Process):
|
|||||||
def start(self):
|
def start(self):
|
||||||
Process.start(self, True)
|
Process.start(self, True)
|
||||||
dbus_file = os.fdopen(self._stdout)
|
dbus_file = os.fdopen(self._stdout)
|
||||||
addr = dbus_file.readline()
|
regexp = re.compile('DBUS_SESSION_BUS_ADDRESS=\'(.*)\'\;')
|
||||||
addr = addr.strip()
|
addr = regexp.match(dbus_file.readline()).group(1)
|
||||||
dbus_file.close()
|
dbus_file.close()
|
||||||
os.environ["DBUS_SESSION_BUS_ADDRESS"] = addr
|
os.environ["DBUS_SESSION_BUS_ADDRESS"] = addr
|
||||||
|
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import sugar.env
|
|
||||||
from PresenceService import PresenceService
|
from PresenceService import PresenceService
|
||||||
|
import sugar.logger
|
||||||
|
|
||||||
# FIXME this looks like duplicated
|
sugar.logger.start('PresenceService')
|
||||||
level = sugar.env.get_logging_level()
|
|
||||||
if level == 'debug':
|
|
||||||
logging.basicConfig(level=logging.DEBUG,
|
|
||||||
format='%(levelname)s %(message)s')
|
|
||||||
|
|
||||||
logging.info('Starting presence service')
|
logging.info('Starting presence service')
|
||||||
|
|
||||||
|
@ -72,6 +72,8 @@ class Activity(gtk.Window):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
gtk.Window.__init__(self)
|
gtk.Window.__init__(self)
|
||||||
|
|
||||||
|
self.connect('destroy', self.__destroy_cb)
|
||||||
|
|
||||||
self._shared = False
|
self._shared = False
|
||||||
self._activity_id = None
|
self._activity_id = None
|
||||||
self._default_type = None
|
self._default_type = None
|
||||||
@ -89,11 +91,6 @@ class Activity(gtk.Window):
|
|||||||
self._bus = ActivityDbusService(bus_name, get_object_path(xid))
|
self._bus = ActivityDbusService(bus_name, get_object_path(xid))
|
||||||
self._bus.start(self._pservice, self)
|
self._bus.start(self._pservice, self)
|
||||||
|
|
||||||
def __del__(self):
|
|
||||||
if self._bus:
|
|
||||||
del self._bus
|
|
||||||
self._bus = None
|
|
||||||
|
|
||||||
def set_default_type(self, default_type):
|
def set_default_type(self, default_type):
|
||||||
"""Set the activity default type.
|
"""Set the activity default type.
|
||||||
|
|
||||||
@ -145,3 +142,10 @@ class Activity(gtk.Window):
|
|||||||
def execute(self, command, args):
|
def execute(self, command, args):
|
||||||
"""Execute the given command with args"""
|
"""Execute the given command with args"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def __destroy_cb(self, window):
|
||||||
|
if self._bus:
|
||||||
|
del self._bus
|
||||||
|
self._bus = None
|
||||||
|
if self._service:
|
||||||
|
self._pservice.unregister_service(self._service)
|
||||||
|
Loading…
Reference in New Issue
Block a user