[SCM] ktp-accounts-kcm packaging branch, master, updated. debian/15.12.1-1-1157-gc4589c5

Maximiliano Curia maxy at moszumanska.debian.org
Fri May 27 23:58:45 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-accounts-kcm.git;a=commitdiff;h=327269b

The following commit has been merged in the master branch:
commit 327269b639e7dfe3d36378cae9c8cf38eef9c3ac
Author: Thomas Richard <thomas9999 at gmail.com>
Date:   Thu Jan 13 21:20:38 2011 +0100

    Renamed the protocol classes to profile classes
    Now showing profiles instead of protocols
---
 src/KCMTelepathyAccounts/CMakeLists.txt            |  12 +-
 .../connection-manager-item.cpp                    |   5 +-
 src/KCMTelepathyAccounts/connection-manager-item.h |   4 +-
 .../{protocol-item.cpp => profile-item.cpp}        |  45 ++++---
 .../{protocol-item.h => profile-item.h}            |  21 +--
 src/KCMTelepathyAccounts/profile-list-model.cpp    | 113 ++++++++++++++++
 ...{protocol-list-model.h => profile-list-model.h} |  28 ++--
 src/KCMTelepathyAccounts/profile-select-widget.cpp | 131 ++++++++++++++++++
 ...col-select-widget.h => profile-select-widget.h} |  29 ++--
 ...l-select-widget.ui => profile-select-widget.ui} |   6 +-
 src/KCMTelepathyAccounts/protocol-list-model.cpp   | 138 -------------------
 .../protocol-select-widget.cpp                     | 147 ---------------------
 src/add-account-assistant.cpp                      |  46 ++++---
 src/add-account-assistant.h                        |   2 +-
 14 files changed, 341 insertions(+), 386 deletions(-)

