From 57429a6ec932978dbefd1c520ca98077c1c733a7 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sat, 16 Jul 2016 10:40:18 +0200 Subject: Kolabnow account configuration --- accounts/CMakeLists.txt | 1 + accounts/kolabnow/CMakeLists.txt | 48 +++++++ accounts/kolabnow/kolabnowaccountplugin.cpp | 29 ++++ accounts/kolabnow/kolabnowaccountplugin.h | 31 +++++ accounts/kolabnow/kolabnowsettings.cpp | 58 ++++++++ accounts/kolabnow/kolabnowsettings.h | 33 +++++ .../contents/ui/KolabnowAccountSettings.qml | 153 +++++++++++++++++++++ accounts/kolabnow/package/metadata.desktop | 8 ++ accounts/kolabnow/qmldir | 3 + 9 files changed, 364 insertions(+) create mode 100644 accounts/kolabnow/CMakeLists.txt create mode 100644 accounts/kolabnow/kolabnowaccountplugin.cpp create mode 100644 accounts/kolabnow/kolabnowaccountplugin.h create mode 100644 accounts/kolabnow/kolabnowsettings.cpp create mode 100644 accounts/kolabnow/kolabnowsettings.h create mode 100644 accounts/kolabnow/package/contents/ui/KolabnowAccountSettings.qml create mode 100644 accounts/kolabnow/package/metadata.desktop create mode 100644 accounts/kolabnow/qmldir (limited to 'accounts') diff --git a/accounts/CMakeLists.txt b/accounts/CMakeLists.txt index 212a62ff..e941e07d 100644 --- a/accounts/CMakeLists.txt +++ b/accounts/CMakeLists.txt @@ -1,2 +1,3 @@ add_subdirectory(maildir) add_subdirectory(imap) +add_subdirectory(kolabnow) diff --git a/accounts/kolabnow/CMakeLists.txt b/accounts/kolabnow/CMakeLists.txt new file mode 100644 index 00000000..c8a2481f --- /dev/null +++ b/accounts/kolabnow/CMakeLists.txt @@ -0,0 +1,48 @@ +project(kube-accounts-kolabnow) + +cmake_minimum_required(VERSION 2.8.12) + +include(CPack) +include(FeatureSummary) +find_package(PkgConfig) + +################# set KDE specific information ################# + +find_package(ECM 0.0.8 REQUIRED NO_MODULE) + +# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) + +include(KDEInstallDirs) +include(KDECMakeSettings) +include(KDECompilerSettings) + +find_package(Qt5 REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui) + +set (QT_MIN_VERSION "5.4.0") +find_package(Sink CONFIG REQUIRED) +find_package(KF5Async CONFIG REQUIRED) +find_package(KF5 REQUIRED COMPONENTS Package Mime) + +include_directories(SYSTEM ${KDE_INSTALL_FULL_INCLUDEDIR}/KF5/) +#FIXME +include_directories(../../framework/) + +set(SRCS + kolabnowsettings.cpp + kolabnowaccountplugin.cpp +) + +add_library(kolabnowaccountplugin SHARED ${SRCS}) +qt5_use_modules(kolabnowaccountplugin Core Quick Qml) +target_link_libraries(kolabnowaccountplugin sink settingsplugin mailplugin) + +add_library(kolabnowaccount_static STATIC ${SRCS}) +qt5_use_modules(kolabnowaccount_static Core Quick Qml) +target_link_libraries(kolabnowaccount_static sink settingsplugin mailplugin) +# add_subdirectory(tests) + +kpackage_install_package(package org.kube.accounts.kolabnow "genericqml") + +install(TARGETS kolabnowaccountplugin DESTINATION ${QML_INSTALL_DIR}/org/kube/accounts/kolabnow) +install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kube/accounts/kolabnow) diff --git a/accounts/kolabnow/kolabnowaccountplugin.cpp b/accounts/kolabnow/kolabnowaccountplugin.cpp new file mode 100644 index 00000000..9c9aaff6 --- /dev/null +++ b/accounts/kolabnow/kolabnowaccountplugin.cpp @@ -0,0 +1,29 @@ +/* + Copyright (c) 2016 Christian Mollekopf + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2 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 Library General Public + License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ +#include "kolabnowaccountplugin.h" + +#include "kolabnowsettings.h" + +#include + +void KolabnowAccountPlugin::registerTypes (const char *uri) +{ + Q_ASSERT(uri == QLatin1String("org.kube.accounts.kolabnow")); + qmlRegisterType(uri, 1, 0, "KolabnowSettings"); +} diff --git a/accounts/kolabnow/kolabnowaccountplugin.h b/accounts/kolabnow/kolabnowaccountplugin.h new file mode 100644 index 00000000..3d5e2d88 --- /dev/null +++ b/accounts/kolabnow/kolabnowaccountplugin.h @@ -0,0 +1,31 @@ +/* + Copyright (c) 2016 Christian Mollekopf + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2 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 Library General Public + License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ +#pragma once + +#include +#include + +class KolabnowAccountPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + +public: + virtual void registerTypes(const char *uri); +}; diff --git a/accounts/kolabnow/kolabnowsettings.cpp b/accounts/kolabnow/kolabnowsettings.cpp new file mode 100644 index 00000000..486a4c5f --- /dev/null +++ b/accounts/kolabnow/kolabnowsettings.cpp @@ -0,0 +1,58 @@ +/* + Copyright (c) 2016 Christian Mollekopf + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2 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 Library General Public + License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ +#include "kolabnowsettings.h" + +KolabnowSettings::KolabnowSettings(QObject *parent) + : AccountSettings(parent) +{ +} + +void KolabnowSettings::load() +{ + loadAccount(); + loadImapResource(); + loadMailtransportResource(); + loadIdentity(); +} + +void KolabnowSettings::save() +{ + mUsername = mEmailAddress; + mImapServer = "imaps://imap.kolabnow.com:993"; + mImapUsername = mEmailAddress; + // mImapPassword = mPassword; + + mSmtpServer = "smtps://smtp.kolabnow.com:587"; + mSmtpUsername = mEmailAddress; + mSmtpPassword = mImapPassword; + + saveAccount(); + saveImapResource(); + saveMailtransportResource(); + saveIdentity(); +} + +void KolabnowSettings::remove() +{ + removeResource(mMailtransportIdentifier); + removeResource(mImapIdentifier); + removeIdentity(); + removeAccount(); +} + diff --git a/accounts/kolabnow/kolabnowsettings.h b/accounts/kolabnow/kolabnowsettings.h new file mode 100644 index 00000000..43dc1133 --- /dev/null +++ b/accounts/kolabnow/kolabnowsettings.h @@ -0,0 +1,33 @@ +/* + Copyright (c) 2016 Christian Mollekopf + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2 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 Library General Public + License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ +#pragma once + +#include + +class KolabnowSettings : public AccountSettings +{ + Q_OBJECT + +public: + KolabnowSettings(QObject *parent = 0); + + Q_INVOKABLE virtual void load() Q_DECL_OVERRIDE; + Q_INVOKABLE virtual void save() Q_DECL_OVERRIDE; + Q_INVOKABLE virtual void remove() Q_DECL_OVERRIDE; +}; diff --git a/accounts/kolabnow/package/contents/ui/KolabnowAccountSettings.qml b/accounts/kolabnow/package/contents/ui/KolabnowAccountSettings.qml new file mode 100644 index 00000000..274b9207 --- /dev/null +++ b/accounts/kolabnow/package/contents/ui/KolabnowAccountSettings.qml @@ -0,0 +1,153 @@ +/* + * Copyright (C) 2016 Michael Bohlender + * + * 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 . + */ + +import QtQuick 2.4 +import QtQuick.Controls 1.4 +import QtQuick.Layouts 1.1 + +import org.kde.kirigami 1.0 as Kirigami + +import org.kube.framework.settings 1.0 as KubeSettings +import org.kube.accounts.kolabnow 1.0 as KolabnowAccount + + +Item { + + property string accountId + + KolabnowAccount.KolabnowSettings { + id: kolabnowSettings + accountIdentifier: accountId + } + + anchors.fill: parent + + Item { + anchors { + fill: parent + margins: Kirigami.Units.largeSpacing * 2 + } + + Kirigami.Heading { + id: heading + text: "Connect your KOLABNOW account" + + color: Kirigami.Theme.highlightColor + } + + Label { + id: subHeadline + + anchors { + left: heading.left + top: heading.bottom + } + + width: parent.width + + text: "To let Kube access your KOLABNOW account, fill in email address and password and give the account a title that will be displayed inside Kube." + //TODO wait for kirgami theme disabled text color + opacity: 0.5 + wrapMode: Text.Wrap + } + + + GridLayout { + anchors { + top:subHeadline.bottom + bottom: parent.bottom + left: parent.left + right: parent.right + topMargin: Kirigami.Units.largeSpacing + bottomMargin: Kirigami.Units.largeSpacing * 2 + } + + columns: 2 + columnSpacing: Kirigami.Units.largeSpacing + rowSpacing: Kirigami.Units.largeSpacing + + Kirigami.Label { + text: "Title of Account" + Layout.alignment: Qt.AlignRight + } + TextField { + Layout.fillWidth: true + + text: kolabnowSettings.accountName + placeholderText: "KOLABNOW" + onTextChanged: { + kolabnowSettings.accountName = text + } + } + + Kirigami.Label { + text: "Email address" + Layout.alignment: Qt.AlignRight + } + TextField { + Layout.fillWidth: true + + text: kolabnowSettings.emailAddress + onTextChanged: { + kolabnowSettings.emailAddress = text + } + } + + Kirigami.Label { + text: "Password" + Layout.alignment: Qt.AlignRight + } + TextField { + Layout.fillWidth: true + + text: kolabnowSettings.imapPassword + onTextChanged: { + kolabnowSettings.imapPassword = text + kolabnowSettings.smtpPassword = text + } + } + + Label { + text: "" + } + Item { + Layout.fillWidth: true + + Button { + text: "Delete" + + onClicked: { + kolabnowSettings.remove() + root.closeDialog() + } + } + + Button { + anchors.right: parent.right + + text: "Save" + + onClicked: { + focus: true + kolabnowSettings.save() + root.closeDialog() + } + } + } + } + } +} diff --git a/accounts/kolabnow/package/metadata.desktop b/accounts/kolabnow/package/metadata.desktop new file mode 100644 index 00000000..6777e2d1 --- /dev/null +++ b/accounts/kolabnow/package/metadata.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Name=Kube Kolabnow Accounts Plugin +X-KDE-PluginInfo-Name=org.kube.accounts.kolabnow +Exec=kpackagelauncherqml -a org.kube.accounts.kolabnow +X-Plasma-MainScript=ui/KolabnowAccountSettings.qml +X-KDE-ServiceTypes=KPackage/GenericQML +Icon=folder +Type=Service diff --git a/accounts/kolabnow/qmldir b/accounts/kolabnow/qmldir new file mode 100644 index 00000000..6eb25c24 --- /dev/null +++ b/accounts/kolabnow/qmldir @@ -0,0 +1,3 @@ +module org.kube.accounts.kolabnow + +plugin kolabnowaccountplugin -- cgit v1.2.3