def __init__(self, videoWindowController): self.videoWindowController = videoWindowController self.log_debug('Init %s' % self) if self.finished: self._finish_close() return from VideoWindowController import TitleBarView NSBundle.loadNibNamed_owner_("VideoLocalWindow", self) self.window().center() title = NSLocalizedString("Video with %s", "Window title") % self.videoWindowController.title NSApplication.sharedApplication().addWindowsItem_title_filename_(self.window(), title, False) self.window().setTitle_(title) self.window().setLevel_(NSFloatingWindowLevel) themeFrame = self.window().contentView().superview() self.titleBarView = LocalTitleBarView.alloc().init() topmenu_frame = self.titleBarView.view.frame() self.disconnectLabel.superview().hide() newFrame = NSMakeRect( 0, themeFrame.frame().size.height - topmenu_frame.size.height, themeFrame.frame().size.width, topmenu_frame.size.height) self.titleBarView.view.setFrame_(newFrame) themeFrame.addSubview_(self.titleBarView.view) self.titleBarView.textLabel.setHidden_(False) self.updateTrackingAreas() self.videoView.setProducer(SIPApplication.video_device.producer) self.notification_center = NotificationCenter() self.notification_center.add_observer(self, name="VideoDeviceDidChangeCamera")
def initWithAccount_target_name_(self, account, target, display_name): self = super(SMSViewController, self).init() if self: self.notification_center = NotificationCenter() self.account = account self.target_uri = target self.display_name = display_name self.queue = [] self.messages = {} self.history=ChatHistory() self.local_uri = '%s@%s' % (account.id.username, account.id.domain) self.remote_uri = '%s@%s' % (self.target_uri.user, self.target_uri.host) 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_("%i chars left" % MAX_MESSAGE_LENGTH) return self
def init(self): if self: NSBundle.loadNibNamed_owner_("EnrollmentWindow", self) icloud_sync_enabled = NSUserDefaults.standardUserDefaults().stringForKey_("iCloudSyncEnabled") self.syncWithiCloudCheckbox.setHidden_(not icloud_sync_enabled) self.selectRadio_(self.radioMatrix) if not SIPManager().validateAddAccountAction(): self.nextButton.setEnabled_(False) self.purchaseProLabel.setHidden_(False) if NSApp.delegate().contactsWindowController.first_run: NotificationCenter().add_observer(self, name='SIPAccountManagerDidAddAccount') if NSApp.delegate().allowed_domains: self.allowed_domains = NSApp.delegate().allowed_domains self.syncWithiCloudCheckbox.setHidden_(True) self.syncWithiCloudCheckbox.setState_(NSOffState) self.domainButton.setHidden_(True) self.addressText.cell().setPlaceholderString_('user@' + self.allowed_domains[0]) if not NSApp.delegate().icloud_enabled: self.syncWithiCloudCheckbox.setHidden_(True) return self
def initWithFrame_oldTransfer_(self, frame, transferInfo): self = NSView.initWithFrame_(self, frame) if self: self.oldTransferInfo = transferInfo NSBundle.loadNibNamed_owner_("FileTransferItemView", self) filename = transferInfo.file_path if filename.endswith(".download"): filename = filename[:-len(".download")] self.updateIcon(NSWorkspace.sharedWorkspace().iconForFile_(filename)) self.nameText.setStringValue_(os.path.basename(filename)) self.fromText.setStringValue_('To %s' % transferInfo.remote_uri if transferInfo.direction=='outgoing' else 'From %s' % transferInfo.remote_uri) if transferInfo.status == "completed": status = "%s %s Completed"%(format_size(transferInfo.file_size, 1024), unichr(0x2014)) else: error = transferInfo.status if transferInfo.direction == "outgoing": status = error else: status = "%s of %s"%(format_size(transferInfo.bytes_transfered, 1024), format_size(transferInfo.file_size, 1024)) status = "%s %s %s"%(status, unichr(0x2014), error) self.sizeText.setStringValue_(status) frame.size = self.view.frame().size self.setFrame_(frame) self.addSubview_(self.view) self.relayoutForDone() self.done = True return self
def __init__(self, image): NSBundle.loadNibNamed_owner_("ScreensharingPreviewPanel", self) self.view.setImage_(image) self.timer = NSTimer.timerWithTimeInterval_target_selector_userInfo_repeats_(5.0, self, "closeTimer:", None, False) NSRunLoop.currentRunLoop().addTimer_forMode_(self.timer, NSModalPanelRunLoopMode) NSRunLoop.currentRunLoop().addTimer_forMode_(self.timer, NSDefaultRunLoopMode) self.window.orderFront_(None)
def __init__(self): if self: BlinkLogger().log_debug('Starting History Viewer') NSBundle.loadNibNamed_owner_("HistoryViewer", self) self.all_contacts = BlinkHistoryViewerContact('Any Address', name='All Contacts') self.bonjour_contact = BlinkHistoryViewerContact('bonjour.local', name='Bonjour Neighbours', icon=NSImage.imageNamed_("NSBonjour")) self.notification_center = NotificationCenter() self.notification_center.add_observer(self, name='ChatViewControllerDidDisplayMessage') self.notification_center.add_observer(self, name='AudioCallLoggedToHistory') self.notification_center.add_observer(self, name='BlinkContactsHaveChanged') self.notification_center.add_observer(self, name='BlinkTableViewSelectionChaged') self.notification_center.add_observer(self, name='BlinkConferenceContactPresenceHasChanged') self.notification_center.add_observer(self, name='BlinkShouldTerminate') self.searchText.cell().setSendsSearchStringImmediately_(True) self.searchText.cell().setPlaceholderString_(NSLocalizedString("Type text and press Enter", "Placeholder text")) self.chatViewController.setContentFile_(NSBundle.mainBundle().pathForResource_ofType_("ChatView", "html")) self.chatViewController.setHandleScrolling_(False) self.entriesView.setShouldCloseWithWindow_(False) for c in ('remote_uri', 'local_uri', 'date', 'type'): col = self.indexTable.tableColumnWithIdentifier_(c) descriptor = NSSortDescriptor.alloc().initWithKey_ascending_(c, True) col.setSortDescriptorPrototype_(descriptor) self.chat_history = ChatHistory() self.session_history = SessionHistory() self.setPeriod(1) self.selectedTableView = self.contactTable
def __init__(self, blink_contact): NSBundle.loadNibNamed_owner_("Contact", self) self.window.setTitle_(NSLocalizedString("Edit Contact", "Window title")) self.addButton.setTitle_(NSLocalizedString("OK", "Button title")) self.dealloc_timer = None self.blink_contact = blink_contact self.belonging_groups = self.model.getBlinkGroupsForBlinkContact( blink_contact) self.all_groups = [ g for g in self.groupsList if g.group is not None and not isinstance(g.group, VirtualGroup) and g.add_contact_allowed ] self.nameText.setStringValue_(blink_contact.name or "") key = NSLocalizedString( "Public key: %s", "Label" ) % blink_contact.contact.public_key_checksum if blink_contact.contact.public_key_checksum else '' self.publicKey.setStringValue_(key) self.organizationText.setStringValue_(blink_contact.organization or "") self.photoImage.setImage_(blink_contact.icon) self.preferred_media = blink_contact.preferred_media address_types = list( item.title() for item in self.addressTypesPopUpButton.itemArray()) for item in blink_contact.contact.uris: type = format_uri_type(item.type) if type not in address_types: self.addressTypesPopUpButton.addItemWithTitle_(type) self.addButton.setEnabled_( True if blink_contact.contact.uris else False) self.default_uri = self.blink_contact.contact.uris.default self.autoanswerCheckbox.setState_( NSOnState if blink_contact.auto_answer else NSOffState) self.uris = sorted(blink_contact.contact.uris, key=lambda uri: uri.position if uri.position is not None else sys.maxsize) # TODO: how to handle xmmp: uris? #for uri in self.uris: #if uri.type is not None and uri.type.lower() == 'xmpp' and ';xmpp' in uri.uri: # uri.uri = uri.uri.replace(';xmpp', '') self.update_default_uri() self.addressTable.reloadData() self.subscriptions = { 'presence': { 'subscribe': blink_contact.contact.presence.subscribe, 'policy': blink_contact.contact.presence.policy }, 'dialog': { 'subscribe': blink_contact.contact.dialog.subscribe, 'policy': blink_contact.contact.dialog.policy } } self.defaultButton.setEnabled_(False) self.updateSubscriptionMenus() self.updatePreferredMediaMenus() self.loadGroupNames()
def init(self): if self: NSBundle.loadNibNamed_owner_("EnrollmentWindow", self) icloud_sync_enabled = NSUserDefaults.standardUserDefaults().stringForKey_("iCloudSyncEnabled") self.syncWithiCloudCheckbox.setHidden_(not icloud_sync_enabled) self.selectRadio_(self.radioMatrix) if not SIPManager().validateAddAccountAction(): self.nextButton.setEnabled_(False) self.purchaseProLabel.setHidden_(False) if NSApp.delegate().contactsWindowController.first_run: NotificationCenter().add_observer(self, name='SIPAccountManagerDidAddAccount') if NSApp.delegate().applicationName == 'SIP2SIP': self.allowed_domains = ['sip2sip.info'] self.syncWithiCloudCheckbox.setHidden_(True) self.syncWithiCloudCheckbox.setState_(NSOffState) self.domainButton.setHidden_(True) self.addressText.cell().setPlaceholderString_('*****@*****.**') if NSApp.delegate().applicationName == 'Blink': self.syncWithiCloudCheckbox.setHidden_(True) return self
def initWithFrame_oldTransfer_(self, frame, transferInfo): self = NSView.initWithFrame_(self, frame) if self: self.oldTransferInfo = transferInfo NSBundle.loadNibNamed_owner_("FileTransferItemView", self) filename = transferInfo.file_path if filename.endswith(".download"): filename = filename[:-len(".download")] self.updateIcon(NSWorkspace.sharedWorkspace().iconForFile_(filename)) self.nameText.setStringValue_(os.path.basename(filename)) self.fromText.setStringValue_('To %s from account %s' % (transferInfo.remote_uri, transferInfo.local_uri) if transferInfo.direction=='outgoing' else 'From %s to account %s' % (transferInfo.remote_uri, transferInfo.local_uri)) time_print = format_date(transferInfo.time) if transferInfo.status == "completed": t = NSLocalizedString("Completed transfer of ", "Label") status = t + "%s %s" % (format_size(transferInfo.file_size, 1024), time_print) else: if transferInfo.direction == "outgoing": status = '%s %s' % (transferInfo.status.title(), time_print) self.retryButton.setHidden_(False) else: #status = "%s of %s"%(format_size(transferInfo.bytes_transfered, 1024), format_size(transferInfo.file_size, 1024)) status = "%s %s" % (transferInfo.status.title(), time_print) self.sizeText.setStringValue_(status) frame.size = self.view.frame().size self.setFrame_(frame) self.addSubview_(self.view) self.relayoutForDone() self.done = True return self
def __init__(self): if self: BlinkLogger().log_debug('Starting History Viewer') NSBundle.loadNibNamed_owner_("HistoryViewer", self) self.all_contacts = BlinkHistoryViewerContact('Any Address', name=u'All Contacts') self.bonjour_contact = BlinkHistoryViewerContact('bonjour', name=u'Bonjour Neighbours', icon=NSImage.imageNamed_("NSBonjour")) self.notification_center = NotificationCenter() self.notification_center.add_observer(self, name='ChatViewControllerDidDisplayMessage') self.notification_center.add_observer(self, name='AudioCallLoggedToHistory') self.notification_center.add_observer(self, name='BlinkContactsHaveChanged') self.notification_center.add_observer(self, name='BlinkTableViewSelectionChaged') self.notification_center.add_observer(self, name='BlinkConferenceContactPresenceHasChanged') self.notification_center.add_observer(self, name='BlinkShouldTerminate') self.searchText.cell().setSendsSearchStringImmediately_(True) self.searchText.cell().setPlaceholderString_(NSLocalizedString("Type text and press Enter", "Placeholder text")) self.chatViewController.setContentFile_(NSBundle.mainBundle().pathForResource_ofType_("ChatView", "html")) self.chatViewController.setHandleScrolling_(False) self.entriesView.setShouldCloseWithWindow_(False) for c in ('remote_uri', 'local_uri', 'date', 'type'): col = self.indexTable.tableColumnWithIdentifier_(c) descriptor = NSSortDescriptor.alloc().initWithKey_ascending_(c, True) col.setSortDescriptorPrototype_(descriptor) self.chat_history = ChatHistory() self.session_history = SessionHistory() self.setPeriod(1) self.selectedTableView = self.contactTable
def __init__(self, target=None, default_domain=None): self._participants = [] self.default_domain = default_domain NSBundle.loadNibNamed_owner_("AddParticipantsWindow", self) if target is not None: self.target.setStringValue_(target) self.target.setHidden_(False)
def __init__(self, target=None, default_domain=None): self._participants = [] self.default_domain = default_domain NSBundle.loadNibNamed_owner_("AddParticipantsWindow", self) if target is not None: self.target.setStringValue_(target) self.target.setHidden_(False)
def orderFrontAboutPanel_(self, sender): if not self.aboutPanel: NSBundle.loadNibNamed_owner_("About", self) self.aboutVersion.setStringValue_(self.about_version) self.aboutSlogan.setStringValue_(self.about_slogan) self.aboutIcon.setImage_(NSImage.imageNamed_(self.about_image)) self.aboutCopyright.setStringValue_(self.about_copyright) self.aboutPanel.makeKeyAndOrderFront_(None)
def initWithOwner_(self, owner): self= super(SMSWindowController, self).init() if self: self._owner = owner NSBundle.loadNibNamed_owner_("SMSSession", self) self.notification_center = NotificationCenter() self.notification_center.add_observer(self, name="BlinkShouldTerminate") self.unreadMessageCounts = {} return self
def __init__(self, videoWindowController): self.videoWindowController = videoWindowController self.log_debug('Init %s' % self) NSBundle.loadNibNamed_owner_("VideoControlPanel", self) self.window().setTitle_(self.videoWindowController.title) self.notification_center = NotificationCenter() self.notification_center.add_observer(self,sender=self.videoWindowController) self.notification_center.add_observer(self, name='BlinkMuteChangedState') self.updateButtons()
def init(self): self = super(PhotoPicker, self).init() if self: NSBundle.loadNibNamed_owner_("PhotoPicker", self) self.lock = NSLock.alloc().init() self.captureButton.setHidden_(True) self.previewButton.setHidden_(False) self.cancelButton.setHidden_(True) return self
def __init__(self, image): NSBundle.loadNibNamed_owner_("ScreensharingPreviewPanel", self) self.view.setImage_(image) self.timer = NSTimer.timerWithTimeInterval_target_selector_userInfo_repeats_( 5.0, self, "closeTimer:", None, False) NSRunLoop.currentRunLoop().addTimer_forMode_(self.timer, NSModalPanelRunLoopMode) NSRunLoop.currentRunLoop().addTimer_forMode_(self.timer, NSDefaultRunLoopMode) self.window.orderFront_(None)
def __init__(self, controller): NSBundle.loadNibNamed_owner_("ChatOtrSmp", self) self.controller = controller self.statusText.setStringValue_('') self.progressBar.startAnimation_(None) self.window.setTitle_(NSLocalizedString("Identity Verification for %s", "Window title") % self.controller.sessionController.titleShort) self.stream = self.controller.stream self.remote_address = self.controller.sessionController.remoteAOR NSNotificationCenter.defaultCenter().addObserver_selector_name_object_(self, "controlTextDidChange:", NSControlTextDidChangeNotification, self.secretText)
def initWithOwner_(self, owner): self = objc.super(SMSWindowController, self).init() if self: self._owner = owner NSBundle.loadNibNamed_owner_("SMSSession", self) self.notification_center = NotificationCenter() self.notification_center.add_observer(self, name="BlinkShouldTerminate") self.unreadMessageCounts = {} return self
def __init__(self, target=None, participants=[], media_type=["chat"], default_domain=None, autostart=False): NSBundle.loadNibNamed_owner_("JoinConferenceWindow", self) self.autostart = autostart self.notification_center = NotificationCenter() self.notification_center.add_observer( self, name='BonjourConferenceServicesDidRemoveServer') self.notification_center.add_observer( self, name='BonjourConferenceServicesDidUpdateServer') self.notification_center.add_observer( self, name='BonjourConferenceServicesDidAddServer') self.notification_center.add_observer( self, name='SIPAccountManagerDidChangeDefaultAccount') self.startWhenParticipantsAvailable.setEnabled_(False) self.storage_path = ApplicationData.get('conference/rooms.pickle') self.selected_configuration = None self.default_domain = default_domain self.nickname = None if target is not None and "@" not in target and self.default_domain: target = '%s@%s' % (target, self.default_domain) if target is not None and validateParticipant(target): self.room.setStringValue_(target) account = AccountManager().default_account if account is not None: self.nickname_textfield.setStringValue_(account.conference.nickname or account.display_name) if participants: self._participants = participants else: self._participants = [] self.participantsTable.reloadData() self.removeAllParticipants.setHidden_( False if len(self._participants) > 1 else True) if media_type: self.audio.setState_(NSOnState if "audio" in media_type else NSOffState) self.chat.setState_(NSOnState if "chat" in media_type else NSOffState) self.updatePopupButtons()
def init(self): NotificationCenter().add_observer(self, name="BlinkFileTransferInitializing") NotificationCenter().add_observer(self, name="BlinkFileTransferRestarting") NotificationCenter().add_observer(self, name="BlinkFileTransferDidFail") NotificationCenter().add_observer(self, name="BlinkFileTransferDidEnd") NotificationCenter().add_observer(self, name="BlinkFileTransferSpeedDidUpdate") NotificationCenter().add_observer(self, name="BlinkShouldTerminate") NSBundle.loadNibNamed_owner_("FileTransferWindow", self) self.transferSpeed.setStringValue_("") return self
def __init__(self): if self: NotificationCenter().add_observer(self, name="BlinkFileTransferInitializing") NotificationCenter().add_observer(self, name="BlinkFileTransferRestarting") NotificationCenter().add_observer(self, name="BlinkFileTransferDidFail") NotificationCenter().add_observer(self, name="BlinkFileTransferDidEnd") NotificationCenter().add_observer(self, name="BlinkFileTransferSpeedDidUpdate") NotificationCenter().add_observer(self, name="BlinkShouldTerminate") NSBundle.loadNibNamed_owner_("FileTransferWindow", self) self.transferSpeed.setStringValue_('') self.load_transfers_from_history()
def init(self): self = objc.super(MyVideoWindowController, self).init() if self: print("loading local window") NSBundle.loadNibNamed_owner_("MyVideoLocalWindow", self) self.window().setAlphaValue_(ALPHA) self.window().setLevel_(NSFloatingWindowLevel) self.window().closeButton.setHidden_(True) self.updateTrackingAreas() self.notification_center = NotificationCenter() self.notification_center.add_observer(self, name="VideoDeviceDidChangeCamera") return self
def startOutgoing(self, is_update): if self.direction == "active": # viewer # open viewer self.sessionController.log_info("Requesting access to remote screen") else: self.sessionController.log_info("Sharing local screen...") NSBundle.loadNibNamed_owner_("ScreenServerWindow", self) self.statusProgress.startAnimation_(None) self.statusWindow.setTitle_("Screen Sharing with %s" % self.sessionController.getTitleShort()) #self.statusItem.show(self) NotificationCenter().add_observer(self, sender=self.stream.handler) NotificationCenter().add_observer(self, sender=self.stream) self.changeStatus(STREAM_PROPOSING if is_update else STREAM_CONNECTING)
def __init__(self, account, encryptedKeyPair): NSBundle.loadNibNamed_owner_("ImportPrivateKeyWindow", self) self.account = account self.encryptedKeyPair = encryptedKeyPair self.checksum.setStringValue_('') self.importButton.setEnabled_(False) self.window.makeFirstResponder_(self.pincode) self.status.setTextColor_(NSColor.blackColor()) self.status.setStringValue_( NSLocalizedString("Enter pincode to decrypt the key", "status label"))
def initWithOwner_(self, owner): self = super(ConferenceScreenSharing, self).init() if self: self.owner = owner NSBundle.loadNibNamed_owner_("ConferenceScreenSharing", self) self.screensharing_fit_window = True self.screensharing_uri = None self.screensharing_url = None self.display_name = None self.webView.setShouldCloseWithWindow_(True) NotificationCenter().add_observer(self, name='SIPSessionGotConferenceInfo') return self
def initWithFrame_transfer_(self, frame, transfer): self = NSView.initWithFrame_(self, frame) if self: self.transfer = transfer NotificationCenter().add_observer(self, sender=transfer) NSBundle.loadNibNamed_owner_("FileTransferItemView", self) self.file_path = os.path.basename(self.transfer.ft_info.file_path) self.nameText.setStringValue_(self.file_path) self.remote_uri = self.transfer.ft_info.remote_uri self.local_uri = self.transfer.ft_info.local_uri if type(self.transfer) == OutgoingPushFileTransferHandler: self.fromText.setStringValue_("To: %s" % self.transfer.account.id) else: self.fromText.setStringValue_("From: %s" % self.transfer.account.id) self.revealButton.setHidden_(True) # XXX: there should be a better way to do this! tmp_folder = ApplicationData.get('.tmp_file_transfers') makedirs(tmp_folder, 0o700) tmpf = tmp_folder + "/tmpf-" + self.file_path.decode( ) if isinstance(self.file_path, bytes) else self.file_path with open(tmpf, "wb+"): self.updateIcon( NSWorkspace.sharedWorkspace().iconForFile_(tmpf)) unlink(tmpf) self.updateProgressInfo() self.progressBar.setIndeterminate_(True) self.progressBar.startAnimation_(None) self.checksumProgressBar.setIndeterminate_(False) self.checksumProgressBar.startAnimation_(None) if transfer.direction == 'outgoing': self.progressBar.setHidden_(True) self.checksumProgressBar.setHidden_(False) else: self.progressBar.setHidden_(False) self.checksumProgressBar.setHidden_(True) frame.size = self.view.frame().size self.setFrame_(frame) self.addSubview_(self.view) self.originalHeight = NSHeight(frame) return self
def init(self): self = super(AlertPanel, self).init() if self: NSBundle.loadNibNamed_owner_("AlertPanel", self) self.panel.setLevel_(3000) self.panel.setWorksWhenModal_(True) self.extraHeight = self.panel.contentRectForFrameRect_(self.panel.frame()).size.height - self.sessionsListView.frame().size.height self.sessionsListView.setSpacing_(2) NotificationCenter().add_observer(self, name="CFGSettingsObjectDidChange") self.init_speech_recognition() self.init_speech_synthesis() return self
def initWithOwner_(self, owner): self = objc.super(ConferenceScreenSharing, self).init() if self: self.owner = owner NSBundle.loadNibNamed_owner_("ConferenceScreenSharing", self) self.screensharing_fit_window = True self.screensharing_uri = None self.screensharing_url = None self.display_name = None self.webView.setShouldCloseWithWindow_(True) NotificationCenter().add_observer( self, name='SIPSessionGotConferenceInfo') return self
def startIncoming(self, is_update): if self.direction == "active": # viewer # open viewer self.sessionController.log_info("Preparing to view remote screen") self.stream.handler = ExternalVNCViewerHandler() else: self.sessionController.log_info("Sharing local screen...") self.stream.handler = ExternalVNCServerHandler(("localhost", self.vncServerPort)) NSBundle.loadNibNamed_owner_("ScreenServerWindow", self) self.statusProgress.startAnimation_(None) self.statusWindow.setTitle_("Screen Sharing with %s" % self.sessionController.getTitleShort()) #self.statusItem.show(self) NotificationCenter().add_observer(self, sender=self.stream.handler) NotificationCenter().add_observer(self, sender=self.stream) self.changeStatus(STREAM_INCOMING)
def init(self): self = super(VideoMirrorWindowController, self).init() if self: NSBundle.loadNibNamed_owner_("VideoMirrowWindow", self) userdef = NSUserDefaults.standardUserDefaults() savedFrame = userdef.stringForKey_("NSWindow Frame MirrorWindow") if savedFrame: x, y, w, h = str(savedFrame).split()[:4] frame = NSMakeRect(int(x), int(y), int(w), int(h)) self.window.setFrame_display_(frame, True) self.window.setAlphaValue_(0.9) return self
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
def __init__(self, storage_folder=ApplicationData.get('photos'), high_res=False, history=True): self.history = history NSBundle.loadNibNamed_owner_("PhotoPicker", self) self.lock = NSLock.alloc().init() self.captureButton.setHidden_(True) self.previewButton.setHidden_(False) self.countdownCheckbox.setHidden_(True) self.storage_folder = storage_folder self.high_res = high_res if self.high_res: self.photoView.setCropSize_() if not self.history: self.tabView.selectTabViewItem_(self.cameraTabView) self.previewButton.setHidden_(True) self.countdownCheckbox.setHidden_(False) self.captureButton.setHidden_(False)
def orderFrontAboutPanel_(self, sender): if not self.aboutPanel: NSBundle.loadNibNamed_owner_("About", self) version = str(NSBundle.mainBundle().infoDictionary().objectForKey_("CFBundleShortVersionString")) build = str(NSBundle.mainBundle().infoDictionary().objectForKey_("CFBundleVersion")) vdate = str(NSBundle.mainBundle().infoDictionary().objectForKey_("BlinkVersionDate")) if self.applicationName == 'Blink Pro': self.aboutVersion.setStringValue_("Version Pro %s build %s\n%s" % (version, build, vdate)) elif self.applicationName == 'Blink Lite': self.aboutVersion.setStringValue_("Version Lite %s build %s\n%s" % (version, build, vdate)) else: self.aboutVersion.setStringValue_("Version %s\n%s" % (version, vdate)) if self.applicationName == 'SIP2SIP': self.aboutSlogan.setStringValue_(NSLocalizedString("Special edition of Blink SIP Client for SIP2SIP", "About panel label")) self.aboutPanel.makeKeyAndOrderFront_(None)
def init(self): self = super(VideoNativeLocalWindowController, self).init() if self: NSBundle.loadNibNamed_owner_("VideoNativeLocalWindow", self) userdef = NSUserDefaults.standardUserDefaults() savedFrame = userdef.stringForKey_("NSWindow Frame MirrorWindow") if savedFrame: x, y, w, h = str(savedFrame).split()[:4] frame = NSMakeRect(int(x), int(y), int(w), int(h)) self.window().setFrame_display_(frame, True) self.window().setAlphaValue_(ALPHA) self.window().setLevel_(NSFloatingWindowLevel) self.window().closeButton.setHidden_(True) self.updateTrackingAreas() return self
def initWithFrame_transfer_(self, frame, transfer): self = NSView.initWithFrame_(self, frame) if self: self.transfer = transfer NotificationCenter().add_observer(self, sender=transfer) NSBundle.loadNibNamed_owner_("FileTransferItemView", self) filename = self.transfer.file_path if type(self.transfer) == OutgoingPushFileTransferHandler: self.fromText.setStringValue_(u"To: %s" % self.transfer.account.id) else: if filename.endswith(".download"): filename = filename[:-len(".download")] self.fromText.setStringValue_(u"From: %s" % self.transfer.account.id) self.nameText.setStringValue_(os.path.basename(filename)) if os.path.exists(filename): self.updateIcon(NSWorkspace.sharedWorkspace().iconForFile_(filename)) else: tmp_folder = ApplicationData.get('.tmp_file_transfers') if not os.path.exists(tmp_folder): os.mkdir(tmp_folder, 0700) tmpf = tmp_folder + "/tmpf" + os.path.splitext(filename)[1] open(tmpf, "w+").close() self.updateIcon(NSWorkspace.sharedWorkspace().iconForFile_(tmpf)) os.remove(tmpf) self.updateProgressInfo() self.progressBar.setIndeterminate_(True) self.progressBar.startAnimation_(None) self.progressBar.setHidden_(True) self.checksumProgressBar.setIndeterminate_(False) self.checksumProgressBar.startAnimation_(None) self.checksumProgressBar.setHidden_(False) frame.size = self.view.frame().size self.setFrame_(frame) self.addSubview_(self.view) self.originalHeight = NSHeight(frame) return self
def __init__(self, target=None, participants=[], media_type=["chat"], default_domain=None, autostart=False): NSBundle.loadNibNamed_owner_("JoinConferenceWindow", self) self.autostart = autostart self.notification_center = NotificationCenter() self.notification_center.add_observer(self, name='BonjourConferenceServicesDidRemoveServer') self.notification_center.add_observer(self, name='BonjourConferenceServicesDidUpdateServer') self.notification_center.add_observer(self, name='BonjourConferenceServicesDidAddServer') self.notification_center.add_observer(self, name='SIPAccountManagerDidChangeDefaultAccount') self.startWhenParticipantsAvailable.setEnabled_(False) self.selected_configuration = None self.default_domain = default_domain self.nickname = None if target is not None and "@" not in target and self.default_domain: target = '%s@%s' % (target, self.default_domain) if target is not None and validateParticipant(target): self.room.setStringValue_(target) account = AccountManager().default_account if account is not None: if account.conference.nickname: self.nickname_textfield.setStringValue_(account.conference.nickname) else: self.nickname_textfield.cell().setPlaceholderString_(account.display_name) if participants: self._participants = participants else: self._participants = [] self.participantsTable.reloadData() self.removeAllParticipants.setHidden_(False if len(self._participants) > 1 else True) if media_type: self.audio.setState_(NSOnState if "audio" in media_type else NSOffState) self.chat.setState_(NSOnState if "chat" in media_type else NSOffState) self.updatePopupButtons()
def __init__(self): if self: notification_center = NotificationCenter() notification_center.add_observer( self, name="BlinkFileTransferNewOutgoing") notification_center.add_observer( self, name="BlinkFileTransferNewIncoming") notification_center.add_observer( self, name="BlinkFileTransferWillRestart") notification_center.add_observer(self, name="BlinkFileTransferDidEnd") notification_center.add_observer( self, name="BlinkFileTransferSpeedDidUpdate") notification_center.add_observer(self, name="BlinkShouldTerminate") NSBundle.loadNibNamed_owner_("FileTransferWindow", self) self.transferSpeed.setStringValue_('') self.load_transfers_from_history()
def initWithFrame_oldTransfer_(self, frame, transferInfo): self = NSView.initWithFrame_(self, frame) if self: self.oldTransferInfo = transferInfo self.file_path = transferInfo.file_path self.remote_uri = transferInfo.remote_uri self.local_uri = transferInfo.local_uri NSBundle.loadNibNamed_owner_("FileTransferItemView", self) self.updateIcon(NSWorkspace.sharedWorkspace().iconForFile_( self.file_path)) self.nameText.setStringValue_(os.path.basename(self.file_path)) self.fromText.setStringValue_( 'To %s from account %s' % (transferInfo.remote_uri, transferInfo.local_uri) if transferInfo.direction == 'outgoing' else 'From %s to account %s' % (transferInfo.remote_uri, transferInfo.local_uri)) self.revealButton.setHidden_(not os.path.exists(self.file_path)) time_print = format_date(transferInfo.time) if transferInfo.status == "completed": self.sizeText.setTextColor_(NSColor.blueColor()) t = NSLocalizedString("Completed transfer of ", "Label") status = t + "%s %s" % (format_size(transferInfo.file_size, 1024), time_print) else: self.sizeText.setTextColor_(NSColor.redColor()) status = "%s %s" % (transferInfo.status.title(), time_print) self.sizeText.setStringValue_(status) frame.size = self.view.frame().size self.setFrame_(frame) self.addSubview_(self.view) self.relayoutForDone() if transferInfo.direction == "outgoing" and transferInfo.status != "completed" and os.path.exists( self.file_path): self.retryButton.setHidden_(False) self.done = True return self
def __init__(self, uri=None, name=None, group=None, type=None): NSBundle.loadNibNamed_owner_("Contact", self) self.window.setTitle_(NSLocalizedString("Add Contact", "Window title")) self.dealloc_timer = None self.default_uri = None self.preferred_media = 'audio' self.uris = [ContactURI(uri=uri, type=format_uri_type(type))] if uri else [] self.update_default_uri() self.subscriptions = {'presence': {'subscribe': True, 'policy': 'allow'}, 'dialog': {'subscribe': False, 'policy': 'block'}} self.all_groups = [g for g in self.groupsList if g.group is not None and not isinstance(g.group, VirtualGroup) and g.add_contact_allowed] self.belonging_groups = [] if group is not None: self.belonging_groups.append(group) self.nameText.setStringValue_(name or "") self.photoImage.setImage_(self.defaultPhotoImage) self.defaultButton.setEnabled_(False) self.updateSubscriptionMenus() self.loadGroupNames() self.addButton.setEnabled_(True if self.uris else False)
def startOutgoing(self, is_update): if self.direction == "active": self.sessionController.log_info("Requesting remote screen...") else: self.sessionController.log_info("Offering local screen...") NSBundle.loadNibNamed_owner_("ScreenServerWindow", self) self.statusProgress.startAnimation_(None) self.statusWindow.setTitle_( NSLocalizedString("Screen Sharing with %s", "Window title") % self.sessionController.titleShort) settings = SIPSimpleSettings() if not settings.logs.trace_msrp: settings.logs.trace_msrp = True settings.save() self.must_reset_trace_msrp = True NotificationCenter().add_observer(self, name="MSRPTransportTrace") #self.statusItem.show(self) NotificationCenter().add_observer(self, sender=self.stream.handler) NotificationCenter().add_observer(self, sender=self.stream) self.changeStatus(STREAM_PROPOSING if is_update else STREAM_CONNECTING)
def init(self): self = super(DebugWindow, self).init() NSBundle.loadNibNamed_owner_("DebugWindow", self) for textView in [self.activityTextView, self.sipTextView, self.rtpTextView, self.msrpTextView, self.xcapTextView, self.pjsipTextView]: textView.setString_("") for label in [self.activityInfoLabel, self.sipInfoLabel, self.rtpInfoLabel, self.msrpInfoLabel, self.xcapInfoLabel, self.notificationsInfoLabel, self.pjsipInfoLabel]: label.setStringValue_('') BlinkLogger().set_gui_logger(self.renderActivity) settings = SIPSimpleSettings() notification_center = NotificationCenter() notification_center.add_observer(self, name="CFGSettingsObjectDidChange") notification_center.add_observer(self, name="SIPSessionDidStart") notification_center.add_observer(self, name="SIPEngineSIPTrace") notification_center.add_observer(self, name="MSRPLibraryLog") notification_center.add_observer(self, name="MSRPTransportTrace") notification_center.add_observer(self, name="SIPEngineLog") notification_center.add_observer(self, name="SIPSessionDidRenegotiateStreams") notification_center.add_observer(self, name="AudioSessionHasQualityIssues") notification_center.add_observer(self, name="AudioSessionQualityRestored") notification_center.add_observer(self, name="AudioStreamICENegotiationDidSucceed") notification_center.add_observer(self, name="AudioStreamICENegotiationDidFail") notification_center.add_observer(self, name="VideoStreamICENegotiationDidSucceed") notification_center.add_observer(self, name="VideoStreamICENegotiationDidFail") if settings.logs.trace_notifications_in_gui: notification_center.add_observer(self) self.sipRadio.selectCellWithTag_(settings.logs.trace_sip_in_gui or Disabled) self.msrpRadio.selectCellWithTag_(settings.logs.trace_msrp_in_gui or Disabled) self.xcapRadio.selectCellWithTag_(settings.logs.trace_xcap_in_gui or Disabled) self.pjsipCheckBox.setState_(NSOnState if settings.logs.trace_pjsip_in_gui else NSOffState) self.notificationsCheckBox.setState_(NSOnState if settings.logs.trace_notifications_in_gui else NSOffState) return self
def __init__(self, controller, type='chat'): self.controller = controller NSBundle.loadNibNamed_owner_("ChatOtrSmp", self) self.statusText.setStringValue_('') self.progressBar.startAnimation_(None) if type == 'chat': _t = self.controller.sessionController.getTitleShort() self.window.setTitle_(NSLocalizedString("Identity Verification for %s", "Window title") % _t) self.stream = self.controller.stream self.remote_address = self.controller.sessionController.remoteSIPAddress self.otr_context_id = self.controller.sessionController.call_id elif type == 'sms': _t = format_identity_to_string(self.controller.target_uri) self.window.setTitle_(NSLocalizedString("Identity Verification for %s", "Window title") % _t) self.stream = self.controller self.remote_address = self.controller.remote_uri self.otr_context_id = self.controller.session_id else: self.stream = None self.remote_address = '' self.otr_context_id = ''
def __init__(self, blink_contact): NSBundle.loadNibNamed_owner_("Contact", self) self.window.setTitle_(NSLocalizedString("Edit Contact", "Window title")) self.addButton.setTitle_(NSLocalizedString("OK", "Button title")) self.dealloc_timer = None self.blink_contact = blink_contact self.belonging_groups = self.model.getBlinkGroupsForBlinkContact(blink_contact) self.all_groups = [g for g in self.groupsList if g.group is not None and not isinstance(g.group, VirtualGroup) and g.add_contact_allowed] self.nameText.setStringValue_(blink_contact.name or "") self.photoImage.setImage_(blink_contact.icon) self.preferred_media = blink_contact.preferred_media address_types = list(item.title() for item in self.addressTypesPopUpButton.itemArray()) for item in blink_contact.contact.uris: type = format_uri_type(item.type) if type not in address_types: self.addressTypesPopUpButton.addItemWithTitle_(type) self.addButton.setEnabled_(True if blink_contact.contact.uris else False) self.default_uri = blink_contact.default_uri self.uris = list(blink_contact.contact.uris) # TODO: how to handle xmmp: uris? #for uri in self.uris: #if uri.type is not None and uri.type.lower() == 'xmpp' and ';xmpp' in uri.uri: # uri.uri = uri.uri.replace(';xmpp', '') self.update_default_uri() self.addressTable.reloadData() self.subscriptions = { 'presence': {'subscribe': blink_contact.contact.presence.subscribe, 'policy': blink_contact.contact.presence.policy}, 'dialog': {'subscribe': blink_contact.contact.dialog.subscribe, 'policy': blink_contact.contact.dialog.policy} } self.defaultButton.setEnabled_(False) self.updateSubscriptionMenus() self.updatePreferredMediaMenus() self.loadGroupNames()
def __init__(self, sessionController): self.notification_center = NotificationCenter() self.sessionController = None self.audio_stream = None self.chat_stream = None self.add_session(sessionController) self.add_audio_stream() self.add_chat_stream() self.timer = NSTimer.timerWithTimeInterval_target_selector_userInfo_repeats_(1.0, self, "updateTimer:", None, True) NSRunLoop.currentRunLoop().addTimer_forMode_(self.timer, NSModalPanelRunLoopMode) NSRunLoop.currentRunLoop().addTimer_forMode_(self.timer, NSDefaultRunLoopMode) NSBundle.loadNibNamed_owner_("SessionInfoPanel", self) sessionBoxTitle = NSAttributedString.alloc().initWithString_attributes_("SIP Session", NSDictionary.dictionaryWithObject_forKey_(NSColor.orangeColor(), NSForegroundColorAttributeName)) self.sessionBox.setTitle_(sessionBoxTitle) audioBoxTitle = NSAttributedString.alloc().initWithString_attributes_("Audio Stream", NSDictionary.dictionaryWithObject_forKey_(NSColor.orangeColor(), NSForegroundColorAttributeName)) self.audioBox.setTitle_(audioBoxTitle) chatBoxTitle = NSAttributedString.alloc().initWithString_attributes_("Chat Stream", NSDictionary.dictionaryWithObject_forKey_(NSColor.orangeColor(), NSForegroundColorAttributeName)) self.chatBox.setTitle_(chatBoxTitle) self.audio_rtt_graph.setLineWidth_(1.0) self.audio_rtt_graph.setLineSpacing_(1.0) self.audio_rtt_graph.setAboveLimit_(200) # if higher than 200 ms show red color self.audio_rtt_graph.setMinimumHeigth_(200) self.audio_packet_loss_graph.setLineWidth_(1.0) self.audio_packet_loss_graph.setLineSpacing_(1.0) self.audio_packet_loss_graph.setAboveLimit_(3) # if higher than 3% show red color self.audio_packet_loss_graph.setLineColor_(NSColor.greenColor()) self.audio_packet_loss_graph.setMinimumHeigth_(5) self.resetSession() self.updatePanelValues()
def __init__(self, uris=[], name=None, group=None): NSBundle.loadNibNamed_owner_("Contact", self) self.window.setTitle_(NSLocalizedString("Add Contact", "Window title")) self.dealloc_timer = None self.default_uri = None self.preferred_media = 'audio' self.uris = [] for (uri, type) in uris: self.uris.append(ContactURI(uri=uri.strip(), type=format_uri_type(type))) self.update_default_uri() self.subscriptions = {'presence': {'subscribe': True, 'policy': 'allow'}, 'dialog': {'subscribe': False, 'policy': 'block'}} self.all_groups = [g for g in self.groupsList if g.group is not None and not isinstance(g.group, VirtualGroup) and g.add_contact_allowed] self.belonging_groups = [] if group is not None: self.belonging_groups.append(group) self.nameText.setStringValue_(name or "") self.photoImage.setImage_(self.defaultPhotoImage) self.defaultButton.setEnabled_(False) self.updateSubscriptionMenus() self.loadGroupNames() self.addButton.setEnabled_(True if self.uris else False)
def __init__(self, storage_folder=ApplicationData.get('photos'), high_res=False, history=True): self.history = history NSBundle.loadNibNamed_owner_("PhotoPicker", self) self.captureButton.setHidden_(True) self.previewButton.setHidden_(False) self.countdownCheckbox.setHidden_(True) self.mirrorButton.setHidden_(True) self.storage_folder = storage_folder self.high_res = high_res settings = SIPSimpleSettings() try: self.previous_auto_rotate_cameras = settings.video.auto_rotate_cameras settings.video.auto_rotate_cameras = False settings.save() except AttributeError: pass if self.high_res: self.photoView.setCropSize_() if not self.history: self.tabView.selectTabViewItem_(self.cameraTabView) self.previewButton.setHidden_(True) #self.countdownCheckbox.setHidden_(False) self.mirrorButton.setHidden_(False) self.captureButton.setHidden_(False) self.notification_center = NotificationCenter() self.notification_center.add_observer( self, name="VideoDeviceDidChangeCamera") self.notification_center.add_observer(self, name="CameraSnapshotDidSucceed")
def LoadNib(self, nibname, path=None): if path and len(path) > 10: bundlePath = path[:path.find("/Contents/Resources/")] bundle = NSBundle.bundleWithPath_(bundlePath) nib = NSNib.alloc().initWithNibNamed_bundle_(nibname, bundle) if not nib: self.logError("Error loading nib for Class: %s" % self.__class__.__name__) result = nib.instantiateWithOwner_topLevelObjects_(self, None) try: error = bool(result[0]) except: error = bool(result) # in 10.9, the result is a bool if not error: self.logError("Error instantiating nib for Class: %s" % self.__class__.__name__) else: try: self.topLevelObjects = result[1] except: pass else: if not NSBundle.loadNibNamed_owner_(nibname, self): self.logError("Error loading %s.nib." % nibname)
def LoadNib(self, nibname, path = None): if path and len(path) > 10: bundlePath = path[:path.find("/Contents/Resources/")] bundle = NSBundle.bundleWithPath_(bundlePath) nib = NSNib.alloc().initWithNibNamed_bundle_(nibname, bundle) if not nib: self.logError("Error loading nib for Class: %s" % self.__class__.__name__) result = nib.instantiateWithOwner_topLevelObjects_(self, None) try: error = bool(result[0]) except: error = bool(result) # in 10.9, the result is a bool if not error: self.logError("Error instantiating nib for Class: %s" % self.__class__.__name__) else: try: self.topLevelObjects = result[1] except: pass else: if not NSBundle.loadNibNamed_owner_(nibname, self): self.logError("Error loading %s.nib." % nibname)
def initWithOwner_(self, owner): self = objc.super(AccountSettings, self).init() if self: self.owner = owner NSBundle.loadNibNamed_owner_("AccountSettings", self) return self
def init(self): self = objc.super(LocalTitleBarView, self).init() if self: NSBundle.loadNibNamed_owner_("VideoLocalTitleBarView", self) return self
def init(self): NSBundle.loadNibNamed_owner_("Group", self) return self
def init(self): NSBundle.loadNibNamed_owner_("PresenceOfflineWindow", self) settings = SIPSimpleSettings() note = settings.presence_state.offline_note self.nameText.setStringValue_(note or '') return self
def init(self): NSBundle.loadNibNamed_owner_("Group", self) return self
def init(self): NSBundle.loadNibNamed_owner_("Updater", self) return self
def __init__(self, streamController): NSBundle.loadNibNamed_owner_("ZRTPAuthentication", self) self.streamController = streamController
def init(self): NSBundle.loadNibNamed_owner_("Updater", self) return self
def init(self): NSBundle.loadNibNamed_owner_("Nickname", self) return self
def __init__(self): self.notification_center = NotificationCenter() NSBundle.loadNibNamed_owner_("PresenceInfoPanel", self) self.statusLabel.setStringValue_("") NotificationCenter().add_observer(self, name="BlinkContactPresenceHasChanged")
def init(self): NSBundle.loadNibNamed_owner_("BlockedContact", self) return self