def awakeFromNib(self):
     smileys = SmileyManager().get_smiley_list()
     menu = self.smileyButton.menu()
     while menu.numberOfItems() > 0:
         menu.removeItemAtIndex_(0)
     bigText = NSAttributedString.alloc().initWithString_attributes_(
         " ",
         NSDictionary.dictionaryWithObject_forKey_(
             NSFont.systemFontOfSize_(16), NSFontAttributeName))
     for text, file in smileys:
         image = NSImage.alloc().initWithContentsOfFile_(file)
         if not image:
             print("cant load %s" % file)
             continue
         image.setScalesWhenResized_(True)
         image.setSize_(NSMakeSize(16, 16))
         atext = bigText.mutableCopy()
         atext.appendAttributedString_(
             NSAttributedString.alloc().initWithString_(text))
         item = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(
             text, "insertSmiley:", "")
         menu.addItem_(item)
         item.setTarget_(self)
         item.setAttributedTitle_(atext)
         item.setRepresentedObject_(
             NSAttributedString.alloc().initWithString_(text))
         item.setImage_(image)
예제 #2
0
    def _NH_MSRPTransportTrace(self, notification):
        settings = SIPSimpleSettings()
        if settings.logs.trace_msrp_in_gui == Disabled:
            return

        arrow = {'incoming': '<--', 'outgoing': '-->'}[notification.data.direction]

        try:
            local_address = notification.sender.transport.getHost()
            local_address = '%s:%d' % (local_address.host, local_address.port)
        except AttributeError:
            # this may happen because we process this notification after transport has been disconnected
            local_address = 'local'

        remote_address = notification.sender.getPeer()
        remote_address = '%s:%d' % (remote_address.host, remote_address.port)

        message = '\n%s: %s %s %s' % (notification.datetime, local_address, arrow, remote_address)
        header = []
        if settings.logs.trace_msrp_in_gui == Full:
            header = notification.data.data.split("\n")
        else:
            if notification.data.data.startswith("MSRP "):
                lines = notification.data.data.split("\n")
                for line in lines:
                    if not line.strip() or line[0] == "-":
                        break
                    header.append(line)

        if notification.data.direction == "outgoing":
            self.msrpOutCount += 1
            self.append_line(self.msrpTextView, self.sendingText)
        else:
            self.msrpInCount += 1
            self.append_line(self.msrpTextView, self.receivedText)

        self.msrpBytes += len(message)
        self.append_line(self.msrpTextView, message)
        if header:
            try:
                dummy, ident, code, msg = header[0].split(None, 3)
                attribs = self.boldRedTextAttribs if int(code) >= 400 else self.boldTextAttribs
                self.append_line(self.msrpTextView, NSAttributedString.alloc().initWithString_attributes_(header[0], attribs))
            except:
                self.append_line(self.msrpTextView, NSAttributedString.alloc().initWithString_attributes_(header[0], self.boldTextAttribs))

            self.append_line(self.msrpTextView, "\n".join(header[1:]))

        if settings.logs.trace_msrp_in_gui != Full:
            self.append_line(self.msrpTextView, self.newline)

        self.msrpInfoLabel.setStringValue_("%d MSRP messages sent, %d MRSP messages received, %sytes" % (self.msrpOutCount, self.msrpInCount, format_size(self.msrpBytes)))
예제 #3
0
    def append_line(self, textView, line):
        if isinstance(line, NSAttributedString):
            textView.textStorage().appendAttributedString_(line)
        else:
            textView.textStorage().appendAttributedString_(NSAttributedString.alloc().initWithString_(line+"\n"))

        textView.scrollRangeToVisible_(NSMakeRange(textView.textStorage().length()-1, 1))
 def setBadgeLabel_(self, text):
     if text:
         self.badgeLabel = NSAttributedString.alloc(
         ).initWithString_attributes_(text, self.badgeAttributes)
     else:
         self.badgeLabel = None
     self.setNeedsDisplay_(True)
