def on_tune_event(self, message): """ Called when a pep notification for an user tune is received """ contact = roster[message['from'].bare] if not contact: return roster.modified() item = message['pubsub_event']['items']['item'] old_tune = contact.tune if item.xml.find('{http://jabber.org/protocol/tune}tune'): item = item['tune'] contact.tune = { 'artist': item['artist'], 'length': item['length'], 'rating': item['rating'], 'source': item['source'], 'title': item['title'], 'track': item['track'], 'uri': item['uri'] } else: contact.tune = {} if contact.tune: logger.log_roster_change(message['from'].bare, 'is now listening to %s' % common.format_tune_string(contact.tune)) if old_tune != contact.tune and config.get_by_tabname('display_tune_notifications', contact.bare_jid): if contact.tune: self.information( 'Tune from '+ message['from'].bare + ': ' + common.format_tune_string(contact.tune), 'Tune') else: self.information(contact.bare_jid + ' stopped listening to music.', 'Tune')
def draw_contact_info(self, contact): """ draw the contact information """ resource = contact.get_highest_priority_resource() if contact: jid = contact.bare_jid elif resource: jid = resource.jid else: jid = '*****@*****.**' # should never happen if resource: presence = resource.presence else: presence = 'unavailable' i = 0 self.addstr(0, 0, '%s (%s)'%(jid, presence,), to_curses_attr(get_theme().COLOR_INFORMATION_BAR)) self.finish_line(get_theme().COLOR_INFORMATION_BAR) i += 1 self.addstr(i, 0, 'Subscription: %s' % (contact.subscription,)) self.finish_line() i += 1 if contact.ask: if contact.ask == 'asked': self.addstr(i, 0, 'Ask: %s' % (contact.ask,), to_curses_attr(get_theme().COLOR_IMPORTANT_TEXT)) else: self.addstr(i, 0, 'Ask: %s' % (contact.ask,)) self.finish_line() i += 1 if resource: self.addstr(i, 0, 'Status: %s' % (resource.status)) self.finish_line() i += 1 if contact.error: self.addstr(i, 0, 'Error: %s' % contact.error, to_curses_attr(get_theme().COLOR_ROSTER_ERROR)) self.finish_line() i += 1 if contact.tune: self.addstr(i, 0, 'Tune: %s' % common.format_tune_string(contact.tune), to_curses_attr(get_theme().COLOR_NORMAL_TEXT)) self.finish_line() i += 1 if contact.mood: self.addstr(i, 0, 'Mood: %s' % contact.mood, to_curses_attr(get_theme().COLOR_NORMAL_TEXT)) self.finish_line() i += 1 if contact.activity: self.addstr(i, 0, 'Activity: %s' % contact.activity, to_curses_attr(get_theme().COLOR_NORMAL_TEXT)) self.finish_line() i += 1 if contact.gaming: self.addstr(i, 0, 'Game: %s' % common.format_gaming_string(contact.gaming), to_curses_attr(get_theme().COLOR_NORMAL_TEXT)) self.finish_line() i += 1
def show_contact_info(self): """ Show the contact info (resource number, status, presence, etc) when 'i' is pressed. """ selected_row = self.roster_win.get_selected_row() if isinstance(selected_row, Contact): cont = selected_row res = selected_row.get_highest_priority_resource() acc = [] acc.append('Contact: %s (%s)' % (cont.bare_jid, res.presence if res else 'unavailable')) if res: acc.append('%s connected resource%s' % (len(cont), '' if len(cont) == 1 else 's')) acc.append('Current status: %s' % res.status) if cont.tune: acc.append('Tune: %s' % common.format_tune_string(cont.tune)) if cont.mood: acc.append('Mood: %s' % cont.mood) if cont.activity: acc.append('Activity: %s' % cont.activity) if cont.gaming: acc.append('Game: %s' % (common.format_gaming_string(cont.gaming))) msg = '\n'.join(acc) elif isinstance(selected_row, Resource): res = selected_row msg = 'Resource: %s (%s)\nCurrent status: %s\nPriority: %s' % ( res.jid, res.presence, res.status, res.priority) elif isinstance(selected_row, RosterGroup): rg = selected_row msg = 'Group: %s [%s/%s] contacts online' % ( rg.name, rg.get_nb_connected_contacts(), len(rg), ) else: msg = None if msg: self.core.information(msg, 'Info')
def show_contact_info(self): """ Show the contact info (resource number, status, presence, etc) when 'i' is pressed. """ selected_row = self.roster_win.get_selected_row() if isinstance(selected_row, Contact): cont = selected_row res = selected_row.get_highest_priority_resource() acc = [] acc.append('Contact: %s (%s)' % (cont.bare_jid, res.presence if res else 'unavailable')) if res: acc.append('%s connected resource%s' % (len(cont), '' if len(cont) == 1 else 's')) acc.append('Current status: %s' % res.status) if cont.tune: acc.append('Tune: %s' % common.format_tune_string(cont.tune)) if cont.mood: acc.append('Mood: %s' % cont.mood) if cont.activity: acc.append('Activity: %s' % cont.activity) if cont.gaming: acc.append('Game: %s' % (common.format_gaming_string(cont.gaming))) msg = '\n'.join(acc) elif isinstance(selected_row, Resource): res = selected_row msg = 'Resource: %s (%s)\nCurrent status: %s\nPriority: %s' % ( res.jid, res.presence, res.status, res.priority) elif isinstance(selected_row, RosterGroup): rg = selected_row msg = 'Group: %s [%s/%s] contacts online' % ( rg.name, rg.get_nb_connected_contacts(), len(rg),) else: msg = None if msg: self.core.information(msg, 'Info')
def draw_contact_info(self, contact): """ draw the contact information """ resource = contact.get_highest_priority_resource() if contact: jid = contact.bare_jid elif resource: jid = resource.jid else: jid = '*****@*****.**' # should never happen if resource: presence = resource.presence else: presence = 'unavailable' i = 0 self.addstr(0, 0, '%s (%s)' % ( jid, presence, ), to_curses_attr(get_theme().COLOR_INFORMATION_BAR)) self.finish_line(get_theme().COLOR_INFORMATION_BAR) i += 1 self.addstr(i, 0, 'Subscription: %s' % (contact.subscription, )) self.finish_line() i += 1 if contact.ask: if contact.ask == 'asked': self.addstr(i, 0, 'Ask: %s' % (contact.ask, ), to_curses_attr(get_theme().COLOR_IMPORTANT_TEXT)) else: self.addstr(i, 0, 'Ask: %s' % (contact.ask, )) self.finish_line() i += 1 if resource: self.addstr(i, 0, 'Status: %s' % (resource.status)) self.finish_line() i += 1 if contact.error: self.addstr(i, 0, 'Error: %s' % contact.error, to_curses_attr(get_theme().COLOR_ROSTER_ERROR)) self.finish_line() i += 1 if contact.tune: self.addstr(i, 0, 'Tune: %s' % common.format_tune_string(contact.tune), to_curses_attr(get_theme().COLOR_NORMAL_TEXT)) self.finish_line() i += 1 if contact.mood: self.addstr(i, 0, 'Mood: %s' % contact.mood, to_curses_attr(get_theme().COLOR_NORMAL_TEXT)) self.finish_line() i += 1 if contact.activity: self.addstr(i, 0, 'Activity: %s' % contact.activity, to_curses_attr(get_theme().COLOR_NORMAL_TEXT)) self.finish_line() i += 1 if contact.gaming: self.addstr( i, 0, 'Game: %s' % common.format_gaming_string(contact.gaming), to_curses_attr(get_theme().COLOR_NORMAL_TEXT)) self.finish_line() i += 1