def JabberStatusMagic(contact): string=u''.join([TitleHTML(_('Subscription:')),BodyHTML(contact.protocol.roster.get_item_by_jid(contact.id).subscription.capitalize())]) for r in contact.resources.values(): string=u''.join([string,separatorshort(),TitleHTML(_('Resource:')),BodyHTML(u''.join([r.jid.resource or '',u' (',str(r.priority),u')']))]) string=u''.join([string,u'<br>',TitleHTML(_(u'Status:')),BodyHTML(r.sightly_status)]) import hooks if r.status_message and hooks.reduce('digsby.status.tagging.strip_tag', r.status_message, impl='text'): string=u''.join([string,u'<br>',BodyHTML(hooks.reduce('digsby.status.tagging.strip_tag', r.status_message, impl='text'))]) return string
def presence_push(self, status=None): assert status is None status = self.status import hooks if status: status = hooks.reduce('digsby.status.tagging.strip_tag', status, impl='text') return super(DigsbyProtocol, self).presence_push(status)
def get_iterator(self): iterator_info = Storage(id=self.id, context=self.context, iterator=self.get_feed_items()) # allow plugins to wrap/transform the generator return hooks.reduce('social.feed.iterator', iterator_info).iterator
def tag_stripped_msg(contact): import hooks msg = hooks.reduce('digsby.status.tagging.strip_tag', contact.stripped_msg, contact.status, impl='text') return msg
def get_contact_status(contact): if not contact_online(contact): return '' msg = hooks.reduce('digsby.status.tagging.strip_tag', contact.stripped_msg, contact.status, impl='text') if msg is not None: return replace_newlines(msg) return ''
def send_message(self, message, *args, **kwargs): # allow plugins to modify the message import hooks message = hooks.reduce('digsby.im.msg.send', message) echonow = pref('messaging.echo_immediately', type=bool, default=True) # Call Protocol Conversation's send message. def error(e=None): log.info('Error sending message: %r', message.format_as('plaintext')) log.info('Message error callback received %r: %r', type(e), e) if self.just_had_error: return emsg = getattr(e, 'error_message', '') if emsg: self.system_message(emsg, content_type = 'text/plain') else: self.system_message(_("Some of the messages you sent may not have been received."), content_type = 'text/plain') self.just_had_error = True def message_sent(): self.just_had_error = False def echo_message(msg=None): echomsg = msg or message if kwargs.get('auto', False): #echomsg = AUTORESP.format(message = echomsg) if 'has_autotext' not in kwargs: kwargs.update(has_autotext = True) self.sent_message(echomsg, **kwargs) if echonow: def success(msg=None): message_sent() echo_message() else: def success(msg=None): message_sent() echo_message(msg) conn = profile.connection if conn is not None: conn.send_message_intercept(self.buddy, message.format_as('plaintext')) netcall(lambda: self._send_message(message, success=success, error=error, *args, **kwargs)) if not self.ischat: # If this is a normal one-on-one chat, record an entry in the # "to-from" list b = self.buddy if b is not None and b is not self.protocol.self_buddy: profile.blist.add_tofrom('im', b, self.protocol)
def send_message(self, message, *args, **kwargs): # allow plugins to modify the message import hooks message = hooks.reduce('digsby.im.msg.send', message) echonow = pref('messaging.echo_immediately', type=bool, default=True) # Call Protocol Conversation's send message. def error(e=None): log.info('Error sending message: %r', message.format_as('plaintext')) log.info('Message error callback received %r: %r', type(e), e) if self.just_had_error: return emsg = getattr(e, 'error_message', '') if emsg: self.system_message(emsg, content_type='text/plain') else: self.system_message(_( "Some of the messages you sent may not have been received." ), content_type='text/plain') self.just_had_error = True def message_sent(): self.just_had_error = False def echo_message(msg=None): echomsg = msg or message if kwargs.get('auto', False): #echomsg = AUTORESP.format(message = echomsg) if 'has_autotext' not in kwargs: kwargs.update(has_autotext=True) self.sent_message(echomsg, **kwargs) if echonow: def success(msg=None): message_sent() echo_message() else: def success(msg=None): message_sent() echo_message(msg) conn = profile.connection if conn is not None: conn.send_message_intercept(self.buddy, message.format_as('plaintext')) netcall(lambda: self._send_message( message, success=success, error=error, *args, **kwargs)) if not self.ischat: # If this is a normal one-on-one chat, record an entry in the # "to-from" list b = self.buddy if b is not None and b is not self.protocol.self_buddy: profile.blist.add_tofrom('im', b, self.protocol)
def GetInfo(contact, showprofile=False, showhide=True, overflow_hidden=True):#showicon=True): css = '''\ table{ table-layout: fixed; } body{ word-wrap: break-word; %s } div{ overflow: hidden; } ''' % ('overflow: hidden' if overflow_hidden else '') + LINK_CSS + skin.get_css() no_icon_path = skin.get('BuddiesPanel.BuddyIcons.NoIcon').path.url() constanttop = u'''\ <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <style> %(css)s </style> <script type="text/javascript"> /* used to replace missing or BMP buddy icons with the default digsby one */ function imgError(img) { img.onerror = ""; img.src = "%(no_icon_path)s"; } </script> </head> <body><div id="content"><TABLE WIDTH=100%% cellpadding=0 border=0><TR><TD valign=top> ''' % dict(css=css, no_icon_path=no_icon_path) constantmiddle = u'</TD><TD width="68" valign="top" align="center">' constantbottom = u'</TD></TR></TABLE></div></body></html>' s = contact.serviceicon if contact.service == 'digsby' and getattr(contact, 'iswidget', False): s = 'widget' ico = skin_get('serviceicons.' + s) if isinstance(s, basestring) else s servico=u''.join([u'<div style="white-space: nowrap; position: relative;"><div style = "position: absolute; left: 0px; top: 0px;">', GenBitmapHTML(ico.path.url(), 16, 16), u'</div>']) alias = contact.alias name=u''.join([u'<div style="white-space: normal; overflow: hidden; word-wrap: break-word; min-height: 20; margin: 0 0 0 20;">', FontTagify(escape(alias),'header'), u'</div></div>']) if s=='widget': location = GetLocationFromIP(contact) #odict moreinfo = u'' if location: moreinfo = u''.join(['<div style="white-space: nowrap; width: 100%;">', TitleHTML(_(u'Location:')), BodyHTML(', '.join(location.values())), '</div>']) ip = u''.join(['<div style="white-space: nowrap; width: 100%;">', TitleHTML(_(u'IP Address:')), '<a href="http://www.geoiptool.com/en/?IP=%s">' % contact.ip, BodyHTML(contact.ip), '</a>', '</div>']) time_ = u''.join(['<div style="white-space: nowrap;">', TitleHTML(_(u'Time on Page:')), DetailHTML(GenTimedString(contact.online_time)), '</div>']) html = u''.join([constanttop, servico, name, time_, ip, moreinfo, constantbottom]) return html nicename = contact.nice_name if nicename != alias: username = u''.join(['<div style="white-space: nowrap;">', TitleHTML(protocols[contact.service].username_desc + u':'), BodyHTML(nicename), '</div>']) else: username = '' profile = ProfileHTML(contact.pretty_profile) if showprofile else u'' times = '' if contact.service in ('icq', 'aim') and contact.online_time: times = u''.join([TitleHTML(_(u'Online:')), DetailHTML(GenTimedString(contact.online_time)) ]) idle_since = contact.idle if contact.service in ('icq', 'aim', 'yahoo') and idle_since and idle_since is not True: times += (u''.join([TitleHTML((' ' if times else '') + _(u'Idle:')), DetailHTML(GenTimedString(idle_since)), ])) away_since = getattr(contact, 'away_updated', None) if getattr(contact, 'away', False) and away_since: times += (u''.join([TitleHTML(_((' ' if times else '') + _(u'Away:'))), DetailHTML(GenTimedString(away_since)) ])) if times: times = '<div>%s</div>' % times if contact.status_orb == 'unknown' or contact.service not in JABBER_SERVICES: status = u''.join(['<div style="white-space: nowrap;">', TitleHTML(_(u'Status:')), BodyHTML((_('{status} + Idle').format(status = contact.sightly_status) if contact.status == u'away' and contact.idle else contact.sightly_status)), '</div>']) else: status = JabberStatusMagic(contact) statusmsg = getattr(contact, '_infobox_status_message', contact.status_message) import hooks if statusmsg is not None: statusmsg = hooks.reduce('digsby.status.tagging.strip_tag', statusmsg, impl='text') if not statusmsg or contact.service in JABBER_SERVICES: statusmsg = '' else: if contact.service not in ('aim', 'icq'): statusmsg = BodyHTML(statusmsg) statusmsg = u''.join((separatorshort(), statusmsg)) icon = ''.join([constantmiddle, GenStatusIconHTML(contact), GenBuddyIconHTML(contact), LinkHTML(u'profile', (_(u'Hide Profile') if showprofile else _(u'Show Profile')) if showhide else '', nowrap = True)]) html = u''.join([constanttop, servico, name, username, times, status, statusmsg, icon, profile, constantbottom]) return linkify(html)