jp (roster): added resync command to do a full roster resynchronisation

This commit is contained in:
Goffi 2019-04-07 18:50:13 +02:00
commit 8c6be44375

View file

@ -19,11 +19,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
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"))