You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Senthil Kumaran S <se...@collab.net> on 2008/09/02 18:31:57 UTC

Re: [RFC,PATCH] Port libsvn_auth_kwallet to KDE3.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

Martin Furter wrote:
> OK, if you do so please tell me which version of the patch you prefer
> and if you want it split into multiple patches or not.
> 
> The two versions are:
> http://svn.haxx.se/dev/archive-2008-05/1408.shtml
> http://svn.haxx.se/dev/archive-2008-05/1516.shtml

I would like to know if we have plans of getting this patch into trunk, which
will help in backporting it to 1.5.x-issue2489 branch.

Thank You.
- --
Senthil Kumaran S
http://www.stylesen.org/

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFIvYaY9o1G+2zNQDgRAoMvAKCE1y2vXgv29k3hpxXNEjO2fDu1lwCfQRuz
QNpD1zSDeOp3ksNA3VgUfaQ=
=/B8a
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [RFC,PATCH] Port libsvn_auth_kwallet to KDE3.

Posted by Arfrever Frehtes Taifersar Arahesis <ar...@gmail.com>.
> Index: subversion/libsvn_auth_kwallet/kwallet.cpp
> ===================================================================
> --- subversion/libsvn_auth_kwallet/kwallet.cpp	(revision 31484)
> +++ subversion/libsvn_auth_kwallet/kwallet.cpp	(working copy)
> @@ -32,8 +32,14 @@
>  
>  #include "svn_private_config.h"
>  
> +#ifdef SVN_HAVE_QT3
> +#include <qstring.h>
> +#include <qwidget.h>
> +#include <klocale.h>
> +#else
>  #include <QtCore/QString>
>  #include <QtGui/QWidget>
> +#endif
>  
>  #include <kapplication.h>
>  #include <kcmdlineargs.h>
> @@ -44,16 +50,28 @@
>  /* KWallet simple provider, puts passwords in KWallet                    */
>  /*-----------------------------------------------------------------------*/
>  
> -/* Implementation of svn_auth__password_get_t that retrieves
> -   the password from KWallet. */
> -static svn_boolean_t
> -kwallet_password_get(const char **password,
> -                     apr_hash_t *creds,
> -                     const char *realmstring,
> -                     const char *username,
> -                     svn_boolean_t non_interactive,
> -                     apr_pool_t *pool)
> +class SvnKWallet
>  {
> +public:
> +  static svn_boolean_t init(svn_boolean_t non_interactive);
> +  SvnKWallet(const char *realmstring, const char *username);
> +  ~SvnKWallet();
> +  svn_boolean_t get(const char **password, apr_pool_t *pool);
> +  svn_boolean_t set(const char *password);
> +private:
> +  bool open(bool check_key, bool create_wallet);
> +
> +  KApplication application;

KApplication causes crashes in JavaHL.

> +  QWidget widget;
> +  WId wid;
> +  KWallet::Wallet *wallet;
> +  QString wallet_name;
> +  QString folder;
> +  QString key;
> +};
> +
> +svn_boolean_t SvnKWallet::init( svn_boolean_t non_interactive )
> +{
>    if (non_interactive)
>      {
>        return FALSE;
> @@ -64,51 +82,107 @@
>        return FALSE;
>      }
>  
> +  char kdearg0[] = "svn";
> +  char *kdeargs[1] = { kdearg0 };
> +#ifdef SVN_HAVE_QT3
>    KCmdLineArgs::init(1,
> -                     (char *[1]) { "svn" },
> +                     kdeargs,
>                       "Subversion",
>                       "subversion",
> +                     i18n("Version control system"),
> +                     SVN_VER_NUMBER,
> +                     true);
> +#else
> +  KCmdLineArgs::init(1,
> +                     kdeargs,
> +                     "Subversion",
> +                     "subversion",
>                       ki18n("Subversion"),
>                       SVN_VER_NUMBER,
>                       ki18n("Version control system"),
>                       KCmdLineArgs::CmdLineArgKDE);
> -  KApplication application;
> -  QWidget widget;
> -  WId wid = widget.winId();
> -  svn_boolean_t ret = FALSE;
> -  QString wallet_name = KWallet::Wallet::NetworkWallet();
> -  QString folder = QString::fromUtf8("Subversion");
> -  QString key =
> -    QString::fromUtf8(username) + "@" + QString::fromUtf8(realmstring);
> -  if (! KWallet::Wallet::keyDoesNotExist(wallet_name, folder, key))
> -    {
> -      KWallet::Wallet *wallet =
> -        KWallet::Wallet::openWallet(wallet_name,
> -                                    wid,
> -                                    KWallet::Wallet::Synchronous);
> -      if (wallet)
> -        {
> -          if (wallet->hasFolder(folder))
> -            {
> -              if (wallet->setFolder(folder))
> -                {
> -                  QString q_password;
> -                  if (wallet->readPassword(key, q_password) == 0);
> -                    {
> -                      *password = apr_pstrmemdup(pool,
> -                                                 q_password.toUtf8().data(),
> -                                                 q_password.size());
> -                      ret = TRUE;
> -                    }
> -                }
> -            }
> -        }
> -    }
> +#endif
> +  return TRUE;
> +}
> +
> +SvnKWallet::SvnKWallet(const char *realmstring, const char *username)
> +  : wallet(0)
> +{
> +  wallet_name = KWallet::Wallet::NetworkWallet();
> +  folder = QString::fromUtf8("Subversion");
> +  key = QString::fromUtf8(username) + "@" + QString::fromUtf8(realmstring);
> +}
> +
> +SvnKWallet::~SvnKWallet()
> +{
>  //  KWallet::Wallet::disconnectApplication(wallet_name,
>  //                                         QString::fromUtf8("Subversion"));
> -  return ret;
> +  delete wallet;
>  }
>  
> +svn_boolean_t SvnKWallet::get(const char **password, apr_pool_t *pool)
> +{
> +  if (!open(true, false))
> +    return FALSE;
> +  QString q_password;
> +  if (wallet->readPassword(key, q_password) != 0)
> +    return FALSE;
> +#ifdef SVN_HAVE_QT3
> +  *password = apr_pstrmemdup(pool,
> +                             q_password.utf8().data(),
> +                             q_password.length());
> +#else
> +  *password = apr_pstrmemdup(pool,
> +                             q_password.toUtf8().data(),
> +                             q_password.size());
> +#endif
> +  return TRUE;
> +}
> +
> +svn_boolean_t SvnKWallet::set(const char *password)
> +{
> +  if (!open(false, true))
> +    return FALSE;
> +  QString q_password = QString::fromUtf8(password);
> +  if (wallet->writePassword(key, q_password) != 0)
> +    return FALSE;
> +  return TRUE;
> +}
> +
> +bool SvnKWallet::open(bool check_key, bool create_wallet)
> +{
> +  if (check_key && KWallet::Wallet::keyDoesNotExist(wallet_name, folder, key))
> +    return false;
> +  wallet = KWallet::Wallet::openWallet(wallet_name,
> +                                       wid,
> +                                       KWallet::Wallet::Synchronous);
> +  if (!wallet)
> +    return false;
> +  if (!wallet->hasFolder(folder))
> +    {
> +      if (!create_wallet)
> +        return false;
> +      if (!wallet->createFolder(folder))
> +        return false;
> +    }
> +  return wallet->setFolder(folder);
> +}
> +
> +/* Implementation of svn_auth__password_get_t that retrieves
> +   the password from KWallet. */
> +static svn_boolean_t
> +kwallet_password_get(const char **password,
> +                     apr_hash_t *creds,
> +                     const char *realmstring,
> +                     const char *username,
> +                     svn_boolean_t non_interactive,
> +                     apr_pool_t *pool)
> +{
> +  if (!SvnKWallet::init(non_interactive))
> +    return FALSE;
> +  return SvnKWallet(realmstring, username).get(password, pool);
> +}
> +
>  /* Implementation of svn_auth__password_set_t that stores
>     the password in KWallet. */
>  static svn_boolean_t
> @@ -119,57 +193,9 @@
>                       svn_boolean_t non_interactive,
>                       apr_pool_t *pool)
>  {
> -  if (non_interactive)
> -    {
> -      return FALSE;
> -    }
> -
> -  if (! KWallet::Wallet::isEnabled())
> -    {
> -      return FALSE;
> -    }
> -
> -  KCmdLineArgs::init(1,
> -                     (char *[1]) { "svn" },
> -                     "Subversion",
> -                     "subversion",
> -                     ki18n("Subversion"),
> -                     SVN_VER_NUMBER,
> -                     ki18n("Version control system"),
> -                     KCmdLineArgs::CmdLineArgKDE);
> -  KApplication application;
> -  QWidget widget;
> -  WId wid = widget.winId();
> -  svn_boolean_t ret = FALSE;
> -  QString q_password = QString::fromUtf8(password);
> -  QString wallet_name = KWallet::Wallet::NetworkWallet();
> -  QString folder = QString::fromUtf8("Subversion");
> -  KWallet::Wallet *wallet =
> -    KWallet::Wallet::openWallet(wallet_name,
> -                                wid,
> -                                KWallet::Wallet::Synchronous);
> -  if (wallet)
> -    {
> -      if (! wallet->hasFolder(folder))
> -        {
> -          wallet->createFolder(folder);
> -        }
> -      if (wallet->hasFolder(folder))
> -        {
> -          if (wallet->setFolder(folder))
> -            {
> -              QString key = QString::fromUtf8(username) + "@"
> -                + QString::fromUtf8(realmstring);
> -              if (wallet->writePassword(key, q_password) == 0)
> -                {
> -                  ret = TRUE;
> -                }
> -            }
> -        }
> -    }
> -//  KWallet::Wallet::disconnectApplication(wallet_name,
> -//                                         QString::fromUtf8("Subversion"));
> -  return ret;
> +  if (!SvnKWallet::init(non_interactive))
> +    return FALSE;
> +  return SvnKWallet(realmstring, username).set(password);
>  }
>  
>  /* Get cached encrypted credentials from the simple provider's cache. */

