コード例 #1
0
 def end(self):
     with self._lock:
         if self.state == "ENDED" or self._done:
             return
         self._done = True
         if not self._initialized:
             self.state = "ENDED"
             self.notification_center.post_notification(
                 'MediaStreamDidNotInitialize',
                 sender=self,
                 data=NotificationData(reason='Interrupted'))
             return
         if self._keyframe_timer is not None:
             self._keyframe_timer.stop()
             self.notification_center.remove_observer(
                 self, sender=self._keyframe_timer)
         self._keyframe_timer = None
         self.notification_center.post_notification('MediaStreamWillEnd',
                                                    sender=self)
         if self._transport is not None:
             self.notification_center.remove_observer(
                 self, sender=self._transport)
             self.notification_center.remove_observer(
                 self, sender=self._rtp_transport)
             call_in_thread('device-io', self._transport.stop)
             self._transport = None
             self._rtp_transport = None
         self.state = "ENDED"
         self.notification_center.post_notification(
             'MediaStreamDidEnd',
             sender=self,
             data=NotificationData(error=self._failure_reason))
         self.session = None
コード例 #2
0
    def init(self):
        self = super(BlinkAppDelegate, self).init()
        if self:
            self.applicationName = str(NSBundle.mainBundle().infoDictionary().objectForKey_("CFBundleExecutable"))
            self.applicationNamePrint = 'Blink' if self.applicationName == 'Blink Pro' else self.applicationName
            build = str(NSBundle.mainBundle().infoDictionary().objectForKey_("CFBundleVersion"))
            date = str(NSBundle.mainBundle().infoDictionary().objectForKey_("BlinkVersionDate"))

            BlinkLogger().log_info(u"Starting %s build %s from %s" % (self.applicationNamePrint, build, date))

            self.registerURLHandler()
            NSWorkspace.sharedWorkspace().notificationCenter().addObserver_selector_name_object_(self, "computerDidWake:", NSWorkspaceDidWakeNotification, None)
            NSWorkspace.sharedWorkspace().notificationCenter().addObserver_selector_name_object_(self, "computerWillSleep:", NSWorkspaceWillSleepNotification, None)
            NSDistributedNotificationCenter.defaultCenter().addObserver_selector_name_object_suspensionBehavior_(self, "callFromAddressBook:", "CallTelephoneNumberWithBlinkFromAddressBookNotification", "AddressBook", NSNotificationSuspensionBehaviorDeliverImmediately)
            NSDistributedNotificationCenter.defaultCenter().addObserver_selector_name_object_suspensionBehavior_(self, "callFromAddressBook:", "CallSipAddressWithBlinkFromAddressBookNotification", "AddressBook", NSNotificationSuspensionBehaviorDeliverImmediately)

            NotificationCenter().add_observer(self, name="SIPApplicationDidStart")
            NotificationCenter().add_observer(self, name="SIPApplicationWillEnd")
            NotificationCenter().add_observer(self, name="SIPApplicationDidEnd")
            NotificationCenter().add_observer(self, name="CFGSettingsObjectDidChange")

            # remove obsolete settings
            userdef = NSUserDefaults.standardUserDefaults()
            userdef.removeObjectForKey_('SIPTrace')
            userdef.removeObjectForKey_('MSRPTrace')
            userdef.removeObjectForKey_('XCAPTrace')
            userdef.removeObjectForKey_('EnablePJSIPTrace')
            userdef.removeObjectForKey_('EnableNotificationsTrace')

            def purge_screenshots():
                screenshots_folder = ApplicationData.get('.tmp_screenshots')
                if os.path.exists(screenshots_folder):
                    try:
                        shutil.rmtree(screenshots_folder)
                    except EnvironmentError:
                        pass

            try:
                from Updater import Updater
            except ImportError:
                pass
            else:
                self.updater = Updater()

            call_in_thread('file-io', purge_screenshots)

        return self
コード例 #3
0
 def _set_default_account(self, account):
     if account is not None and not account.enabled:
         raise ValueError("account %s is not enabled" % account.id)
     notification_center = NotificationCenter()
     settings = SIPSimpleSettings()
     with self._lock:
         old_account = self.accounts.get(settings.default_account, None)
         if account is old_account:
             return
         if account is None:
             settings.default_account = None
         else:
             settings.default_account = account.id
         settings.save()
         # we need to post the notification in the file-io thread in order to have it serialized after the
         # SIPAccountManagerDidAddAccount notification that is triggered when the account is saved the first
         # time, because save is executed in the file-io thread while this runs in the current thread. -Dan
         call_in_thread('file-io', notification_center.post_notification, 'SIPAccountManagerDidChangeDefaultAccount', sender=self, data=NotificationData(old_account=old_account, account=account))
