def on_call_fire(self, opts, id=None, buttons=None, onclick=None): from common import fire, pref from gui import skin # stringify keys, so that they can be keywords. # also turn dicts into storages opts = to_storage(dict((str(k), v) for k, v in opts.iteritems())) if pref('twitter.popups.user_icons', default=True): from gui.browser.webkit.imageloader import LazyWebKitImage twitter_icon = skin.get('serviceicons.twitter', None) for tweet in opts.tweets: tweet.icon = LazyWebKitImage(tweet.user.profile_image_url, twitter_icon) def buttons_cb(item): if hasattr(item.tweet, 'sender_id'): return self.direct_buttons else: return self.tweet_buttons opts.update(onclick=onclick or self.on_popup_click, popupid='twitter20_' + self.username + str(opts.get('popupid_postfix', '')), buttons=buttons or buttons_cb, max_lines=10) if pref('twitter.popups.mark_as_read', default=True): opts.update(mark_as_read=self.mark_as_read) opts.update(badge=skin.get('serviceicons.twitter', None)) fire(**opts)
def _notify_since(self, when): to_notify = filter(lambda x: x.updated_parsed > when, reversed(self.combined_feed())) self_user = self.user_from_id(self.userid) to_notify = filter(lambda x: self.user_from_id(x.author_id) is not self_user, to_notify) default_icon = gui.skin.get('BuddiesPanel.BuddyIcons.NoIcon', None) for thing in to_notify: if getattr(thing, 'acct', None) is None: thing.acct = weakref.ref(self) if getattr(thing, 'icon', None) is not None: continue user = self.user_from_id(thing.author_id) url = getattr(user, 'thumbnailUrl', None) thing.icon = imageloader.LazyWebKitImage(url, default_icon) log.info_s("myspace notifying: %r", to_notify) if to_notify: common.fire('myspace.newsfeed', title = _("MySpace Newsfeed"), items = to_notify, conn = self, onclick = lambda item: getattr(item, 'url', util.try_this(lambda:getattr(self.user_from_activity(item), 'webUri', None) or getattr(self.user_from_activity(item), 'profileUrl', None), None)), popupid = '%r.myspace' % self, update = 'paged', util = util, badge = gui.skin.get('serviceicons.myspace', None), buttons = self.get_popup_buttons)
def _fire_browser_error_popup(): from common import fire fire( 'error', title='Error Launching Default Browser', msg= "No default web browser set in Windows. Please check your web browser's preferences.", details='')
def on_error(**k): if k.get('permissions'): common.fire('error', title=_('MySpace Error'), major = _('Error posting {thing}').format(thing=thing), minor = _('Digsby does not have permission to perform this action.'), buttons = [(_('Grant Permissions'), self.need_permissions), (_('Close'), lambda: None)], sticky = True, )
def do_load_local_notification(self): if sys.opts.start_offline: return # if --online was passed on the command line, don't show a popup if self.maybe_delay_accounts(self.do_load_local_notification): return log.debug('local mode popup') fire('error', title = _('Digsby is running in "Local Mode"'), major = '', minor = _('Changes to Digsby preferences may not synchronize to your other PCs right away'), onclick = LOCAL_MODE_URL)
def on_error(self, e): import traceback log.error(traceback.format_exc()) title = get(e, 'header', 'Error:') msg = get(e, 'major', '%s: %s'%(type(e).__name__,str(e))) details = get(e, 'minor', '') close = (_('Close'), lambda: None) fire('error', title = title, msg = msg, details = details, sticky = True, popupid = Exception, buttons = (close,), update = 'replace')
def on_error(**k): if k.get('permissions'): common.fire( 'error', title=_('MySpace Error'), major=_('Error posting {thing}').format(thing=thing), minor= _('Digsby does not have permission to perform this action.' ), buttons=[(_('Grant Permissions'), self.need_permissions), (_('Close'), lambda: None)], sticky=True, )
def _notify_alerts(self, alerts): log.info('MySpace got the following alerts: %r', alerts) for alert in alerts: if alert == 'countnewmail': continue if self.filters['indicators'].get(alert, False) or alert == 'mailurl': text = text_for_alert(alert, alerts) if text is None: continue common.fire('myspace.alert', title = _("MySpace Alerts"), msg = _("You have new %s") % (text), onclick = lambda *a, **k: self.openurl(alerts[alert]), popupid = '%r.myspace' % self)
def error(self,stanza): from common import fire #gtalk gets this from conference.jabber.org if not self.room_state.configured and stanza.get_from() == self.jid and\ stanza.stanza_type == 'presence': err = stanza.get_error() cond = err.get_condition() if cond is not None and cond.name == 'item-not-found': return try: fire('error', title = self.jid, msg = stanza.get_error().get_message(), details='', sticky = True, popupid = self.jid, buttons = ((_('Close'), lambda: None),), update = 'replace') except Exception: traceback.print_exc() if not self.room_state.joined: self.exit()
def on_invite(self, protocol, buddy, room_name, message='', on_yes=None, on_no=None): 'Someone has invited you to a chat room or conference.' if not pref('messaging.groupchat.enabled', False): log.warning('groupchat pref is off, ignoring chat invite') maybe_safe_call(on_no) return message = u'\n\n' + (message if message else _(u'Would you like to join?')) buddy_name = getattr(buddy, 'name', unicode(buddy)) if buddy is not None: # an invite from a buddy. msg = (_(u'{name} has invited you to a group chat.').format( name=buddy_name)) + message else: # an anonymous invite. just say (mysteriously) that you have been invited msg = _(u'You have been invited to a group chat.') + message def cb(join): if join: on_yes() if on_yes is not None else protocol.join_chat_room( room_name) else: maybe_safe_call(on_no) res = fire('chatinvite.received', buddy=buddy, minor=msg, buttons=[ (_('Join'), lambda *a: on_yes()), (_('Ignore'), lambda *a: maybe_safe_call(on_no)), ]) @wx.CallAfter # allow popups to fire def after(): if res.had_reaction('Popup'): return from gui.toolbox import SimpleMessageDialog protocol_name = protocol.account.protocol_info().name title = _('{protocol_name:s} Invite').format( protocol_name=protocol_name) diag = SimpleMessageDialog(None, title=title, message=msg.strip(), ok_caption=_('Join Chat'), icon=protocol.serviceicon.Resized(32), cancel_caption=_('Ignore Invite'), wrap=450) diag.OnTop = True diag.ShowWithCallback(cb)
def on_error(self, e): import traceback log.error(traceback.format_exc()) title = get(e, 'header', 'Error:') msg = get(e, 'major', '%s: %s' % (type(e).__name__, str(e))) details = get(e, 'minor', '') close = (_('Close'), lambda: None) fire('error', title=title, msg=msg, details=details, sticky=True, popupid=Exception, buttons=(close, ), update='replace')
def _notify_alerts(self, alerts): log.info('MySpace got the following alerts: %r', alerts) for alert in alerts: if alert == 'countnewmail': continue if self.filters['indicators'].get(alert, False) or alert == 'mailurl': text = text_for_alert(alert, alerts) if text is None: continue common.fire( 'myspace.alert', title=_("MySpace Alerts"), msg=_("You have new %s") % (text), onclick=lambda *a, **k: self.openurl(alerts[alert]), popupid='%r.myspace' % self)
def do_notifications(self, updates): if not updates: return items = [] for item in updates: try: items.append(self.update_item_to_notification(item)) except Exception: traceback.print_exc() common.fire('linkedin.newsfeed', items=items, popupid='%d.linkedin' % id(self), update='paged', badge=skin.get('serviceicons.linkedin', None), buttons=self.get_popup_buttons, onclick=self.on_popup_click)
def do_notifications(self, updates): if not updates: return items = [] for item in updates: try: items.append(self.update_item_to_notification(item)) except Exception: traceback.print_exc() common.fire( "linkedin.newsfeed", items=items, popupid="%d.linkedin" % id(self), update="paged", badge=skin.get("serviceicons.linkedin", None), buttons=self.get_popup_buttons, onclick=self.on_popup_click, )
def _error(e): from common import fire import gui.clipboard if isinstance(e, basestring): error_message = u''.join([e, u'\n\n', u'"', status, u'"']) else: error_message = status fire('error', title=_('Twitter Error'), major=_('Send Tweet Failed'), minor=error_message, buttons=[(_('Retry'), lambda: self.on_status_with_error_popup(status)), (_('Copy'), lambda: gui.clipboard.copy(status)), (_('Close'), lambda * a, **k: None)], sticky=True) if error is not None: error(e)
def _error(e): from common import fire import gui.clipboard if isinstance(e, basestring): error_message = u''.join([e, u'\n\n', u'"', status, u'"']) else: error_message = status fire('error', title=_('Twitter Error'), major=_('Send Tweet Failed'), minor=error_message, buttons=[(_('Retry'), lambda: self.on_status_with_error_popup(status)), (_('Copy'), lambda: gui.clipboard.copy(status)), (_('Close'), lambda *a, **k: None)], sticky=True) if error is not None: error(e)
def error(self, stanza): from common import fire #gtalk gets this from conference.jabber.org if not self.room_state.configured and stanza.get_from() == self.jid and\ stanza.stanza_type == 'presence': err = stanza.get_error() cond = err.get_condition() if cond is not None and cond.name == 'item-not-found': return try: fire('error', title=self.jid, msg=stanza.get_error().get_message(), details='', sticky=True, popupid=self.jid, buttons=((_('Close'), lambda: None), ), update='replace') except Exception: traceback.print_exc() if not self.room_state.joined: self.exit()
def _notify_since(self, when): to_notify = filter(lambda x: x.updated_parsed > when, reversed(self.combined_feed())) self_user = self.user_from_id(self.userid) to_notify = filter( lambda x: self.user_from_id(x.author_id) is not self_user, to_notify) default_icon = gui.skin.get('BuddiesPanel.BuddyIcons.NoIcon', None) for thing in to_notify: if getattr(thing, 'acct', None) is None: thing.acct = weakref.ref(self) if getattr(thing, 'icon', None) is not None: continue user = self.user_from_id(thing.author_id) url = getattr(user, 'thumbnailUrl', None) thing.icon = imageloader.LazyWebKitImage(url, default_icon) log.info_s("myspace notifying: %r", to_notify) if to_notify: common.fire('myspace.newsfeed', title=_("MySpace Newsfeed"), items=to_notify, conn=self, onclick=lambda item: getattr( item, 'url', util.try_this( lambda: getattr(self.user_from_activity( item), 'webUri', None) or getattr( self.user_from_activity(item), 'profileUrl', None), None)), popupid='%r.myspace' % self, update='paged', util=util, badge=gui.skin.get('serviceicons.myspace', None), buttons=self.get_popup_buttons)
def on_file_request(self, protocol, xferinfo): 'A protocol is asking you to receive a file.' if xferinfo not in profile.xfers: if pref('filetransfer.auto_accept_from_blist', default=False) and \ profile.blist.on_buddylist(xferinfo.buddy): profile.xfers.insert(0, xferinfo) wx.CallAfter(xferinfo.save) else: xferinfo.state = xferinfo.states.WAITING_FOR_YOU notifies = fire('filetransfer.request', buddy = xferinfo.buddy, target = xferinfo) xferinfo.notifications = notifies profile.xfers.insert(0, xferinfo)
def on_invite(self, protocol, buddy, room_name, message='', on_yes = None, on_no = None): 'Someone has invited you to a chat room or conference.' if not pref('messaging.groupchat.enabled', False): log.warning('groupchat pref is off, ignoring chat invite') maybe_safe_call(on_no) return message = u'\n\n' + (message if message else _(u'Would you like to join?')) buddy_name = getattr(buddy, 'name', unicode(buddy)) if buddy is not None: # an invite from a buddy. msg = (_(u'{name} has invited you to a group chat.').format(name=buddy_name)) + message else: # an anonymous invite. just say (mysteriously) that you have been invited msg = _(u'You have been invited to a group chat.') + message def cb(join): if join: on_yes() if on_yes is not None else protocol.join_chat_room(room_name) else: maybe_safe_call(on_no) res = fire('chatinvite.received', buddy=buddy, minor=msg, buttons = [ (_('Join'), lambda *a: on_yes()), (_('Ignore'), lambda *a: maybe_safe_call(on_no)), ]) @wx.CallAfter # allow popups to fire def after(): if res.had_reaction('Popup'): return from gui.toolbox import SimpleMessageDialog protocol_name = protocol.account.protocol_info().name title = _('{protocol_name:s} Invite').format(protocol_name=protocol_name) diag = SimpleMessageDialog(None, title=title, message=msg.strip(), ok_caption=_('Join Chat'), icon = protocol.serviceicon.Resized(32), cancel_caption=_('Ignore Invite'), wrap=450) diag.OnTop = True diag.ShowWithCallback(cb)
def on_file_request(self, protocol, xferinfo): 'A protocol is asking you to receive a file.' if xferinfo not in profile.xfers: if pref('filetransfer.auto_accept_from_blist', default=False) and \ profile.blist.on_buddylist(xferinfo.buddy): profile.xfers.insert(0, xferinfo) wx.CallAfter(xferinfo.save) else: xferinfo.state = xferinfo.states.WAITING_FOR_YOU notifies = fire('filetransfer.request', buddy=xferinfo.buddy, target=xferinfo) xferinfo.notifications = notifies profile.xfers.insert(0, xferinfo)
def _fire_browser_error_popup(): from common import fire fire('error', title='Error Launching Default Browser', msg="No default web browser set in Windows. Please check your web browser's preferences.", details='')
if src.offline_reason == Reasons.BAD_PASSWORD: rsn = getattr(getattr(src, 'connection', None), '_auth_error_msg', None) if rsn: msg = msg + ' - ' + rsn addtl_txt = getattr(src, 'error_txt', False) if addtl_txt: msg = msg + ': ' + addtl_txt sticky = True del src.error_txt log.debug('Firing popup for %r', src) canceller = fire('error', title = _('{protocol_name} Error').format(protocol_name = nice_proto_names[src.protocol]), msg = src.display_name, details = msg, sticky = sticky, buttons = buttons, popupid = src, **moreoptions) if src in self.cancellers: old = self.cancellers.pop(src) if old is not canceller: from weakref import ref with traceguard: for item in old.get(): canceller.put(ref(item)) self.cancellers[src] = canceller def get_profile_reconnect_time(self):
None) if rsn: msg = msg + ' - ' + rsn addtl_txt = getattr(src, 'error_txt', False) if addtl_txt: msg = msg + ': ' + addtl_txt sticky = True del src.error_txt log.debug('Firing popup for %r', src) canceller = fire('error', title=_('{protocol_name} Error').format( protocol_name=nice_proto_names[src.protocol]), msg=src.display_name, details=msg, sticky=sticky, buttons=buttons, popupid=src, **moreoptions) if src in self.cancellers: old = self.cancellers.pop(src) if old is not canceller: from weakref import ref with traceguard: for item in old.get(): canceller.put(ref(item)) self.cancellers[src] = canceller