Mercurial > libervia-backend
comparison src/plugins/plugin_sec_otr.py @ 1169:a3354063dfb6
plugin OTR: disconnect the active OTR sessions and delete the context on profile disconnection
author | souliane <souliane@mailoo.org> |
---|---|
date | Fri, 05 Sep 2014 11:01:14 +0200 |
parents | 39572f9d5249 |
children | 2df6427a5299 |
comparison
equal
deleted
inserted
replaced
1168:39572f9d5249 | 1169:a3354063dfb6 |
---|---|
112 mess_type="headline", | 112 mess_type="headline", |
113 to_jid=self.peer.full(), | 113 to_jid=self.peer.full(), |
114 extra={}, | 114 extra={}, |
115 profile=client.profile) | 115 profile=client.profile) |
116 # TODO: send signal to frontends | 116 # TODO: send signal to frontends |
117 | |
118 def disconnect(self): | |
119 """Disconnect the session.""" | |
120 if self.state != potr.context.STATE_PLAINTEXT: | |
121 super(Context, self).disconnect() | |
117 | 122 |
118 | 123 |
119 class Account(potr.context.Account): | 124 class Account(potr.context.Account): |
120 #TODO: manage trusted keys: if a fingerprint is not used anymore, we have no way to remove it from database yet (same thing for a correspondent jid) | 125 #TODO: manage trusted keys: if a fingerprint is not used anymore, we have no way to remove it from database yet (same thing for a correspondent jid) |
121 | 126 |
238 ctxMng.account.privkey = None | 243 ctxMng.account.privkey = None |
239 ctxMng.account.loadTrusts() | 244 ctxMng.account.loadTrusts() |
240 | 245 |
241 def profileDisconnected(self, profile): | 246 def profileDisconnected(self, profile): |
242 try: | 247 try: |
248 for context in self.context_managers[profile].contexts.values(): | |
249 context.disconnect() | |
250 del self.context_managers[profile] | |
251 except KeyError: | |
252 pass | |
253 try: | |
243 self.skipped_profiles.remove(profile) | 254 self.skipped_profiles.remove(profile) |
244 except KeyError: | 255 except KeyError: |
245 pass | 256 pass |
246 | 257 |
247 def _startRefresh(self, menu_data, profile): | 258 def _startRefresh(self, menu_data, profile): |
369 | 380 |
370 def dropKey(data, profile): | 381 def dropKey(data, profile): |
371 if C.bool(data['answer']): | 382 if C.bool(data['answer']): |
372 # we end all sessions | 383 # we end all sessions |
373 for context in ctxMng.contexts.values(): | 384 for context in ctxMng.contexts.values(): |
374 if context.state not in (potr.context.STATE_FINISHED, potr.context.STATE_PLAINTEXT): | 385 context.disconnect() |
375 context.disconnect() | |
376 ctxMng.account.privkey = None | 386 ctxMng.account.privkey = None |
377 ctxMng.account.getPrivkey() # as account.privkey is None, getPrivkey will generate a new key, and save it | 387 ctxMng.account.getPrivkey() # as account.privkey is None, getPrivkey will generate a new key, and save it |
378 return {'xmlui': xml_tools.note(_("Your private key has been dropped")).toXml()} | 388 return {'xmlui': xml_tools.note(_("Your private key has been dropped")).toXml()} |
379 return {} | 389 return {} |
380 | 390 |