summaryrefslogtreecommitdiffstats
path: root/src/collectiondb.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/collectiondb.cpp')
-rw-r--r--src/collectiondb.cpp134
1 files changed, 67 insertions, 67 deletions
diff --git a/src/collectiondb.cpp b/src/collectiondb.cpp
index ebb9742..a729282 100644
--- a/src/collectiondb.cpp
+++ b/src/collectiondb.cpp
@@ -15,8 +15,8 @@
#include "sqlite/sqlite3.h"
-#include <qfile.h>
-#include <qtimer.h>
+#include <tqfile.h>
+#include <tqtimer.h>
#include <kapplication.h>
#include <kconfig.h>
@@ -89,10 +89,10 @@ CollectionDB::returnStaticDbConnection( DbConnection *conn )
/**
* Executes a SQL query on the already opened database
* @param statement SQL program to execute. Only one SQL statement is allowed.
- * @return The queried data, or QStringList() on error.
+ * @return The queried data, or TQStringList() on error.
*/
-QStringList
-CollectionDB::query( const QString& statement, DbConnection *conn )
+TQStringList
+CollectionDB::query( const TQString& statement, DbConnection *conn )
{
clock_t start;
if ( DEBUGSQL )
@@ -113,7 +113,7 @@ CollectionDB::query( const QString& statement, DbConnection *conn )
//kdDebug() << statement << endl;
- QStringList values = dbConn->query( statement );
+ TQStringList values = dbConn->query( statement );
//kdDebug() << values << endl;
@@ -138,7 +138,7 @@ CollectionDB::query( const QString& statement, DbConnection *conn )
* @return The rowid of the inserted item.
*/
int
-CollectionDB::insert( const QString& statement, const QString& table, DbConnection *conn )
+CollectionDB::insert( const TQString& statement, const TQString& table, DbConnection *conn )
{
clock_t start;
if ( DEBUGSQL )
@@ -181,7 +181,7 @@ CollectionDB::insert( const QString& statement, const QString& table, DbConnecti
bool
CollectionDB::isEmpty()
{
- QStringList values;
+ TQStringList values;
values = query( "SELECT COUNT( type ) FROM klamav_activity LIMIT 0, 1;" );
@@ -190,12 +190,12 @@ CollectionDB::isEmpty()
bool
-CollectionDB::isValid(const QString &column, const QString &table)
+CollectionDB::isValid(const TQString &column, const TQString &table)
{
- QStringList values1;
- QStringList values2;
+ TQStringList values1;
+ TQStringList values2;
- values1 = query( QString("SELECT COUNT( %1 ) FROM %2 LIMIT 0, 1;").arg(column).arg(table) );
+ values1 = query( TQString("SELECT COUNT( %1 ) FROM %2 LIMIT 0, 1;").arg(column).arg(table) );
//TODO? this returns true if value1 or value2 is not empty. Shouldn't this be and (&&)???
return !values1.isEmpty();
@@ -211,7 +211,7 @@ CollectionDB::createTables( DbConnection */*conn*/ )
//createMetaDBTable();
//create indexes
-/* query( QString( "CREATE INDEX date_idx%1 ON klamav_activity%2( date );" )
+/* query( TQString( "CREATE INDEX date_idx%1 ON klamav_activity%2( date );" )
.arg( conn ? "_temp" : "" ).arg( conn ? "_temp" : "" ), conn );*/
}
@@ -236,18 +236,18 @@ void
CollectionDB::loadMetaDBTable( DbConnection */*conn*/ )
{
- QString location = locate("data", "klamav/about/metadb.txt");
+ TQString location = locate("data", "klamav/about/metadb.txt");
-/* query( QString( ".import %1 klamav_activity;" ).arg(location), conn );
+/* query( TQString( ".import %1 klamav_activity;" ).arg(location), conn );
return;*/
- QFile file( location );
+ TQFile file( location );
if ( file.open( IO_ReadOnly ) ) {
- QTextStream stream( &file );
- QString line;
+ TQTextStream stream( &file );
+ TQString line;
while ( !stream.atEnd() ) {
line = stream.readLine(); // line of text excluding '\n'
- QStringList columns = QStringList::split("\t",line.remove("\""));
+ TQStringList columns = TQStringList::split("\t",line.remove("\""));
if (columns.count() >= 5)
insertMetaDBEntry(columns[0],columns[1],columns[2],columns[3],columns[4],columns[5]);
}
@@ -259,8 +259,8 @@ void
CollectionDB::dropTables( DbConnection *conn )
{
- query( QString( "DROP TABLE klamav_activity%1;" ).arg( conn ? "_temp" : "" ), conn );
- query( QString( "DROP TABLE klamav_metadb%1;" ).arg( conn ? "_temp" : "" ), conn );
+ query( TQString( "DROP TABLE klamav_activity%1;" ).arg( conn ? "_temp" : "" ), conn );
+ query( TQString( "DROP TABLE klamav_metadb%1;" ).arg( conn ? "_temp" : "" ), conn );
}
@@ -268,10 +268,10 @@ void
CollectionDB::clearTables( DbConnection *conn )
{
- QString clearCommand = "DELETE FROM";
+ TQString clearCommand = "DELETE FROM";
- query( QString( "%1 klamav_activity%2;" ).arg( clearCommand ).arg( conn ? "_temp" : "" ), conn );
- query( QString( "%1 klamav_metadb%2;" ).arg( clearCommand ).arg( conn ? "_temp" : "" ), conn );
+ query( TQString( "%1 klamav_activity%2;" ).arg( clearCommand ).arg( conn ? "_temp" : "" ), conn );
+ query( TQString( "%1 klamav_metadb%2;" ).arg( clearCommand ).arg( conn ? "_temp" : "" ), conn );
}
@@ -287,22 +287,22 @@ CollectionDB::moveTempTables( DbConnection *conn )
uint
-CollectionDB::IDFromValue( QString name, QString value, bool autocreate, const bool temporary, const bool updateSpelling, DbConnection *conn )
+CollectionDB::IDFromValue( TQString name, TQString value, bool autocreate, const bool temporary, const bool updateSpelling, DbConnection *conn )
{
if ( temporary )
name.append( "_temp" );
else
conn = NULL;
- QStringList values =
- query( QString(
+ TQStringList values =
+ query( TQString(
"SELECT id, name FROM %1 WHERE name LIKE '%2';" )
.arg( name )
.arg( CollectionDB::instance()->escapeString( value ) ), conn );
if ( updateSpelling && !values.isEmpty() && ( values[1] != value ) )
{
- query( QString( "UPDATE %1 SET id = %2, name = '%3' WHERE id = %4;" )
+ query( TQString( "UPDATE %1 SET id = %2, name = '%3' WHERE id = %4;" )
.arg( name )
.arg( values.first() )
.arg( CollectionDB::instance()->escapeString( value ) )
@@ -313,7 +313,7 @@ CollectionDB::IDFromValue( QString name, QString value, bool autocreate, const b
uint id;
if ( values.isEmpty() && autocreate )
{
- id = insert( QString( "INSERT INTO %1 ( name ) VALUES ( '%2' );" )
+ id = insert( TQString( "INSERT INTO %1 ( name ) VALUES ( '%2' );" )
.arg( name )
.arg( CollectionDB::instance()->escapeString( value ) ), name, conn );
@@ -324,11 +324,11 @@ CollectionDB::IDFromValue( QString name, QString value, bool autocreate, const b
}
-QString
-CollectionDB::valueFromID( QString table, uint id )
+TQString
+CollectionDB::valueFromID( TQString table, uint id )
{
- QStringList values =
- query( QString(
+ TQStringList values =
+ query( TQString(
"SELECT name FROM %1 WHERE id=%2;" )
.arg( table )
.arg( id ) );
@@ -338,23 +338,23 @@ CollectionDB::valueFromID( QString table, uint id )
}
-QString
-CollectionDB::typeCount( const QString &type_id )
+TQString
+CollectionDB::typeCount( const TQString &type_id )
{
- QStringList values =
- query( QString(
+ TQStringList values =
+ query( TQString(
"SELECT COUNT( type ) FROM klamav_activity WHERE type = %1;" )
.arg( type_id ) );
return values.first();
}
-QStringList
-CollectionDB::messagesForType( const QString &type_id, const bool isValue )
+TQStringList
+CollectionDB::messagesForType( const TQString &type_id, const bool isValue )
{
if ( isValue)
{
- return query( QString( "SELECT * FROM klamav_activity "
+ return query( TQString( "SELECT * FROM klamav_activity "
"WHERE (type = \"%1\" ) ;" )
.arg( type_id ) );
}
@@ -438,16 +438,16 @@ SqliteConnection::SqliteConnection( SqliteConfig* config )
: DbConnection( config )
{
- QString homepath = getenv("HOME");
- const QCString path = (homepath+"/.klamav/activity.db").local8Bit();
+ TQString homepath = getenv("HOME");
+ const TQCString path = (homepath+"/.klamav/activity.db").local8Bit();
// Open database file and check for correctness
m_initialized = false;
- QFile file( path );
+ TQFile file( path );
if ( file.open( IO_ReadOnly ) )
{
- QString format;
+ TQString format;
file.readLine( format, 50 );
if ( !format.startsWith( "SQLite format 3" ) )
{
@@ -465,7 +465,7 @@ SqliteConnection::SqliteConnection( SqliteConfig* config )
if ( !m_initialized )
{
// Remove old db file; create new
- QFile::remove( path );
+ TQFile::remove( path );
if ( sqlite3_open( path, &m_db ) == SQLITE_OK )
{
m_initialized = true;
@@ -490,9 +490,9 @@ SqliteConnection::~SqliteConnection()
}
-QStringList SqliteConnection::query( const QString& statement )
+TQStringList SqliteConnection::query( const TQString& statement )
{
- QStringList values;
+ TQStringList values;
int error;
const char* tail;
sqlite3_stmt* stmt;
@@ -505,7 +505,7 @@ QStringList SqliteConnection::query( const QString& statement )
kdDebug() << k_funcinfo << " sqlite3_compile error:" << endl;
kdDebug() << sqlite3_errmsg( m_db ) << endl;
kdDebug() << "on query: " << statement << endl;
- values = QStringList();
+ values = TQStringList();
}
else
{
@@ -533,7 +533,7 @@ QStringList SqliteConnection::query( const QString& statement )
//iterate over columns
for ( int i = 0; i < number; i++ )
{
- values << QString::fromUtf8( (const char*) sqlite3_column_text( stmt, i ) );
+ values << TQString::fromUtf8( (const char*) sqlite3_column_text( stmt, i ) );
}
}
//deallocate vm ressources
@@ -544,7 +544,7 @@ QStringList SqliteConnection::query( const QString& statement )
kdDebug() << k_funcinfo << "sqlite_step error.\n";
kdDebug() << sqlite3_errmsg( m_db ) << endl;
kdDebug() << "on query: " << statement << endl;
- values = QStringList();
+ values = TQStringList();
}
}
@@ -552,7 +552,7 @@ QStringList SqliteConnection::query( const QString& statement )
}
-int SqliteConnection::insert( const QString& statement, const QString& /* table */ )
+int SqliteConnection::insert( const TQString& statement, const TQString& /* table */ )
{
int error;
const char* tail;
@@ -629,7 +629,7 @@ void SqliteConnection::sqlite_power(sqlite3_context *context, int argc, sqlite3_
// CLASS SqliteConfig
//////////////////////////////////////////////////////////////////////////////////////////
-SqliteConfig::SqliteConfig( const QString& dbfile )
+SqliteConfig::SqliteConfig( const TQString& dbfile )
: m_dbfile( dbfile )
{
}
@@ -709,37 +709,37 @@ void DbConnectionPool::putDbConnection( const DbConnection *conn )
void
-CollectionDB::expireActivity(const QString &days )
+CollectionDB::expireActivity(const TQString &days )
{
int intdays = days.toInt();
if (intdays > 0)
intdays--;
- query( QString( "DELETE FROM klamav_activity WHERE date < datetime('now','localtime','-%2 days', 'start of day');" ).arg(intdays) );
+ query( TQString( "DELETE FROM klamav_activity WHERE date < datetime('now','localtime','-%2 days', 'start of day');" ).arg(intdays) );
}
-QStringList
+TQStringList
CollectionDB::allActivity( )
{
- return query( QString( "SELECT * FROM klamav_activity" ) );
+ return query( TQString( "SELECT * FROM klamav_activity" ) );
}
-QStringList
-CollectionDB::allActivityOfType(const QString &type,const QString &days )
+TQStringList
+CollectionDB::allActivityOfType(const TQString &type,const TQString &days )
{
int intdays = days.toInt();
intdays--;
if (type == "All Types")
- return query( QString( "SELECT * FROM klamav_activity WHERE date > datetime('now','localtime','-%2 days', 'start of day');" ).arg(intdays) );
+ return query( TQString( "SELECT * FROM klamav_activity WHERE date > datetime('now','localtime','-%2 days', 'start of day');" ).arg(intdays) );
- return query( QString( "SELECT * FROM klamav_activity where type = '%1'"
+ return query( TQString( "SELECT * FROM klamav_activity where type = '%1'"
" and date > datetime('now','localtime','-%2 days', 'start of day');" ).arg(type).arg(intdays) );
}
-void CollectionDB::insertEvent(const QString &type, const QString &event, const QString &file, DbConnection *conn)
+void CollectionDB::insertEvent(const TQString &type, const TQString &event, const TQString &file, DbConnection *conn)
{
if (((!(KlamavConfig::launchShutdown())) && (type == "Launch")) ||
@@ -752,8 +752,8 @@ void CollectionDB::insertEvent(const QString &type, const QString &event, const
((!(KlamavConfig::startedStoppedCancelled())) && (type == "Auto-Scan")))
return;
- QString date = query( QString( "select datetime('now','localtime')" ) ).first();
- insert( QString( "INSERT INTO klamav_activity ( type, date, event, file )"
+ TQString date = query( TQString( "select datetime('now','localtime')" ) ).first();
+ insert( TQString( "INSERT INTO klamav_activity ( type, date, event, file )"
" VALUES ( '%1', '%2', '%3', '%4' );" )
.arg( type )
.arg( date )
@@ -764,10 +764,10 @@ void CollectionDB::insertEvent(const QString &type, const QString &event, const
kmain->activityviewer->insertItem(date,type,event,file);
}
-void CollectionDB::insertMetaDBEntry(const QString &date, const QString &submission, const QString &creator,const QString &virus,const QString &alias, const QString &sender,DbConnection *conn)
+void CollectionDB::insertMetaDBEntry(const TQString &date, const TQString &submission, const TQString &creator,const TQString &virus,const TQString &alias, const TQString &sender,DbConnection *conn)
{
- insert( QString( "INSERT INTO klamav_metadb ( id, date, submission, creator, virus, alias, sender )"
+ insert( TQString( "INSERT INTO klamav_metadb ( id, date, submission, creator, virus, alias, sender )"
" VALUES ( NULL, \"%1\", \"%2\", \"%3\", \"%4\", \"%5\", \"%6\");" )
.arg( date )
.arg( submission.toInt() )
@@ -779,10 +779,10 @@ void CollectionDB::insertMetaDBEntry(const QString &date, const QString &submis
}
-QString
+TQString
CollectionDB::latestMetaDBDate( )
{
- QStringList highest = query( QString( "SELECT MAX(date) FROM klamav_metadb;" ));
+ TQStringList highest = query( TQString( "SELECT MAX(date) FROM klamav_metadb;" ));
return highest.first();
}