diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2014-09-21 17:37:36 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2014-09-21 17:37:36 -0500 |
commit | 47ac4096211c3f8634bc5e17027523dfe955bcaf (patch) | |
tree | 81124942ac2548fde3eb84c6f8f70bd6c66ceb0c /knewstuff | |
parent | 20e7ea1336a0c28c09b22623cb676d83a7fd168b (diff) | |
download | tdelibs-47ac4096211c3f8634bc5e17027523dfe955bcaf.tar.gz tdelibs-47ac4096211c3f8634bc5e17027523dfe955bcaf.zip |
Rework the KHNS system to properly download data from the new OCS network
This relates to Bug 2093
Diffstat (limited to 'knewstuff')
31 files changed, 418 insertions, 251 deletions
diff --git a/knewstuff/Mainpage.dox b/knewstuff/Mainpage.dox index 6f2d31051..d7f1c4da5 100644 --- a/knewstuff/Mainpage.dox +++ b/knewstuff/Mainpage.dox @@ -1,6 +1,6 @@ /** \mainpage Collaborative Data Sharing in Trinity Applications -The \b KNewStuff2 library adds data sharing capabilities to %Trinity +The \b TDENewStuff2 library adds data sharing capabilities to %Trinity applications. Technically, it implements the <a href="http://ghns.freedesktop.org/">GHNS</a> and DXS specifications. The library consists of three parts: the data management core @@ -8,15 +8,15 @@ and GHNS protocol implementation, the DXS web service handler, and the user inte classes like dialogs and buttons. Application authors should not use all of the classes directly, which are installed -only for the purpose of implementing functionality on top of \b KNewStuff2; instead, +only for the purpose of implementing functionality on top of \b TDENewStuff2; instead, the high-level KNS::Engine class provides everything an application needs. Both upload and download scenarios are handled by the engine. There are only two preparation steps necessary before this class can be used: the setup of a GHNS repository, and the creation of a <b>*.knsrc</b> file which will determine all aspects of the -application's \b KNewStuff2 usage. +application's \b TDENewStuff2 usage. All of the related information such as <b>*.knsrc</b> files, repositories and security -can be found in the <a href="http://techbase.kde.org/Development/Tutorials/K_Hot_New_Stuff2">KNewStuff2 tutorial</a>. +can be found in the <a href="http://techbase.kde.org/Development/Tutorials/K_Hot_New_Stuff2">TDENewStuff2 tutorial</a>. @authors Josef Spillner \<spillner@kde.org\> @@ -31,5 +31,5 @@ Jeremy Whiting \<jeremy@scitools.com\> */ // DOXYGEN_REFERENCES = tdecore tdeui tdeio -// DOXYGEN_SET_PROJECT_NAME = KNewStuff +// DOXYGEN_SET_PROJECT_NAME = TDENewStuff // vim:ts=4:sw=4:expandtab:filetype=doxygen diff --git a/knewstuff/README.knewstuff b/knewstuff/README.knewstuff index cdf4c79b3..fabefa988 100644 --- a/knewstuff/README.knewstuff +++ b/knewstuff/README.knewstuff @@ -1,6 +1,6 @@ -KNewStuff library - application data sharing framework for KDE +TDENewStuff library - application data sharing framework for KDE -KNewStuff implements the "Get Hot New Stuff" (GHNS) architecture and +TDENewStuff implements the "Get Hot New Stuff" (GHNS) architecture and provides KDE applications with easy-to-use upload and download mechanisms, with optional popularity counters, ratings, digital signatures, uncompression and post-installation DCOP/scripting hooks. @@ -11,14 +11,14 @@ and post-installation DCOP/scripting hooks. * Documentation - API docs http://developer.kde.org/documentation/library/cvs-api/knewstuff/html/ -- KNewStuff tutorial +- TDENewStuff tutorial http://www.kstuff.org/docs/tutorial/ -- KNewStuffSecure tutorial +- TDENewStuffSecure tutorial http://developer.kde.org/documentation/tutorials/knewstuffsecure/ * Repositories Currently, about 7 repositories exist for a variety of KDE applications using -KNewStuff for either download or upload or both. +TDENewStuff for either download or upload or both. Please have a look at the repository browser: -> http://www.kstuff.org/hotstuff/index.php?p=browser If you want automatic upload processing, download counting and administration diff --git a/knewstuff/data/README b/knewstuff/data/README deleted file mode 100644 index 6e50ceb2c..000000000 --- a/knewstuff/data/README +++ /dev/null @@ -1,5 +0,0 @@ -This directory contains example files for the providers list and the description -of downloadable entries. - -It also contains the DTDs for the XML files. You can check the XML files for -validity e.g with "xmllint <filename> --valid". diff --git a/knewstuff/data/knewstuff.dtd b/knewstuff/data/knewstuff.dtd deleted file mode 100644 index b8f6ecd4e..000000000 --- a/knewstuff/data/knewstuff.dtd +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!ELEMENT knewstuff (stuff*)> -<!ELEMENT stuff (name,author,licence,summary*,version,release,releasedate, - preview*,payload*,rating?,downloads?)> - <!ATTLIST stuff type CDATA #IMPLIED> - -<!ELEMENT name (#PCDATA)> - -<!ELEMENT author (#PCDATA)> - <!ATTLIST author email CDATA #REQUIRED> - -<!ELEMENT licence (#PCDATA)> - -<!ELEMENT summary (#PCDATA)> - <!ATTLIST summary lang CDATA #REQUIRED> - -<!ELEMENT version (#PCDATA)> - -<!ELEMENT release (#PCDATA)> - -<!ELEMENT releasedate (#PCDATA)> - -<!ELEMENT url (#PCDATA)> - -<!ELEMENT preview (#PCDATA)> - <!ATTLIST preview lang CDATA #REQUIRED> - -<!ELEMENT payload (#PCDATA)> - <!ATTLIST payload lang CDATA #REQUIRED> - -<!ELEMENT rating (#PCDATA)> - -<!ELEMENT downloads (#PCDATA)> diff --git a/knewstuff/data/knewstuff.xml b/knewstuff/data/knewstuff.xml deleted file mode 100644 index f7ba326ec..000000000 --- a/knewstuff/data/knewstuff.xml +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE knewstuff SYSTEM "knewstuff.dtd"> -<knewstuff> - <stuff type="korganizer/calendar"> - <name>worldcup2002</name> - <author email="schumacher@kde.org">Cornelius Schumacher</author> - <licence>GPL</licence> - <summary lang="en">Soccer world cup 2002</summary> - <version>1.0</version> - <release>1</release> - <releasedate>2002-06-19</releasedate> - <preview lang="en"></preview> - <payload lang="en">http://korganizer.kde.org/knewstuff/korganizer/calendar/worldcup2002.ics</payload> - <rating>5</rating> - <downloads>0</downloads> - </stuff> -</knewstuff> diff --git a/knewstuff/data/knewstuffproviders.dtd b/knewstuff/data/knewstuffproviders.dtd deleted file mode 100644 index aebbdb39e..000000000 --- a/knewstuff/data/knewstuffproviders.dtd +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!ELEMENT knewstuffproviders (provider+)> - -<!ELEMENT provider (noupload?,title)> - <!ATTLIST provider downloadurl CDATA #REQUIRED> - <!ATTLIST provider uploadurl CDATA #REQUIRED> - <!ATTLIST provider nouploadurl CDATA #IMPLIED> - <!ATTLIST provider icon CDATA #IMPLIED> - <!ATTLIST provider webaccess CDATA #IMPLIED> - -<!ELEMENT noupload EMPTY> - -<!ELEMENT title (#PCDATA)> diff --git a/knewstuff/data/providers.xml b/knewstuff/data/providers.xml deleted file mode 100644 index c76897a95..000000000 --- a/knewstuff/data/providers.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE knewstuffproviders SYSTEM "knewstuffproviders.dtd"> -<knewstuffproviders> - <provider downloadurl="http://korganizer.kde.org/knewstuff/korganizer/calendar/knewstuff.xml" - uploadurl="ftp://some.upload.server" - icon="korganizer" - webaccess="http://some.webfrontend.server"> - <title>KOrganizer Home Page</title> - </provider> -</knewstuffproviders> diff --git a/knewstuff/downloaddialog.cpp b/knewstuff/downloaddialog.cpp index 8c31712cb..4a3c56ff4 100644 --- a/knewstuff/downloaddialog.cpp +++ b/knewstuff/downloaddialog.cpp @@ -1,6 +1,7 @@ /* - This file is part of KNewStuff. + This file is part of TDENewStuff. Copyright (c) 2003 Josef Spillner <spillner@kde.org> + Copyright (c) 2014 Timothy Pearson <kb9vqf@pearsoncomputing.net> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -44,6 +45,8 @@ #include <tqtabwidget.h> #include <tqtimer.h> // hack +#define OPENDESKTOP_REDIRECT_URL "opendesktop.org/content/download.php?content=" + using namespace KNS; struct DownloadDialog::Private @@ -217,7 +220,6 @@ void DownloadDialog::addProvider(Provider *p) TQFrame *frame; TQTabWidget *ctl; TQWidget *w_d, *w_r, *w_l; - TQWidget *w2; TQTextBrowser *rt; TQString tmp; int ret; @@ -250,7 +252,6 @@ void DownloadDialog::addProvider(Provider *p) frame = addPage(p->name(), p->name(), pix); m_frame = frame; - w2 = new TQWidget(frame); w_d = new TQWidget(frame); w_r = new TQWidget(frame); w_l = new TQWidget(frame); @@ -335,10 +336,11 @@ void DownloadDialog::slotResult(TDEIO::Job *job) { TQDomDocument dom; TQDomElement knewstuff; + TQDomElement content; kdDebug() << "got data: " << m_data[job] << endl; - kapp->config()->setGroup("KNewStuffStatus"); + kapp->config()->setGroup("TDENewStuffStatus"); dom.setContent(m_data[job]); knewstuff = dom.documentElement(); @@ -347,9 +349,19 @@ void DownloadDialog::slotResult(TDEIO::Job *job) { TQDomElement stuff = pn.toElement(); + if(stuff.tagName() == "data") + { + content = pn.toElement(); + } + } + + for(TQDomNode pn = content.firstChild(); !pn.isNull(); pn = pn.nextSibling()) + { + TQDomElement stuff = pn.toElement(); + kdDebug() << "element: " << stuff.tagName() << endl; - if(stuff.tagName() == "stuff") + if(stuff.tagName() == "content") { Entry *entry = new Entry(stuff); kdDebug() << "TYPE::" << entry->type() << " FILTER::" << m_filter << endl; @@ -394,7 +406,7 @@ int DownloadDialog::installStatus(Entry *entry) TQString lang = TDEGlobal::locale()->language(); - kapp->config()->setGroup("KNewStuffStatus"); + kapp->config()->setGroup("TDENewStuffStatus"); datestring = kapp->config()->readEntry(entry->name(lang)); if(datestring.isNull()) installed = 0; else @@ -522,10 +534,39 @@ void DownloadDialog::slotInstall() d->m_lvtmp_r->setEnabled( false ); d->m_lvtmp_l->setEnabled( false ); d->m_lvtmp_d->setEnabled( false ); + + kdDebug() << "download entry now" << endl; + + // OpenDesktop.org broke the basic functionality of TDEHNS by forcing + // downloads though an advertising display page. This in turn forces + // the user to download and manually install the wallpaper, which + // is relatively complex and negates much of the benefit of TDEHNS. + // Therefore, if the download URL contains OPENDESKTOP_REDIRECT_URL + // then download the raw HTML page and extract the real download URL for use below. + // In the future we may want to figure out how to display unobtrusive ads + // during the download process, but OpenDesktop.org would need to add back + // in the direct download ability for this to even be considered. + if (e->payload().url().contains(OPENDESKTOP_REDIRECT_URL)) { + TDEIO::TransferJob *job = TDEIO::get( KURL( e->payload() ), 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 & ) ) ); + } + else { + slotInstallPhase2(); + } +} + +void DownloadDialog::slotInstallPhase2() +{ + Entry *e = getEntry(); + if(!e) return; + m_entryitem = currentEntryItem(); m_entryname = m_entryitem->text(0); - kdDebug() << "download entry now" << endl; + kdDebug() << "download entry now (phase 2)" << endl; if(m_engine) { @@ -534,7 +575,7 @@ void DownloadDialog::slotInstall() } else { - m_s = new KNewStuffGeneric(e->type(), this); + m_s = new TDENewStuffGeneric(e->type(), this); m_entry = e; KURL source = e->payload(); KURL dest = KURL(m_s->downloadDestination(e)); @@ -544,9 +585,42 @@ void DownloadDialog::slotInstall() } } +void DownloadDialog::slotJobData( TDEIO::Job *, const TQByteArray &data ) +{ + kdDebug() << "DownloadDialog::slotJobData()" << endl; + + if ( data.size() == 0 ) return; + + TQCString str( data, data.size() + 1 ); + + mJobData.append( TQString::fromUtf8( str ) ); +} + +void DownloadDialog::slotJobResult( TDEIO::Job *job ) +{ + if ( job->error() ) { + job->showErrorDialog( this ); + return; + } + + Entry *e = getEntry(); + if(!e) return; + + // See previous note regarding OpenDesktop.org + if (e->payload().url().contains(OPENDESKTOP_REDIRECT_URL)) { + TQString realURL = mJobData.mid(mJobData.find("<a href=\"/CONTENT/content-files/")); + realURL = realURL.mid(0, realURL.find("Click here</a>")-2); + realURL = realURL.mid(realURL.find("/CONTENT/content-files")); + realURL = e->payload().protocol() + "://opendesktop.org" + realURL; + e->setPayload(realURL); + } + + slotInstallPhase2(); +} + void DownloadDialog::install(Entry *e) { - kapp->config()->setGroup("KNewStuffStatus"); + kapp->config()->setGroup("TDENewStuffStatus"); kapp->config()->writeEntry(m_entryname, TQString(e->releaseDate().toString(Qt::ISODate))); kapp->config()->sync(); diff --git a/knewstuff/downloaddialog.h b/knewstuff/downloaddialog.h index 1d61d259d..2c74e21f3 100644 --- a/knewstuff/downloaddialog.h +++ b/knewstuff/downloaddialog.h @@ -1,5 +1,5 @@ /* - This file is part of KNewStuff. + This file is part of TDENewStuff. Copyright (c) 2003 Josef Spillner <spillner@kde.org> This library is free software; you can redistribute it and/or @@ -31,7 +31,7 @@ namespace TDEIO class TDEListView; class TQTextBrowser; class TQFrame; -class KNewStuffGeneric; +class TDENewStuffGeneric; namespace KNS { @@ -47,7 +47,7 @@ class Engine; * It provides an easy-to-use convenience method named open() which does all * the work, unless a more complex operation is needed. * \code - * KNewStuff::DownloadDialog::open("kdesktop/wallpapers"); + * TDENewStuff::DownloadDialog::open("kdesktop/wallpapers"); * \endcode * * @author Josef Spillner (spillner@kde.org) @@ -213,7 +213,10 @@ class KDE_EXPORT DownloadDialog : public KDialogBase private slots: void slotResult(TDEIO::Job *job); void slotData(TDEIO::Job *job, const TQByteArray &a); + void slotJobData( TDEIO::Job *, const TQByteArray & ); + void slotJobResult( TDEIO::Job * ); void slotInstall(); + void slotInstallPhase2(); void slotDetails(); void slotInstalled(TDEIO::Job *job); void slotTab(); @@ -238,7 +241,7 @@ class KDE_EXPORT DownloadDialog : public KDialogBase TQListViewItem *m_entryitem; TQPtrList<Entry> m_entries; Entry *m_entry; - KNewStuffGeneric *m_s; + TDENewStuffGeneric *m_s; int m_curtab; TQMap<TQWidget*, TQValueList<TDEListView*>* > m_map; TQMap<TQWidget*, Provider*> m_providers; @@ -247,6 +250,7 @@ class KDE_EXPORT DownloadDialog : public KDialogBase TQMap<TDEIO::Job*, Provider*> m_jobs; TQMap<TDEIO::Job*, TQString> m_data; TQString m_filter; + TQString mJobData; Engine *m_engine; Private *d; }; diff --git a/knewstuff/engine.cpp b/knewstuff/engine.cpp index 2b33e85f5..f8e7163a9 100644 --- a/knewstuff/engine.cpp +++ b/knewstuff/engine.cpp @@ -1,6 +1,7 @@ /* This file is part of KOrganizer. Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> + Copyright (c) 2014 Timothy Pearson <kb9vqf@pearsoncomputing.net> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -42,10 +43,10 @@ using namespace KNS; struct Engine::Private { bool mIgnoreInstallResult; - KNewStuff *mNewStuff; + TDENewStuff *mNewStuff; }; -Engine::Engine( KNewStuff *newStuff, const TQString &type, +Engine::Engine( TDENewStuff *newStuff, const TQString &type, TQWidget *parentWidget ) : mParentWidget( parentWidget ), mDownloadDialog( 0 ), mUploadDialog( 0 ), mProviderDialog( 0 ), mUploadProvider( 0 ), @@ -56,7 +57,7 @@ Engine::Engine( KNewStuff *newStuff, const TQString &type, mProviderLoader = new ProviderLoader( mParentWidget ); } -Engine::Engine( KNewStuff *newStuff, const TQString &type, +Engine::Engine( TDENewStuff *newStuff, const TQString &type, const TQString &providerList, TQWidget *parentWidget ) : mParentWidget( parentWidget ), mDownloadDialog( 0 ), mUploadDialog( 0 ), diff --git a/knewstuff/engine.h b/knewstuff/engine.h index 374f9122d..432f3b04c 100644 --- a/knewstuff/engine.h +++ b/knewstuff/engine.h @@ -1,6 +1,7 @@ /* This file is part of KOrganizer. Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> + Copyright (c) 2014 Timothy Pearson <kb9vqf@pearsoncomputing.net> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -29,7 +30,7 @@ namespace TDEIO { class Job; } -class KNewStuff; +class TDENewStuff; namespace KNS { @@ -38,7 +39,7 @@ class UploadDialog; class ProviderDialog; /** - * @short Central class combining all possible KNewStuff operations. + * @short Central class combining all possible TDENewStuff operations. * * In most cases, Engine objects are built and used internally. * Using this class explicitely does however give fine-grained control about the @@ -56,20 +57,20 @@ class KDE_EXPORT Engine : public TQObject /** Constructor. - @param newStuff a KNewStuff object + @param newStuff a TDENewStuff object @param type the Hotstuff data type such as "korganizer/calendar" @param parentWidget the parent window */ - Engine( KNewStuff *newStuff, const TQString &type, TQWidget *parentWidget = 0 ); + Engine( TDENewStuff *newStuff, const TQString &type, TQWidget *parentWidget = 0 ); /** Constructor. - @param newStuff a KNewStuff object + @param newStuff a TDENewStuff object @param type the Hotstuff data type such as "korganizer/calendar" @param providerList the URL of the provider list @param parentWidget the parent window */ - Engine( KNewStuff *newStuff, const TQString &type, const TQString &providerList, TQWidget *parentWidget = 0 ); + Engine( TDENewStuff *newStuff, const TQString &type, const TQString &providerList, TQWidget *parentWidget = 0 ); /** Destructor. @@ -130,7 +131,7 @@ class KDE_EXPORT Engine : public TQObject /** Ignores the return value of the install method. Used internally to avoid showing of the success/failure dialog when installation is done - in another place, like in @ref KNewStuffSecure + in another place, like in @ref TDENewStuffSecure */ void ignoreInstallResult(bool ignore); diff --git a/knewstuff/entry.cpp b/knewstuff/entry.cpp index 00f7df522..2713fadfb 100644 --- a/knewstuff/entry.cpp +++ b/knewstuff/entry.cpp @@ -1,6 +1,7 @@ /* This file is part of KOrganizer. Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> + Copyright (c) 2014 Timothy Pearson <kb9vqf@pearsoncomputing.net> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -297,46 +298,57 @@ TQStringList Entry::langs() return mLangs; } +// FIXME +// It appears that OCS has removed the ability to retrieve author EMail; +// further confirmation is needed before removing EMail-related code void Entry::parseDomElement( const TQDomElement &element ) { - if ( element.tagName() != "stuff" ) return; + if ( element.tagName() != "content" ) return; mType = element.attribute("type"); TQDomNode n; + TQString lang; + for( n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) { + TQDomElement e = n.toElement(); + if ( e.tagName() == "language" ) + { + lang = e.text(); + } + } + if (lang == "") { + lang = TQString::null; + } + for( n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) { TQDomElement e = n.toElement(); if ( e.tagName() == "name" ) { - TQString lang = e.attribute( "lang" ); setName( e.text().stripWhiteSpace(), lang ); - if(lang.isNull()) setName( e.text().stripWhiteSpace() ); /* primary key - no i18n */ + setName( e.text().stripWhiteSpace() ); /* primary key - no i18n */ } - if ( e.tagName() == "author" ) { + if ( e.tagName() == "personid" ) { setAuthor( e.text().stripWhiteSpace() ); - TQString email = e.attribute( "email" ); - setAuthorEmail( email ); +// TQString email = e.attribute( "email" ); +// setAuthorEmail( email ); } - if ( e.tagName() == "email" ) setAuthorEmail( e.text().stripWhiteSpace() ); /* kde-look; change on server! */ +// if ( e.tagName() == "email" ) setAuthorEmail( e.text().stripWhiteSpace() ); /* kde-look; change on server! */ if ( e.tagName() == "licence" ) setLicence( e.text().stripWhiteSpace() ); - if ( e.tagName() == "summary" ) { - TQString lang = e.attribute( "lang" ); + if ( e.tagName() == "description" ) { setSummary( e.text().stripWhiteSpace(), lang ); } if ( e.tagName() == "version" ) setVersion( e.text().stripWhiteSpace() ); - if ( e.tagName() == "release" ) setRelease( e.text().toInt() ); - if ( e.tagName() == "releasedate" ) { +// if ( e.tagName() == "release" ) setRelease( e.text().toInt() ); + if ( e.tagName() == "created" ) { TQDate date = TQT_TQDATE_OBJECT(TQDate::fromString( e.text().stripWhiteSpace(), Qt::ISODate )); setReleaseDate( date ); } - if ( e.tagName() == "preview" ) { - TQString lang = e.attribute( "lang" ); + if ( e.tagName() == "smallpreviewpic1" ) { setPreview( KURL( e.text().stripWhiteSpace() ), lang ); } - if ( e.tagName() == "payload" ) { - TQString lang = e.attribute( "lang" ); + if ( e.tagName() == "downloadlink1" ) { setPayload( KURL( e.text().stripWhiteSpace() ), lang ); } - if ( e.tagName() == "rating" ) setRating( e.text().toInt() ); + if ( e.tagName() == "score" ) setRating( e.text().toInt() ); if ( e.tagName() == "downloads" ) setDownloads( e.text().toInt() ); } } @@ -344,32 +356,27 @@ void Entry::parseDomElement( const TQDomElement &element ) TQDomElement Entry::createDomElement( TQDomDocument &doc, TQDomElement &parent ) { - TQDomElement entry = doc.createElement( "stuff" ); + TQDomElement entry = doc.createElement( "content" ); entry.setAttribute("type", mType); parent.appendChild( entry ); + addElement( doc, entry, "language", langs().first() ); + addElement( doc, entry, "name", name() ); - addElement( doc, entry, "author", author() ); - addElement( doc, entry, "email", authorEmail() ); + addElement( doc, entry, "personid", author() ); +// addElement( doc, entry, "email", authorEmail() ); addElement( doc, entry, "licence", license() ); addElement( doc, entry, "version", version() ); - addElement( doc, entry, "release", TQString::number( release() ) ); - addElement( doc, entry, "rating", TQString::number( rating() ) ); +// addElement( doc, entry, "release", TQString::number( release() ) ); + addElement( doc, entry, "score", TQString::number( rating() ) ); addElement( doc, entry, "downloads", TQString::number( downloads() ) ); - addElement( doc, entry, "releasedate", + addElement( doc, entry, "created", releaseDate().toString( Qt::ISODate ) ); - TQStringList ls = langs(); - TQStringList::ConstIterator it; - for( it = ls.begin(); it != ls.end(); ++it ) { - TQDomElement e = addElement( doc, entry, "summary", summary( *it ) ); - e.setAttribute( "lang", *it ); - e = addElement( doc, entry, "preview", preview( *it ).url() ); - e.setAttribute( "lang", *it ); - e = addElement( doc, entry, "payload", payload( *it ).url() ); - e.setAttribute( "lang", *it ); - } + addElement( doc, entry, "description", summary() ); + addElement( doc, entry, "preview", preview().url() ); + addElement( doc, entry, "payload", payload().url() ); return entry; } diff --git a/knewstuff/entry.h b/knewstuff/entry.h index 6e8a15bc7..e04822e39 100644 --- a/knewstuff/entry.h +++ b/knewstuff/entry.h @@ -1,6 +1,7 @@ /* This file is part of KOrganizer. Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> + Copyright (c) 2014 Timothy Pearson <kb9vqf@pearsoncomputing.net> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -31,10 +32,10 @@ namespace KNS { /** - * @short KNewStuff data entry container. + * @short TDENewStuff data entry container. * * This class provides accessor methods to the data objects - * as used by KNewStuff. + * as used by TDENewStuff. * It should probably not be used directly by the application. * * @author Cornelius Schumacher (schumacher@kde.org) diff --git a/knewstuff/ghns.cpp b/knewstuff/ghns.cpp index 0702f16bb..3217de80e 100644 --- a/knewstuff/ghns.cpp +++ b/knewstuff/ghns.cpp @@ -41,7 +41,7 @@ using namespace std; GhnsWidget::GhnsWidget() { - mWallpapers = new KNewStuffGeneric( "kdesktop/wallpaper", this ); + mWallpapers = new TDENewStuffGeneric( "kdesktop/wallpaper", this ); TQBoxLayout *topLayout = new TQVBoxLayout( this ); topLayout->setMargin( KDialog::marginHint() ); diff --git a/knewstuff/ghns.h b/knewstuff/ghns.h index 74efc007e..7eea0c489 100644 --- a/knewstuff/ghns.h +++ b/knewstuff/ghns.h @@ -41,7 +41,7 @@ class GhnsWidget : public TQWidget void downloadWallpapers(); private: - KNewStuff *mWallpapers; + TDENewStuff *mWallpapers; }; #endif diff --git a/knewstuff/knewstuff.cpp b/knewstuff/knewstuff.cpp index b652ba4a8..ad4f0fb98 100644 --- a/knewstuff/knewstuff.cpp +++ b/knewstuff/knewstuff.cpp @@ -39,48 +39,48 @@ TDEAction* KNS::standardAction(const TQString& what, 0, recvr, slot, parent, name); } -KNewStuff::KNewStuff( const TQString &type, TQWidget *parentWidget ) +TDENewStuff::TDENewStuff( const TQString &type, TQWidget *parentWidget ) { mEngine = new Engine( this, type, parentWidget ); } -KNewStuff::KNewStuff( const TQString &type, const TQString &providerList, TQWidget *parentWidget ) +TDENewStuff::TDENewStuff( const TQString &type, const TQString &providerList, TQWidget *parentWidget ) { mEngine = new Engine( this, type, providerList, parentWidget ); } -TQString KNewStuff::type() const +TQString TDENewStuff::type() const { return mEngine->type(); } -TQWidget *KNewStuff::parentWidget() const +TQWidget *TDENewStuff::parentWidget() const { return mEngine->parentWidget(); } -KNewStuff::~KNewStuff() +TDENewStuff::~TDENewStuff() { delete mEngine; } -void KNewStuff::download() +void TDENewStuff::download() { mEngine->download(); } -TQString KNewStuff::downloadDestination( Entry * ) +TQString TDENewStuff::downloadDestination( Entry * ) { return TDEGlobal::dirs()->saveLocation( "tmp" ) + TDEApplication::randomString( 10 ); } -void KNewStuff::upload() +void TDENewStuff::upload() { mEngine->upload(); } -void KNewStuff::upload( const TQString &fileName, const TQString previewName ) +void TDENewStuff::upload( const TQString &fileName, const TQString previewName ) { mEngine->upload(fileName, previewName); } diff --git a/knewstuff/knewstuff.h b/knewstuff/knewstuff.h index ca07c7f0d..55d6db9b4 100644 --- a/knewstuff/knewstuff.h +++ b/knewstuff/knewstuff.h @@ -43,7 +43,7 @@ KDE_EXPORT TDEAction* standardAction(const TQString& what, /** * @short This class provides the functionality to download and upload "new stuff". * - * Applications have to subclass KNewStuff, implement the pure virtual functions + * Applications have to subclass TDENewStuff, implement the pure virtual functions * and link to against libknewstuff. * * By calling download() the download process is started which means that a list @@ -66,7 +66,7 @@ KDE_EXPORT TDEAction* standardAction(const TQString& what, * * @since 3.3 */ -class KDE_EXPORT KNewStuff +class KDE_EXPORT TDENewStuff { public: /** @@ -74,10 +74,10 @@ class KDE_EXPORT KNewStuff @param type type of data to be handled, should be something like korganizer/calendar, kword/template, kdesktop/wallpaper - @param parentWidget parent widget of dialogs opened by the KNewStuff + @param parentWidget parent widget of dialogs opened by the TDENewStuff engine */ - KNewStuff( const TQString &type, TQWidget *parentWidget = 0 ); + TDENewStuff( const TQString &type, TQWidget *parentWidget = 0 ); /** Constructor. @@ -85,11 +85,11 @@ class KDE_EXPORT KNewStuff @param type type of data to be handled, should be something like korganizer/calendar, kword/template, kdesktop/wallpaper @param providerList the URL of the provider list - @param parentWidget parent widget of dialogs opened by the KNewStuff + @param parentWidget parent widget of dialogs opened by the TDENewStuff engine */ - KNewStuff( const TQString &type, const TQString &providerList, TQWidget *parentWidget = 0 ); - virtual ~KNewStuff(); + TDENewStuff( const TQString &type, const TQString &providerList, TQWidget *parentWidget = 0 ); + virtual ~TDENewStuff(); /** Return type of data. @@ -118,7 +118,7 @@ class KDE_EXPORT KNewStuff /** Install file to application. The given fileName points to the file - downloaded by the KNewStuff engine. This is a temporary file by default. + downloaded by the TDENewStuff engine. This is a temporary file by default. The application can do whatever is needed to handle the information contained in the file. diff --git a/knewstuff/knewstuffbutton.h b/knewstuff/knewstuffbutton.h index bebd08297..e4a98ae3a 100644 --- a/knewstuff/knewstuffbutton.h +++ b/knewstuff/knewstuffbutton.h @@ -28,9 +28,9 @@ namespace KNS class DownloadDialog; /** - * KHotNewStuff push button that makes using KHNS in an application + * TDEHotNewStuff push button that makes using KHNS in an application * more convenient by encapsulating most of the details involved in - * using KHotNewStuff in the button itself. + * using TDEHotNewStuff in the button itself. * * @since 3.4 */ @@ -40,7 +40,7 @@ class Button : public KPushButton public: /** - * Constructor used when the details of the KHotNewStuff + * Constructor used when the details of the TDEHotNewStuff * download is known when the button is created. * * @param what text describing what is being downloaded. will be @@ -59,7 +59,7 @@ class Button : public KPushButton TQWidget* parent, const char* name); /** - * Constructor used when the details of the KHotNewStuff + * Constructor used when the details of the TDEHotNewStuff * download is not known in advance of the button being created. * * @param parent the parent widget diff --git a/knewstuff/knewstuffgeneric.cpp b/knewstuff/knewstuffgeneric.cpp index ef6a37456..16fda977c 100644 --- a/knewstuff/knewstuffgeneric.cpp +++ b/knewstuff/knewstuffgeneric.cpp @@ -37,22 +37,22 @@ using namespace std; -KNewStuffGeneric::KNewStuffGeneric( const TQString &type, TQWidget *parent ) - : KNewStuff( type, parent ) +TDENewStuffGeneric::TDENewStuffGeneric( const TQString &type, TQWidget *parent ) + : TDENewStuff( type, parent ) { mConfig = TDEGlobal::config(); } -KNewStuffGeneric::~KNewStuffGeneric() +TDENewStuffGeneric::~TDENewStuffGeneric() { } -bool KNewStuffGeneric::install( const TQString &fileName ) +bool TDENewStuffGeneric::install( const TQString &fileName ) { - kdDebug() << "KNewStuffGeneric::install(): " << fileName << endl; + kdDebug() << "TDENewStuffGeneric::install(): " << fileName << endl; TQStringList list, list2; - mConfig->setGroup("KNewStuff"); + mConfig->setGroup("TDENewStuff"); TQString uncompress = mConfig->readEntry( "Uncompress" ); if ( !uncompress.isEmpty() ) { @@ -80,16 +80,16 @@ bool KNewStuffGeneric::install( const TQString &fileName ) return true; } -bool KNewStuffGeneric::createUploadFile( const TQString & /*fileName*/ ) +bool TDENewStuffGeneric::createUploadFile( const TQString & /*fileName*/ ) { return false; } -TQString KNewStuffGeneric::destinationPath( KNS::Entry *entry ) +TQString TDENewStuffGeneric::destinationPath( KNS::Entry *entry ) { TQString path, file, target, ext; - mConfig->setGroup("KNewStuff"); + mConfig->setGroup("TDENewStuff"); if ( entry ) { @@ -117,7 +117,7 @@ TQString KNewStuffGeneric::destinationPath( KNS::Entry *entry ) if ( res.isEmpty() && path.isEmpty() ) { if ( !entry ) return TQString::null; - else return KNewStuff::downloadDestination( entry ); + else return TDENewStuff::downloadDestination( entry ); } if ( !path.isEmpty() ) @@ -130,7 +130,7 @@ TQString KNewStuffGeneric::destinationPath( KNS::Entry *entry ) return file; } -TQString KNewStuffGeneric::downloadDestination( KNS::Entry *entry ) +TQString TDENewStuffGeneric::downloadDestination( KNS::Entry *entry ) { TQString file = destinationPath(entry); diff --git a/knewstuff/knewstuffgeneric.h b/knewstuff/knewstuffgeneric.h index 053f83a05..36feb1a77 100644 --- a/knewstuff/knewstuffgeneric.h +++ b/knewstuff/knewstuffgeneric.h @@ -26,12 +26,12 @@ class TDEConfig; /** - * @short Basic KNewStuff class with predefined actions. + * @short Basic TDENewStuff class with predefined actions. * * This class is used for data uploads and installation. * \code * TQString payload, preview; - * KNewStuffGeneric *ns = new KNewStuffGeneric("kamikaze/level", this); + * TDENewStuffGeneric *ns = new TDENewStuffGeneric("kamikaze/level", this); * ns->upload(payload, preview); * \endcode * @@ -39,7 +39,7 @@ class TDEConfig; * \par Maintainer: * Josef Spillner (spillner@kde.org) */ -class KDE_EXPORT KNewStuffGeneric : public KNewStuff +class KDE_EXPORT TDENewStuffGeneric : public TDENewStuff { public: /** @@ -48,8 +48,8 @@ class KDE_EXPORT KNewStuffGeneric : public KNewStuff @param type a Hotstuff data type such as "korganizer/calendar" @param parent the parent window. */ - KNewStuffGeneric( const TQString &type, TQWidget *parent = 0 ); - ~KNewStuffGeneric(); + TDENewStuffGeneric( const TQString &type, TQWidget *parent = 0 ); + ~TDENewStuffGeneric(); /** Installs a downloaded file according to the application's configuration. @@ -61,7 +61,7 @@ class KDE_EXPORT KNewStuffGeneric : public KNewStuff /** Creates a file suitable for upload. - Note that this method always fails, since using KNewStuffGeneric + Note that this method always fails, since using TDENewStuffGeneric means that the provided file must already be in a usable format. @param fileName the name of the file to upload after its creation diff --git a/knewstuff/knewstuffsecure.cpp b/knewstuff/knewstuffsecure.cpp index 67374800e..0f95c8c0c 100644 --- a/knewstuff/knewstuffsecure.cpp +++ b/knewstuff/knewstuffsecure.cpp @@ -33,20 +33,20 @@ using namespace KNS; -KNewStuffSecure::KNewStuffSecure(const TQString &type, TQWidget *parentWidget) - : KNewStuff(type, parentWidget) +TDENewStuffSecure::TDENewStuffSecure(const TQString &type, TQWidget *parentWidget) + : TDENewStuff(type, parentWidget) { m_tempDir = 0L; connect(engine(), TQT_SIGNAL(uploadFinished(bool)), TQT_SLOT(slotUploadFinished(bool))); } -KNewStuffSecure::~KNewStuffSecure() +TDENewStuffSecure::~TDENewStuffSecure() { removeTempDirectory(); } -bool KNewStuffSecure::install(const TQString &fileName) +bool TDENewStuffSecure::install(const TQString &fileName) { bool ok = true; @@ -84,7 +84,7 @@ bool KNewStuffSecure::install(const TQString &fileName) return ok; } -void KNewStuffSecure::slotValidated(int result) +void TDENewStuffSecure::slotValidated(int result) { TQString errorString; TQString signatureStr; @@ -145,8 +145,8 @@ void KNewStuffSecure::slotValidated(int result) } else { TDEConfig *cfg = TDEGlobal::config(); - cfg->deleteGroup("KNewStuffStatus"); - cfg->setGroup("KNewStuffStatus"); + cfg->deleteGroup("TDENewStuffStatus"); + cfg->setGroup("TDENewStuffStatus"); for (TQMap<TQString, TQString>::ConstIterator it = m_installedResources.constBegin(); it != m_installedResources.constEnd(); ++it) { cfg->writeEntry(it.key(), it.data()); @@ -157,21 +157,21 @@ void KNewStuffSecure::slotValidated(int result) disconnect(Security::ref(), TQT_SIGNAL(validityResult(int)), this, TQT_SLOT(slotValidated(int))); } -void KNewStuffSecure::downloadResource() +void TDENewStuffSecure::downloadResource() { TDEConfig *cfg = TDEGlobal::config(); - m_installedResources = cfg->entryMap("KNewStuffStatus"); + m_installedResources = cfg->entryMap("TDENewStuffStatus"); engine()->ignoreInstallResult(true); - KNewStuff::download(); + TDENewStuff::download(); } -bool KNewStuffSecure::createUploadFile(const TQString &fileName) +bool TDENewStuffSecure::createUploadFile(const TQString &fileName) { Q_UNUSED(fileName); return true; } -void KNewStuffSecure::uploadResource(const TQString& fileName) +void TDENewStuffSecure::uploadResource(const TQString& fileName) { connect(Security::ref(), TQT_SIGNAL(fileSigned(int)), this, TQT_SLOT(slotFileSigned(int))); removeTempDirectory(); @@ -183,7 +183,7 @@ void KNewStuffSecure::uploadResource(const TQString& fileName) Security::ref()->signFile(m_signedFileName); } -void KNewStuffSecure::slotFileSigned(int result) +void TDENewStuffSecure::slotFileSigned(int result) { if (result == 0) { @@ -216,18 +216,18 @@ void KNewStuffSecure::slotFileSigned(int result) } tar.close(); TDEIO::NetAccess::file_move(KURL::fromPathOrURL(m_signedFileName + ".signed"), KURL::fromPathOrURL(m_signedFileName), -1, true); - KNewStuff::upload(m_signedFileName, TQString::null); + TDENewStuff::upload(m_signedFileName, TQString::null); disconnect(Security::ref(), TQT_SIGNAL(fileSigned(int)), this, TQT_SLOT(slotFileSigned(int))); } } -void KNewStuffSecure::slotUploadFinished(bool result) +void TDENewStuffSecure::slotUploadFinished(bool result) { Q_UNUSED(result); removeTempDirectory(); } -void KNewStuffSecure::removeTempDirectory() +void TDENewStuffSecure::removeTempDirectory() { if (m_tempDir) { diff --git a/knewstuff/knewstuffsecure.h b/knewstuff/knewstuffsecure.h index 1a6bc44a1..1c292a9a8 100644 --- a/knewstuff/knewstuffsecure.h +++ b/knewstuff/knewstuffsecure.h @@ -31,13 +31,13 @@ tarball (which is installabale by @ref installResource()) and call the @ref uploadResource() method with this tarball as the argument. Signing and verification is done by the gpg application, so the user must have it installed, otherwise this class does not give any extra security compared -to the standard KNewStuff class. +to the standard TDENewStuff class. @since 3.4 @author Andras Mantia <amantia@kde.org> */ -class KDE_EXPORT KNewStuffSecure : public TQObject, public KNewStuff +class KDE_EXPORT TDENewStuffSecure : public TQObject, public TDENewStuff { Q_OBJECT @@ -46,14 +46,14 @@ public: @param type type of data to be handled, should be something like korganizer/calendar, kword/template, kdesktop/wallpaper - @param parentWidget parent widget of dialogs opened by the KNewStuff + @param parentWidget parent widget of dialogs opened by the TDENewStuff engine */ - KNewStuffSecure(const TQString &type, TQWidget *parentWidget=0); - virtual ~KNewStuffSecure(); + TDENewStuffSecure(const TQString &type, TQWidget *parentWidget=0); + virtual ~TDENewStuffSecure(); /** Installs the downloaded resource. Do not call or reimplement directly. - It's reimplemented from KNewStuff for internal reasons. + It's reimplemented from TDENewStuff for internal reasons. */ bool install( const TQString &fileName ); diff --git a/knewstuff/provider.cpp b/knewstuff/provider.cpp index 20f1668f7..029a07caf 100644 --- a/knewstuff/provider.cpp +++ b/knewstuff/provider.cpp @@ -1,6 +1,7 @@ /* This file is part of KOrganizer. Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> + Copyright (c) 2014 Timothy Pearson <kb9vqf@pearsoncomputing.net> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -76,11 +77,11 @@ KURL Provider::downloadUrlVariant( TQString variant ) const // BCI part ends here -Provider::Provider() : mNoUpload( false ) +Provider::Provider( TQString type, TQWidget* parent ) : mNoUpload( false ), mParent( parent ), mLoaded( false ), mContentType( type ) { } -Provider::Provider( const TQDomElement &e ) : mNoUpload( false ) +Provider::Provider( const TQDomElement &e, TQString type, TQWidget* parent ) : mNoUpload( false ), mParent( parent ), mLoaded( false ), mContentType( type ) { parseDomElement( e ); } @@ -101,6 +102,10 @@ Provider::~Provider() } } +bool Provider::loaded() +{ + return mLoaded; +} void Provider::setName( const TQString &name ) { @@ -167,29 +172,51 @@ bool Provider::noUpload() const return mNoUpload; } - void Provider::parseDomElement( const TQDomElement &element ) { - if ( element.tagName() != "provider" ) return; - - setDownloadUrl( KURL( element.attribute("downloadurl") ) ); - setUploadUrl( KURL( element.attribute("uploadurl") ) ); - setNoUploadUrl( KURL( element.attribute("nouploadurl") ) ); + bool contentAvailable = false; - d_prov(this)->mDownloadUrlLatest = KURL( element.attribute("downloadurl-latest") ); - d_prov(this)->mDownloadUrlScore = KURL( element.attribute("downloadurl-score") ); - d_prov(this)->mDownloadUrlDownloads = KURL( element.attribute("downloadurl-downloads") ); - - KURL iconurl( element.attribute("icon") ); - if(!iconurl.isValid()) iconurl.setPath( element.attribute("icon") ); - setIcon( iconurl ); + if ( element.tagName() != "provider" ) return; TQDomNode n; for ( n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) { TQDomElement p = n.toElement(); - + + if ( p.tagName() == "location" ) mBaseURL = p.text(); + if ( p.tagName() == "icon" ) { + KURL iconurl( p.text() ); + if(!iconurl.isValid()) iconurl.setPath( p.text() ); + setIcon( iconurl ); + } + if ( p.tagName() == "noupload" ) setNoUpload( true ); - if ( p.tagName() == "title" ) setName( p.text().stripWhiteSpace() ); + if ( p.tagName() == "name" ) setName( p.text().stripWhiteSpace() ); + + if ( p.tagName() == "services" ) { + TQDomNode n2; + for ( n2 = p.firstChild(); !n2.isNull(); n2 = n2.nextSibling() ) { + TQDomElement p = n2.toElement(); + + if ( p.tagName() == "content" ) contentAvailable = true; + } + } + } + + if (!mBaseURL.endsWith("/")) { + mBaseURL.append("/"); + } + + if (contentAvailable) { + // Load content type list + KURL contentTypeUrl( mBaseURL + "content/categories" ); + + kdDebug() << "Provider::parseDomElement(): contentTypeUrl: " << contentTypeUrl << endl; + + TDEIO::TransferJob *job = TDEIO::get( KURL( contentTypeUrl ), 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 & ) ) ); } } @@ -205,6 +232,101 @@ TQDomElement Provider::createDomElement( TQDomDocument &doc, TQDomElement &paren return entry; } +void Provider::slotJobData( TDEIO::Job *, const TQByteArray &data ) +{ + kdDebug() << "ProviderLoader::slotJobData()" << endl; + + if ( data.size() == 0 ) return; + + TQCString str( data, data.size() + 1 ); + + mJobData.append( TQString::fromUtf8( str ) ); +} + +void Provider::slotJobResult( TDEIO::Job *job ) +{ + if ( job->error() ) { + if (mParent) { + job->showErrorDialog( mParent ); + } + return; + } + + kdDebug() << "--CONTENT-START--" << endl << mJobData << "--CONT_END--" + << endl; + + TQDomDocument doc; + if ( !doc.setContent( mJobData ) ) { + if (mParent) { + KMessageBox::error( mParent, i18n("Error parsing category list.") ); + } + return; + } + + TQDomElement categories = doc.documentElement(); + + if ( categories.isNull() ) { + kdDebug() << "No document in Content.xml." << endl; + } + + TQStringList desiredCategoryList; + TQString desiredCategories; + + TQDomNode n; + for ( n = categories.firstChild(); !n.isNull(); n = n.nextSibling() ) { + TQDomElement p = n.toElement(); + + if ( p.tagName() == "data" ) { + TQDomNode n2; + for ( n2 = p.firstChild(); !n2.isNull(); n2 = n2.nextSibling() ) { + TQDomElement p = n2.toElement(); + + if ( p.tagName() == "category" ) { + TQDomNode n3; + TQString id; + TQString name; + for ( n3 = p.firstChild(); !n3.isNull(); n3 = n3.nextSibling() ) { + TQDomElement p = n3.toElement(); + + if ( p.tagName() == "id" ) { + id = p.text(); + } + + if ( p.tagName() == "name" ) { + name = p.text(); + } + } + + if (mContentType == "") { + desiredCategoryList.append(id); + } + else { + if (name.lower().contains(mContentType.lower())) { + desiredCategoryList.append(id); + } + } + } + } + } + } + + desiredCategories = desiredCategoryList.join("x"); + + // int maxEntries = 10; + int maxEntries = 50; + + setDownloadUrl( KURL( mBaseURL ) ); + setUploadUrl( KURL( mBaseURL ) ); + setNoUploadUrl( KURL( mBaseURL ) ); + + d_prov(this)->mDownloadUrlLatest = KURL( mBaseURL + "content/data?categories=" + desiredCategories + "&search=&sortmode=new&page=1&pagesize=" + TQString("%1").arg(maxEntries) ); + d_prov(this)->mDownloadUrlScore = KURL( mBaseURL + "content/data?categories=" + desiredCategories + "&search=&sortmode=high&page=1&pagesize=" + TQString("%1").arg(maxEntries) ); + d_prov(this)->mDownloadUrlDownloads = KURL( mBaseURL + "content/data?categories=" + desiredCategories + "&search=&sortmode=down&page=1&pagesize=" + TQString("%1").arg(maxEntries) ); + + mLoaded = true; + emit providerLoaded(); +} + ProviderLoader::ProviderLoader( TQWidget *parentWidget ) : TQObject( parentWidget ) @@ -218,9 +340,10 @@ void ProviderLoader::load( const TQString &type, const TQString &providersList ) mProviders.clear(); mJobData = ""; + mContentType = type; TDEConfig *cfg = TDEGlobal::config(); - cfg->setGroup("KNewStuff"); + cfg->setGroup("TDENewStuff"); TQString providersUrl = providersList; if( providersUrl.isEmpty() ) @@ -282,9 +405,24 @@ void ProviderLoader::slotJobResult( TDEIO::Job *job ) TQDomElement p = n.toElement(); if ( p.tagName() == "provider" ) { - mProviders.append( new Provider( p ) ); + Provider* prov = new Provider( p, mContentType, TQT_TQWIDGET(parent()) ); + mProviders.append( prov ); + connect( prov, TQT_SIGNAL( providerLoaded() ), this, TQT_SLOT( providerLoaded() ) ); } } - - emit providersLoaded( &mProviders ); } + +void ProviderLoader::providerLoaded() { + Provider* prov = NULL; + bool allLoaded = true; + for ( prov = mProviders.first(); prov; prov = mProviders.next() ) { + if (!prov->loaded()) { + allLoaded = false; + break; + } + } + + if (allLoaded) { + emit providersLoaded( &mProviders ); + } +}
\ No newline at end of file diff --git a/knewstuff/provider.h b/knewstuff/provider.h index 2a0d54a12..130864158 100644 --- a/knewstuff/provider.h +++ b/knewstuff/provider.h @@ -1,6 +1,7 @@ /* This file is part of KOrganizer. Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> + Copyright (c) 2014 Timothy Pearson <kb9vqf@pearsoncomputing.net> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -33,35 +34,41 @@ namespace TDEIO { class Job; } namespace KNS { /** - * @short KNewStuff provider container. + * @short TDENewStuff provider container. * * This class provides accessors for the provider object. - * as used by KNewStuff. + * as used by TDENewStuff. * It should probably not be used directly by the application. * * @author Cornelius Schumacher (schumacher@kde.org) * \par Maintainer: * Josef Spillner (spillner@kde.org) */ -class KDE_EXPORT Provider +class KDE_EXPORT Provider : public TQObject { + Q_OBJECT public: typedef TQPtrList<Provider> List; /** * Constructor. */ - Provider(); + Provider( TQString type = TQString::null, TQWidget* parent = 0 ); /** * Constructor with XML feed. */ - Provider( const TQDomElement & ); + Provider( const TQDomElement &, TQString type = TQString::null, TQWidget* parent = 0 ); /** * Destructor. */ - ~Provider(); + virtual ~Provider(); + + /** + * @return provider load status + */ + bool loaded(); /** * Sets the common name of the provider. @@ -154,6 +161,13 @@ class KDE_EXPORT Provider TQDomElement createDomElement( TQDomDocument &, TQDomElement &parent ); + protected slots: + void slotJobData( TDEIO::Job *, const TQByteArray & ); + void slotJobResult( TDEIO::Job * ); + + signals: + void providerLoaded(); + private: TQString mName; KURL mDownloadUrl; @@ -161,10 +175,15 @@ class KDE_EXPORT Provider KURL mNoUploadUrl; KURL mIcon; bool mNoUpload; + TQString mJobData; + TQString mBaseURL; + TQWidget* mParent; + bool mLoaded; + TQString mContentType; }; /** - * KNewStuff provider loader. + * TDENewStuff provider loader. * This class sets up a list of all possible providers by querying * the main provider database for this specific application. * It should probably not be used directly by the application. @@ -200,11 +219,13 @@ class KDE_EXPORT ProviderLoader : public TQObject protected slots: void slotJobData( TDEIO::Job *, const TQByteArray & ); void slotJobResult( TDEIO::Job * ); + void providerLoaded(); private: TQWidget *mParentWidget; TQString mJobData; + TQString mContentType; Provider::List mProviders; }; diff --git a/knewstuff/providerdialog.h b/knewstuff/providerdialog.h index 549a65416..fe7652f14 100644 --- a/knewstuff/providerdialog.h +++ b/knewstuff/providerdialog.h @@ -47,7 +47,7 @@ class ProviderDialog : public KDialogBase /** Constructor. - @param engine a KNewStuff engine object + @param engine a TDENewStuff engine object @param parent the parent window */ ProviderDialog( Engine *engine, TQWidget *parent ); diff --git a/knewstuff/tdehotnewstuff.cpp b/knewstuff/tdehotnewstuff.cpp index fb9e92a9b..7f4135b84 100644 --- a/knewstuff/tdehotnewstuff.cpp +++ b/knewstuff/tdehotnewstuff.cpp @@ -35,7 +35,7 @@ static const TDECmdLineOptions op[] = int main(int argc, char **argv) { - TDEAboutData about("tdehotnewstuff", "KHotNewStuff", "0.2"); + TDEAboutData about("tdehotnewstuff", "TDEHotNewStuff", "0.2"); TDECmdLineArgs *args; TDECmdLineArgs::init(argc, argv, &about); diff --git a/knewstuff/tdehotnewstuffrc b/knewstuff/tdehotnewstuffrc index 737ad61c2..546ebb053 100644 --- a/knewstuff/tdehotnewstuffrc +++ b/knewstuff/tdehotnewstuffrc @@ -1,3 +1,3 @@ -[KNewStuff] -ProvidersUrl=http://www.kstuff.org/hotstuff/providers/index.xml +[TDENewStuff] +ProvidersUrl=https://www.trinitydesktop.org/ocs/providers.xml diff --git a/knewstuff/testnewstuff.cpp b/knewstuff/testnewstuff.cpp index 3494c5230..f9fc7269f 100644 --- a/knewstuff/testnewstuff.cpp +++ b/knewstuff/testnewstuff.cpp @@ -107,7 +107,7 @@ void MyWidget::upload() int main(int argc,char **argv) { - TDEAboutData aboutData("knewstufftest","KNewStuff Test","0.1"); + TDEAboutData aboutData("knewstufftest","TDENewStuff Test","0.1"); TDECmdLineArgs::init(argc,argv,&aboutData); TDEApplication app; diff --git a/knewstuff/testnewstuff.h b/knewstuff/testnewstuff.h index a7bc5710f..acd9aece4 100644 --- a/knewstuff/testnewstuff.h +++ b/knewstuff/testnewstuff.h @@ -30,10 +30,10 @@ #include "knewstuff.h" -class TestNewStuff : public KNewStuff +class TestNewStuff : public TDENewStuff { public: - TestNewStuff() : KNewStuff( "korganizer/calendar" ) {} + TestNewStuff() : TDENewStuff( "korganizer/calendar" ) {} bool install( const TQString &fileName ); @@ -52,7 +52,7 @@ class MyWidget : public TQWidget void download(); private: - KNewStuff *mNewStuff; + TDENewStuff *mNewStuff; }; #endif diff --git a/knewstuff/uploaddialog.cpp b/knewstuff/uploaddialog.cpp index f4b3dd50e..a8e13a493 100644 --- a/knewstuff/uploaddialog.cpp +++ b/knewstuff/uploaddialog.cpp @@ -137,7 +137,7 @@ void UploadDialog::slotOk() if ( mPayloadUrl.isValid() ) { TDEConfig *conf = kapp->config(); - conf->setGroup( TQString("KNewStuffUpload:%1").arg(mPayloadUrl.fileName()) ); + conf->setGroup( TQString("TDENewStuffUpload:%1").arg(mPayloadUrl.fileName()) ); conf->writeEntry("name", mNameEdit->text()); conf->writeEntry("author", mAuthorEdit->text()); conf->writeEntry("email", mEmailEdit->text()); @@ -165,7 +165,7 @@ void UploadDialog::setPayloadFile( const TQString &payloadFile ) mPayloadUrl = payloadFile; TDEConfig *conf = kapp->config(); - conf->setGroup( TQString("KNewStuffUpload:%1").arg(mPayloadUrl.fileName()) ); + conf->setGroup( TQString("TDENewStuffUpload:%1").arg(mPayloadUrl.fileName()) ); TQString name = conf->readEntry("name"); TQString author = conf->readEntry("author"); TQString email = conf->readEntry("email"); diff --git a/knewstuff/uploaddialog.h b/knewstuff/uploaddialog.h index 3847cb14b..3fc068e3a 100644 --- a/knewstuff/uploaddialog.h +++ b/knewstuff/uploaddialog.h @@ -34,11 +34,11 @@ class Engine; class Entry; /** - * @short KNewStuff file upload dialog. + * @short TDENewStuff file upload dialog. * * Using this dialog, data can easily be uploaded to the Hotstuff servers. - * It should however not be used on its own, instead a KNewStuff (or - * KNewStuffGeneric) object invokes it. + * It should however not be used on its own, instead a TDENewStuff (or + * TDENewStuffGeneric) object invokes it. * * @author Cornelius Schumacher (schumacher@kde.org) * \par Maintainer: @@ -51,7 +51,7 @@ class UploadDialog : public KDialogBase /** Constructor. - @param engine a KNewStuff engine object to be used for uploads + @param engine a TDENewStuff engine object to be used for uploads @param parent the parent window */ UploadDialog( Engine *engine, TQWidget *parent ); |