Example #1
0
	def load_settings(self):
		try:
			settingsPath = linux_utils.get_resource_path("config", constants.__app_name__, "settings.ini")
			config = ConfigParser.SafeConfigParser()
			config.read(settingsPath)
		except IOError, e:
			_moduleLogger.info("No settings")
			return
Example #2
0
	def save_settings(self):
		_moduleLogger.info("Saving settings")
		config = ConfigParser.SafeConfigParser()

		self._mainWindow.save_settings(config)

		settingsPath = linux_utils.get_resource_path("config", constants.__app_name__, "settings.ini")
		with open(settingsPath, "wb") as configFile:
			config.write(configFile)
Example #3
0
	def load_settings(self):
		settingsPath = linux_utils.get_resource_path(
			"config", constants.__app_name__, "settings.json"
		)
		try:
			with open(settingsPath) as settingsFile:
				settings = simplejson.load(settingsFile)
		except IOError, e:
			_moduleLogger.info("No settings")
			settings = {}
Example #4
0
	def save_settings(self):
		settings = {
			"isFullScreen": self._fullscreenAction.isChecked(),
			"isPortrait": self._orientationAction.isChecked(),
		}

		settingsPath = linux_utils.get_resource_path(
			"config", constants.__app_name__, "settings.json"
		)
		with open(settingsPath, "w") as settingsFile:
			simplejson.dump(settings, settingsFile)
Example #5
0
def notify_on_change():
	settingsPath = linux_utils.get_resource_path("config", constants.__app_name__, "settings.ini")

	config = ConfigParser.SafeConfigParser()
	config.read(settingsPath)
	backend = create_backend(config)
	notifyUser = is_changed(config, backend)

	if notifyUser:
		logging.info("Changed")
		import led_handler
		led = led_handler.LedHandler()
		led.on()
	else:
		logging.info("No Change")
Example #6
0
def run():
	try:
		os.makedirs(linux_utils.get_resource_path("config", constants.__app_name__))
	except OSError, e:
		if e.errno != 17:
			raise
Example #7
0
	def __init__(self, parent, app):
		qwrappers.WindowWrapper.__init__(self, parent, app)
		self._window.setWindowTitle("%s" % constants.__pretty_app_name__)
		self._window.resized.connect(self._on_window_resized)
		self._errorLog = self._app.errorLog

		cachePath = linux_utils.get_resource_path("cache", constants.__app_name__)
		self._session = session.Session(self._errorLog, cachePath)
		self._session.error.connect(self._on_session_error)
		self._session.loggedIn.connect(self._on_login)
		self._session.loggedOut.connect(self._on_logout)
		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 = None
		self._updateVoicemailOnMissedCall = False

		self._defaultCredentials = "", ""
		self._curentCredentials = "", ""
		self._currentTab = 0

		self._credentialsDialog = None
		self._smsEntryDialog = None
		self._accountDialog = None

		self._tabsContents = [
			DelayedWidget(self._app, self._TAB_SETTINGS_NAMES[i])
			for i in xrange(self.MAX_TABS)
		]
		for tab in self._tabsContents:
			tab.disable()

		self._tabWidget = QtGui.QTabWidget()
		if qui_utils.screen_orientation() == QtCore.Qt.Vertical:
			self._tabWidget.setTabPosition(QtGui.QTabWidget.South)
		else:
			self._tabWidget.setTabPosition(QtGui.QTabWidget.West)
		defaultTabIconSize = self._tabWidget.iconSize()
		defaultTabIconWidth, defaultTabIconHeight = defaultTabIconSize.width(), defaultTabIconSize.height()
		for tabIndex, (tabTitle, tabIcon) in enumerate(
			zip(self._TAB_TITLES, self._TAB_ICONS)
		):
			icon = self._app.get_icon(tabIcon)
			if constants.IS_MAEMO and icon is not None:
				tabTitle = ""

			if icon is None:
				self._tabWidget.addTab(self._tabsContents[tabIndex].toplevel, tabTitle)
			else:
				iconSize = icon.availableSizes()[0]
				defaultTabIconWidth = max(defaultTabIconWidth, iconSize.width())
				defaultTabIconHeight = max(defaultTabIconHeight, iconSize.height())
				self._tabWidget.addTab(self._tabsContents[tabIndex].toplevel, icon, tabTitle)
		defaultTabIconWidth = max(defaultTabIconWidth, 32)
		defaultTabIconHeight = max(defaultTabIconHeight, 32)
		self._tabWidget.setIconSize(QtCore.QSize(defaultTabIconWidth, defaultTabIconHeight))
		self._tabWidget.currentChanged[int].connect(self._on_tab_changed)
		self._tabWidget.setContentsMargins(0, 0, 0, 0)

		self._layout.addWidget(self._tabWidget)

		self._loginAction = QtGui.QAction(None)
		self._loginAction.setText("Login")
		self._loginAction.triggered.connect(self._on_login_requested)

		self._importAction = QtGui.QAction(None)
		self._importAction.setText("Import")
		self._importAction.triggered.connect(self._on_import)

		self._accountAction = QtGui.QAction(None)
		self._accountAction.setText("Account")
		self._accountAction.triggered.connect(self._on_account)

		self._refreshConnectionAction = QtGui.QAction(None)
		self._refreshConnectionAction.setText("Refresh Connection")
		self._refreshConnectionAction.setShortcut(QtGui.QKeySequence("CTRL+a"))
		self._refreshConnectionAction.triggered.connect(self._on_refresh_connection)

		self._refreshTabAction = QtGui.QAction(None)
		self._refreshTabAction.setText("Refresh Tab")
		self._refreshTabAction.setShortcut(QtGui.QKeySequence("CTRL+r"))
		self._refreshTabAction.triggered.connect(self._on_refresh)

		fileMenu = self._window.menuBar().addMenu("&File")
		fileMenu.addAction(self._loginAction)
		fileMenu.addAction(self._refreshTabAction)
		fileMenu.addAction(self._refreshConnectionAction)

		toolsMenu = self._window.menuBar().addMenu("&Tools")
		toolsMenu.addAction(self._accountAction)
		toolsMenu.addAction(self._importAction)
		toolsMenu.addAction(self._app.aboutAction)

		self._initialize_tab(self._tabWidget.currentIndex())
		self.set_fullscreen(self._app.fullscreenAction.isChecked())
		self.update_orientation(self._app.orientation)
