Jump to: navigation, search



Attica Introduction
Tutorial Series   Attica
Previous   Getting started with KDE development
What's Next   n/a
Further Reading   n/a


In this tutorial you learn how to use Attica to access the Open Collaboration Services in your application.

Our goal is to get a list of friends for any user registered on this site.

With Attica you can easily access services from providers such as It implements the specification for the Open Collaboration Services API.

Initializing the Provider Manager

Attica supports multiple Open Collaboration Service (OCS) providers at the same time. Therefor the first thing to do is getting a ProviderManager and either asking it for a default provider (e.g. for KDE) or setting a different provider by hand. Let's create a mainwindow class that loads a default provider.



  1. ifndef MAINWINDOW_H
  2. define MAINWINDOW_H
  1. include <KMainWindow>
  2. include <KLineEdit>
  3. include <QLabel>
  1. include <attica/providermanager.h>
  2. include <attica/provider.h>

class MainWindow : public KMainWindow {



   MainWindow(QWidget *parent=0);

public Q_SLOTS:

   void providersChanged();


   Attica::Provider m_provider;
   Attica::ProviderManager m_manager;


  1. endif



  1. include "mainwindow.h"
  1. include <KDebug>
  2. include <QVBoxLayout>
  1. include <attica/providermanager.h>
  1. include "simplepersonrequest.h"
  2. include "contentdownload.h"
  3. include "contentcreation.h"

MainWindow::MainWindow(QWidget *parent) : KMainWindow(parent) {

   connect(&m_manager, SIGNAL(providersChanged()), SLOT(providersChanged()));


void MainWindow::providersChanged() {

   if (!m_manager.providers().isEmpty()) {
       m_provider = m_manager.providerByUrl(QUrl(""));
       if (!m_provider.isValid()) {
           kDebug() << "Could not find provider.";
       QTabWidget* mainWidget = new QTabWidget(this);
       SimplePersonRequest* personWidget = new SimplePersonRequest(m_provider, this);
       mainWidget->addTab(personWidget, tr("Person Search"));
       ContentDownload* contentWidget = new ContentDownload(m_provider, this);
       mainWidget->addTab(contentWidget, tr("Content"));
       ContentCreation* contentCreationWidget = new ContentCreation(m_provider, this);
       mainWidget->addTab(contentCreationWidget, tr("Add Content"));


  1. include "mainwindow.moc"

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal