[SCM] ktp-text-ui packaging branch, master, updated. debian/15.12.1-1-1918-gdf4b0ec
Maximiliano Curia
maxy at moszumanska.debian.org
Sat May 28 00:18:23 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=c75ea9f
The following commit has been merged in the master branch:
commit c75ea9f62551fc06310768341defcd400f5bf248
Author: Dominik Schmidt <ich at dominik-schmidt.de>
Date: Mon Oct 4 00:57:56 2010 +0000
Refactor protocol handler.
Don't use ugly app pointer anymore and update notifications to show success or failure state.
svn path=/trunk/playground/network/telepathy-chat-handler/; revision=1182267
---
adiumxtra-protocol-handler/CMakeLists.txt | 1 +
.../adiumxtra-protocol-handler.notifyrc | 32 +++++-
.../adiumxtraprotocolhandler.cpp | 128 +++++++++++++++++++++
.../adiumxtraprotocolhandler.h | 38 ++++++
adiumxtra-protocol-handler/bundleinstaller.h | 6 +-
adiumxtra-protocol-handler/chatstyleinstaller.cpp | 58 +++++++++-
adiumxtra-protocol-handler/chatstyleinstaller.h | 4 +
.../emoticonsetinstaller.cpp | 51 +++++++-
adiumxtra-protocol-handler/emoticonsetinstaller.h | 3 +
adiumxtra-protocol-handler/main.cpp | 109 +-----------------
10 files changed, 315 insertions(+), 115 deletions(-)
diff --git a/adiumxtra-protocol-handler/CMakeLists.txt b/adiumxtra-protocol-handler/CMakeLists.txt
index f61074f..514aa87 100644
--- a/adiumxtra-protocol-handler/CMakeLists.txt
+++ b/adiumxtra-protocol-handler/CMakeLists.txt
@@ -6,6 +6,7 @@ set(telepathy_chat_config_SRCS
bundleinstaller.cpp
chatstyleinstaller.cpp
emoticonsetinstaller.cpp
+ adiumxtraprotocolhandler.cpp
main.cpp
)
diff --git a/adiumxtra-protocol-handler/adiumxtra-protocol-handler.notifyrc b/adiumxtra-protocol-handler/adiumxtra-protocol-handler.notifyrc
index f71f5fc..9b6d45f 100644
--- a/adiumxtra-protocol-handler/adiumxtra-protocol-handler.notifyrc
+++ b/adiumxtra-protocol-handler/adiumxtra-protocol-handler.notifyrc
@@ -4,20 +4,40 @@ Comment=adiumxtra
Name=adiumxtra-protocol-handler
-[Event/installchatstyle]
-Name=Install Chatstyle
+[Event/chatstyleRequest]
+Name=Chatstyle Install Request
IconName=telepathy
Action=Popup
Flags=Persistent
-[Event/installemoticonset]
-Name=Install Emoticonset
+[Event/chatstyleSuccess]
+Name=Installed Chatstyle successfully
IconName=telepathy
Action=Popup
Flags=Persistent
-[Event/packagenotrecognized]
-Name=Package not recognized
+
+[Event/chatstyleFailure]
+Name=Install Chatstyle Installation failed
IconName=telepathy
Action=Popup
Flags=Persistent
+
+[Event/emoticonsRequest]
+Name=Emoticonset Install Request
+IconName=telepathy
+Action=Popup
+Flags=Persistent
+
+[Event/emoticonsSuccess]
+Name=Installed Emoticonset successfully
+IconName=telepathy
+Action=Popup
+Flags=Persistent
+
+
+[Event/emoticonsFailure]
+Name=Emoticonset Installation failed
+IconName=telepathy
+Action=Popup
+Flags=Persistent
\ No newline at end of file
diff --git a/adiumxtra-protocol-handler/adiumxtraprotocolhandler.cpp b/adiumxtra-protocol-handler/adiumxtraprotocolhandler.cpp
new file mode 100644
index 0000000..2c935cc
--- /dev/null
+++ b/adiumxtra-protocol-handler/adiumxtraprotocolhandler.cpp
@@ -0,0 +1,128 @@
+/*
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+
+#include "adiumxtraprotocolhandler.h"
+#include "chatstyleinstaller.h"
+#include "emoticonsetinstaller.h"
+#include <chatwindowstylemanager.h>
+
+#include <KDebug>
+#include <KZip>
+#include <KTar>
+#include <KEmoticons>
+#include <KTemporaryFile>
+#include <kio/job.h>
+#include <kio/netaccess.h>
+#include <KNotification>
+#include <KIcon>
+
+AdiumxtraProtocolHandler::AdiumxtraProtocolHandler()
+{
+ kDebug();
+}
+
+AdiumxtraProtocolHandler::~AdiumxtraProtocolHandler()
+{
+ kDebug();
+}
+
+BundleInstaller::BundleStatus AdiumxtraProtocolHandler::install(const QString &path)
+{
+ kDebug();
+
+ KUrl url(path);
+ if(url.protocol() == "adiumxtra") {
+ url.setProtocol("http");
+ }
+
+ KTemporaryFile *tmpFile = new KTemporaryFile();
+ if (tmpFile->open()) {
+ KIO::Job* getJob = KIO::file_copy(url.prettyUrl(), KUrl(tmpFile->fileName()), -1, KIO::Overwrite);
+ if (!KIO::NetAccess::synchronousRun(getJob, 0)) {
+ kDebug() << "download failed";
+ return BundleInstaller::BundleCannotOpen;
+ }
+ }
+
+ KArchive *archive = 0L;
+
+ QString currentBundleMimeType = KMimeType::findByPath(tmpFile->fileName(), 0, false)->name();
+ if (currentBundleMimeType == "application/zip") {
+ archive = new KZip(tmpFile->fileName());
+ } else if (currentBundleMimeType == "application/x-compressed-tar" || currentBundleMimeType == "application/x-bzip-compressed-tar" || currentBundleMimeType == "application/x-gzip" || currentBundleMimeType == "application/x-bzip") {
+ archive = new KTar(tmpFile->fileName());
+ } else {
+ KNotification *notification = new KNotification("packagenotrecognized", NULL, KNotification::Persistent);
+ notification->setText( i18n("Package type not recognized or not supported") );
+ notification->setActions( QStringList() << i18n("Ok") );
+ QObject::connect(notification, SIGNAL(action1Activated()), this, SLOT(install()));
+ QObject::connect(notification, SIGNAL(action1Activated()), notification, SLOT(close()));
+
+ QObject::connect(notification, SIGNAL(ignored()), this, SLOT(ignoreRequest()));
+ QObject::connect(notification, SIGNAL(ignored()), notification, SLOT(close()));
+ notification->sendEvent();
+ kDebug() << "unsupported file type" << currentBundleMimeType;
+ kDebug() << tmpFile->fileName();
+ return BundleInstaller::BundleNotValid;
+ }
+
+ if (!archive->open(QIODevice::ReadOnly)) {
+ delete archive;
+ kDebug() << "cannot open theme file";
+ return BundleInstaller::BundleCannotOpen;
+ }
+
+ BundleInstaller *installer = new ChatStyleInstaller(archive, tmpFile);
+ if(installer->validate() == BundleInstaller::BundleValid) {
+ installer->showRequest();
+
+ QObject::connect(installer, SIGNAL(finished(BundleInstaller::BundleStatus)), installer, SLOT(showResult()));
+ QObject::connect(installer, SIGNAL(showedResult()), this, SLOT(quit()));
+ QObject::connect(installer, SIGNAL(ignoredRequest()), this, SLOT(quit()));
+
+ kDebug() << "sent messagestyle request";
+ } else {
+ delete installer;
+ installer = new EmoticonSetInstaller(archive, tmpFile);
+ if(installer->validate() == BundleInstaller::BundleValid) {
+ installer->showRequest();
+
+ QObject::connect(installer, SIGNAL(finished(BundleInstaller::BundleStatus)), installer, SLOT(showResult()));
+ QObject::connect(installer, SIGNAL(showedResult()), this, SLOT(quit()));
+ QObject::connect(installer, SIGNAL(ignoredRequest()), this, SLOT(quit()));
+
+ kDebug() << "sent emoticonset request";
+ } else {
+ KNotification *notification = new KNotification("packagenotrecognized", NULL, KNotification::Persistent);
+ notification->setText( i18n("Package type not recognized or not supported") );
+ QObject::connect(notification, SIGNAL(action1Activated()), this, SLOT(install()));
+ QObject::connect(notification, SIGNAL(action1Activated()), notification, SLOT(close()));
+
+ QObject::connect(notification, SIGNAL(ignored()), this, SLOT(ignoreRequest()));
+ QObject::connect(notification, SIGNAL(ignored()), notification, SLOT(close()));
+ notification->setActions( QStringList() << i18n("Ok") );
+ notification->sendEvent();
+ kDebug() << "sent error";
+
+ return BundleInstaller::BundleUnknownError;
+ }
+ }
+
+ return BundleInstaller::BundleValid;
+}
diff --git a/adiumxtra-protocol-handler/adiumxtraprotocolhandler.h b/adiumxtra-protocol-handler/adiumxtraprotocolhandler.h
new file mode 100644
index 0000000..4f088dd
--- /dev/null
+++ b/adiumxtra-protocol-handler/adiumxtraprotocolhandler.h
@@ -0,0 +1,38 @@
+/*
+ KDE Telepathy AdiumxtraProtocolHandler - Install Adiumxtra packages through adiumxtra://-pseudo protocol
+ Copyright (C) 2010 Dominik Schmidt <domme at rautelinux.org>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+
+#ifndef ADIUMXTRAPROTOCOLHANDLER_H
+#define ADIUMXTRAPROTOCOLHANDLER_H
+
+#include "bundleinstaller.h"
+
+#include <KApplication>
+
+
+
+class AdiumxtraProtocolHandler : public KApplication
+{
+ public:
+ AdiumxtraProtocolHandler();
+ virtual ~AdiumxtraProtocolHandler();
+
+ BundleInstaller::BundleStatus install(const QString& path);
+};
+
+#endif // ADIUMXTRAPROTOCOLHANDLER_H
diff --git a/adiumxtra-protocol-handler/bundleinstaller.h b/adiumxtra-protocol-handler/bundleinstaller.h
index 863cc9a..aa8420a 100644
--- a/adiumxtra-protocol-handler/bundleinstaller.h
+++ b/adiumxtra-protocol-handler/bundleinstaller.h
@@ -15,10 +15,14 @@ class BundleInstaller : public QObject
virtual ~BundleInstaller(){ kDebug(); };
Q_SIGNALS:
- void finished();
+ void ignoredRequest();
+ void finished(BundleInstaller::BundleStatus status);
+ void showedResult();
public Q_SLOTS:
+ virtual void showRequest() = 0;
virtual BundleStatus install() = 0;
+ virtual void showResult() = 0;
};
#endif // BUNDLEINSTALLER_H
diff --git a/adiumxtra-protocol-handler/chatstyleinstaller.cpp b/adiumxtra-protocol-handler/chatstyleinstaller.cpp
index 2dab8a8..dc82def 100644
--- a/adiumxtra-protocol-handler/chatstyleinstaller.cpp
+++ b/adiumxtra-protocol-handler/chatstyleinstaller.cpp
@@ -4,6 +4,9 @@
#include <KDebug>
#include <KTemporaryFile>
#include <KArchiveFile>
+#include <KLocale>
+#include <KNotification>
+#include <KApplication>
ChatStyleInstaller::ChatStyleInstaller(KArchive *archive, KTemporaryFile *tmpFile)
@@ -51,7 +54,7 @@ BundleInstaller::BundleStatus ChatStyleInstaller::validate()
if(validResult >= 2) {
return BundleValid;
} else {
- return BundleValid;
+ return BundleNotValid;
}
}
@@ -70,7 +73,58 @@ BundleInstaller::BundleStatus ChatStyleInstaller::install()
kDebug()<< "status " << status;
delete(m_tmpFile);
- emit(finished());
+ m_status = status;
+
+ emit(finished(status));
return status;
}
+
+void ChatStyleInstaller::showRequest()
+{
+ kDebug();
+
+ KNotification *notification = new KNotification("chatstyleRequest", NULL, KNotification::Persistent);
+ notification->setText( i18n("Install Chatstyle %1", this->bundleName()) );
+ notification->setActions( QStringList() << i18n("Install") << i18n("Cancel") );
+
+ QObject::connect(notification, SIGNAL(action1Activated()), this, SLOT(install()));
+ QObject::connect(notification, SIGNAL(action1Activated()), notification, SLOT(close()));
+
+ QObject::connect(notification, SIGNAL(ignored()), this, SLOT(ignoreRequest()));
+ QObject::connect(notification, SIGNAL(ignored()), notification, SLOT(close()));
+
+ QObject::connect(notification, SIGNAL(action2Activated()), this, SLOT(ignoreRequest()));
+ QObject::connect(notification, SIGNAL(action2Activated()), notification, SLOT(close()));
+
+ notification->sendEvent();
+}
+
+void ChatStyleInstaller::showResult()
+{
+ kDebug();
+
+ KNotification *notification;
+ if(m_status == BundleInstaller::BundleInstallOk) {
+ notification = new KNotification("chatstyleSuccess", NULL, KNotification::Persistent);
+ notification->setText( i18n("Installed Chatstyle %1 successfully.", this->bundleName()) );
+ } else {
+ notification = new KNotification("chatstyleFailure", NULL, KNotification::Persistent);
+ notification->setText( i18n("Installation of Chatstyle %1 failed.", this->bundleName()) );
+ }
+
+ notification->setActions( QStringList() << i18n("OK") );
+ QObject::connect(notification, SIGNAL(action1Activated()), notification, SLOT(close()));
+ QObject::connect(notification, SIGNAL(ignored()), notification, SLOT(close()));
+
+ notification->sendEvent();
+
+ emit(showedResult());
+}
+
+void ChatStyleInstaller::ignoreRequest()
+{
+ kDebug();
+
+ emit(ignoredRequest());
+}
diff --git a/adiumxtra-protocol-handler/chatstyleinstaller.h b/adiumxtra-protocol-handler/chatstyleinstaller.h
index 2d0f657..ba6b145 100644
--- a/adiumxtra-protocol-handler/chatstyleinstaller.h
+++ b/adiumxtra-protocol-handler/chatstyleinstaller.h
@@ -18,12 +18,16 @@ class ChatStyleInstaller : public BundleInstaller
~ChatStyleInstaller() { kDebug(); };
public Q_SLOTS:
+ void showRequest();
BundleInstaller::BundleStatus install();
+ void showResult();
+ void ignoreRequest();
private:
KArchive *m_archive;
KTemporaryFile *m_tmpFile;
QString m_bundleName;
+ BundleInstaller::BundleStatus m_status;
};
diff --git a/adiumxtra-protocol-handler/emoticonsetinstaller.cpp b/adiumxtra-protocol-handler/emoticonsetinstaller.cpp
index e11ebd7..1fd5b3c 100644
--- a/adiumxtra-protocol-handler/emoticonsetinstaller.cpp
+++ b/adiumxtra-protocol-handler/emoticonsetinstaller.cpp
@@ -6,7 +6,8 @@
#include <KArchiveFile>
#include <KEmoticons>
#include <KArchiveDirectory>
-
+#include <KNotification>
+#include <KLocale>
EmoticonSetInstaller::EmoticonSetInstaller(KArchive *archive, KTemporaryFile *tmpFile)
{
@@ -64,6 +65,52 @@ BundleInstaller::BundleStatus EmoticonSetInstaller::install()
KEmoticons emoticons;
emoticons.installTheme(m_tmpFile->fileName());
- emit(finished());
+ // we trust in KEmoticons as it gives us no status information
+ // installTheme only returns a list of installed themes if we compare the list before and after
+ // the style could have been updated and the list would not have changed
+ emit(finished(BundleInstallOk));
return BundleInstallOk;
}
+
+void EmoticonSetInstaller::showRequest()
+{
+ kDebug();
+
+ KNotification *notification = new KNotification("emoticonsRequest", NULL, KNotification::Persistent);
+ notification->setText( i18n("Install Emoticonset %1", this->bundleName()) );
+ notification->setActions( QStringList() << i18n("Install") << i18n("Cancel") );
+
+ QObject::connect(notification, SIGNAL(action1Activated()), this, SLOT(install()));
+ QObject::connect(notification, SIGNAL(action1Activated()), notification, SLOT(close()));
+
+ QObject::connect(notification, SIGNAL(ignored()), this, SLOT(ignoreRequest()));
+ QObject::connect(notification, SIGNAL(ignored()), notification, SLOT(close()));
+
+ QObject::connect(notification, SIGNAL(action2Activated()), this, SLOT(ignoreRequest()));
+ QObject::connect(notification, SIGNAL(action2Activated()), notification, SLOT(close()));
+
+ notification->sendEvent();
+}
+
+void EmoticonSetInstaller::showResult()
+{
+ kDebug();
+
+ KNotification *notification = new KNotification("emoticonsSuccess", NULL, KNotification::Persistent);
+ notification->setText( i18n("Installed Emoticonset %1 successfully.", this->bundleName()) );
+
+ notification->setActions( QStringList() << i18n("OK") );
+ QObject::connect(notification, SIGNAL(action1Activated()), notification, SLOT(close()));
+ QObject::connect(notification, SIGNAL(ignored()), notification, SLOT(close()));
+
+ notification->sendEvent();
+
+ emit(showedResult());
+}
+
+void EmoticonSetInstaller::ignoreRequest()
+{
+ kDebug();
+
+ emit(ignoredRequest());
+}
diff --git a/adiumxtra-protocol-handler/emoticonsetinstaller.h b/adiumxtra-protocol-handler/emoticonsetinstaller.h
index 7f20470..f3efa31 100644
--- a/adiumxtra-protocol-handler/emoticonsetinstaller.h
+++ b/adiumxtra-protocol-handler/emoticonsetinstaller.h
@@ -15,9 +15,12 @@ class EmoticonSetInstaller : public BundleInstaller
EmoticonSetInstaller(KArchive *archive, KTemporaryFile *tmpFile);
BundleStatus validate();
QString bundleName();
+ void showRequest();
+ void showResult();
~EmoticonSetInstaller() { kDebug(); };
public Q_SLOTS:
+ void ignoreRequest();
BundleStatus install();
private:
diff --git a/adiumxtra-protocol-handler/main.cpp b/adiumxtra-protocol-handler/main.cpp
index 6aeafcd..338f156 100644
--- a/adiumxtra-protocol-handler/main.cpp
+++ b/adiumxtra-protocol-handler/main.cpp
@@ -1,24 +1,9 @@
-#include "chatstyleinstaller.h"
-#include "emoticonsetinstaller.h"
-#include <chatwindowstylemanager.h>
-
+#include "adiumxtraprotocolhandler.h"
#include <KApplication>
#include <KAboutData>
#include <KCmdLineArgs>
#include <KDebug>
-#include <KZip>
-#include <KTar>
-#include <KEmoticons>
-#include <KTemporaryFile>
-#include <kio/job.h>
-#include <kio/netaccess.h>
-#include <KNotification>
-#include <KIcon>
-
-bool install(const QString& path);
-
-KApplication *app;
int main(int argc, char *argv[])
{
@@ -34,100 +19,16 @@ int main(int argc, char *argv[])
KCmdLineArgs::addCmdLineOptions( options );
- app = new KApplication();
+ AdiumxtraProtocolHandler app;
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
for(int i = 0; i < args->count(); i++)
{
kDebug() << "install: " << args->arg(i);
- install(args->arg(i));
+ app.install(args->arg(i));
}
args->clear();
- return app->exec();
-}
-
-
-bool install(const QString &path)
-{
- kDebug();
-
- KUrl url(path);
- if(url.protocol() == "adiumxtra") {
- url.setProtocol("http");
- }
-
- KTemporaryFile *tmpFile = new KTemporaryFile();
- if (tmpFile->open()) {
- KIO::Job* getJob = KIO::file_copy(url.prettyUrl(), KUrl(tmpFile->fileName()), -1, KIO::Overwrite);
- if (!KIO::NetAccess::synchronousRun(getJob, 0)) {
- kDebug() << "download failed";
- return false;
- }
- }
-
- KArchive *archive = 0L;
-
- QString currentBundleMimeType = KMimeType::findByPath(tmpFile->fileName(), 0, false)->name();
- if (currentBundleMimeType == "application/zip") {
- archive = new KZip(tmpFile->fileName());
- } else if (currentBundleMimeType == "application/x-compressed-tar" || currentBundleMimeType == "application/x-bzip-compressed-tar" || currentBundleMimeType == "application/x-gzip" || currentBundleMimeType == "application/x-bzip") {
- archive = new KTar(tmpFile->fileName());
- } else {
- KNotification *notification = new KNotification("packagenotrecognized", NULL, KNotification::Persistent);
- notification->setText( i18n("Package type not recognized or not supported") );
- notification->setActions( QStringList() << i18n("Ok") );
- notification->sendEvent();
- kDebug() << "unsupported file type" << currentBundleMimeType;
- kDebug() << tmpFile->fileName();
- return false;
- }
-
- if (!archive->open(QIODevice::ReadOnly)) {
- delete archive;
- kDebug() << "cannot open theme file";
- return false;
- }
-
- BundleInstaller *installer = new ChatStyleInstaller(archive, tmpFile);
- if(installer->validate()) {
- KNotification *notification = new KNotification("installchatstyle", NULL, KNotification::Persistent);
- notification->setText( i18n("Install Chatstyle %1", installer->bundleName()) );
- notification->setActions( QStringList() << i18n("Install") << i18n("Cancel") );
-
- QObject::connect(notification, SIGNAL(action1Activated()), installer, SLOT(install()));
- QObject::connect(notification, SIGNAL(ignored()), app, SLOT(quit()));
- QObject::connect(notification, SIGNAL(action2Activated()), app, SLOT(quit()));
-
- QObject::connect(installer, SIGNAL(finished()), app, SLOT(quit()));
-
-
- notification->sendEvent();
- kDebug() << "sent messagestyle request";
- } else {
- delete installer;
- installer = new EmoticonSetInstaller(archive, tmpFile);
- if(installer->validate()) {
- KNotification *notification = new KNotification("installemoticonset", NULL, KNotification::Persistent);
- notification->setText( i18n("Install Emoticonset %1", installer->bundleName()) );
- notification->setActions( QStringList() << i18n("Install") << i18n("Cancel") );
-
- QObject::connect(notification, SIGNAL(action1Activated()), installer, SLOT(install()));
- QObject::connect(notification, SIGNAL(ignored()), app, SLOT(quit()));
- QObject::connect(notification, SIGNAL(action2Activated()), app, SLOT(quit()));
-
- QObject::connect(installer, SIGNAL(finished()), app, SLOT(quit()));
-
-
- notification->sendEvent();
- kDebug() << "sent emoticonset request";
- } else {
- KNotification *notification = new KNotification("packagenotrecognized", NULL, KNotification::Persistent);
- notification->setText( i18n("Package type not recognized or not supported") );
- notification->setActions( QStringList() << i18n("Ok") );
- notification->sendEvent();
- kDebug() << "sent error";
- }
- }
-}
+ return app.exec();
+}
\ No newline at end of file
--
ktp-text-ui packaging
More information about the pkg-kde-commits
mailing list