[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:52 UTC 2016


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

The following commit has been merged in the master branch:
commit 6b97c7adf4b83acacb486fad7d533aa2537d8689
Author: Thomas Richard <thomas9999 at gmail.com>
Date:   Fri Jan 14 19:32:16 2011 +0100

    Integrate the use of profiles in the new AbstractAccountParametersWidget
    Fix creation of new accounts
    Add the use of profiles in the AccountManager
    Various other profile related changes
---
 src/KCMTelepathyAccounts/CMakeLists.txt            |   2 -
 .../abstract-account-parameters-widget.cpp         |  11 ++
 .../abstract-account-parameters-widget.h           |   2 +
 src/KCMTelepathyAccounts/abstract-account-ui.cpp   |   2 +
 src/KCMTelepathyAccounts/abstract-account-ui.h     |   2 +
 src/KCMTelepathyAccounts/account-edit-widget.cpp   |  22 +++-
 src/KCMTelepathyAccounts/account-edit-widget.h     |   2 +-
 .../connection-manager-item.cpp                    |  77 -------------
 src/KCMTelepathyAccounts/connection-manager-item.h |  59 ----------
 src/KCMTelepathyAccounts/dictionary.cpp            |   1 +
 .../generic-advanced-options-widget.cpp            |   4 +-
 .../generic-advanced-options-widget.h              |   2 +-
 src/KCMTelepathyAccounts/parameter-edit-model.cpp  |  13 ++-
 src/KCMTelepathyAccounts/parameter-edit-model.h    |   4 +
 src/KCMTelepathyAccounts/parameter-edit-widget.cpp |   2 +-
 src/KCMTelepathyAccounts/parameter-item.cpp        |   2 -
 src/KCMTelepathyAccounts/profile-item.cpp          |  15 ++-
 src/KCMTelepathyAccounts/profile-item.h            |   3 +
 src/KCMTelepathyAccounts/profile-list-model.cpp    |   9 +-
 src/KCMTelepathyAccounts/profile-list-model.h      |   1 +
 src/KCMTelepathyAccounts/profile-select-widget.cpp |   3 +-
 src/KCMTelepathyAccounts/profile-select-widget.h   |   1 +
 src/account-item.cpp                               |   2 +-
 src/add-account-assistant.cpp                      | 126 +++++++++++----------
 src/add-account-assistant.h                        |   5 +-
 src/edit-account-dialog.cpp                        |   2 +-
 src/kcm-telepathy-accounts.cpp                     |   3 +-
 27 files changed, 148 insertions(+), 229 deletions(-)

diff --git a/src/KCMTelepathyAccounts/CMakeLists.txt b/src/KCMTelepathyAccounts/CMakeLists.txt
index 87d9ea5..ce76860 100644
--- a/src/KCMTelepathyAccounts/CMakeLists.txt
+++ b/src/KCMTelepathyAccounts/CMakeLists.txt
@@ -12,7 +12,6 @@ set (libkcmtelepathyaccounts_SRCS
      account-edit-widget.cpp
      profile-select-widget.cpp
      profile-list-model.cpp
-     connection-manager-item.cpp
      profile-item.cpp
      parameter-edit-widget.cpp
      parameter-edit-delegate.cpp
@@ -30,7 +29,6 @@ set (libkcmtelepathyaccounts_HDRS
      generic-advanced-options-widget.h
      account-edit-widget.h
      plugin-macros.h
-     connection-manager-item.h
      plugin-manager.h
      profile-select-widget.h
      profile-item.h
diff --git a/src/KCMTelepathyAccounts/abstract-account-parameters-widget.cpp b/src/KCMTelepathyAccounts/abstract-account-parameters-widget.cpp
index fb29cc3..541a465 100644
--- a/src/KCMTelepathyAccounts/abstract-account-parameters-widget.cpp
+++ b/src/KCMTelepathyAccounts/abstract-account-parameters-widget.cpp
@@ -43,10 +43,12 @@ public:
     }
     ParameterEditModel *parameterModel;
     QDataWidgetMapper *mapper;
+    QString profile;
     Tp::ProtocolParameterList parameters;
 };
 
 AbstractAccountParametersWidget::AbstractAccountParametersWidget(ParameterEditModel *parameterModel,
+                                                                 const QString &profile,
                                                                  QWidget *parent)
         : QWidget(parent),
           d(new Private)
@@ -59,6 +61,8 @@ AbstractAccountParametersWidget::AbstractAccountParametersWidget(ParameterEditMo
     d->mapper->setModel(d->parameterModel);
 
     d->mapper->setOrientation(Qt::Vertical);
+
+    d->profile = profile;
 }
 
 AbstractAccountParametersWidget::~AbstractAccountParametersWidget()
@@ -112,9 +116,11 @@ void AbstractAccountParametersWidget::handleParameter(const QString &parameterNa
     if(!foundParameter.isValid() || foundParameter.type() != parameterType)
     {
         // hide widgets because they are not needed
+        kDebug() << "WARNING: Field" << parameterName << "hidden";
         dataWidget->hide();
         foreach(QWidget *label, labelWidgets)
         {
+
             if(label) {
                 label->hide();
             }
@@ -136,6 +142,11 @@ ParameterEditModel* AbstractAccountParametersWidget::parameterModel() const
     return d->parameterModel;
 }
 
+QString AbstractAccountParametersWidget::profile() const
+{
+    return d->profile;
+}
+
 
 #include "abstract-account-parameters-widget.moc"
 
diff --git a/src/KCMTelepathyAccounts/abstract-account-parameters-widget.h b/src/KCMTelepathyAccounts/abstract-account-parameters-widget.h
index 6071de3..d43705e 100644
--- a/src/KCMTelepathyAccounts/abstract-account-parameters-widget.h
+++ b/src/KCMTelepathyAccounts/abstract-account-parameters-widget.h
@@ -43,6 +43,7 @@ class KDE_EXPORT AbstractAccountParametersWidget : public QWidget
 
 public:
     explicit AbstractAccountParametersWidget(ParameterEditModel *parameterModel,
+                                             const QString &profile,
                                              QWidget *parent = 0);
     virtual ~AbstractAccountParametersWidget();
 
@@ -61,6 +62,7 @@ protected:
                          QWidget *labelWidget);
 
     ParameterEditModel *parameterModel() const;
+    QString profile() const;
 
 private:
     Q_DISABLE_COPY(AbstractAccountParametersWidget);
diff --git a/src/KCMTelepathyAccounts/abstract-account-ui.cpp b/src/KCMTelepathyAccounts/abstract-account-ui.cpp
index 500452b..66285b2 100644
--- a/src/KCMTelepathyAccounts/abstract-account-ui.cpp
+++ b/src/KCMTelepathyAccounts/abstract-account-ui.cpp
@@ -54,10 +54,12 @@ bool AbstractAccountUi::hasAdvancedOptionsWidget() const
 }
 
 AbstractAccountParametersWidget* AbstractAccountUi::advancedOptionsWidget(ParameterEditModel *parameterModel,
+                                                                          const QString &profile,
                                                                           QWidget *parent) const
 {
     Q_UNUSED(parameterModel);
     Q_UNUSED(parent);
+    Q_UNUSED(profile);
     return 0;
 }
 
diff --git a/src/KCMTelepathyAccounts/abstract-account-ui.h b/src/KCMTelepathyAccounts/abstract-account-ui.h
index a86ce69..48628ef 100644
--- a/src/KCMTelepathyAccounts/abstract-account-ui.h
+++ b/src/KCMTelepathyAccounts/abstract-account-ui.h
@@ -45,10 +45,12 @@ public:
 
     virtual AbstractAccountParametersWidget
               *mainOptionsWidget(ParameterEditModel *parameterModel,
+                                 const QString &profile,
                                  QWidget *parent = 0) const = 0;
     virtual bool hasAdvancedOptionsWidget() const;
     virtual AbstractAccountParametersWidget
               *advancedOptionsWidget(ParameterEditModel *parameterModel,
+                                     const QString &profile,
                                      QWidget *parent = 0) const;
 
 protected:
diff --git a/src/KCMTelepathyAccounts/account-edit-widget.cpp b/src/KCMTelepathyAccounts/account-edit-widget.cpp
index 224dab9..8ac0f64 100644
--- a/src/KCMTelepathyAccounts/account-edit-widget.cpp
+++ b/src/KCMTelepathyAccounts/account-edit-widget.cpp
@@ -31,6 +31,7 @@
 #include <KDebug>
 #include <KLocale>
 
+#include <TelepathyQt4/Profile>
 #include <QtCore/QList>
 
 class AccountEditWidget::Private
@@ -44,6 +45,7 @@ public:
 
     QString connectionManager;
     QString protocol;
+    QString profileName;
 
     ParameterEditModel *parameterModel;
 
@@ -52,7 +54,7 @@ public:
     AbstractAccountParametersWidget *mainOptionsWidget;
 };
 
