Add presence service-scope signals when new services appear on buddies, so that client's don't have to connect signal handlers to every single buddy
This commit is contained in:
parent
63bff5cecd
commit
5938a6dc14
@ -69,6 +69,10 @@ class PresenceService(gobject.GObject):
|
|||||||
([gobject.TYPE_PYOBJECT])),
|
([gobject.TYPE_PYOBJECT])),
|
||||||
'buddy-disappeared': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
|
'buddy-disappeared': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
|
||||||
([gobject.TYPE_PYOBJECT])),
|
([gobject.TYPE_PYOBJECT])),
|
||||||
|
'service-appeared': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
|
||||||
|
([gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT])),
|
||||||
|
'service-disappeared': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
|
||||||
|
([gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT])),
|
||||||
'activity-announced': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
|
'activity-announced': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
|
||||||
([gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT])),
|
([gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT])),
|
||||||
'new-service-adv': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
|
'new-service-adv': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
|
||||||
@ -197,7 +201,9 @@ class PresenceService(gobject.GObject):
|
|||||||
try:
|
try:
|
||||||
buddy = self._buddies[name]
|
buddy = self._buddies[name]
|
||||||
buddy_was_valid = buddy.is_valid()
|
buddy_was_valid = buddy.is_valid()
|
||||||
buddy.add_service(service)
|
service_added = buddy.add_service(service)
|
||||||
|
if service_added:
|
||||||
|
self.emit('service-appeared', buddy, service)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
# Should this service mark the owner?
|
# Should this service mark the owner?
|
||||||
owner_nick = env.get_nick_name()
|
owner_nick = env.get_nick_name()
|
||||||
@ -208,6 +214,7 @@ class PresenceService(gobject.GObject):
|
|||||||
else:
|
else:
|
||||||
buddy = Buddy.Buddy(service)
|
buddy = Buddy.Buddy(service)
|
||||||
self._buddies[name] = buddy
|
self._buddies[name] = buddy
|
||||||
|
self.emit('service-appeared', buddy, service)
|
||||||
if not buddy_was_valid and buddy.is_valid():
|
if not buddy_was_valid and buddy.is_valid():
|
||||||
self.emit("buddy-appeared", buddy)
|
self.emit("buddy-appeared", buddy)
|
||||||
return buddy
|
return buddy
|
||||||
@ -351,6 +358,7 @@ class PresenceService(gobject.GObject):
|
|||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
buddy.remove_service(service)
|
buddy.remove_service(service)
|
||||||
|
self.emit('service-disappeared', buddy, service)
|
||||||
if not buddy.is_valid():
|
if not buddy.is_valid():
|
||||||
self.emit("buddy-disappeared", buddy)
|
self.emit("buddy-disappeared", buddy)
|
||||||
del self._buddies[name]
|
del self._buddies[name]
|
||||||
|
Loading…
Reference in New Issue
Block a user