home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 October / maximum-cd-2011-10.iso / DiscContents / digsby_setup.exe / lib / plugins / msim / MSIMContacts.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2011-06-22  |  9.7 KB  |  336 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. import logging
  5. import util
  6. import common
  7. import contacts
  8. log = logging.getLogger('msim.contacts')
  9.  
  10. class MSIM_Group(contacts.Group):
  11.     GroupName = None
  12.     GroupID = None
  13.     GroupFlag = None
  14.     Position = None
  15.     
  16.     def __init__(self, group_info, proto, *contents):
  17.         self.update_info(group_info)
  18.         contacts.Group.__init__(self, self.GroupName, proto, self.GroupID, *contents)
  19.  
  20.     
  21.     def update_info(self, info):
  22.         self._pending_info_request = False
  23.         for k in info.keys():
  24.             v = info[k]
  25.             if isinstance(v, bytes):
  26.                 v = v.decode('fuzzy utf8')
  27.             
  28.             setattr(self, k, v)
  29.         
  30.  
  31.     
  32.     def _get_name(self):
  33.         return self.GroupName
  34.  
  35.     
  36.     def _set_name(self, val):
  37.         self.GroupName = val
  38.  
  39.     name = property(_get_name, _set_name)
  40.     
  41.     def get_infodict(self):
  42.         return dict(GroupName = self.GroupName, GroupID = self.GroupID, GroupFlag = str(self.GroupFlag), Position = str(self.Position))
  43.  
  44.     
  45.     def __cmp__(self, other):
  46.         other_id = getattr(other, 'GroupID', None)
  47.         id_cmp = cmp(self.GroupID, other_id)
  48.         if id_cmp == 0:
  49.             return 0
  50.         
  51.         try:
  52.             return cmp(int(self.Position), int(getattr(other, 'Position', -1)))
  53.         except Exception:
  54.             id_cmp == 0
  55.             id_cmp == 0
  56.             return -1
  57.  
  58.  
  59.  
  60.  
  61. class MSIM_Buddy(contacts.Contact, common.buddy):
  62.     _renderer = 'Contact'
  63.     HIDDEN_CONTACTS = [
  64.         u'myspaceim',
  65.         '78744676']
  66.     Position = None
  67.     GroupName = None
  68.     Visibility = None
  69.     ShowAvatar = None
  70.     AvatarURL = None
  71.     ImageURL = None
  72.     NickName = None
  73.     IMName = None
  74.     NameSelect = None
  75.     OfflineMsg = None
  76.     Headline = None
  77.     LastLogin = None
  78.     UserID = None
  79.     ContactID = None
  80.     SkyStatus = None
  81.     UserName = None
  82.     RealName = None
  83.     DisplayName = None
  84.     BandName = None
  85.     SongName = None
  86.     ContactType = None
  87.     Gender = None
  88.     RoomLastLogin = None
  89.     _settable_properties = [
  90.         'Visibility',
  91.         'Position',
  92.         'GroupName',
  93.         'NameSelect',
  94.         'NickName']
  95.     _all_properties = [
  96.         'Position',
  97.         'GroupName',
  98.         'Visibility',
  99.         'ShowAvatar',
  100.         'AvatarURL',
  101.         'ImageURL',
  102.         'NickName',
  103.         'IMName',
  104.         'NameSelect',
  105.         'OfflineMsg',
  106.         'Headline',
  107.         'LastLogin',
  108.         'SkyStatus',
  109.         'UserName',
  110.         'RealName',
  111.         'DisplayName',
  112.         'BandName',
  113.         'SongName',
  114.         'ContactType',
  115.         'Gender',
  116.         'RoomLastLogin']
  117.     
  118.     def __init__(self, info, proto):
  119.         self._status_message = None
  120.         self.status = 'unknown'
  121.         self.id = self.ContactID = self.UserID = info.get('ContactID', info.get('UserID'))
  122.         common.buddy.__init__(self, self.id, proto)
  123.         self.UserName = info.get('UserName')
  124.         self.RealName = info.get('RealName')
  125.         self.DisplayName = info.get('DisplayName')
  126.         self.IMName = info.get('IMName')
  127.         self.NickName = info.get('NickName')
  128.         self.NameSelect = info.get('NameSelect', '1')
  129.         self.OfflineMsg = info.get('OfflineMsg')
  130.         self.Headline = info.get('Headline')
  131.         self.LastLogin = info.get('LastLogin', '0')
  132.         self.ShowAvatar = info.get('ShowAvatar', 'False')
  133.         self.AvatarURL = info.get('AvatarURL')
  134.         self.ImageURL = info.get('ImageURL')
  135.         self.SkyStatus = info.get('SkyStatus')
  136.         self.Visibility = info.get('Visibility')
  137.         self.Position = info.get('Position', '0')
  138.         self.GroupName = info.get('GroupName')
  139.         contacts.Contact.__init__(self, self, self.id)
  140.  
  141.     
  142.     def visible(self):
  143.         visible = False
  144.         
  145.         try:
  146.             visible = int(self.Visibility)
  147.         except (ValueError, TypeError):
  148.             e = None
  149.  
  150.         if visible and self.UserName not in self.HIDDEN_CONTACTS:
  151.             pass
  152.         return self.id not in self.HIDDEN_CONTACTS
  153.  
  154.     visible = property(visible)
  155.     
  156.     def _get_icon_hash(self):
  157.         if not self.AvatarURL:
  158.             pass
  159.         return self.ImageURL
  160.  
  161.     
  162.     def _set_icon_hash(self, val):
  163.         self.AvatarURL = self.ImageURL = val
  164.  
  165.     icon_hash = property(_get_icon_hash, _set_icon_hash)
  166.     
  167.     def _get__use_icon(self):
  168.         return self.ShowAvatar == 'True'
  169.  
  170.     
  171.     def _set__use_icon(self, val):
  172.         if val:
  173.             self.ShowAvatar = 'True'
  174.         else:
  175.             self.ShowAvatar = 'False'
  176.  
  177.     _use_icon = property(_get__use_icon, _set__use_icon)
  178.     
  179.     def get_infodict(self, id_key = 'ContactID', settable_only = True):
  180.         if settable_only:
  181.             keys = self._settable_properties[:]
  182.         else:
  183.             keys = self._all_properties[:]
  184.         keys.append(id_key)
  185.         d = { }
  186.         for key in keys:
  187.             val = getattr(self, key, None)
  188.             if val is not None:
  189.                 d[key] = val
  190.                 continue
  191.         
  192.         return d
  193.  
  194.     
  195.     def __repr__(self):
  196.         return common.buddy.__repr__(self)
  197.  
  198.     
  199.     def __getattr__(self, attr):
  200.         return object.__getattribute__(self, attr)
  201.  
  202.     
  203.     def _get__notify_dirty(self):
  204.         return self._notify_dirty_
  205.  
  206.     
  207.     def _set__notify_dirty(self, val):
  208.         self._notify_dirty_ = val
  209.  
  210.     _notify_dirty = property(_get__notify_dirty, _set__notify_dirty)
  211.     
  212.     def _get_GroupName(self):
  213.         group = self.protocol.get_group(self.GroupID)
  214.         if group is None:
  215.             return None
  216.         return group.GroupName
  217.  
  218.     
  219.     def _set_GroupName(self, val):
  220.         group = self.protocol.get_group(val)
  221.         if group is None:
  222.             self.GroupID = None
  223.         else:
  224.             self.GroupID = group.GroupID
  225.  
  226.     GroupName = property(_get_GroupName, _set_GroupName)
  227.     
  228.     def blocked(self):
  229.         return False
  230.  
  231.     blocked = property(blocked)
  232.     
  233.     def block(self, block = True, **k):
  234.         pass
  235.  
  236.     block = common.action((lambda : pass))(block)
  237.     unblock = block
  238.     
  239.     def update_info(self, info, info_type = None):
  240.         for k in info.keys():
  241.             is_name = k in ('NickName', 'IMName', 'RealName', 'UserName', 'DisplayName')
  242.             newval = info.get(k, '').decode('utf8').decode('xml')
  243.             if is_name or newval.strip() or not is_name:
  244.                 setattr(self, k, newval)
  245.                 continue
  246.         
  247.         self.notify()
  248.  
  249.     
  250.     def get_icon_hash(self):
  251.         return self.icon_hash
  252.  
  253.     
  254.     def _get_status_message(self):
  255.         if self.online:
  256.             return self._status_message
  257.         return self.OfflineMsg
  258.  
  259.     
  260.     def _set_status_message(self, val):
  261.         if isinstance(val, bytes):
  262.             val = val.decode('fuzzy utf8')
  263.             _val = val
  264.         
  265.         self._status_message = val
  266.  
  267.     status_message = property(_get_status_message, _set_status_message)
  268.     
  269.     def idle(self):
  270.         return self.status == 'idle'
  271.  
  272.     idle = property(idle)
  273.     
  274.     def mobile(self):
  275.         return False
  276.  
  277.     mobile = property(mobile)
  278.     
  279.     def away(self):
  280.         return self.status == 'away'
  281.  
  282.     away = property(away)
  283.     
  284.     def online(self):
  285.         return self.status not in ('unknown', 'offline', 'hidden')
  286.  
  287.     online = property(online)
  288.     
  289.     def remote_alias(self):
  290.         alias = None
  291.         
  292.         try:
  293.             ns = int(self.NameSelect)
  294.         except Exception:
  295.             ns = -1
  296.  
  297.         if ns <= ns:
  298.             pass
  299.         elif ns <= 3:
  300.             alias = [
  301.                 self.DisplayName,
  302.                 self.IMName,
  303.                 self.NickName][ns - 1]
  304.         
  305.         if not alias:
  306.             if not self.RealName and self.DisplayName and self.UserName and self.IMName:
  307.                 pass
  308.             alias = self.NickName
  309.         
  310.         if not alias and not getattr(self, '_pending_info_request', False):
  311.             util.Timer((common.pref('msim.contact_info.request_timeout', type = int, default = 5),), (lambda : setattr(self, '_pending_info_request', False))).start()
  312.             self._pending_info_request = True
  313.             self.protocol.request_buddy_info(self.id)
  314.         
  315.         if isinstance(alias, bytes):
  316.             return alias.decode('utf8')
  317.         return alias
  318.  
  319.     remote_alias = property(remote_alias)
  320.     
  321.     def __cmp__(self, other):
  322.         other_id = getattr(other, 'id', None)
  323.         id_cmp = cmp(self.id, other_id)
  324.         if id_cmp == 0:
  325.             return 0
  326.         
  327.         try:
  328.             return cmp(int(self.Position), int(getattr(other, 'Position', -1)))
  329.         except Exception:
  330.             id_cmp == 0
  331.             id_cmp == 0
  332.             return -1
  333.  
  334.  
  335.  
  336.