we are now informed when vcard publication faild / succeed
This commit is contained in:
parent
ff1edfffff
commit
d271c29a24
|
@ -18,6 +18,9 @@
|
||||||
## GNU General Public License for more details.
|
## GNU General Public License for more details.
|
||||||
##
|
##
|
||||||
|
|
||||||
|
# kind of events we can wait for an answer
|
||||||
|
VCARD_PUBLISHED = 'vcard_published'
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import sha
|
import sha
|
||||||
import os
|
import os
|
||||||
|
@ -138,6 +141,8 @@ class Connection:
|
||||||
self.privacy_rules_supported = False
|
self.privacy_rules_supported = False
|
||||||
#Do we continue connection when we get roster (send presence,get vcard...)
|
#Do we continue connection when we get roster (send presence,get vcard...)
|
||||||
self.continue_connect_info = None
|
self.continue_connect_info = None
|
||||||
|
#List of IDs we are waiting answers for {id: type_of_request, }
|
||||||
|
self.awaiting_answers = {}
|
||||||
if USE_GPG:
|
if USE_GPG:
|
||||||
self.gpg = GnuPG.GnuPG()
|
self.gpg = GnuPG.GnuPG()
|
||||||
gajim.config.set('usegpg', True)
|
gajim.config.set('usegpg', True)
|
||||||
|
@ -1232,6 +1237,22 @@ class Connection:
|
||||||
def _StanzaArrivedCB(self, con, obj):
|
def _StanzaArrivedCB(self, con, obj):
|
||||||
self.last_io = time.time()
|
self.last_io = time.time()
|
||||||
|
|
||||||
|
def _IqCB(self, con, iq_obj):
|
||||||
|
id = iq_obj.getID()
|
||||||
|
print 'a'
|
||||||
|
if id not in self.awaiting_answers:
|
||||||
|
return
|
||||||
|
print self.awaiting_answers[id]
|
||||||
|
print VCARD_PUBLISHED
|
||||||
|
if self.awaiting_answers[id] == VCARD_PUBLISHED:
|
||||||
|
typ = iq_obj.getType()
|
||||||
|
print typ
|
||||||
|
if iq_obj.getType() == 'result':
|
||||||
|
self.dispatch('VCARD_PUBLISHED', ())
|
||||||
|
elif iq_obj.getType() == 'error':
|
||||||
|
self.dispatch('VCARD_NOT_PUBLISHED', ())
|
||||||
|
del self.awaiting_answers[id]
|
||||||
|
|
||||||
def _event_dispatcher(self, realm, event, data):
|
def _event_dispatcher(self, realm, event, data):
|
||||||
if realm == common.xmpp.NS_REGISTER:
|
if realm == common.xmpp.NS_REGISTER:
|
||||||
if event == common.xmpp.features.REGISTER_DATA_RECEIVED:
|
if event == common.xmpp.features.REGISTER_DATA_RECEIVED:
|
||||||
|
@ -1358,6 +1379,7 @@ class Connection:
|
||||||
con.RegisterHandler('iq', self._HttpAuthCB, 'get',
|
con.RegisterHandler('iq', self._HttpAuthCB, 'get',
|
||||||
common.xmpp.NS_HTTP_AUTH)
|
common.xmpp.NS_HTTP_AUTH)
|
||||||
con.RegisterHandler('iq', self._ErrorCB, 'error')
|
con.RegisterHandler('iq', self._ErrorCB, 'error')
|
||||||
|
con.RegisterHandler('iq', self._IqCB)
|
||||||
con.RegisterHandler('iq', self._StanzaArrivedCB)
|
con.RegisterHandler('iq', self._StanzaArrivedCB)
|
||||||
con.RegisterHandler('presence', self._StanzaArrivedCB)
|
con.RegisterHandler('presence', self._StanzaArrivedCB)
|
||||||
con.RegisterHandler('message', self._StanzaArrivedCB)
|
con.RegisterHandler('message', self._StanzaArrivedCB)
|
||||||
|
@ -1749,6 +1771,9 @@ class Connection:
|
||||||
iq3.addChild(k).setData(j[k])
|
iq3.addChild(k).setData(j[k])
|
||||||
else:
|
else:
|
||||||
iq2.addChild(i).setData(vcard[i])
|
iq2.addChild(i).setData(vcard[i])
|
||||||
|
id = self.connection.getAnID()
|
||||||
|
iq.setID(id)
|
||||||
|
self.awaiting_answers[str(id)] = VCARD_PUBLISHED
|
||||||
self.to_be_sent.append(iq)
|
self.to_be_sent.append(iq)
|
||||||
|
|
||||||
def get_settings(self):
|
def get_settings(self):
|
||||||
|
|
|
@ -813,6 +813,12 @@ class Interface:
|
||||||
if self.windows[account].has_key('xml_console'):
|
if self.windows[account].has_key('xml_console'):
|
||||||
self.windows[account]['xml_console'].print_stanza(stanza, 'outgoing')
|
self.windows[account]['xml_console'].print_stanza(stanza, 'outgoing')
|
||||||
|
|
||||||
|
def handle_event_vcard_published(self, account, array):
|
||||||
|
dialogs.InformationDialog(_('vCard publication succeeded'), _('Your vCard has been published successfuly.'))
|
||||||
|
|
||||||
|
def handle_event_vcard_not_published(self, account, array):
|
||||||
|
dialogs.InformationDialog(_('vCard publication failed'), _('There was an error while publishing your vCard, try again later.'))
|
||||||
|
|
||||||
def read_sleepy(self):
|
def read_sleepy(self):
|
||||||
'''Check idle status and change that status if needed'''
|
'''Check idle status and change that status if needed'''
|
||||||
if not self.sleeper.poll():
|
if not self.sleeper.poll():
|
||||||
|
@ -996,6 +1002,8 @@ class Interface:
|
||||||
'STANZA_ARRIVED': self.handle_event_stanza_arrived,
|
'STANZA_ARRIVED': self.handle_event_stanza_arrived,
|
||||||
'STANZA_SENT': self.handle_event_stanza_sent,
|
'STANZA_SENT': self.handle_event_stanza_sent,
|
||||||
'HTTP_AUTH': self.handle_event_http_auth,
|
'HTTP_AUTH': self.handle_event_http_auth,
|
||||||
|
'VCARD_PUBLISHED': self.handle_event_vcard_published,
|
||||||
|
'VCARD_NOT_PUBLISHED': self.handle_event_vcard_not_published,
|
||||||
}
|
}
|
||||||
|
|
||||||
def exec_event(self, account):
|
def exec_event(self, account):
|
||||||
|
|
Loading…
Reference in New Issue