Changeset 9980
- Timestamp:
- 07/22/08 16:13:37 (5 weeks ago)
- Files:
-
- 1 modified
-
trunk/src/gajim.py (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gajim.py
r9978 r9980 590 590 591 591 def handle_event_notify(self, account, array): 592 # 'NOTIFY' (account, (jid, status, status message, resource, priority,593 # keyID, timestamp, contact_nickname))592 # 'NOTIFY' (account, (jid, status, status message, resource, 593 # priority, # keyID, timestamp, contact_nickname)) 594 594 # 595 595 # Contact changed show … … 597 597 # FIXME: Drop and rewrite... 598 598 599 statuss = ['offline', 'error', 'online', 'chat', 'away', 'xa', 'dnd',600 ' invisible']599 statuss = ['offline', 'error', 'online', 'chat', 'away', 'xa', 600 'dnd', 'invisible'] 601 601 # Ignore invalid show 602 602 if array[1] not in statuss: … … 623 623 ji = jid 624 624 625 highest = gajim.contacts.get_contact_with_highest_priority(account, jid) 625 highest = gajim.contacts. \ 626 get_contact_with_highest_priority(account, jid) 626 627 was_highest = (highest and highest.resource == resource) 627 628 … … 647 648 self.roster.draw_contact(jid, account) 648 649 649 if old_show == new_show and contact1.status == status_message and \ 650 if old_show == new_show and \ 651 contact1.status == status_message and \ 650 652 contact1.priority == priority: # no change 651 653 return 652 654 else: 653 contact1 = gajim.contacts.get_first_contact_from_jid(account, ji) 655 contact1 = gajim.contacts. \ 656 get_first_contact_from_jid(account, ji) 654 657 if not contact1: 655 # Presence of another resource of our jid 656 # Create SelfContact and add to roster 657 if resource == gajim.connections[account].server_resource: 658 # Presence of another resource of our 659 # jid 660 # Create self contact and add to roster 661 if resource == gajim.connections \ 662 [account].server_resource: 658 663 return 659 contact1 = gajim.contacts.create_contact(jid=ji, 660 name=gajim.nicks[account], groups=['self_contact'], 661 show=array[1], status=status_message, sub='both', ask='none', 662 priority=priority, keyID=keyID, resource=resource) 664 contact1 = gajim.contacts. \ 665 create_contact(jid=ji, 666 name=gajim.nicks[account], 667 groups=['self_contact'], 668 show=array[1], 669 status=status_message, 670 sub='both', ask='none', 671 priority=priority, keyID=keyID, 672 resource=resource) 663 673 old_show = 0 664 gajim.contacts.add_contact(account, contact1) 674 gajim.contacts.add_contact(account, 675 contact1) 665 676 lcontact.append(contact1) 666 677 elif contact1.show in statuss: 667 678 old_show = statuss.index(contact1.show) 668 # FIXME: What Am I?679 # FIXME: What am I? 669 680 if (resources != [''] and (len(lcontact) != 1 or 670 lcontact[0].show != 'offline')) and jid.find('@') > 0: 681 lcontact[0].show != 'offline')) and \ 682 jid.find('@') > 0: 671 683 old_show = 0 672 contact1 = gajim.contacts.copy_contact(contact1) 684 contact1 = gajim.contacts. \ 685 copy_contact(contact1) 673 686 lcontact.append(contact1) 674 687 contact1.resource = resource … … 679 692 # It's not an agent 680 693 if old_show == 0 and new_show > 1: 681 if not contact1.jid in gajim.newly_added[account]: 682 gajim.newly_added[account].append(contact1.jid) 683 if contact1.jid in gajim.to_be_removed[account]: 684 gajim.to_be_removed[account].remove(contact1.jid) 685 gobject.timeout_add_seconds(5, self.roster.remove_newly_added, 694 if not contact1.jid in \ 695 gajim.newly_added[account]: 696 gajim.newly_added[account]. \ 697 append(contact1.jid) 698 if contact1.jid in \ 699 gajim.to_be_removed[account]: 700 gajim.to_be_removed[account]. \ 701 remove(contact1.jid) 702 gobject.timeout_add_seconds(5, self. \ 703 roster.remove_newly_added, 686 704 contact1.jid, account) 687 elif old_show > 1 and new_show == 0 and gajim.connections[account].\ 688 connected > 1: 689 if not contact1.jid in gajim.to_be_removed[account]: 690 gajim.to_be_removed[account].append(contact1.jid) 691 if contact1.jid in gajim.newly_added[account]: 692 gajim.newly_added[account].remove(contact1.jid) 693 self.roster.draw_contact(contact1.jid, account) 694 gobject.timeout_add_seconds(5, self.roster.remove_to_be_removed, 705 elif old_show > 1 and new_show == 0 and \ 706 gajim.connections[account].connected > 1: 707 if not contact1.jid in \ 708 gajim.to_be_removed[account]: 709 gajim.to_be_removed[account]. \ 710 append(contact1.jid) 711 if contact1.jid in \ 712 gajim.newly_added[account]: 713 gajim.newly_added[account]. \ 714 remove(contact1.jid) 715 self.roster.draw_contact(contact1.jid, 716 account) 717 gobject.timeout_add_seconds(5, self. \ 718 roster.remove_to_be_removed, 695 719 contact1.jid, account) 696 720 contact1.show = array[1] … … 711 735 # Update existing iter 712 736 self.roster.draw_contact(ji, account) 713 if new_show > 1 and ji in gajim.transport_avatar[account]: 714 # transport just signed in. request avatars 715 for jid_ in gajim.transport_avatar[account][ji]: 716 gajim.connections[account].request_vcard(jid_) 717 # transport just signed in/out, don't show popup notifications 718 # for 30s 737 if new_show > 1 and ji in \ 738 gajim.transport_avatar[account]: 739 # transport just signed in. 740 # request avatars 741 for jid_ in gajim.transport_avatar \ 742 [account][ji]: 743 gajim.connections[account]. \ 744 request_vcard(jid_) 745 # transport just signed in/out, don't show 746 # popup notifications for 30s 719 747 account_ji = account + '/' + ji 720 gajim.block_signed_in_notifications[account_ji] = True 721 gobject.timeout_add_seconds(30, self.unblock_signed_in_notifications, 748 gajim.block_signed_in_notifications \ 749 [account_ji] = True 750 gobject.timeout_add_seconds(30, 751 self.unblock_signed_in_notifications, 722 752 account_ji) 723 753 locations = (self.instances, self.instances[account]) … … 725 755 if location.has_key('add_contact'): 726 756 if old_show == 0 and new_show > 1: 727 location['add_contact'].transport_signed_in(jid) 757 location['add_contact']. \ 758 transport_signed_in(jid) 728 759 break 729 760 elif old_show > 1 and new_show == 0: 730 location['add_contact'].transport_signed_out(jid) 761 location['add_contact']. \ 762 transport_signed_out( 763 jid) 731 764 break 732 765 elif ji in jid_list: … … 737 770 contact1.our_chatstate = contact1.chatstate = \ 738 771 contact1.composing_xep = None 739 gajim.connections[account].remove_transfers_for_contact(contact1) 740 self.roster.chg_contact_status(contact1, array[1], status_message, 741 account) 772 # TODO: This causes problems when another 773 # resource signs off! 774 gajim.connections[account]. \ 775 remove_transfers_for_contact(contact1) 776 self.roster.chg_contact_status(contact1, array[1], 777 status_message, account) 742 778 # Notifications 743 779 if old_show < 2 and new_show > 1: 744 notify.notify('contact_connected', jid, account, status_message) 780 notify.notify('contact_connected', jid, 781 account, status_message) 745 782 if self.remote_ctrl: 746 self.remote_ctrl.raise_signal('ContactPresence', 783 self.remote_ctrl.raise_signal( 784 'ContactPresence', 747 785 (account, array)) 748 786 749 787 elif old_show > 1 and new_show < 2: 750 notify.notify('contact_disconnected', jid, account, status_message) 788 notify.notify('contact_disconnected', jid, 789 ccount, status_message) 751 790 if self.remote_ctrl: 752 self.remote_ctrl.raise_signal('ContactAbsence', (account, array)) 791 self.remote_ctrl.raise_signal( 792 'ContactAbsence', 793 (account, array)) 753 794 # FIXME: stop non active file transfers 754 elif new_show > 1: # Status change (not connected/disconnected or error (<1)) 755 notify.notify('status_change', jid, account, [new_show, 756 status_message]) 795 # Status change (not connected/disconnected or 796 # error (<1)) 797 elif new_show > 1: 798 notify.notify('status_change', jid, account, 799 [new_show, status_message]) 757 800 if self.remote_ctrl: 758 self.remote_ctrl.raise_signal('ContactStatus', (account, array)) 801 self.remote_ctrl.raise_signal( 802 'ContactStatus', 803 (account, array)) 759 804 else: 760 # FIXME: Msn transport (CMSN1.2.1 and PyMSN) doesn't follow the XEP 761 # still the case in 2008 762 # It's maybe a GC_NOTIFY (specialy for MSN gc) 763 self.handle_event_gc_notify(account, (jid, array[1], status_message, 764 array[3], None, None, None, None, None, [], None, None)) 765 766 highest = gajim.contacts.get_contact_with_highest_priority(account, jid) 805 # FIXME: MSN transport (CMSN1.2.1 and PyMSN) don't 806 # follow the XEP, still the case in 2008. 807 # It's maybe a GC_NOTIFY (specialy for MSN gc) 808 self.handle_event_gc_notify(account, (jid, array[1], 809 status_message, array[3], None, None, None, 810 None, None, [], None, None)) 811 812 highest = gajim.contacts.get_contact_with_highest_priority( 813 account, jid) 767 814 is_highest = (highest and highest.resource == resource) 768 815
