Ejemplo n.º 1
0
 def save_certificates(self, sip_address, crt, key, ca):
     crt = crt.strip() + os.linesep
     key = key.strip() + os.linesep
     ca = ca.strip() + os.linesep
     X509Certificate(crt)
     X509PrivateKey(key)
     X509Certificate(ca)
     makedirs(ApplicationData.get('tls'))
     certificate_path = ApplicationData.get(os.path.join('tls', sip_address+'.crt'))
     file = open(certificate_path, 'w')
     os.chmod(certificate_path, 0600)
     file.write(crt+key)
     file.close()
     ca_path = ApplicationData.get(os.path.join('tls', 'ca.crt'))
     try:
         existing_cas = open(ca_path).read().strip() + os.linesep
     except:
         file = open(ca_path, 'w')
         file.write(ca)
         file.close()
     else:
         if ca not in existing_cas:
             file = open(ca_path, 'w')
             file.write(existing_cas+ca)
             file.close()
     settings = SIPSimpleSettings()
     settings.tls.ca_list = ca_path
     settings.save()
     return certificate_path
Ejemplo n.º 2
0
 def _save_certificates(sip_address, crt, key, ca):
     crt = crt.strip() + os.linesep
     key = key.strip() + os.linesep
     ca = ca.strip() + os.linesep
     X509Certificate(crt)
     X509PrivateKey(key)
     X509Certificate(ca)
     makedirs(ApplicationData.get('tls'))
     certificate_path = ApplicationData.get(
         os.path.join('tls', sip_address + '.crt'))
     certificate_file = open(certificate_path, 'w')
     os.chmod(certificate_path, 0600)
     certificate_file.write(crt + key)
     certificate_file.close()
     ca_path = ApplicationData.get(os.path.join('tls', 'ca.crt'))
     try:
         existing_cas = open(ca_path).read().strip() + os.linesep
     except:
         certificate_file = open(ca_path, 'w')
         certificate_file.write(ca)
         certificate_file.close()
     else:
         if ca not in existing_cas:
             certificate_file = open(ca_path, 'w')
             certificate_file.write(existing_cas + ca)
             certificate_file.close()
     settings = SIPSimpleSettings()
     settings.tls.ca_list = ca_path
     settings.save()
     return certificate_path
Ejemplo n.º 3
0
 def run(self):
     self.first_run = not os.path.exists(ApplicationData.get("config"))
     self.sip_application.start(FileStorage(ApplicationData.directory))
     self.exec_()
     self.update_manager.shutdown()
     self.sip_application.stop()
     self.sip_application.thread.join()
     self.log_manager.stop()
Ejemplo n.º 4
0
 def run(self):
     self.first_run = not os.path.exists(ApplicationData.get('config'))
     self.sip_application.start(FileStorage(ApplicationData.directory))
     self.exec_()
     self.update_manager.shutdown()
     self.sip_application.stop()
     self.sip_application.thread.join()
     self.log_manager.stop()
Ejemplo n.º 5
0
 def _set_filename(self, filename):
     self.__dict__['filename'] = filename
     filename = ApplicationData.get(filename) if filename else Resources.get(self.default_icon)
     pixmap = QPixmap()
     if pixmap.load(filename):
         self.setPixmap(pixmap.scaled(32, 32, Qt.KeepAspectRatio, Qt.SmoothTransformation))
     else:
         self.setPixmap(pixmap)
Ejemplo n.º 6
0
 def __init__(self):
     try:
         data = pickle.load(open(ApplicationData.get('calls_history')))
         if not isinstance(data, list) or not all(isinstance(item, HistoryEntry) and item.text and isinstance(item.call_time, ISOTimestamp) for item in data):
             raise ValueError("invalid save data")
     except Exception:
         self.calls = []
     else:
         self.calls = data[-self.history_size:]
     notification_center = NotificationCenter()
     notification_center.add_observer(self, name='SIPSessionDidEnd')
     notification_center.add_observer(self, name='SIPSessionDidFail')
Ejemplo n.º 7
0
 def _NH_SIPApplicationDidStart(self, notification):
     try:
         data = pickle.load(open(ApplicationData.get('calls_history'),
                                 "rb"))
         if not isinstance(data, list) or not all(
                 isinstance(item, HistoryEntry) and item.text
                 and isinstance(item.call_time, ISOTimestamp)
                 for item in data):
             raise ValueError("invalid save data")
     except Exception as e:
         traceback.print_exc()
     else:
         self.calls = data[-self.history_size:]
Ejemplo n.º 8
0
 def __init__(self):
     try:
         data = pickle.load(open(ApplicationData.get('calls_history')))
         if not isinstance(data, list) or not all(
                 isinstance(item, HistoryEntry) and item.text
                 and isinstance(item.call_time, ISOTimestamp)
                 for item in data):
             raise ValueError("invalid save data")
     except Exception:
         self.calls = []
     else:
         self.calls = data[-self.history_size:]
     notification_center = NotificationCenter()
     notification_center.add_observer(self, name='SIPSessionDidEnd')
     notification_center.add_observer(self, name='SIPSessionDidFail')
