diff -Nru emesene2-2.0+git20101025-9e1aa6da/debian/changelog emesene2-2.0+git20101027-7fcd845d/debian/changelog --- emesene2-2.0+git20101025-9e1aa6da/debian/changelog 2010-10-26 10:52:24.000000000 +0000 +++ emesene2-2.0+git20101027-7fcd845d/debian/changelog 2010-10-28 19:05:41.000000000 +0000 @@ -1,3 +1,9 @@ +emesene2 (2.0+git20101027-7fcd845d-1~frasten0) maverick; urgency=low + + * Git snapshot of rev 7fcd845d on 20101027. + + -- Andrea Piccinelli Thu, 28 Oct 2010 21:05:41 +0200 + emesene2 (2.0+git20101025-9e1aa6da-1~frasten0) maverick; urgency=low * Git snapshot of rev 9e1aa6da on 20101025. diff -Nru emesene2-2.0+git20101025-9e1aa6da/emesene/e3/cache/EmoticonCache.py emesene2-2.0+git20101027-7fcd845d/emesene/e3/cache/EmoticonCache.py --- emesene2-2.0+git20101025-9e1aa6da/emesene/e3/cache/EmoticonCache.py 2010-10-26 00:39:10.000000000 +0000 +++ emesene2-2.0+git20101027-7fcd845d/emesene/e3/cache/EmoticonCache.py 2010-10-27 15:52:32.000000000 +0000 @@ -120,3 +120,4 @@ if 'lolw00t' in cache: asd() ''' return os.path.isfile(os.path.join(self.path, name)) + diff -Nru emesene2-2.0+git20101025-9e1aa6da/emesene/e3/common/notification.py emesene2-2.0+git20101027-7fcd845d/emesene/e3/common/notification.py --- emesene2-2.0+git20101025-9e1aa6da/emesene/e3/common/notification.py 2010-10-26 00:39:10.000000000 +0000 +++ emesene2-2.0+git20101027-7fcd845d/emesene/e3/common/notification.py 2010-10-27 15:52:32.000000000 +0000 @@ -35,7 +35,7 @@ self.notify_online = False self.last_online = None - def _on_message(self, cid, account, msgobj, cedict=None): + def _on_message(self, cid, account, msgobj, cedict=[]): """ This is called when a new message arrives to a user. """ diff -Nru emesene2-2.0+git20101025-9e1aa6da/emesene/e3/__init__.py emesene2-2.0+git20101027-7fcd845d/emesene/e3/__init__.py --- emesene2-2.0+git20101025-9e1aa6da/emesene/e3/__init__.py 2010-10-26 00:39:10.000000000 +0000 +++ emesene2-2.0+git20101027-7fcd845d/emesene/e3/__init__.py 2010-10-27 15:52:32.000000000 +0000 @@ -1,2 +1,3 @@ from base import * +from cache import * import common diff -Nru emesene2-2.0+git20101025-9e1aa6da/emesene/e3/papylib/Session.py emesene2-2.0+git20101027-7fcd845d/emesene/e3/papylib/Session.py --- emesene2-2.0+git20101025-9e1aa6da/emesene/e3/papylib/Session.py 2010-10-26 00:39:10.000000000 +0000 +++ emesene2-2.0+git20101027-7fcd845d/emesene/e3/papylib/Session.py 2010-10-27 15:52:32.000000000 +0000 @@ -54,12 +54,12 @@ self.add_action(e3.Action.ACTION_LOGIN, (account, password, status, host, port)) - def send_message(self, cid, text, style=None): + def send_message(self, cid, text, style=None, cedict={}, celist=[]): '''send a common message''' account = self.account.account message = e3.Message(e3.Message.TYPE_MESSAGE, text, account, style) - self.add_action(e3.Action.ACTION_SEND_MESSAGE, (cid, message)) + self.add_action(e3.Action.ACTION_SEND_MESSAGE, (cid, message, cedict, celist)) def request_attention(self, cid): '''request the attention of the contact''' diff -Nru emesene2-2.0+git20101025-9e1aa6da/emesene/e3/papylib/Worker.py emesene2-2.0+git20101027-7fcd845d/emesene/e3/papylib/Worker.py --- emesene2-2.0+git20101025-9e1aa6da/emesene/e3/papylib/Worker.py 2010-10-26 00:39:10.000000000 +0000 +++ emesene2-2.0+git20101027-7fcd845d/emesene/e3/papylib/Worker.py 2010-10-27 15:52:32.000000000 +0000 @@ -40,7 +40,7 @@ sys.path.insert(0, papypath) try: - REQ_VER = (0, 5, 1) + REQ_VER = (0, 5, 2) import papyon import papyon.event @@ -409,7 +409,7 @@ papymessage.content, account, \ formatting_papy_to_e3(papymessage.formatting)) # convert papyon msnobjects to a simple dict {shortcut:identifier} - cedict = {} + received_custom_emoticons = {} emotes = self.caches.get_emoticon_cache(account) def download_failed(reason): @@ -425,19 +425,19 @@ account, 'emoticon', emoticon_path) for shortcut, msn_object in papymessage.msn_objects.iteritems(): - cedict[shortcut] = None + received_custom_emoticons[shortcut] = None emoticon_hash = msn_object._data_sha.encode("hex") emoticon_path = os.path.join(emotes.path, emoticon_hash) if emoticon_hash in emotes: - cedict[shortcut] = emoticon_path + received_custom_emoticons[shortcut] = emoticon_path else: self.msn_object_store.request(msn_object, \ (download_ok, download_failed)) self.session.add_event(\ - Event.EVENT_CONV_MESSAGE, cid, account, msgobj, cedict) + Event.EVENT_CONV_MESSAGE, cid, account, msgobj, received_custom_emoticons) def _on_conversation_nudge_received(self, papycontact, pyconvevent): ''' handle received nudges ''' @@ -754,7 +754,7 @@ print "unblock fail", args self.session.add_event(e3.Event.EVENT_CONTACT_UNBLOCK_FAILED, '') #account papycontact = self.address_book.contacts.search_by('account', account)[0] - self.address_book.unblock_contact(papycontact, failed_cb=block_fail) + self.address_book.unblock_contact(papycontact, failed_cb=unblock_fail) def _handle_action_move_to_group(self, account, src_gid, dest_gid): '''handle Action.ACTION_MOVE_TO_GROUP ''' @@ -964,7 +964,7 @@ papycontact = self.address_book.contacts.search_by('account', account)[0] conv._invite_user(papycontact) - def _handle_action_send_message(self, cid, message): + def _handle_action_send_message(self, cid, message, cedict={}, l_custom_emoticons=[]): ''' handle Action.ACTION_SEND_MESSAGE ''' #print "you're guin to send %(msg)s in %(ci)s" % \ #{ 'msg' : message, 'ci' : cid } @@ -977,8 +977,29 @@ elif message.type == e3.base.Message.TYPE_MESSAGE: # format the text for papy formatting = formatting_e3_to_papy(message.style) + emoticon_cache = self.caches.get_emoticon_cache(self.session.account.account) + d_msn_objects = {} + + for custom_emoticon in l_custom_emoticons: + try: + fpath = os.path.join(emoticon_cache.path, cedict[custom_emoticon]) + f = open(fpath, 'rb') + d_custom_emoticon = f.read() + f.close() + except Exception as e: + print e + if not isinstance(d_custom_emoticon, str): + d_custom_emoticon = "".join([chr(b) for b in d_custom_emoticon]) + + msn_object = papyon.p2p.MSNObject(self.session.account.account, + len(d_custom_emoticon), + papyon.p2p.MSNObjectType.CUSTOM_EMOTICON, + cedict[custom_emoticon], + custom_emoticon, None, None, + data=StringIO.StringIO(d_custom_emoticon)) + d_msn_objects[custom_emoticon] = msn_object # create papymessage - msg = papyon.ConversationMessage(message.body, formatting) + msg = papyon.ConversationMessage(message.body, formatting, d_msn_objects) # send through the network papyconversation.send_text_message(msg) diff -Nru emesene2-2.0+git20101025-9e1aa6da/emesene/emesene.py emesene2-2.0+git20101027-7fcd845d/emesene/emesene.py --- emesene2-2.0+git20101025-9e1aa6da/emesene/emesene.py 2010-10-26 00:39:10.000000000 +0000 +++ emesene2-2.0+git20101027-7fcd845d/emesene/emesene.py 2010-10-27 15:52:32.000000000 +0000 @@ -23,7 +23,7 @@ from e3.common.utils import project_path os.chdir(os.path.abspath(project_path())) -print (project_path()) +#print (project_path()) import sys import glib diff -Nru emesene2-2.0+git20101025-9e1aa6da/emesene/gui/base/AdiumTheme.py emesene2-2.0+git20101027-7fcd845d/emesene/gui/base/AdiumTheme.py --- emesene2-2.0+git20101025-9e1aa6da/emesene/gui/base/AdiumTheme.py 2010-10-26 00:39:10.000000000 +0000 +++ emesene2-2.0+git20101027-7fcd845d/emesene/gui/base/AdiumTheme.py 2010-10-27 15:52:32.000000000 +0000 @@ -7,6 +7,7 @@ import parsers import gui +import MarkupParser class AdiumTheme(object): '''a class that contains information of a adium theme @@ -53,7 +54,7 @@ self.outgoing_next = read_file(self.outgoing_path, 'NextContent.html') - def format_incoming(self, msg, style=None): + def format_incoming(self, msg, style=None, cedict={}, cedir=None): '''return a string containing the template for the incoming message with the vars replaced ''' @@ -71,9 +72,9 @@ else: template = self.incoming - return self.replace(template, msg) + return self.replace(template, msg, style, cedict, cedir) - def format_outgoing(self, msg, style=None): + def format_outgoing(self, msg, style=None, cedict={}, cedir=None): '''return a string containing the template for the outgoing message with the vars replaced ''' @@ -97,13 +98,13 @@ else: template = self.outgoing - return self.replace(template, msg, style) + return self.replace(template, msg, style, cedict, cedir) - def replace(self, template, msg, style=None): + def replace(self, template, msg, style=None, cedict={}, cedir=None): '''replace the variables on template for the values on msg ''' - msgtext = replace_emotes(escape(msg.message)) + msgtext = MarkupParser.replace_emotes(escape(msg.message), cedict, cedir) if style is not None: msgtext = style_message(msgtext, style) @@ -221,14 +222,3 @@ '''add html markupt to msgtext to format the style of the message''' return '%s' % (style.to_css(), msgtext) -def replace_emotes(msgtext): - '''replace emotes with img tags to the images''' - for code in gui.Theme.EMOTES.iterkeys(): - if code in msgtext: - path = gui.theme.emote_to_path(code) - - if path is not None: - imgtag = '%s' % (path, code) - msgtext = msgtext.replace(code, imgtag) - - return msgtext diff -Nru emesene2-2.0+git20101025-9e1aa6da/emesene/gui/base/Conversation.py emesene2-2.0+git20101027-7fcd845d/emesene/gui/base/Conversation.py --- emesene2-2.0+git20101025-9e1aa6da/emesene/gui/base/Conversation.py 2010-10-26 00:39:10.000000000 +0000 +++ emesene2-2.0+git20101027-7fcd845d/emesene/gui/base/Conversation.py 2010-10-27 15:52:32.000000000 +0000 @@ -17,6 +17,9 @@ def __init__(self, session, cid, members=None): '''constructor''' self.session = session + self.caches = e3.cache.CacheManager(self.session.config_dir.base_dir) + self.emcache = self.caches.get_emoticon_cache(self.session.account.account) + self.cid = float(cid) self.formatter = e3.common.MessageFormatter(session.contacts.me) self.first = True @@ -196,16 +199,18 @@ group_chat = property(fget=_get_group_chat) - def _on_send_message(self, text, cedict=None): + def _on_send_message(self, text): '''method called when the user press enter on the input text''' - self.session.send_message(self.cid, text, self.cstyle) + custom_emoticons = gui.base.MarkupParser.get_custom_emotes(text, self.emcache.parse()) + + self.session.send_message(self.cid, text, self.cstyle, self.emcache.parse(), custom_emoticons) self.output.send_message(self.formatter, self.session.contacts.me, - text, cedict, self.cstyle, self.first) + text, self.emcache.parse(), self.emcache.path, self.cstyle, self.first) self.messages.push(text) self.play_send() self.first = False - def on_receive_message(self, message, account, cedict): + def on_receive_message(self, message, account, received_custom_emoticons): '''method called when a message arrives to the conversation''' contact = self.session.contacts.get(account) @@ -213,8 +218,9 @@ contact = e3.Contact(account) if message.type == e3.Message.TYPE_MESSAGE: + user_emcache = self.caches.get_emoticon_cache(account) self.output.receive_message(self.formatter, contact, message, - cedict, self.first) + received_custom_emoticons, user_emcache.path, self.first) self.play_type() elif message.type == e3.Message.TYPE_NUDGE: diff -Nru emesene2-2.0+git20101025-9e1aa6da/emesene/gui/base/MarkupParser.py emesene2-2.0+git20101027-7fcd845d/emesene/gui/base/MarkupParser.py --- emesene2-2.0+git20101025-9e1aa6da/emesene/gui/base/MarkupParser.py 2010-10-26 00:39:10.000000000 +0000 +++ emesene2-2.0+git20101027-7fcd845d/emesene/gui/base/MarkupParser.py 2010-10-27 15:52:32.000000000 +0000 @@ -1,5 +1,6 @@ # this module will include a parser for all the markups that will # convert it into a restricted subset of xhtml +import os import xml.sax.saxutils import gui @@ -22,7 +23,7 @@ '''replace the values on dic_inv keys with the values''' return xml.sax.saxutils.unescape(string_, dic_inv) -def parse_emotes(message, cedict=None): +def parse_emotes(message, cedict={}): '''parser the emotes in a message, return a string with img tags for the emotes acording to the theme''' @@ -58,3 +59,41 @@ return ''.join(chunks) + +def replace_emotes(msgtext, cedict={}, cedir=None): + '''replace emotes with img tags to the images''' + shortcuts = gui.Theme.EMOTES.keys() + if cedict is not None: + shortcuts.extend(cedict.keys()) + for shortcut in shortcuts: + if shortcut in msgtext: + if shortcut in gui.Theme.EMOTES.keys(): + path = gui.theme.emote_to_path(shortcut) + else: + path = os.path.join(cedir, cedict[shortcut]) + + if path is not None: + imgtag = '%s' % (path, shortcut) + msgtext = msgtext.replace(shortcut, imgtag) + + return msgtext + +def get_custom_emotes(message, cedict={}): + ''' returns a list with the shortcuts of the + custom emoticons present in the message + celist comes from cache ''' + chunks = [message] + l = [] + if cedict is None: + return l + shortcuts = cedict.keys() + while len(shortcuts) > 0: + shortcut = shortcuts.pop() + + for chunk in chunks: + parts = chunk.split(shortcut) + + if len(parts) > 1: + l.append(shortcut) + return l + diff -Nru emesene2-2.0+git20101025-9e1aa6da/emesene/gui/base/Theme.py emesene2-2.0+git20101027-7fcd845d/emesene/gui/base/Theme.py --- emesene2-2.0+git20101025-9e1aa6da/emesene/gui/base/Theme.py 2010-10-26 00:39:10.000000000 +0000 +++ emesene2-2.0+git20101027-7fcd845d/emesene/gui/base/Theme.py 2010-10-27 15:52:32.000000000 +0000 @@ -82,7 +82,7 @@ #EMOTES['(h)'] = '' #EMOTES[':^)'] = '' EMOTES['(ip)'] = 'island' - EMOTES['({)'] = 'hughleft' + EMOTES['({)'] = 'hugleft' EMOTES['(i)'] = 'lamp' EMOTES['(I)'] = EMOTES['(i)'] EMOTES['(li)'] = 'c10ud' @@ -102,7 +102,7 @@ EMOTES['(K)'] = EMOTES['(k)'] EMOTES['(f)'] = 'rose' EMOTES['(F)'] = EMOTES['(f)'] - EMOTES['(})'] = 'hughright' + EMOTES['(})'] = 'hugright' #EMOTES['^o)'] = '' EMOTES[':-*'] = 'secret' EMOTES['(S)'] = 'moon' diff -Nru emesene2-2.0+git20101025-9e1aa6da/emesene/gui/gtkui/AdiumTextBox.py emesene2-2.0+git20101027-7fcd845d/emesene/gui/gtkui/AdiumTextBox.py --- emesene2-2.0+git20101025-9e1aa6da/emesene/gui/gtkui/AdiumTextBox.py 2010-10-26 00:39:10.000000000 +0000 +++ emesene2-2.0+git20101027-7fcd845d/emesene/gui/gtkui/AdiumTextBox.py 2010-10-27 15:52:32.000000000 +0000 @@ -41,7 +41,7 @@ self.pending = [] self.ready = False - def add_message(self, msg, style=None): + def add_message(self, msg, style=None, cedict={}, cedir=None): '''add a message to the conversation''' if msg.incoming: @@ -49,14 +49,14 @@ self.last_incoming = False msg.first = not self.last_incoming - html = self.theme.format_incoming(msg, style) + html = self.theme.format_incoming(msg, style, cedict, cedir) self.last_incoming = True else: if self.last_incoming is None: self.last_incoming = True msg.first = self.last_incoming - html = self.theme.format_outgoing(msg, style) + html = self.theme.format_outgoing(msg, style, cedict, cedir) self.last_incoming = False html = html.replace("\n", "
") @@ -145,19 +145,19 @@ self._texts = [] - def send_message(self, formatter, contact, text, cedict, style, is_first): + def send_message(self, formatter, contact, text, cedict, cedir, style, is_first): '''add a message to the widget''' msg = gui.Message.from_contact(contact, text, is_first, False) - self.view.add_message(msg, style) + self.view.add_message(msg, style, cedict, cedir) - def receive_message(self, formatter, contact, message, cedict, is_first): + def receive_message(self, formatter, contact, message, cedict, cedir, is_first): '''add a message to the widget''' msg = gui.Message.from_contact(contact, message.body, is_first, True) - self.view.add_message(msg, message.style) + self.view.add_message(msg, message.style, cedict, cedir) def information(self, formatter, contact, message): '''add an information message to the widget''' # TODO: make it with a status message msg = gui.Message.from_contact(contact, message, False, True) - self.view.add_message(msg, None) + self.view.add_message(msg, None, None, None) diff -Nru emesene2-2.0+git20101025-9e1aa6da/emesene/gui/gtkui/AvatarChooser.py emesene2-2.0+git20101027-7fcd845d/emesene/gui/gtkui/AvatarChooser.py --- emesene2-2.0+git20101025-9e1aa6da/emesene/gui/gtkui/AvatarChooser.py 2010-10-26 00:39:10.000000000 +0000 +++ emesene2-2.0+git20101027-7fcd845d/emesene/gui/gtkui/AvatarChooser.py 2010-10-27 15:52:32.000000000 +0000 @@ -195,17 +195,12 @@ '''method called when an image is selected''' if response == gui.stock.ACCEPT: animation = gtk.gdk.PixbufAnimation(path) - #we don't need to resize animation here - if not animation.is_static_image(): - view = self.views[self.notebook.get_current_page()] - view.add_picture(path) - return - self._on_image_area_selector(path) + self._on_image_area_selector(path, animation.is_static_image()) class_ = extension.get_default('image chooser') class_(os.path.expanduser('~'), _on_image_selected).show() - def _on_image_area_selector(self, path): + def _on_image_area_selector(self, path, static=True): '''called when the user must resize the added image''' def _on_image_resized(response, pix): '''method called when an image is selected''' @@ -215,6 +210,12 @@ pix, avpath = self.avatar_manager.add_new_avatar_from_pix(pix) view.add_picture(avpath) + if not static: + view = self.views[self.notebook.get_current_page()] + pix, avpath = self.avatar_manager.add_new_avatar(path) + view.add_picture(avpath) + return + class_ = extension.get_default('image area selector') class_(_on_image_resized, gtk.gdk.pixbuf_new_from_file(path), parent=self).run() diff -Nru emesene2-2.0+git20101025-9e1aa6da/emesene/gui/gtkui/AvatarManager.py emesene2-2.0+git20101027-7fcd845d/emesene/gui/gtkui/AvatarManager.py --- emesene2-2.0+git20101025-9e1aa6da/emesene/gui/gtkui/AvatarManager.py 2010-10-26 00:39:10.000000000 +0000 +++ emesene2-2.0+git20101027-7fcd845d/emesene/gui/gtkui/AvatarManager.py 2010-10-27 15:52:32.000000000 +0000 @@ -80,13 +80,10 @@ fpath = os.path.join(self.get_avatars_dir(), gen_filename(filename)) try: - #FIXME temporaney hack for animations + #FIXME temporaney hack for animations = simple copy animation = gtk.gdk.PixbufAnimation(filename) if not animation.is_static_image(): - self.session.set_picture(filename) - if os.path.exists(self.avatar_path): - os.remove(self.avatar_path) - shutil.copy(filename, self.avatar_path) + shutil.copy(filename, fpath) return None, fpath else: if not os.path.exists(self.get_avatars_dir()): diff -Nru emesene2-2.0+git20101025-9e1aa6da/emesene/gui/gtkui/TextBox.py emesene2-2.0+git20101027-7fcd845d/emesene/gui/gtkui/TextBox.py --- emesene2-2.0+git20101025-9e1aa6da/emesene/gui/gtkui/TextBox.py 2010-10-26 00:39:10.000000000 +0000 +++ emesene2-2.0+git20101027-7fcd845d/emesene/gui/gtkui/TextBox.py 2010-10-27 15:52:32.000000000 +0000 @@ -270,7 +270,7 @@ def append(self, text, cedict,scroll=True): '''append formatted text to the widget''' if self.config.b_show_emoticons: - text = MarkupParser.parse_emotes(text) + text = MarkupParser.parse_emotes(text, cedict) TextBox.append(self, text, scroll)