예제 #5
0
	def drawTextAtPoint(self, text, textPosition, fontSize=10.0, fontColor=NSColor.blackColor(), align='bottomleft'):
		"""
		Use self.drawTextAtPoint("blabla", myNSPoint) to display left-aligned text at myNSPoint.
		"""
		try:

			alignment = {
				'topleft': 6,
				'topcenter': 7,
				'topright': 8,
				'left': 3,
				'center': 4,
				'right': 5,
				'bottomleft': 0,
				'bottomcenter': 1,
				'bottomright': 2
			}

			currentZoom = self.getScale()
			fontAttributes = {
				NSFontAttributeName: NSFont.labelFontOfSize_(fontSize / currentZoom),
				NSForegroundColorAttributeName: fontColor}
			displayText = NSAttributedString.alloc().initWithString_attributes_(unicode(text), fontAttributes)
			textAlignment = alignment[align]  # top left: 6, top center: 7, top right: 8, center left: 3, center center: 4, center right: 5, bottom left: 0, bottom center: 1, bottom right: 2
			displayText.drawAtPoint_alignment_(textPosition, textAlignment)
		except:
			self.logError(traceback.format_exc())
예제 #6
0
    def _NH_AudioStreamICENegotiationDidSucceed(self, notification):
        data = notification.data
        stream = notification.sender

        text = u'%s Audio session %s, ICE negotiation succeeded in %s\n' % (notification.datetime, stream.session.remote_identity, data.duration)
        if stream.local_rtp_candidate and stream.remote_rtp_candidate:
            text += '%s Audio RTP endpoints: %s:%d (ICE type %s) <-> %s:%d (ICE type %s)' % (notification.datetime,
                                                                                             stream.local_rtp_address,
                                                                                             stream.local_rtp_port,
                                                                                             stream.local_rtp_candidate.type.lower(),
                                                                                             stream.remote_rtp_address,
                                                                                             stream.remote_rtp_port,
                                                                                             stream.remote_rtp_candidate.type.lower())

        text += '\nLocal ICE candidates:\n'
        for candidate in data.local_candidates:
            text += '\t%s\n' % candidate
        text += '\nRemote ICE candidates:\n'
        for candidate in data.remote_candidates:
            text += '\t%s\n' % candidate
        text += '\nICE connectivity checks results:\n'
        for check in data.valid_list:
            text += '\t%s\n' % check
        astring = NSAttributedString.alloc().initWithString_(text)
        self.rtpTextView.textStorage().appendAttributedString_(astring)
        self.rtpTextView.scrollRangeToVisible_(NSMakeRange(self.rtpTextView.textStorage().length()-1, 1))
예제 #7
0
    def _NH_AudioStreamICENegotiationDidFail(self, notification):
        data = notification.data

        text = '%s ICE negotiation failed: %s\n' % (notification.datetime, data.reason)
        astring = NSAttributedString.alloc().initWithString_(text)
        self.rtpTextView.textStorage().appendAttributedString_(astring)
        self.rtpTextView.scrollRangeToVisible_(NSMakeRange(self.rtpTextView.textStorage().length()-1, 1))
