Warning, file /sdk/cervisia/repositories.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 * Copyright (C) 1999-2001 Bernd Gehrmann 0003 * bernd@mail.berlios.de 0004 * 0005 * This program is free software; you can redistribute it and/or modify 0006 * it under the terms of the GNU General Public License as published by 0007 * the Free Software Foundation; either version 2 of the License, or 0008 * (at your option) any later version. 0009 * 0010 * This program is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 * GNU General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU General Public License 0016 * along with this program; if not, write to the Free Software 0017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #include "repositories.h" 0021 0022 #include <qdir.h> 0023 #include <qfile.h> 0024 #include <qtextstream.h> 0025 0026 #include <KConfig> 0027 #include <KConfigGroup> 0028 0029 #include "cervisiapart.h" 0030 0031 static QString fileNameCvs() 0032 { 0033 return QDir::homePath() + "/.cvspass"; 0034 } 0035 0036 static QString fileNameCvsnt() 0037 { 0038 return QDir::homePath() + "/.cvs/cvspass"; 0039 } 0040 0041 // old .cvspass format: 0042 // user@host:/path Acleartext_password 0043 // 0044 // new .cvspass format (since cvs 1.11.1): 0045 // /1 user@host:port/path Aencoded_password 0046 // 0047 static QStringList readCvsPassFile() 0048 { 0049 QStringList list; 0050 0051 QFile f(fileNameCvs()); 0052 if (f.open(QIODevice::ReadOnly)) { 0053 QTextStream stream(&f); 0054 while (!stream.atEnd()) { 0055 int pos; 0056 QString line = stream.readLine(); 0057 if ((pos = line.indexOf(' ')) != -1) { 0058 if (line[0] != '/') // old format 0059 list.append(line.left(pos)); 0060 else // new format 0061 list.append(line.section(' ', 1, 1)); 0062 } 0063 } 0064 } 0065 0066 return list; 0067 } 0068 0069 // .cvs/cvspass format 0070 // user@host:port/path=Aencoded_password 0071 // 0072 static QStringList readCvsntPassFile() 0073 { 0074 QStringList list; 0075 0076 QFile file(fileNameCvsnt()); 0077 if (file.open(QIODevice::ReadOnly)) { 0078 QTextStream stream(&file); 0079 while (!stream.atEnd()) { 0080 const QString line(stream.readLine()); 0081 0082 const int pos(line.indexOf("=A")); 0083 if (pos >= 0) 0084 list.append(line.left(pos)); 0085 } 0086 } 0087 0088 return list; 0089 } 0090 0091 QStringList Repositories::readCvsPassFile() 0092 { 0093 return (QFileInfo(fileNameCvs()).lastModified() < QFileInfo(fileNameCvsnt()).lastModified()) ? readCvsntPassFile() : ::readCvsPassFile(); 0094 } 0095 0096 QStringList Repositories::readConfigFile() 0097 { 0098 QStringList list; 0099 0100 KConfigGroup config(CervisiaPart::config(), "Repositories"); 0101 list = config.readEntry("Repos", QStringList()); 0102 0103 // Some people actually use CVSROOT, so we add it here 0104 QString env = QString::fromLocal8Bit(qgetenv("CVSROOT")); 0105 if (!env.isEmpty() && !list.contains(env)) 0106 list.append(env); 0107 0108 return list; 0109 } 0110 0111 // Local Variables: 0112 // c-basic-offset: 4 0113 // End: