Commit 882e576e authored by Saul Ibarra's avatar Saul Ibarra

Added UpdateManager and Windows implementation with WinSparkle

parent 88c3efcf
...@@ -24,6 +24,7 @@ from blink.log import LogManager ...@@ -24,6 +24,7 @@ from blink.log import LogManager
from blink.mainwindow import MainWindow from blink.mainwindow import MainWindow
from blink.resources import ApplicationData from blink.resources import ApplicationData
from blink.sessions import SessionManager from blink.sessions import SessionManager
from blink.update import UpdateManager
from blink.util import QSingleton, run_in_gui_thread from blink.util import QSingleton, run_in_gui_thread
...@@ -37,6 +38,10 @@ class Blink(QApplication): ...@@ -37,6 +38,10 @@ class Blink(QApplication):
self.application = SIPApplication() self.application = SIPApplication()
self.main_window = MainWindow() self.main_window = MainWindow()
self.update_manager = UpdateManager()
self.main_window.check_for_updates_action.triggered.connect(self.update_manager.check_for_updates)
self.main_window.check_for_updates_action.setEnabled(self.update_manager != Null)
Account.register_extension(AccountExtension) Account.register_extension(AccountExtension)
BonjourAccount.register_extension(BonjourAccountExtension) BonjourAccount.register_extension(BonjourAccountExtension)
SIPSimpleSettings.register_extension(SIPSimpleSettingsExtension) SIPSimpleSettings.register_extension(SIPSimpleSettingsExtension)
...@@ -47,6 +52,7 @@ class Blink(QApplication): ...@@ -47,6 +52,7 @@ class Blink(QApplication):
from blink.util import call_in_gui_thread as call_later from blink.util import call_in_gui_thread as call_later
call_later(self._initialize_sipsimple) call_later(self._initialize_sipsimple)
self.exec_() self.exec_()
self.update_manager.shutdown()
self.application.stop() self.application.stop()
def customEvent(self, event): def customEvent(self, event):
...@@ -71,6 +77,7 @@ class Blink(QApplication): ...@@ -71,6 +77,7 @@ class Blink(QApplication):
@run_in_gui_thread @run_in_gui_thread
def _NH_SIPApplicationDidStart(self, notification): def _NH_SIPApplicationDidStart(self, notification):
self.main_window.show() self.main_window.show()
self.update_manager.initialize()
def _NH_SIPApplicationDidEnd(self, notification): def _NH_SIPApplicationDidEnd(self, notification):
log_manager = LogManager() log_manager = LogManager()
......
# Copyright (C) 2010 AG Projects. See LICENSE for details.
#
__all__ = ['IUpdateManager', 'UpdateManager']
import sys
from application.python.util import Null
from zope.interface import Interface
class IUpdateManager(Interface):
def initialize(self):
pass
def shutdown(self):
pass
def check_for_updates(self):
pass
if sys.platform == 'win32':
try:
from blink.update.windows import UpdateManager
except (AttributeError, ImportError, RuntimeError):
UpdateManager = Null
else:
UpdateManager = Null
# Copyright (C) 2010 AG Projects. See LICENSE for details.
#
import os
from blink.update import IUpdateManager
from ctypes import c_char_p, c_wchar_p, CDLL
from ctypes.util import find_library
from zope.interface import implements
def library_locations(name):
library_name = '%s.dll' % (name)
additional_paths = ['.']
library = find_library(library_name)
if library is not None:
yield library
for path in additional_paths:
yield os.path.join(path, library_name)
def load_library(name):
for library in library_locations(name):
try:
return CDLL(library)
except OSError:
pass
else:
break
else:
raise RuntimeError('cannot find %s on this system' % name)
# load WinSparkle dll
winsparkle_dll = load_library('WinSparkle')
# function definitions
winsparkle_init = winsparkle_dll.win_sparkle_init
winsparkle_init.argtypes = []
winsparkle_init.restype = None
winsparkle_cleanup = winsparkle_dll.win_sparkle_cleanup
winsparkle_cleanup.argtypes = []
winsparkle_cleanup.restype = None
winsparkle_set_appcast_url = winsparkle_dll.win_sparkle_set_appcast_url
winsparkle_set_appcast_url.argtypes = [c_char_p]
winsparkle_set_appcast_url.restype = None
winsparkle_check_update = winsparkle_dll.win_sparkle_check_update_with_ui
winsparkle_check_update.argtypes = []
winsparkle_check_update.restype = None
winsparkle_set_app_details = winsparkle_dll.win_sparkle_set_app_details
winsparkle_set_app_details.argtypes = [c_wchar_p, c_wchar_p, c_wchar_p]
winsparkle_set_app_details.restype = None
class UpdateManager(object):
implements(IUpdateManager)
def __init__(self):
from blink import __version__
winsparkle_set_appcast_url('https://blink.sipthor.net/BlinkQTAppcast.xml')
winsparkle_set_app_details('AG Projects', 'Blink', __version__)
def initialize(self):
"""Initialize WinSparkle library, it will try to fetch updates in the background"""
winsparkle_init()
def shutdown(self):
"""Shutdown WinSparkle library. Stops pending tasks and shuts down helper threads"""
winsparkle_cleanup()
def check_for_updates(self):
"""Interactively check for updates"""
winsparkle_check_update()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment