Exemplo n.º 1
0
 def start(self):
     settings = SIPSimpleSettings()
     notification_center = NotificationCenter()
     notification_center.add_observer(self)
     if settings.logs.trace_sip:
         self.siptrace_file = LogFile(
             os.path.join(ApplicationData.directory, 'logs',
                          'sip_trace.txt'))
     if settings.logs.trace_msrp:
         self.msrptrace_file = LogFile(
             os.path.join(ApplicationData.directory, 'logs',
                          'msrp_trace.txt'))
     if settings.logs.trace_pjsip:
         self.pjsiptrace_file = LogFile(
             os.path.join(ApplicationData.directory, 'logs',
                          'pjsip_trace.txt'))
     if settings.logs.trace_notifications:
         self.notifications_file = LogFile(
             os.path.join(ApplicationData.directory, 'logs',
                          'notifications_trace.txt'))
     self._siptrace_start_time = datetime.now()
     self._siptrace_packet_count = 0
     self.event_queue = EventQueue(handler=self._process_notification,
                                   name='Blink LogManager')
     self.event_queue.start()
     while settings.logs.trace_notifications and self.notification_queue and self.notification_queue.notifications:
         notification = self.notification_queue.notifications.popleft()
         self.handle_notification(notification)
     self.notification_queue = None
Exemplo n.º 2
0
    def __init__(self,
                 sip_to_stdout=False,
                 msrp_to_stdout=False,
                 pjsip_to_stdout=False,
                 notifications_to_stdout=False,
                 msrp_level=log.level.ERROR):
        self.sip_to_stdout = sip_to_stdout
        self.msrp_to_stdout = msrp_to_stdout
        self.pjsip_to_stdout = pjsip_to_stdout
        self.notifications_to_stdout = notifications_to_stdout
        self.msrp_level = msrp_level

        self._siptrace_filename = None
        self._siptrace_file = None
        self._siptrace_error = False
        self._siptrace_start_time = None
        self._siptrace_packet_count = 0

        self._msrptrace_filename = None
        self._msrptrace_file = None
        self._msrptrace_error = False

        self._pjsiptrace_filename = None
        self._pjsiptrace_file = None
        self._pjsiptrace_error = False

        self._notifications_filename = None
        self._notifications_file = None
        self._notifications_error = False

        self._event_queue = EventQueue(handler=self._process_notification,
                                       name='Log handling')
        self._log_directory_error = False
Exemplo n.º 3
0
 def get_thread(self, thread_id):
     with self.lock:
         try:
             thread = self.threads[thread_id]
         except KeyError:
             self.threads[thread_id] = thread = EventQueue(
                 handler=self._event_handler, name=thread_id)
             thread.start()
         return thread
Exemplo n.º 4
0
    def __init__(self):
        self.queue = EventQueue(handler=self._handle_task, name='RadiusQueue')
        self.queue.start()

        credentials = RadiusDatabaseConfig.user and (
            "%s%s@" % (RadiusDatabaseConfig.user,
                       RadiusDatabaseConfig.password and ":%s" %
                       (RadiusDatabaseConfig.password) or '')) or ''
        self.conn = sqlobject.connectionForURI(
            "mysql://%s%s/%s" % (credentials, RadiusDatabaseConfig.host,
                                 RadiusDatabaseConfig.database))
Exemplo n.º 5
0
    def start(self):
        # try to create the log directory
        try:
            self._init_log_directory()
        except Exception:
            pass

        # register to receive log notifications
        notification_center = NotificationCenter()
        notification_center.add_observer(self)

        # start the thread processing the notifications
        self._event_queue = EventQueue(handler=self._process_notification,
                                       name='Log handling')
        self._event_queue.start()