예제 #8
0
    def renderRTP(self, session):
        try:
            audio_stream = (s for s in session.streams or [] if s.type=='audio').next()
        except StopIteration:
            return

        text = u'\n%s New Audio session %s\n' % (session.start_time, session.remote_identity)
        if audio_stream.local_rtp_address and audio_stream.local_rtp_port and audio_stream.remote_rtp_address and audio_stream.remote_rtp_port:
            if audio_stream.ice_active and audio_stream.local_rtp_candidate and audio_stream.remote_rtp_candidate:
                text += '%s Audio RTP endpoints %s:%d (ICE type %s) <-> %s:%d (ICE type %s)\n' % (session.start_time,
                                                                                                  audio_stream.local_rtp_address,
                                                                                                  audio_stream.local_rtp_port,
                                                                                                  ice_candidates[audio_stream.local_rtp_candidate.type.lower()],
                                                                                                  audio_stream.remote_rtp_address,
                                                                                                  audio_stream.remote_rtp_port,
                                                                                                  ice_candidates[audio_stream.remote_rtp_candidate.type.lower()])
            else:
                text += '%s Audio RTP endpoints %s:%d <-> %s:%d\n' % (session.start_time,
                                                                      audio_stream.local_rtp_address,
                                                                      audio_stream.local_rtp_port,
                                                                      audio_stream.remote_rtp_address,
                                                                      audio_stream.remote_rtp_port)
        if audio_stream.codec and audio_stream.sample_rate:
            text += '%s Audio session established using "%s" codec at %sHz\n' % (session.start_time, audio_stream.codec, audio_stream.sample_rate)
        if audio_stream.srtp_active:
            text += '%s RTP audio stream is encrypted\n' % session.start_time
        if session.remote_user_agent is not None:
            text += '%s Remote SIP User Agent is "%s"\n' % (session.start_time, session.remote_user_agent)

        astring = NSAttributedString.alloc().initWithString_(text)
        self.rtpTextView.textStorage().appendAttributedString_(astring)
        self.rtpTextView.scrollRangeToVisible_(NSMakeRange(self.rtpTextView.textStorage().length()-1, 1))
예제 #9
0
    def _NH_MSRPLibraryLog(self, notification):
        settings = SIPSimpleSettings()
        if settings.logs.trace_msrp_in_gui == Disabled:
            return

        message = '%s %s%s\n\n' % (notification.datetime, notification.data.level.prefix, notification.data.message)
        text = NSAttributedString.alloc().initWithString_attributes_(message, self.grayText)
        self.append_line(self.msrpTextView, text)
예제 #10
0
 def _formatString_forOutput_(self, s, name):
     return NSAttributedString.alloc().initWithString_attributes_(
         s,
         {
             NSFontAttributeName: self.font(),
             NSForegroundColorAttributeName: getattr(self, name+'Color')(),
         },
     )
    def render_pidf(self):
        if not self.contact:
            return
        has_locations = False
        status_label = ''
        if self.contact.presence_state['devices']:
            has_locations = any(device['location'] for device in self.contact.presence_state['devices'].values() if device['location'] is not None)
            count = len(self.contact.presence_state['devices'])
            if count == 1:
                status_label = 'One device available'
            elif count > 1:
                status_label = '%d devices available' % count

        splitViewFrame = self.splitView.frame()
        mapViewFrame = self.mapViewSplitView.frame()
        pidfViewFrame = self.pidfView.frame()

        if has_locations:
            if mapViewFrame.size.height == 0:
                mapViewFrame.size.height = SPLITTER_HEIGHT
                self.mapViewSplitView.setFrame_(mapViewFrame)
                pidfViewFrame.size.height -= SPLITTER_HEIGHT
                self.pidfView.setFrame_(pidfViewFrame)
            self.mapView.setContact(self.contact)
            nr_countries = len(self.mapView.selectedCountries)
            if nr_countries == 1:
                status_label += ' in one country'
            elif nr_countries > 1:
                status_label += ' in %d countries' % nr_countries
        else:
            mapViewFrame.size.height = 0
            self.mapViewSplitView.setFrame_(mapViewFrame)
            pidfViewFrame.size.height = splitViewFrame.size.height
            self.pidfView.setFrame_(pidfViewFrame)

        self.statusLabel.setStringValue_(status_label)

        text = ''
        for pidf in self.contact.pidfs:
            text += self.build_pidf_text(pidf) + '\n\n'

        if self.contact.presence_state['pending_authorizations']:
            text += "Pending authorizations:\n"

        pending_authorizations = self.contact.presence_state['pending_authorizations']
        for key in pending_authorizations.keys():
            text += "    Subscription to %s from account %s\n" % (sip_prefix_pattern.sub('', key), pending_authorizations[key])

        self.presenceText.textStorage().deleteCharactersInRange_(NSMakeRange(0, self.presenceText.textStorage().length()))
        astring = NSAttributedString.alloc().initWithString_(text)
        self.presenceText.textStorage().appendAttributedString_(astring)

        image = presence_status_for_contact(self.contact)
        if image:
            icon = NSImage.imageNamed_(image)
            icon.setScalesWhenResized_(True)
            icon.setSize_(NSMakeSize(12,12))
            self.presence_icon.setImage_(icon)
