# HG changeset patch # User Goffi # Date 1428334613 -7200 # Node ID e4e960d285b0b6fc08059adc01fdd184bf2b6802 # Parent f913b09cd9cc90bfa9b452b0a07c51e5d7614854 jp (profile): added "profile modify" command diff -r f913b09cd9cc -r e4e960d285b0 frontends/src/jp/cmd_profile.py --- a/frontends/src/jp/cmd_profile.py Mon Apr 06 17:36:21 2015 +0200 +++ b/frontends/src/jp/cmd_profile.py Mon Apr 06 17:36:53 2015 +0200 @@ -115,8 +115,36 @@ 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'))