revert unwanted commits from in 63c35c953516

This commit is contained in:
Yann Leboulanger 2010-12-19 10:52:56 +01:00
parent 2cdd95d6c6
commit 48a44e0cfe
4 changed files with 29 additions and 115 deletions

View File

@ -31,6 +31,7 @@ from common import gajim
from common import xmpp from common import xmpp
from common import dataforms from common import dataforms
from common import exceptions from common import exceptions
from common.zeroconf import zeroconf
from common.logger import LOG_DB_PATH from common.logger import LOG_DB_PATH
from common.pep import SUPPORTED_PERSONAL_USER_EVENTS from common.pep import SUPPORTED_PERSONAL_USER_EVENTS
@ -1046,6 +1047,23 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
return True return True
class ZeroconfMessageReceivedEvent(MessageReceivedEvent):
name = 'message-received'
base_network_events = []
def get_jid_resource(self):
self.fjid =self.stanza.getFrom()
if self.fjid is None:
for key in self.conn.connection.zeroconf.contacts:
if self.ip == self.conn.connection.zeroconf.contacts[key][
zeroconf.C_ADDRESS]:
self.fjid = key
break
self.fjid = unicode(self.fjid)
self.jid, self.resource = gajim.get_room_and_nick_from_fjid(self.fjid)
class GcInvitationReceivedEvent(nec.NetworkIncomingEvent): class GcInvitationReceivedEvent(nec.NetworkIncomingEvent):
name = 'gc-invitation-received' name = 'gc-invitation-received'
base_network_events = [] base_network_events = []
@ -1853,100 +1871,3 @@ class GatewayPromptReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
self.prompt = None self.prompt = None
self.prompt_jid = None self.prompt_jid = None
return True return True
class NotificationEvent(nec.NetworkIncomingEvent):
name = 'notification'
base_network_events = ['decrypted-message-received']
def detect_type(self):
if self.base_event.name == 'decrypted-message-received':
self.notif_type='msg'
def get_focused(self):
self.control_focused = False
if self.control:
parent_win = self.control.parent_win
if parent_win and self.control == parent_win.get_active_control() \
and parent_win.window.has_focus:
self.control_focused = True
def handle_incoming_msg_event(self, msg_obj):
self.control = msg_obj.session.control
self.get_focused()
if not self.control and not gajim.events.get_events(self.conn.name, \
self.control.jid, [msg_obj.mtype]):
self.first_unread = True
if msg_obj.mtype == 'pm':
nick = msg_obj.resource
else:
nick = gajim.get_name_from_jid(self.conn.name, msg_obj.jid)
if self.first_unread:
self.sound_event = 'first_message_received'
elif self.control_focused:
self.sound_event = 'next_message_received_focused'
else:
self.sound_event = 'next_message_received_unfocused'
if gajim.config.get('notification_preview_message'):
self.popup_text = msg_obj.msgtxt
if self.popup_text.startswith('/me ') or self.popup_text.startswith(
'/me\n'):
self.popup_text = '* ' + nick + self.popup_text[3:]
else:
# We don't want message preview, do_preview = False
self.popup_text = ''
if msg_obj.mtype == 'normal': # single message
self.popup_event_type = _('New Single Message')
self.popup_image = 'gajim-single_msg_recv'
self.popup_title = _('New Single Message from %(nickname)s') % \
{'nickname': nick}
elif msg_obj.mtype == 'pm':
self.popup_event_type = _('New Private Message')
self.popup_image = 'gajim-priv_msg_recv'
self.popup_title = _('New Private Message from group chat %s') % \
msg_obj.jid
if self.popup_text:
self.popup_text = _('%(nickname)s: %(message)s') % \
{'nickname': nick, 'message': self.popup_text}
else:
self.popup_text = _('Messaged by %(nickname)s') % \
{'nickname': nick}
else: # chat message
self.popup_event_type = _('New Message')
self.popup_image = 'gajim-chat_msg_recv'
self.popup_title = _('New Message from %(nickname)s') % \
{'nickname': nick}
self.popup_image = gtkgui_helpers.get_icon_path(self.popup_image, 48)
def handle_incoming_msg_event(self, msg_obj):
pass
def generate(self):
# what's needed to compute output
self.control = None
self.control_focused = False
self.first_unread = False
# For output
self.sound_event = ''
self.show_popup = False
self.popup_title = ''
self.popup_text = ''
self.popup_event_type = ''
self.popup_image = ''
self.open_chat = False
self.activate_urgency_hint = False
self.command_to_run = ''
self.show_in_notification_area = False
self.show_in_roster = False
self.detect_type()
if self.notif_type == 'msg':
self.handle_incoming_msg_event(self.base_event)
elif self.notif_type == 'pres':
self.handle_incoming_pres_event(self.base_event)
return True