-AccountEditWidget::AccountEditWidget(const Tp::ProtocolInfo &info,
+AccountEditWidget::AccountEditWidget(const Tp::ProfilePtr &profile,
                                      ParameterEditModel *parameterModel,
                                      QWidget *parent)
         : QWidget(parent),
@@ -65,16 +67,22 @@ AccountEditWidget::AccountEditWidget(const Tp::ProtocolInfo &info,
     d->ui->setupUi(this);
 
     d->parameterModel = parameterModel;
-    d->connectionManager = info.cmName();
-    d->protocol = info.name();
+    d->profileName = profile.data()->serviceName();
+    d->connectionManager = profile.data()->cmName();
+    d->protocol = profile.data()->protocolName();
 
     connect(d->ui->advancedButton, SIGNAL(clicked()),
             this, SLOT(onAdvancedClicked()));
 
     d->ui->advancedButton->setIcon(KIcon("configure"));
-    d->ui->titleLabel->setText(Dictionary::instance()->string(info.name()));
+    //FIXME: Dictionary should not be needed anymore when distros ship profiles
+    QString localizedName = Dictionary::instance()->string(profile.data()->name());
+    if(localizedName.isEmpty()) {
+        localizedName = profile.data()->name();
+    }
+    d->ui->titleLabel->setText(localizedName);
     d->ui->iconLabel->setText("");
-    d->ui->iconLabel->setPixmap(KIcon(info.iconName()).pixmap(32));
+    d->ui->iconLabel->setPixmap(KIcon(profile.data()->iconName()).pixmap(32));
 
     loadWidgets();
 }
@@ -120,6 +128,7 @@ void AccountEditWidget::loadWidgets()
     if (d->accountUi) {
         // UI does exist, set it up.
         d->mainOptionsWidget = d->accountUi->mainOptionsWidget(d->parameterModel,
+                                                               d->profileName,
                                                                this);
         //Widgets wrapped in a layout should not have double margins
         d->mainOptionsWidget->layout()->setContentsMargins(0, 0, 0, 0);
@@ -146,7 +155,7 @@ void AccountEditWidget::loadWidgets()
             ++paramIter;
         }
 
-        // if a parameter is missing or a mandatory parameter is not being handle,
+        // if a parameter is missing or a mandatory parameter is not being handled,
         // fall back to the generic interface.
         // FIXME: not sure this is the best way to handle the situation, but
         //        it is like this in a hope the case won't happen often
@@ -177,6 +186,7 @@ void AccountEditWidget::onAdvancedClicked()
 
     AbstractAccountParametersWidget *advancedWidget;
     advancedWidget = d->accountUi->advancedOptionsWidget(d->parameterModel,
+                                                         d->profileName,
                                                          &dialog);
     dialog.setMainWidget(advancedWidget);
 
diff --git a/src/KCMTelepathyAccounts/account-edit-widget.h b/src/KCMTelepathyAccounts/account-edit-widget.h
index 95e2923..42dcd92 100644
--- a/src/KCMTelepathyAccounts/account-edit-widget.h
+++ b/src/KCMTelepathyAccounts/account-edit-widget.h
@@ -37,7 +37,7 @@ class KDE_EXPORT AccountEditWidget : public QWidget
     Q_OBJECT
 
 public:
-    explicit AccountEditWidget(const Tp::ProtocolInfo &info,
+    explicit AccountEditWidget(const Tp::ProfilePtr &info,
                                ParameterEditModel *parameterModel,
                                QWidget *parent = 0);
     virtual ~AccountEditWidget();
diff --git a/src/KCMTelepathyAccounts/connection-manager-item.cpp b/src/KCMTelepathyAccounts/connection-manager-item.cpp
deleted file mode 100644
index 5f883d8..0000000
--- a/src/KCMTelepathyAccounts/connection-manager-item.cpp
+++ /dev/null
@@ -1,77 +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 "connection-manager-item.h"
-
-#include "profile-list-model.h"
-
-#include <KDebug>
-
-#include <TelepathyQt4/PendingOperation>
-#include <TelepathyQt4/PendingReady>
-/*
-ConnectionManagerItem::ConnectionManagerItem(const Tp::ConnectionManagerPtr &connectionManager,
-                                             ProtocolListModel *parent)
- : QObject(parent),
-   m_connectionManager(connectionManager)
-{
-    kDebug();
-
-    // Get the connection manager ready
-    connect(m_connectionManager->becomeReady(Tp::ConnectionManager::FeatureCore),
-            SIGNAL(finished(Tp::PendingOperation*)),
-            SLOT(onConnectionManagerReady(Tp::PendingOperation*)));
-}
-
-ConnectionManagerItem::~ConnectionManagerItem()
-{
-    kDebug();
-
-    // TODO: Implement me...
-}
-
-Tp::ConnectionManagerPtr ConnectionManagerItem::connectionManager() const
-{
-    kDebug();
-
-    return m_connectionManager;
-}
-
-void ConnectionManagerItem::onConnectionManagerReady(Tp::PendingOperation *op)
-{
-    kDebug();
-
-    if (op->isError()) {
-        kDebug() << "An error occurred in making the Connection Manager ready."
-                 << op->errorName()
-                 << op->errorMessage();
-        return;
-    }
-
-    // Emit the protocol() signal for every protocol supported by this connection manager.
-    foreach (const QString &protocol, m_connectionManager->supportedProtocols()) {
-        Q_EMIT newProtocol(protocol);
-    }
-}
-
-
-#include "connection-manager-item.moc"
-
-*/
diff --git a/src/KCMTelepathyAccounts/connection-manager-item.h b/src/KCMTelepathyAccounts/connection-manager-item.h
deleted file mode 100644
index 93b0a97..0000000
--- a/src/KCMTelepathyAccounts/connection-manager-item.h
+++ /dev/null
@@ -1,59 +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
- */
-
-#ifndef TELEPATHY_ACCOUNTS_KCM_CONNECTION_MANAGER_ITEM_H
-#define TELEPATHY_ACCOUNTS_KCM_CONNECTION_MANAGER_ITEM_H
-
-#include <kdemacros.h>
-
-#include <QtCore/QObject>
-
-#include <TelepathyQt4/ConnectionManager>
-/*
-class ProtocolListModel;
-
-namespace Tp {
-    class PendingOperation;
-}
-
-class KDE_EXPORT ConnectionManagerItem : public QObject
-{
-    Q_OBJECT
-    Q_DISABLE_COPY(ConnectionManagerItem);
-
-public:
-    explicit ConnectionManagerItem(const Tp::ConnectionManagerPtr &connectionManager,
-                                   ProtocolListModel *parent = 0);
-    virtual ~ConnectionManagerItem();
-    Tp::ConnectionManagerPtr connectionManager() const;
-
-Q_SIGNALS:
-    void newProtocol(const QString &protocol);
-
-private Q_SLOTS:
-    void onConnectionManagerReady(Tp::PendingOperation *op);
-
-private:
-    Tp::ConnectionManagerPtr m_connectionManager;
-};
-*/
-
-#endif // header guard
-
diff --git a/src/KCMTelepathyAccounts/dictionary.cpp b/src/KCMTelepathyAccounts/dictionary.cpp
index 2eeff58..4d7b609 100644
--- a/src/KCMTelepathyAccounts/dictionary.cpp
+++ b/src/KCMTelepathyAccounts/dictionary.cpp
@@ -71,6 +71,7 @@ Dictionary::Dictionary()
     m_strings.insert("sip", i18n("Session Initiation Protocol (SIP)"));
     m_strings.insert("trepia", i18n("Trepia"));
     m_strings.insert("yahoo", i18n("Yahoo! Messenger"));
+    m_strings.insert("yahoojp", i18n("Yahoo! Messenger Japan"));
     m_strings.insert("zephyr", i18n("Zephyr"));
 }
 
diff --git a/src/KCMTelepathyAccounts/generic-advanced-options-widget.cpp b/src/KCMTelepathyAccounts/generic-advanced-options-widget.cpp
index 0e39b47..cf1444c 100644
--- a/src/KCMTelepathyAccounts/generic-advanced-options-widget.cpp
+++ b/src/KCMTelepathyAccounts/generic-advanced-options-widget.cpp
@@ -41,8 +41,8 @@ public:
 };
 
 GenericAdvancedOptionsWidget::GenericAdvancedOptionsWidget(ParameterEditModel *parameterModel,
-                                             QWidget *parent)
- : AbstractAccountParametersWidget(parameterModel, parent),
+                                                           QWidget *parent)
+ : AbstractAccountParametersWidget(parameterModel, QString(), parent),
    d(new Private)
 {
     QHBoxLayout *layout = new QHBoxLayout(this);
diff --git a/src/KCMTelepathyAccounts/generic-advanced-options-widget.h b/src/KCMTelepathyAccounts/generic-advanced-options-widget.h
index ac5ff02..b40c2ac 100644
--- a/src/KCMTelepathyAccounts/generic-advanced-options-widget.h
+++ b/src/KCMTelepathyAccounts/generic-advanced-options-widget.h
@@ -31,7 +31,7 @@ class KDE_EXPORT GenericAdvancedOptionsWidget : public AbstractAccountParameters
 
 public:
     explicit GenericAdvancedOptionsWidget(ParameterEditModel* model,
-                                   QWidget *parent = 0);
+                                          QWidget *parent = 0);
     virtual ~GenericAdvancedOptionsWidget();
 
     virtual QList<ProtocolParameterValue> parameterValues() const;