コード例 #4
0
    def init(self):
        self = super(BlinkAppDelegate, self).init()
        if self:
            self.applicationName = str(NSBundle.mainBundle().infoDictionary().objectForKey_("CFBundleExecutable"))
            self.applicationNamePrint = str(NSBundle.mainBundle().infoDictionary().objectForKey_("CFBundleName"))
            build = str(NSBundle.mainBundle().infoDictionary().objectForKey_("CFBundleVersion"))
            date = str(NSBundle.mainBundle().infoDictionary().objectForKey_("BlinkVersionDate"))

            BlinkLogger().log_info(u"Starting %s build %s from %s" % (self.applicationNamePrint, build, date))

            self.registerURLHandler()
            NSWorkspace.sharedWorkspace().notificationCenter().addObserver_selector_name_object_(self, "computerDidWake:", NSWorkspaceDidWakeNotification, None)
            NSWorkspace.sharedWorkspace().notificationCenter().addObserver_selector_name_object_(self, "computerWillSleep:", NSWorkspaceWillSleepNotification, None)
            NSDistributedNotificationCenter.defaultCenter().addObserver_selector_name_object_suspensionBehavior_(self, "callFromAddressBook:", "CallTelephoneNumberWithBlinkFromAddressBookNotification", "AddressBook", NSNotificationSuspensionBehaviorDeliverImmediately)
            NSDistributedNotificationCenter.defaultCenter().addObserver_selector_name_object_suspensionBehavior_(self, "callFromAddressBook:", "CallSipAddressWithBlinkFromAddressBookNotification", "AddressBook", NSNotificationSuspensionBehaviorDeliverImmediately)

            NotificationCenter().add_observer(self, name="CFGSettingsObjectDidChange")
            NotificationCenter().add_observer(self, name="SIPApplicationDidStart")
            NotificationCenter().add_observer(self, name="SIPApplicationWillEnd")
            NotificationCenter().add_observer(self, name="SIPApplicationDidEnd")
            NotificationCenter().add_observer(self, name="SystemIPAddressDidChange")
            NotificationCenter().add_observer(self, name="NetworkConditionsDidChange")
            NotificationCenter().add_observer(self, name="SIPEngineTransportDidDisconnect")
            NotificationCenter().add_observer(self, name="SIPEngineTransportDidConnect")
            NotificationCenter().add_observer(self, name="DNSNameserversDidChange")

            # remove obsolete settings
            userdef = NSUserDefaults.standardUserDefaults()
            userdef.removeObjectForKey_('SIPTrace')
            userdef.removeObjectForKey_('MSRPTrace')
            userdef.removeObjectForKey_('XCAPTrace')
            userdef.removeObjectForKey_('EnablePJSIPTrace')
            userdef.removeObjectForKey_('EnableNotificationsTrace')

            try:
                from Updater import Updater
            except ImportError:
                pass
            else:
                self.updater = Updater()

            call_in_thread('file-io', self.purge_temporary_files)

        return self
コード例 #5
0
 def default_account(self, account):
     if account is not None and not account.enabled:
         raise ValueError("account %s is not enabled" % account.id)
     notification_center = NotificationCenter()
     settings = SIPSimpleSettings()
     with self._lock:
         old_account = self.accounts.get(settings.default_account, None)
         if account is old_account:
             return
         if account is None:
             settings.default_account = None
         else:
             settings.default_account = account.id
         settings.save()
         # we need to post the notification in the file-io thread in order to have it serialized after the
         # SIPAccountManagerDidAddAccount notification that is triggered when the account is saved the first
         # time, because save is executed in the file-io thread while this runs in the current thread. -Dan
         call_in_thread('file-io',
                        notification_center.post_notification,
                        'SIPAccountManagerDidChangeDefaultAccount',
                        sender=self,
                        data=NotificationData(old_account=old_account,
                                              account=account))
コード例 #6
0
ファイル: video.py プロジェクト: AGProjects/python-sipsimple
 def end(self):
     with self._lock:
         if self.state == "ENDED" or self._done:
             return
         self._done = True
         if not self._initialized:
             self.state = "ENDED"
             self.notification_center.post_notification('MediaStreamDidNotInitialize', sender=self, data=NotificationData(reason='Interrupted'))
             return
         if self._keyframe_timer is not None:
             self._keyframe_timer.stop()
             self.notification_center.remove_observer(self, sender=self._keyframe_timer)
         self._keyframe_timer = None
         self.notification_center.post_notification('MediaStreamWillEnd', sender=self)
         if self._transport is not None:
             self.notification_center.remove_observer(self, sender=self._transport)
             self.notification_center.remove_observer(self, sender=self._rtp_transport)
             call_in_thread('device-io', self._transport.stop)
             self._transport = None
             self._rtp_transport = None
         self.state = "ENDED"
         self.notification_center.post_notification('MediaStreamDidEnd', sender=self, data=NotificationData(error=self._failure_reason))
         self.session = None
コード例 #7
0
 def paste_(self, sender):
     pasteboard = NSPasteboard.generalPasteboard()
     digits = pasteboard.stringForType_("public.utf8-plain-text")
     dtmf_match_regexp = re.compile("^([0-9]#*)+$")
     if digits and dtmf_match_regexp.match(digits):
         call_in_thread('dtmf-io', self.send_dtmf, digits)
コード例 #8
0
 def _NH_SIPApplicationDidStart(self, notification):
     settings = SIPSimpleSettings()
     self.debug = settings.gui.extended_debug
     settings.audio.enable_aec = settings.audio.echo_canceller.enabled
     settings.audio.sound_card_delay = settings.audio.echo_canceller.tail_length
     call_in_thread('file-io', self.purge_temporary_files)
コード例 #9
0
 def _NH_SIPApplicationWillEnd(self, notification):
     call_in_thread('file-io', self.purge_temporary_files)
コード例 #10
0
 def paste_(self, sender):
     pasteboard = NSPasteboard.generalPasteboard()
     digits = pasteboard.stringForType_("public.utf8-plain-text")
     dtmf_match_regexp = re.compile("^([0-9]#*)+$")
     if digits and dtmf_match_regexp.match(digits):
         call_in_thread('dtmf-io', self.send_dtmf, digits)