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

Maximiliano Curia maxy at moszumanska.debian.org
Sat May 28 00:02:52 UTC 2016


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

The following commit has been merged in the master branch:
commit 88f3b1a591a1210278c4d7147e9a3a377a5a30cf
Author: Dan Vrátil <dvratil at redhat.com>
Date:   Wed Nov 14 11:57:45 2012 +0100

    Import Kopete logs when adding a new account in KCM
    
    When there are Kopete logs that seem to belong to the
    same account that was just created in KCM, ask user
    whether to import them.
    
    When removing an account, user can remove all account
    logs from TpLogger.
    
    REVIEW: 107246
---
 CMakeLists.txt                 |  3 ++
 src/CMakeLists.txt             |  2 +-
 src/kcm-telepathy-accounts.cpp | 90 +++++++++++++++++++++++++++++++++++++-----
 src/kcm-telepathy-accounts.h   |  7 ++++
 4 files changed, 92 insertions(+), 10 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b4248fb..845fe6e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,6 +7,7 @@ set(IS_KTP_INTERNAL_MODULE TRUE)
 set(KDE_MIN_VERSION "4.7.0")
 find_package (KDE4 REQUIRED)
 find_package (TelepathyQt4 0.8.9 REQUIRED)
+find_package (TelepathyLoggerQt4 REQUIRED)
 find_package (KTp REQUIRED)
 
 # set some default settings
@@ -18,10 +19,12 @@ include (MacroLibrary)
 add_definitions (${KDE4_DEFINITIONS}
                  -DQT_NO_CAST_FROM_ASCII
                  -DQT_NO_KEYWORDS
+		 ${TELEPATHY_LOGGER_QT4_DEFINITIONS}
 )
 
 include_directories (${KDE4_INCLUDES}
                      ${TELEPATHY_QT4_INCLUDE_DIR}
+                     ${TELEPATHY_LOGGER_QT4_INCLUDE_DIRS}
                      ${KTP_INCLUDE_DIR}
                      ${CMAKE_CURRENT_SOURCE_DIR}/src
 )
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 62aef14..5672469 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -39,7 +39,7 @@ target_link_libraries (kcm_ktp_accounts
                        ${KTP_LIBRARIES}
                        ${KTP_MODELS_LIBRARIES}
                        ${KDE4_KIO_LIBS}
-
+                       ${TELEPATHY_LOGGER_QT4_LIBRARIES}
 )
 
 # Install:
diff --git a/src/kcm-telepathy-accounts.cpp b/src/kcm-telepathy-accounts.cpp
index 8cab323..2ef7d74 100644
--- a/src/kcm-telepathy-accounts.cpp
+++ b/src/kcm-telepathy-accounts.cpp
@@ -31,6 +31,8 @@
 
 #include <QtGui/QLabel>
 #include <QtGui/QSortFilterProxyModel>
+#include <QtGui/QProgressBar>
+#include <QtCore/QPointer>
 
 #include <KPluginFactory>
 #include <KIcon>
@@ -41,9 +43,11 @@
 #include <KPixmapSequenceOverlayPainter>
 #include <KDebug>
 #include <KPixmapSequence>
+#include <KProgressDialog>
 
 #include <KTp/wallet-utils.h>
 #include <KTp/Models/accounts-list-model.h>
+#include <KTp/logs-importer.h>
 
 #include <TelepathyQt/Account>
 #include <TelepathyQt/AccountFactory>
@@ -53,6 +57,9 @@
 #include <TelepathyQt/PendingComposite>
 #include <TelepathyQt/ConnectionManager>
 
+#include <TelepathyLoggerQt4/LogManager>
+#include <TelepathyLoggerQt4/Init>
+#include <TelepathyLoggerQt4/PendingOperation>
 
 
 K_PLUGIN_FACTORY(KCMTelepathyAccountsFactory, registerPlugin<KCMTelepathyAccounts>();)
