|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2004 by Paulo Moura Guedes *
|
|
|
|
* moura@kdewebdev.org *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the *
|
|
|
|
* Free Software Foundation, Inc., *
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#include "utils.h"
|
|
|
|
|
|
|
|
#include <tqprocess.h>
|
|
|
|
#include <tqwidget.h>
|
|
|
|
|
|
|
|
#include <tdeapplication.h>
|
|
|
|
#include <tdemessagebox.h>
|
|
|
|
#include <kdebug.h>
|
|
|
|
|
|
|
|
|
|
|
|
TQString htmlDocCharset[NUMBER_OF_HTML_CODES][2] = {
|
|
|
|
|
|
|
|
{ "€", "@" },
|
|
|
|
{ "	", "\t" },
|
|
|
|
{ " ", "\n" },
|
|
|
|
{ " ", "\r" },
|
|
|
|
{ " ", " " },
|
|
|
|
{ "!", "!" },
|
|
|
|
{ """, "\"" },
|
|
|
|
{ "#", "#" },
|
|
|
|
{ "$", "$" },
|
|
|
|
{ "%", "%" },
|
|
|
|
{ "&", "&" },
|
|
|
|
{ "'", "'" },
|
|
|
|
{ "(", "(" },
|
|
|
|
{ ")", ")" },
|
|
|
|
{ "*", "*" },
|
|
|
|
{ "+", "+" },
|
|
|
|
{ ",", "," },
|
|
|
|
{ "-", "-" },
|
|
|
|
{ ".", "." },
|
|
|
|
{ "/", "/" },
|
|
|
|
// numbers....
|
|
|
|
{ ":", ":" },
|
|
|
|
{ ";", ";" },
|
|
|
|
{ "<", "<" },
|
|
|
|
{ "=", "=" },
|
|
|
|
{ ">", ">" },
|
|
|
|
{ "?", "?" },
|
|
|
|
{ "@", "@" },
|
|
|
|
// letters...
|
|
|
|
{ "[", "[" },
|
|
|
|
{ "\", "\\" },
|
|
|
|
{ "]", "]" },
|
|
|
|
{ "^", "^" },
|
|
|
|
{ "_", "_" },
|
|
|
|
{ "`", "`" },
|
|
|
|
//letters...
|
|
|
|
{ "{", "{" },
|
|
|
|
{ "|", "|" },
|
|
|
|
{ "}", "}" },
|
|
|
|
{ "~", "~" },
|
|
|
|
{ "€", "?" },
|
|
|
|
{ "‚", "," },
|
|
|
|
{ "ƒ", "?" },
|
|
|
|
{ "„", "\"" },
|
|
|
|
{ "…", "?" },
|
|
|
|
{ "†", "?" },
|
|
|
|
{ "‡", "?" },
|
|
|
|
{ "‰", "?" },
|
|
|
|
{ "Š", "?" },
|
|
|
|
{ "‹", "<" },
|
|
|
|
{ "Œ", "?" },
|
|
|
|
{ "Ž", "?" },
|
|
|
|
{ "‘", "'" },
|
|
|
|
{ "’", "'" },
|
|
|
|
{ "“", "\"" },
|
|
|
|
{ "”", "\"" },
|
|
|
|
{ "•", "*" },
|
|
|
|
{ "–", "-" },
|
|
|
|
{ "—", "-" },
|
|
|
|
{ "˜", "~" },
|
|
|
|
{ "™", "?" },
|
|
|
|
{ "š", "?" },
|
|
|
|
{ "›", ">" },
|
|
|
|
{ "œ", "?" },
|
|
|
|
{ "ž", "?" },
|
|
|
|
{ "Ÿ", "?" },
|
|
|
|
{ "¡", "?" },
|
|
|
|
{ "¢", "?" },
|
|
|
|
{ "£", "?" },
|
|
|
|
{ "¤", "?" },
|
|
|
|
{ "¥", "?" },
|
|
|
|
{ "¦", "?" },
|
|
|
|
{ "§", "?" },
|
|
|
|
{ "¨", "?" },
|
|
|
|
{ "©", "" },
|
|
|
|
{ "ª", "?" },
|
|
|
|
{ "«", "?" },
|
|
|
|
{ "¬", "?" },
|
|
|
|
{ "®", "?" },
|
|
|
|
{ "¯", "?" },
|
|
|
|
{ "°", "" },
|
|
|
|
{ "±", "?" },
|
|
|
|
{ "²", "" },
|
|
|
|
{ "³", "?" },
|
|
|
|
{ "´", "?" },
|
|
|
|
{ "µ", "?" },
|
|
|
|
{ "¶", "?" },
|
|
|
|
{ "·", "" },
|
|
|
|
{ "¸", "?" },
|
|
|
|
{ "¹", "?" },
|
|
|
|
{ "º", "?" },
|
|
|
|
{ "»", "?" },
|
|
|
|
{ "¼", "?" },
|
|
|
|
{ "½", "?" },
|
|
|
|
{ "¾", "?" }
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void decode(TQString& url)
|
|
|
|
{
|
|
|
|
if( (int)url.find('&') != -1)
|
|
|
|
{
|
|
|
|
for(int i = 0; i != NUMBER_OF_HTML_CODES; ++i)
|
|
|
|
{
|
|
|
|
int index = url.find(htmlDocCharset[i][0]);
|
|
|
|
if(index != - 1)
|
|
|
|
{
|
|
|
|
url.replace(htmlDocCharset[i][0], htmlDocCharset[i][1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
void decode(string& url)
|
|
|
|
{
|
|
|
|
if( (int)url.find('&') != -1)
|
|
|
|
{
|
|
|
|
for(int i = 0; i != NUMBER_OF_HTML_CODES; ++i)
|
|
|
|
{
|
|
|
|
int index = url.find(htmlDocCharset[i][0].latin1());
|
|
|
|
if(index != - 1)
|
|
|
|
{
|
|
|
|
int length = htmlDocCharset[i][0].length();
|
|
|
|
url.replace(index, length, htmlDocCharset[i][1].latin1());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
int smallerUnsigned(int a, int b)
|
|
|
|
{
|
|
|
|
if(a >= 0 && b >= 0)
|
|
|
|
{
|
|
|
|
if(a < b)
|
|
|
|
return -1;
|
|
|
|
else if(a > b)
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(a < 0 && b < 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
else if(a < 0)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace FileManager
|
|
|
|
{
|
|
|
|
TQString read(TQString const& path)
|
|
|
|
{
|
|
|
|
TQFile file(path);
|
|
|
|
|
|
|
|
if(!file.open(IO_ReadOnly))
|
|
|
|
{
|
|
|
|
kdDebug() << "File " << path << " not found." << endl;
|
|
|
|
return TQString();
|
|
|
|
}
|
|
|
|
|
|
|
|
TQTextStream stream(&file);
|
|
|
|
TQString fileString = stream.read();
|
|
|
|
|
|
|
|
file.close();
|
|
|
|
|
|
|
|
return fileString;
|
|
|
|
}
|
|
|
|
}
|