Add proper OCS support to the base TDENewStuff class

This relates to Bug 2127
pull/16/head
Timothy Pearson 10 years ago
parent 62bfcbe478
commit 72a2afc0af

@ -141,34 +141,51 @@ void Engine::slotNewStuffJobResult( TDEIO::Job *job )
TQDomDocument doc;
if ( !doc.setContent( knewstuffDoc ) ) {
kdDebug() << "Error parsing knewstuff.xml." << endl;
kdDebug() << "Error parsing OCS response." << endl;
return;
} else {
}
else {
TQDomElement knewstuff = doc.documentElement();
if ( knewstuff.isNull() ) {
kdDebug() << "No document in knewstuffproviders.xml." << endl;
} else {
TQDomNode p;
for ( p = knewstuff.firstChild(); !p.isNull(); p = p.nextSibling() ) {
TQDomElement stuff = p.toElement();
if ( stuff.tagName() != "stuff" ) continue;
if ( stuff.attribute("type", mType) != mType ) continue;
kdDebug() << "No document in OCS response." << endl;
}
else {
TQDomElement content;
for(TQDomNode pn = knewstuff.firstChild(); !pn.isNull(); pn = pn.nextSibling())
{
TQDomElement stuff = pn.toElement();
if(stuff.tagName() == "data")
{
content = pn.toElement();
}
}
if ( content.isNull() ) {
kdDebug() << "No content in OCS response." << endl;
}
else {
TQDomNode p;
for ( p = content.firstChild(); !p.isNull(); p = p.nextSibling() ) {
TQDomElement stuff = p.toElement();
if ( stuff.tagName() != "content" ) continue;
Entry *entry = new Entry( stuff );
Entry *entry = new Entry( stuff );
mDownloadDialog->show();
mDownloadDialog->show();
mDownloadDialog->addEntry( entry );
mDownloadDialog->addEntry( entry );
kdDebug() << "KNEWSTUFF: " << entry->name() << endl;
kdDebug() << "KNEWSTUFF: " << entry->name() << endl;
kdDebug() << " SUMMARY: " << entry->summary() << endl;
kdDebug() << " VERSION: " << entry->version() << endl;
kdDebug() << " RELEASEDATE: " << TQString(entry->releaseDate().toString()) << endl;
kdDebug() << " RATING: " << entry->rating() << endl;
kdDebug() << " SUMMARY: " << entry->summary() << endl;
kdDebug() << " VERSION: " << entry->version() << endl;
kdDebug() << " RELEASEDATE: " << TQString(entry->releaseDate().toString()) << endl;
kdDebug() << " RATING: " << entry->rating() << endl;
kdDebug() << " LANGS: " << entry->langs().join(", ") << endl;
kdDebug() << " LANGS: " << entry->langs().join(", ") << endl;
}
}
}
}

@ -301,6 +301,10 @@ TQStringList Entry::langs()
// FIXME
// It appears that OCS has removed the ability to retrieve author EMail;
// further confirmation is needed before removing EMail-related code
// NOTE
// OCS also removed the ability to have individually localized names and summaries for a single item
// As this would be a useful feature to add to the OCS system I'm keeping the lang code skeleton in at this time
// Note that the "language" XML tag refers to the intended language of the content, not the language of the entry!
void Entry::parseDomElement( const TQDomElement &element )
{
if ( element.tagName() != "content" ) return;
@ -308,17 +312,6 @@ void Entry::parseDomElement( const TQDomElement &element )
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" )

@ -316,7 +316,12 @@ void Provider::slotJobResult( TDEIO::Job *job )
//int maxEntries = 50;
int maxEntries = 100;
setDownloadUrl( KURL( mBaseURL ) );
// FIXME
// The download URL assumes no more than 100 entries will be present on the remote server
// Any more and assembly of the list from multiple fetched pages will be required; the TDENewStuff Engine class does not have support for paging at this time
setDownloadUrl( KURL( mBaseURL + "content/data?categories=" + desiredCategories + "&search=&sortmode=alpha&page=0&pagesize=" + TQString("%1").arg(maxEntries) ) );
// FIXME
// Uploading is not implemented at this time
setUploadUrl( KURL( mBaseURL ) );
setNoUploadUrl( KURL( mBaseURL ) );
@ -347,8 +352,9 @@ void ProviderLoader::load( const TQString &type, const TQString &providersList )
cfg->setGroup("TDENewStuff");
TQString providersUrl = providersList;
if( providersUrl.isEmpty() )
providersUrl = cfg->readEntry( "ProvidersUrl" );
if( providersUrl.isEmpty() ) {
providersUrl = cfg->readEntry( "ProvidersUrl" );
}
if ( providersUrl.isEmpty() ) {
TQString server = cfg->readEntry( "MasterServer",

Loading…
Cancel
Save