Changeset 711

Show
Ignore:
Timestamp:
07/07/08 16:29:16 (5 months ago)
Author:
sylvain
Message:

ensured contact was removed from roster when unsubscribed

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • oss/jlib/jlib/core/contact.py

    r710 r711  
    2424    def __init__(self, parent=None): 
    2525        QAxonObject.__init__(self, parent) 
     26        QtCore.QObject.connect(self, QtCore.SIGNAL("removeContact(PyQt_PyObject)"), 
     27                               self.removeContact)  
    2628 
    2729    def setComponent(self, component): 
     
    2931        self.emit(QtCore.SIGNAL("setupOneMapping(PyQt_PyObject)"), 'inbox') 
    3032        self.emit(QtCore.SIGNAL("setupOneMapping(PyQt_PyObject)"), 'pushed') 
     33        self.emit(QtCore.SIGNAL("setupOneMapping(PyQt_PyObject)"), 'remove') 
    3134 
    3235    def getLinkages(self): 
     
    3942        return dict(rosterdisp=RosterDispatcher(), rosterhandler=self.component), linkages 
    4043 
     44    def removeContact(self, contact_jid): 
     45        self._deliver(contact_jid, 'remove') 
     46 
    4147class jlibContactComponent(component):     
    4248    Inboxes = {"inbox"        : "headstock.api.contact.Roster instance", 
    4349               "control"      : "stops the component", 
    4450               "pushed"       : "roster stanzas pushed by the server", 
     51               "remove"       : "", 
    4552               "jid"          : "headstock.api.jid.JID instance received from the server", 
    4653               "ask-activity" : "request activity status to the server for each roster contact"} 
     
    9299                    self.send(Roster(from_jid=self.from_jid, to_jid=nodeid, 
    93100                                     type=u'result', stanza_id=generate_unique()), 'result') 
    94                  
     101                     
     102            if self.dataReady('remove'): 
     103                contact_jid = self.recv('remove') 
     104                contact_jid = str(contact_jid) 
     105                r = Roster(from_jid=self.from_jid, to_jid=contact_jid, 
     106                           type=u'set', stanza_id=generate_unique()) 
     107                i = Item(contact_jid) 
     108                i.subscription = u'remove' 
     109                r.items[contact_jid] = i 
     110                self.send(r, 'result') 
     111 
    95112            if self.dataReady("inbox"): 
    96113                roster = self.recv("inbox") 
     
    126143        for nodeid in roster.items: 
    127144            contact = roster.items[nodeid] 
     145            print contact.groups 
    128146            self.addContact(contact) 
    129147 
  • oss/jlib/jlib/gui/contact.py

    r710 r711  
    4444        model.setRoster(roster) 
    4545         
     46    def removeContact(self, contact): 
     47        model = self.contacts.model() 
     48        contact = model.getContact(model.currentIndex()) 
     49        self.contact.emit(QtCore.SIGNAL("removeContact(PyQt_PyObject)"), contact.jid) 
     50 
    4651    def removedContact(self, contact): 
    4752        model = self.contacts.model() 
     
    7681                self.presence.emit(QtCore.SIGNAL("rejectSubscription(PyQt_PyObject)"), contact.jid) 
    7782                self.presence.emit(QtCore.SIGNAL("requestUnsubscription(PyQt_PyObject)"), contact.jid) 
     83                self.contact.emit(QtCore.SIGNAL("removeContact(PyQt_PyObject)"), contact.jid) 
    7884 
    7985    def contextMenuEvent(self, event):