4 from __future__ import with_statement
11 import logging.handlers
13 import util.qt_compat as qt_compat
14 QtCore = qt_compat.QtCore
15 QtGui = qt_compat.import_module("QtGui")
19 from util import qtpie
20 from util import qwrappers
21 from util import qui_utils
22 from util import misc as misc_utils
27 _moduleLogger = logging.getLogger(__name__)
30 class Dialcentral(qwrappers.ApplicationWrapper):
33 os.path.join(os.path.dirname(__file__), "../share"),
34 os.path.join(os.path.dirname(__file__), "../data"),
37 def __init__(self, app):
39 self._aboutDialog = None
40 self.notifyOnMissed = False
41 self.notifyOnVoicemail = False
42 self.notifyOnSms = False
44 self._streamHandler = None
45 self._ledHandler = None
46 self._alarmHandler = alarm_handler.AlarmHandler()
48 qwrappers.ApplicationWrapper.__init__(self, app, constants)
50 def load_settings(self):
52 config = ConfigParser.SafeConfigParser()
53 config.read(constants._user_settings_)
55 _moduleLogger.info("No settings")
58 _moduleLogger.info("Settings were corrupt")
60 except ConfigParser.MissingSectionHeaderError:
61 _moduleLogger.info("Settings were corrupt")
64 _moduleLogger.exception("Unknown loading error")
66 self._mainWindow.load_settings(config)
68 def save_settings(self):
69 _moduleLogger.info("Saving settings")
70 config = ConfigParser.SafeConfigParser()
72 self._mainWindow.save_settings(config)
74 with open(constants._user_settings_, "wb") as configFile:
75 config.write(configFile)
77 def get_icon(self, name):
78 if self._dataPath is None:
79 for path in self._DATA_PATHS:
80 if os.path.exists(os.path.join(path, name)):
83 if self._dataPath is not None:
84 icon = QtGui.QIcon(os.path.join(self._dataPath, name))
89 def get_resource(self, name):
90 if self._dataPath is None:
91 for path in self._DATA_PATHS:
92 if os.path.exists(os.path.join(path, name)):
95 if self._dataPath is not None:
96 return os.path.join(self._dataPath, name)
100 def _close_windows(self):
101 qwrappers.ApplicationWrapper._close_windows(self)
102 if self._aboutDialog is not None:
103 self._aboutDialog.close()
106 def fsContactsPath(self):
107 return os.path.join(constants._data_path_, "contacts")
110 def streamHandler(self):
111 if self._streamHandler is None:
112 import stream_handler
113 self._streamHandler = stream_handler.StreamHandler()
114 return self._streamHandler
117 def alarmHandler(self):
118 return self._alarmHandler
121 def ledHandler(self):
122 if self._ledHandler is None:
124 self._ledHandler = led_handler.LedHandler()
125 return self._ledHandler
127 def _new_main_window(self):
128 return MainWindow(None, self)
131 @qt_compat.Slot(bool)
132 @misc_utils.log_exception(_moduleLogger)
133 def _on_about(self, checked = True):
134 with qui_utils.notify_error(self._errorLog):
135 if self._aboutDialog is None:
137 self._aboutDialog = dialogs.AboutDialog(self)
138 response = self._aboutDialog.run(self._mainWindow.window)
141 class DelayedWidget(object):
143 def __init__(self, app, settingsNames):
144 self._layout = QtGui.QVBoxLayout()
145 self._layout.setContentsMargins(0, 0, 0, 0)
146 self._widget = QtGui.QWidget()
147 self._widget.setContentsMargins(0, 0, 0, 0)
148 self._widget.setLayout(self._layout)
149 self._settings = dict((name, "") for name in settingsNames)
152 self._isEnabled = True
159 return self._child is not None
161 def set_child(self, child):
162 if self._child is not None:
163 self._layout.removeWidget(self._child.toplevel)
165 if self._child is not None:
166 self._layout.addWidget(self._child.toplevel)
168 self._child.set_settings(self._settings)
173 self._child.disable()
180 self._isEnabled = True
181 if self._child is not None:
185 self._isEnabled = False
186 if self._child is not None:
187 self._child.disable()
190 if self._child is not None:
193 def refresh(self, force=True):
194 if self._child is not None:
195 self._child.refresh(force)
197 def get_settings(self):
198 if self._child is not None:
199 return self._child.get_settings()
201 return self._settings
203 def set_settings(self, settings):
204 if self._child is not None:
205 self._child.set_settings(settings)
207 self._settings = settings
210 def _tab_factory(tab, app, session, errorLog):
212 return gv_views.__dict__[tab](app, session, errorLog)
215 class MainWindow(qwrappers.WindowWrapper):
229 assert len(_TAB_TITLES) == MAX_TABS
237 assert len(_TAB_ICONS) == MAX_TABS
240 functools.partial(_tab_factory, "Dialpad"),
241 functools.partial(_tab_factory, "History"),
242 functools.partial(_tab_factory, "Messages"),
243 functools.partial(_tab_factory, "Contacts"),
245 assert len(_TAB_CLASS) == MAX_TABS
247 # Hack to allow delay importing/loading of tabs
248 _TAB_SETTINGS_NAMES = [
252 ("selectedAddressbook", ),
254 assert len(_TAB_SETTINGS_NAMES) == MAX_TABS
256 def __init__(self, parent, app):
257 qwrappers.WindowWrapper.__init__(self, parent, app)
258 self._window.setWindowTitle("%s" % constants.__pretty_app_name__)
259 self._window.resized.connect(self._on_window_resized)
260 self._errorLog = self._app.errorLog
262 self._session = session.Session(self._errorLog, constants._data_path_)
263 self._session.error.connect(self._on_session_error)
264 self._session.loggedIn.connect(self._on_login)
265 self._session.loggedOut.connect(self._on_logout)
266 self._session.draft.recipientsChanged.connect(self._on_recipients_changed)
267 self._session.newMessages.connect(self._on_new_message_alert)
268 self._app.alarmHandler.applicationNotifySignal.connect(self._on_app_alert)
269 self._voicemailRefreshDelay = QtCore.QTimer()
270 self._voicemailRefreshDelay.setInterval(30 * 1000)
271 self._voicemailRefreshDelay.timeout.connect(self._on_call_missed)
272 self._voicemailRefreshDelay.setSingleShot(True)
273 self._callHandler = None
274 self._updateVoicemailOnMissedCall = False
276 self._defaultCredentials = "", ""
277 self._curentCredentials = "", ""
280 self._credentialsDialog = None
281 self._smsEntryDialog = None
282 self._accountDialog = None
284 self._tabsContents = [
285 DelayedWidget(self._app, self._TAB_SETTINGS_NAMES[i])
286 for i in xrange(self.MAX_TABS)
288 for tab in self._tabsContents:
291 self._tabWidget = QtGui.QTabWidget()
292 if qui_utils.screen_orientation() == QtCore.Qt.Vertical:
293 self._tabWidget.setTabPosition(QtGui.QTabWidget.South)
295 self._tabWidget.setTabPosition(QtGui.QTabWidget.West)
296 defaultTabIconSize = self._tabWidget.iconSize()
297 defaultTabIconWidth, defaultTabIconHeight = defaultTabIconSize.width(), defaultTabIconSize.height()
298 for tabIndex, (tabTitle, tabIcon) in enumerate(
299 zip(self._TAB_TITLES, self._TAB_ICONS)
301 icon = self._app.get_icon(tabIcon)
302 if constants.IS_MAEMO and icon is not None:
306 self._tabWidget.addTab(self._tabsContents[tabIndex].toplevel, tabTitle)
308 iconSize = icon.availableSizes()[0]
309 defaultTabIconWidth = max(defaultTabIconWidth, iconSize.width())
310 defaultTabIconHeight = max(defaultTabIconHeight, iconSize.height())
311 self._tabWidget.addTab(self._tabsContents[tabIndex].toplevel, icon, tabTitle)
312 defaultTabIconWidth = max(defaultTabIconWidth, 32)
313 defaultTabIconHeight = max(defaultTabIconHeight, 32)
314 self._tabWidget.setIconSize(QtCore.QSize(defaultTabIconWidth, defaultTabIconHeight))
315 self._tabWidget.currentChanged.connect(self._on_tab_changed)
316 self._tabWidget.setContentsMargins(0, 0, 0, 0)
318 self._layout.addWidget(self._tabWidget)
320 self._loginAction = QtGui.QAction(None)
321 self._loginAction.setText("Login")
322 self._loginAction.triggered.connect(self._on_login_requested)
324 self._importAction = QtGui.QAction(None)
325 self._importAction.setText("Import")
326 self._importAction.triggered.connect(self._on_import)
328 self._accountAction = QtGui.QAction(None)
329 self._accountAction.setText("Account")
330 self._accountAction.triggered.connect(self._on_account)
332 self._refreshConnectionAction = QtGui.QAction(None)
333 self._refreshConnectionAction.setText("Refresh Connection")
334 self._refreshConnectionAction.setShortcut(QtGui.QKeySequence("CTRL+a"))
335 self._refreshConnectionAction.triggered.connect(self._on_refresh_connection)
337 self._refreshTabAction = QtGui.QAction(None)
338 self._refreshTabAction.setText("Refresh Tab")
339 self._refreshTabAction.setShortcut(QtGui.QKeySequence("CTRL+r"))
340 self._refreshTabAction.triggered.connect(self._on_refresh)
342 fileMenu = self._window.menuBar().addMenu("&File")
343 fileMenu.addAction(self._loginAction)
344 fileMenu.addAction(self._refreshTabAction)
345 fileMenu.addAction(self._refreshConnectionAction)
347 toolsMenu = self._window.menuBar().addMenu("&Tools")
348 toolsMenu.addAction(self._accountAction)
349 toolsMenu.addAction(self._importAction)
350 toolsMenu.addAction(self._app.aboutAction)
352 self._initialize_tab(self._tabWidget.currentIndex())
353 self.set_fullscreen(self._app.fullscreenAction.isChecked())
354 self.update_orientation(self._app.orientation)
356 def set_default_credentials(self, username, password):
357 self._defaultCredentials = username, password
359 def get_default_credentials(self):
360 return self._defaultCredentials
362 def walk_children(self):
363 if self._smsEntryDialog is not None:
364 return (self._smsEntryDialog, )
369 qwrappers.WindowWrapper.start(self)
370 assert self._session.state == self._session.LOGGEDOUT_STATE, "Initialization messed up"
371 if self._defaultCredentials != ("", ""):
372 username, password = self._defaultCredentials[0], self._defaultCredentials[1]
373 self._curentCredentials = username, password
374 self._session.login(username, password)
376 self._prompt_for_login()
380 self._credentialsDialog,
385 for child in self.walk_children():
386 child.window.destroyed.disconnect(self._on_child_close)
387 child.window.closed.disconnect(self._on_child_close)
392 qwrappers.WindowWrapper.destroy(self)
393 if self._session.state != self._session.LOGGEDOUT_STATE:
394 self._session.logout()
396 def get_current_tab(self):
397 return self._currentTab
399 def set_current_tab(self, tabIndex):
400 self._tabWidget.setCurrentIndex(tabIndex)
402 def load_settings(self, config):
405 orientation = self._app.orientation
409 config.get(constants.__pretty_app_name__, "bin_blob_%i" % i)
410 for i in xrange(len(self.get_default_credentials()))
412 isFullscreen = config.getboolean(constants.__pretty_app_name__, "fullscreen")
413 tabIndex = config.getint(constants.__pretty_app_name__, "tab")
414 orientation = config.get(constants.__pretty_app_name__, "orientation")
415 except ConfigParser.NoOptionError, e:
417 "Settings file %s is missing option %s" % (
418 constants._user_settings_,
422 except ConfigParser.NoSectionError, e:
424 "Settings file %s is missing section %s" % (
425 constants._user_settings_,
430 _moduleLogger.exception("Unknown loading error")
433 self._app.alarmHandler.load_settings(config, "alarm")
434 self._app.notifyOnMissed = config.getboolean("2 - Account Info", "notifyOnMissed")
435 self._app.notifyOnVoicemail = config.getboolean("2 - Account Info", "notifyOnVoicemail")
436 self._app.notifyOnSms = config.getboolean("2 - Account Info", "notifyOnSms")
437 self._updateVoicemailOnMissedCall = config.getboolean("2 - Account Info", "updateVoicemailOnMissedCall")
438 except ConfigParser.NoOptionError, e:
440 "Settings file %s is missing option %s" % (
441 constants._user_settings_,
445 except ConfigParser.NoSectionError, e:
447 "Settings file %s is missing section %s" % (
448 constants._user_settings_,
453 _moduleLogger.exception("Unknown loading error")
456 base64.b64decode(blob)
459 self.set_default_credentials(*creds)
460 self._app.fullscreenAction.setChecked(isFullscreen)
461 self.update_orientation(orientation)
462 self.set_current_tab(tabIndex)
464 backendId = 2 # For backwards compatibility
465 for tabIndex, tabTitle in enumerate(self._TAB_TITLES):
466 sectionName = "%s - %s" % (backendId, tabTitle)
467 settings = self._tabsContents[tabIndex].get_settings()
468 for settingName in settings.iterkeys():
470 settingValue = config.get(sectionName, settingName)
471 except ConfigParser.NoOptionError, e:
473 "Settings file %s is missing section %s" % (
474 constants._user_settings_,
479 except ConfigParser.NoSectionError, e:
481 "Settings file %s is missing section %s" % (
482 constants._user_settings_,
488 _moduleLogger.exception("Unknown loading error")
490 settings[settingName] = settingValue
491 self._tabsContents[tabIndex].set_settings(settings)
493 def save_settings(self, config):
494 config.add_section(constants.__pretty_app_name__)
495 config.set(constants.__pretty_app_name__, "tab", str(self.get_current_tab()))
496 config.set(constants.__pretty_app_name__, "fullscreen", str(self._app.fullscreenAction.isChecked()))
497 config.set(constants.__pretty_app_name__, "orientation", str(self._app.orientation))
498 for i, value in enumerate(self.get_default_credentials()):
499 blob = base64.b64encode(value)
500 config.set(constants.__pretty_app_name__, "bin_blob_%i" % i, blob)
502 config.add_section("alarm")
503 self._app.alarmHandler.save_settings(config, "alarm")
504 config.add_section("2 - Account Info")
505 config.set("2 - Account Info", "notifyOnMissed", repr(self._app.notifyOnMissed))
506 config.set("2 - Account Info", "notifyOnVoicemail", repr(self._app.notifyOnVoicemail))
507 config.set("2 - Account Info", "notifyOnSms", repr(self._app.notifyOnSms))
508 config.set("2 - Account Info", "updateVoicemailOnMissedCall", repr(self._updateVoicemailOnMissedCall))
510 backendId = 2 # For backwards compatibility
511 for tabIndex, tabTitle in enumerate(self._TAB_TITLES):
512 sectionName = "%s - %s" % (backendId, tabTitle)
513 config.add_section(sectionName)
514 tabSettings = self._tabsContents[tabIndex].get_settings()
515 for settingName, settingValue in tabSettings.iteritems():
516 config.set(sectionName, settingName, settingValue)
518 def update_orientation(self, orientation):
519 qwrappers.WindowWrapper.update_orientation(self, orientation)
520 windowOrientation = self.idealWindowOrientation
521 if windowOrientation == QtCore.Qt.Horizontal:
522 self._tabWidget.setTabPosition(QtGui.QTabWidget.West)
524 self._tabWidget.setTabPosition(QtGui.QTabWidget.South)
526 def _initialize_tab(self, index):
527 assert index < self.MAX_TABS, "Invalid tab"
528 if not self._tabsContents[index].has_child():
529 tab = self._TAB_CLASS[index](self._app, self._session, self._errorLog)
530 self._tabsContents[index].set_child(tab)
531 self._tabsContents[index].refresh(force=False)
533 def _prompt_for_login(self):
534 if self._credentialsDialog is None:
536 self._credentialsDialog = dialogs.CredentialsDialog(self._app)
537 credentials = self._credentialsDialog.run(
538 self._defaultCredentials[0], self._defaultCredentials[1], self.window
540 if credentials is None:
542 username, password = credentials
543 self._curentCredentials = username, password
544 self._session.login(username, password)
546 def _show_account_dialog(self):
547 if self._accountDialog is None:
549 self._accountDialog = dialogs.AccountDialog(self._app)
550 self._accountDialog.setIfNotificationsSupported(self._app.alarmHandler.backgroundNotificationsSupported)
552 if self._callHandler is None or not self._callHandler.isSupported:
553 self._accountDialog.updateVMOnMissedCall = self._accountDialog.VOICEMAIL_CHECK_NOT_SUPPORTED
554 elif self._updateVoicemailOnMissedCall:
555 self._accountDialog.updateVMOnMissedCall = self._accountDialog.VOICEMAIL_CHECK_ENABLED
557 self._accountDialog.updateVMOnMissedCall = self._accountDialog.VOICEMAIL_CHECK_DISABLED
558 self._accountDialog.notifications = self._app.alarmHandler.alarmType
559 self._accountDialog.notificationTime = self._app.alarmHandler.recurrence
560 self._accountDialog.notifyOnMissed = self._app.notifyOnMissed
561 self._accountDialog.notifyOnVoicemail = self._app.notifyOnVoicemail
562 self._accountDialog.notifyOnSms = self._app.notifyOnSms
563 self._accountDialog.set_callbacks(
564 self._session.get_callback_numbers(), self._session.get_callback_number()
566 accountNumberToDisplay = self._session.get_account_number()
567 if not accountNumberToDisplay:
568 accountNumberToDisplay = "Not Available (%s)" % self._session.state
569 self._accountDialog.set_account_number(accountNumberToDisplay)
570 response = self._accountDialog.run(self.window)
571 if response == QtGui.QDialog.Accepted:
572 if self._accountDialog.doClear:
573 self._session.logout_and_clear()
574 self._defaultCredentials = "", ""
575 self._curentCredentials = "", ""
576 for tab in self._tabsContents:
579 callbackNumber = self._accountDialog.selectedCallback
580 self._session.set_callback_number(callbackNumber)
582 if self._callHandler is None or self._accountDialog.updateVMOnMissedCall == self._accountDialog.VOICEMAIL_CHECK_DISABLEDD:
584 elif self._accountDialog.updateVMOnMissedCall == self._accountDialog.VOICEMAIL_CHECK_ENABLED:
585 self._updateVoicemailOnMissedCall = True
586 self._callHandler.start()
588 self._updateVoicemailOnMissedCall = False
589 self._callHandler.stop()
591 self._accountDialog.notifyOnMissed or
592 self._accountDialog.notifyOnVoicemail or
593 self._accountDialog.notifyOnSms
595 notifications = self._accountDialog.notifications
597 notifications = self._accountDialog.ALARM_NONE
598 self._app.alarmHandler.apply_settings(notifications, self._accountDialog.notificationTime)
600 self._app.notifyOnMissed = self._accountDialog.notifyOnMissed
601 self._app.notifyOnVoicemail = self._accountDialog.notifyOnVoicemail
602 self._app.notifyOnSms = self._accountDialog.notifyOnSms
603 self._app.save_settings()
604 elif response == QtGui.QDialog.Rejected:
605 _moduleLogger.info("Cancelled")
607 _moduleLogger.info("Unknown response")
610 @misc_utils.log_exception(_moduleLogger)
611 def _on_window_resized(self):
612 with qui_utils.notify_error(self._app.errorLog):
613 windowOrientation = self.idealWindowOrientation
614 if windowOrientation == QtCore.Qt.Horizontal:
615 self._tabWidget.setTabPosition(QtGui.QTabWidget.West)
617 self._tabWidget.setTabPosition(QtGui.QTabWidget.South)
620 @misc_utils.log_exception(_moduleLogger)
621 def _on_new_message_alert(self):
622 with qui_utils.notify_error(self._errorLog):
623 if self._app.alarmHandler.alarmType == self._app.alarmHandler.ALARM_APPLICATION:
624 if self._currentTab == self.MESSAGES_TAB or not self._app.ledHandler.isReal:
625 self._errorLog.push_message("New messages available")
627 self._app.ledHandler.on()
630 @misc_utils.log_exception(_moduleLogger)
631 def _on_call_missed(self):
632 with qui_utils.notify_error(self._errorLog):
633 self._session.update_messages(self._session.MESSAGE_VOICEMAILS, force=True)
636 @misc_utils.log_exception(_moduleLogger)
637 def _on_session_error(self, message):
638 with qui_utils.notify_error(self._errorLog):
639 self._errorLog.push_error(message)
642 @misc_utils.log_exception(_moduleLogger)
644 with qui_utils.notify_error(self._errorLog):
645 changedAccounts = self._defaultCredentials != self._curentCredentials
646 noCallback = not self._session.get_callback_number()
647 if changedAccounts or noCallback:
648 self._show_account_dialog()
650 self._defaultCredentials = self._curentCredentials
652 for tab in self._tabsContents:
654 self._initialize_tab(self._currentTab)
655 if self._updateVoicemailOnMissedCall:
656 if self._callHandler is None:
658 self._callHandler = call_handler.MissedCallWatcher()
659 self._callHandler.callMissed.connect(self._voicemailRefreshDelay.start)
660 self._callHandler.start()
663 @misc_utils.log_exception(_moduleLogger)
664 def _on_logout(self):
665 with qui_utils.notify_error(self._errorLog):
666 for tab in self._tabsContents:
668 if self._callHandler is not None:
669 self._callHandler.stop()
672 @misc_utils.log_exception(_moduleLogger)
673 def _on_app_alert(self):
674 with qui_utils.notify_error(self._errorLog):
675 if self._session.state == self._session.LOGGEDIN_STATE:
677 (True, True): self._session.MESSAGE_ALL,
678 (True, False): self._session.MESSAGE_TEXTS,
679 (False, True): self._session.MESSAGE_VOICEMAILS,
680 }[(self._app.notifyOnSms, self._app.notifyOnVoicemail)]
681 self._session.update_messages(messageType, force=True)
684 @misc_utils.log_exception(_moduleLogger)
685 def _on_recipients_changed(self):
686 with qui_utils.notify_error(self._errorLog):
687 if self._session.draft.get_num_contacts() == 0:
690 if self._smsEntryDialog is None:
692 self._smsEntryDialog = dialogs.SMSEntryWindow(self.window, self._app, self._session, self._errorLog)
693 self._smsEntryDialog.window.destroyed.connect(self._on_child_close)
694 self._smsEntryDialog.window.closed.connect(self._on_child_close)
695 self._smsEntryDialog.window.show()
697 @misc_utils.log_exception(_moduleLogger)
698 def _on_child_close(self, obj = None):
699 self._smsEntryDialog = None
702 @qt_compat.Slot(bool)
703 @misc_utils.log_exception(_moduleLogger)
704 def _on_login_requested(self, checked = True):
705 with qui_utils.notify_error(self._errorLog):
706 self._prompt_for_login()
709 @misc_utils.log_exception(_moduleLogger)
710 def _on_tab_changed(self, index):
711 with qui_utils.notify_error(self._errorLog):
712 self._currentTab = index
713 self._initialize_tab(index)
714 if self._app.alarmHandler.alarmType == self._app.alarmHandler.ALARM_APPLICATION:
715 self._app.ledHandler.off()
718 @qt_compat.Slot(bool)
719 @misc_utils.log_exception(_moduleLogger)
720 def _on_refresh(self, checked = True):
721 with qui_utils.notify_error(self._errorLog):
722 self._tabsContents[self._currentTab].refresh(force=True)
725 @qt_compat.Slot(bool)
726 @misc_utils.log_exception(_moduleLogger)
727 def _on_refresh_connection(self, checked = True):
728 with qui_utils.notify_error(self._errorLog):
729 self._session.refresh_connection()
732 @qt_compat.Slot(bool)
733 @misc_utils.log_exception(_moduleLogger)
734 def _on_import(self, checked = True):
735 with qui_utils.notify_error(self._errorLog):
736 csvName = QtGui.QFileDialog.getOpenFileName(self._window, caption="Import", filter="CSV Files (*.csv)")
737 csvName = unicode(csvName)
741 shutil.copy2(csvName, self._app.fsContactsPath)
742 if self._tabsContents[self.CONTACTS_TAB].has_child:
743 self._tabsContents[self.CONTACTS_TAB].child.update_addressbooks()
746 @qt_compat.Slot(bool)
747 @misc_utils.log_exception(_moduleLogger)
748 def _on_account(self, checked = True):
749 with qui_utils.notify_error(self._errorLog):
750 assert self._session.state == self._session.LOGGEDIN_STATE, "Must be logged in for settings"
751 self._show_account_dialog()
756 os.makedirs(constants._data_path_)
761 logFormat = '(%(relativeCreated)5d) %(levelname)-5s %(threadName)s.%(name)s.%(funcName)s: %(message)s'
762 logging.basicConfig(level=logging.DEBUG, format=logFormat)
763 rotating = logging.handlers.RotatingFileHandler(constants._user_logpath_, maxBytes=512*1024, backupCount=1)
764 rotating.setFormatter(logging.Formatter(logFormat))
765 root = logging.getLogger()
766 root.addHandler(rotating)
767 _moduleLogger.info("%s %s-%s" % (constants.__app_name__, constants.__version__, constants.__build__))
768 _moduleLogger.info("OS: %s" % (os.uname()[0], ))
769 _moduleLogger.info("Kernel: %s (%s) for %s" % os.uname()[2:])
770 _moduleLogger.info("Hostname: %s" % os.uname()[1])
774 gobject.threads_init()
776 _moduleLogger.info("GObject support not available")
780 from dbus.mainloop.qt import DBusQtMainLoop
781 DBusQtMainLoop(set_as_default=True)
782 _moduleLogger.info("Using Qt mainloop")
785 from dbus.mainloop.glib import DBusGMainLoop
786 DBusGMainLoop(set_as_default=True)
787 _moduleLogger.info("Using GObject mainloop")
789 _moduleLogger.info("Mainloop not available")
791 _moduleLogger.info("DBus support not available")
793 app = QtGui.QApplication([])
794 handle = Dialcentral(app)
799 if __name__ == "__main__":