diff --git a/src/KCMTelepathyAccounts/parameter-edit-model.cpp b/src/KCMTelepathyAccounts/parameter-edit-model.cpp
index d64fea0..557fe22 100644
--- a/src/KCMTelepathyAccounts/parameter-edit-model.cpp
+++ b/src/KCMTelepathyAccounts/parameter-edit-model.cpp
@@ -31,6 +31,7 @@
 
 #include <QtGui/QValidator>
 
+#include <TelepathyQt4/Profile>
 #include <TelepathyQt4/ConnectionManager>
 
 ParameterEditModel::ParameterEditModel(QObject *parent)
@@ -154,6 +155,17 @@ QModelIndex ParameterEditModel::indexForParameter(const Tp::ProtocolParameter &p
     return QModelIndex();
 }
 
+QModelIndex ParameterEditModel::indexForParameter(const Tp::Profile::Parameter &parameter) const
+{
+    for(int i=0; i<m_items.size(); ++i) {
+        ParameterItem *item = m_items.at(i);
+        if(item->parameter().name() == parameter.name() && item->parameter().type() == parameter.type()) {
+            return createIndex(i,0);
+        }
+    }
+    return QModelIndex();
+}
+
 Tp::ProtocolParameter ParameterEditModel::parameter(const QString &parameterName) const
 {
     foreach(ParameterItem* item, m_items) {
@@ -168,7 +180,6 @@ Tp::ProtocolParameter ParameterEditModel::parameter(const QString &parameterName
 
 void ParameterEditModel::addItem(const Tp::ProtocolParameter &parameter, const QVariant &originalValue)
 {
-    kDebug();
     // FIXME: Check we are not creating duplicate items.
 
     // Create a new ParameterItem and add it to the list.
diff --git a/src/KCMTelepathyAccounts/parameter-edit-model.h b/src/KCMTelepathyAccounts/parameter-edit-model.h
index 44c9d4d..2ca58c2 100644
--- a/src/KCMTelepathyAccounts/parameter-edit-model.h
+++ b/src/KCMTelepathyAccounts/parameter-edit-model.h
@@ -26,11 +26,14 @@
 #include "protocol-parameter-value.h"
 
 #include <QtCore/QAbstractListModel>
+#include <TelepathyQt4/Profile>
 
 class ParameterItem;
 
 namespace Tp {
     class ProtocolParameter;
+    class Profile;
+    class Parameter;
 }
 
 class KDE_EXPORT ParameterEditModel : public QAbstractListModel
@@ -59,6 +62,7 @@ public:
     virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
     virtual bool setData(const QModelIndex &index, const QVariant &value, int role);
     QModelIndex indexForParameter(const Tp::ProtocolParameter &parameter) const;
+    QModelIndex indexForParameter(const Tp::Profile::Parameter &parameter) const;
     Tp::ProtocolParameter parameter(const QString &parameterName) const;
 
     void addItem(const Tp::ProtocolParameter &parameter, const QVariant &originalValue);
diff --git a/src/KCMTelepathyAccounts/parameter-edit-widget.cpp b/src/KCMTelepathyAccounts/parameter-edit-widget.cpp
index 34e161a..41bb255 100644
--- a/src/KCMTelepathyAccounts/parameter-edit-widget.cpp
+++ b/src/KCMTelepathyAccounts/parameter-edit-widget.cpp
@@ -43,7 +43,7 @@ public:
 
 ParameterEditWidget::ParameterEditWidget(ParameterEditModel *parameterModel,
                                          QWidget *parent)
- : AbstractAccountParametersWidget(parameterModel, parent),
+ : AbstractAccountParametersWidget(parameterModel, QString(), parent),
    d(new Private)
 {
     kDebug();
diff --git a/src/KCMTelepathyAccounts/parameter-item.cpp b/src/KCMTelepathyAccounts/parameter-item.cpp
index 65e4334..c7d827a 100644
--- a/src/KCMTelepathyAccounts/parameter-item.cpp
+++ b/src/KCMTelepathyAccounts/parameter-item.cpp
@@ -31,8 +31,6 @@ ParameterItem::ParameterItem(const Tp::ProtocolParameter &parameter,
    m_parameter(parameter),
    m_originalValue(originalValue)
 {
-    kDebug() << "New parameter:" << parameter.name() << "of type:" << parameter.type() << "with value:" << m_originalValue;
-
     // To begin with, the current value is the original value.
     m_currentValue = m_originalValue;
 
diff --git a/src/KCMTelepathyAccounts/profile-item.cpp b/src/KCMTelepathyAccounts/profile-item.cpp
index f88c99b..6f71888 100644
--- a/src/KCMTelepathyAccounts/profile-item.cpp
+++ b/src/KCMTelepathyAccounts/profile-item.cpp
@@ -2,6 +2,7 @@
  * This file is part of telepathy-accounts-kcm
  *
  * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
+ * Copyright (C) 2011 Thomas Richard <thomas.richard at proan.be>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -21,7 +22,6 @@
 #include "profile-item.h"
 
 #include "profile-list-model.h"
-#include "connection-manager-item.h"
 #include "dictionary.h"
 
 #include <TelepathyQt4/Profile>
@@ -31,8 +31,7 @@ ProfileItem::ProfileItem(const Tp::ProfilePtr &profile, ProfileListModel *parent
  : QObject(parent),
    m_profile(profile)
 {
-    kDebug() << "Creating new ProfileItem with and profile;" << profile.data()->name();
-
+    //FIXME: Dictionary should not be needed anymore when distros ship profiles
     m_localizedName = Dictionary::instance()->string(profile.data()->name());
     if(m_localizedName.isEmpty()) {
         m_localizedName = profile.data()->name();
@@ -46,6 +45,11 @@ ProfileItem::~ProfileItem()
     // TODO: Implement me...
 }
 
+QString ProfileItem::serviceName() const
+{
+    return m_profile.data()->serviceName();
+}
+
 QString ProfileItem::name() const
 {
     return m_profile.data()->name();
@@ -71,5 +75,10 @@ QString ProfileItem::protocolName() const
     return m_profile.data()->protocolName();
 }
 
+Tp::ProfilePtr ProfileItem::profile() const
+{
+    return m_profile;
+}
+
 #include "profile-item.moc"
 
diff --git a/src/KCMTelepathyAccounts/profile-item.h b/src/KCMTelepathyAccounts/profile-item.h
index fb4ebc1..31c1e18 100644
--- a/src/KCMTelepathyAccounts/profile-item.h
+++ b/src/KCMTelepathyAccounts/profile-item.h
@@ -2,6 +2,7 @@
  * This file is part of telepathy-accounts-kcm
  *
  * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
+ * Copyright (C) 2011 Thomas Richard <thomas.richard at proan.be>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -38,11 +39,13 @@ public:
     explicit ProfileItem(const Tp::ProfilePtr &profile, ProfileListModel *parent);
     virtual ~ProfileItem();
 
+    QString serviceName() const;
     QString name() const;
     QString localizedName() const;
     QString iconName() const;
     QString cmName() const;
     QString protocolName() const;
+    Tp::ProfilePtr profile() const;
 
 private:
     Tp::ProfilePtr m_profile;
diff --git a/src/KCMTelepathyAccounts/profile-list-model.cpp b/src/KCMTelepathyAccounts/profile-list-model.cpp
index 97f28d3..c5d8fa9 100644
--- a/src/KCMTelepathyAccounts/profile-list-model.cpp
+++ b/src/KCMTelepathyAccounts/profile-list-model.cpp
@@ -2,6 +2,7 @@
  * This file is part of telepathy-accounts-kcm
  *
  * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
+ * Copyright (C) 2011 Thomas Richard <thomas.richard at proan.be>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -20,7 +21,6 @@
 
 #include "profile-list-model.h"
 
-#include "connection-manager-item.h"
 #include "profile-item.h"
 
 #include <TelepathyQt4/ProfileManager>
@@ -89,13 +89,6 @@ void ProfileListModel::setProfileManager(Tp::ProfileManagerPtr profileManager)
     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();
     }
 
 
diff --git a/src/KCMTelepathyAccounts/profile-list-model.h b/src/KCMTelepathyAccounts/profile-list-model.h
index a48f69d..0025a95 100644
--- a/src/KCMTelepathyAccounts/profile-list-model.h
+++ b/src/KCMTelepathyAccounts/profile-list-model.h
@@ -2,6 +2,7 @@
  * This file is part of telepathy-accounts-kcm
  *
  * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
+ * Copyright (C) 2011 Thomas Richard <thomas.richard at proan.be>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/KCMTelepathyAccounts/profile-select-widget.cpp b/src/KCMTelepathyAccounts/profile-select-widget.cpp
index 92deee2..7a87a2f 100644
--- a/src/KCMTelepathyAccounts/profile-select-widget.cpp
+++ b/src/KCMTelepathyAccounts/profile-select-widget.cpp
@@ -2,6 +2,7 @@
  * This file is part of telepathy-accounts-kcm
  *
  * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
+ * Copyright (C) 2011 Thomas Richard <thomas.richard at proan.be>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -68,6 +69,7 @@ ProfileSelectWidget::ProfileSelectWidget(QWidget *parent)
             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*)),
@@ -82,7 +84,6 @@ ProfileSelectWidget::~ProfileSelectWidget()
     delete d;
 }
 
-
 void ProfileSelectWidget::onProfileManagerReady(Tp::PendingOperation *op)
 {
     kDebug();
diff --git a/src/KCMTelepathyAccounts/profile-select-widget.h b/src/KCMTelepathyAccounts/profile-select-widget.h
index e0d04c9..3f741f0 100644
--- a/src/KCMTelepathyAccounts/profile-select-widget.h
+++ b/src/KCMTelepathyAccounts/profile-select-widget.h
@@ -2,6 +2,7 @@
  * This file is part of telepathy-accounts-kcm
  *
  * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
+ * Copyright (C) 2011 Thomas Richard <thomas.richard at proan.be>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/account-item.cpp b/src/account-item.cpp
index a670a1b..ce16726 100644
--- a/src/account-item.cpp
+++ b/src/account-item.cpp
@@ -85,8 +85,8 @@ void AccountItem::generateIcon()
     kDebug();
 
     QString iconPath = account()->iconName();
-    //if the icon has not been setted, we use the protocol icon
 
+    //if the icon has not been setted, we use the protocol icon    
     if(iconPath.isEmpty()) {
         iconPath = QString("im-%1").arg(account()->protocolName());
     }
diff --git a/src/add-account-assistant.cpp b/src/add-account-assistant.cpp
index 040ba88..61b2315 100644
--- a/src/add-account-assistant.cpp
+++ b/src/add-account-assistant.cpp
@@ -3,6 +3,7 @@
  *
  * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
  * Copyright (C) 2011 Dominik Schmidt <kde at dominik-schmidt.de>
+ * Copyright (C) 2011 Thomas Richard <thomas.richard at proan.be>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -37,6 +38,7 @@
 #include <QtCore/QList>
 #include <QtGui/QHBoxLayout>
 
+#include <TelepathyQt4/PendingReady>
 #include <TelepathyQt4/PendingAccount>
 #include <TelepathyQt4/PendingOperation>
 
@@ -44,7 +46,8 @@ class AddAccountAssistant::Private
 {
 public:
     Private()
-     : profileSelectWidget(0),
+     : currentProfileItem(0),
+       profileSelectWidget(0),
        accountEditWidget(0),
        pageOne(0),
        pageTwo(0)
@@ -53,7 +56,8 @@ public:
     }
 
     Tp::AccountManagerPtr accountManager;
-    Tp::AccountPtr account;
+    Tp::ConnectionManagerPtr connectionManager;
+    ProfileItem *currentProfileItem;
     ProfileSelectWidget *profileSelectWidget;
     AccountEditWidget *accountEditWidget;
     QWidget *pageTwoWidget;
@@ -114,35 +118,20 @@ void AddAccountAssistant::next()
 
         Q_ASSERT(d->profileSelectWidget->selectedProfile());
 
+        ProfileItem *selectedItem = d->profileSelectWidget->selectedProfile();
+
         // Set up the next page.
-        ProfileItem *item = d->profileSelectWidget->selectedProfile();
-/*
-        ConnectionManagerItem *cmItem = qobject_cast<ConnectionManagerItem*>(item->parent());
-        if (!cmItem) {
-            kWarning() << "cmItem is invalid.";
-        }
+        if(d->currentProfileItem != selectedItem) {
+            d->currentProfileItem = selectedItem;
 
-        // Delete the widgets for the next page if they already exist
-        if (d->accountEditWidget) {
-            d->accountEditWidget->deleteLater();
-            d->accountEditWidget = 0;
+            d->connectionManager = Tp::ConnectionManager::create(selectedItem->cmName());
+            connect(d->connectionManager.data()->becomeReady(),
+                    SIGNAL(finished(Tp::PendingOperation*)),
+                    SLOT(onConnectionManagerReady(Tp::PendingOperation*)));
+        }
+        else {
+            pageTwo();
         }
-
-        // Get the protocol's parameters and values.
-        Tp::ProtocolInfo protocolInfo = item->protocolInfo();
-        Tp::ProtocolParameterList parameters = protocolInfo.parameters();
-
-        // Add the parameters to the model.
-        ParameterEditModel *parameterModel = new ParameterEditModel(this);
-        parameterModel->addItems(parameters);
-
-        // Set up the account edit widget
-        d->accountEditWidget = new AccountEditWidget(item->protocolInfo(),
-                                                     parameterModel,
-                                                     d->pageTwoWidget);
-        d->pageTwoWidget->layout()->addWidget(d->accountEditWidget);
-*/
-        KAssistantDialog::next();
     }
 }
 
@@ -166,15 +155,6 @@ void AddAccountAssistant::accept()
     QList<ProtocolParameterValue> parameterValues;
     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());
-
-    //if (!connectionManagerItem) {
-    //    kWarning() << "Invalid ConnectionManager item.";
-    //    return;
-    //}
-
     QVariantMap values;
     foreach(const ProtocolParameterValue &ppv, parameterValues)
     {
@@ -183,17 +163,22 @@ void AddAccountAssistant::accept()
         }
     }
 
-    /*
+    QVariantMap properties;
+
+    properties.insert("org.freedesktop.Telepathy.Account.Service", d->currentProfileItem->serviceName());
+    properties.insert("org.freedesktop.Telepathy.Account.Enabled", true);
+
     // FIXME: Ask the user to submit a Display Name
-    Tp::PendingAccount *pa = d->accountManager->createAccount(connectionManagerItem->connectionManager()->name(),
-                                                              protocolItem->protocol(),
+    Tp::PendingAccount *pa = d->accountManager->createAccount(d->currentProfileItem->cmName(),
+                                                              d->currentProfileItem->protocolName(),
                                                               values["account"].toString(),
-                                                              values);
+                                                              values,
+                                                              properties);
 
     connect(pa,
             SIGNAL(finished(Tp::PendingOperation*)),
             SLOT(onAccountCreated(Tp::PendingOperation*)));
-            */
+
 }
 
 void AddAccountAssistant::reject()
@@ -225,32 +210,22 @@ void AddAccountAssistant::onAccountCreated(Tp::PendingOperation *op)
         return;
     }
 
