diff options
Diffstat (limited to 'src/newstuff/providerloader.cpp')
-rw-r--r-- | src/newstuff/providerloader.cpp | 102 |
1 files changed, 0 insertions, 102 deletions
diff --git a/src/newstuff/providerloader.cpp b/src/newstuff/providerloader.cpp deleted file mode 100644 index 625156c..0000000 --- a/src/newstuff/providerloader.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/*************************************************************************** - copyright : (C) 2006 by Robby Stephenson - email : [email protected] - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of version 2 of the GNU General Public License as * - * published by the Free Software Foundation; * - * * - ***************************************************************************/ - -// this class is largely copied from tdelibs/tdenewstuff/provider.cpp -// which is Copyright (c) 2002 Cornelius Schumacher <[email protected]> -// and licensed under GPL v2, just like Tellico - -#include "providerloader.h" -#include "../tellico_debug.h" -#include "../latin1literal.h" - -#include <tdeio/job.h> -#include <tdenewstuff/provider.h> -#include <tdeglobal.h> -#include <tdeconfig.h> -#include <tdemessagebox.h> -#include <tdelocale.h> - -#include <tqdom.h> - -using Tellico::NewStuff::ProviderLoader; - -ProviderLoader::ProviderLoader( TQWidget *parentWidget ) : - mParentWidget( parentWidget ), mTryAlt(true) -{ - mProviders.setAutoDelete( true ); -} - -void ProviderLoader::load( const TQString &type, const TQString &providersList ) -{ - mProviders.clear(); - mJobData.truncate(0); - -// myLog() << "ProviderLoader::load(): providersList: " << providersList << endl; - - TDEIO::TransferJob *job = TDEIO::get( KURL( providersList ), false, false ); - connect( job, TQT_SIGNAL( result( TDEIO::Job * ) ), - TQT_SLOT( slotJobResult( TDEIO::Job * ) ) ); - connect( job, TQT_SIGNAL( data( TDEIO::Job *, const TQByteArray & ) ), - TQT_SLOT( slotJobData( TDEIO::Job *, const TQByteArray & ) ) ); - connect( job, TQT_SIGNAL( percent (TDEIO::Job *, unsigned long) ), - TQT_SIGNAL( percent (TDEIO::Job *, unsigned long) ) ); - -// job->dumpObjectInfo(); -} - -void ProviderLoader::slotJobData( TDEIO::Job *, const TQByteArray &data ) -{ - if ( data.size() == 0 ) return; - TQCString str( data, data.size() + 1 ); - mJobData.append( TQString::fromUtf8( str ) ); -} - -void ProviderLoader::slotJobResult( TDEIO::Job *job ) -{ - if ( job->error() ) { - job->showErrorDialog( mParentWidget ); - if(mTryAlt && !mAltProvider.isEmpty()) { - mTryAlt = false; - load(TQString(), mAltProvider); - } else { - emit error(); - } - return; - } - - TQDomDocument doc; - if ( !doc.setContent( mJobData ) ) { - myDebug() << "ProviderLoader::slotJobResult() - error parsing providers list." << endl; - if(mTryAlt && !mAltProvider.isEmpty()) { - mTryAlt = false; - load(TQString(), mAltProvider); - } else { - emit error(); - } - return; - } - - TQDomElement providers = doc.documentElement(); - TQDomNode n; - for ( n = providers.firstChild(); !n.isNull(); n = n.nextSibling() ) { - TQDomElement p = n.toElement(); - - if ( p.tagName() == Latin1Literal("provider") ) { - mProviders.append( new KNS::Provider( p ) ); - } - } - - emit providersLoaded( &mProviders ); -} - -#include "providerloader.moc" |