diff options
| author | 2008-07-16 13:44:11 +0000 | |
|---|---|---|
| committer | 2008-07-16 13:44:11 +0000 | |
| commit | be7369f71fca7d2ad1c1d70c2d86b510f376bd16 (patch) | |
| tree | 27c5e72263fd3e2eed4c11631f9169baa41d605b /src | |
| parent | added a proper option for default server encoding (diff) | |
| download | KVIrc-be7369f71fca7d2ad1c1d70c2d86b510f376bd16.tar.gz KVIrc-be7369f71fca7d2ad1c1d70c2d86b510f376bd16.tar.bz2 KVIrc-be7369f71fca7d2ad1c1d70c2d86b510f376bd16.zip | |
fix for #34 (please test)
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@2080 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src')
| -rw-r--r-- | src/kvilib/file/kvi_fileutils.cpp | 38 | ||||
| -rw-r--r-- | src/kvilib/file/kvi_fileutils.h | 8 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_window.cpp | 9 | ||||
| -rw-r--r-- | src/modules/reguser/dialog.cpp | 21 |
4 files changed, 13 insertions, 63 deletions
diff --git a/src/kvilib/file/kvi_fileutils.cpp b/src/kvilib/file/kvi_fileutils.cpp index 8fec5c2c2..e67298d27 100644 --- a/src/kvilib/file/kvi_fileutils.cpp +++ b/src/kvilib/file/kvi_fileutils.cpp @@ -37,7 +37,6 @@ #include <QTextCodec>
#include <QTextStream>
-
namespace KviFileUtils
{
/*
@@ -436,43 +435,6 @@ namespace KviFileUtils }
};
-static char hexchars[16] = { '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , 'A' , 'B' , 'C' , 'D' , 'E' , 'F' };
-
-
-void kvi_encodeFileName(KviStr & path)
-{
- QString szPath(path.ptr());
- kvi_encodeFileName(szPath);
- path=szPath;
-}
-
-void kvi_encodeFileName(QString & path)
-{
- QString src(path);
- path="";
- for(int i=0;i<src.length();i++)
- {
- QChar cur=src[i];
- if( ! (cur.isLetter() || cur.isDigit() || cur==' ' || cur=='_' || cur=='.' || cur=='#' || cur=='%') )
- {
- if(cur.row()!=0)
- {
- path+='%';
- path+=hexchars[cur.row() >> 4];
- path+=hexchars[cur.row() & 15];
- }
- path+='%';
- path+=hexchars[cur.cell() >> 4];
- path+=hexchars[cur.cell() & 15];
- } else if (cur=='%')
- {
- path+="%%";
- } else {
- path+=cur;
- }
- }
-}
-
//================ kvi_isAbsolutePath ===============//
bool kvi_isAbsolutePath(const char *path)
diff --git a/src/kvilib/file/kvi_fileutils.h b/src/kvilib/file/kvi_fileutils.h index ed5fd2333..e4a08b6d9 100644 --- a/src/kvilib/file/kvi_fileutils.h +++ b/src/kvilib/file/kvi_fileutils.h @@ -44,8 +44,6 @@ // #warning "or should it be availible only for dirbrowser module ?" namespace KviFileUtils { - //extern KVILIB_API bool readLine(QFile * f,QString &szBuffer,bool bClearBuffer = true); - //extern KVILIB_API bool loadFileStripCR(const QString &szPath,QString &szBuffer); // loads the file at szPath to szBuffer eventually converting from utf8 extern KVILIB_API bool loadFile(const QString &szPath,QString &szBuffer,bool bUtf8 = true); @@ -96,14 +94,8 @@ namespace KviFileUtils }; // ALL THIS STUFF BELOW SHOULD DIE: IF YOU SEE IT, REPLACE WITH THE FUNCTIONS IN THE NAMESPACE ABOVE - // Returns true if the path begins with '/' KVILIB_API extern bool kvi_isAbsolutePath(const char *path); -// Translates ANY string into a valid filename (with no path!) -// There is NO way to come back to the original string -// the algo is one-way only -KVILIB_API extern void kvi_encodeFileName(KviStr & path); -KVILIB_API extern void kvi_encodeFileName(QString & path); // Reads a single line from the file and returns false if EOF was encountered. KVILIB_API extern bool kvi_readLine(QFile *f,KviStr &str); diff --git a/src/kvirc/ui/kvi_window.cpp b/src/kvirc/ui/kvi_window.cpp index 6c5d2b521..f591e13ad 100644 --- a/src/kvirc/ui/kvi_window.cpp +++ b/src/kvirc/ui/kvi_window.cpp @@ -68,6 +68,7 @@ #include <QEvent> #include <QCloseEvent> #include <QIcon> +#include <QUrl> #ifdef COMPILE_CRYPT_SUPPORT #include "kvi_crypt.h" @@ -561,8 +562,7 @@ void KviWindow::getDefaultLogFileName(QString &buffer) date=dt.toString("yyyy.MM.dd"); QString base; getBaseLogFileName(base); - kvi_encodeFileName(base); - base.replace("%%2e","%2e"); + base = QUrl(base).toEncoded(); base=base.toLower(); QString tmp; if(KVI_OPTION_BOOL(KviOption_boolGzipLogs)) @@ -572,11 +572,6 @@ void KviWindow::getDefaultLogFileName(QString &buffer) g_pApp->getLocalKvircDirectory(buffer,KviApp::Log,tmp); } -/*void KviWindow::getBaseLogFileName(KviStr &buffer) -{ - buffer = m_szName; -}*/ - void KviWindow::getBaseLogFileName(QString &buffer) { buffer = m_szName; diff --git a/src/modules/reguser/dialog.cpp b/src/modules/reguser/dialog.cpp index 1b883c455..5cc9c4a2c 100644 --- a/src/modules/reguser/dialog.cpp +++ b/src/modules/reguser/dialog.cpp @@ -36,8 +36,8 @@ #include "kvi_options.h"
#include "kvi_file.h"
#include "kvi_filedialog.h"
-#include "kvi_msgbox.h"
#include "kvi_fileutils.h"
+#include "kvi_msgbox.h"
#include "kvi_settings.h"
#include "kvi_stringconversion.h"
#include "kvi_options.h"
@@ -59,6 +59,7 @@ #include <QEvent>
#include <QCloseEvent>
#include <QAbstractItemView>
+#include <QUrl>
#define LVI_ICON_SIZE 32
#define LVI_BORDER 4
@@ -814,23 +815,23 @@ void KviRegisteredUsersDialog::importClicked() if(img.isNull())debug("Ops.. readed a null image ?");
- KviStr fName = u->name();
- kvi_encodeFileName(fName);
+ QString fName = QUrl(u->name()).toEncoded();
- KviStr fPath;
+ QString fPath;
int rnm = 0 ;
do
{
- g_pApp->getLocalKvircDirectory(fPath,KviApp::Avatars,fName.ptr());
- fPath.append(KviStr::Format,"%d.png",rnm);
+ g_pApp->getLocalKvircDirectory(fPath,KviApp::Avatars,fName);
+ fPath+= rnm;
+ fPath+= ".png";
rnm++;
- } while(KviFileUtils::fileExists(fPath.ptr()));
+ } while(KviFileUtils::fileExists(fPath));
- if(!img.save(fPath.ptr(),"PNG"))
+ if(!img.save(fPath,"PNG"))
{
- debug("Can't save image %s",fPath.ptr());
+ debug("Can't save image %s",fPath.toUtf8().data());
} else {
- u->setProperty("avatar",fPath.ptr());
+ u->setProperty("avatar",fPath);
}
}
}
|