-    // Get the account pointer.
-    d->account = pendingAccount->account();
-
-    // Set the account icon
-    QString icon = QString("im-%1").arg(d->account->protocolName());
-    kDebug() << "Set account icon to: " << icon;
-    d->account->setIconName(icon);
-
-    kDebug() << "Calling set enabled.";
-
-    connect(d->account->setEnabled(true),
-            SIGNAL(finished(Tp::PendingOperation*)),
-            SLOT(onSetEnabledFinished(Tp::PendingOperation*)));
+    KAssistantDialog::accept();
 }
 
-void AddAccountAssistant::onSetEnabledFinished(Tp::PendingOperation *op)
+void AddAccountAssistant::onConnectionManagerReady(Tp::PendingOperation *op)
 {
     kDebug();
 
-    if (op->isError()) {
-        // TODO: User feedback in this case.
-        kWarning() << "Enabling Account failed:" << op->errorName() << op->errorMessage();
-        return;
+    if(op->isError()) {
+        kWarning() << "Creating ConnectionManager failed:" << op->errorName() << op->errorMessage();
     }
 
-    KAssistantDialog::accept();
+    if(!d->connectionManager.data()->isValid()) {
+        kWarning() << "Invalid ConnectionManager";
+    }
+
+    pageTwo();
 }
 
 void AddAccountAssistant::onProfileSelected(bool value)
@@ -260,5 +235,34 @@ void AddAccountAssistant::onProfileSelected(bool value)
     setValid(d->pageOne, value);
 }
 
