diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:48:06 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:48:06 +0000 |
commit | 47c8a359c5276062c4bc17f0e82410f29081b502 (patch) | |
tree | 2d54a5f60a5b74067632f9ef6df58c2bc38155e6 /kopete/plugins/history/converter.cpp | |
parent | 6f82532777a35e0e60bbd2b290b2e93e646f349b (diff) | |
download | tdenetwork-47c8a359c5276062c4bc17f0e82410f29081b502.tar.gz tdenetwork-47c8a359c5276062c4bc17f0e82410f29081b502.zip |
Trinity Qt initial conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1157648 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kopete/plugins/history/converter.cpp')
-rw-r--r-- | kopete/plugins/history/converter.cpp | 140 |
1 files changed, 70 insertions, 70 deletions
diff --git a/kopete/plugins/history/converter.cpp b/kopete/plugins/history/converter.cpp index 22f662bc..d2e4839d 100644 --- a/kopete/plugins/history/converter.cpp +++ b/kopete/plugins/history/converter.cpp @@ -28,9 +28,9 @@ #include <kprogress.h> #include <kapplication.h> #include <ksavefile.h> -#include <qdir.h> -#include <qdom.h> -#include <qregexp.h> +#include <tqdir.h> +#include <tqdom.h> +#include <tqregexp.h> #define CBUFLENGTH 512 // buffer length for fgets() @@ -40,27 +40,27 @@ void HistoryPlugin::convertOldHistory() i18n( "Would you like to remove old history files?" ) , i18n( "History Converter" ), KStdGuiItem::del(), i18n("Keep") ) == KMessageBox::Yes; KProgressDialog *progressDlg=new KProgressDialog(Kopete::UI::Global::mainWidget() , "history_progress_dlg" , i18n( "History converter" ) , - QString::null , true); //modal to make sure the user will not doing stupid things (we have a kapp->processEvents()) + TQString::null , true); //modal to make sure the user will not doing stupid things (we have a kapp->processEvents()) progressDlg->setAllowCancel(false); //because i am too lazy to allow to cancel - QString kopetedir=locateLocal( "data", QString::fromLatin1( "kopete")); - QDir d( kopetedir ); //d should point to ~/.kde/share/apps/kopete/ + TQString kopetedir=locateLocal( "data", TQString::fromLatin1( "kopete")); + TQDir d( kopetedir ); //d should point to ~/.kde/share/apps/kopete/ - d.setFilter( QDir::Dirs ); + d.setFilter( TQDir::Dirs ); const QFileInfoList *list = d.entryInfoList(); QFileInfoListIterator it( *list ); - QFileInfo *fi; + TQFileInfo *fi; while ( (fi = it.current()) != 0 ) { - QString protocolId; - QString accountId; + TQString protocolId; + TQString accountId; if( Kopete::Protocol *p = dynamic_cast<Kopete::Protocol *>( Kopete::PluginManager::self()->plugin( fi->fileName() ) ) ) { protocolId=p->pluginId(); - QDictIterator<Kopete::Account> it(Kopete::AccountManager::self()->accounts(p)); + TQDictIterator<Kopete::Account> it(Kopete::AccountManager::self()->accounts(p)); Kopete::Account *a = it.current(); if(a) accountId=a->accountId(); @@ -103,12 +103,12 @@ void HistoryPlugin::convertOldHistory() if(!protocolId.isEmpty() || !accountId.isEmpty()) { - QDir d2( fi->absFilePath() ); - d2.setFilter( QDir::Files ); + TQDir d2( fi->absFilePath() ); + d2.setFilter( TQDir::Files ); d2.setNameFilter("*.log"); const QFileInfoList *list = d2.entryInfoList(); QFileInfoListIterator it2( *list ); - QFileInfo *fi2; + TQFileInfo *fi2; progressDlg->progressBar()->reset(); progressDlg->progressBar()->setTotalSteps(d2.count()); @@ -118,7 +118,7 @@ void HistoryPlugin::convertOldHistory() while ( (fi2 = it2.current()) != 0 ) { //we assume that all "-" are dots. (like in hotmail.com) - QString contactId=fi2->fileName().replace(".log" , QString::null).replace("-" , "."); + TQString contactId=fi2->fileName().replace(".log" , TQString::null).replace("-" , "."); if(!contactId.isEmpty() ) { @@ -127,48 +127,48 @@ void HistoryPlugin::convertOldHistory() int month=0; int year=0; - QDomDocument doc; - QDomElement docElem; + TQDomDocument doc; + TQDomElement docElem; - QDomElement msgelement; - QDomNode node; - QDomDocument xmllist; + TQDomElement msgelement; + TQDomNode node; + TQDomDocument xmllist; Kopete::Message::MessageDirection dir; - QString body, date, nick; - QString buffer, msgBlock; + TQString body, date, nick; + TQString buffer, msgBlock; char cbuf[CBUFLENGTH]; // buffer for the log file - QString logFileName = fi2->absFilePath(); + TQString logFileName = fi2->absFilePath(); // open the file - FILE *f = fopen(QFile::encodeName(logFileName), "r"); + FILE *f = fopen(TQFile::encodeName(logFileName), "r"); // create a new <message> block while ( ! feof( f ) ) { fgets(cbuf, CBUFLENGTH, f); - buffer = QString::fromUtf8(cbuf); + buffer = TQString::fromUtf8(cbuf); while ( strchr(cbuf, '\n') == NULL && !feof(f) ) { fgets( cbuf, CBUFLENGTH, f ); - buffer += QString::fromUtf8(cbuf); + buffer += TQString::fromUtf8(cbuf); } - if( buffer.startsWith( QString::fromLatin1( "<message " ) ) ) + if( buffer.startsWith( TQString::fromLatin1( "<message " ) ) ) { msgBlock = buffer; // find the end of the message block - while( !feof( f ) && buffer != QString::fromLatin1( "</message>\n" ) /*strcmp("</message>\n", cbuf )*/ ) + while( !feof( f ) && buffer != TQString::fromLatin1( "</message>\n" ) /*strcmp("</message>\n", cbuf )*/ ) { fgets(cbuf, CBUFLENGTH, f); - buffer = QString::fromUtf8(cbuf); + buffer = TQString::fromUtf8(cbuf); while ( strchr(cbuf, '\n') == NULL && !feof(f) ) { fgets( cbuf, CBUFLENGTH, f ); - buffer += QString::fromUtf8(cbuf); + buffer += TQString::fromUtf8(cbuf); } msgBlock.append(buffer); } @@ -178,14 +178,14 @@ void HistoryPlugin::convertOldHistory() msgelement = xmllist.documentElement(); node = msgelement.firstChild(); - if( msgelement.attribute( QString::fromLatin1( "direction" ) ) == QString::fromLatin1( "inbound" ) ) + if( msgelement.attribute( TQString::fromLatin1( "direction" ) ) == TQString::fromLatin1( "inbound" ) ) dir = Kopete::Message::Inbound; else dir = Kopete::Message::Outbound; // Read all the elements. - QString tagname; - QDomElement element; + TQString tagname; + TQDomElement element; while ( ! node.isNull() ) { @@ -194,12 +194,12 @@ void HistoryPlugin::convertOldHistory() element = node.toElement(); tagname = element.tagName(); - if( tagname == QString::fromLatin1( "srcnick" ) ) + if( tagname == TQString::fromLatin1( "srcnick" ) ) nick = element.text(); - else if( tagname == QString::fromLatin1( "date" ) ) + else if( tagname == TQString::fromLatin1( "date" ) ) date = element.text(); - else if( tagname == QString::fromLatin1( "body" ) ) + else if( tagname == TQString::fromLatin1( "body" ) ) body = element.text().stripWhiteSpace(); } @@ -207,21 +207,21 @@ void HistoryPlugin::convertOldHistory() } //FIXME!! The date in logs writed with kopete running with QT 3.0 is Localised. // so QT can't parse it correctly. - QDateTime dt=QDateTime::fromString(date); + TQDateTime dt=TQDateTime::fromString(date); if(dt.date().month() != month || dt.date().year() != year) { if(!docElem.isNull()) { - QDate date(year,month,1); - QString name = protocolId.replace( QRegExp( QString::fromLatin1( "[./~?*]" ) ), QString::fromLatin1( "-" ) ) + - QString::fromLatin1( "/" ) + - contactId.replace( QRegExp( QString::fromLatin1( "[./~?*]" ) ), QString::fromLatin1( "-" ) ) + + TQDate date(year,month,1); + TQString name = protocolId.replace( TQRegExp( TQString::fromLatin1( "[./~?*]" ) ), TQString::fromLatin1( "-" ) ) + + TQString::fromLatin1( "/" ) + + contactId.replace( TQRegExp( TQString::fromLatin1( "[./~?*]" ) ), TQString::fromLatin1( "-" ) ) + date.toString(".yyyyMM"); - KSaveFile file( locateLocal( "data", QString::fromLatin1( "kopete/logs/" ) + name+ QString::fromLatin1( ".xml" ) ) ); + KSaveFile file( locateLocal( "data", TQString::fromLatin1( "kopete/logs/" ) + name+ TQString::fromLatin1( ".xml" ) ) ); if( file.status() == 0 ) { - QTextStream *stream = file.textStream(); - //stream->setEncoding( QTextStream::UnicodeUTF8 ); //???? oui ou non? + TQTextStream *stream = file.textStream(); + //stream->setEncoding( TQTextStream::UnicodeUTF8 ); //???? oui ou non? doc.save( *stream , 1 ); file.close(); } @@ -230,39 +230,39 @@ void HistoryPlugin::convertOldHistory() month=dt.date().month(); year=dt.date().year(); - docElem=QDomElement(); + docElem=TQDomElement(); } if(docElem.isNull()) { - doc=QDomDocument("Kopete-History"); + doc=TQDomDocument("Kopete-History"); docElem= doc.createElement( "kopete-history" ); docElem.setAttribute ( "version" , "0.7" ); doc.appendChild( docElem ); - QDomElement headElem = doc.createElement( "head" ); + TQDomElement headElem = doc.createElement( "head" ); docElem.appendChild( headElem ); - QDomElement dateElem = doc.createElement( "date" ); - dateElem.setAttribute( "year", QString::number(year) ); - dateElem.setAttribute( "month", QString::number(month) ); + TQDomElement dateElem = doc.createElement( "date" ); + dateElem.setAttribute( "year", TQString::number(year) ); + dateElem.setAttribute( "month", TQString::number(month) ); headElem.appendChild(dateElem); - QDomElement myselfElem = doc.createElement( "contact" ); + TQDomElement myselfElem = doc.createElement( "contact" ); myselfElem.setAttribute( "type", "myself" ); myselfElem.setAttribute( "contactId", accountId ); headElem.appendChild(myselfElem); - QDomElement contactElem = doc.createElement( "contact" ); + TQDomElement contactElem = doc.createElement( "contact" ); contactElem.setAttribute( "contactId", contactId ); headElem.appendChild(contactElem); - QDomElement importElem = doc.createElement( "imported" ); + TQDomElement importElem = doc.createElement( "imported" ); importElem.setAttribute( "from", fi->fileName() ); - importElem.setAttribute( "date", QDateTime::currentDateTime().toString() ); + importElem.setAttribute( "date", TQDateTime::currentDateTime().toString() ); headElem.appendChild(importElem); } - QDomElement msgElem = doc.createElement( "msg" ); + TQDomElement msgElem = doc.createElement( "msg" ); msgElem.setAttribute( "in", dir==Kopete::Message::Outbound ? "0" : "1" ); msgElem.setAttribute( "from", dir==Kopete::Message::Outbound ? accountId : contactId ); msgElem.setAttribute( "nick", nick ); //do we have to set this? - msgElem.setAttribute( "time", QString::number(dt.date().day()) + " " + QString::number(dt.time().hour()) + ":" + QString::number(dt.time().minute()) ); - QDomText msgNode = doc.createTextNode( body.stripWhiteSpace() ); + msgElem.setAttribute( "time", TQString::number(dt.date().day()) + " " + TQString::number(dt.time().hour()) + ":" + TQString::number(dt.time().minute()) ); + TQDomText msgNode = doc.createTextNode( body.stripWhiteSpace() ); docElem.appendChild( msgElem ); msgElem.appendChild( msgNode ); } @@ -274,16 +274,16 @@ void HistoryPlugin::convertOldHistory() if(!docElem.isNull()) { - QDate date(year,month,1); - QString name = protocolId.replace( QRegExp( QString::fromLatin1( "[./~?*]" ) ), QString::fromLatin1( "-" ) ) + - QString::fromLatin1( "/" ) + - contactId.replace( QRegExp( QString::fromLatin1( "[./~?*]" ) ), QString::fromLatin1( "-" ) ) + + TQDate date(year,month,1); + TQString name = protocolId.replace( TQRegExp( TQString::fromLatin1( "[./~?*]" ) ), TQString::fromLatin1( "-" ) ) + + TQString::fromLatin1( "/" ) + + contactId.replace( TQRegExp( TQString::fromLatin1( "[./~?*]" ) ), TQString::fromLatin1( "-" ) ) + date.toString(".yyyyMM"); - KSaveFile file( locateLocal( "data", QString::fromLatin1( "kopete/logs/" ) + name+ QString::fromLatin1( ".xml" ) ) ); + KSaveFile file( locateLocal( "data", TQString::fromLatin1( "kopete/logs/" ) + name+ TQString::fromLatin1( ".xml" ) ) ); if( file.status() == 0 ) { - QTextStream *stream = file.textStream(); - //stream->setEncoding( QTextStream::UnicodeUTF8 ); //???? oui ou non? + TQTextStream *stream = file.textStream(); + //stream->setEncoding( TQTextStream::UnicodeUTF8 ); //???? oui ou non? doc.save( *stream ,1 ); file.close(); } @@ -304,22 +304,22 @@ void HistoryPlugin::convertOldHistory() bool HistoryPlugin::detectOldHistory() { KGlobal::config()->setGroup("History Plugin"); - QString version=KGlobal::config()->readEntry( "Version" ,"0.6" ); + TQString version=KGlobal::config()->readEntry( "Version" ,"0.6" ); if(version != "0.6") return false; - QDir d( locateLocal( "data", QString::fromLatin1( "kopete/logs")) ); - d.setFilter( QDir::Dirs ); + TQDir d( locateLocal( "data", TQString::fromLatin1( "kopete/logs")) ); + d.setFilter( TQDir::Dirs ); if(d.count() >= 3) // '.' and '..' are included return false; //the new history already exists - QDir d2( locateLocal( "data", QString::fromLatin1( "kopete")) ); - d2.setFilter( QDir::Dirs ); + TQDir d2( locateLocal( "data", TQString::fromLatin1( "kopete")) ); + d2.setFilter( TQDir::Dirs ); const QFileInfoList *list = d2.entryInfoList(); QFileInfoListIterator it( *list ); - QFileInfo *fi; + TQFileInfo *fi; while ( (fi = it.current()) != 0 ) { if( dynamic_cast<Kopete::Protocol *>( Kopete::PluginManager::self()->plugin( fi->fileName() ) ) ) |