예제 #12
0
    def render_pidf(self):
        if not self.contact:
            return
        has_locations = False
        status_label = ''
        if self.contact.presence_state['devices']:
            has_locations = any(device['location'] for device in list(self.contact.presence_state['devices'].values()) if device['location'] is not None)
            count = len(self.contact.presence_state['devices'])
            if count == 1:
                status_label = NSLocalizedString("One device available", "Label")
            elif count > 1:
                status_label = NSLocalizedString("%d devices available" % count, "Label")

        splitViewFrame = self.splitView.frame()
        mapViewFrame = self.mapViewSplitView.frame()
        pidfViewFrame = self.pidfView.frame()

        if has_locations:
            if mapViewFrame.size.height == 0:
                mapViewFrame.size.height = SPLITTER_HEIGHT
                self.mapViewSplitView.setFrame_(mapViewFrame)
                pidfViewFrame.size.height -= SPLITTER_HEIGHT
                self.pidfView.setFrame_(pidfViewFrame)
            self.mapView.setContact(self.contact)
            nr_countries = len(self.mapView.selectedCountries)
            if nr_countries == 1:
                status_label += NSLocalizedString(" in one country", "Label")
            elif nr_countries > 1:
                status_label +=  NSLocalizedString(" in %d countries" % nr_countries, "Label")
        else:
            mapViewFrame.size.height = 0
            self.mapViewSplitView.setFrame_(mapViewFrame)
            pidfViewFrame.size.height = splitViewFrame.size.height
            self.pidfView.setFrame_(pidfViewFrame)

        self.statusLabel.setStringValue_(status_label)

        text = ''
        for pidf in self.contact.pidfs:
            text += self.build_pidf_text(pidf) + '\n\n'

        if self.contact.presence_state['pending_authorizations']:
            text += "Pending authorizations:\n"

        pending_authorizations = self.contact.presence_state['pending_authorizations']
        for key in list(pending_authorizations.keys()):
            text += "    Subscription to %s from account %s\n" % (sip_prefix_pattern.sub('', key), pending_authorizations[key])

        self.presenceText.textStorage().deleteCharactersInRange_(NSMakeRange(0, self.presenceText.textStorage().length()))
        astring = NSAttributedString.alloc().initWithString_(text)
        self.presenceText.textStorage().appendAttributedString_(astring)

        image = presence_status_for_contact(self.contact)
        if image:
            icon = NSImage.imageNamed_(image)
            icon.setScalesWhenResized_(True)
            icon.setSize_(NSMakeSize(12,12))
            self.presence_icon.setImage_(icon)
예제 #13
0
 def _ns_update_attributed_title(self):
     if self._color:
         ns_button = self._ns_view
         ns_attrs = NSMutableDictionary.alloc().init()
         ns_attrs[NSFontAttributeName] = ns_button.font()
         ns_attrs[NSForegroundColorAttributeName] = self._color._ns_color
         ns_parstyle = NSMutableParagraphStyle.alloc().init()
         ns_parstyle.setAlignment_(ns_button.alignment())
         ns_attrs[NSParagraphStyleAttributeName] = ns_parstyle
         ns_attstr = NSAttributedString.alloc().initWithString_attributes_(
             ns_button.title(), ns_attrs)
         ns_button.setAttributedTitle_(ns_attstr)
 def awakeFromNib(self):
     smileys = SmileyManager().get_smiley_list()
     menu = self.smileyButton.menu()
     while menu.numberOfItems() > 0:
         menu.removeItemAtIndex_(0)
     bigText = NSAttributedString.alloc().initWithString_attributes_(" ", NSDictionary.dictionaryWithObject_forKey_(NSFont.systemFontOfSize_(16), NSFontAttributeName))
     for text, file in smileys:
         image = NSImage.alloc().initWithContentsOfFile_(file)
         if not image:
             print "cant load %s"%file
             continue
         image.setScalesWhenResized_(True)
         image.setSize_(NSMakeSize(16, 16))
         atext = bigText.mutableCopy()
         atext.appendAttributedString_(NSAttributedString.alloc().initWithString_(text))
         item = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(text, "insertSmiley:", "")
         menu.addItem_(item)
         item.setTarget_(self)
         item.setAttributedTitle_(atext)
         item.setRepresentedObject_(NSAttributedString.alloc().initWithString_(text))
         item.setImage_(image)
 def _ns_update_attributed_title(self):
     if self._color:
         ns_button = self._ns_view
         ns_attrs = NSMutableDictionary.alloc().init()
         ns_attrs[NSFontAttributeName] = ns_button.font()
         ns_attrs[NSForegroundColorAttributeName] = self._color._ns_color
         ns_parstyle = NSMutableParagraphStyle.alloc().init()
         ns_parstyle.setAlignment_(ns_button.alignment())
         ns_attrs[NSParagraphStyleAttributeName] = ns_parstyle
         ns_attstr = NSAttributedString.alloc().initWithString_attributes_(
             ns_button.title(), ns_attrs)
         ns_button.setAttributedTitle_(ns_attstr)
    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()