+void AddAccountAssistant::pageTwo()
+{
+    // Get the protocol's parameters and values.
+    Tp::ProtocolInfo protocolInfo = d->connectionManager.data()->protocol(d->currentProfileItem->protocolName());
+    Tp::ProtocolParameterList parameters = protocolInfo.parameters();
+
+    // Add the parameters to the model.
+    ParameterEditModel *parameterModel = new ParameterEditModel(this);
+    parameterModel->addItems(parameters);
+
+    foreach(const Tp::Profile::Parameter &parameter, d->currentProfileItem->profile().data()->parameters()) {
+        parameterModel->setData(parameterModel->indexForParameter(parameter), parameter.value(), Qt::EditRole);
+    }
+
+    // Delete account previous widget if it already existed.
+    if (d->accountEditWidget) {
+        d->accountEditWidget->deleteLater();
+        d->accountEditWidget = 0;
+    }
+
+    // Set up the account edit widget.
+    d->accountEditWidget = new AccountEditWidget(d->currentProfileItem->profile(),
+                                                 parameterModel,
+                                                 d->pageTwoWidget);
+    d->pageTwoWidget->layout()->addWidget(d->accountEditWidget);
+
+    KAssistantDialog::next();
+}
+
 #include "add-account-assistant.moc"
 