Example #8
0
	def fsContactsPath(self):
		return linux_utils.get_resource_path("data", constants.__app_name__, "contacts")
Example #9
0
	@qt_compat.Slot(bool)
	@misc_utils.log_exception(_moduleLogger)
	def _on_account(self, checked = True):
		with qui_utils.notify_error(self._errorLog):
			assert self._session.state == self._session.LOGGEDIN_STATE, "Must be logged in for settings"
			self._show_account_dialog()


def run():
	try:
		os.makedirs(linux_utils.get_resource_path("config", constants.__app_name__))
	except OSError, e:
		if e.errno != 17:
			raise
	try:
		os.makedirs(linux_utils.get_resource_path("cache", constants.__app_name__))
	except OSError, e:
		if e.errno != 17:
			raise
	try:
		os.makedirs(linux_utils.get_resource_path("data", constants.__app_name__))
	except OSError, e:
		if e.errno != 17:
			raise

	logPath = linux_utils.get_resource_path("cache", constants.__app_name__, "%s.log" % constants.__app_name__)
	logFormat = '(%(relativeCreated)5d) %(levelname)-5s %(threadName)s.%(name)s.%(funcName)s: %(message)s'
	logging.basicConfig(level=logging.DEBUG, format=logFormat)
	rotating = logging.handlers.RotatingFileHandler(logPath, maxBytes=512*1024, backupCount=1)
	rotating.setFormatter(logging.Formatter(logFormat))
	root = logging.getLogger()
Example #10
0
#!/usr/bin/env python

import os
import filecmp
import ConfigParser
import pprint
import logging
import logging.handlers

import constants
from util import linux as linux_utils
from backends.gvoice import gvoice


CACHE_PATH = linux_utils.get_resource_path("cache", constants.__app_name__)


def get_missed(backend):
	missedPage = backend._browser.download(backend._XML_MISSED_URL)
	missedJson = backend._grab_json(missedPage)
	return missedJson


def get_voicemail(backend):
	voicemailPage = backend._browser.download(backend._XML_VOICEMAIL_URL)
	voicemailJson = backend._grab_json(voicemailPage)
	return voicemailJson


def get_sms(backend):
	smsPage = backend._browser.download(backend._XML_SMS_URL)