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

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. import hooks
  5. _did_register_hooks = False
  6. from logging import getLogger
  7. log = getLogger('twitter')
  8. debug = log.debug
  9.  
  10. def _register_hooks():
  11.     global _did_register_hooks
  12.     if _did_register_hooks:
  13.         return None
  14.     _did_register_hooks = True
  15.     if False:
  16.         hooks.register('digsby.notifications.get_topics', _on_get_topics)
  17.         hooks.register('digsby.notifications.changed', _on_nots_changed)
  18.     
  19.  
  20.  
  21. def active_twitter_protocols():
  22.     profile = profile
  23.     import common
  24.     TwitterAccount = TwitterAccount
  25.     import twitter
  26.     for acct in profile.account_manager.socialaccounts:
  27.         if isinstance(acct, TwitterAccount):
  28.             if acct.enabled:
  29.                 conn = getattr(acct, 'connection', None)
  30.                 if conn is not None:
  31.                     yield conn
  32.                 
  33.             
  34.         acct.enabled
  35.     
  36.  
  37.  
  38. def _on_nots_changed():
  39.     for conn in active_twitter_protocols():
  40.         _notifications_changed(conn)
  41.     
  42.  
  43.  
  44. def _on_get_topics(nots):
  45.     for conn in active_twitter_protocols():
  46.         _get_notification_info(conn, nots)
  47.     
  48.  
  49.  
  50. def _get_notification_info(self, info):
  51.     return None
  52.     profile = profile
  53.     import common
  54.     nots = profile.notifications.setdefault(None, { })
  55.     prefix = self.account_prefix
  56.     template = dict(header = '${tweet.user.screen_name}', minor = '${tweet.text.decode("xml")}', pages = 'tweets', update = 'paged', icon = 'skin:serviceicons.twitter')
  57.     
  58.     def templ(desc):
  59.         t = template.copy()
  60.         t['description'] = desc
  61.         return t
  62.  
  63.     for key in nots.keys():
  64.         if key.startswith(prefix):
  65.             feed_name = key[len(prefix) + 1:]
  66.             if feed_name in self.feeds_by_name:
  67.                 feed = self.feeds_by_name[feed_name]
  68.                 if feed['type'] == 'search':
  69.                     info[key] = templ(_('Twitter - ') + feed['label'] + ' (%s)' % self.username)
  70.                 elif feed['type'] == 'group':
  71.                     info[key] = templ(_('Twitter - Group: ') + feed['label'] + ' (%s)' % self.username)
  72.                 
  73.             
  74.         feed_name in self.feeds_by_name
  75.     
  76.  
  77.  
  78. def _update_notifications(self, feeds):
  79.     return None
  80.     
  81.     def feed_notification_name(feed):
  82.         return '.'.join([
  83.             self.account_prefix,
  84.             feed['name']])
  85.  
  86.     profile = profile
  87.     import common
  88.     nots = profile.notifications.setdefault(None, { })
  89.     popup_reaction = {
  90.         'reaction': 'Popup' }
  91.     for feed in feeds:
  92.         notify_name = feed_notification_name(feed)
  93.         popup = feed.get('popups', sentinel)
  94.         if popup and popup is not sentinel:
  95.             if notify_name not in nots:
  96.                 nots[notify_name] = [
  97.                     popup_reaction]
  98.                 debug('adding popup for %r to notifications', notify_name)
  99.             elif popup_reaction not in nots[notify_name]:
  100.                 nots[notify_name].append(popup_reaction)
  101.                 debug('adding popup for %r to notifications', notify_name)
  102.             
  103.         notify_name not in nots
  104.         if notify_name in nots and popup == False:
  105.             if popup_reaction in nots[notify_name]:
  106.                 nots[notify_name].remove(popup_reaction)
  107.                 debug('removing popup for %r', notify_name)
  108.             
  109.         popup_reaction in nots[notify_name]
  110.     
  111.     for key in nots.keys():
  112.         if key.startswith(self.account_prefix):
  113.             fname = key[len(self.account_prefix) + 1:]
  114.             if fname not in self.feeds_by_name:
  115.                 debug('feed name %r not found in feeds, removing', fname)
  116.                 nots.pop(key)
  117.             
  118.         fname not in self.feeds_by_name
  119.     
  120.  
  121.  
  122. def _notifications_changed(self):
  123.     return None
  124.     profile = profile
  125.     import common
  126.     popup_reaction = {
  127.         'reaction': 'Popup' }
  128.     nots = profile.notifications.setdefault(None, { })
  129.     for key in nots.keys():
  130.         if key.startswith(self.account_prefix):
  131.             fname = key[len(self.account_prefix) + 1:]
  132.             if fname in self.feeds_by_name:
  133.                 feed = self.feeds_by_name[fname]
  134.                 in_not = popup_reaction in nots[key]
  135.                 if feed.get('popups', sentinel) != in_not:
  136.                     feed['popups'] = in_not
  137.                     self.webkitcontroller.edit_feed(feed)
  138.                 
  139.             
  140.         fname in self.feeds_by_name
  141.     
  142.  
  143.