View File

@ -133,8 +133,6 @@ connection_handlers.ConnectionHandlersBase, connection_handlers.ConnectionJingle
msg = session.decrypt_stanza(msg) msg = session.decrypt_stanza(msg)
except Exception: except Exception:
self.dispatch('FAILED_DECRYPT', (frm, tim, session)) self.dispatch('FAILED_DECRYPT', (frm, tim, session))
gajim.nec.push_incoming_event(FailedDecryptEvent(None,
conn=self, msg_obj=obj))
msgtxt = msg.getBody() msgtxt = msg.getBody()

View File

@ -306,8 +306,6 @@ class Interface:
elif gc_control: elif gc_control:
gc_control.print_conversation('Error %s: %s' % (obj.errcode, gc_control.print_conversation('Error %s: %s' % (obj.errcode,
obj.errmsg)) obj.errmsg))
if gc_control and gc_control.autorejoin:
gc_control.autorejoin = False
def handle_event_presence(self, obj): def handle_event_presence(self, obj):
# 'NOTIFY' (account, (jid, status, status message, resource, # 'NOTIFY' (account, (jid, status, status message, resource,

View File

@ -106,6 +106,14 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
pm = True pm = True
obj.mtype = 'pm' obj.mtype = 'pm'
highest_contact = gajim.contacts.get_contact_with_highest_priority(
self.conn.name, obj.jid)
# does this resource have the highest priority of any available?
is_highest = not highest_contact or not highest_contact.resource or \
obj.resource == highest_contact.resource or highest_contact.show ==\
'offline'
# Handle chat states # Handle chat states
contact = gajim.contacts.get_contact(self.conn.name, obj.jid, contact = gajim.contacts.get_contact(self.conn.name, obj.jid,
obj.resource) obj.resource)
@ -134,14 +142,13 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
# THIS MUST BE AFTER chatstates handling # THIS MUST BE AFTER chatstates handling
# AND BEFORE playsound (else we ear sounding on chatstates!) # AND BEFORE playsound (else we ear sounding on chatstates!)
if not obj.msgtxt: # empty message text if not obj.msgtxt: # empty message text
return True return
if gajim.config.get_per('accounts', self.conn.name, if gajim.config.get_per('accounts', self.conn.name,
'ignore_unknown_contacts') and not gajim.contacts.get_contacts( 'ignore_unknown_contacts') and not gajim.contacts.get_contacts(
self.conn.name, obj.jid) and not pm: self.conn.name, obj.jid) and not pm:
return True return
#FIXME Remove after advanced_notif will be removed
if not contact: if not contact:
# contact is not in the roster, create a fake one to display # contact is not in the roster, create a fake one to display
# notification # notification
@ -151,14 +158,6 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
advanced_notif_num = notify.get_advanced_notification( advanced_notif_num = notify.get_advanced_notification(
'message_received', self.conn.name, contact) 'message_received', self.conn.name, contact)
highest_contact = gajim.contacts.get_contact_with_highest_priority(
self.conn.name, obj.jid)
# does this resource have the highest priority of any available?
is_highest = not highest_contact or not highest_contact.resource or \
obj.resource == highest_contact.resource or highest_contact.show ==\
'offline'
if not pm and is_highest: if not pm and is_highest:
jid_of_control = obj.jid jid_of_control = obj.jid
else: else:
@ -171,7 +170,6 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
self.control = ctrl self.control = ctrl
self.control.set_session(self) self.control.set_session(self)
#TODO handled
# Is it a first or next message received ? # Is it a first or next message received ?
first = False first = False
if not self.control and not gajim.events.get_events(self.conn.name, \ if not self.control and not gajim.events.get_events(self.conn.name, \
@ -203,9 +201,8 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
msg = obj.msgtxt msg = obj.msgtxt
if obj.subject: if obj.subject:
msg = _('Subject: %s') % obj.subject + '\n' + msg msg = _('Subject: %s') % obj.subject + '\n' + msg
#TODO handled
focused = False focused = False
if self.control: if self.control:
parent_win = self.control.parent_win parent_win = self.control.parent_win
if parent_win and self.control == parent_win.get_active_control() \ if parent_win and self.control == parent_win.get_active_control() \