-- 
Arfrever Frehtes Taifersar Arahesis

Re: [RFC,PATCH] Port libsvn_auth_kwallet to KDE3.

Posted by Daniel Shahaf <d....@daniel.shahaf.co.il>.
Senthil Kumaran S wrote on Wed, 3 Sep 2008 at 00:01 +0530:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi,
> 
> Martin Furter wrote:
> > OK, if you do so please tell me which version of the patch you prefer
> > and if you want it split into multiple patches or not.
> > 
> > The two versions are:
> > http://svn.haxx.se/dev/archive-2008-05/1408.shtml
> > http://svn.haxx.se/dev/archive-2008-05/1516.shtml
> 
> I would like to know if we have plans of getting this patch into trunk, which
> will help in backporting it to 1.5.x-issue2489 branch.
> 

I believe the consensus of this thread was that the patch is acceptable.  
(Anyone, please correct me if that's wrong.)  Therefore, I think you are 
free to apply it to trunk and then to the issue2489 branch.

Daniel

> Thank You.
> - --
> Senthil Kumaran S
> http://www.stylesen.org/
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
> 
> iD8DBQFIvYaY9o1G+2zNQDgRAoMvAKCE1y2vXgv29k3hpxXNEjO2fDu1lwCfQRuz
> QNpD1zSDeOp3ksNA3VgUfaQ=
> =/B8a
> -----END PGP SIGNATURE-----
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org