diff --git a/src/KCMTelepathyAccounts/CMakeLists.txt b/src/KCMTelepathyAccounts/CMakeLists.txt
index 082f335..5cbcff5 100644
--- a/src/KCMTelepathyAccounts/CMakeLists.txt
+++ b/src/KCMTelepathyAccounts/CMakeLists.txt
@@ -9,10 +9,10 @@ set (libkcmtelepathyaccounts_SRCS
      abstract-account-ui.cpp
      abstract-account-parameters-widget.cpp
      account-edit-widget.cpp
-     protocol-select-widget.cpp
-     protocol-list-model.cpp
+     profile-select-widget.cpp
+     profile-list-model.cpp
      connection-manager-item.cpp
-     protocol-item.cpp
+     profile-item.cpp
      parameter-edit-widget.cpp
      parameter-edit-delegate.cpp
      parameter-edit-model.cpp
@@ -30,8 +30,8 @@ set (libkcmtelepathyaccounts_HDRS
      plugin-macros.h
      connection-manager-item.h
      plugin-manager.h
-     protocol-select-widget.h
-     protocol-item.h
+     profile-select-widget.h
+     profile-item.h
      parameter-edit-widget.h
      protocol-parameter-value.h
 )
@@ -53,7 +53,7 @@ set (libkcmtelepathyaccounts_PRETTY_HDRS
 kde4_add_ui_files (libkcmtelepathyaccounts_SRCS
                    account-edit-widget.ui
                    parameter-edit-widget.ui
-                   protocol-select-widget.ui
+                   profile-select-widget.ui
 )
 
 kde4_add_library (kcmtelepathyaccounts
diff --git a/src/KCMTelepathyAccounts/connection-manager-item.cpp b/src/KCMTelepathyAccounts/connection-manager-item.cpp
index 91eea62..5f883d8 100644
--- a/src/KCMTelepathyAccounts/connection-manager-item.cpp
+++ b/src/KCMTelepathyAccounts/connection-manager-item.cpp
@@ -20,13 +20,13 @@
 
 #include "connection-manager-item.h"
 
-#include "protocol-list-model.h"
+#include "profile-list-model.h"
 
 #include <KDebug>
 
 #include <TelepathyQt4/PendingOperation>
 #include <TelepathyQt4/PendingReady>
-
+/*
 ConnectionManagerItem::ConnectionManagerItem(const Tp::ConnectionManagerPtr &connectionManager,
                                              ProtocolListModel *parent)
  : QObject(parent),
@@ -74,3 +74,4 @@ void ConnectionManagerItem::onConnectionManagerReady(Tp::PendingOperation *op)
 
 #include "connection-manager-item.moc"
 
+*/
diff --git a/src/KCMTelepathyAccounts/connection-manager-item.h b/src/KCMTelepathyAccounts/connection-manager-item.h
index aa3480e..93b0a97 100644
--- a/src/KCMTelepathyAccounts/connection-manager-item.h
+++ b/src/KCMTelepathyAccounts/connection-manager-item.h
@@ -26,7 +26,7 @@
 #include <QtCore/QObject>
 
 #include <TelepathyQt4/ConnectionManager>
-
+/*
 class ProtocolListModel;
 
 namespace Tp {
@@ -53,7 +53,7 @@ private Q_SLOTS:
 private:
     Tp::ConnectionManagerPtr m_connectionManager;
 };
-
+*/
 
 #endif // header guard
 
diff --git a/src/KCMTelepathyAccounts/protocol-item.cpp b/src/KCMTelepathyAccounts/profile-item.cpp
similarity index 56%
rename from src/KCMTelepathyAccounts/protocol-item.cpp
rename to src/KCMTelepathyAccounts/profile-item.cpp
index 2a68443..f88c99b 100644
--- a/src/KCMTelepathyAccounts/protocol-item.cpp
+++ b/src/KCMTelepathyAccounts/profile-item.cpp
@@ -18,57 +18,58 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include "protocol-item.h"
+#include "profile-item.h"
 
+#include "profile-list-model.h"
 #include "connection-manager-item.h"
 #include "dictionary.h"
 
+#include <TelepathyQt4/Profile>
 #include <KDebug>
 
-ProtocolItem::ProtocolItem(const QString &protocol, ConnectionManagerItem *parent)
+ProfileItem::ProfileItem(const Tp::ProfilePtr &profile, ProfileListModel *parent)
  : QObject(parent),
-   m_protocol(protocol)
+   m_profile(profile)
 {
-    kDebug() << "Creating new ProtocolItem with cmItem: " << parent << " and protocol;" << protocol;
+    kDebug() << "Creating new ProfileItem with and profile;" << profile.data()->name();
 
-    m_localizedName = Dictionary::instance()->string(protocol);
+    m_localizedName = Dictionary::instance()->string(profile.data()->name());
     if(m_localizedName.isEmpty()) {
-        m_localizedName = protocol;
+        m_localizedName = profile.data()->name();
     }
 }
 
-ProtocolItem::~ProtocolItem()
+ProfileItem::~ProfileItem()
 {
     kDebug();
 
     // TODO: Implement me...
 }
 
-QString ProtocolItem::protocol() const
+QString ProfileItem::name() const
 {
-    return m_protocol;
+    return m_profile.data()->name();
 }
 
-QString ProtocolItem::localizedName() const
+QString ProfileItem::localizedName() const
 {
     return m_localizedName;
 }
 
-Tp::ProtocolInfo ProtocolItem::protocolInfo() const
+QString ProfileItem::iconName() const
 {
-    kDebug();
-
-    ConnectionManagerItem *item = qobject_cast<ConnectionManagerItem*>(parent());
-
-    Tp::ConnectionManagerPtr cm = item->connectionManager();
+    return m_profile.data()->iconName();
+}
 
+QString ProfileItem::cmName() const
+{
+    return m_profile.data()->cmName();
+}
 
-    foreach (const Tp::ProtocolInfo &info, cm->protocols()) {
-        if (info.name() == m_protocol)
-            return info;
-    }
-    return Tp::ProtocolInfo();
+QString ProfileItem::protocolName() const
+{
+    return m_profile.data()->protocolName();
 }
 
-#include "protocol-item.moc"
+#include "profile-item.moc"
 
diff --git a/src/KCMTelepathyAccounts/protocol-item.h b/src/KCMTelepathyAccounts/profile-item.h
similarity index 74%
rename from src/KCMTelepathyAccounts/protocol-item.h
rename to src/KCMTelepathyAccounts/profile-item.h
index 759956e..fb4ebc1 100644
--- a/src/KCMTelepathyAccounts/protocol-item.h
+++ b/src/KCMTelepathyAccounts/profile-item.h
@@ -25,26 +25,27 @@
 
 #include <QtCore/QObject>
 
-#include <TelepathyQt4/ConnectionManager>
+#include <TelepathyQt4/Profile>
 
-class ConnectionManagerItem;
+class ProfileListModel;
 
-class KDE_EXPORT ProtocolItem : public QObject
+class KDE_EXPORT ProfileItem : public QObject
 {
     Q_OBJECT
-    Q_DISABLE_COPY(ProtocolItem);
+    Q_DISABLE_COPY(ProfileItem);
 
 public:
-    explicit ProtocolItem(const QString &protocol,
-                          ConnectionManagerItem *parent = 0);
-    virtual ~ProtocolItem();
+    explicit ProfileItem(const Tp::ProfilePtr &profile, ProfileListModel *parent);
+    virtual ~ProfileItem();
 
-    QString protocol() const;
+    QString name() const;
     QString localizedName() const;
-    Tp::ProtocolInfo protocolInfo() const;
+    QString iconName() const;
+    QString cmName() const;
+    QString protocolName() const;
 
 private:
-    QString m_protocol;
+    Tp::ProfilePtr m_profile;
     QString m_localizedName;
 };
 
diff --git a/src/KCMTelepathyAccounts/profile-list-model.cpp b/src/KCMTelepathyAccounts/profile-list-model.cpp
new file mode 100644
index 0000000..97f28d3
--- /dev/null
+++ b/src/KCMTelepathyAccounts/profile-list-model.cpp
@@ -0,0 +1,113 @@
+/*
+ * This file is part of telepathy-accounts-kcm
+ *
+ * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "profile-list-model.h"
+
+#include "connection-manager-item.h"
+#include "profile-item.h"
+
+#include <TelepathyQt4/ProfileManager>
+#include <KIcon>
+#include <KDebug>
+
+ProfileListModel::ProfileListModel(QObject *parent)
+ : QAbstractListModel(parent)
+{
+    kDebug();
+
+    m_profileItems.clear();
+}
+
+ProfileListModel::~ProfileListModel()
+{
+    kDebug();
+
+    // TODO: Implement me!
+}
+
+int ProfileListModel::rowCount(const QModelIndex &index) const
+{
+    // If the index is the root item, then return the row count.
+    if (index == QModelIndex()) {
+       return m_profileItems.size();
+    }
+
+    // Otherwise, return 0 (as this is a list model, so all items
+    // are children of the root item).
+    return 0;
+}
+
+QVariant ProfileListModel::data(const QModelIndex &index, int role) const
+{
+    // FIXME: This is a basic implementation just so I can see what's going
+    // on while developing this code further. Needs expanding.
+    QVariant data;
+
+    switch(role)
+    {
+    case Qt::DisplayRole:
+        data = QVariant(m_profileItems.at(index.row())->localizedName());
+        break;
+    case Qt::DecorationRole:
+        // Look for an icon named im-<iconname>
+        data = QVariant(KIcon((QString("im-%1").arg(m_profileItems.at(index.row())->iconName()))));
+        break;
+    default:
+        break;
+    }
+
+    return data;
+}
+
+void ProfileListModel::setProfileManager(Tp::ProfileManagerPtr profileManager)
+{
+    kDebug() << "Setting ProfileManager to:"
+             << profileManager.data();
+
+    foreach (ProfileItem *item, m_profileItems) {
+        delete item;
+        item = 0;
+    }
+
+    beginInsertRows(QModelIndex(), 0, profileManager.data()->profiles().size());
+    foreach(Tp::ProfilePtr ptr, profileManager.data()->profiles()) {
+        m_profileItems.append(new ProfileItem(ptr, this));
+        Tp::Profile::ParameterList list = ptr.data()->parameters();
+        foreach(Tp::Profile::Parameter parameter, list)
+        {
+            kDebug() << parameter.name();
+        }
+
+        kDebug() << "list size is" << list.size();
+    }
+
+
+
+    endInsertRows();
+}
+
+ProfileItem *ProfileListModel::itemForIndex(const QModelIndex &index) const
+{
+    return m_profileItems.at(index.row());
+}
+
+
+#include "profile-list-model.moc"
+
diff --git a/src/KCMTelepathyAccounts/protocol-list-model.h b/src/KCMTelepathyAccounts/profile-list-model.h
similarity index 62%
rename from src/KCMTelepathyAccounts/protocol-list-model.h
rename to src/KCMTelepathyAccounts/profile-list-model.h
index 3718e8f..a48f69d 100644
--- a/src/KCMTelepathyAccounts/protocol-list-model.h
+++ b/src/KCMTelepathyAccounts/profile-list-model.h
@@ -18,41 +18,33 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#ifndef TELEPATHY_ACCOUNTS_KCM_PROTOCOL_LIST_MODEL_H
-#define TELEPATHY_ACCOUNTS_KCM_PROTOCOL_LIST_MODEL_H
+#ifndef TELEPATHY_ACCOUNTS_KCM_PROFILE_LIST_MODEL_H
+#define TELEPATHY_ACCOUNTS_KCM_PROFILE_LIST_MODEL_H
 
 #include <QtCore/QAbstractListModel>
 
 #include <TelepathyQt4/ConnectionManager>
 
-class ProtocolItem;
-class ConnectionManagerItem;
+class ProfileItem;
 
-class ProtocolListModel : public QAbstractListModel
+class ProfileListModel : public QAbstractListModel
 {
     Q_OBJECT
-    Q_DISABLE_COPY(ProtocolListModel);
+    Q_DISABLE_COPY(ProfileListModel);
 
 public:
-    explicit ProtocolListModel(QObject *parent = 0);
-    virtual ~ProtocolListModel();
+    explicit ProfileListModel(QObject *parent = 0);
+    virtual ~ProfileListModel();
 
     virtual int rowCount(const QModelIndex &index) const;
     virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
 
-    ProtocolItem *itemForIndex(const QModelIndex &index) const;
+    ProfileItem *itemForIndex(const QModelIndex &index) const;
 
-    void addConnectionManager(Tp::ConnectionManagerPtr connectionManager);
-    void addProtocolItem(ProtocolItem *item);
-
-
-
-private Q_SLOTS:
-    void onNewProtocol(const QString& protocol);
+    void setProfileManager(Tp::ProfileManagerPtr profileManager);
 
 private:
-    QList<ConnectionManagerItem*> m_connectionManagerItems;
-    QList<ProtocolItem*> m_protocolItems;
+    QList<ProfileItem*> m_profileItems;
 };
 
 
diff --git a/src/KCMTelepathyAccounts/profile-select-widget.cpp b/src/KCMTelepathyAccounts/profile-select-widget.cpp
new file mode 100644
index 0000000..92deee2
--- /dev/null
+++ b/src/KCMTelepathyAccounts/profile-select-widget.cpp
@@ -0,0 +1,131 @@
+/*
+ * This file is part of telepathy-accounts-kcm
+ *
+ * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "profile-select-widget.h"
+
+#include "profile-item.h"
+#include "profile-list-model.h"
+
+#include "ui_profile-select-widget.h"
+
+#include <KDebug>
+
+#include <TelepathyQt4/PendingReady>
+#include <TelepathyQt4/ProfileManager>
+#include <TelepathyQt4/Feature>
+
+class ProfileSelectWidget::Private
+{
+public:
+    Private()
+     : profileManager(0),
+       ui(0),
+       model(0)
+    {
+        kDebug();
+    }
+
+    Tp::ProfileManagerPtr profileManager;
+    Ui::ProfileSelectWidget *ui;
+    ProfileListModel *model;
+};
+
+ProfileSelectWidget::ProfileSelectWidget(QWidget *parent)
+ : QWidget(parent),
+   d(new Private)
+{
+    kDebug();
+
+    // Set up the widget
+    d->model = new ProfileListModel(this);
+
+    d->ui = new Ui::ProfileSelectWidget;
+    d->ui->setupUi(this);
+    d->ui->profileListView->setModel(d->model);
+
+    connect(d->ui->profileListView->selectionModel(),
+            SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
+            SLOT(onSelectionChanged(const QItemSelection &)));
+    connect(d->ui->profileListView,
+            SIGNAL(doubleClicked(QModelIndex)),
+            SIGNAL(profileDoubleClicked()));
+
+    d->profileManager = Tp::ProfileManager::create(QDBusConnection::sessionBus());
+    // Until all distros ship correct profile files, we should fake them
+    connect(d->profileManager.data()->becomeReady(Tp::Features() << Tp::ProfileManager::FeatureFakeProfiles),
+            SIGNAL(finished(Tp::PendingOperation*)),
+            SLOT(onProfileManagerReady(Tp::PendingOperation*)));
+}
+
+ProfileSelectWidget::~ProfileSelectWidget()
+{
+    kDebug();
+
+    delete d->ui;
+    delete d;
+}
+
+
+void ProfileSelectWidget::onProfileManagerReady(Tp::PendingOperation *op)
+{
+    kDebug();
+
+    // Check the pending operation completed successfully.
+    if (op->isError()) {
+        kDebug() << "becomeReady() failed:" << op->errorName() << op->errorMessage();
+        return;
+    }
+
+    d->model->setProfileManager(d->profileManager);
+}
+
+// Return the selected ProfileItem or 0 if nothing is selected.
+ProfileItem *ProfileSelectWidget::selectedProfile()
+{
+    kDebug();
+
+    // Get the indexes of the selected items from the view
+    QModelIndexList selectedIndexes = d->ui->profileListView->selectionModel()->selectedIndexes();
+
+    // If more than 1 profile is selected (shouldn't be possible, but just in case) error.
+    if (selectedIndexes.size() > 1) {
+        kWarning() << "More than 1 profile is selected.";
+        return 0;
+    }
+
+    // If no indexes are selected, return 0.
+    if (selectedIndexes.size() == 0) {
+        return 0;
+    }
+
+    // 1 index is selected. Return the Pr for that.
+    return d->model->itemForIndex(selectedIndexes.at(0));
+}
+
+void ProfileSelectWidget::onSelectionChanged(const QItemSelection &selected)
+{
+    kDebug();
+
+    Q_EMIT profileGotSelected(!selected.isEmpty());
+}
+
+
+#include "profile-select-widget.moc"
+
diff --git a/src/KCMTelepathyAccounts/protocol-select-widget.h b/src/KCMTelepathyAccounts/profile-select-widget.h
similarity index 71%
rename from src/KCMTelepathyAccounts/protocol-select-widget.h
rename to src/KCMTelepathyAccounts/profile-select-widget.h
index ca0bd8a..e0d04c9 100644
--- a/src/KCMTelepathyAccounts/protocol-select-widget.h
+++ b/src/KCMTelepathyAccounts/profile-select-widget.h
@@ -18,40 +18,39 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#ifndef TELEPATHY_ACCOUNTS_KCM_PROTOCOL_SELECT_WIDGET_H
-#define TELEPATHY_ACCOUNTS_KCM_PROTOCOL_SELECT_WIDGET_H
+#ifndef TELEPATHY_ACCOUNTS_KCM_PROFILE_SELECT_WIDGET_H
+#define TELEPATHY_ACCOUNTS_KCM_PROFILE_SELECT_WIDGET_H
 
 #include <kdemacros.h>
 
 #include <QtGui/QWidget>
 
-class ProtocolItem;
-class QItemSelection;
-
-class QModelIndex;
-
 namespace Tp {
     class PendingOperation;
 }
 
-class KDE_EXPORT ProtocolSelectWidget : public QWidget
+class ProfileItem;
+class QItemSelection;
+
+class QModelIndex;
+
+class KDE_EXPORT ProfileSelectWidget : public QWidget
 {
     Q_OBJECT
 
 public:
-    explicit ProtocolSelectWidget(QWidget *parent = 0);
-    ~ProtocolSelectWidget();
+    explicit ProfileSelectWidget(QWidget *parent = 0);
+    ~ProfileSelectWidget();
 
-    ProtocolItem *selectedProtocol();
+    ProfileItem *selectedProfile();
 
 private Q_SLOTS:
-    void getConnectionManagerList();
-    void onConnectionManagerListGot(Tp::PendingOperation *op);
+    void onProfileManagerReady(Tp::PendingOperation *op);
     void onSelectionChanged(const QItemSelection &selected);
 
 Q_SIGNALS:
-    void protocolGotSelected(bool selected);
-    void protocolDoubleClicked();
+    void profileGotSelected(bool selected);
+    void profileDoubleClicked();
 
 private:
     class Private;
diff --git a/src/KCMTelepathyAccounts/protocol-select-widget.ui b/src/KCMTelepathyAccounts/profile-select-widget.ui
similarity index 69%
rename from src/KCMTelepathyAccounts/protocol-select-widget.ui
rename to src/KCMTelepathyAccounts/profile-select-widget.ui
index d6aee67..d462a42 100644
--- a/src/KCMTelepathyAccounts/protocol-select-widget.ui
+++ b/src/KCMTelepathyAccounts/profile-select-widget.ui
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <ui version="4.0">
- <class>ProtocolSelectWidget</class>
- <widget class="QWidget" name="ProtocolSelectWidget">
+ <class>ProfileSelectWidget</class>
+ <widget class="QWidget" name="ProfileSelectWidget">
   <property name="geometry">
    <rect>
     <x>0</x>
@@ -12,7 +12,7 @@
   </property>
   <layout class="QVBoxLayout" name="verticalLayout_2">
    <item>
-    <widget class="QListView" name="protocolListView"/>
+    <widget class="QListView" name="profileListView"/>
    </item>
   </layout>
  </widget>
diff --git a/src/KCMTelepathyAccounts/protocol-list-model.cpp b/src/KCMTelepathyAccounts/protocol-list-model.cpp
deleted file mode 100644
index 168c6c5..0000000
--- a/src/KCMTelepathyAccounts/protocol-list-model.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * This file is part of telepathy-accounts-kcm
- *
- * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include "protocol-list-model.h"
-
-#include "connection-manager-item.h"
-#include "protocol-item.h"
-
-#include <KIcon>
-#include <KDebug>
-
-ProtocolListModel::ProtocolListModel(QObject *parent)
- : QAbstractListModel(parent)
-{
-    kDebug();
-
-    m_connectionManagerItems.clear();
-    m_protocolItems.clear();
-}
-
-ProtocolListModel::~ProtocolListModel()
-{
-    kDebug();
-
-    // TODO: Implement me!
-}
-
-int ProtocolListModel::rowCount(const QModelIndex &index) const
-{
-    // If the index is the root item, then return the row count.
-    if (index == QModelIndex()) {
-       return m_protocolItems.size();
-    }
-
-    // Otherwise, return 0 (as this is a list model, so all items
-    // are children of the root item).
-    return 0;
-}
-
-QVariant ProtocolListModel::data(const QModelIndex &index, int role) const
-{
-    // FIXME: This is a basic implementation just so I can see what's going
-    // on while developing this code further. Needs expanding.
-    QVariant data;
-
-    switch(role)
-    {
-    case Qt::DisplayRole:
-        data = QVariant(m_protocolItems.at(index.row())->localizedName());
-        break;
-    case Qt::DecorationRole:
-        // Look for an icon named im-<protocolname>
-        data = QVariant(KIcon((QString("im-%1").arg(m_protocolItems.at(index.row())->protocol()))));
-        break;
-    default:
-        break;
-    }
-
-    return data;
-}
-
-void ProtocolListModel::addConnectionManager(Tp::ConnectionManagerPtr connectionManager)
-{
-    kDebug() << "Creating a new ConnectionManagerItem from connection manager:"
-             << connectionManager.data();
-
-    // Check if the cm is already in the list.
-    foreach (const ConnectionManagerItem* cmi, m_connectionManagerItems) {
-        if (cmi->connectionManager() == connectionManager) {
-            kWarning() << "Connection Manager: "
-                       << cmi->connectionManager()->name()
-                       << " is already in the list.";
-            return;
-        }
-    }
-
-    kDebug() << "Connection Manager not already in list. Create new ConnectionManagerItem from cm:"
-             << connectionManager.data();
-
-    ConnectionManagerItem *item = new ConnectionManagerItem(connectionManager, this);
-    m_connectionManagerItems.append(item);
-
-    connect(item, SIGNAL(newProtocol(const QString&)),
-            this, SLOT(onNewProtocol(const QString&)));
-}
-
-
-void ProtocolListModel::onNewProtocol(const QString& protocol)
-{
-    kDebug();
-
-    // New protocol supported by a connection manager. Get the ConnectionManagerItem for it.
-    ConnectionManagerItem *cmItem = qobject_cast<ConnectionManagerItem*>(sender());
-    if (!cmItem) {
-        kWarning() << "Slot was called by a non-ConnectionManagerItem object.";
-        return;
-    }
-
-    // Check that the protocol/cm pair are not already in the model.
-    foreach (ProtocolItem *pi, m_protocolItems) {
-        if ((pi->parent() == cmItem) && (pi->protocol() == protocol)) {
-            kWarning() << "Protocol/CM pair already in the model.";
-            return;
-        }
-    }
-
-    // Add the Protocol/CM pair to the model.
-    beginInsertRows(QModelIndex(), m_protocolItems.size(), m_protocolItems.size());
-    ProtocolItem *item = new ProtocolItem(protocol, cmItem);
-    m_protocolItems.append(item);
-    endInsertRows();
-}
-
-ProtocolItem *ProtocolListModel::itemForIndex(const QModelIndex &index) const
-{
-    return m_protocolItems.at(index.row());
-}
-
-
-#include "protocol-list-model.moc"
-
diff --git a/src/KCMTelepathyAccounts/protocol-select-widget.cpp b/src/KCMTelepathyAccounts/protocol-select-widget.cpp
deleted file mode 100644
index f53c5b7..0000000
--- a/src/KCMTelepathyAccounts/protocol-select-widget.cpp
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * This file is part of telepathy-accounts-kcm
- *
- * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include "protocol-select-widget.h"
-
-#include "protocol-item.h"
-#include "protocol-list-model.h"
-
-#include "ui_protocol-select-widget.h"
-
-#include <KDebug>
-
-#include <TelepathyQt4/ConnectionManager>
-#include <TelepathyQt4/PendingOperation>
-#include <TelepathyQt4/PendingStringList>
-
-class ProtocolSelectWidget::Private
-{
-public:
-    Private()
-     : ui(0),
-       model(0)
-    {
-        kDebug();
-    }
-
-    Ui::ProtocolSelectWidget *ui;
-    ProtocolListModel *model;
-};
-
-ProtocolSelectWidget::ProtocolSelectWidget(QWidget *parent)
- : QWidget(parent),
-   d(new Private)
-{
-    kDebug();
-
-    // Set up the widget
-    d->model = new ProtocolListModel(this);
-
-    d->ui = new Ui::ProtocolSelectWidget;
-    d->ui->setupUi(this);
-    d->ui->protocolListView->setModel(d->model);
-
-    connect(d->ui->protocolListView->selectionModel(),
-            SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
-            SLOT(onSelectionChanged(const QItemSelection &)));
-    connect(d->ui->protocolListView,
-            SIGNAL(doubleClicked(QModelIndex)),
-            SIGNAL(protocolDoubleClicked()));
-
-    // Load the list of all installed Telepathy Connection Managers Asynchronously
-    QTimer::singleShot(0, this, SLOT(getConnectionManagerList()));
-}
-
-ProtocolSelectWidget::~ProtocolSelectWidget()
-{
-    kDebug();
-
-    delete d->ui;
-    delete d;
-}
-
-void ProtocolSelectWidget::getConnectionManagerList()
-{
-    kDebug();
-
-    // Ask TpQt4 for the list of all installed Connection Managers.
-    Tp::PendingStringList *psl = Tp::ConnectionManager::listNames();
-
-    connect(psl,
-            SIGNAL(finished(Tp::PendingOperation*)),
-            SLOT(onConnectionManagerListGot(Tp::PendingOperation*)));
-}
-
-void ProtocolSelectWidget::onConnectionManagerListGot(Tp::PendingOperation *op)
-{
-    kDebug();
-
-    // Check the operation completed successfully.
-    if (op->isError()) {
-        kWarning() << "Operation failed:" << op->errorName() << op->errorMessage();
-        return;
-    }
-
-    // Check the operation we were passed is of the correct type.
-    Tp::PendingStringList *psl = qobject_cast<Tp::PendingStringList*>(op);
-    if (!psl) {
-        kWarning() << "Operation is not of type PendingStringList.";
-        return;
-    }
-
-    foreach (QString cmName, psl->result()) {
-        // Add the CM to the ProtocolListModel
-        d->model->addConnectionManager(Tp::ConnectionManager::create(cmName));
-    }
-}
-
-// Return the selected ProtocolItem or 0 if nothing is selected.
-ProtocolItem *ProtocolSelectWidget::selectedProtocol()
-{
-    kDebug();
-
-    // Get the indexes of the selected items from the view
-    QModelIndexList selectedIndexes = d->ui->protocolListView->selectionModel()->selectedIndexes();
-
-    // If more than 1 protocol is selected (shouldn't be possible, but just in case) error.
-    if (selectedIndexes.size() > 1) {
-        kWarning() << "More than 1 protocol is selected.";
-        return 0;
-    }
-
-    // If no indexes are selected, return 0.
-    if (selectedIndexes.size() == 0) {
-        return 0;
-    }
-
-    // 1 index is selected. Return the ProtocolItem for that.
-    return d->model->itemForIndex(selectedIndexes.at(0));
-}
-
-void ProtocolSelectWidget::onSelectionChanged(const QItemSelection &selected)
-{
-    kDebug();
-
-    Q_EMIT protocolGotSelected(!selected.isEmpty());
-}
-
-
-#include "protocol-select-widget.moc"
-
diff --git a/src/add-account-assistant.cpp b/src/add-account-assistant.cpp
index 184cf93..a269bbd 100644
--- a/src/add-account-assistant.cpp
+++ b/src/add-account-assistant.cpp
@@ -25,8 +25,8 @@
 #include "KCMTelepathyAccounts/account-edit-widget.h"
 #include "KCMTelepathyAccounts/connection-manager-item.h"
 #include "KCMTelepathyAccounts/plugin-manager.h"
-#include "KCMTelepathyAccounts/protocol-item.h"
-#include "KCMTelepathyAccounts/protocol-select-widget.h"
+#include "KCMTelepathyAccounts/profile-item.h"
+#include "KCMTelepathyAccounts/profile-select-widget.h"
 
 #include <KDebug>
 #include <KLocale>
@@ -43,7 +43,7 @@ class AddAccountAssistant::Private
 {
 public:
     Private()
-     : protocolSelectWidget(0),
+     : profileSelectWidget(0),
        accountEditWidget(0),
        pageOne(0),
        pageTwo(0)
@@ -53,7 +53,7 @@ public:
 
     Tp::AccountManagerPtr accountManager;
     Tp::AccountPtr account;
-    ProtocolSelectWidget *protocolSelectWidget;
+    ProfileSelectWidget *profileSelectWidget;
     AccountEditWidget *accountEditWidget;
     QWidget *pageTwoWidget;
     KPageWidgetItem *pageOne;
@@ -69,15 +69,15 @@ AddAccountAssistant::AddAccountAssistant(Tp::AccountManagerPtr accountManager, Q
     d->accountManager = accountManager;
 
     // Set up the pages of the Assistant.
-    d->protocolSelectWidget = new ProtocolSelectWidget(this);
-    d->pageOne = new KPageWidgetItem(d->protocolSelectWidget);
+    d->profileSelectWidget = new ProfileSelectWidget(this);
+    d->pageOne = new KPageWidgetItem(d->profileSelectWidget);
     d->pageOne->setHeader(i18n("Step 1: Select an Instant Messaging Network."));
     setValid(d->pageOne, false);
-    connect(d->protocolSelectWidget,
-            SIGNAL(protocolGotSelected(bool)),
-            SLOT(onProtocolSelected(bool)));
-    connect(d->protocolSelectWidget,
-            SIGNAL(protocolDoubleClicked()),
+    connect(d->profileSelectWidget,
+            SIGNAL(profileGotSelected(bool)),
+            SLOT(onProfileSelected(bool)));
+    connect(d->profileSelectWidget,
+            SIGNAL(profileDoubleClicked()),
             SLOT(next()));
 
     // we will build the page widget later, but the constructor of
@@ -111,11 +111,11 @@ void AddAccountAssistant::next()
     if (currentPage() == d->pageOne) {
         kDebug() << "Current page: Page 1.";
 
-        Q_ASSERT(d->protocolSelectWidget->selectedProtocol());
+        Q_ASSERT(d->profileSelectWidget->selectedProfile());
 
         // Set up the next page.
-        ProtocolItem *item = d->protocolSelectWidget->selectedProtocol();
-
+        ProfileItem *item = d->profileSelectWidget->selectedProfile();
+/*
         ConnectionManagerItem *cmItem = qobject_cast<ConnectionManagerItem*>(item->parent());
         if (!cmItem) {
             kWarning() << "cmItem is invalid.";
@@ -132,7 +132,7 @@ void AddAccountAssistant::next()
                                                      QVariantMap(),
                                                      d->pageTwoWidget);
         d->pageTwoWidget->layout()->addWidget(d->accountEditWidget);
-
+*/
         KAssistantDialog::next();
     }
 }
@@ -158,13 +158,13 @@ void AddAccountAssistant::accept()
     parameterValues = d->accountEditWidget->parameterValues();
 
     // Get the ProtocolItem that was selected and the corresponding ConnectionManagerItem.
-    ProtocolItem *protocolItem = d->protocolSelectWidget->selectedProtocol();
-    ConnectionManagerItem *connectionManagerItem = qobject_cast<ConnectionManagerItem*>(protocolItem->parent());
+    //ProtocolItem *protocolItem = d->protocolSelectWidget->selectedProtocol();
+    //ConnectionManagerItem *connectionManagerItem = qobject_cast<ConnectionManagerItem*>(protocolItem->parent());
 
-    if (!connectionManagerItem) {
-        kWarning() << "Invalid ConnectionManager item.";
-        return;
-    }
+    //if (!connectionManagerItem) {
+    //    kWarning() << "Invalid ConnectionManager item.";
+    //    return;
+    //}
 
     QVariantMap values;
     foreach(const ProtocolParameterValue &ppv, parameterValues)
@@ -174,6 +174,7 @@ void AddAccountAssistant::accept()
         }
     }
 
+    /*
     // FIXME: Ask the user to submit a Display Name
     Tp::PendingAccount *pa = d->accountManager->createAccount(connectionManagerItem->connectionManager()->name(),
                                                               protocolItem->protocol(),
@@ -183,6 +184,7 @@ void AddAccountAssistant::accept()
     connect(pa,
             SIGNAL(finished(Tp::PendingOperation*)),
             SLOT(onAccountCreated(Tp::PendingOperation*)));
+            */
 }
 
 void AddAccountAssistant::reject()
@@ -242,7 +244,7 @@ void AddAccountAssistant::onSetEnabledFinished(Tp::PendingOperation *op)
     KAssistantDialog::accept();
 }
 
-void AddAccountAssistant::onProtocolSelected(bool value)
+void AddAccountAssistant::onProfileSelected(bool value)
 {
     kDebug();
     //if a protocol is selected, enable the next button on the first page
diff --git a/src/add-account-assistant.h b/src/add-account-assistant.h
index b16d76b..17a0206 100644
--- a/src/add-account-assistant.h
+++ b/src/add-account-assistant.h
@@ -48,7 +48,7 @@ Q_SIGNALS:
 private Q_SLOTS:
     void onAccountCreated(Tp::PendingOperation *op);
     void onSetEnabledFinished(Tp::PendingOperation *op);
-    void onProtocolSelected(bool value);
+    void onProfileSelected(bool value);
 
 private:
     class Private;

-- 
ktp-accounts-kcm packaging



More information about the pkg-kde-commits mailing list