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