예제 #17
0
 def showAboutPlugin_(self, sender):
     icon = None
     info = objc.currentBundle().infoDictionary()
     if 'CFBundleIconFile' in info:
         icon_file = info['CFBundleIconFile']
         icon_path = objc.currentBundle().pathForImageResource_(icon_file)
         if icon_path is not None:
             icon = NSImage.alloc().initWithContentsOfFile_(icon_path)
     if icon is None:
         icon = NSImage.imageNamed_('NSApplicationIcon')
     options = {'Credits': NSAttributedString.alloc().initWithString_('ÇFULLUSERNAMEÈ'),
                'ApplicationName': self.name(),
                'ApplicationIcon': icon,
                'ApplicationVersion': info['CFBundleShortVersionString'],
                'Version': 'Coda %s' % NSBundle.mainBundle().infoDictionary()['CFBundleShortVersionString']}
     NSApp.orderFrontStandardAboutPanelWithOptions_(options)
예제 #18
0
    def _NH_AudioStreamDidChangeRTPParameters(self, notification):
        stream = notification.sender

        text = u'%s Audio session to %s: RTP parameters changed\n' % (notification.datetime, stream.session.remote_identity)
        if stream.local_rtp_address and stream.local_rtp_port and stream.remote_rtp_address and stream.remote_rtp_port:
            text += '%s Audio RTP endpoints %s:%d <-> %s:%d\n' % (notification.datetime,
                                                                  stream.local_rtp_address,
                                                                  stream.local_rtp_port,
                                                                  stream.remote_rtp_address,
                                                                  stream.remote_rtp_port)
        if stream.codec and stream.sample_rate:
            text += '%s Audio session established using "%s" codec at %sHz\n' % (notification.datetime, stream.codec, stream.sample_rate)
        if stream.srtp_active:
            text += '%s RTP audio stream is encrypted\n' % notification.datetime
        astring = NSAttributedString.alloc().initWithString_(text)
        self.rtpTextView.textStorage().appendAttributedString_(astring)
        self.rtpTextView.scrollRangeToVisible_(NSMakeRange(self.rtpTextView.textStorage().length()-1, 1))