Exemplo n.º 6
0
    def initWithAccount_target_name_(self, account, target, display_name):
        self = objc.super(SMSViewController, self).init()
        if self:
            self.session_id = str(uuid.uuid1())

            self.notification_center = NotificationCenter()
            self.account = account
            self.target_uri = target
            self.display_name = display_name
            self.messages = {}

            self.encryption = OTREncryption(self)

            self.message_queue = EventQueue(self._send_message)

            self.history = ChatHistory()

            self.local_uri = '%s@%s' % (account.id.username, account.id.domain)
            self.remote_uri = '%s@%s' % (self.target_uri.user.decode(),
                                         self.target_uri.host.decode())
            self.contact = NSApp.delegate(
            ).contactsWindowController.getFirstContactFromAllContactsGroupMatchingURI(
                self.remote_uri)

            NSBundle.loadNibNamed_owner_("SMSView", self)

            self.chatViewController.setContentFile_(
                NSBundle.mainBundle().pathForResource_ofType_(
                    "ChatView", "html"))
            self.chatViewController.setAccount_(self.account)
            self.chatViewController.resetRenderedMessages()

            self.chatViewController.inputText.unregisterDraggedTypes()
            self.chatViewController.inputText.setMaxLength_(MAX_MESSAGE_LENGTH)
            self.splitView.setText_(
                NSLocalizedString("%i chars left", "Label") %
                MAX_MESSAGE_LENGTH)

            self.enableIsComposing = True

            self.log_info('Using local account %s' % self.local_uri)

            self.notification_center.add_observer(
                self, name='ChatStreamOTREncryptionStateChanged')
            self.started = False

        return self
Exemplo n.º 7
0
 def __init__(self, name):
     self.name = name
     self.secret = None
     self.private_key = DSAPrivateKey.generate()
     self.otr_session = OTRSession(self.private_key, transport=self)
     self.peer = None
     self.send_queue = EventQueue(handler=self._send_handler)
     self.send_queue.start()
     self.ake_done = Event()
     self.smp_done = Event()
     self.all_done = Event()
     self.otr_done = Event()
     self.smp_status = None
     self.same_secrets = None
     self.sent_message = None
     self.received_message = None
     NotificationCenter().add_observer(self, sender=self.otr_session)
Exemplo n.º 8
0
    def __init__(self):
        Thread.__init__(self, target=self._run, name='UI-Thread')
        self.setDaemon(True)

        self.__dict__['prompt'] = Prompt('')
        self.__dict__['status'] = None
        self.command_sequence = '/'
        self.application_control_char = '\x18' # ctrl-X
        self.application_control_bindings = {}
        self.display_commands = True
        self.display_text = True

        self.cursor_x = None
        self.cursor_y = None
        self.displaying_question = False
        self.input = Input()
        self.last_window_size = None
        self.prompt_y = None
        self.questions = deque()
        self.stopping = False
        self.lock = RLock()
        self.event_queue = EventQueue(handler=lambda (function, self, args, kwargs): function(self, *args, **kwargs), name='UI operation handling')
Exemplo n.º 9
0
    def __init__(self):
        # Loads the config file
        config = configparser.ConfigParser()
        try:
            config.read('config.ini')
        except Exception as e:
            print("ERROR: " + e)
            return
        self.account_name = config["SIPCONFIG"]["account_name"]
        self.target = None
        self.input = InputThread(self)
        self.output = EventQueue(self._write)
        self.logger = Logger(sip_to_stdout=False,
                             pjsip_to_stdout=False,
                             notifications_to_stdout=False)
        self.account = None
        self.subscriptions = []
        self.subscriptionqueue = []
        self.statusdict = {}
        self.stopping = False
        self.lastmessage = None
        self.commandsystemenabled = bool(config['SIPCONFIG']['commands'])

        self._subscription_routes = None
        self._subscription_timeout = 0.0
        self._subscription_wait = 0.5

        account_manager = AccountManager()
        engine = Engine()
        notification_center = NotificationCenter()
        notification_center.add_observer(self, sender=account_manager)
        notification_center.add_observer(self, sender=engine)
        notification_center.add_observer(self, sender=self.input)
        notification_center.add_observer(self, name='SIPEngineGotMessage')

        log.level.current = log.level.WARNING
Exemplo n.º 10
0
    def __init__(self, msrp_level=log.level.INFO):
        self.msrp_level = msrp_level

        self._siptrace_filename = None
        self._siptrace_file = None
        self._siptrace_error = False
        self._siptrace_start_time = None
        self._siptrace_packet_count = 0

        self._msrptrace_filename = None
        self._msrptrace_file = None
        self._msrptrace_error = False

        self._pjsiptrace_filename = None
        self._pjsiptrace_file = None
        self._pjsiptrace_error = False

        self._notifications_filename = None
        self._notifications_file = None
        self._notifications_error = False

        self._event_queue = EventQueue(handler=self._process_notification,
                                       name='Log handling')
        self._log_directory_error = False