diff --git a/sat_frontends/jp/cmd_roster.py b/sat_frontends/jp/cmd_roster.py index ab64054d..f31f8979 100644 --- a/sat_frontends/jp/cmd_roster.py +++ b/sat_frontends/jp/cmd_roster.py @@ -19,11 +19,11 @@ # along with this program. If not, see . import base -from sat_frontends.jp.constants import Const as C -from sat.core.i18n import _ - -from twisted.words.protocols.jabber import jid from collections import OrderedDict +from functools import partial +from sat.core.i18n import _ +from sat_frontends.jp.constants import Const as C +from twisted.words.protocols.jabber import jid __commands__ = ["Roster"] @@ -207,8 +207,32 @@ class Get(base.CommandBase): self.host.quit() +class Resync(base.CommandBase): + + def __init__(self, host): + super(Resync, self).__init__( + host, 'resync', help=_(u'do a full resynchronisation of roster with server')) + self.need_loop = True + + def add_parser_options(self): + pass + + def rosterResyncCb(self): + self.disp(_(u"Roster resynchronized")) + self.host.quit(C.EXIT_OK) + + def start(self): + self.host.bridge.rosterResync(profile_key=self.host.profile, + callback=self.rosterResyncCb, + errback=partial( + self.errback, + msg=_(u"can't resynchronise roster: {}"), + exit_code=C.EXIT_BRIDGE_ERRBACK, + )) + + class Roster(base.CommandBase): - subcommands = (Get, Stats, Purge) + subcommands = (Get, Stats, Purge, Resync) def __init__(self, host): super(Roster, self).__init__(host, 'roster', use_profile=True, help=_("Manage an entity's roster"))