Nepomuk Quickstart

Reading or setting simple metadata in your application with Nepomuk, can be very easy. However, keep in mind that the process described here may have performance drawbacks when changing a lot of metadata.
We will now take a look at a simple way to access a resource's metadata.

Initializing the Resource Manager

The ResourceManager is the central KMetaData configuration point. For KDE 4.2 and newer, we must explicitly initialize it in order to connect to the Nepomuk service.

Nepomuk::ResourceManager::instance()->init();

This method returns an int. If it succeeds (returns 0), the connection to the Nepomuk service has been established and we can work with it. If it fails (returns negative integer), the Nepomuk service was unreachable and we can't continue working with any Nepomuk related code--this may occur if the user has disabled the Nepomuk service for his current session.

Retrieving Metadata

Let's get the metadata for a file, assuming the URL or the file is stored in uri.