# knewstuff Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# KNewStuff Class Reference

This class provides the functionality to download and upload "new stuff". More...

`#include <knewstuff.h>`

Inheritance diagram for KNewStuff:

[legend]
Collaboration diagram for KNewStuff:

[legend]
List of all members.

## Public Member Functions

| KNewStuff (const QString &type, QWidget *parentWidget=0)
| KNewStuff (const QString &type, const QString &providerList, QWidget *parentWidget=0)
QString | type () const
QWidget * | parentWidget () const
void | download ()
void | upload ()
void | upload (const QString &fileName, const QString previewName)
virtual bool | install (const QString &fileName)=0
virtual bool | createUploadFile (const QString &fileName)=0
virtual QString | downloadDestination (KNS::Entry *entry)

## Protected Member Functions

KNS::Engine * | engine ()

## Detailed Description

This class provides the functionality to download and upload "new stuff".

Applications have to subclass KNewStuff, implement the pure virtual functions and link to against libknewstuff.

By calling download() the download process is started which means that a list of "providers" is fetched from a "master server", information about new stuff is collected from the providers and presented to the user. Selected entries get downloaded and installed to the application. The required functions to install new stuff are provided by implementing install(). The location where the downloaded files are stored can be customized by reimplementing downloadDestination().

By calling upload() the upload process is started which means the user has to select a provider from the list fetched from the master server and to put in information about the entry to be uploaded. Then the file to be uploaded is fetched from the application by calling createUploadFile() and transfered to the upload destination specified in the provider list.

Author:
  Cornelius Schumacher (schumacher@kde.org)

Maintainer:
  Josef Spillner (spillner@kde.org)

Since:
  3.3

Definition at line 69 of file knewstuff.h.

## Constructor & Destructor Documentation

KNewStuff::KNewStuff | ( | const QString & | type,
|  | QWidget * | parentWidget = `0`
| ) |

Constructor.

Parameters:

  | type | type of data to be handled, should be something like korganizer/calendar, kword/template, kdesktop/wallpaper
  | parentWidget | parent widget of dialogs opened by the KNewStuff engine

Definition at line 42 of file knewstuff.cpp.

References parentWidget(), and type().

KNewStuff::KNewStuff | ( | const QString & | type,
|  | const QString & | providerList,
|  | QWidget * | parentWidget = `0`
| ) |

Constructor.

Parameters:

  | type | type of data to be handled, should be something like korganizer/calendar, kword/template, kdesktop/wallpaper
  | providerList | the URL of the provider list
  | parentWidget | parent widget of dialogs opened by the KNewStuff engine

Definition at line 47 of file knewstuff.cpp.

References parentWidget(), and type().

## Member Function Documentation

QString KNewStuff::type | ( |  | ) | const

| Return type of data. Definition at line 52 of file knewstuff.cpp. References KNS::Engine::type(). Referenced by KNewStuff().

QWidget * KNewStuff::parentWidget | ( |  | ) | const

| Return parent widget. Definition at line 57 of file knewstuff.cpp. References KNS::Engine::parentWidget(). Referenced by KNewStuffGeneric::downloadDestination(), KNewStuffSecure::install(), KNewStuff(), and KNewStuffSecure::removeTempDirectory().

void KNewStuff::download | ( |  | ) |

| Start download process. Definition at line 67 of file knewstuff.cpp. References KNS::Engine::download(). Referenced by KNewStuffSecure::downloadResource().

void KNewStuff::upload | ( |  | ) |

| Start upload process. Definition at line 78 of file knewstuff.cpp. References KNS::Engine::upload().

void KNewStuff::upload | ( | const QString & | fileName,
|  | const QString | previewName
| ) |

| Upload with pre-defined files. Definition at line 83 of file knewstuff.cpp. References KNS::Engine::upload().

virtual bool KNewStuff::install | ( | const QString & | fileName | ) | `[pure virtual]`

Install file to application.

The given fileName points to the file downloaded by the KNewStuff engine. This is a temporary file by default. The application can do whatever is needed to handle the information contained in the file.

The function returns true, when the installation was successful and false if were errors.

Parameters:

  | fileName | name of downloaded file

Implemented in KNewStuffGeneric, and KNewStuffSecure.

virtual bool KNewStuff::createUploadFile | ( | const QString & | fileName | ) | `[pure virtual]`

Create a file to be uploaded to a "new stuff provider" and return the filename.

The format of the file is application specific. The only constraint is that the corresponding install() implementation is able to use the file.

Parameters:

  | fileName | name of the file to be written

Returns:
  `true` on success, `false` on error.

Implemented in KNewStuffGeneric, and KNewStuffSecure.

QString KNewStuff::downloadDestination | ( | KNS::Entry * | entry | ) | `[virtual]`

| Return a filename which should be used as destination for downloading the specified new stuff entry. Reimplement this function, if you don't want the new stuff to be downloaded to a temporary file. Reimplemented in KNewStuffGeneric. Definition at line 72 of file knewstuff.cpp.

KNS::Engine* KNewStuff::engine | ( |  | ) | `[inline, protected]`

| Get the pointer to the engine. Needed by subclasses to access the KNS::Engine object. Definition at line 154 of file knewstuff.h. Referenced by KNewStuffSecure::downloadResource(), and KNewStuffSecure::KNewStuffSecure().

The documentation for this class was generated from the following files:

- knewstuff.h
- knewstuff.cpp

This file is part of the documentation for knewstuff Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:28:36 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003