TQt4 port kio-apt

This enables compilation under both Qt3 and Qt4


git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kio-apt@1239302 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
v3.5.13-sru
tpearson 13 years ago
parent 0bceb5251f
commit f22f5c856d

@ -7,7 +7,7 @@ METASOURCES = AUTO
kio_apt_la_SOURCES = aptcache.cpp apt.cpp regexps.cpp packagemanager.cpp dpkg.cpp
kio_apt_la_LIBADD = $(top_builddir)/src/parsers/libparsers.la -lkio
kio_apt_la_LDFLAGS = -avoid-version -module $(all_libraries) $(KDE_PLUGIN)
kio_apt_la_LDFLAGS = -avoid-version -module $(all_libraries) $(KDE_PLUGIN) $(LIB_QT) $(LIB_KDECORE) $(LIB_KDEUI) $(LIB_KURL)
protocoldir = $(kde_servicesdir)
protocol_DATA = apt.protocol apt+http.protocol

@ -16,7 +16,7 @@
#include "parsers/parsers.h"
#include <qcstring.h>
#include <tqcstring.h>
#include <kapplication.h>
#include <kinstance.h>
@ -30,7 +30,7 @@
#include <kdebug.h>
#include <qregexp.h>
#include <tqregexp.h>
#include <stdlib.h>
@ -42,33 +42,33 @@ using namespace KIO;
* Common definitions of HTML fragments
*/
static const QString
static const TQString
html_preamble("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Strict//EN\"\n"
"\t\"http://www.w3.org/TR/html4/strict.dtd\">\n"
"<html>\n");
static const QString
static const TQString
html_redirect(html_preamble +
QString("<head>\n"
TQString("<head>\n"
"\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n"
"\t<meta http-equiv=\"Refresh\" content=\"0 ; URL=%1\">\n"
"</head>\n"
"\n<body></body>\n"
"</html>"));
static const QString
static const TQString
html_head(html_preamble +
QString("<head>\n"
TQString("<head>\n"
"\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n"
"\t<link rel=\"stylesheet\" href=\"file:%1\">\n"
"\t<title>%2</title>\n"
"</head>\n\n"
"<body>\n"));
static QString close_html_head();
static QString open_html_head(const QString& title, bool links, AptProtocol const& config)
static TQString close_html_head();
static TQString open_html_head(const TQString& title, bool links, AptProtocol const& config)
{
static const QString
static const TQString
html_head_table(
"<table class=\"header\" style=\"background-image: url(file:%1);\"\n"
"\t\tcellspacing=\"0\" cellpadding=\"0\">\n"
@ -76,18 +76,18 @@ static QString open_html_head(const QString& title, bool links, AptProtocol cons
"\t<td class=\"logo\" %2><img src=\"file:%3\" alt=\"%4\" style=\"border: 0px\" /></td>\n"
"\t<td class=\"header-title\">%4</td>\n");
QString rowspan;
TQString rowspan;
if (links) rowspan = "rowspan=\"2\"";
QString ret =
TQString ret =
html_head
.arg(config.stylesheet())
.arg(title)
.tqarg(config.stylesheet())
.tqarg(title)
+ html_head_table
.arg(config.header_background())
.arg(rowspan)
.arg(config.logo())
.arg(config.logo_alt())
.arg(title);
.tqarg(config.header_background())
.tqarg(rowspan)
.tqarg(config.logo())
.tqarg(config.logo_alt())
.tqarg(title);
if (links)
{
@ -103,12 +103,12 @@ static QString open_html_head(const QString& title, bool links, AptProtocol cons
return ret + "</tr>\n</table>\n\n";
}
}
static QString add_html_head_link(const QString& url, const QString& name, const QString& long_desc)
static TQString add_html_head_link(const TQString& url, const TQString& name, const TQString& long_desc)
{
static const QString format("\t\t<td><a href=\"%1\" title=\"%2\">%3</a></td>\n");
return format.arg(url).arg(long_desc).arg(name);
static const TQString format("\t\t<td><a href=\"%1\" title=\"%2\">%3</a></td>\n");
return format.tqarg(url).tqarg(long_desc).tqarg(name);
}
static QString close_html_head()
static TQString close_html_head()
{
return "\t</tr>\n"
"\t</table>\n"
@ -117,23 +117,23 @@ static QString close_html_head()
"</table>";
}
static const QString
static const TQString
html_tail("<div class=\"footer\">%1</div>\n"
"</body>\n"
"</html>");
QString AptProtocol::make_html_tail(const QString& note, bool with_form)
TQString AptProtocol::make_html_tail(const TQString& note, bool with_form)
{
with_form = m_search && with_form;
QString ret;
TQString ret;
if (with_form)
ret = "<hr>\n" + make_html_form();
if (!note.isEmpty())
ret += html_tail.arg(note + ". " + i18n("Page generated by kio_apt."));
else ret += html_tail.arg(i18n("Page generated by kio_apt."));
ret += html_tail.tqarg(note + ". " + i18n("Page generated by kio_apt."));
else ret += html_tail.tqarg(i18n("Page generated by kio_apt."));
return ret;
}
@ -142,30 +142,30 @@ QString AptProtocol::make_html_tail(const QString& note, bool with_form)
* Search form
*/
static const QString
static const TQString
html_form_begin("\n<form action=\"apt:/\" method=\"GET\">\n"
"<table class=\"query\">\n");
static const QString
static const TQString
html_form_end("<tr>\n"
"\t<td class=\"button\" colspan=\"2\"><input type=\"submit\" value=\"%1\"></td>\n"
"</tr>\n"
"</table>\n"
"</form>\n");
static const QString
static const TQString
html_form_line("<tr>\n"
"\t<td><label for=\"%1\">%2</label></td>\n"
"\t<td><input type=\"text\" name=\"%3\" id=\"%4\"></td>\n"
"</tr>\n");
static QString make_html_form_line(const QString& type, const QString& label)
{ return html_form_line.arg(type).arg(label).arg(type).arg(type); }
static TQString make_html_form_line(const TQString& type, const TQString& label)
{ return html_form_line.tqarg(type).tqarg(label).tqarg(type).tqarg(type); }
static QString make_extform_cmd(bool ext_form, const KURL& query)
static TQString make_extform_cmd(bool ext_form, const KURL& query)
{
QString cmd = ext_form ? "0" : "1";
QString msg = ext_form ? i18n("Hide extended form") : i18n("Show extended form");
TQString cmd = ext_form ? "0" : "1";
TQString msg = ext_form ? i18n("Hide extended form") : i18n("Show extended form");
KURL url(query);
url.addQueryItem("extended_form", cmd);
@ -178,7 +178,7 @@ static QString make_extform_cmd(bool ext_form, const KURL& query)
}
/** Prints the HTML code for the query form */
QString AptProtocol::make_html_form() const
TQString AptProtocol::make_html_form() const
{
bool can_fsearch = false;
bool ext_form = KGlobal::config() -> readBoolEntry("extended_form", true);
@ -190,8 +190,8 @@ QString AptProtocol::make_html_form() const
if (m_adept_batch)
online = online_form && (!m_internal) && ext_form && m_adept_batch -> capabilities(PackageManager::ONLINE);
QString ret;
QTextOStream stream(&ret);
TQString ret;
TQTextOStream stream(&ret);
stream << make_extform_cmd(ext_form, m_query);
if (online)
@ -206,7 +206,7 @@ QString AptProtocol::make_html_form() const
stream << make_html_form_line("fsearch", i18n("File search"));
stream << make_html_form_line("show", i18n("Package info"));
}
stream << html_form_end.arg( i18n("Search") );
stream << html_form_end.tqarg( i18n("Search") );
if (online)
{
@ -220,7 +220,7 @@ QString AptProtocol::make_html_form() const
/****************************************************************************************/
AptProtocol::AptProtocol( const QCString &pool_socket, const QCString &app_socket )
AptProtocol::AptProtocol( const TQCString &pool_socket, const TQCString &app_socket )
: SlaveBase( "kio_apt", pool_socket, app_socket ),
m_adept_batch(0), m_parser(0)
@ -236,38 +236,38 @@ AptProtocol::AptProtocol( const QCString &pool_socket, const QCString &app_socke
m_logo_alt = KGlobal::config() -> readEntryUntranslated("alt_tag", i18n("KDE on Debian") );
connect(&m_process, SIGNAL(token(const QString&, const QString&)),
this, SLOT(token_dispatch(const QString&, const QString&)));
connect(&m_process, TQT_SIGNAL(token(const TQString&, const TQString&)),
this, TQT_SLOT(token_dispatch(const TQString&, const TQString&)));
m_adept_batch = new Dpkg(this);
if (m_adept_batch)
{
connect(m_adept_batch, SIGNAL(token(const QString&, const QString&)),
this, SLOT(token_dispatch(const QString&, const QString&)));
connect(m_adept_batch, TQT_SIGNAL(token(const TQString&, const TQString&)),
this, TQT_SLOT(token_dispatch(const TQString&, const TQString&)));
}
}
AptProtocol::~AptProtocol() {}
QString AptProtocol::stylesheet() const { return m_stylesheet; }
QString AptProtocol::logo() const { return m_logo; }
QString AptProtocol::logo_alt() const { return m_logo_alt; }
QString AptProtocol::header_background() const { return m_header_background; }
TQString AptProtocol::stylesheet() const { return m_stylesheet; }
TQString AptProtocol::logo() const { return m_logo; }
TQString AptProtocol::logo_alt() const { return m_logo_alt; }
TQString AptProtocol::header_background() const { return m_header_background; }
void AptProtocol::token_dispatch(const QString& name, const QString& val)
void AptProtocol::token_dispatch(const TQString& name, const TQString& val)
{
if (m_parser.get())
(*m_parser)(this, name, val);
}
void AptProtocol::data(const QCString& string)
void AptProtocol::data(const TQCString& string)
{
using namespace Parsers;
(*this) << string;
}
void AptProtocol::data(const QString& string)
void AptProtocol::data(const TQString& string)
{
using namespace Parsers;
(*this) << string;
@ -279,7 +279,7 @@ void AptProtocol::data(const char* string)
(*this) << string;
}
void AptProtocol::data(const QByteArray& array)
void AptProtocol::data(const TQByteArray& array)
{ SlaveBase::data(array); }
void AptProtocol::mimetype( const KURL & /*url*/ )
@ -288,12 +288,12 @@ void AptProtocol::mimetype( const KURL & /*url*/ )
finished();
}
bool AptProtocol::check_validpackage(const QString& query)
bool AptProtocol::check_validpackage(const TQString& query)
{
static QRegExp rx_pkgname(rxs_pkgname);
static TQRegExp rx_pkgname(rxs_pkgname);
if (!rx_pkgname.exactMatch(query))
{
error( ERR_SLAVE_DEFINED, i18n("\"%1\" is not a valid package name").arg(query) );
error( ERR_SLAVE_DEFINED, i18n("\"%1\" is not a valid package name").tqarg(query) );
return false;
}
return true;
@ -304,10 +304,10 @@ bool AptProtocol::check_validpackage(const QString& query)
* Main entry point
*/
static QString read_option(QMap<QString, QString>& map, const QString& name, const QString& def)
static TQString read_option(TQMap<TQString, TQString>& map, const TQString& name, const TQString& def)
{
if (!map.contains(name)) return def;
QString ret = map[name];
if (!map.tqcontains(name)) return def;
TQString ret = map[name];
map.remove(name);
return ret;
}
@ -324,23 +324,23 @@ void AptProtocol::get ( const KURL& url )
apt:/
*/
typedef void (AptProtocol::*Command)(const QString&, const QueryOptions&);
static const QString commands[] =
typedef void (AptProtocol::*Command)(const TQString&, const QueryOptions&);
static const TQString commands[] =
{ "search", "show", "policy",
"fsearch", "list", "online",
"get", QString::null };
"get", TQString() };
static const Command methods[] =
{ &AptProtocol::search, &AptProtocol::show, &AptProtocol::policy,
&AptProtocol::searchfile, &AptProtocol::listfiles, &AptProtocol::online,
&AptProtocol::adept_batch };
QString command, query;
TQString command, query;
Command method = 0;
QueryOptions options = url.queryItems(KURL::CaseInsensitiveKeys);
// canonize the part before ? : remove the first /
QString path = url.path();
QString host = url.host();
TQString path = url.path();
TQString host = url.host();
if ( path.isEmpty() && !host.isEmpty() )
{
@ -352,7 +352,7 @@ void AptProtocol::get ( const KURL& url )
for (int cmd_idx = 0; !commands[cmd_idx].isNull(); ++cmd_idx)
{
const QString cmd_it = commands[cmd_idx];
const TQString cmd_it = commands[cmd_idx];
// Look if the command is in the path part
if (command.isEmpty() && cmd_it == path)
@ -360,7 +360,7 @@ void AptProtocol::get ( const KURL& url )
command = cmd_it;
method = methods[cmd_idx];
}
if (options.contains(cmd_it))
if (options.tqcontains(cmd_it))
{
if (options[cmd_it].isEmpty() && !options[cmd_it].isNull())
@ -393,7 +393,7 @@ void AptProtocol::get ( const KURL& url )
// Interpret the ioslave config options
// and remove them from the options map
QString opt = read_option(options, "extended_form", QString::null);
TQString opt = read_option(options, "extended_form", TQString());
if (!opt.isNull())
{
bool ext_form = (opt != "0");
@ -442,7 +442,7 @@ void AptProtocol::get ( const KURL& url )
if (m_query != url)
{
redirection(m_query);
data(QByteArray());
data(TQByteArray());
finished();
return;
}
@ -462,14 +462,14 @@ void AptProtocol::help()
{
mimeType("text/html");
QString buffer;
QTextOStream stream(&buffer);
TQString buffer;
TQTextOStream stream(&buffer);
stream
<< open_html_head(i18n("Search Form"), false, *this)
<< make_html_form()
<< make_html_tail(QString::null, false);
<< make_html_tail(TQString(), false);
data(buffer);
data(QByteArray());
data(TQByteArray());
finished();
}
@ -483,23 +483,23 @@ void AptProtocol::help()
* apt-cache search
*/
void AptProtocol::search( const QString& query, const QueryOptions& /*options*/ )
void AptProtocol::search( const TQString& query, const QueryOptions& /*options*/ )
{
mimeType("text/html");
data(open_html_head(i18n("Package search result for \"%1\"").arg(query), false, *this));
data(open_html_head(i18n("Package search result for \"%1\"").tqarg(query), false, *this));
m_parser.reset(new Parsers::Search);
(*m_parser)(this, "begin", query);
if (!m_process.search( query ))
{
error(ERR_SLAVE_DEFINED, i18n("Error launching the search").arg(query));
error(ERR_SLAVE_DEFINED, i18n("Error launching the search").tqarg(query));
return;
}
(*m_parser)(this, "end", QString::null);
(*m_parser)(this, "end", TQString());
data(make_html_tail( i18n("%1 results").arg(m_parser -> result_count())) );
data(QByteArray());
data(make_html_tail( i18n("%1 results").tqarg(m_parser -> result_count())) );
data(TQByteArray());
finished();
}
@ -512,10 +512,10 @@ void AptProtocol::search( const QString& query, const QueryOptions& /*options*/
* apt-cache show
*/
static QString filelist_cmd(bool show_filelist, const KURL& query)
static TQString filelist_cmd(bool show_filelist, const KURL& query)
{
QString value = show_filelist ? "0" : "1";
QString msg = show_filelist ? i18n("Hide file list") : i18n("Show file list");
TQString value = show_filelist ? "0" : "1";
TQString msg = show_filelist ? i18n("Hide file list") : i18n("Show file list");
KURL url(query);
url.addQueryItem("show_filelist", value);
@ -529,11 +529,11 @@ static QString filelist_cmd(bool show_filelist, const KURL& query)
"</div>";
}
void AptProtocol::show(const QString& package, const QueryOptions& options)
void AptProtocol::show(const TQString& package, const QueryOptions& options)
{
if (!check_validpackage(package)) return;
if (options.contains("show_filelist"))
if (options.tqcontains("show_filelist"))
{
KGlobal::config() -> writeEntry("show_filelist", options["show_filelist"] != "0");
KGlobal::config() -> sync();
@ -541,7 +541,7 @@ void AptProtocol::show(const QString& package, const QueryOptions& options)
mimeType("text/html");
QString installed_version;
TQString installed_version;
/** First, we parse policy
* We use here the fact that HTML is generated
@ -550,53 +550,53 @@ void AptProtocol::show(const QString& package, const QueryOptions& options)
* is installed or not */
Parsers::Policy* policy = new Parsers::Policy(package, m_act);
m_parser.reset(policy);
(*m_parser)(this, "begin", QString::null);
(*m_parser)(this, "begin", TQString());
{
if (!m_process.policy( package ))
{
error(ERR_SLAVE_DEFINED, i18n("Can't launch \"apt-cache policy %1\"").arg(package));
error(ERR_SLAVE_DEFINED, i18n("Can't launch \"apt-cache policy %1\"").tqarg(package));
return;
}
installed_version = policy->getInstalled();
bool can_list = can_listfiles(!installed_version.isEmpty());
QString buffer;
QTextOStream s(&buffer);
TQString buffer;
TQTextOStream s(&buffer);
if (can_list)
{
KURL url = buildURL("list", package);
s << open_html_head(i18n("Package description for \"%1\"").arg(package), true, *this)
s << open_html_head(i18n("Package description for \"%1\"").tqarg(package), true, *this)
<< add_html_head_link(url.htmlURL(), i18n("List package files"), "")
<< close_html_head();
}
else
{
s << open_html_head(i18n("Package description for \"%1\"").arg(package), false, *this);
s << open_html_head(i18n("Package description for \"%1\"").tqarg(package), false, *this);
}
data(buffer);
}
(*m_parser)(this, "end", QString::null);
(*m_parser)(this, "end", TQString());
/** Add package description section */
m_parser.reset(new Parsers::Show(package, installed_version, m_act));
(*m_parser)(this, "begin", QString::null);
(*m_parser)(this, "begin", TQString());
{
if (!m_process.show(package))
{
error(ERR_SLAVE_DEFINED, i18n("Can't launch \"apt-cache show %1\"").arg(package));
error(ERR_SLAVE_DEFINED, i18n("Can't launch \"apt-cache show %1\"").tqarg(package));
return;
}
if (!m_parser -> result_count())
{
data("<div class=\"error\">" + i18n("No package found named \"%1\"").arg(package) + "</div>\n");
data("<div class=\"error\">" + i18n("No package found named \"%1\"").tqarg(package) + "</div>\n");
data(make_html_tail());
data(QByteArray());
data(TQByteArray());
finished();
return;
}
}
(*m_parser)(this, "end", QString::null);
(*m_parser)(this, "end", TQString());
@ -612,13 +612,13 @@ void AptProtocol::show(const QString& package, const QueryOptions& options)
+ "<div class=\"filelist\">\n");
m_parser.reset(new Parsers::List(!m_internal));
(*m_parser)(this, "begin", QString::null);
(*m_parser)(this, "begin", TQString());
if (!m_adept_batch -> list(package))
{
error(ERR_SLAVE_DEFINED, i18n("Error listing files of %1").arg(package));
error(ERR_SLAVE_DEFINED, i18n("Error listing files of %1").tqarg(package));
return;
}
(*m_parser)(this, "end", QString::null);
(*m_parser)(this, "end", TQString());
data("\n</div>\n");
}
@ -637,7 +637,7 @@ void AptProtocol::show(const QString& package, const QueryOptions& options)
data(make_html_tail());
data(QByteArray());
data(TQByteArray());
finished();
}
@ -648,25 +648,25 @@ void AptProtocol::show(const QString& package, const QueryOptions& options)
* apt-cache policy
*/
void AptProtocol::policy( const QString& query, const QueryOptions& /*options*/ )
void AptProtocol::policy( const TQString& query, const QueryOptions& /*options*/ )
{
if (!check_validpackage(query)) return;
mimeType("text/html");
data( open_html_head(i18n("Apt policy for \"%1\"").arg(query), false, *this) );
data( open_html_head(i18n("Apt policy for \"%1\"").tqarg(query), false, *this) );
m_parser.reset(new Parsers::Policy(query, m_act));
(*m_parser)(this, "begin", QString::null);
(*m_parser)(this, "begin", TQString());
if (!m_process.policy( query ))
{
error(ERR_SLAVE_DEFINED, i18n("Can't launch the policy for %1").arg(query));
error(ERR_SLAVE_DEFINED, i18n("Can't launch the policy for %1").tqarg(query));
return;
}
(*m_parser)(this, "end", QString::null);
(*m_parser)(this, "end", TQString());
data(make_html_tail());
data(QByteArray());
data(TQByteArray());
finished();
}
@ -676,7 +676,7 @@ void AptProtocol::policy( const QString& query, const QueryOptions& /*options*/
* Search the package which contains a specific file
*/
static const QString
static const TQString
html_dpkgs_begin("\n\n<table>\n"),
html_dpkgs_end("\n\n</table>\n");
@ -688,24 +688,24 @@ bool AptProtocol::can_searchfile(bool is_installed) const
if (!caps) return false;
return is_installed || !(caps & PackageManager::INSTALLED_ONLY);
}
void AptProtocol::searchfile(const QString& query, const QueryOptions& /*options*/)
void AptProtocol::searchfile(const TQString& query, const QueryOptions& /*options*/)
{
if (!can_searchfile(true)) return;
mimeType("text/html");
data( open_html_head(i18n("File search for \"%1\"").arg(query), false, *this) + html_dpkgs_begin );
data( open_html_head(i18n("File search for \"%1\"").tqarg(query), false, *this) + html_dpkgs_begin );
m_parser.reset(new Parsers::FileSearch);
(*m_parser)(this, "begin", QString::null);
(*m_parser)(this, "begin", TQString());
if (!m_adept_batch -> search( query ))
{
error(ERR_SLAVE_DEFINED, i18n("Can't launch the package manager").arg(query));
error(ERR_SLAVE_DEFINED, i18n("Can't launch the package manager").tqarg(query));
return;
}
(*m_parser)(this, "end", QString::null);
(*m_parser)(this, "end", TQString());
data( html_dpkgs_end + make_html_tail(i18n("%1 files found").arg(m_parser -> result_count())) );
data(QByteArray());
data( html_dpkgs_end + make_html_tail(i18n("%1 files found").tqarg(m_parser -> result_count())) );
data(TQByteArray());
finished();
}
@ -724,7 +724,7 @@ bool AptProtocol::can_listfiles(bool is_installed) const
return is_installed || !(caps & PackageManager::INSTALLED_ONLY);
}
void AptProtocol::listfiles(const QString& query, const QueryOptions& /*options*/)
void AptProtocol::listfiles(const TQString& query, const QueryOptions& /*options*/)
{
if (!can_listfiles(true)) return;
if (!check_validpackage(query)) return;
@ -733,26 +733,26 @@ void AptProtocol::listfiles(const QString& query, const QueryOptions& /*options*
KURL ret_url = buildURL("show", query);
QString buffer;
QTextOStream stream(&buffer);
TQString buffer;
TQTextOStream stream(&buffer);
stream
<< open_html_head(i18n("Files in \"%1\"").arg(query), true, *this)
<< open_html_head(i18n("Files in \"%1\"").tqarg(query), true, *this)
<< add_html_head_link(ret_url.htmlURL(), i18n("Show package info"), "")
<< close_html_head()
<< endl;
data(buffer);
m_parser.reset(new Parsers::List(!m_internal));
(*m_parser)(this, "begin", QString::null);
(*m_parser)(this, "begin", TQString());
if (!m_adept_batch -> list( query ))
{
error(ERR_SLAVE_DEFINED, i18n("Can't launch the package manager").arg(query));
error(ERR_SLAVE_DEFINED, i18n("Can't launch the package manager").tqarg(query));
return;
}
(*m_parser)(this, "end", QString::null);
(*m_parser)(this, "end", TQString());
data(make_html_tail());
data(QByteArray());
data(TQByteArray());
finished();
}
@ -770,9 +770,9 @@ void AptProtocol::listfiles(const QString& query, const QueryOptions& /*options*
// return false;
//}
void AptProtocol::online(const QString& query, const QueryOptions& options)
void AptProtocol::online(const TQString& query, const QueryOptions& options)
{
QString url = m_adept_batch -> getOnlineURL(query, options);
TQString url = m_adept_batch -> getOnlineURL(query, options);
redirection(url);
finished();
return;
@ -781,15 +781,15 @@ void AptProtocol::online(const QString& query, const QueryOptions& options)
/***********************************************************************************
* Send commands for adept_batch
*/
void AptProtocol::adept_batch(const QString& query, const QueryOptions& options)
void AptProtocol::adept_batch(const TQString& query, const QueryOptions& options)
{
p=NULL;
QString command;
QString url;
QStringList plist;
QStringList puninst;
QStringList pinst;
TQString command;
TQString url;
TQStringList plist;
TQStringList puninst;
TQStringList pinst;
int pcount;
int ip;
@ -805,29 +805,29 @@ void AptProtocol::adept_batch(const QString& query, const QueryOptions& options)
return;
}
if (!options.contains("package"))
if (!options.tqcontains("package"))
{
error(ERR_SLAVE_DEFINED, i18n("No package specified"));
return;
}
plist = QStringList::split(", ", options["package"], false);
plist = TQStringList::split(", ", options["package"], false);
pcount = plist.count();
command += plist.join(" ");
if (pcount == 1)
{
if (query == "install")
ip = SlaveBase::messageBox(QuestionYesNo, i18n("Do you want to install %1 ?").arg(plist[0]), i18n("Package Installation"));
ip = SlaveBase::messageBox(QuestionYesNo, i18n("Do you want to install %1 ?").tqarg(plist[0]), i18n("Package Installation"));
else
ip = SlaveBase::messageBox(QuestionYesNo, i18n("Do you want to remove %1 ?").arg(plist[0]), i18n("Package Removal"));
ip = SlaveBase::messageBox(QuestionYesNo, i18n("Do you want to remove %1 ?").tqarg(plist[0]), i18n("Package Removal"));
}
else
{
if (query == "install")
ip = SlaveBase::messageBox(QuestionYesNo,i18n("Do you want to install the following %1 packages ?\n%2").arg(pcount).arg(options["package"]));
ip = SlaveBase::messageBox(QuestionYesNo,i18n("Do you want to install the following %1 packages ?\n%2").tqarg(pcount).tqarg(options["package"]));
else
ip = SlaveBase::messageBox(QuestionYesNo,i18n("Do you want to remove the following %1 packages ?\n").arg(pcount).arg(options["package"]));
ip = SlaveBase::messageBox(QuestionYesNo,i18n("Do you want to remove the following %1 packages ?\n").tqarg(pcount).tqarg(options["package"]));
}
kdDebug(DEBUG_ZONE) << command << endl;
@ -841,15 +841,15 @@ void AptProtocol::adept_batch(const QString& query, const QueryOptions& options)
for(int i = 0; i != pcount; ++i)
{
QString installed_version;
TQString installed_version;
Parsers::Policy* policy = new Parsers::Policy(plist[i], m_act);
m_parser.reset(policy);
(*m_parser)(this, "begin", QString::null);
(*m_parser)(this, "begin", TQString());
{
if (!m_process.policy( plist[i] ))
{
error(ERR_SLAVE_DEFINED, i18n("Can't launch \"apt-cache policy %1\"").arg(plist[i]));
error(ERR_SLAVE_DEFINED, i18n("Can't launch \"apt-cache policy %1\"").tqarg(plist[i]));
return;
}
@ -865,7 +865,7 @@ void AptProtocol::adept_batch(const QString& query, const QueryOptions& options)
}
}
if (options.contains("weblinkinstall"))
if (options.tqcontains("weblinkinstall"))
{
if (puninst.count() == 0)
{
@ -873,8 +873,8 @@ void AptProtocol::adept_batch(const QString& query, const QueryOptions& options)
}
else
{
QString toto = puninst.join(" ");
messageBox(Information,i18n("There was a problem installing %1.").arg(toto));
TQString toto = puninst.join(" ");
messageBox(Information,i18n("There was a problem installing %1.").tqarg(toto));
}
return;
}
@ -884,7 +884,7 @@ void AptProtocol::adept_batch(const QString& query, const QueryOptions& options)
// Outside of a weblink, only one package can be installed at time
url += plist[0];
redirection(url);
data(QByteArray());
data(TQByteArray());
finished();
return;
}
@ -895,7 +895,7 @@ void AptProtocol::adept_batch(const QString& query, const QueryOptions& options)
}
}
KURL AptProtocol::buildURL( const QString & command, const QString & query ) const
KURL AptProtocol::buildURL( const TQString & command, const TQString & query ) const
{
KURL url;
url.setProtocol("apt");

@ -1,8 +1,8 @@
#ifndef KIOAPT_APTPROTOCOL_H
#define KIOAPT_APTPROTOCOL_H
#include <qstring.h>
#include <qcstring.h>
#include <tqstring.h>
#include <tqcstring.h>
#include <kurl.h>
#include <kio/global.h>
@ -14,22 +14,23 @@
#include <memory>
class QCString;
class TQCString;
namespace Parsers
{
class Parser;
}
class AptProtocol : public QObject, public KIO::SlaveBase {
class AptProtocol : public TQObject, public KIO::SlaveBase {
Q_OBJECT
TQ_OBJECT
friend class AptCache;
AptCache m_process;
PackageManager* m_adept_batch;
typedef QMap<QString, QString> QueryOptions;
typedef TQMap<TQString, TQString> QueryOptions;
/** This this the URL that should be used if we want
* to get the same output again. It is especially
@ -47,14 +48,14 @@ class AptProtocol : public QObject, public KIO::SlaveBase {
* mode (for forbidding install, for instance) */
bool m_act, m_search, m_internal;
QString m_stylesheet;
QString m_header_background;
QString m_logo;
QString m_logo_alt;
TQString m_stylesheet;
TQString m_header_background;
TQString m_logo;
TQString m_logo_alt;
public:
AptProtocol( const QCString &pool_socket, const QCString &app_socket );
AptProtocol( const TQCString &pool_socket, const TQCString &app_socket );
virtual ~AptProtocol();
virtual void mimetype( const KURL& url );
virtual void get ( const KURL& url );
@ -63,26 +64,26 @@ public:
* SlaveBase::data() sends a byte array as is. Since we
* definitely don't want to send \0 to the master,
* we redefine data() for strings */
void data(const QCString& string);
void data(const TQCString& string);
/** @overload */
void data(const QString& string);
void data(const TQString& string);
/** @overload */
void data(const char* string);
void data(const QByteArray& array);
void data(const TQByteArray& array);
KURL buildURL(const QString& command, const QString& query) const;
KURL buildURL(const TQString& command, const TQString& query) const;
KURL buildURL(const KURL& query) const;
QString stylesheet() const;
QString header_background() const;
QString logo() const;
QString logo_alt() const;
TQString stylesheet() const;
TQString header_background() const;
TQString logo() const;
TQString logo_alt() const;
private slots:
void token_dispatch(const QString& tag, const QString& value);
void token_dispatch(const TQString& tag, const TQString& value);
private:
std::auto_ptr<Parsers::Parser> m_parser;
@ -90,24 +91,24 @@ private:
/** apt-cache search
* Performs apt-cache search, with the query encoded in url.query()
* and sends the result as an HTML file */
void search( const QString& url, const QueryOptions& options );
void search( const TQString& url, const QueryOptions& options );
/** apt-cache show
* Performs apt-cache search, with the package name encoded in url.query()
* and sends the result as an HTML file.
* It checks that the query contains a valid package name */
void show( const QString& url, const QueryOptions& options );
void show( const TQString& url, const QueryOptions& options );
/** apt-cache policy
* Performs apt-cache policy, with the package name encoded in url.query()
* and sends the result as an HTML file.
* It checks that the query contains a valid package name */
void policy( const QString& url, const QueryOptions& options );
void policy( const TQString& url, const QueryOptions& options );
/**
* Sends an application/x-adept_batch file with commands
* understandable by adept_batch */
void adept_batch( const QString& url, const QueryOptions& options );
void adept_batch( const TQString& url, const QueryOptions& options );
/**
* Shows a form where one can enter parameters for some queries
@ -116,19 +117,19 @@ private:
/** Offline listing of the file of a package */
bool can_listfiles(bool is_installed) const;
void listfiles( const QString& query, const QueryOptions& options);
void listfiles( const TQString& query, const QueryOptions& options);
/** Offline file search.
* Searches the package which contains the specified file */
bool can_searchfile(bool is_installed) const;
void searchfile( const QString& query, const QueryOptions& options);
void searchfile( const TQString& query, const QueryOptions& options);
bool can_online(int mode) const;
void online( const QString& query, const QueryOptions& options);
void online( const TQString& query, const QueryOptions& options);
bool check_validpackage(const QString& query);
QString make_html_form() const;
QString make_html_tail(const QString& note = QString::null, bool with_form = true);
bool check_validpackage(const TQString& query);
TQString make_html_form() const;
TQString make_html_tail(const TQString& note = TQString(), bool with_form = true);
KShellProcess * p;

@ -13,8 +13,8 @@
#include "regexps.h"
#include <qstringlist.h>
#include <qregexp.h>
#include <tqstringlist.h>
#include <tqregexp.h>
#include <kdebug.h>
@ -25,20 +25,20 @@
AptCache::AptCache()
{
connect(&m_process, SIGNAL(receivedStderr(KProcess*, char*, int)),
this, SLOT(receivedStdErr(KProcess*, char*, int )));
connect(&m_process, SIGNAL(receivedStdout(KProcess*, char*, int)),
this, SLOT(receivedStdOut(KProcess*, char*, int )));
connect(&m_process, TQT_SIGNAL(receivedStderr(KProcess*, char*, int)),
this, TQT_SLOT(receivedStdErr(KProcess*, char*, int )));
connect(&m_process, TQT_SIGNAL(receivedStdout(KProcess*, char*, int)),
this, TQT_SLOT(receivedStdOut(KProcess*, char*, int )));
}
AptCache::~AptCache() {}
static QStringList received(QString& buffer, char* input, int input_len)
static TQStringList received(TQString& buffer, char* input, int input_len)
{
buffer += QString::fromLatin1(input, input_len);
QStringList ret = QStringList::split('\n', buffer, true);
buffer += TQString::tqfromLatin1(input, input_len);
TQStringList ret = TQStringList::split('\n', buffer, true);
if (!buffer.endsWith("\n"))
{
buffer = ret.last();
@ -51,10 +51,10 @@ static QStringList received(QString& buffer, char* input, int input_len)
}
void AptCache::receivedStdErr( KProcess * /*process*/, char * buffer, int len )
{
static QRegExp rx_we("(W|E):\\s+(.*)");
static TQRegExp rx_we("(W|E):\\s+(.*)");
QStringList lines = received(m_received_err, buffer, len);
for (QStringList::ConstIterator i = lines.begin(); i != lines.end(); ++i)
TQStringList lines = received(m_received_err, buffer, len);
for (TQStringList::ConstIterator i = lines.begin(); i != lines.end(); ++i)
{
if (rx_we.exactMatch(*i))
{
@ -69,7 +69,7 @@ void AptCache::receivedStdErr( KProcess * /*process*/, char * buffer, int len )
}
void AptCache::receivedStdOut( KProcess * /*process*/, char * buffer, int len )
{
QStringList lines = received(m_received_out, buffer, len);
TQStringList lines = received(m_received_out, buffer, len);
(this->*m_receive)(lines);
}
@ -84,22 +84,22 @@ void AptCache::clear()
m_received_out = "";
}
bool AptCache::search(const QString& expression)
bool AptCache::search(const TQString& expression)
{
clear();
m_process.setEnvironment("LANGUAGE", "C");
m_process << "apt-cache" << "search";
m_process << QStringList::split(" ", expression);
m_process << TQStringList::split(" ", expression);
m_receive = &AptCache::receiveSearch;
return m_process.start(KProcess::Block, KProcess::Stdout );
}
void AptCache::receiveSearch(const QStringList& lines)
void AptCache::receiveSearch(const TQStringList& lines)
{
static QRegExp rx_parse("([^ ]+) - (.*)");
static TQRegExp rx_parse("([^ ]+) - (.*)");
QStringList::ConstIterator i;
TQStringList::ConstIterator i;
for (i = lines.begin(); i != lines.end(); ++i)
{
if ((*i).isEmpty()) continue;
@ -117,7 +117,7 @@ void AptCache::receiveSearch(const QStringList& lines)
}
}
bool AptCache::show(const QString& package)
bool AptCache::show(const TQString& package)
{
clear();
@ -127,19 +127,19 @@ bool AptCache::show(const QString& package)
return m_process.start(KProcess::Block, KProcess::Stdout );
}
void AptCache::receiveShow(const QStringList& lines)
void AptCache::receiveShow(const TQStringList& lines)
{
static bool pkgfield = false, insert_newline = false;
static int indent = 0;
static QRegExp rx_attribute("([\\w-]+): (.*)");
static const QString pkg_fields[] =
{ "Suggests", "Replaces", "Depends", "Conflicts", QString::null };
static TQRegExp rx_attribute("([\\w-]+): (.*)");
static const TQString pkg_fields[] =
{ "Suggests", "Replaces", "Depends", "Conflicts", TQString() };
QStringList::ConstIterator i;
TQStringList::ConstIterator i;
for (i = lines.begin(); i != lines.end(); ++i)
{
QString data(*i);
TQString data(*i);
if (data.isEmpty()) continue;
if (rx_attribute.exactMatch(*i))
@ -153,7 +153,7 @@ void AptCache::receiveShow(const QStringList& lines)
insert_newline = pkgfield = false;
indent = 0;
const QString * test_field;
const TQString * test_field;
for (test_field = pkg_fields; !test_field -> isNull(); ++test_field)
if (*test_field == m_attribute)
{
@ -168,7 +168,7 @@ void AptCache::receiveShow(const QStringList& lines)
parse_pkgfield(data);
else
{
int new_indent = data.find( QRegExp("[^\\s]") );
int new_indent = data.tqfind( TQRegExp("[^\\s]") );
// new_indent > 0 means that we are in a multi-line
// field. Those lines always begin with " ", so we want
@ -177,7 +177,7 @@ void AptCache::receiveShow(const QStringList& lines)
if (new_indent != indent)
{
emit token("indent", QString::number(new_indent) );
emit token("indent", TQString::number(new_indent) );
indent = new_indent;
insert_newline = false;
}
@ -200,20 +200,20 @@ void AptCache::receiveShow(const QStringList& lines)
}
}
void AptCache::parse_pkgfield(const QString& data)
void AptCache::parse_pkgfield(const TQString& data)
{
QStringList split(QStringList::split(",", data));
for (QStringList::ConstIterator i = split.begin(); i != split.end(); ++i)
TQStringList split(TQStringList::split(",", data));
for (TQStringList::ConstIterator i = split.begin(); i != split.end(); ++i)
{
if (i != split.begin()) emit token("data", ", ");
QStringList bar(QStringList::split("|", *i));
for (QStringList::ConstIterator j = bar.begin(); j != bar.end(); ++j)
TQStringList bar(TQStringList::split("|", *i));
for (TQStringList::ConstIterator j = bar.begin(); j != bar.end(); ++j)
{
if (j != bar.begin()) emit token("data", " | ");
QString pkg, remaining;
TQString pkg, remaining;
int paren = (*j).find('(');
int paren = (*j).tqfind('(');
if (paren != -1)
{
pkg = (*j).left(paren - 1);
@ -233,7 +233,7 @@ void AptCache::parse_pkgfield(const QString& data)
}
}
bool AptCache::policy( const QString & package )
bool AptCache::policy( const TQString & package )
{
clear();
@ -243,32 +243,32 @@ bool AptCache::policy( const QString & package )
return m_process.start(KProcess::Block, KProcess::Stdout );
}
void AptCache::receivePolicy(const QStringList& lines)
void AptCache::receivePolicy(const TQStringList& lines)
{
static QRegExp rx_pkgname("(\\w[\\w+-.]+):");
static QRegExp rx_location("^\\s*\\d+\\s[^\\d]");
static TQRegExp rx_pkgname("(\\w[\\w+-.]+):");
static TQRegExp rx_location("^\\s*\\d+\\s[^\\d]");
for(QStringList::ConstIterator l = lines.begin(); l != lines.end(); ++l)
for(TQStringList::ConstIterator l = lines.begin(); l != lines.end(); ++l)
{
if ((*l).isEmpty()) continue;
QString data( (*l).stripWhiteSpace() );
TQString data( (*l).stripWhiteSpace() );
if (rx_pkgname.exactMatch(*l))
emit token("package", rx_pkgname.cap(1));
else if (data.startsWith("Installed:", false))
else if (data.tqstartsWith("Installed:", false))
{
data = data.right(data.length() - 11);
emit token("installed", data);
m_installed = data;
}
else if (data.startsWith("Candidate:", false))
else if (data.tqstartsWith("Candidate:", false))
{
data = data.right(data.length() - 11);
emit token("candidate", data);
m_candidate = data;
}
else if (data.startsWith("Version table:", false))
emit token("version_table", QString::null);
else if (data.tqstartsWith("Version table:", false))
emit token("version_table", TQString());
else if (rx_location.search(data) > -1)
emit token("location", data);
else
@ -282,9 +282,9 @@ void AptCache::receivePolicy(const QStringList& lines)
}
}
QString AptCache::policy_installed() const
TQString AptCache::policy_installed() const
{ return m_installed; }
QString AptCache::policy_candidate() const
TQString AptCache::policy_candidate() const
{ return m_candidate; }

@ -10,9 +10,9 @@
#ifndef KIOAPT_APTCACHE_H
#define KIOAPT_APTCACHE_H
#include <qvaluelist.h>
#include <qmap.h>
#include <qstring.h>
#include <tqvaluelist.h>
#include <tqmap.h>
#include <tqstring.h>
#include <kprocess.h>
class AptProtocol;
@ -20,19 +20,20 @@ class AptProtocol;
/**
@author Sylvain Joyeux
*/
class AptCache : public QObject {
class AptCache : public TQObject {
Q_OBJECT
TQ_OBJECT
typedef void (AptCache::*ReceiveMethod) (const QStringList& lines);
typedef void (AptCache::*ReceiveMethod) (const TQStringList& lines);
ReceiveMethod m_receive;
// KProcIO messes the stderr and the stdout lines :(
KProcess m_process;
QString m_received_out, m_received_err;
TQString m_received_out, m_received_err;
QString m_attribute;
TQString m_attribute;
QString m_installed, m_candidate;
TQString m_installed, m_candidate;
private slots:
void receivedStdErr(KProcess* process, char* buffer, int len);
@ -40,21 +41,21 @@ private slots:
private:
void clear();
void receiveSearch(const QStringList& lines);
void receiveShow(const QStringList& lines);
void receivePolicy(const QStringList& lines);
void parse_pkgfield(const QString& data);
void receiveSearch(const TQStringList& lines);
void receiveShow(const TQStringList& lines);
void receivePolicy(const TQStringList& lines);
void parse_pkgfield(const TQString& data);
public:
AptCache();
~AptCache();
bool search(const QString& expression);
bool show(const QString& package);
bool policy(const QString& package);
bool search(const TQString& expression);