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


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

The following commit has been merged in the master branch:
commit 54ebb5e80135ef7bf6a3f7af0eafb6f4ea555cd3
Author: Daniele E. Domenichelli <daniele.domenichelli at gmail.com>
Date:   Mon Sep 19 16:24:55 2011 +0100

    Add a dialog to enable local-xmpp account
---
 src/CMakeLists.txt                                 |   1 +
 src/salut-enable-dialog.cpp                        | 210 +++++++++++++++++++++
 ...d-account-assistant.h => salut-enable-dialog.h} |  31 ++-
 3 files changed, 225 insertions(+), 17 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c55c046..dc837a4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -12,6 +12,7 @@ set (telepathy_accounts_kcm_SRCS
      account-item.cpp
      add-account-assistant.cpp
      edit-account-dialog.cpp
+     salut-enable-dialog.cpp
      accounts-list-delegate.cpp
 )
 
diff --git a/src/salut-enable-dialog.cpp b/src/salut-enable-dialog.cpp
new file mode 100644
index 0000000..954f6f9
--- /dev/null
+++ b/src/salut-enable-dialog.cpp
@@ -0,0 +1,210 @@
+/*
+ * 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>
+ * Copyright (C) 2011 Dominik Schmidt <kde at dominik-schmidt.de>
+ * Copyright (C) 2011 Daniele E. Domenichelli <daniele.domenichelli at gmail.com>
+ *
+ * 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 "salut-enable-dialog.h"
+
+#include "KCMTelepathyAccounts/parameter-edit-model.h"
+#include "KCMTelepathyAccounts/account-edit-widget.h"
+#include "KCMTelepathyAccounts/profile-item.h"
+
+#include <KLocalizedString>
+#include <KDebug>
+
+#include <TelepathyQt4/ConnectionManager>
+#include <TelepathyQt4/ProfileManager>
+#include <TelepathyQt4/AccountManager>
+#include <TelepathyQt4/PendingOperation>
+#include <TelepathyQt4/PendingReady>
+#include <TelepathyQt4/PendingAccount>
+
+class SalutEnableDialog::Private
+{
+public:
+    Private(SalutEnableDialog* parent)
+        : q(parent),
+          widget(0)
+    {
+        kDebug();
+    }
+
+    SalutEnableDialog *q;
+    AccountEditWidget *widget;
+
+    Tp::ConnectionManagerPtr connectionManager;
+    Tp::ProfileManagerPtr profileManager;
+    Tp::AccountManagerPtr accountManager;
+    Tp::ProfilePtr profile;
+};
+
+SalutEnableDialog::SalutEnableDialog(Tp::AccountManagerPtr accountManager, QWidget *parent)
+    : KDialog(parent),
+      d(new Private(this))
+{
+    kDebug();
+
+    d->accountManager = accountManager;
+
+    setMinimumWidth(400);
+
+    d->connectionManager = Tp::ConnectionManager::create("salut");
+    connect(d->connectionManager->becomeReady(),
+            SIGNAL(finished(Tp::PendingOperation*)),
+            SLOT(onConnectionManagerReady(Tp::PendingOperation*)));
+}
+
+SalutEnableDialog::~SalutEnableDialog()
+{
+    kDebug();
+    delete d;
+}
+
+void SalutEnableDialog::onConnectionManagerReady(Tp::PendingOperation* op)
+{
+    kDebug();
+
+    if(op->isError()) {
+        kWarning() << "Creating ConnectionManager failed:" << op->errorName() << op->errorMessage();
+    }
+
+    if(!d->connectionManager->isValid()) {
+        kWarning() << "Invalid ConnectionManager";
+    }
+
+    d->profileManager = Tp::ProfileManager::create(QDBusConnection::sessionBus());
+
+    // FIXME: Until all distros ship correct profile files, we should fake them
+    connect(d->profileManager->becomeReady(Tp::Features() << Tp::ProfileManager::FeatureFakeProfiles),
+            SIGNAL(finished(Tp::PendingOperation*)),
+            SLOT(onProfileManagerReady(Tp::PendingOperation*)));
+}
+
+void SalutEnableDialog::onProfileManagerReady(Tp::PendingOperation* op)
+{
+    if(op->isError()) {
+        kWarning() << "Creating ProfileManager failed:" << op->errorName() << op->errorMessage();
+    }
+
+    // Get the protocol's parameters and values.
+    Tp::ProtocolInfo protocolInfo = d->connectionManager->protocol(QLatin1String("local-xmpp"));
+    Tp::ProtocolParameterList parameters = protocolInfo.parameters();
+
+    // Add the parameters to the model.
+    ParameterEditModel *parameterModel = new ParameterEditModel(this);
+    d->profile = d->profileManager->profilesForCM("salut").first();
+    parameterModel->addItems(parameters, d->profile->parameters());
+
+    // Set up the interface
+    d->widget = new AccountEditWidget(d->profile,
+                                      parameterModel,
+                                      doNotConnectOnAdd,
+                                      this);
+    connect(this,
+            SIGNAL(feedbackMessage(QString,QString,KTitleWidget::MessageType)),
+            d->widget,
+            SIGNAL(feedbackMessage(QString,QString,KTitleWidget::MessageType)));
+    setMainWidget(d->widget);
+
+}
+
+void SalutEnableDialog::onAccountCreated(Tp::PendingOperation* op)
+{
+    if(op->isError()) {
+        kWarning() << "Creating Account failed:" << op->errorName() << op->errorMessage();
+    }
+
+    if (op->isError()) {
+        Q_EMIT feedbackMessage(i18n("Failed to create account"),
+                               i18n("Possibly not all required fields are valid"),
+                               KTitleWidget::ErrorMessage);
+        kWarning() << "Adding Account failed:" << op->errorName() << op->errorMessage();
+        return;
+    }
+
+    // Get the PendingAccount.
+    Tp::PendingAccount *pendingAccount = qobject_cast<Tp::PendingAccount*>(op);
+    if (!pendingAccount) {
+        Q_EMIT feedbackMessage(i18n("Something went wrong with Telepathy"),
+                               QString(),
+                               KTitleWidget::ErrorMessage);
+        kWarning() << "Method called with wrong type.";
+        return;
+    }
+
+    pendingAccount->account()->setRequestedPresence(Tp::Presence::available(QString("Online")));
+    pendingAccount->account()->setServiceName(d->profile->serviceName());
+
+    // set the dialog as accepted and exit
+    done(KDialog::Accepted);
+}
+
+void SalutEnableDialog::accept()
+{
+    kDebug();
+
+    // Get the parameter values.
+    QVariantMap values = d->widget->parametersSet();
+
+    // Check all pages of parameters pass validation.
+    if (!d->widget->validateParameterValues()) {
+        kDebug() << "A widget failed parameter validation. Not accepting wizard.";
+        return;
+    }
+
+    // FIXME: In some next version of tp-qt4 there should be a convenience class for this
+    // https://bugs.freedesktop.org/show_bug.cgi?id=33153
+    QVariantMap properties;
+
+    if (d->accountManager->supportedAccountProperties().contains(QLatin1String("org.freedesktop.Telepathy.Account.Service"))) {
+      properties.insert("org.freedesktop.Telepathy.Account.Service", d->profile->serviceName());
+    }
+    if (d->accountManager->supportedAccountProperties().contains(QLatin1String("org.freedesktop.Telepathy.Account.Enabled"))) {
+      properties.insert("org.freedesktop.Telepathy.Account.Enabled", true);
+    }
+
+    // FIXME: Ask the user to submit a Display Name
+
+    QString displayName = values["first-name"].toString();
+    displayName += QLatin1Char(' ');
+    displayName += values["last-name"].toString();
+    displayName += QLatin1Char(' ');
+    if (values.contains("nickname")) {
+        displayName += QLatin1Char('(');
+        displayName += values["nickname"].toString();
+        displayName += QLatin1Char(')');
+        displayName += QLatin1Char(' ');
+    }
+    displayName += i18n("on local network");
+
+    Tp::PendingAccount *pa = d->accountManager->createAccount(d->profile->cmName(),
+                                                              d->profile->protocolName(),
+                                                              displayName,
+                                                              values,
+                                                              properties);
+
+    connect(pa,
+            SIGNAL(finished(Tp::PendingOperation*)),
+            SLOT(onAccountCreated(Tp::PendingOperation*)));
+}
+
+
+#include "salut-enable-dialog.moc"
\ No newline at end of file
diff --git a/src/add-account-assistant.h b/src/salut-enable-dialog.h
similarity index 68%
copy from src/add-account-assistant.h
copy to src/salut-enable-dialog.h
index 3647912..ca15d59 100644
--- a/src/add-account-assistant.h
+++ b/src/salut-enable-dialog.h
@@ -3,6 +3,8 @@
  *
  * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
  * Copyright (C) 2011 Thomas Richard <thomas.richard at proan.be>
+ * Copyright (C) 2011 Dominik Schmidt <kde at dominik-schmidt.de>
+ * Copyright (C) 2011 Daniele E. Domenichelli <daniele.domenichelli at gmail.com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -19,47 +21,42 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#ifndef TELEPATHY_ACCOUNTS_KCM_ADD_ACCOUNT_ASSISTANT_H
-#define TELEPATHY_ACCOUNTS_KCM_ADD_ACCOUNT_ASSISTANT_H
+#ifndef KCM_TELEPATHY_SALUT_ENABLE_ACCOUNT_DIALOG_H
+#define KCM_TELEPATHY_SALUT_ENABLE_ACCOUNT_DIALOG_H
 
-#include <KAssistantDialog>
+#include <KDialog>
 #include <KTitleWidget>
 
-#include <TelepathyQt4/AccountManager>
+#include <TelepathyQt4/Types>
 
 namespace Tp {
     class PendingOperation;
 }
 
-class AddAccountAssistant : public KAssistantDialog
+class SalutEnableDialog : public KDialog
 {
     Q_OBJECT
+    Q_DISABLE_COPY(SalutEnableDialog);
 
 public:
-    explicit AddAccountAssistant(Tp::AccountManagerPtr accountManager, QWidget *parent = 0);
-    ~AddAccountAssistant();
-
-protected Q_SLOTS:
-    virtual void next();
-    virtual void accept();
-    virtual void reject();
+    explicit SalutEnableDialog(Tp::AccountManagerPtr accountManager, QWidget *parent = 0);
+    virtual ~SalutEnableDialog();
 
 Q_SIGNALS:
-    void cancelled();
     void feedbackMessage(const QString &text, const QString &comment, KTitleWidget::MessageType);
 
 private Q_SLOTS:
     void onAccountCreated(Tp::PendingOperation *op);
     void onConnectionManagerReady(Tp::PendingOperation *op);
-    void onProfileSelected(bool value);
+    void onProfileManagerReady(Tp::PendingOperation *op);
 
 private:
-    void pageTwo();
+    void accept();
+//     void reject() {}
 
     class Private;
     Private * const d;
 };
 
 
-#endif  // Header guard
-
+#endif // KCM_TELEPATHY_SALUT_ENABLE_ACCOUNT_DIALOG_H

-- 
ktp-accounts-kcm packaging



More information about the pkg-kde-commits mailing list