File indexing completed on 2024-04-28 05:42:11
0001 /* 0002 * Port for usage with qt-framework and development for kdesvn 0003 * Copyright (C) 2005-2009 by Rajko Albrecht (ral@alwins-world.de) 0004 * https://kde.org/applications/development/org.kde.kdesvn 0005 */ 0006 /* 0007 * ==================================================================== 0008 * Copyright (c) 2002-2005 The RapidSvn Group. All rights reserved. 0009 * dev@rapidsvn.tigris.org 0010 * 0011 * This library is free software; you can redistribute it and/or 0012 * modify it under the terms of the GNU Lesser General Public 0013 * License as published by the Free Software Foundation; either 0014 * version 2.1 of the License, or (at your option) any later version. 0015 * 0016 * This library is distributed in the hope that it will be useful, 0017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0019 * Lesser General Public License for more details. 0020 * 0021 * You should have received a copy of the GNU Lesser General Public 0022 * License along with this library (in the file LGPL.txt); if not, 0023 * write to the Free Software Foundation, Inc., 51 Franklin St, 0024 * Fifth Floor, Boston, MA 02110-1301 USA 0025 * 0026 * This software consists of voluntary contributions made by many 0027 * individuals. For exact contribution history, see the revision 0028 * history and logs, available at http://rapidsvn.tigris.org/. 0029 * ==================================================================== 0030 */ 0031 0032 #include "url.h" 0033 0034 // svncpp 0035 #include "helper.h" 0036 #include "pool.h" 0037 #include "svnqt_defines.h" 0038 0039 #include <svn_dirent_uri.h> 0040 0041 #include <qglobal.h> 0042 0043 namespace svn 0044 { 0045 0046 Url::Url(const QUrl &url) 0047 : m_url(url.toString(QUrl::RemoveQuery | QUrl::NormalizePathSegments)) 0048 { 0049 } 0050 0051 Url::Url(const svn::Path &url) 0052 : m_url(url) 0053 { 0054 } 0055 0056 QByteArray Url::cstr() const 0057 { 0058 return m_url.cstr(); 0059 } 0060 0061 /* static helpers */ 0062 bool Url::isLocal(const QString &url) 0063 { 0064 static const Qt::CaseSensitivity cs = Qt::CaseInsensitive; 0065 static const QLatin1String stf("file://"); 0066 static const QLatin1String stsf("svn+file://"); 0067 static const QLatin1String stkf("ksvn+file://"); 0068 if (url.startsWith(stf, cs) || url.startsWith(QLatin1Char('/')) || url.startsWith(stsf, cs) || url.startsWith(stkf, cs)) { 0069 return true; 0070 } 0071 return false; 0072 } 0073 0074 bool Url::isValid(const QString &url) 0075 { 0076 static const std::vector<QLatin1String> VALID_SCHEMAS = {QLatin1String("http"), 0077 QLatin1String("https"), 0078 QLatin1String("file"), 0079 QLatin1String("svn"), 0080 QLatin1String("svn+ssh"), 0081 QLatin1String("svn+http"), 0082 QLatin1String("svn+https"), 0083 QLatin1String("svn+file"), 0084 QLatin1String("ksvn"), 0085 QLatin1String("ksvn+ssh"), 0086 QLatin1String("ksvn+http"), 0087 QLatin1String("ksvn+https"), 0088 QLatin1String("ksvn+file")}; 0089 const QString urlTest(url); 0090 for (const QLatin1String &schema : VALID_SCHEMAS) { 0091 const QStringRef urlComp = urlTest.leftRef(schema.size()); 0092 0093 if (schema == urlComp) { 0094 return true; 0095 } 0096 } 0097 return false; 0098 } 0099 0100 QString Url::transformProtokoll(const QString &prot) 0101 { 0102 const QString _prot = prot.toLower(); 0103 if (_prot == QLatin1String("svn+http") || _prot == QLatin1String("ksvn+http")) 0104 return QLatin1String("http"); 0105 if (_prot == QLatin1String("svn+https") || _prot == QLatin1String("ksvn+https")) 0106 return QLatin1String("https"); 0107 if (_prot == QLatin1String("svn+file") || _prot == QLatin1String("ksvn+file")) 0108 return QLatin1String("file"); 0109 if (_prot == QLatin1String("ksvn+ssh")) 0110 return QLatin1String("svn+ssh"); 0111 if (_prot == QLatin1String("ksvn")) 0112 return QLatin1String("svn"); 0113 return _prot; 0114 } 0115 } 0116 0117 /* ----------------------------------------------------------------- 0118 * local variables: 0119 * eval: (load-file "../../rapidsvn-dev.el") 0120 * end: 0121 */