import dbus
try:
import telepathy as _telepathy
+ import util.tp_utils as telepathy_utils
telepathy = _telepathy
except ImportError:
- _telepathy = None
+ telepathy = None
-import constants
-import util.tp_utils as telepathy_utils
import util.misc as misc_utils
_moduleLogger = logging.getLogger(__name__)
+class _FakeSignaller(object):
+
+ def start(self):
+ pass
+
+ def stop(self):
+ pass
+
+
class _MissedCallWatcher(QtCore.QObject):
callMissed = QtCore.pyqtSignal()
def __init__(self):
QtCore.QObject.__init__(self)
self._isStarted = False
+ self._isSupported = True
self._newChannelSignaller = telepathy_utils.NewChannelSignaller(self._on_new_channel)
self._outstandingRequests = []
+ @property
+ def isSupported(self):
+ return self._isSupported
+
def start(self):
- self._newChannelSignaller.start()
+ try:
+ self._newChannelSignaller.start()
+ except RuntimeError:
+ _moduleLogger.exception("Missed call detection not supported")
+ self._newChannelSignaller = _FakeSignaller()
+ self._isSupported = False
self._isStarted = True
def stop(self):
if channelType != telepathy.interfaces.CHANNEL_TYPE_STREAMED_MEDIA:
return
- cmName = telepathy_utils.cm_from_path(connObjectPath)
- if cmName == constants._telepathy_implementation_name_:
- _moduleLogger.debug("Ignoring channels from self to prevent deadlock")
- return
-
conn = telepathy.client.Connection(serviceName, connObjectPath)
try:
chan = telepathy.client.Channel(serviceName, channelObjectPath)
QtCore.QObject.__init__(self)
self._isStarted = False
+ @property
+ def isSupported(self):
+ return False
+
def start(self):
self._isStarted = True
import constants
import alarm_handler
+import call_handler
from util import qtpie
from util import qwrappers
from util import qui_utils
self._session.draft.recipientsChanged.connect(self._on_recipients_changed)
self._session.newMessages.connect(self._on_new_message_alert)
self._app.alarmHandler.applicationNotifySignal.connect(self._on_app_alert)
+ self._voicemailRefreshDelay = QtCore.QTimer()
+ self._voicemailRefreshDelay.setInterval(30 * 1000)
+ self._voicemailRefreshDelay.timeout.connect(self._on_call_missed)
+ self._voicemailRefreshDelay.setSingleShot(True)
+ self._callHandler = call_handler.MissedCallWatcher()
+ self._callHandler.callMissed.connect(self._voicemailRefreshDelay.start)
+
self._defaultCredentials = "", ""
self._curentCredentials = "", ""
self._currentTab = 0
else:
self._app.ledHandler.on()
+ @QtCore.pyqtSlot()
+ @misc_utils.log_exception(_moduleLogger)
+ def _on_call_missed(self):
+ with qui_utils.notify_error(self._errorLog):
+ self._session.update_messages(self._session.MESSAGE_VOICEMAILS, force=True)
+
@QtCore.pyqtSlot(str)
@misc_utils.log_exception(_moduleLogger)
def _on_session_error(self, message):
for tab in self._tabsContents:
tab.enable()
self._initialize_tab(self._currentTab)
+ self._callHandler.start()
@QtCore.pyqtSlot()
@misc_utils.log_exception(_moduleLogger)
with qui_utils.notify_error(self._errorLog):
for tab in self._tabsContents:
tab.disable()
+ self._callHandler.stop()
@QtCore.pyqtSlot()
@misc_utils.log_exception(_moduleLogger)
if e.errno != 17:
raise
- try:
- import gobject
- gobject.threads_init()
- except ImportError:
- pass
-
logFormat = '(%(relativeCreated)5d) %(levelname)-5s %(threadName)s.%(name)s.%(funcName)s: %(message)s'
logging.basicConfig(level=logging.DEBUG, format=logFormat)
rotating = logging.handlers.RotatingFileHandler(constants._user_logpath_, maxBytes=512*1024, backupCount=1)
_moduleLogger.info("Kernel: %s (%s) for %s" % os.uname()[2:])
_moduleLogger.info("Hostname: %s" % os.uname()[1])
+ try:
+ import gobject
+ gobject.threads_init()
+ except ImportError:
+ _moduleLogger.info("GObject support not available")
+ try:
+ import dbus
+ try:
+ from dbus.mainloop.qt import DBusQtMainLoop
+ DBusQtMainLoop(set_as_default=True)
+ _moduleLogger.info("Using Qt mainloop")
+ except ImportError:
+ try:
+ from dbus.mainloop.glib import DBusGMainLoop
+ DBusGMainLoop(set_as_default=True)
+ _moduleLogger.info("Using GObject mainloop")
+ except ImportError:
+ _moduleLogger.info("Mainloop not available")
+ except ImportError:
+ _moduleLogger.info("DBus support not available")
+
app = QtGui.QApplication([])
handle = Dialcentral(app)
qtpie.init_pies()