Ejemplo n.º 9
0
 def _initialize_sipsimple(self):
     if not os.path.exists(ApplicationData.get('config')):
         self.first_run = True
     notification_center = NotificationCenter()
     notification_center.add_observer(self, sender=self.application)
     self.application.start(FileBackend(ApplicationData.get('config')))
Ejemplo n.º 10
0
 def save(self):
     with open(ApplicationData.get('calls_history'), 'wb+') as history_file:
         pickle.dump(self.calls, history_file)
Ejemplo n.º 11
0
 def normalized(self):
     return ApplicationData.get(self)
Ejemplo n.º 12
0
from blink.configuration.settings import SIPSimpleSettingsExtension
from blink.logging import LogManager
from blink.mainwindow import MainWindow
from blink.presence import PresenceManager
from blink.resources import ApplicationData, Resources
from blink.sessions import SessionManager
from blink.update import UpdateManager
from blink.util import QSingleton, run_in_gui_thread

__all__ = ['Blink']

if hasattr(sys, 'frozen'):
    import httplib2
    httplib2.CA_CERTS = os.environ['SSL_CERT_FILE'] = Resources.get(
        'tls/cacerts.pem')
    makedirs(ApplicationData.get('logs'))
    sys.stdout.file = ApplicationData.get('logs/output.log')


class IPAddressMonitor(object):
    """
    An object which monitors the IP address used for the default route of the
    host and posts a SystemIPAddressDidChange notification when a change is
    detected.
    """
    def __init__(self):
        self.greenlet = None

    @run_in_green_thread
    def start(self):
        notification_center = NotificationCenter()
Ejemplo n.º 13
0
 def _get_path(self):
     return ApplicationData.get(self.__dict__['path'])
Ejemplo n.º 14
0
from blink.configuration.addressbook import ContactExtension, GroupExtension
from blink.configuration.settings import SIPSimpleSettingsExtension
from blink.logging import LogManager
from blink.mainwindow import MainWindow
from blink.presence import PresenceManager
from blink.resources import ApplicationData, Resources
from blink.sessions import SessionManager
from blink.update import UpdateManager
from blink.util import QSingleton, run_in_gui_thread


__all__ = ["Blink"]


if hasattr(sys, "frozen"):
    makedirs(ApplicationData.get("logs"))
    sys.stdout.file = open(ApplicationData.get("logs/output.log"), "a", 0)
    import httplib2

    httplib2.CA_CERTS = os.environ["SSL_CERT_FILE"] = Resources.get("tls/cacerts.pem")


class IPAddressMonitor(object):
    """
    An object which monitors the IP address used for the default route of the
    host and posts a SystemIPAddressDidChange notification when a change is
    detected.
    """

    def __init__(self):
        self.greenlet = None
Ejemplo n.º 15
0
 def _get_path(self):
     path = self.__dict__['path']
     return path if path is DefaultPath else ApplicationData.get(path)
Ejemplo n.º 16
0
 def _AH_LogsWindowActionTriggered(self, checked):
     directory = ApplicationData.get('logs')
     makedirs(directory)
     QDesktopServices.openUrl(QUrl.fromLocalFile(directory))
Ejemplo n.º 17
0
 def _get_path(self):
     return ApplicationData.get(self.__dict__['path'])
Ejemplo n.º 18
0
 def save(self):
     with open(ApplicationData.get('calls_history'), 'wb+') as history_file:
         pickle.dump(self.calls, history_file)
Ejemplo n.º 19
0
 def _AH_LogsWindowActionTriggered(self, checked):
     directory = ApplicationData.get('logs')
     makedirs(directory)
     QDesktopServices.openUrl(QUrl.fromLocalFile(directory))
Ejemplo n.º 20
0
 def normalized(self):
     return ApplicationData.get(self)
Ejemplo n.º 21
0
from blink.configuration.account import AccountExtension, BonjourAccountExtension
from blink.configuration.addressbook import ContactExtension, GroupExtension
from blink.configuration.datatypes import InvalidToken
from blink.configuration.settings import SIPSimpleSettingsExtension
from blink.logging import LogManager
from blink.mainwindow import MainWindow
from blink.presence import PresenceManager
from blink.resources import ApplicationData, Resources
from blink.sessions import SessionManager
from blink.update import UpdateManager
from blink.util import QSingleton, run_in_gui_thread


if getattr(sys, 'frozen', False):
    output = sys.stdout
    makedirs(ApplicationData.get('logs'))
    sys.stdout = sys.stderr = open(ApplicationData.get('logs/output.log'), 'a')
    sys.stdout.write(output.getvalue())
    output.close()


class IPAddressMonitor(object):
    """
    An object which monitors the IP address used for the default route of the
    host and posts a SystemIPAddressDidChange notification when a change is
    detected.
    """

    def __init__(self):
        self.greenlet = None
Ejemplo n.º 22
0
 def _get_path(self):
     path = self.__dict__['path']
     return path if path is DefaultPath else ApplicationData.get(path)
Ejemplo n.º 23
0
 def __init__(self):
     db_file = ApplicationData.get('message_history.db')
     db_uri = f'sqlite://{db_file}'
     self._initialize(db_uri)