| ... |
... |
@@ -1837,6 +1837,8 @@ class Connection(CommonConnection, ConnectionHandlers): |
|
1837
|
1837
|
our_server = app.config.get_per('accounts', self.name, 'hostname')
|
|
1838
|
1838
|
self.discoverInfo(our_jid, id_prefix='Gajim_')
|
|
1839
|
1839
|
self.discoverInfo(our_server, id_prefix='Gajim_')
|
|
|
1840
|
+ else:
|
|
|
1841
|
+ self.request_roster(resume=True)
|
|
1840
|
1842
|
|
|
1841
|
1843
|
self.sm.resuming = False # back to previous state
|
|
1842
|
1844
|
# Discover Stun server(s)
|
| ... |
... |
@@ -2535,16 +2537,25 @@ class Connection(CommonConnection, ConnectionHandlers): |
|
2535
|
2537
|
iq3.addChild(name='meta', attrs=dict_)
|
|
2536
|
2538
|
self.connection.send(iq)
|
|
2537
|
2539
|
|
|
2538
|
|
- def request_roster(self):
|
|
|
2540
|
+ def request_roster(self, resume=False):
|
|
2539
|
2541
|
version = None
|
|
2540
|
2542
|
features = self.connection.Dispatcher.Stream.features
|
|
2541
|
|
- if features and features.getTag('ver',
|
|
2542
|
|
- namespace=nbxmpp.NS_ROSTER_VER):
|
|
2543
|
|
- version = app.config.get_per('accounts', self.name,
|
|
2544
|
|
- 'roster_version')
|
|
|
2543
|
+ if features and features.getTag('ver', namespace=nbxmpp.NS_ROSTER_VER):
|
|
|
2544
|
+ version = app.config.get_per(
|
|
|
2545
|
+ 'accounts', self.name, 'roster_version')
|
|
|
2546
|
+
|
|
|
2547
|
+ iq_id = self.connection.initRoster(version=version,
|
|
|
2548
|
+ request=not resume)
|
|
|
2549
|
+ if resume:
|
|
|
2550
|
+ self._init_roster_from_db()
|
|
|
2551
|
+ else:
|
|
|
2552
|
+ self.awaiting_answers[iq_id] = (ROSTER_ARRIVED, )
|
|
2545
|
2553
|
|
|
2546
|
|
- iq_id = self.connection.initRoster(version=version)
|
|
2547
|
|
- self.awaiting_answers[iq_id] = (ROSTER_ARRIVED, )
|
|
|
2554
|
+ def _init_roster_from_db(self):
|
|
|
2555
|
+ account_jid = app.get_jid_from_account(self.name)
|
|
|
2556
|
+ roster_data = app.logger.get_roster(account_jid)
|
|
|
2557
|
+ roster = self.connection.getRoster(force=True)
|
|
|
2558
|
+ roster.setRaw(roster_data)
|
|
2548
|
2559
|
|
|
2549
|
2560
|
def send_agent_status(self, agent, ptype):
|
|
2550
|
2561
|
if not app.account_is_connected(self.name):
|