Changeset 9137

Show
Ignore:
Timestamp:
12/13/07 21:26:13 (12 months ago)
Author:
asterix
Message:

[js & I] show pep info in account tooltip, fix a bug in create_contact()

Location:
trunk
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/common/connection.py

    r9125 r9137  
    143143                self.blocked_groups = [] 
    144144                self.pep_supported = False 
     145                self.mood = {} 
     146                self.tune = {} 
     147                self.activity = {} 
    145148                # Do we continue connection when we get roster (send presence,get vcard..) 
    146149                self.continue_connect_info = None 
  • trunk/src/common/contacts.py

    r9125 r9137  
    2828        def __init__(self, jid='', name='', groups=[], show='', status='', sub='', 
    2929        ask='', resource='', priority=0, keyID='', our_chatstate=None, 
    30         chatstate=None, last_status_time=None, msg_id = None, composing_xep = None): 
     30        chatstate=None, last_status_time=None, msg_id = None, composing_xep = None, 
     31        mood={}, tune={}, activity={}): 
    3132                self.jid = jid 
    3233                self.name = name 
     
    3536                self.show = show 
    3637                self.status = status 
    37                 # FIXME 
    38                 self.mood = dict() 
    39                 self.activity = dict() 
    40                 self.tune = dict() 
    4138                self.sub = sub 
    4239                self.ask = ask 
     
    6865                self.last_status_time = last_status_time 
    6966 
     67                self.mood = mood.copy() 
     68                self.tune = tune.copy() 
     69                self.activity = activity.copy() 
     70 
    7071        def get_full_jid(self): 
    7172                if self.resource: 
     
    167168        def create_contact(self, jid='', name='', groups=[], show='', status='', 
    168169                sub='', ask='', resource='', priority=0, keyID='', our_chatstate=None, 
    169                 chatstate=None, last_status_time=None, composing_xep=None): 
     170                chatstate=None, last_status_time=None, composing_xep=None, 
     171                mood={}, tune={}, activity={}): 
    170172                return Contact(jid, name, groups, show, status, sub, ask, resource, 
    171173                        priority, keyID, our_chatstate, chatstate, last_status_time, 
    172                         composing_xep) 
     174                        None, composing_xep, mood, tune, activity) 
    173175         
    174176        def copy_contact(self, contact): 
  • trunk/src/common/pep.py

    r9127 r9137  
    22 
    33def user_mood(items, name, jid): 
     4        has_child = False 
     5        mood = None 
     6        text = None 
     7        for item in items.getTags('item'): 
     8                child = item.getTag('mood') 
     9                if child is not None: 
     10                        has_child = True 
     11                        for ch in child.getChildren(): 
     12                                if ch.getName() != 'text': 
     13                                        mood = ch.getName() 
     14                                else: 
     15                                        text = ch.getData() 
     16        if jid == gajim.get_jid_from_account(name): 
     17                acc = gajim.connections[name] 
     18                if has_child: 
     19                        if acc.mood.has_key('mood'): 
     20                                del acc.mood['mood'] 
     21                        if acc.mood.has_key('text'): 
     22                                del acc.mood['text'] 
     23                        if mood != None: 
     24                                acc.mood['mood'] = mood 
     25                        if text != None: 
     26                                acc.mood['text'] = text 
     27 
    428        (user, resource) = gajim.get_room_and_nick_from_fjid(jid) 
    529        contact = gajim.contacts.get_contact(name, user, resource=resource) 
    630        if not contact: 
    731                return 
     32        if has_child: 
     33                if contact.mood.has_key('mood'): 
     34                        del contact.mood['mood'] 
     35                if contact.mood.has_key('text'): 
     36                        del contact.mood['text'] 
     37                if mood != None: 
     38                        contact.mood['mood'] = mood 
     39                if text != None: 
     40                        contact.mood['text'] = text 
     41 
     42def user_tune(items, name, jid): 
     43        has_child = False 
     44        artist = None 
     45        title = None 
     46        source = None 
     47        track = None 
     48        length = None 
     49 
    850        for item in items.getTags('item'): 
    9                 child = item.getTag('mood') 
     51                child = item.getTag('tune') 
    1052                if child is not None: 
    11                         if contact.mood.has_key('mood'): 
    12                                 del contact.mood['mood'] 
    13                         if contact.mood.has_key('text'): 
    14                                 del contact.mood['text'] 
     53                        has_child = True 
    1554                        for ch in child.getChildren(): 
    16                                 if ch.getName() != 'text': 
    17                                         contact.mood['mood'] = ch.getName() 
    18                                 else: 
    19                                         contact.mood['text'] = ch.getData() 
    20  
    21 def user_tune(items, name, jid): 
     55                                if ch.getName() == 'artist': 
     56                                        artist = ch.getData() 
     57                                elif ch.getName() == 'title': 
     58                                        title = ch.getData() 
     59                                elif ch.getName() == 'source': 
     60                                        source = ch.getData() 
     61                                elif ch.getName() == 'track': 
     62                                        track = ch.getData() 
     63                                elif ch.getName() == 'length': 
     64                                        length = ch.getData() 
     65 
     66        if jid == gajim.get_jid_from_account(name): 
     67                acc = gajim.connections[name] 
     68                if has_child: 
     69                        if acc.tune.has_key('artist'): 
     70                                del acc.tune['artist'] 
     71                        if acc.tune.has_key('title'): 
     72                                del acc.tune['title'] 
     73                        if acc.tune.has_key('source'): 
     74                                del acc.tune['source'] 
     75                        if acc.tune.has_key('track'): 
     76                                del acc.tune['track'] 
     77                        if acc.tune.has_key('length'): 
     78                                del acc.tune['length'] 
     79                        if artist != None: 
     80                                acc.tune['artist'] = artist 
     81                        if title != None: 
     82                                acc.tune['title'] = title 
     83                        if source != None: 
     84                                acc.tune['source'] = source 
     85                        if track != None: 
     86                                acc.tune['track'] = track 
     87                        if length != None: 
     88                                acc.tune['length'] = length 
     89 
    2290        (user, resource) = gajim.get_room_and_nick_from_fjid(jid) 
    2391        contact = gajim.contacts.get_contact(name, user, resource=resource) 
    2492        if not contact: 
    2593                return 
    26         for item in items.getTags('item'): 
    27                 child = item.getTag('tune') 
    28                 if child is not None: 
    29                         if contact.tune.has_key('artist'): 
    30                                 del contact.tune['artist'] 
    31                         if contact.tune.has_key('title'): 
    32                                 del contact.tune['title'] 
    33                         if contact.tune.has_key('source'): 
    34                                 del contact.tune['source'] 
    35                         if contact.tune.has_key('track'): 
    36                                 del contact.tune['track'] 
    37                         if contact.tune.has_key('length'): 
    38                                 del contact.tune['length'] 
    39                         for ch in child.getChildren(): 
    40                                 if ch.getName() == 'artist': 
    41                                         contact.tune['artist'] = ch.getData() 
    42                                 elif ch.getName() == 'title': 
    43                                         contact.tune['title'] = ch.getData() 
    44                                 elif ch.getName() == 'source': 
    45                                         contact.tune['source'] = ch.getData() 
    46                                 elif ch.getName() == 'track': 
    47                                         contact.tune['track'] = ch.getData() 
    48                                 elif ch.getName() == 'length': 
    49                                         contact.tune['length'] = ch.getData() 
     94        if has_child: 
     95                if contact.tune.has_key('artist'): 
     96                        del contact.tune['artist'] 
     97                if contact.tune.has_key('title'): 
     98                        del contact.tune['title'] 
     99                if contact.tune.has_key('source'): 
     100                        del contact.tune['source'] 
     101                if contact.tune.has_key('track'): 
     102                        del contact.tune['track'] 
     103                if contact.tune.has_key('length'): 
     104                        del contact.tune['length'] 
     105                if artist != None: 
     106                        contact.tune['artist'] = artist 
     107                if title != None: 
     108                        contact.tune['title'] = title 
     109                if source != None: 
     110                        contact.tune['source'] = source 
     111                if track != None: 
     112                        contact.tune['track'] = track 
     113                if length != None: 
     114                        contact.tune['length'] = length 
    50115 
    51116def user_geoloc(items, name, jid): 
     
    53118 
    54119def user_activity(items, name, jid): 
     120        has_child = False 
     121        activity = None 
     122        subactivity = None 
     123        text = None 
     124 
     125        for item in items.getTags('item'): 
     126                child = item.getTag('activity') 
     127                if child is not None: 
     128                        has_child = True 
     129                        for ch in child.getChildren(): 
     130                                if ch.getName() != 'text': 
     131                                        activity = ch.getName() 
     132                                        for chi in ch.getChildren(): 
     133                                                subactivity = chi.getName() 
     134                                else: 
     135                                        text = ch.getData() 
     136 
     137        if jid == gajim.get_jid_from_account(name): 
     138                acc = gajim.connections[name] 
     139                if has_child: 
     140                        if acc.activity.has_key('activity'): 
     141                                del acc.activity['activity'] 
     142                        if acc.activity.has_key('subactivity'): 
     143                                del acc.activity['subactivity'] 
     144                        if acc.activity.has_key('text'): 
     145                                del acc.activity['text'] 
     146                        if activity != None: 
     147                                acc.activity['activity'] = activity 
     148                        if subactivity != None: 
     149                                acc.activity['subactivity'] = subactivity 
     150                        if text != None: 
     151                                acc.activity['text'] = text 
     152 
    55153        (user, resource) = gajim.get_room_and_nick_from_fjid(jid) 
    56154        contact = gajim.contacts.get_contact(name, user, resource=resource) 
    57155        if not contact: 
    58156                return 
    59         for item in items.getTags('item'): 
    60                 child = item.getTag('activity') 
    61                 if child is not None: 
    62                         if contact.activity.has_key('activity'): 
    63                                 del contact.activity['activity'] 
    64                         if contact.activity.has_key('subactivity'): 
    65                                 del contact.activity['subactivity'] 
    66                         if contact.activity.has_key('text'): 
    67                                 del contact.activity['text'] 
    68                         for ch in child.getChildren(): 
    69                                 if ch.getName() != 'text': 
    70                                         contact.activity['activity'] = ch.getName() 
    71                                         for chi in ch.getChildren(): 
    72                                                 contact.activity['subactivity'] = chi.getName() 
    73                                 else: 
    74                                         contact.activity['text'] = ch.getData() 
     157        if has_child: 
     158                if contact.activity.has_key('activity'): 
     159                        del contact.activity['activity'] 
     160                if contact.activity.has_key('subactivity'): 
     161                        del contact.activity['subactivity'] 
     162                if contact.activity.has_key('text'): 
     163                        del contact.activity['text'] 
     164                if activity != None: 
     165                        contact.activity['activity'] = activity 
     166                if subactivity != None: 
     167                        contact.activity['subactivity'] = subactivity 
     168                if text != None: 
     169                        contact.activity['text'] = text 
    75170 
    76171def user_send_mood(account, mood, message = ''): 
  • trunk/src/common/zeroconf/connection_zeroconf.py

    r9078 r9137  
    8787 
    8888                self.pep_supported = False 
     89                self.mood = {} 
     90                self.tune = {} 
     91                self.activity = {} 
    8992                # Do we continue connection when we get roster (send presence,get vcard...) 
    9093                self.continue_connect_info = None 
  • trunk/src/roster_window.py

    r9136 r9137  
    15311531                                        status = connection.status, 
    15321532                                        resource = connection.server_resource, 
    1533                                         priority = connection.priority) 
     1533                                        priority = connection.priority, 
     1534                                        mood = connection.mood, 
     1535                                        tune = connection.tune, 
     1536                                        activity = connection.activity) 
    15341537                                if gajim.connections[account].gpg: 
    15351538                                        contact.keyID = gajim.config.get_per('accounts', connection.name, 
  • trunk/src/tooltips.py

    r9125 r9137  
    501501                                 
    502502                                if contact.mood.has_key('mood'): 
    503                                         mood_string = 'Mood: <b>%s</b>' % contact.mood['mood'].strip() 
     503                                        mood_string = _('Mood:') + ' <b>%s</b>' % contact.mood['mood'].strip() 
    504504                                        if contact.mood.has_key('text') and contact.mood['text'] != '': 
    505505                                                mood_string += ' (%s)' % contact.mood['text'].strip() 
     
    508508                                if contact.activity.has_key('activity'): 
    509509                                        activity = contact.activity['activity'].strip() 
    510                                         activity_string = 'Activity: <b>%s' % activity 
     510                                        activity_string = _('Activity:') + ' <b>%s' % activity 
    511511                                        if contact.activity.has_key('subactivity'): 
    512512                                                activity_sub = contact.activity['subactivity'].strip() 
     
    532532                                        else: 
    533533                                                source = _('Unknown Source') 
    534                                         tune_string = '♪ ' + _('<b>"%(title)s"</b> by <i>%(artist)s</i>\nfrom <i>%(source)s</i>' %\ 
    535                                                         {'title': title, 'artist': artist, 'source': source}) + ' ♪' 
     534                                        tune_string = _('Tune:') + ' ' + _('<b>"%(title)s"</b> by <i>%(artist)s</i>\nfrom <i>%(source)s</i>' %\ 
     535                                                        {'title': title, 'artist': artist, 'source': source}) 
    536536                                        properties.append((tune_string, None)) 
    537537 
  • trunk/TODO.pep

    r9125 r9137  
    66 
    77Tooltips use cases: 
    8 • Show PEP in contact tooltips 
    98• Show PEP in GC tooltips 
    10 • Show PEP in account tooltips 
    119 
    1210Mood/Activity use cases