From 145abc15d57fb29701a12e8a14dcb9c1fd72e9be Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Mon, 7 Dec 2020 22:58:44 +0900 Subject: Renaming of files in preparation for code style tools. Signed-off-by: Michele Calgaro --- tdeioslave/info/CMakeLists.txt | 2 +- tdeioslave/info/Makefile.am | 2 +- tdeioslave/info/info.cc | 261 ----------------------------------------- tdeioslave/info/info.cpp | 261 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 263 insertions(+), 263 deletions(-) delete mode 100644 tdeioslave/info/info.cc create mode 100644 tdeioslave/info/info.cpp (limited to 'tdeioslave/info') diff --git a/tdeioslave/info/CMakeLists.txt b/tdeioslave/info/CMakeLists.txt index 6f243ba3f..85937d486 100644 --- a/tdeioslave/info/CMakeLists.txt +++ b/tdeioslave/info/CMakeLists.txt @@ -37,7 +37,7 @@ install( PROGRAMS kde-info2html DESTINATION ${DATA_INSTALL_DIR}/tdeio_info ) set( target tdeio_info ) tde_add_kpart( ${target} AUTOMOC - SOURCES info.cc + SOURCES info.cpp LINK tdeio-shared DESTINATION ${PLUGIN_INSTALL_DIR} ) diff --git a/tdeioslave/info/Makefile.am b/tdeioslave/info/Makefile.am index a682f4a77..8f0541c0f 100644 --- a/tdeioslave/info/Makefile.am +++ b/tdeioslave/info/Makefile.am @@ -8,7 +8,7 @@ METASOURCES = AUTO kde_module_LTLIBRARIES = tdeio_info.la -tdeio_info_la_SOURCES = info.cc +tdeio_info_la_SOURCES = info.cpp tdeio_info_la_LIBADD = $(LIB_TDEIO) tdeio_info_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) noinst_HEADERS = info.h diff --git a/tdeioslave/info/info.cc b/tdeioslave/info/info.cc deleted file mode 100644 index 83b41dae8..000000000 --- a/tdeioslave/info/info.cc +++ /dev/null @@ -1,261 +0,0 @@ -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "info.h" - -using namespace TDEIO; - -InfoProtocol::InfoProtocol( const TQCString &pool, const TQCString &app ) - : SlaveBase( "info", pool, app ) - , m_page( "" ) - , m_node( "" ) -{ - kdDebug( 7108 ) << "InfoProtocol::InfoProtocol" << endl; - - m_perl = TDEGlobal::dirs()->findExe( "perl" ); - m_infoScript = locate( "data", "tdeio_info/kde-info2html" ); - m_infoConf = locate("data", "tdeio_info/kde-info2html.conf"); - - if( m_perl.isNull() || m_infoScript.isNull() || m_infoConf.isNull() ) { - kdError( 7108 ) << "Critical error: Cannot locate files for HTML-conversion" << endl; - TQString errorStr; - if ( m_perl.isNull() ) { - errorStr = "perl."; - } else { - TQString missing =m_infoScript.isNull() ? "tdeio_info/kde-info2html" : "tdeio_info/kde-info2html.conf"; - errorStr = "kde-info2html" + i18n( "\nUnable to locate file %1 which is necessary to run this service. " - "Please check your software installation" ).arg( missing ); - } - error( TDEIO::ERR_CANNOT_LAUNCH_PROCESS, errorStr ); - exit(); - } - - kdDebug( 7108 ) << "InfoProtocol::InfoProtocol - done" << endl; -} - -InfoProtocol::~InfoProtocol() -{ - kdDebug( 7108 ) << "InfoProtocol::~InfoProtocol" << endl; - - kdDebug( 7108 ) << "InfoProtocol::~InfoProtocol - done" << endl; -} - -void InfoProtocol::get( const KURL& url ) -{ - kdDebug( 7108 ) << "InfoProtocol::get" << endl; - kdDebug( 7108 ) << "URL: " << url.prettyURL() << " , Path :" << url.path() << endl; - - if (url.path()=="/") - { - KURL newUrl("info:/dir"); - redirection(newUrl); - finished(); - return; - }; - - // some people write info://autoconf instead of info:/autoconf - if (!url.host().isEmpty()) { - KURL newURl(url); - newURl.setPath(url.host()+url.path()); - newURl.setHost(TQString::null); - redirection(newURl); - finished(); - return; - } - - if ( url.path().right(1) == "/" ) - { - // Trailing / are not supported, so we need to remove them. - KURL newUrl( url ); - TQString newPath( url.path() ); - newPath.truncate( newPath.length()-1 ); - newUrl.setPath( newPath ); - redirection( newUrl ); - finished(); - return; - } - - mimeType("text/html"); - // extract the path and node from url - decodeURL( url ); - - TQString path = TDEGlobal::iconLoader()->iconPath("go-up", TDEIcon::Toolbar, true); - int revindex = path.findRev('/'); - path = path.left(revindex); - - TQString cmd = TDEProcess::quote(m_perl); - cmd += " "; - cmd += TDEProcess::quote(m_infoScript); - cmd += " "; - cmd += TDEProcess::quote(m_infoConf); - cmd += " "; - cmd += TDEProcess::quote(path); - cmd += " "; - cmd += TDEProcess::quote(m_page); - cmd += " "; - cmd += TDEProcess::quote(m_node); - - kdDebug( 7108 ) << "cmd: " << cmd << endl; - - FILE *file = popen( TQFile::encodeName(cmd), "r" ); - if ( !file ) { - kdDebug( 7108 ) << "InfoProtocol::get popen failed" << endl; - error( ERR_CANNOT_LAUNCH_PROCESS, cmd ); - return; - } - - char buffer[ 4096 ]; - TQByteArray array; - - bool empty = true; - while ( !feof( file ) ) - { - int n = fread( buffer, 1, sizeof( buffer ), file ); - if ( !n && feof( file ) && empty ) { - error( ERR_CANNOT_LAUNCH_PROCESS, cmd ); - return; - } - if ( n < 0 ) - { - // ERROR - kdDebug( 7108 ) << "InfoProtocol::get ERROR!" << endl; - pclose( file ); - return; - } - - empty = false; - array.setRawData( buffer, n ); - data( array ); - array.resetRawData( buffer, n ); - } - - pclose( file ); - - finished(); - - kdDebug( 7108 ) << "InfoProtocol::get - done" << endl; -} - -void InfoProtocol::mimetype( const KURL& /* url */ ) -{ - kdDebug( 7108 ) << "InfoProtocol::mimetype" << endl; - - // to get rid of those "Open with" dialogs... - mimeType( "text/html" ); - - // finish action - finished(); - - kdDebug( 7108 ) << "InfoProtocol::mimetype - done" << endl; -} - -void InfoProtocol::decodeURL( const KURL &url ) -{ - kdDebug( 7108 ) << "InfoProtocol::decodeURL" << endl; - - /* Notes: - * - * I cleaned up the URL decoding and chose not to support URLs in the - * form "info:/usr/local/share/info/libc.info.gz" or similar which the - * older code attempted (and failed, maybe it had worked once) to do. - * - * The reason is that an obvious use such as viewing a info file off your - * infopath would work for the first page, but then all the links would be - * wrong. Of course, one could change kde-info2html to make it work, but I don't - * think it worthy, others are free to disagree and write the necessary code ;) - * - * luis pedro - */ - - if ( url == KURL( "info:/browse_by_file?special=yes" ) ) { - m_page = "#special#"; - m_node = "browse_by_file"; - kdDebug( 7108 ) << "InfoProtocol::decodeURL - special - browse by file" << endl; - return; - } - - decodePath( url.path() ); - - kdDebug( 7108 ) << "InfoProtocol::decodeURL - done" << endl; -} - -void InfoProtocol::decodePath( TQString path ) -{ - kdDebug( 7108 ) << "InfoProtocol::decodePath(-" < +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "info.h" + +using namespace TDEIO; + +InfoProtocol::InfoProtocol( const TQCString &pool, const TQCString &app ) + : SlaveBase( "info", pool, app ) + , m_page( "" ) + , m_node( "" ) +{ + kdDebug( 7108 ) << "InfoProtocol::InfoProtocol" << endl; + + m_perl = TDEGlobal::dirs()->findExe( "perl" ); + m_infoScript = locate( "data", "tdeio_info/kde-info2html" ); + m_infoConf = locate("data", "tdeio_info/kde-info2html.conf"); + + if( m_perl.isNull() || m_infoScript.isNull() || m_infoConf.isNull() ) { + kdError( 7108 ) << "Critical error: Cannot locate files for HTML-conversion" << endl; + TQString errorStr; + if ( m_perl.isNull() ) { + errorStr = "perl."; + } else { + TQString missing =m_infoScript.isNull() ? "tdeio_info/kde-info2html" : "tdeio_info/kde-info2html.conf"; + errorStr = "kde-info2html" + i18n( "\nUnable to locate file %1 which is necessary to run this service. " + "Please check your software installation" ).arg( missing ); + } + error( TDEIO::ERR_CANNOT_LAUNCH_PROCESS, errorStr ); + exit(); + } + + kdDebug( 7108 ) << "InfoProtocol::InfoProtocol - done" << endl; +} + +InfoProtocol::~InfoProtocol() +{ + kdDebug( 7108 ) << "InfoProtocol::~InfoProtocol" << endl; + + kdDebug( 7108 ) << "InfoProtocol::~InfoProtocol - done" << endl; +} + +void InfoProtocol::get( const KURL& url ) +{ + kdDebug( 7108 ) << "InfoProtocol::get" << endl; + kdDebug( 7108 ) << "URL: " << url.prettyURL() << " , Path :" << url.path() << endl; + + if (url.path()=="/") + { + KURL newUrl("info:/dir"); + redirection(newUrl); + finished(); + return; + }; + + // some people write info://autoconf instead of info:/autoconf + if (!url.host().isEmpty()) { + KURL newURl(url); + newURl.setPath(url.host()+url.path()); + newURl.setHost(TQString::null); + redirection(newURl); + finished(); + return; + } + + if ( url.path().right(1) == "/" ) + { + // Trailing / are not supported, so we need to remove them. + KURL newUrl( url ); + TQString newPath( url.path() ); + newPath.truncate( newPath.length()-1 ); + newUrl.setPath( newPath ); + redirection( newUrl ); + finished(); + return; + } + + mimeType("text/html"); + // extract the path and node from url + decodeURL( url ); + + TQString path = TDEGlobal::iconLoader()->iconPath("go-up", TDEIcon::Toolbar, true); + int revindex = path.findRev('/'); + path = path.left(revindex); + + TQString cmd = TDEProcess::quote(m_perl); + cmd += " "; + cmd += TDEProcess::quote(m_infoScript); + cmd += " "; + cmd += TDEProcess::quote(m_infoConf); + cmd += " "; + cmd += TDEProcess::quote(path); + cmd += " "; + cmd += TDEProcess::quote(m_page); + cmd += " "; + cmd += TDEProcess::quote(m_node); + + kdDebug( 7108 ) << "cmd: " << cmd << endl; + + FILE *file = popen( TQFile::encodeName(cmd), "r" ); + if ( !file ) { + kdDebug( 7108 ) << "InfoProtocol::get popen failed" << endl; + error( ERR_CANNOT_LAUNCH_PROCESS, cmd ); + return; + } + + char buffer[ 4096 ]; + TQByteArray array; + + bool empty = true; + while ( !feof( file ) ) + { + int n = fread( buffer, 1, sizeof( buffer ), file ); + if ( !n && feof( file ) && empty ) { + error( ERR_CANNOT_LAUNCH_PROCESS, cmd ); + return; + } + if ( n < 0 ) + { + // ERROR + kdDebug( 7108 ) << "InfoProtocol::get ERROR!" << endl; + pclose( file ); + return; + } + + empty = false; + array.setRawData( buffer, n ); + data( array ); + array.resetRawData( buffer, n ); + } + + pclose( file ); + + finished(); + + kdDebug( 7108 ) << "InfoProtocol::get - done" << endl; +} + +void InfoProtocol::mimetype( const KURL& /* url */ ) +{ + kdDebug( 7108 ) << "InfoProtocol::mimetype" << endl; + + // to get rid of those "Open with" dialogs... + mimeType( "text/html" ); + + // finish action + finished(); + + kdDebug( 7108 ) << "InfoProtocol::mimetype - done" << endl; +} + +void InfoProtocol::decodeURL( const KURL &url ) +{ + kdDebug( 7108 ) << "InfoProtocol::decodeURL" << endl; + + /* Notes: + * + * I cleaned up the URL decoding and chose not to support URLs in the + * form "info:/usr/local/share/info/libc.info.gz" or similar which the + * older code attempted (and failed, maybe it had worked once) to do. + * + * The reason is that an obvious use such as viewing a info file off your + * infopath would work for the first page, but then all the links would be + * wrong. Of course, one could change kde-info2html to make it work, but I don't + * think it worthy, others are free to disagree and write the necessary code ;) + * + * luis pedro + */ + + if ( url == KURL( "info:/browse_by_file?special=yes" ) ) { + m_page = "#special#"; + m_node = "browse_by_file"; + kdDebug( 7108 ) << "InfoProtocol::decodeURL - special - browse by file" << endl; + return; + } + + decodePath( url.path() ); + + kdDebug( 7108 ) << "InfoProtocol::decodeURL - done" << endl; +} + +void InfoProtocol::decodePath( TQString path ) +{ + kdDebug( 7108 ) << "InfoProtocol::decodePath(-" <