X-Git-Url: http://git.maemo.org/git/?p=theonering;a=blobdiff_plain;f=src%2Ftelepathy-theonering;h=baf7dae0a80f601167d66a10a28d63bee8ac30bb;hp=33decda1d9bf359ce3fe1e0f29ec464dcdae4b53;hb=7f6c18e15e7a157208a9523a3d14f07c9a0b7f72;hpb=c1299d00ddbb17aa0bf8826f9f6e98d0a756c16f diff --git a/src/telepathy-theonering b/src/telepathy-theonering index 33decda..baf7dae 100755 --- a/src/telepathy-theonering +++ b/src/telepathy-theonering @@ -1,80 +1,11 @@ -#!/usr/bin/env python +#!/usr/bin/python -""" -Telepathy-TheOneRing - Telepathy plugin for GoogleVoice -Copyright (C) 2009 Ed Page eopage AT byu DOT net - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library 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 -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -""" - -import os import sys -import signal -import logging -import gobject - -import dbus.glib -import telepathy.utils as telepathy_utils - -import util.linux as linux_utils -import util.go_utils as gobject_utils -import constants -import connection_manager - - -IDLE_TIMEOUT = 5000 - - -def run_theonering(): - linux_utils.set_process_name(constants.__app_name__) - - @gobject_utils.async - def quit(): - manager.quit() - mainloop.quit() - - def timeout_cb(): - if len(manager._connections) == 0: - logging.info('No connection received - quitting') - quit() - return False - - if 'THEONERING_PERSIST' not in os.environ: - gobject.timeout_add(IDLE_TIMEOUT, timeout_cb) - shutdown_callback = quit - else: - shutdown_callback = None - - signal.signal(signal.SIGTERM, quit) - - try: - manager = connection_manager.TheOneRingConnectionManager(shutdown_func=shutdown_callback) - except dbus.exceptions.NameExistsException: - logging.warning('Failed to acquire bus name, connection manager already running?') - sys.exit(1) +sys.path.insert(0, "/usr/lib/theonering") - mainloop = gobject.MainLoop(is_running=True) - while mainloop.is_running(): - try: - mainloop.run() - except KeyboardInterrupt: - quit() +import theonering -if __name__ == '__main__': - telepathy_utils.debug_divert_messages(os.getenv('THEONERING_LOGFILE')) - logging.basicConfig(level=logging.DEBUG) - run_theonering() +if __name__ == "__main__": + theonering.main(logToFile=True)