This commit is contained in:
Marco Pesenti Gritti 2006-05-19 18:05:59 -04:00
parent 11a1925c2d
commit b4d4d9eb21
3 changed files with 29 additions and 11 deletions

View File

@ -251,7 +251,7 @@ class BrowserActivity(activity.Activity):
escaped_title = saxutils.escape(self.embed.get_title())
escaped_address = saxutils.escape(address)
chat_shell.send_message('<richtext><link href="' + escaped_address +
chat_shell.send_text_message('<richtext><link href="' + escaped_address +
'">' + escaped_title + '</link></richtext>')
def __title_cb(self, embed):

View File

@ -140,7 +140,7 @@ class Chat(activity.Activity):
serializer = richtext.RichTextSerializer()
text = serializer.serialize(buf)
self.send_message(text)
self.send_text_message(text)
buf.set_text("")
buf.place_cursor(buf.get_start_iter())
@ -186,9 +186,6 @@ class Chat(activity.Activity):
print "act %d: in activity_on_got_focus" % self.activity_get_id()
# FIXME self._controller.notify_activate(self)
def recv_message(self, buddy, msg):
self._insert_rich_message(buddy.get_nick_name(), msg)
def _insert_rich_message(self, nick, msg):
buf = self._chat_view.get_buffer()
aniter = buf.get_end_iter()
@ -200,7 +197,16 @@ class Chat(activity.Activity):
aniter = buf.get_end_iter()
buf.insert(aniter, "\n")
def send_message(self, text):
def _insert_sketch(self, sketch):
"""Insert a sketch object into the chat buffer."""
pass
def recv_message(self, buddy, msg):
"""Insert a remote chat message into the chat buffer."""
self._insert_rich_message(buddy.get_nick_name(), msg)
def send_text_message(self, text):
"""Send a chat message and insert it into the local buffer."""
if len(text) <= 0:
return
self._stream_writer.write(text)
@ -402,7 +408,7 @@ class GroupChat(Chat):
self._buddy_list_model.set(aniter, self._MODEL_COL_ICON, self._pixbuf_active_chat)
def _group_recv_message(self, buddy, msg):
Chat.recv_message(self, buddy, msg)
self.recv_message(buddy, msg)
self._controller.notify_new_message(self, None)
def _buddy_recv_message(self, buddy, msg):
@ -436,8 +442,8 @@ class ChatShell(dbus.service.Object):
self._group_chat.activity_connect_to_shell()
@dbus.service.method('com.redhat.Sugar.ChatShell')
def send_message(self, message):
self._group_chat.send_message(message)
def send_text_message(self, message):
self._group_chat.send_text_message(message)
if len(sys.argv) > 1 and sys.argv[1] == "--console":
sys.stdout = LogWriter("Chat")

View File

@ -209,8 +209,16 @@ class RichTextHandler(xml.sax.handler.ContentHandler):
self.buf = buf
self.serializer = serializer
self.tags = []
self._in_richtext = False
self._done = False
def startElement(self, name, attrs):
# Look for, and only start parsing after 'richtext'
if not self._in_richtext and name == "richtext":
self._in_richtext = True
if not self._in_richtext:
return
if name != "richtext":
tag = self.serializer.deserialize_element(name, attrs)
self.tags.append(tag)
@ -230,8 +238,12 @@ class RichTextHandler(xml.sax.handler.ContentHandler):
"link", "link-address")
def endElement(self, name):
if not self._done and self._in_richtext:
if name != "richtext":
self.tags.pop()
if name == "richtext":
self._done = True
self._in_richtext = False
class RichTextSerializer:
def __init__(self):