From 0a8918bcef2ddd7f8b2292b7021b3716d8350d3b Mon Sep 17 00:00:00 2001 From: Goffi Date: Mon, 6 Apr 2015 17:36:53 +0200 Subject: [PATCH] jp (profile): added "profile modify" command --- frontends/src/jp/cmd_profile.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/frontends/src/jp/cmd_profile.py b/frontends/src/jp/cmd_profile.py index 9bcf60f5..43c88f04 100644 --- a/frontends/src/jp/cmd_profile.py +++ b/frontends/src/jp/cmd_profile.py @@ -115,8 +115,36 @@ class ProfileCreate(base.CommandBase): self.host.bridge.asyncCreateProfile(self.args.profile, self.args.password, callback=self._profile_created, errback=None) +class ProfileModify(base.CommandBase): + def __init__(self, host): + super(ProfileModify, self).__init__(host, 'modify', help=_('Modify an existing profile')) + + def add_parser_options(self): + self.parser.add_argument('-w', '--password', type=str, default='', help=_('the password of the profile')) + self.parser.add_argument('-j', '--jid', type=str, help=_('the jid of the profile')) + self.parser.add_argument('-x', '--xmpp-password', type=str, help=_('the password of the XMPP account'), + metavar='PASSWORD') + + def _profile_created(self): + if self.args.jid: + self.host.bridge.setParam("JabberID", self.args.jid, "Connection" ,profile_key=self.args.profile) + xmpp_pwd = self.args.password or self.args.xmpp_password + if xmpp_pwd: + self.host.bridge.setParam("Password", xmpp_pwd, "Connection", profile_key=self.args.profile) + self.host.quit() + + def connected(self): + super(ProfileModify, self).connected() + if self.args.password is not None: + self.host.bridge.setParam("Password", self.args.password, "General", profile_key=self.host.profile) + if self.args.jid is not None: + self.host.bridge.setParam("JabberID", self.args.jid, "Connection", profile_key=self.host.profile) + if self.args.xmpp_password is not None: + self.host.bridge.setParam("Password", self.args.xmpp_password, "Connection", profile_key=self.host.profile) + + class Profile(base.CommandBase): - subcommands = (ProfileDelete, ProfileInfo, ProfileList, ProfileCreate) + subcommands = (ProfileDelete, ProfileInfo, ProfileList, ProfileCreate, ProfileModify) def __init__(self, host): super(Profile, self).__init__(host, 'profile', use_profile=False, help=_('Profile commands'))