Use dbus-launch with the --exit-with-session. dbus not exiting still not fully solved.

This commit is contained in:
Marco Pesenti Gritti 2006-08-12 01:29:55 +02:00
parent c5fb39875c
commit fc1aefc72c
4 changed files with 21 additions and 18 deletions

View File

@ -212,7 +212,7 @@ class PresenceServiceDBusHelper(dbus.service.Object):
in_signature="o", out_signature="")
def unregisterService(self, service_op):
found_serv = None
serv = self._parent.get_services()
services = self._parent.get_services()
for serv in services:
if serv.object_path() == service_op:
found_serv = serv
@ -688,12 +688,13 @@ class PresenceService(object):
if stype in self._registered_service_types:
self._registered_service_types.remove(stype)
def main():
loop = gobject.MainLoop()
ps = PresenceService()
loop.run()
try:
loop.run()
except KeyboardInterrupt:
print 'Ctrl+C pressed, exiting...'
if __name__ == "__main__":
main()

View File

@ -2,6 +2,8 @@ import os
import gtk
import gobject
import time
import re
import dbus
import dbus.dbus_bindings
@ -13,7 +15,7 @@ import sugar.env
class DbusProcess(Process):
def __init__(self):
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)
def get_name(self):
@ -22,8 +24,8 @@ class DbusProcess(Process):
def start(self):
Process.start(self, True)
dbus_file = os.fdopen(self._stdout)
addr = dbus_file.readline()
addr = addr.strip()
regexp = re.compile('DBUS_SESSION_BUS_ADDRESS=\'(.*)\'\;')
addr = regexp.match(dbus_file.readline()).group(1)
dbus_file.close()
os.environ["DBUS_SESSION_BUS_ADDRESS"] = addr

View File

@ -1,14 +1,10 @@
#!/usr/bin/python
import logging
import sugar.env
from PresenceService import PresenceService
import sugar.logger
# FIXME this looks like duplicated
level = sugar.env.get_logging_level()
if level == 'debug':
logging.basicConfig(level=logging.DEBUG,
format='%(levelname)s %(message)s')
sugar.logger.start('PresenceService')
logging.info('Starting presence service')

View File

@ -72,6 +72,8 @@ class Activity(gtk.Window):
def __init__(self):
gtk.Window.__init__(self)
self.connect('destroy', self.__destroy_cb)
self._shared = False
self._activity_id = None
self._default_type = None
@ -89,11 +91,6 @@ class Activity(gtk.Window):
self._bus = ActivityDbusService(bus_name, get_object_path(xid))
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):
"""Set the activity default type.
@ -145,3 +142,10 @@ class Activity(gtk.Window):
def execute(self, command, args):
"""Execute the given command with args"""
pass
def __destroy_cb(self, window):
if self._bus:
del self._bus
self._bus = None
if self._service:
self._pservice.unregister_service(self._service)