diff --git a/src/add-account-assistant.h b/src/add-account-assistant.h
index 17a0206..973bad4 100644
--- a/src/add-account-assistant.h
+++ b/src/add-account-assistant.h
@@ -2,6 +2,7 @@
  * This file is part of telepathy-accounts-kcm
  *
  * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
+ * Copyright (C) 2011 Thomas Richard <thomas.richard at proan.be>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -47,10 +48,12 @@ Q_SIGNALS:
 
 private Q_SLOTS:
     void onAccountCreated(Tp::PendingOperation *op);
-    void onSetEnabledFinished(Tp::PendingOperation *op);
+    void onConnectionManagerReady(Tp::PendingOperation *op);
     void onProfileSelected(bool value);
 
 private:
+    void pageTwo();
+
     class Private;
     Private * const d;
 };
diff --git a/src/edit-account-dialog.cpp b/src/edit-account-dialog.cpp
index 9797421..a716259 100644
--- a/src/edit-account-dialog.cpp
+++ b/src/edit-account-dialog.cpp
@@ -70,7 +70,7 @@ EditAccountDialog::EditAccountDialog(AccountItem *item, QWidget *parent)
     parameterModel->addItems(parameters, parameterValues);
 
     // Set up the interface
-    d->widget = new AccountEditWidget(protocolInfo,
+    d->widget = new AccountEditWidget(d->item->account().data()->profile(),
                                       parameterModel,
                                       this);
     setMainWidget(d->widget);
diff --git a/src/kcm-telepathy-accounts.cpp b/src/kcm-telepathy-accounts.cpp
index 554f6d1..e323df7 100644
--- a/src/kcm-telepathy-accounts.cpp
+++ b/src/kcm-telepathy-accounts.cpp
@@ -57,7 +57,8 @@ KCMTelepathyAccounts::KCMTelepathyAccounts(QWidget *parent, const QVariantList&
     Tp::AccountFactoryPtr  accountFactory = Tp::AccountFactory::create(QDBusConnection::sessionBus(),
                                                                        Tp::Features() << Tp::Account::FeatureCore
                                                                        << Tp::Account::FeatureAvatar
-                                                                       << Tp::Account::FeatureProtocolInfo);
+                                                                       << Tp::Account::FeatureProtocolInfo
+                                                                       << Tp::Account::FeatureProfile);
 
     m_accountManager = Tp::AccountManager::create(accountFactory);
 

-- 
ktp-accounts-kcm packaging



More information about the pkg-kde-commits mailing list