@@ -78,6 +85,7 @@ KCMTelepathyAccounts::KCMTelepathyAccounts(QWidget *parent, const QVariantList&
 
     // The first thing we must do is register Telepathy DBus Types.
     Tp::registerTypes();
+    Tpl::init();
 
     // Start setting up the Telepathy AccountManager.
     Tp::AccountFactoryPtr  accountFactory = Tp::AccountFactory::create(QDBusConnection::sessionBus(),
@@ -91,6 +99,9 @@ KCMTelepathyAccounts::KCMTelepathyAccounts(QWidget *parent, const QVariantList&
     connect(m_accountManager->becomeReady(),
             SIGNAL(finished(Tp::PendingOperation*)),
             SLOT(onAccountManagerReady(Tp::PendingOperation*)));
+    connect(m_accountManager.constData(),
+	    SIGNAL(newAccount(Tp::AccountPtr)),
+	    SLOT(onNewAccountAdded(Tp::AccountPtr)));
 
     // Set up the UI stuff.
     m_ui = new Ui::MainWidget;
@@ -234,6 +245,56 @@ void KCMTelepathyAccounts::onAccountManagerReady(Tp::PendingOperation *op)
     m_accountsListModel->setAccountManager(m_accountManager);
 }
 
+void KCMTelepathyAccounts::onNewAccountAdded(const Tp::AccountPtr& account)
+{
+    KTp::LogsImporter logsImporter;
+    if (!logsImporter.hasKopeteLogs(account)) {
+	kDebug() << "No Kopete logs for" << account->uniqueIdentifier() << "found";
+	return;
+    }
+
+    int ret = KMessageBox::questionYesNo(this,
+		i18n("We have found Kopete logs for this account. Do you want to import the logs to KDE Telepathy?"),
+		i18n("Import Logs?"));
+
+    if (ret == KMessageBox::No) {
+	return;
+    }
+
+    m_importProgressDialog = new KProgressDialog(this);
+    m_importProgressDialog->setLabelText(i18n("Importing logs..."));
+    m_importProgressDialog->setAllowCancel(false);
+    m_importProgressDialog->progressBar()->setMinimum(0);
+    m_importProgressDialog->progressBar()->setMaximum(0);
+    m_importProgressDialog->setButtons(KDialog::Close);
+    m_importProgressDialog->enableButton(KDialog::Close, false);
+
+    connect(&logsImporter, SIGNAL(logsImported()), SLOT(onLogsImportDone()));
+    connect(&logsImporter, SIGNAL(error(QString)), SLOT(onLogsImportError(QString)));
+
+    logsImporter.startLogImport(account);
+    m_importProgressDialog->exec();
+
+    delete m_importProgressDialog;
+}
+
+void KCMTelepathyAccounts::onLogsImportError(const QString &error)
+{
+    if (m_importProgressDialog) {
+	m_importProgressDialog->close();
+    }
+
+    KMessageBox::error(this, error, i18n("Kopete Logs Import"));
+}
+
+void KCMTelepathyAccounts::onLogsImportDone()
+{
+    if (m_importProgressDialog) {
+	m_importProgressDialog->close();
+    }
+
+    KMessageBox::information(this, i18n("Kopete logs succesfully imported"), i18n("Kopete Logs Import"));
+}
 
 void KCMTelepathyAccounts::onSelectedItemChanged(const QModelIndex &current, const QModelIndex &previous)
 {
@@ -325,21 +386,32 @@ void KCMTelepathyAccounts::onRemoveAccountClicked()
 {
     QModelIndex index = m_currentListView->currentIndex();
 
-     if ( KMessageBox::warningContinueCancel(this, i18n("Are you sure you want to remove the account \"%1\"?", m_currentModel->data(index, Qt::DisplayRole).toString()),
-                                        i18n("Remove Account"), KGuiItem(i18n("Remove Account"), QLatin1String("edit-delete")), KStandardGuiItem::cancel(),
-                                        QString(), KMessageBox::Notify | KMessageBox::Dangerous) == KMessageBox::Continue)
-    {
-         Tp::AccountPtr account = index.data(AccountsListModel::AccountRole).value<Tp::AccountPtr>();
+    QString accountName = index.data(Qt::DisplayRole).toString();
+
+    KDialog *dialog = new KDialog(this); /* will be deleted by KMessageBox::createKMessageBox */
+    dialog->setButtons(KDialog::Yes | KDialog::Cancel);
+    dialog->setWindowTitle(i18n("Remove Account"));
+    dialog->setButtonGuiItem(KDialog::Yes, KGuiItem(i18n("Remove Account"), QLatin1String("edit-delete")));
+    bool removeLogs = false;
+    if (KMessageBox::createKMessageBox(dialog, QMessageBox::Warning, i18n("Are you sure you want to remove the account \"%1\"?", accountName),
+			QStringList(),  i18n("Remove conversations logs"), &removeLogs,
+			KMessageBox::Dangerous | KMessageBox::Notify) == KDialog::Yes) {
 
-         if (account.isNull()) {
-             return;
-         }
+	Tp::AccountPtr account = index.data(AccountsListModel::AccountRole).value<Tp::AccountPtr>();
+	if (account.isNull()) {
+	    return;
+	}
+
+	if (removeLogs) {
+	    Tpl::LogManagerPtr logManager = Tpl::LogManager::instance();
+	    logManager->clearAccountHistory(account);
+	}
 
          QList<Tp::PendingOperation*> ops;
          ops.append(KTp::WalletUtils::removeAccountPassword(account));
          ops.append(account->remove());
          connect(new Tp::PendingComposite(ops, account), SIGNAL(finished(Tp::PendingOperation*)), SLOT(onOperationFinished(Tp::PendingOperation*)));
-     }
+    }
 }
 
 void KCMTelepathyAccounts::onModelDataChanged()
diff --git a/src/kcm-telepathy-accounts.h b/src/kcm-telepathy-accounts.h
index 7ef5bd7..c944042 100644
--- a/src/kcm-telepathy-accounts.h
+++ b/src/kcm-telepathy-accounts.h
@@ -33,6 +33,7 @@ class AccountsListModel;
 class AddAccountAssistant;
 class QSortFilterProxyModel;
 class QListView;
+class KProgressDialog;
 
 namespace Tp {
     class PendingOperation;
@@ -72,6 +73,10 @@ private Q_SLOTS:
     void onSalutSetupDone();
     void onOperationFinished(Tp::PendingOperation *op);
 
+    void onNewAccountAdded(const Tp::AccountPtr &account);
+    void onLogsImportError(const QString&);
+    void onLogsImportDone();
+
 private:
     Ui::MainWidget *m_ui;
 
@@ -84,6 +89,8 @@ private:
 
     QWeakPointer<SalutEnabler> m_salutEnabler;
     KPixmapSequenceOverlayPainter *m_salutBusyWheel;
+
+    QPointer<KProgressDialog> m_importProgressDialog;
 };
 
 // Helper class for drawing error overlays

-- 
ktp-accounts-kcm packaging



More information about the pkg-kde-commits mailing list