From cb51401903348230a408ee11714acbc06c2c3951 Mon Sep 17 00:00:00 2001
From: Yann Leboulanger <asterix@lagaule.org>
Date: Tue, 26 Feb 2008 08:31:48 +0000
Subject: [PATCH] [shivan] don't trat emoticons created with parenthesis
 arround status message. fixes #3368

---
 src/chat_control.py          | 14 +++++++-------
 src/conversation_textview.py | 11 ++++++-----
 src/gajim.py                 |  9 +++++----
 src/roster_window.py         | 10 +++++-----
 4 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/src/chat_control.py b/src/chat_control.py
index 388d9fd236..93aa148451 100644
--- a/src/chat_control.py
+++ b/src/chat_control.py
@@ -643,9 +643,8 @@ class ChatControlBase(MessageControl):
 		self.orig_msg = None
 
 	def print_conversation_line(self, text, kind, name, tim,
-		other_tags_for_name = [], other_tags_for_time = [],
-		other_tags_for_text = [], count_as_new = True,
-		subject = None, old_kind = None, xhtml = None):
+	other_tags_for_name=[], other_tags_for_time=[], other_tags_for_text=[],
+	count_as_new=True, subject=None, old_kind=None, xhtml=None, simple=False):
 		'''prints 'chat' type messages'''
 		jid = self.contact.jid
 		full_jid = self.get_full_jid()
@@ -655,7 +654,7 @@ class ChatControlBase(MessageControl):
 			end = True
 		textview.print_conversation_line(text, jid, kind, name, tim,
 			other_tags_for_name, other_tags_for_time, other_tags_for_text,
-			subject, old_kind, xhtml)
+			subject, old_kind, xhtml, simple=simple)
 
 		if not count_as_new:
 			return
@@ -1518,8 +1517,8 @@ class ChatControl(ChatControlBase):
 		self._show_lock_image(e2e_is_active, 'E2E', e2e_is_active, self.session and \
 				self.session.is_loggable()) 
 
-	def print_conversation(self, text, frm = '', tim = None,
-		encrypted = False, subject = None, xhtml = None):
+	def print_conversation(self, text, frm='', tim=None, encrypted=False,
+	subject=None, xhtml=None, simple=False):
 		'''Print a line in the conversation:
 		if contact is set to status: it's a status message
 		if contact is set to another value: it's an outgoing message
@@ -1567,7 +1566,8 @@ class ChatControl(ChatControlBase):
 					if xhtml:
 						xhtml = '<body xmlns="%s">%s</body>' % (NS_XHTML, xhtml)
 		ChatControlBase.print_conversation_line(self, text, kind, name, tim,
-			subject = subject, old_kind = self.old_msg_kind, xhtml = xhtml)
+			subject=subject, old_kind=self.old_msg_kind, xhtml=xhtml,
+			simple=simple)
 		if text.startswith('/me ') or text.startswith('/me\n'):
 			self.old_msg_kind = None
 		else:
diff --git a/src/conversation_textview.py b/src/conversation_textview.py
index 07998af66e..7a1cd7c53e 100644
--- a/src/conversation_textview.py
+++ b/src/conversation_textview.py
@@ -982,8 +982,8 @@ class ConversationTextview:
 		buffer.insert_with_tags_by_name(end_iter, '\n', 'eol')
 
 	def print_conversation_line(self, text, jid, kind, name, tim,
-	other_tags_for_name = [], other_tags_for_time = [], other_tags_for_text = [],
-	subject = None, old_kind = None, xhtml = None):
+	other_tags_for_name=[], other_tags_for_time=[], other_tags_for_text=[],
+	subject=None, old_kind=None, xhtml=None, simple=False):
 		'''prints 'chat' type messages'''
 		buffer = self.tv.get_buffer()
 		buffer.begin_user_action()
@@ -1004,7 +1004,8 @@ class ConversationTextview:
 		# else twice (one for end bound, one for start bound)
 		mark = None
 		if buffer.get_char_count() > 0:
-			buffer.insert_with_tags_by_name(end_iter, '\n', 'eol')
+			if not simple:
+				buffer.insert_with_tags_by_name(end_iter, '\n', 'eol')
 			mark = buffer.create_mark(None, end_iter, left_gravity=True)
 			self.marks_queue.put(mark)
 		if not mark:
@@ -1019,12 +1020,12 @@ class ConversationTextview:
 			# We don't have tim for outgoing messages...
 			tim = time.localtime()
 		current_print_time = gajim.config.get('print_time')
-		if current_print_time == 'always' and kind != 'info':
+		if current_print_time == 'always' and kind != 'info' and not simple:
 			timestamp_str = self.get_time_to_show(tim)
 			timestamp = time.strftime(timestamp_str, tim)
 			buffer.insert_with_tags_by_name(end_iter, timestamp,
 				*other_tags_for_time)
-		elif current_print_time == 'sometimes' and kind != 'info':
+		elif current_print_time == 'sometimes' and kind != 'info' and not simple:
 			every_foo_seconds = 60 * gajim.config.get(
 				'print_ichat_every_foo_minutes')
 			seconds_passed = time.mktime(tim) - self.last_time_printout
diff --git a/src/gajim.py b/src/gajim.py
index ae9f36d52e..648efc187e 100755
--- a/src/gajim.py
+++ b/src/gajim.py
@@ -1198,12 +1198,13 @@ class Interface:
 				contact.show = show
 				contact.status = status
 				uf_show = helpers.get_uf_show(show)
+				ctrl.print_conversation(_('%s is now %s') % (nick, uf_show),
+					'status')
 				if status:
-					ctrl.print_conversation(_('%s is now %s (%s)') % (nick, uf_show,
-						status), 'status')
+					ctrl.print_conversation(' (', 'status', simple=True)
+					ctrl.print_conversation('%s' % (status), 'status', simple=True)
+					ctrl.print_conversation(')', 'status', simple=True)
 				else:
-					ctrl.print_conversation(_('%s is now %s') % (nick, uf_show),
-						'status')
 				ctrl.parent_win.redraw_tab(ctrl)
 				ctrl.update_ui()
 			if self.remote_ctrl:
diff --git a/src/roster_window.py b/src/roster_window.py
index cb56308a70..661506b570 100644
--- a/src/roster_window.py
+++ b/src/roster_window.py
@@ -1402,12 +1402,12 @@ class RosterWindow:
 			win.redraw_tab(ctrl)
 
 			uf_show = helpers.get_uf_show(show)
+			ctrl.print_conversation(_('%s is now %s') % (name, uf_show),
+				'status')
 			if status:
-				ctrl.print_conversation(_('%s is now %s (%s)') % (name, uf_show,
-					status), 'status')
-			else: # No status message
-				ctrl.print_conversation(_('%s is now %s') % (name, uf_show),
-					'status')
+				ctrl.print_conversation(' (', 'status', simple=True)
+				ctrl.print_conversation('%s' % (status), 'status', simple=True)
+				ctrl.print_conversation(')', 'status', simple=True)
 
 		# unset custom status
 		if gajim.interface.status_sent_to_users.has_key(account) and \
-- 
GitLab