diff --git a/data/glade/preferences_window.glade b/data/glade/preferences_window.glade
index 7f8ad20d8..91780c9d7 100644
--- a/data/glade/preferences_window.glade
+++ b/data/glade/preferences_window.glade
@@ -485,6 +485,61 @@ Per type
+
+
+ True
+ False
+ 0
+
+
+
+ True
+ Treat incoming and single messages as:
+ False
+ False
+ GTK_JUSTIFY_LEFT
+ False
+ False
+ 0.5
+ 0.5
+ 1
+ 0
+ PANGO_ELLIPSIZE_NONE
+ -1
+ False
+ 0
+
+
+ 0
+ False
+ False
+
+
+
+
+
+ True
+ Determined by sender
+Chat message
+Single message
+ False
+ True
+
+
+
+ 0
+ False
+ False
+
+
+
+
+ 0
+ False
+ True
+
+
+
True
diff --git a/src/common/config.py b/src/common/config.py
index 504d1369a..84f300584 100644
--- a/src/common/config.py
+++ b/src/common/config.py
@@ -38,6 +38,7 @@ opt_str = [ 'string', 0 ]
opt_bool = [ 'boolean', 0 ]
opt_color = [ 'color', '^(#[0-9a-fA-F]{6})|()$' ]
opt_one_window_types = ['never', 'always', 'peracct', 'pertype']
+opt_treat_incoming_messages = ['', 'chat', 'normal']
class Config:
@@ -223,6 +224,7 @@ class Config:
'enable_negative_priority': [ opt_bool, False, _('If True, you will be able to set a negative priority to your account in account modification window. BE CAREFUL, when you are logged in with a negative priority, you will NOT receive any message from your server.')],
'use_gnomekeyring': [opt_bool, True, _('If True, Gajim will use Gnome Keyring (if available) to store account passwords.')],
'show_contacts_number': [opt_bool, True, _('If True, Gajim will show number of online and total contacts in account and group rows.')],
+ 'treat_incoming_messages': [ opt_str, '', _('Can be empty, \'chat\' or \'normal\'. If not empty, treat all incoming messages as if they were of this type')],
}
__options_per_key = {
diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py
index efa88b5dd..24f5a1918 100644
--- a/src/common/connection_handlers.py
+++ b/src/common/connection_handlers.py
@@ -1446,6 +1446,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
subject = subject)
self.dispatch('MSGERROR', (frm, msg.getErrorCode(), error_msg, msgtxt,
tim))
+ return
elif mtype == 'groupchat':
has_timestamp = False
if msg.timestamp:
@@ -1459,9 +1460,10 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
if not self.last_history_line.has_key(jid):
return
self.dispatch('GC_MSG', (frm, msgtxt, tim, has_timestamp, msghtml))
- if self.name not in no_log_for and not int(float(time.mktime(tim))) <= \
- self.last_history_line[jid] and msgtxt:
+ if self.name not in no_log_for and not int(float(time.mktime(tim)))\
+ <= self.last_history_line[jid] and msgtxt:
gajim.logger.write('gc_msg', frm, msgtxt, tim = tim)
+ return
elif mtype == 'chat': # it's type 'chat'
if not msg.getTag('body') and chatstate is None: #no
return
@@ -1469,8 +1471,6 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
no_log_for and msgtxt:
msg_id = gajim.logger.write('chat_msg_recv', frm, msgtxt, tim = tim,
subject = subject)
- self.dispatch('MSG', (frm, msgtxt, tim, encrypted, mtype, subject,
- chatstate, msg_id, composing_jep, user_nick, msghtml))
else: # it's single message
if invite is not None:
item = invite.getTag('invite')
@@ -1483,8 +1483,12 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
if self.name not in no_log_for and jid not in no_log_for and msgtxt:
gajim.logger.write('single_msg_recv', frm, msgtxt, tim = tim,
subject = subject)
- self.dispatch('MSG', (frm, msgtxt, tim, encrypted, 'normal',
- subject, chatstate, msg_id, composing_jep, user_nick, msghtml))
+ mtype = 'normal'
+ treat_as = gajim.config.get('treat_incoming_messages')
+ if treat_as:
+ mtype = treat_as
+ self.dispatch('MSG', (frm, msgtxt, tim, encrypted, mtype,
+ subject, chatstate, msg_id, composing_jep, user_nick, msghtml))
# END messageCB
def _pubsubEventCB(self, con, msg):
diff --git a/src/config.py b/src/config.py
index bd61dcd68..d4507e3ff 100644
--- a/src/config.py
+++ b/src/config.py
@@ -84,6 +84,8 @@ class PreferencesWindow:
self.notebook = self.xml.get_widget('preferences_notebook')
self.one_window_type_combobox =\
self.xml.get_widget('one_window_type_combobox')
+ self.treat_incoming_messages_combobox =\
+ self.xml.get_widget('treat_incoming_messages_combobox')
#FIXME: remove when ANC will be implemented
w = self.xml.get_widget('hbox3020')
@@ -140,7 +142,7 @@ class PreferencesWindow:
if not gajim.config.get('emoticons_theme'):
emoticons_combobox.set_active(len(l)-1)
- #iconset
+ # iconset
iconsets_list = os.listdir(os.path.join(gajim.DATA_DIR, 'iconsets'))
# new model, image in 0, string in 1
model = gtk.ListStore(gtk.Image, str)
@@ -182,6 +184,14 @@ class PreferencesWindow:
else:
self.one_window_type_combobox.set_active(0)
+ # Set default for treat incoming messages
+ choices = common.config.opt_treat_incoming_messages
+ type = gajim.config.get('treat_incoming_messages')
+ if type in choices:
+ self.treat_incoming_messages_combobox.set_active(choices.index(type))
+ else:
+ self.treat_incoming_messages_combobox.set_active(0)
+
# Use transports iconsets
st = gajim.config.get('use_transports_iconsets')
self.xml.get_widget('transports_iconsets_checkbutton').set_active(st)
@@ -353,7 +363,7 @@ class PreferencesWindow:
gajim.config.set('soundplayer', command)
break
- #sounds treeview
+ # sounds treeview
self.sound_tree = self.xml.get_widget('sounds_treeview')
# active, event ui name, path to sound file, event_config_name
@@ -380,31 +390,31 @@ class PreferencesWindow:
st = gajim.config.get('autoaway')
self.auto_away_checkbutton.set_active(st)
- #Autoawaytime
+ # Autoawaytime
st = gajim.config.get('autoawaytime')
self.auto_away_time_spinbutton.set_value(st)
self.auto_away_time_spinbutton.set_sensitive(gajim.config.get('autoaway'))
- #autoaway message
+ # autoaway message
st = gajim.config.get('autoaway_message')
self.auto_away_message_entry.set_text(st)
self.auto_away_message_entry.set_sensitive(gajim.config.get('autoaway'))
- #Autoxa
+ # Autoxa
st = gajim.config.get('autoxa')
self.auto_xa_checkbutton.set_active(st)
- #Autoxatime
+ # Autoxatime
st = gajim.config.get('autoxatime')
self.auto_xa_time_spinbutton.set_value(st)
self.auto_xa_time_spinbutton.set_sensitive(gajim.config.get('autoxa'))
- #autoxa message
+ # autoxa message
st = gajim.config.get('autoxa_message')
self.auto_xa_message_entry.set_text(st)
self.auto_xa_message_entry.set_sensitive(gajim.config.get('autoxa'))
- #ask_status when online / offline
+ # ask_status when online / offline
st = gajim.config.get('ask_online_status')
self.xml.get_widget('prompt_online_status_message_checkbutton').\
set_active(st)
@@ -438,7 +448,7 @@ class PreferencesWindow:
renderer.connect('toggled', self.default_msg_toggled_cb)
self.fill_default_msg_treeview()
- #Status messages
+ # Status messages
self.msg_tree = self.xml.get_widget('msg_treeview')
model = gtk.ListStore(str, str)
self.msg_tree.set_model(model)
@@ -453,7 +463,7 @@ class PreferencesWindow:
buf = self.xml.get_widget('msg_textview').get_buffer()
buf.connect('changed', self.on_msg_textview_changed)
- #open links with
+ # open links with
if os.name == 'nt':
applications_frame = self.xml.get_widget('applications_frame')
applications_frame.set_no_show_all(True)
@@ -650,6 +660,11 @@ class PreferencesWindow:
gajim.interface.save_config()
gajim.interface.msg_win_mgr.reconfig()
+ def on_treat_incoming_messages_combobox_changed(self, widget):
+ active = widget.get_active()
+ config_type = common.config.opt_treat_incoming_messages[active]
+ gajim.config.set('treat_incoming_messages', config_type)
+
def apply_speller(self):
for acct in gajim.connections:
for ctrl in gajim.interface.msg_win_mgr.controls():