예제 #19
0
def main():


    # "Skia-Regular 14.00 pt. P [] (0x7ff98cb0b410) fobj=0x7ff98cb0ad90, spc=3.50"


    font           = NSFont.fontWithName_size_("HelveticaNeue-Medium",14.0)
    font           = NSFont.fontWithName_size_("Avenir Next LT Pro Ultra Light Italic",14.0)
    print "font is", font
    print "font.displayName() is", font.displayName()
    
    # attributes = NSDictionary.dictionaryWithObjectsAndKeys_(font, NSFontAttributeName, None )
    # print "attributes is", attributes


 
    s = "CGColorCreateGenericRGB(0.8, 0.8, 0.8, 0.4)"
    
    # print dir(NSAttributedString)
        
    # s2 = NSAttributedString.alloc().initWithString_attributes_(s, attributes)
    # 
    # print "s2 is", s2

    s3 = NSAttributedString.alloc().initWithString_attributes_(s, { "NSFont":font })

    print "s3 is", s3 # , "s2 == s3", s2 == s3

    print "s3.size() is", s3.size()

    # s3.size() is <NSSize width=293.0 height=21.0>
    
    cat = CATextLayer.alloc().init()
    
    cat.setString_(s3)
    
    # cat.setFont_(font)
    # cat.setFontSize_(font.pointSize() )        # necessary after setFont?
    
    s4 = cat.string()
    
    print "s4 is", s4, "s3 == s4", s3 == s4
    
    print "cat.bounds() is", cat.frame()
예제 #20
0
for m in Font.masters:
    for gname in names:
        layer = Font.glyphs[gname].layers[m.id]
        # print(layer)
        theseLayers.append(layer)

    theseLayers.append(GSControlLayer.newline())

if theseLayers:
    # Font.currentTab.layers.append( theseLayers ) # BROKEN IN 1224
    # WORKAROUND:
    string = NSMutableAttributedString.alloc().init()
    for l in theseLayers:
        if l.className() == "GSLayer":
            char = Font.characterForGlyph_(l.parent)
            A = NSAttributedString.alloc().initWithString_attributes_(
                unichr(char), {"GSLayerIdAttrib": l.layerId})
        elif l.className() == "GSBackgroundLayer":
            char = Font.characterForGlyph_(l.parent)
            A = NSAttributedString.alloc().initWithString_attributes_(
                unichr(char), {
                    "GSLayerIdAttrib": l.layerId,
                    "GSShowBackgroundAttrib": True
                })
        elif l.className() == "GSControlLayer":
            char = l.parent.unicodeChar()
            A = NSAttributedString.alloc().initWithString_(unichr(char))
        else:
            raise ValueError
        string.appendAttributedString_(A)
    Font.currentTab.graphicView().textStorage().setText_(string)
예제 #21
0
 def setBadgeLabel_(self, text):
     if text:
         self.badgeLabel = NSAttributedString.alloc().initWithString_attributes_(text, self.badgeAttributes)
     else:
         self.badgeLabel = None
     self.setNeedsDisplay_(True)
