Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
This commit is contained in:
parent
fded7958f4
commit
b3bff009e8
1 changed files with 74 additions and 20 deletions
|
|
@ -48,6 +48,7 @@ class QuickApp():
|
|||
self.bridge.register("disconnected", self.disconnected)
|
||||
self.bridge.register("newContact", self.newContact)
|
||||
self.bridge.register("newMessage", self.newMessage)
|
||||
self.bridge.register("newAlert", self.newAlert)
|
||||
self.bridge.register("presenceUpdate", self.presenceUpdate)
|
||||
self.bridge.register("roomJoined", self.roomJoined)
|
||||
self.bridge.register("roomUserJoined", self.roomUserJoined)
|
||||
|
|
@ -199,6 +200,13 @@ class QuickApp():
|
|||
self.current_action_ids_cb = {}
|
||||
self.chat_wins[win.short].printMessage(sender, msg, profile)
|
||||
|
||||
def newAlert(self, msg, title, type, profile):
|
||||
if not self.check_profile(profile):
|
||||
return
|
||||
assert type in ['INFO','ERROR']
|
||||
self.showDialog(unicode(msg),unicode(title),type.lower())
|
||||
|
||||
|
||||
def setStatusOnline(self, online=True):
|
||||
pass
|
||||
|
||||
|
|
@ -344,7 +352,14 @@ class QuickApp():
|
|||
debug (_("Cards played are not valid: %s") % invalid_cards)
|
||||
if self.chat_wins.has_key(room_jid):
|
||||
self.chat_wins[room_jid].getGame("Tarot").invalidCards(phase, played_cards, invalid_cards)
|
||||
|
||||
|
||||
def _subscribe_cb(self, answer, data):
|
||||
entity, profile = data
|
||||
if answer:
|
||||
self.bridge.subscription("subscribed", entity.short, profile_key = profile)
|
||||
else:
|
||||
self.bridge.subscription("unsubscribed", entity.short, profile_key = profile)
|
||||
|
||||
def subscribe(self, type, raw_jid, profile):
|
||||
"""Called when a subsciption management signal is received"""
|
||||
if not self.check_profile(profile):
|
||||
|
|
@ -358,13 +373,9 @@ class QuickApp():
|
|||
self.showDialog(_("The contact %s has refused your subscription") % entity.short, _('Subscription refusal'), 'error')
|
||||
elif type=="subscribe":
|
||||
# this is a subscriptionn request, we have to ask for user confirmation
|
||||
answer = self.showDialog(_("The contact %s wants to subscribe to your presence.\nDo you accept ?") % entity.short, _('Subscription confirmation'), 'yes/no')
|
||||
if answer:
|
||||
self.bridge.subscription("subscribed", entity.short, profile_key = profile)
|
||||
else:
|
||||
self.bridge.subscription("unsubscribed", entity.short, profile_key = profile)
|
||||
answer = self.showDialog(_("The contact %s wants to subscribe to your presence.\nDo you accept ?") % entity.short, _('Subscription confirmation'), 'yes/no', answer_cb = self._subscribe_cb, answer_data=(entity, profile))
|
||||
|
||||
def showDialog(self, message, title, type="info"):
|
||||
def showDialog(self, message, title, type="info", answer_cb = None):
|
||||
raise NotImplementedError
|
||||
|
||||
def showAlert(self, message):
|
||||
|
|
|
|||
Loading…
Reference in a new issue