diff frontends/src/jp/cmd_profile.py @ 1687:de9cc4d62a4a

jp (profile): fixed profile/modify command: - profile modify was resetting profile password if the option was not used - str types where used instead of unicode decoder - a new option allow to disable profile password (mutually exclusive with --password) - XMPP password was broken in a similar way as profile password
author Goffi <goffi@goffi.org>
date Thu, 26 Nov 2015 15:49:58 +0100
parents 91a605feed8c
children bc7e3ff3c838
line wrap: on
line diff
--- a/frontends/src/jp/cmd_profile.py	Thu Nov 26 15:47:01 2015 +0100
+++ b/frontends/src/jp/cmd_profile.py	Thu Nov 26 15:49:58 2015 +0100
@@ -143,22 +143,18 @@
         super(ProfileModify, self).__init__(host, 'modify', need_connect=False, 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'),
+        profile_pwd_group = self.parser.add_mutually_exclusive_group()
+        profile_pwd_group.add_argument('-w', '--password', type=base.unicode_decoder, help=_('change the password of the profile'))
+        profile_pwd_group.add_argument('--disable-password', action='store_true', help=_('disable profile password (dangerous!)'))
+        self.parser.add_argument('-j', '--jid', type=base.unicode_decoder, help=_('the jid of the profile'))
+        self.parser.add_argument('-x', '--xmpp-password', type=base.unicode_decoder, help=_('change the password of the XMPP account'),
                                  metavar='PASSWORD')
         self.parser.add_argument('-D', '--default', action='store_true', help=_(u'set as default profile'))
 
-    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.disable_password:
+            self.args.password = ''
         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: