Rework the KHNS system to properly download data from the new OCS network

This relates to Bug 2093
pull/16/head
Timothy Pearson 10 years ago
parent 20e7ea1336
commit 47ac409621

@ -1,6 +1,6 @@
/** \mainpage Collaborative Data Sharing in Trinity Applications /** \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 applications. Technically, it implements the
<a href="http://ghns.freedesktop.org/">GHNS</a> and <a href="http://ghns.freedesktop.org/">GHNS</a> and
DXS specifications. The library consists of three parts: the data management core 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. classes like dialogs and buttons.
Application authors should not use all of the classes directly, which are installed 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. 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 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, 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 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 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 @authors
Josef Spillner \<spillner@kde.org\> Josef Spillner \<spillner@kde.org\>
@ -31,5 +31,5 @@ Jeremy Whiting \<jeremy@scitools.com\>
*/ */
// DOXYGEN_REFERENCES = tdecore tdeui tdeio // DOXYGEN_REFERENCES = tdecore tdeui tdeio
// DOXYGEN_SET_PROJECT_NAME = KNewStuff // DOXYGEN_SET_PROJECT_NAME = TDENewStuff
// vim:ts=4:sw=4:expandtab:filetype=doxygen // vim:ts=4:sw=4:expandtab:filetype=doxygen

@ -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, provides KDE applications with easy-to-use upload and download mechanisms,
with optional popularity counters, ratings, digital signatures, uncompression with optional popularity counters, ratings, digital signatures, uncompression
and post-installation DCOP/scripting hooks. and post-installation DCOP/scripting hooks.
@ -11,14 +11,14 @@ and post-installation DCOP/scripting hooks.
* Documentation * Documentation
- API docs - API docs
http://developer.kde.org/documentation/library/cvs-api/knewstuff/html/ http://developer.kde.org/documentation/library/cvs-api/knewstuff/html/
- KNewStuff tutorial - TDENewStuff tutorial
http://www.kstuff.org/docs/tutorial/ http://www.kstuff.org/docs/tutorial/
- KNewStuffSecure tutorial - TDENewStuffSecure tutorial
http://developer.kde.org/documentation/tutorials/knewstuffsecure/ http://developer.kde.org/documentation/tutorials/knewstuffsecure/
* Repositories * Repositories
Currently, about 7 repositories exist for a variety of KDE applications using 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: Please have a look at the repository browser:
-> http://www.kstuff.org/hotstuff/index.php?p=browser -> http://www.kstuff.org/hotstuff/index.php?p=browser
If you want automatic upload processing, download counting and administration If you want automatic upload processing, download counting and administration

@ -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".

@ -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)>

@ -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>

@ -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)>

@ -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>

@ -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) 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 This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public modify it under the terms of the GNU Library General Public
@ -44,6 +45,8 @@
#include <tqtabwidget.h> #include <tqtabwidget.h>
#include <tqtimer.h> // hack #include <tqtimer.h> // hack
#define OPENDESKTOP_REDIRECT_URL "opendesktop.org/content/download.php?content="
using namespace KNS; using namespace KNS;
struct DownloadDialog::Private struct DownloadDialog::Private
@ -217,7 +220,6 @@ void DownloadDialog::addProvider(Provider *p)
TQFrame *frame; TQFrame *frame;
TQTabWidget *ctl; TQTabWidget *ctl;
TQWidget *w_d, *w_r, *w_l; TQWidget *w_d, *w_r, *w_l;
TQWidget *w2;
TQTextBrowser *rt; TQTextBrowser *rt;
TQString tmp; TQString tmp;
int ret; int ret;
@ -250,7 +252,6 @@ void DownloadDialog::addProvider(Provider *p)
frame = addPage(p->name(), p->name(), pix); frame = addPage(p->name(), p->name(), pix);
m_frame = frame; m_frame = frame;
w2 = new TQWidget(frame);
w_d = new TQWidget(frame); w_d = new TQWidget(frame);
w_r = new TQWidget(frame); w_r = new TQWidget(frame);
w_l = new TQWidget(frame); w_l = new TQWidget(frame);
@ -335,10 +336,11 @@ void DownloadDialog::slotResult(TDEIO::Job *job)
{ {
TQDomDocument dom; TQDomDocument dom;
TQDomElement knewstuff; TQDomElement knewstuff;
TQDomElement content;
kdDebug() << "got data: " << m_data[job] << endl; kdDebug() << "got data: " << m_data[job] << endl;
kapp->config()->setGroup("KNewStuffStatus"); kapp->config()->setGroup("TDENewStuffStatus");
dom.setContent(m_data[job]); dom.setContent(m_data[job]);
knewstuff = dom.documentElement(); knewstuff = dom.documentElement();
@ -347,9 +349,19 @@ void DownloadDialog::slotResult(TDEIO::Job *job)
{ {
TQDomElement stuff = pn.toElement(); 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; kdDebug() << "element: " << stuff.tagName() << endl;
if(stuff.tagName() == "stuff") if(stuff.tagName() == "content")
{ {
Entry *entry = new Entry(stuff); Entry *entry = new Entry(stuff);
kdDebug() << "TYPE::" << entry->type() << " FILTER::" << m_filter << endl; kdDebug() << "TYPE::" << entry->type() << " FILTER::" << m_filter << endl;
@ -394,7 +406,7 @@ int DownloadDialog::installStatus(Entry *entry)
TQString lang = TDEGlobal::locale()->language(); TQString lang = TDEGlobal::locale()->language();
kapp->config()->setGroup("KNewStuffStatus"); kapp->config()->setGroup("TDENewStuffStatus");
datestring = kapp->config()->readEntry(entry->name(lang)); datestring = kapp->config()->readEntry(entry->name(lang));
if(datestring.isNull()) installed = 0; if(datestring.isNull()) installed = 0;
else else
@ -522,10 +534,39 @@ void DownloadDialog::slotInstall()
d->m_lvtmp_r->setEnabled( false ); d->m_lvtmp_r->setEnabled( false );
d->m_lvtmp_l->setEnabled( false ); d->m_lvtmp_l->setEnabled( false );
d->m_lvtmp_d->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_entryitem = currentEntryItem();
m_entryname = m_entryitem->text(0); m_entryname = m_entryitem->text(0);
kdDebug() << "download entry now" << endl; kdDebug() << "download entry now (phase 2)" << endl;
if(m_engine) if(m_engine)
{ {
@ -534,7 +575,7 @@ void DownloadDialog::slotInstall()
} }
else else
{ {
m_s = new KNewStuffGeneric(e->type(), this); m_s = new TDENewStuffGeneric(e->type(), this);
m_entry = e; m_entry = e;
KURL source = e->payload(); KURL source = e->payload();
KURL dest = KURL(m_s->downloadDestination(e)); 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) 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()->writeEntry(m_entryname, TQString(e->releaseDate().toString(Qt::ISODate)));
kapp->config()->sync(); kapp->config()->sync();

@ -1,5 +1,5 @@
/* /*
This file is part of KNewStuff. This file is part of TDENewStuff.
Copyright (c) 2003 Josef Spillner <spillner@kde.org> Copyright (c) 2003 Josef Spillner <spillner@kde.org>
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
@ -31,7 +31,7 @@ namespace TDEIO
class TDEListView; class TDEListView;
class TQTextBrowser; class TQTextBrowser;
class TQFrame; class TQFrame;
class KNewStuffGeneric; class TDENewStuffGeneric;
namespace KNS namespace KNS
{ {
@ -47,7 +47,7 @@ class Engine;
* It provides an easy-to-use convenience method named open() which does all * It provides an easy-to-use convenience method named open() which does all
* the work, unless a more complex operation is needed. * the work, unless a more complex operation is needed.
* \code * \code
* KNewStuff::DownloadDialog::open("kdesktop/wallpapers"); * TDENewStuff::DownloadDialog::open("kdesktop/wallpapers");
* \endcode * \endcode
* *
* @author Josef Spillner (spillner@kde.org) * @author Josef Spillner (spillner@kde.org)
@ -213,7 +213,10 @@ class KDE_EXPORT DownloadDialog : public KDialogBase
private slots: private slots:
void slotResult(TDEIO::Job *job); void slotResult(TDEIO::Job *job);
void slotData(TDEIO::Job *job, const TQByteArray &a); void slotData(TDEIO::Job *job, const TQByteArray &a);
void slotJobData( TDEIO::Job *, const TQByteArray & );
void slotJobResult( TDEIO::Job * );
void slotInstall(); void slotInstall();
void slotInstallPhase2();
void slotDetails(); void slotDetails();
void slotInstalled(TDEIO::Job *job); void slotInstalled(TDEIO::Job *job);
void slotTab(); void slotTab();
@ -238,7 +241,7 @@ class KDE_EXPORT DownloadDialog : public KDialogBase
TQListViewItem *m_entryitem; TQListViewItem *m_entryitem;
TQPtrList<Entry> m_entries; TQPtrList<Entry> m_entries;
Entry *m_entry; Entry *m_entry;
KNewStuffGeneric *m_s; TDENewStuffGeneric *m_s;
int m_curtab; int m_curtab;
TQMap<TQWidget*, TQValueList<TDEListView*>* > m_map; TQMap<TQWidget*, TQValueList<TDEListView*>* > m_map;
TQMap<TQWidget*, Provider*> m_providers; TQMap<TQWidget*, Provider*> m_providers;
@ -247,6 +250,7 @@ class KDE_EXPORT DownloadDialog : public KDialogBase
TQMap<TDEIO::Job*, Provider*> m_jobs; TQMap<TDEIO::Job*, Provider*> m_jobs;
TQMap<TDEIO::Job*, TQString> m_data; TQMap<TDEIO::Job*, TQString> m_data;
TQString m_filter; TQString m_filter;
TQString mJobData;
Engine *m_engine; Engine *m_engine;
Private *d; Private *d;
}; };

@ -1,6 +1,7 @@
/* /*
This file is part of KOrganizer. This file is part of KOrganizer.
Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 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 This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public modify it under the terms of the GNU Library General Public
@ -42,10 +43,10 @@ using namespace KNS;
struct Engine::Private struct Engine::Private
{ {
bool mIgnoreInstallResult; bool mIgnoreInstallResult;
KNewStuff *mNewStuff; TDENewStuff *mNewStuff;
}; };
Engine::Engine( KNewStuff *newStuff, const TQString &type, Engine::Engine( TDENewStuff *newStuff, const TQString &type,
TQWidget *parentWidget ) : TQWidget *parentWidget ) :
mParentWidget( parentWidget ), mDownloadDialog( 0 ), mParentWidget( parentWidget ), mDownloadDialog( 0 ),
mUploadDialog( 0 ), mProviderDialog( 0 ), mUploadProvider( 0 ), mUploadDialog( 0 ), mProviderDialog( 0 ), mUploadProvider( 0 ),
@ -56,7 +57,7 @@ Engine::Engine( KNewStuff *newStuff, const TQString &type,
mProviderLoader = new ProviderLoader( mParentWidget ); mProviderLoader = new ProviderLoader( mParentWidget );
} }
Engine::Engine( KNewStuff *newStuff, const TQString &type, Engine::Engine( TDENewStuff *newStuff, const TQString &type,
const TQString &providerList, TQWidget *parentWidget ) : const TQString &providerList, TQWidget *parentWidget ) :
mParentWidget( parentWidget ), mParentWidget( parentWidget ),
mDownloadDialog( 0 ), mUploadDialog( 0 ), mDownloadDialog( 0 ), mUploadDialog( 0 ),

@ -1,6 +1,7 @@
/* /*
This file is part of KOrganizer. This file is part of KOrganizer.
Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 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 This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public modify it under the terms of the GNU Library General Public
@ -29,7 +30,7 @@
namespace TDEIO { class Job; } namespace TDEIO { class Job; }
class KNewStuff; class TDENewStuff;
namespace KNS { namespace KNS {
@ -38,7 +39,7 @@ class UploadDialog;
class ProviderDialog; 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. * In most cases, Engine objects are built and used internally.
* Using this class explicitely does however give fine-grained control about the * Using this class explicitely does however give fine-grained control about the
@ -56,20 +57,20 @@ class KDE_EXPORT Engine : public TQObject
/** /**
Constructor. Constructor.
@param newStuff a KNewStuff object @param newStuff a TDENewStuff object
@param type the Hotstuff data type such as "korganizer/calendar" @param type the Hotstuff data type such as "korganizer/calendar"
@param parentWidget the parent window @param parentWidget the parent window
*/ */
Engine( KNewStuff *newStuff, const TQString &type, TQWidget *parentWidget = 0 ); Engine( TDENewStuff *newStuff, const TQString &type, TQWidget *parentWidget = 0 );
/** /**
Constructor. Constructor.
@param newStuff a KNewStuff object @param newStuff a TDENewStuff object
@param type the Hotstuff data type such as "korganizer/calendar" @param type the Hotstuff data type such as "korganizer/calendar"
@param providerList the URL of the provider list @param providerList the URL of the provider list
@param parentWidget the parent window @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. Destructor.
@ -130,7 +131,7 @@ class KDE_EXPORT Engine : public TQObject
/** /**
Ignores the return value of the install method. Used internally to Ignores the return value of the install method. Used internally to
avoid showing of the success/failure dialog when installation is done 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); void ignoreInstallResult(bool ignore);

@ -1,6 +1,7 @@
/* /*
This file is part of KOrganizer. This file is part of KOrganizer.
Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 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 This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public modify it under the terms of the GNU Library General Public
@ -297,46 +298,57 @@ TQStringList Entry::langs()
return mLangs; 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 ) void Entry::parseDomElement( const TQDomElement &element )
{ {
if ( element.tagName() != "stuff" ) return; if ( element.tagName() != "content" ) return;
mType = element.attribute("type"); mType = element.attribute("type");
TQDomNode n; 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() ) { for( n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) {
TQDomElement e = n.toElement(); TQDomElement e = n.toElement();
if ( e.tagName() == "name" ) if ( e.tagName() == "name" )
{ {
TQString lang = e.attribute( "lang" );
setName( e.text().stripWhiteSpace(), 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() ); setAuthor( e.text().stripWhiteSpace() );
TQString email = e.attribute( "email" ); // TQString email = e.attribute( "email" );
setAuthorEmail( 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() == "licence" ) setLicence( e.text().stripWhiteSpace() );
if ( e.tagName() == "summary" ) { if ( e.tagName() == "description" ) {
TQString lang = e.attribute( "lang" );
setSummary( e.text().stripWhiteSpace(), lang ); setSummary( e.text().stripWhiteSpace(), lang );
} }
if ( e.tagName() == "version" ) setVersion( e.text().stripWhiteSpace() ); if ( e.tagName() == "version" ) setVersion( e.text().stripWhiteSpace() );
if ( e.tagName() == "release" ) setRelease( e.text().toInt() ); // if ( e.tagName() == "release" ) setRelease( e.text().toInt() );
if ( e.tagName() == "releasedate" ) { if ( e.tagName() == "created" ) {
TQDate date = TQT_TQDATE_OBJECT(TQDate::fromString( e.text().stripWhiteSpace(), Qt::ISODate )); TQDate date = TQT_TQDATE_OBJECT(TQDate::fromString( e.text().stripWhiteSpace(), Qt::ISODate ));
setReleaseDate( date ); setReleaseDate( date );
} }
if ( e.tagName() == "preview" ) { if ( e.tagName() == "smallpreviewpic1" ) {
TQString lang = e.attribute( "lang" );
setPreview( KURL( e.text().stripWhiteSpace() ), lang ); setPreview( KURL( e.text().stripWhiteSpace() ), lang );
} }
if ( e.tagName() == "payload" ) { if ( e.tagName() == "downloadlink1" ) {
TQString lang = e.attribute( "lang" );
setPayload( KURL( e.text().stripWhiteSpace() ), lang ); 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() ); if ( e.tagName() == "downloads" ) setDownloads( e.text().toInt() );
} }
} }
@ -344,32 +356,27 @@ void Entry::parseDomElement( const TQDomElement &element )
TQDomElement Entry::createDomElement( TQDomDocument &doc, TQDomElement Entry::createDomElement( TQDomDocument &doc,
TQDomElement &parent ) TQDomElement &parent )
{ {
TQDomElement entry = doc.createElement( "stuff" ); TQDomElement entry = doc.createElement( "content" );
entry.setAttribute("type", mType); entry.setAttribute("type", mType);
parent.appendChild( entry ); parent.appendChild( entry );
addElement( doc, entry, "language", langs().first() );
addElement( doc, entry, "name", name() ); addElement( doc, entry, "name", name() );
addElement( doc, entry, "author", author() ); addElement( doc, entry, "personid", author() );
addElement( doc, entry, "email", authorEmail() ); // addElement( doc, entry, "email", authorEmail() );
addElement( doc, entry, "licence", license() ); addElement( doc, entry, "licence", license() );
addElement( doc, entry, "version", version() ); addElement( doc, entry, "version", version() );
addElement( doc, entry, "release", TQString::number( release() ) ); // addElement( doc, entry, "release", TQString::number( release() ) );
addElement( doc, entry, "rating", TQString::number( rating() ) ); addElement( doc, entry, "score", TQString::number( rating() ) );
addElement( doc, entry, "downloads", TQString::number( downloads() ) ); addElement( doc, entry, "downloads", TQString::number( downloads() ) );
addElement( doc, entry, "releasedate", addElement( doc, entry, "created",
releaseDate().toString( Qt::ISODate ) ); releaseDate().toString( Qt::ISODate ) );
TQStringList ls = langs(); addElement( doc, entry, "description", summary() );
TQStringList::ConstIterator it; addElement( doc, entry, "preview", preview().url() );
for( it = ls.begin(); it != ls.end(); ++it ) { addElement( doc, entry, "payload", payload().url() );
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 );
}
return entry; return entry;
} }

@ -1,6 +1,7 @@
/* /*
This file is part of KOrganizer. This file is part of KOrganizer.
Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 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 This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public modify it under the terms of the GNU Library General Public
@ -31,10 +32,10 @@
namespace KNS { namespace KNS {
/** /**
* @short KNewStuff data entry container. * @short TDENewStuff data entry container.
* *
* This class provides accessor methods to the data objects * 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. * It should probably not be used directly by the application.
* *
* @author Cornelius Schumacher (schumacher@kde.org) * @author Cornelius Schumacher (schumacher@kde.org)

@ -41,7 +41,7 @@ using namespace std;
GhnsWidget::GhnsWidget() GhnsWidget::GhnsWidget()
{ {
mWallpapers = new KNewStuffGeneric( "kdesktop/wallpaper", this ); mWallpapers = new TDENewStuffGeneric( "kdesktop/wallpaper", this );
TQBoxLayout *topLayout = new TQVBoxLayout( this ); TQBoxLayout *topLayout = new TQVBoxLayout( this );
topLayout->setMargin( KDialog::marginHint() ); topLayout->setMargin( KDialog::marginHint() );

@ -41,7 +41,7 @@ class GhnsWidget : public TQWidget
void downloadWallpapers(); void downloadWallpapers();
private: private:
KNewStuff *mWallpapers; TDENewStuff *mWallpapers;
}; };
#endif #endif

@ -39,48 +39,48 @@ TDEAction* KNS::standardAction(const TQString& what,
0, recvr, slot, parent, name); 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 ); 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 ); mEngine = new Engine( this, type, providerList, parentWidget );
} }
TQString KNewStuff::type() const TQString TDENewStuff::type() const
{ {
return mEngine->type(); return mEngine->type();
} }
TQWidget *KNewStuff::parentWidget() const TQWidget *TDENewStuff::parentWidget() const
{ {
return mEngine->parentWidget(); return mEngine->parentWidget();
} }
KNewStuff::~KNewStuff() TDENewStuff::~TDENewStuff()
{ {
delete mEngine; delete mEngine;
} }
void KNewStuff::download() void TDENewStuff::download()
{ {
mEngine->download(); mEngine->download();
} }
TQString KNewStuff::downloadDestination( Entry * ) TQString TDENewStuff::downloadDestination( Entry * )
{ {
return TDEGlobal::dirs()->saveLocation( "tmp" ) + return TDEGlobal::dirs()->saveLocation( "tmp" ) +
TDEApplication::randomString( 10 ); TDEApplication::randomString( 10 );
} }
void KNewStuff::upload() void TDENewStuff::upload()
{ {
mEngine->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); mEngine->upload(fileName, previewName);
} }

@ -43,7 +43,7 @@ KDE_EXPORT TDEAction* standardAction(const TQString& what,
/** /**
* @short This class provides the functionality to download and upload "new stuff". * @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. * and link to against libknewstuff.
* *
* By calling download() the download process is started which means that a list * 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 * @since 3.3
*/ */
class KDE_EXPORT KNewStuff class KDE_EXPORT TDENewStuff
{ {
public: public:
/** /**
@ -74,10 +74,10 @@ class KDE_EXPORT KNewStuff
@param type type of data to be handled, should be something like @param type type of data to be handled, should be something like
korganizer/calendar, kword/template, kdesktop/wallpaper 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 engine
*/ */
KNewStuff( const TQString &type, TQWidget *parentWidget = 0 ); TDENewStuff( const TQString &type, TQWidget *parentWidget = 0 );
/** /**
Constructor. Constructor.
@ -85,11 +85,11 @@ class KDE_EXPORT KNewStuff
@param type type of data to be handled, should be something like @param type type of data to be handled, should be something like
korganizer/calendar, kword/template, kdesktop/wallpaper korganizer/calendar, kword/template, kdesktop/wallpaper
@param providerList the URL of the provider list @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 engine
*/ */
KNewStuff( const TQString &type, const TQString &providerList, TQWidget *parentWidget = 0 ); TDENewStuff( const TQString &type, const TQString &providerList, TQWidget *parentWidget = 0 );
virtual ~KNewStuff(); virtual ~TDENewStuff();
/** /**
Return type of data. Return type of data.
@ -118,7 +118,7 @@ class KDE_EXPORT KNewStuff
/** /**
Install file to application. The given fileName points to the file 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 The application can do whatever is needed to handle the information
contained in the file. contained in the file.

@ -28,9 +28,9 @@ namespace KNS
class DownloadDialog; 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 * 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 * @since 3.4
*/ */
@ -40,7 +40,7 @@ class Button : public KPushButton
public: 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. * download is known when the button is created.
* *
* @param what text describing what is being downloaded. will be * @param what text describing what is being downloaded. will be
@ -59,7 +59,7 @@ class Button : public KPushButton
TQWidget* parent, const char* name); 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. * download is not known in advance of the button being created.
* *
* @param parent the parent widget * @param parent the parent widget

@ -37,22 +37,22 @@
using namespace std; using namespace std;
KNewStuffGeneric::KNewStuffGeneric( const TQString &type, TQWidget *parent ) TDENewStuffGeneric::TDENewStuffGeneric( const TQString &type, TQWidget *parent )
: KNewStuff( type, parent ) : TDENewStuff( type, parent )
{ {
mConfig = TDEGlobal::config(); 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; TQStringList list, list2;
mConfig->setGroup("KNewStuff"); mConfig->setGroup("TDENewStuff");
TQString uncompress = mConfig->readEntry( "Uncompress" ); TQString uncompress = mConfig->readEntry( "Uncompress" );
if ( !uncompress.isEmpty() ) { if ( !uncompress.isEmpty() ) {
@ -80,16 +80,16 @@ bool KNewStuffGeneric::install( const TQString &fileName )
return true; return true;
} }
bool KNewStuffGeneric::createUploadFile( const TQString & /*fileName*/ ) bool TDENewStuffGeneric::createUploadFile( const TQString & /*fileName*/ )
{ {
return false; return false;
} }
TQString KNewStuffGeneric::destinationPath( KNS::Entry *entry ) TQString TDENewStuffGeneric::destinationPath( KNS::Entry *entry )
{ {
TQString path, file, target, ext; TQString path, file, target, ext;
mConfig->setGroup("KNewStuff"); mConfig->setGroup("TDENewStuff");
if ( entry ) if ( entry )
{ {
@ -117,7 +117,7 @@ TQString KNewStuffGeneric::destinationPath( KNS::Entry *entry )
if ( res.isEmpty() && path.isEmpty() ) if ( res.isEmpty() && path.isEmpty() )
{ {
if ( !entry ) return TQString::null; if ( !entry ) return TQString::null;
else return KNewStuff::downloadDestination( entry ); else return TDENewStuff::downloadDestination( entry );
} }
if ( !path.isEmpty() ) if ( !path.isEmpty() )
@ -130,7 +130,7 @@ TQString KNewStuffGeneric::destinationPath( KNS::Entry *entry )
return file; return file;
} }
TQString KNewStuffGeneric::downloadDestination( KNS::Entry *entry ) TQString TDENewStuffGeneric::downloadDestination( KNS::Entry *entry )
{ {
TQString file = destinationPath(entry); TQString file = destinationPath(entry);

@ -26,12 +26,12 @@
class TDEConfig; 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. * This class is used for data uploads and installation.
* \code * \code
* TQString payload, preview; * TQString payload, preview;
* KNewStuffGeneric *ns = new KNewStuffGeneric("kamikaze/level", this); * TDENewStuffGeneric *ns = new TDENewStuffGeneric("kamikaze/level", this);
* ns->upload(payload, preview); * ns->upload(payload, preview);
* \endcode * \endcode
* *
@ -39,7 +39,7 @@ class TDEConfig;
* \par Maintainer: * \par Maintainer:
* Josef Spillner (spillner@kde.org) * Josef Spillner (spillner@kde.org)
*/ */
class KDE_EXPORT KNewStuffGeneric : public KNewStuff class KDE_EXPORT TDENewStuffGeneric : public TDENewStuff
{ {
public: public:
/** /**
@ -48,8 +48,8 @@ class KDE_EXPORT KNewStuffGeneric : public KNewStuff
@param type a Hotstuff data type such as "korganizer/calendar" @param type a Hotstuff data type such as "korganizer/calendar"
@param parent the parent window. @param parent the parent window.
*/ */
KNewStuffGeneric( const TQString &type, TQWidget *parent = 0 ); TDENewStuffGeneric( const TQString &type, TQWidget *parent = 0 );
~KNewStuffGeneric(); ~TDENewStuffGeneric();
/** /**
Installs a downloaded file according to the application's configuration. 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. 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. means that the provided file must already be in a usable format.
@param fileName the name of the file to upload after its creation @param fileName the name of the file to upload after its creation

@ -33,20 +33,20 @@
using namespace KNS; using namespace KNS;
KNewStuffSecure::KNewStuffSecure(const TQString &type, TQWidget *parentWidget) TDENewStuffSecure::TDENewStuffSecure(const TQString &type, TQWidget *parentWidget)
: KNewStuff(type, parentWidget) : TDENewStuff(type, parentWidget)
{ {
m_tempDir = 0L; m_tempDir = 0L;
connect(engine(), TQT_SIGNAL(uploadFinished(bool)), TQT_SLOT(slotUploadFinished(bool))); connect(engine(), TQT_SIGNAL(uploadFinished(bool)), TQT_SLOT(slotUploadFinished(bool)));
} }
KNewStuffSecure::~KNewStuffSecure() TDENewStuffSecure::~TDENewStuffSecure()
{ {
removeTempDirectory(); removeTempDirectory();
} }
bool KNewStuffSecure::install(const TQString &fileName) bool TDENewStuffSecure::install(const TQString &fileName)
{ {
bool ok = true; bool ok = true;
@ -84,7 +84,7 @@ bool KNewStuffSecure::install(const TQString &fileName)
return ok; return ok;
} }
void KNewStuffSecure::slotValidated(int result) void TDENewStuffSecure::slotValidated(int result)
{ {
TQString errorString; TQString errorString;
TQString signatureStr; TQString signatureStr;
@ -145,8 +145,8 @@ void KNewStuffSecure::slotValidated(int result)
} else } else
{ {
TDEConfig *cfg = TDEGlobal::config(); TDEConfig *cfg = TDEGlobal::config();
cfg->deleteGroup("KNewStuffStatus"); cfg->deleteGroup("TDENewStuffStatus");
cfg->setGroup("KNewStuffStatus"); cfg->setGroup("TDENewStuffStatus");
for (TQMap<TQString, TQString>::ConstIterator it = m_installedResources.constBegin(); it != m_installedResources.constEnd(); ++it) for (TQMap<TQString, TQString>::ConstIterator it = m_installedResources.constBegin(); it != m_installedResources.constEnd(); ++it)
{ {
cfg->writeEntry(it.key(), it.data()); 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))); disconnect(Security::ref(), TQT_SIGNAL(validityResult(int)), this, TQT_SLOT(slotValidated(int)));
} }
void KNewStuffSecure::downloadResource() void TDENewStuffSecure::downloadResource()
{ {
TDEConfig *cfg = TDEGlobal::config(); TDEConfig *cfg = TDEGlobal::config();
m_installedResources = cfg->entryMap("KNewStuffStatus"); m_installedResources = cfg->entryMap("TDENewStuffStatus");
engine()->ignoreInstallResult(true); engine()->ignoreInstallResult(true);
KNewStuff::download(); TDENewStuff::download();
} }
bool KNewStuffSecure::createUploadFile(const TQString &fileName) bool TDENewStuffSecure::createUploadFile(const TQString &fileName)
{ {
Q_UNUSED(fileName); Q_UNUSED(fileName);
return true; 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))); connect(Security::ref(), TQT_SIGNAL(fileSigned(int)), this, TQT_SLOT(slotFileSigned(int)));
removeTempDirectory(); removeTempDirectory();
@ -183,7 +183,7 @@ void KNewStuffSecure::uploadResource(const TQString& fileName)
Security::ref()->signFile(m_signedFileName); Security::ref()->signFile(m_signedFileName);
} }
void KNewStuffSecure::slotFileSigned(int result) void TDENewStuffSecure::slotFileSigned(int result)
{ {
if (result == 0) if (result == 0)
{ {
@ -216,18 +216,18 @@ void KNewStuffSecure::slotFileSigned(int result)
} }
tar.close(); tar.close();
TDEIO::NetAccess::file_move(KURL::fromPathOrURL(m_signedFileName + ".signed"), KURL::fromPathOrURL(m_signedFileName), -1, true); 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))); 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); Q_UNUSED(result);
removeTempDirectory(); removeTempDirectory();
} }
void KNewStuffSecure::removeTempDirectory() void TDENewStuffSecure::removeTempDirectory()
{ {
if (m_tempDir) if (m_tempDir)
{ {

@ -31,13 +31,13 @@ tarball (which is installabale by @ref installResource()) and call the
@ref uploadResource() method with this tarball as the argument. @ref uploadResource() method with this tarball as the argument.
Signing and verification is done by the gpg application, so the user must 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 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 @since 3.4
@author Andras Mantia <amantia@kde.org> @author Andras Mantia <amantia@kde.org>
*/ */
class KDE_EXPORT KNewStuffSecure : public TQObject, public KNewStuff class KDE_EXPORT TDENewStuffSecure : public TQObject, public TDENewStuff
{ {
Q_OBJECT Q_OBJECT
@ -46,14 +46,14 @@ public:
@param type type of data to be handled, should be something like @param type type of data to be handled, should be something like
korganizer/calendar, kword/template, kdesktop/wallpaper 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 engine
*/ */
KNewStuffSecure(const TQString &type, TQWidget *parentWidget=0); TDENewStuffSecure(const TQString &type, TQWidget *parentWidget=0);
virtual ~KNewStuffSecure(); virtual ~TDENewStuffSecure();
/** Installs the downloaded resource. Do not call or reimplement directly. /** 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 ); bool install( const TQString &fileName );

@ -1,6 +1,7 @@
/* /*
This file is part of KOrganizer. This file is part of KOrganizer.
Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 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 This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public 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 // 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 ); parseDomElement( e );
} }
@ -101,6 +102,10 @@ Provider::~Provider()
} }
} }
bool Provider::loaded()
{
return mLoaded;
}
void Provider::setName( const TQString &name ) void Provider::setName( const TQString &name )
{ {
@ -167,29 +172,51 @@ bool Provider::noUpload() const
return mNoUpload; return mNoUpload;
} }
void Provider::parseDomElement( const TQDomElement &element ) void Provider::parseDomElement( const TQDomElement &element )
{ {
if ( element.tagName() != "provider" ) return; bool contentAvailable = false;
setDownloadUrl( KURL( element.attribute("downloadurl") ) ); if ( element.tagName() != "provider" ) return;
setUploadUrl( KURL( element.attribute("uploadurl") ) );
setNoUploadUrl( KURL( element.attribute("nouploadurl") ) );
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 );
TQDomNode n; TQDomNode n;
for ( n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) { for ( n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) {
TQDomElement p = n.toElement(); 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() == "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; 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 ) : ProviderLoader::ProviderLoader( TQWidget *parentWidget ) :
TQObject( parentWidget ) TQObject( parentWidget )
@ -218,9 +340,10 @@ void ProviderLoader::load( const TQString &type, const TQString &providersList )
mProviders.clear(); mProviders.clear();
mJobData = ""; mJobData = "";
mContentType = type;
TDEConfig *cfg = TDEGlobal::config(); TDEConfig *cfg = TDEGlobal::config();
cfg->setGroup("KNewStuff"); cfg->setGroup("TDENewStuff");
TQString providersUrl = providersList; TQString providersUrl = providersList;
if( providersUrl.isEmpty() ) if( providersUrl.isEmpty() )
@ -282,9 +405,24 @@ void ProviderLoader::slotJobResult( TDEIO::Job *job )
TQDomElement p = n.toElement(); TQDomElement p = n.toElement();
if ( p.tagName() == "provider" ) { 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() ) );
}
}
}
void ProviderLoader::providerLoaded() {
Provider* prov = NULL;
bool allLoaded = true;
for ( prov = mProviders.first(); prov; prov = mProviders.next() ) {
if (!prov->loaded()) {
allLoaded = false;
break;
} }
} }
emit providersLoaded( &mProviders ); if (allLoaded) {
emit providersLoaded( &mProviders );
}
} }

@ -1,6 +1,7 @@
/* /*
This file is part of KOrganizer. This file is part of KOrganizer.
Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 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 This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public modify it under the terms of the GNU Library General Public
@ -33,35 +34,41 @@ namespace TDEIO { class Job; }
namespace KNS { namespace KNS {
/** /**
* @short KNewStuff provider container. * @short TDENewStuff provider container.
* *
* This class provides accessors for the provider object. * 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. * It should probably not be used directly by the application.
* *
* @author Cornelius Schumacher (schumacher@kde.org) * @author Cornelius Schumacher (schumacher@kde.org)
* \par Maintainer: * \par Maintainer:
* Josef Spillner (spillner@kde.org) * Josef Spillner (spillner@kde.org)
*/ */
class KDE_EXPORT Provider class KDE_EXPORT Provider : public TQObject
{ {
Q_OBJECT
public: public:
typedef TQPtrList<Provider> List; typedef TQPtrList<Provider> List;
/** /**
* Constructor. * Constructor.
*/ */
Provider(); Provider( TQString type = TQString::null, TQWidget* parent = 0 );
/** /**
* Constructor with XML feed. * Constructor with XML feed.
*/ */
Provider( const TQDomElement & ); Provider( const TQDomElement &, TQString type = TQString::null, TQWidget* parent = 0 );
/** /**
* Destructor. * Destructor.
*/ */
~Provider(); virtual ~Provider();
/**
* @return provider load status
*/
bool loaded();
/** /**
* Sets the common name of the provider. * Sets the common name of the provider.
@ -154,6 +161,13 @@ class KDE_EXPORT Provider
TQDomElement createDomElement( TQDomDocument &, TQDomElement &parent ); TQDomElement createDomElement( TQDomDocument &, TQDomElement &parent );
protected slots:
void slotJobData( TDEIO::Job *, const TQByteArray & );
void slotJobResult( TDEIO::Job * );
signals:
void providerLoaded();
private: private:
TQString mName; TQString mName;
KURL mDownloadUrl; KURL mDownloadUrl;
@ -161,10 +175,15 @@ class KDE_EXPORT Provider
KURL mNoUploadUrl; KURL mNoUploadUrl;
KURL mIcon; KURL mIcon;
bool mNoUpload; 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 * This class sets up a list of all possible providers by querying
* the main provider database for this specific application. * the main provider database for this specific application.
* It should probably not be used directly by the application. * It should probably not be used directly by the application.
@ -200,11 +219,13 @@ class KDE_EXPORT ProviderLoader : public TQObject
protected slots: protected slots:
void slotJobData( TDEIO::Job *, const TQByteArray & ); void slotJobData( TDEIO::Job *, const TQByteArray & );
void slotJobResult( TDEIO::Job * ); void slotJobResult( TDEIO::Job * );
void providerLoaded();
private: private:
TQWidget *mParentWidget; TQWidget *mParentWidget;
TQString mJobData; TQString mJobData;
TQString mContentType;
Provider::List mProviders; Provider::List mProviders;
}; };

@ -47,7 +47,7 @@ class ProviderDialog : public KDialogBase
/** /**
Constructor. Constructor.
@param engine a KNewStuff engine object @param engine a TDENewStuff engine object
@param parent the parent window @param parent the parent window
*/ */
ProviderDialog( Engine *engine, TQWidget *parent ); ProviderDialog( Engine *engine, TQWidget *parent );

@ -35,7 +35,7 @@ static const TDECmdLineOptions op[] =
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
TDEAboutData about("tdehotnewstuff", "KHotNewStuff", "0.2"); TDEAboutData about("tdehotnewstuff", "TDEHotNewStuff", "0.2");
TDECmdLineArgs *args; TDECmdLineArgs *args;
TDECmdLineArgs::init(argc, argv, &about); TDECmdLineArgs::init(argc, argv, &about);

@ -1,3 +1,3 @@
[KNewStuff] [TDENewStuff]
ProvidersUrl=http://www.kstuff.org/hotstuff/providers/index.xml ProvidersUrl=https://www.trinitydesktop.org/ocs/providers.xml

@ -107,7 +107,7 @@ void MyWidget::upload()
int main(int argc,char **argv) 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); TDECmdLineArgs::init(argc,argv,&aboutData);
TDEApplication app; TDEApplication app;

@ -30,10 +30,10 @@
#include "knewstuff.h" #include "knewstuff.h"
class TestNewStuff : public KNewStuff class TestNewStuff : public TDENewStuff
{ {
public: public:
TestNewStuff() : KNewStuff( "korganizer/calendar" ) {} TestNewStuff() : TDENewStuff( "korganizer/calendar" ) {}
bool install( const TQString &fileName ); bool install( const TQString &fileName );
@ -52,7 +52,7 @@ class MyWidget : public TQWidget
void download(); void download();
private: private:
KNewStuff *mNewStuff; TDENewStuff *mNewStuff;
}; };
#endif #endif

@ -137,7 +137,7 @@ void UploadDialog::slotOk()
if ( mPayloadUrl.isValid() ) { if ( mPayloadUrl.isValid() ) {
TDEConfig *conf = kapp->config(); 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("name", mNameEdit->text());
conf->writeEntry("author", mAuthorEdit->text()); conf->writeEntry("author", mAuthorEdit->text());
conf->writeEntry("email", mEmailEdit->text()); conf->writeEntry("email", mEmailEdit->text());
@ -165,7 +165,7 @@ void UploadDialog::setPayloadFile( const TQString &payloadFile )
mPayloadUrl = payloadFile; mPayloadUrl = payloadFile;
TDEConfig *conf = kapp->config(); 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 name = conf->readEntry("name");
TQString author = conf->readEntry("author"); TQString author = conf->readEntry("author");
TQString email = conf->readEntry("email"); TQString email = conf->readEntry("email");

@ -34,11 +34,11 @@ class Engine;
class Entry; class Entry;
/** /**
* @short KNewStuff file upload dialog. * @short TDENewStuff file upload dialog.
* *
* Using this dialog, data can easily be uploaded to the Hotstuff servers. * 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 * It should however not be used on its own, instead a TDENewStuff (or
* KNewStuffGeneric) object invokes it. * TDENewStuffGeneric) object invokes it.
* *
* @author Cornelius Schumacher (schumacher@kde.org) * @author Cornelius Schumacher (schumacher@kde.org)
* \par Maintainer: * \par Maintainer:
@ -51,7 +51,7 @@ class UploadDialog : public KDialogBase
/** /**
Constructor. 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 @param parent the parent window
*/ */
UploadDialog( Engine *engine, TQWidget *parent ); UploadDialog( Engine *engine, TQWidget *parent );

Loading…
Cancel
Save