jp (profile): added "profile modify" command
This commit is contained in:
parent
84e6b89f2f
commit
0a8918bcef
1 changed files with 29 additions and 1 deletions
|
|
@ -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'))
|
||||
|
|
|
|||
Loading…
Reference in a new issue