예제 #22
0
    def __init__(self, sessionController):

        self.notification_center = NotificationCenter()
        self.notification_center.add_observer(
            self, name='CFGSettingsObjectDidChange')

        self.sessionController = None
        self.audio_stream = None
        self.video_stream = None
        self.chat_stream = None

        self.add_session(sessionController)
        self.add_audio_stream()
        self.add_video_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_(
            NSLocalizedString("SIP Session", "Label"),
            NSDictionary.dictionaryWithObject_forKey_(
                NSColor.orangeColor(), NSForegroundColorAttributeName))
        self.sessionBox.setTitle_(sessionBoxTitle)

        audioBoxTitle = NSAttributedString.alloc().initWithString_attributes_(
            NSLocalizedString("Audio Stream", "Label"),
            NSDictionary.dictionaryWithObject_forKey_(
                NSColor.orangeColor(), NSForegroundColorAttributeName))
        self.audioBox.setTitle_(audioBoxTitle)

        videoBoxTitle = NSAttributedString.alloc().initWithString_attributes_(
            NSLocalizedString("Video Stream", "Label"),
            NSDictionary.dictionaryWithObject_forKey_(
                NSColor.orangeColor(), NSForegroundColorAttributeName))
        self.videoBox.setTitle_(videoBoxTitle)

        chatBoxTitle = NSAttributedString.alloc().initWithString_attributes_(
            NSLocalizedString("Chat Stream", "Label"),
            NSDictionary.dictionaryWithObject_forKey_(
                NSColor.orangeColor(), NSForegroundColorAttributeName))
        self.chatBox.setTitle_(chatBoxTitle)

        settings = SIPSimpleSettings()

        self.audio_rtt_graph.setLineWidth_(1.0)
        self.audio_rtt_graph.setLineSpacing_(1.0)
        self.audio_rtt_graph.setAboveLimit_(
            settings.gui.rtt_threshold)  # if higher show red color
        self.audio_rtt_graph.setMinimumHeigth_(settings.gui.rtt_threshold)

        self.audio_packet_loss_rx_graph.setLineWidth_(1.0)
        self.audio_packet_loss_rx_graph.setLineSpacing_(1.0)
        self.audio_packet_loss_rx_graph.setAboveLimit_(
            3)  # if higher than 3% show red color
        self.audio_packet_loss_rx_graph.setLineColor_(NSColor.greenColor())
        self.audio_packet_loss_rx_graph.setMinimumHeigth_(5)

        self.audio_packet_loss_tx_graph.setLineWidth_(1.0)
        self.audio_packet_loss_tx_graph.setLineSpacing_(1.0)
        self.audio_packet_loss_tx_graph.setAboveLimit_(
            3)  # if higher than 3% show red color
        self.audio_packet_loss_tx_graph.setLineColor_(NSColor.greenColor())
        self.audio_packet_loss_tx_graph.setMinimumHeigth_(5)

        self.rx_speed_graph.setLineWidth_(1.0)
        self.rx_speed_graph.setLineSpacing_(0.0)
        self.rx_speed_graph.setLineColor_(NSColor.greenColor())
        self.rx_speed_graph.setMinimumHeigth_(100000)
        self.rx_speed_graph.setAboveLimit_(120000)

        self.tx_speed_graph.setLineWidth_(1.0)
        self.tx_speed_graph.setLineSpacing_(0.0)
        self.tx_speed_graph.setLineColor_(NSColor.blueColor())
        self.tx_speed_graph.setMinimumHeigth_(100000)
        self.tx_speed_graph.setAboveLimit_(120000)

        self.video_rx_speed_graph.setLineWidth_(1.0)
        self.video_rx_speed_graph.setLineSpacing_(0.0)
        self.video_rx_speed_graph.setLineColor_(NSColor.greenColor())
        self.video_rx_speed_graph.setMinimumHeigth_(100000)
        self.video_rx_speed_graph.setAboveLimit_(99999999)

        self.video_tx_speed_graph.setLineWidth_(1.0)
        self.video_tx_speed_graph.setLineSpacing_(0.0)
        self.video_tx_speed_graph.setLineColor_(NSColor.blueColor())
        self.video_tx_speed_graph.setMinimumHeigth_(100000)
        self.video_tx_speed_graph.setAboveLimit_(99999999)

        self.resetSession()
        self.updatePanelValues()
예제 #23
0
    def updateButtons(self):
        for button in (self.holdButton, self.hangupButton, self.chatButton, self.infoButton, self.muteButton, self.aspectButton, self.contactsButton, self.fullscreenButton, self.myvideoButton, self.pauseButton):

            lightGrayTitle = NSAttributedString.alloc().initWithString_attributes_(button.label(), NSDictionary.dictionaryWithObject_forKey_(NSColor.lightGrayColor(), NSForegroundColorAttributeName))
            button.setLabel_(lightGrayTitle)
예제 #24
0
 def _NH_AudioSessionHasQualityIssues(self, notification):
     text = '%s Audio session to %s has quality issues: loss %s, rtt: %s\n' % (notification.datetime, notification.sender.sessionController.target_uri, notification.data.packet_loss, notification.data.latency)
     astring = NSAttributedString.alloc().initWithString_(text)
     self.rtpTextView.textStorage().appendAttributedString_(astring)
     self.rtpTextView.scrollRangeToVisible_(NSMakeRange(self.rtpTextView.textStorage().length()-1, 1))
