Logo Search packages:      
Sourcecode: gajim version File versions  Download package

def roster_window::RosterWindow::on_message (   self,
  jid,
  msg,
  tim,
  account,
  encrypted = False,
  msg_type = '',
  subject = None,
  resource = '',
  msg_id = None 
)

when we receive a message

Definition at line 2134 of file roster_window.py.

                                                                              :
            '''when we receive a message'''
            contact = None
            # if chat window will be for specific resource
            resource_for_chat = resource
            # Try to catch the contact with correct resource
            if resource:
                  fjid = jid + '/' + resource
                  contact = gajim.contacts.get_contact(account, jid, resource)
            # Default to highest prio
            highest_contact = gajim.contacts.get_contact_with_highest_priority(
                  account, jid)
            if not contact:
                  fjid = jid
                  resource_for_chat = None
                  contact = highest_contact
            if not contact:
                  keyID = ''
                  attached_keys = gajim.config.get_per('accounts', account,
                        'attached_gpg_keys').split()
                  if jid in attached_keys:
                        keyID = attached_keys[attached_keys.index(jid) + 1]
                  contact = gajim.contacts.create_contact(jid = jid,
                        name = jid.split('@')[0], groups = [_('Not in Roster')],
                        show = 'not in roster', status = '', ask = 'none',
                        keyID = keyID, resource = resource)
                  gajim.contacts.add_contact(account, contact)
                  self.add_contact_to_roster(jid, account)

            iters = self.get_contact_iter(jid, account)
            if iters:
                  path = self.tree.get_model().get_path(iters[0])
            else:
                  path = None
            autopopup = gajim.config.get('autopopup')
            autopopupaway = gajim.config.get('autopopupaway')

            # Look for a chat control that has the given resource
            ctrl = gajim.interface.msg_win_mgr.get_control(fjid, account)
            if not ctrl:
                  # if not, if message comes from highest prio, get control or open one
                  # without resource
                  if highest_contact and contact.resource == highest_contact.resource:
                        ctrl = gajim.interface.msg_win_mgr.get_control(jid, account)
                        fjid = jid
                        resource_for_chat = None

            # Do we have a queue?
            qs = gajim.awaiting_events[account]
            no_queue = True
            if qs.has_key(fjid):
                  no_queue = False
            popup = False
            if autopopup and (autopopupaway or gajim.connections[account].connected \
                  in (1, 2)):
                  popup = True

            if msg_type == 'normal' and popup: # it's single message to be autopopuped
                  dialogs.SingleMessageWindow(account, contact.jid,
                        action = 'receive', from_whom = jid, subject = subject,
                        message = msg, resource = resource)
                  return

            # We print if window is opened and it's not a single message
            if ctrl and msg_type != 'normal':
                  typ = ''
                  if msg_type == 'error':
                        typ = 'status'
                  ctrl.print_conversation(msg, typ, tim = tim, encrypted = encrypted,
                                    subject = subject)
                  if msg_id:
                        gajim.logger.set_read_messages([msg_id])
                  return

            # We save it in a queue
            if no_queue:
                  qs[fjid] = []
            kind = 'chat'
            if msg_type == 'normal':
                  kind = 'normal'
            qs[fjid].append((kind, (msg, subject, msg_type, tim, encrypted,
                  resource, msg_id)))
            self.nb_unread += 1
            if popup:
                  if not ctrl:
                        self.new_chat(contact, account, resource = resource_for_chat)
                        if path:
                              self.tree.expand_row(path[0:1], False)
                              self.tree.expand_row(path[0:2], False)
                              self.tree.scroll_to_cell(path)
                              self.tree.set_cursor(path)
            else:
                  if no_queue: # We didn't have a queue: we change icons
                        self.draw_contact(jid, account)
                        # Redraw parent too
                        self.draw_parent_contact(jid, account)
                  if gajim.interface.systray_enabled:
                        gajim.interface.systray.add_jid(fjid, account, kind)
                  self.show_title() # we show the * or [n]
                  if not path:
                        self.add_contact_to_roster(jid, account)
                        iters = self.get_contact_iter(jid, account)
                        path = self.tree.get_model().get_path(iters[0])
                  self.tree.expand_row(path[0:1], False)
                  self.tree.expand_row(path[0:2], False)
                  self.tree.scroll_to_cell(path)
                  self.tree.set_cursor(path)

      def on_preferences_menuitem_activate(self, widget):


Generated by  Doxygen 1.6.0   Back to index