2009-03-19 17:40:01 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2011-01-11 16:28:15 +01:00
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
2009-03-19 17:40:01 +01:00
|
|
|
**
|
2009-06-17 00:01:27 +10:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2009-03-19 17:40:01 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** No Commercial Usage
|
2009-03-19 17:40:01 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** This file contains pre-release code and may not be distributed.
|
|
|
|
|
** You may use this file in accordance with the terms and conditions
|
|
|
|
|
** contained in the Technology Preview License Agreement accompanying
|
|
|
|
|
** this package.
|
2009-03-19 17:40:01 +01:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
|
|
|
|
** If you have questions regarding the use of this file, please contact
|
|
|
|
|
** Nokia at qt-info@nokia.com.
|
2009-03-19 17:40:01 +01:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
#include "commonvcssettings.h"
|
2009-03-19 17:40:01 +01:00
|
|
|
|
|
|
|
|
#include <QtCore/QSettings>
|
|
|
|
|
#include <QtCore/QDebug>
|
|
|
|
|
|
2010-05-21 17:46:00 +02:00
|
|
|
static const char settingsGroupC[] = "VCS";
|
|
|
|
|
static const char nickNameMailMapKeyC[] = "NickNameMailMap";
|
|
|
|
|
static const char nickNameFieldListFileKeyC[] = "NickNameFieldListFile";
|
|
|
|
|
static const char submitMessageCheckScriptKeyC[] = "SubmitMessageCheckScript";
|
|
|
|
|
static const char lineWrapKeyC[] = "LineWrap";
|
|
|
|
|
static const char lineWrapWidthKeyC[] = "LineWrapWidth";
|
|
|
|
|
static const char sshPasswordPromptKeyC[] = "SshPasswordPrompt";
|
2009-03-20 14:20:28 +01:00
|
|
|
|
|
|
|
|
static const int lineWrapWidthDefault = 72;
|
|
|
|
|
static const bool lineWrapDefault = true;
|
2009-03-19 17:40:01 +01:00
|
|
|
|
2010-05-25 09:38:41 +02:00
|
|
|
// Return default for the ssh-askpass command (default to environment)
|
|
|
|
|
static inline QString sshPasswordPromptDefault()
|
|
|
|
|
{
|
|
|
|
|
const QByteArray envSetting = qgetenv("SSH_ASKPASS");
|
|
|
|
|
if (!envSetting.isEmpty())
|
|
|
|
|
return QString::fromLocal8Bit(envSetting);
|
2010-05-21 17:46:00 +02:00
|
|
|
#ifdef Q_OS_WIN
|
2010-05-25 09:38:41 +02:00
|
|
|
return QLatin1String("win-ssh-askpass");
|
2010-05-21 17:46:00 +02:00
|
|
|
#else
|
2010-05-25 09:38:41 +02:00
|
|
|
return QLatin1String("ssh-askpass");
|
2010-05-21 17:46:00 +02:00
|
|
|
#endif
|
2010-05-25 09:38:41 +02:00
|
|
|
}
|
2010-05-21 17:46:00 +02:00
|
|
|
|
2009-03-19 17:40:01 +01:00
|
|
|
namespace VCSBase {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
CommonVcsSettings::CommonVcsSettings() :
|
2010-05-25 09:38:41 +02:00
|
|
|
sshPasswordPrompt(sshPasswordPromptDefault()),
|
2009-03-20 14:20:28 +01:00
|
|
|
lineWrap(lineWrapDefault),
|
|
|
|
|
lineWrapWidth(lineWrapWidthDefault)
|
2009-03-19 17:40:01 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
void CommonVcsSettings::toSettings(QSettings *s) const
|
2009-03-19 17:40:01 +01:00
|
|
|
{
|
|
|
|
|
s->beginGroup(QLatin1String(settingsGroupC));
|
|
|
|
|
s->setValue(QLatin1String(nickNameMailMapKeyC), nickNameMailMap);
|
|
|
|
|
s->setValue(QLatin1String(nickNameFieldListFileKeyC), nickNameFieldListFile);
|
|
|
|
|
s->setValue(QLatin1String(submitMessageCheckScriptKeyC), submitMessageCheckScript);
|
2009-03-20 14:20:28 +01:00
|
|
|
s->setValue(QLatin1String(lineWrapKeyC), lineWrap);
|
|
|
|
|
s->setValue(QLatin1String(lineWrapWidthKeyC), lineWrapWidth);
|
2010-05-25 09:38:41 +02:00
|
|
|
// Do not store the default setting to avoid clobbering the environment.
|
|
|
|
|
if (sshPasswordPrompt != sshPasswordPromptDefault()) {
|
|
|
|
|
s->setValue(QLatin1String(sshPasswordPromptKeyC), sshPasswordPrompt);
|
|
|
|
|
} else {
|
|
|
|
|
s->remove(QLatin1String(sshPasswordPromptKeyC));
|
|
|
|
|
}
|
2009-03-19 17:40:01 +01:00
|
|
|
s->endGroup();
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
void CommonVcsSettings::fromSettings(QSettings *s)
|
2009-03-19 17:40:01 +01:00
|
|
|
{
|
|
|
|
|
s->beginGroup(QLatin1String(settingsGroupC));
|
|
|
|
|
nickNameMailMap = s->value(QLatin1String(nickNameMailMapKeyC), QString()).toString();
|
|
|
|
|
nickNameFieldListFile = s->value(QLatin1String(nickNameFieldListFileKeyC), QString()).toString();
|
|
|
|
|
submitMessageCheckScript = s->value(QLatin1String(submitMessageCheckScriptKeyC), QString()).toString();
|
2009-03-20 14:20:28 +01:00
|
|
|
lineWrap = s->value(QLatin1String(lineWrapKeyC), lineWrapDefault).toBool();
|
|
|
|
|
lineWrapWidth = s->value(QLatin1String(lineWrapWidthKeyC), lineWrapWidthDefault).toInt();
|
2010-05-25 09:38:41 +02:00
|
|
|
sshPasswordPrompt = s->value(QLatin1String(sshPasswordPromptKeyC), sshPasswordPromptDefault()).toString();
|
2009-03-19 17:40:01 +01:00
|
|
|
s->endGroup();
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
bool CommonVcsSettings::equals(const CommonVcsSettings &rhs) const
|
2009-03-19 17:40:01 +01:00
|
|
|
{
|
2009-06-19 16:34:38 +02:00
|
|
|
return lineWrap == rhs.lineWrap
|
2009-03-20 14:20:28 +01:00
|
|
|
&& lineWrapWidth == rhs.lineWrapWidth
|
2009-03-19 17:40:01 +01:00
|
|
|
&& nickNameMailMap == rhs.nickNameMailMap
|
|
|
|
|
&& nickNameFieldListFile == rhs.nickNameFieldListFile
|
2010-05-21 17:46:00 +02:00
|
|
|
&& submitMessageCheckScript == rhs.submitMessageCheckScript
|
|
|
|
|
&& sshPasswordPrompt == rhs.sshPasswordPrompt;
|
2009-03-19 17:40:01 +01:00
|
|
|
}
|
|
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
QDebug operator<<(QDebug d,const CommonVcsSettings& s)
|
2009-03-20 14:20:28 +01:00
|
|
|
{
|
2009-06-19 16:34:38 +02:00
|
|
|
d.nospace() << " lineWrap=" << s.lineWrap
|
2009-03-20 14:20:28 +01:00
|
|
|
<< " lineWrapWidth=" << s.lineWrapWidth
|
|
|
|
|
<< " nickNameMailMap='" << s.nickNameMailMap
|
|
|
|
|
<< "' nickNameFieldListFile='" << s.nickNameFieldListFile
|
2010-05-21 17:46:00 +02:00
|
|
|
<< "'submitMessageCheckScript='" << s.submitMessageCheckScript
|
|
|
|
|
<< "'sshPasswordPrompt='" << s.sshPasswordPrompt
|
|
|
|
|
<< "'\n";
|
2009-03-20 14:20:28 +01:00
|
|
|
return d;
|
|
|
|
|
}
|
2010-04-12 16:34:21 +02:00
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace VCSBase
|