コード例 #1
0
    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
コード例 #2
0
    def add_to_history(self):
        FileTransferHistory().add_transfer(
            transfer_id=self.ft_info.transfer_id,
            direction=self.ft_info.direction,
            local_uri=self.ft_info.local_uri,
            remote_uri=self.ft_info.remote_uri,
            file_path=self.ft_info.file_path,
            bytes_transfered=self.ft_info.bytes_transfered,
            file_size=self.ft_info.file_size or 0,
            status=self.ft_info.status)

        message = "<h3>%s File Transfer</h3>" % self.ft_info.direction.capitalize(
        )
        message += "<p>%s (%s)" % (self.ft_info.file_path,
                                   format_size(self.ft_info.file_size or 0))
        media_type = 'file-transfer'
        local_uri = self.ft_info.local_uri
        remote_uri = self.ft_info.remote_uri
        direction = self.ft_info.direction
        status = 'delivered' if self.ft_info.status == 'completed' else 'failed'
        cpim_from = self.ft_info.remote_uri
        cpim_to = self.ft_info.remote_uri
        timestamp = str(ISOTimestamp.now())

        ChatHistory().add_message(self.ft_info.transfer_id, media_type,
                                  local_uri, remote_uri, direction, cpim_from,
                                  cpim_to, timestamp, message, "html", "0",
                                  status)
コード例 #3
0
    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
コード例 #4
0
    def add_to_history(self, media_type, local_uri, remote_uri, direction, cpim_from, cpim_to, timestamp, message, status):
        try:
            controller = next((controller for controller in NSApp.delegate().contactsWindowController.sessionControllersManager.sessionControllers if controller.session == self.session))
        except StopIteration:
            history_id = str(uuid.uuid1())
        else:
            history_id = controller.history_id

        ChatHistory().add_message(history_id, media_type, local_uri, remote_uri, direction, cpim_from, cpim_to, timestamp, message, "html", "0", status)
コード例 #5
0
ファイル: HistoryViewer.py プロジェクト: wilane/blink-cocoa
    def __init__(self):
        if self:
            NSBundle.loadNibNamed_owner_("HistoryViewer", self)

            self.all_contacts = BlinkContact('Any Address',
                                             name=u'All Contacts')
            self.bonjour_contact = BlinkContact(
                '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.searchText.cell().setSendsSearchStringImmediately_(True)
            self.searchText.cell().setPlaceholderString_(
                "Type text and press Enter")

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

            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.history = ChatHistory()

            tag = self.afterDate.selectedItem().tag()
            if tag < 4:
                self.after_date = self.period_array[tag].strftime(
                    "%Y-%m-%d") if self.period_array[tag] else None
            else:
                self.before_date = self.period_array[tag].strftime(
                    "%Y-%m-%d") if self.period_array[tag] else None

            self.refreshViewer()

            self.selectedTableView = self.contactTable
コード例 #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
コード例 #7
0
 def add_to_history(self, media_type, local_uri, remote_uri, direction,
                    cpim_from, cpim_to, timestamp, message, status):
     ChatHistory().add_message(str(uuid.uuid1()), media_type, local_uri,
                               remote_uri, direction, cpim_from, cpim_to,
                               timestamp, message, "html", "0", status)