예제 #25
0
    def renderSIP(self, notification):
        settings = SIPSimpleSettings()
        if settings.logs.trace_sip_in_gui == Disabled:
            return

        event_data = notification.data
        self.sipBytes += len(event_data.data)
        if self._siptrace_start_time is None:
            self._siptrace_start_time = notification.datetime
        self._siptrace_packet_count += 1

        text = NSMutableAttributedString.alloc().init()

        if self.lastSIPMessageWasDNS:
            text.appendAttributedString_(self.newline)
        self.lastSIPMessageWasDNS = False

        if event_data.received:
            self.sipInCount += 1
            text.appendAttributedString_(self.receivedText)
        else:
            self.sipOutCount += 1
            text.appendAttributedString_(self.sendingText)

        line = " Packet %d, +%s\n" % (self._siptrace_packet_count, (notification.datetime - self._siptrace_start_time))
        text.appendAttributedString_(NSAttributedString.alloc().initWithString_(line))

        line = "%s: %s:%d -(SIP over %s)-> %s:%d\n" % (notification.datetime, event_data.source_ip, event_data.source_port, event_data.transport, event_data.destination_ip, event_data.destination_port)
        text.appendAttributedString_(NSAttributedString.alloc().initWithString_(line))

        data = event_data.data.strip()
        first, rest = data.split("\n", 1)

        applications = None
        method = None
        msg_type = None
        event = None
        code = None

        if data.startswith("SIP/2.0"):
            try:
                code = first.split()[1]
                attribs = self.boldRedTextAttribs if code[0] in ["4", "5", "6"] else self.boldTextAttribs
                for line in data.split("\n"):
                    line = line.strip()
                    if line.startswith("Event:"):
                        try:
                            event = line.split(" ", 1)[1]
                        except IndexError:
                            pass
                        continue
                    if line.startswith("CSeq"):
                        cseq, _number, _method = line.split(" ", 2)
                        try:
                            applications = self.filter_sip_methods[_method.strip()]
                            method = _method
                            msg_type = 'response'
                        except KeyError:
                            pass
                        continue

                if settings.logs.trace_sip_in_gui == Full:
                    text.appendAttributedString_(NSAttributedString.alloc().initWithString_attributes_(first+"\n", attribs))
                    text.appendAttributedString_(NSAttributedString.alloc().initWithString_(rest+"\n"))
                else:
                    text.appendAttributedString_(NSAttributedString.alloc().initWithString_attributes_(first+"\n", attribs))

            except:
                text.appendAttributedString_(NSAttributedString.alloc().initWithString_(data+"\n"))
        else:
            _method = first.split()[0]
            try:
                applications = self.filter_sip_methods[_method]
                method = _method
                msg_type = 'offer'
            except KeyError:
                pass

            for line in data.split("\n"):
                line = line.strip()
                if line.startswith("Event:"):
                    try:
                        event = line.split(" ", 1)[1]
                    except IndexError:
                        pass
                    continue

            if settings.logs.trace_sip_in_gui == Full:
                text.appendAttributedString_(NSAttributedString.alloc().initWithString_attributes_(first+"\n", self.boldTextAttribs))
                text.appendAttributedString_(NSAttributedString.alloc().initWithString_(rest+"\n"))
            else:
                text.appendAttributedString_(NSAttributedString.alloc().initWithString_attributes_(first+"\n", self.boldTextAttribs))

        self.sipInfoLabel.setStringValue_("%d SIP messages sent, %d SIP messages received, %sytes" % (self.sipOutCount, self.sipInCount, format_size(self.sipBytes)))


        if self.filter_sip_application is not None and applications is not None:
            if self.filter_sip_application not in applications:
                return

        self.sipTextView.textStorage().appendAttributedString_(text)
        self.sipTextView.textStorage().appendAttributedString_(self.newline)
        self.sipTextView.scrollRangeToVisible_(NSMakeRange(self.sipTextView.textStorage().length()-1, 1))
예제 #26
0
 def append_error_line(self, textView, line):
     red = NSDictionary.dictionaryWithObject_forKey_(NSColor.redColor(), NSForegroundColorAttributeName)
     textView.textStorage().appendAttributedString_(NSAttributedString.alloc().initWithString_attributes_(line+"\n", red))
     textView.scrollRangeToVisible_(NSMakeRange(textView.textStorage().length()-1, 1))