[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:20 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=8e76563
The following commit has been merged in the master branch:
commit 8e765638f74501081d34f14f0cb8953ae114757f
Author: Dominik Schmidt <ich at dominik-schmidt.de>
Date: Mon Oct 4 00:57:44 2010 +0000
Introduce adiumxtra-protocol-handler.
svn path=/trunk/playground/network/telepathy-chat-handler/; revision=1182262
---
CMakeLists.txt | 1 +
adiumxtra-protocol-handler/CMakeLists.txt | 25 ++++
.../adiumxtra-protocol-handler.notifyrc | 23 ++++
adiumxtra-protocol-handler/adiumxtra.protocol | 14 +++
adiumxtra-protocol-handler/bundleinstaller.cpp | 1 +
adiumxtra-protocol-handler/bundleinstaller.h | 25 ++++
adiumxtra-protocol-handler/chatstyleinstaller.cpp | 79 ++++++++++++
adiumxtra-protocol-handler/chatstyleinstaller.h | 30 +++++
.../emoticonsetinstaller.cpp | 70 +++++++++++
adiumxtra-protocol-handler/emoticonsetinstaller.h | 30 +++++
adiumxtra-protocol-handler/main.cpp | 133 +++++++++++++++++++++
11 files changed, 431 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8ca7699..d352370 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,3 +27,4 @@ add_subdirectory(lib)
add_subdirectory(app)
add_subdirectory(config)
add_subdirectory(data)
+add_subdirectory(adiumxtra-protocol-handler)
diff --git a/adiumxtra-protocol-handler/CMakeLists.txt b/adiumxtra-protocol-handler/CMakeLists.txt
new file mode 100644
index 0000000..63db702
--- /dev/null
+++ b/adiumxtra-protocol-handler/CMakeLists.txt
@@ -0,0 +1,25 @@
+# FIXME when the chat connection builds a lib correctly, don't do this weird horrible hack.
+
+include_directories(../lib/)
+
+set(telepathy_chat_config_SRCS
+ bundleinstaller.cpp
+ chatstyleinstaller.cpp
+ emoticonsetinstaller.cpp
+ main.cpp
+)
+
+
+
+kde4_add_ui_files(telepathy_chat_config_SRCS)
+
+kde4_add_executable(adiumxtra-protocol-handler ${telepathy_chat_config_SRCS})
+
+target_link_libraries(adiumxtra-protocol-handler ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBS} ${QT_QTWEBKIT_LIBRARY} ${KDE4_KUTILS_LIBS} ktelepathy_chat_lib)
+
+
+install(TARGETS adiumxtra-protocol-handler ${INSTALL_TARGETS_DEFAULT_ARGS})
+
+install( FILES adiumxtra.protocol DESTINATION ${SERVICES_INSTALL_DIR} )
+
+install(FILES adiumxtra-protocol-handler.notifyrc DESTINATION ${DATA_INSTALL_DIR}/adiumxtra-protocol-handler)
diff --git a/adiumxtra-protocol-handler/adiumxtra-protocol-handler.notifyrc b/adiumxtra-protocol-handler/adiumxtra-protocol-handler.notifyrc
new file mode 100644
index 0000000..f71f5fc
--- /dev/null
+++ b/adiumxtra-protocol-handler/adiumxtra-protocol-handler.notifyrc
@@ -0,0 +1,23 @@
+[Global]
+IconName=telepathy
+Comment=adiumxtra
+Name=adiumxtra-protocol-handler
+
+
+[Event/installchatstyle]
+Name=Install Chatstyle
+IconName=telepathy
+Action=Popup
+Flags=Persistent
+
+[Event/installemoticonset]
+Name=Install Emoticonset
+IconName=telepathy
+Action=Popup
+Flags=Persistent
+
+[Event/packagenotrecognized]
+Name=Package not recognized
+IconName=telepathy
+Action=Popup
+Flags=Persistent
diff --git a/adiumxtra-protocol-handler/adiumxtra.protocol b/adiumxtra-protocol-handler/adiumxtra.protocol
new file mode 100644
index 0000000..153b3c5
--- /dev/null
+++ b/adiumxtra-protocol-handler/adiumxtra.protocol
@@ -0,0 +1,14 @@
+[Protocol]
+Type=Service
+exec=adiumxtra-protocol-handler "%U"
+protocol=adiumxtra
+input=none
+output=none
+helper=true
+listing=
+reading=false
+writing=false
+makedir=false
+deleting=false
+URIMode=rawuri
+Icon=evolution
diff --git a/adiumxtra-protocol-handler/bundleinstaller.cpp b/adiumxtra-protocol-handler/bundleinstaller.cpp
new file mode 100644
index 0000000..ebc11e1
--- /dev/null
+++ b/adiumxtra-protocol-handler/bundleinstaller.cpp
@@ -0,0 +1 @@
+#include "bundleinstaller.h"
diff --git a/adiumxtra-protocol-handler/bundleinstaller.h b/adiumxtra-protocol-handler/bundleinstaller.h
new file mode 100644
index 0000000..da4fbc3
--- /dev/null
+++ b/adiumxtra-protocol-handler/bundleinstaller.h
@@ -0,0 +1,25 @@
+#ifndef BUNDLEINSTALLER_H
+#define BUNDLEINSTALLER_H
+
+#include "bundleinstaller.cpp"
+
+#include <KArchive>
+#include <KDebug>
+
+class BundleInstaller : public QObject
+{
+ Q_OBJECT
+
+ public:
+ virtual bool validate() = 0;
+ virtual QString bundleName() = 0;
+ virtual ~BundleInstaller(){ kDebug(); };
+
+ Q_SIGNALS:
+ void finished();
+
+ public Q_SLOTS:
+ virtual bool install() = 0;
+};
+
+#endif // BUNDLEINSTALLER_H
diff --git a/adiumxtra-protocol-handler/chatstyleinstaller.cpp b/adiumxtra-protocol-handler/chatstyleinstaller.cpp
new file mode 100644
index 0000000..279b086
--- /dev/null
+++ b/adiumxtra-protocol-handler/chatstyleinstaller.cpp
@@ -0,0 +1,79 @@
+#include "chatstyleinstaller.h"
+#include <chatwindowstylemanager.h>
+#include <chatstyleplistfilereader.h>
+#include <KDebug>
+#include <KTemporaryFile>
+#include <KArchiveFile>
+
+
+ChatStyleInstaller::ChatStyleInstaller(KArchive *archive, KTemporaryFile *tmpFile)
+{
+ kDebug();
+
+ m_archive = archive;
+ m_tmpFile = tmpFile;
+}
+
+bool ChatStyleInstaller::validate()
+{
+ kDebug();
+
+ KArchiveEntry *currentEntry = 0L;
+ KArchiveDirectory* currentDir = 0L;
+ const KArchiveDirectory* rootDir = m_archive->directory();
+ int validResult = 0;
+ const QStringList entries = rootDir->entries();
+ QStringList::ConstIterator entriesIt, entriesItEnd = entries.end();
+ for (entriesIt = entries.begin(); entriesIt != entries.end(); ++entriesIt) {
+ currentEntry = const_cast<KArchiveEntry*>(rootDir->entry(*entriesIt));
+ kDebug() << "Current entry name: " << currentEntry->name();
+ if (currentEntry->isDirectory()) {
+ currentDir = dynamic_cast<KArchiveDirectory*>(currentEntry);
+ if (currentDir) {
+ if (currentDir->entry(QString::fromUtf8("Contents"))) {
+ kDebug() << "Contents found";
+ validResult += 1;
+ }
+ if (currentDir->entry(QString::fromUtf8("Contents/Info.plist"))) {
+ kDebug() << "Contents/Info.plist found";
+ KArchiveFile const *info = dynamic_cast<KArchiveFile const *>(currentDir->entry(QString::fromUtf8("Contents/Info.plist")));
+ ChatStylePlistFileReader reader(info->data());
+ if(m_bundleName.isEmpty()) {
+ m_bundleName = reader.CFBundleName();
+ }
+ validResult += 1;
+ }
+ }
+ }
+ }
+
+ if(validResult >= 2) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+QString ChatStyleInstaller::bundleName()
+{
+ kDebug();
+
+ return m_bundleName;
+}
+
+bool ChatStyleInstaller::install()
+{
+ kDebug();
+
+ int status = ChatWindowStyleManager::self()->installStyle(m_archive->fileName());
+ kDebug()<< "status " << status;
+ delete(m_tmpFile);
+
+ emit(finished());
+
+ if(!status) {
+ return true;
+ } else {
+ return false;
+ }
+}
diff --git a/adiumxtra-protocol-handler/chatstyleinstaller.h b/adiumxtra-protocol-handler/chatstyleinstaller.h
new file mode 100644
index 0000000..0323218
--- /dev/null
+++ b/adiumxtra-protocol-handler/chatstyleinstaller.h
@@ -0,0 +1,30 @@
+#ifndef CHATSTYLEINSTALLER_H
+#define CHATSTYLEINSTALLER_H
+
+#include "bundleinstaller.h"
+
+#include <KDebug>
+
+class KTemporaryFile;
+
+class ChatStyleInstaller : public BundleInstaller
+{
+ Q_OBJECT
+
+ public:
+ ChatStyleInstaller(KArchive *archive, KTemporaryFile *tmpFile);
+ bool validate();
+ QString bundleName();
+ ~ChatStyleInstaller() { kDebug(); };
+
+ public Q_SLOTS:
+ bool install();
+
+ private:
+ KArchive *m_archive;
+ KTemporaryFile *m_tmpFile;
+ QString m_bundleName;
+
+};
+
+#endif // CHATSTYLEINSTALLER_H
diff --git a/adiumxtra-protocol-handler/emoticonsetinstaller.cpp b/adiumxtra-protocol-handler/emoticonsetinstaller.cpp
new file mode 100644
index 0000000..b4cb354
--- /dev/null
+++ b/adiumxtra-protocol-handler/emoticonsetinstaller.cpp
@@ -0,0 +1,70 @@
+#include "emoticonsetinstaller.h"
+#include <chatwindowstylemanager.h>
+#include <chatstyleplistfilereader.h>
+#include <KDebug>
+#include <KTemporaryFile>
+#include <KArchiveFile>
+#include <KEmoticons>
+#include <KArchiveDirectory>
+
+
+EmoticonSetInstaller::EmoticonSetInstaller(KArchive *archive, KTemporaryFile *tmpFile)
+{
+ kDebug();
+
+ m_archive = archive;
+ m_tmpFile = tmpFile;
+}
+
+bool EmoticonSetInstaller::validate()
+{
+ kDebug();
+
+ KArchiveEntry *currentEntry = 0L;
+ KArchiveDirectory* currentDir = 0L;
+ if(m_archive == 0) exit(1);
+ m_archive->fileName();
+ m_archive->directory();
+ const KArchiveDirectory* rootDir = m_archive->directory();
+ int validResult = 0;
+ const QStringList entries = rootDir->entries();
+ // Will be reused later.
+ QStringList::ConstIterator entriesIt, entriesItEnd = entries.end();
+ for (entriesIt = entries.begin(); entriesIt != entries.end(); ++entriesIt) {
+ currentEntry = const_cast<KArchiveEntry*>(rootDir->entry(*entriesIt));
+ kDebug() << "Current entry name: " << currentEntry->name();
+ if (currentEntry->isDirectory()) {
+ currentDir = dynamic_cast<KArchiveDirectory*>(currentEntry);
+ if (currentDir) {
+ if (currentDir->entry(QString::fromUtf8("Emoticons.plist"))) {
+ kDebug() << "Emoticons.plist found";
+ QString currentItem = currentEntry->name();
+ if(m_bundleName.isEmpty() && currentItem.endsWith(".AdiumEmoticonset")) {
+ m_bundleName = currentItem.remove(".AdiumEmoticonset");
+ }
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+}
+
+QString EmoticonSetInstaller::bundleName()
+{
+ kDebug();
+
+ return m_bundleName;
+}
+
+bool EmoticonSetInstaller::install()
+{
+ kDebug();
+
+ KEmoticons emoticons;
+ emoticons.installTheme(m_tmpFile->fileName());
+
+ emit(finished());
+ return true;
+}
diff --git a/adiumxtra-protocol-handler/emoticonsetinstaller.h b/adiumxtra-protocol-handler/emoticonsetinstaller.h
new file mode 100644
index 0000000..8bf46d6
--- /dev/null
+++ b/adiumxtra-protocol-handler/emoticonsetinstaller.h
@@ -0,0 +1,30 @@
+#ifndef EMOTICONSETINSTALLER_H
+#define EMOTICONSETINSTALLER_H
+
+#include "bundleinstaller.h"
+
+#include <KDebug>
+
+class KTemporaryFile;
+
+class EmoticonSetInstaller : public BundleInstaller
+{
+ Q_OBJECT
+
+ public:
+ EmoticonSetInstaller(KArchive *archive, KTemporaryFile *tmpFile);
+ bool validate();
+ QString bundleName();
+ ~EmoticonSetInstaller() { kDebug(); };
+
+ public Q_SLOTS:
+ bool install();
+
+private:
+ KArchive *m_archive;
+ KTemporaryFile *m_tmpFile;
+ QString m_bundleName;
+
+};
+
+#endif // EMOTICONSETINSTALLER_H
diff --git a/adiumxtra-protocol-handler/main.cpp b/adiumxtra-protocol-handler/main.cpp
new file mode 100644
index 0000000..6aeafcd
--- /dev/null
+++ b/adiumxtra-protocol-handler/main.cpp
@@ -0,0 +1,133 @@
+#include "chatstyleinstaller.h"
+#include "emoticonsetinstaller.h"
+#include <chatwindowstylemanager.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[])
+{
+ kDebug();
+
+ KAboutData aboutData("adiumxtra-protocol-handler",
+ 0,
+ ki18n("AdiumXtra Protocol Handler"),
+ "0.1");
+ KCmdLineArgs::init(argc, argv, &aboutData);
+ KCmdLineOptions options;
+ options.add("!+install-chatstyles", ki18n("Install Adium packages"));
+ KCmdLineArgs::addCmdLineOptions( options );
+
+
+ app = new KApplication();
+
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+ for(int i = 0; i < args->count(); i++)
+ {
+ kDebug() << "install: " << args->arg(i);
+ 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";
+ }
+ }
+}
--
ktp-text-ui packaging
More information about the pkg-kde-commits
mailing list