diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-11-24 15:48:43 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-11-24 15:48:43 +0100 |
commit | 9e937c1d987d407d974c9a2840a9b0581e43dcd0 (patch) | |
tree | b53512282742713907191d89f012cdb1e4602c7a | |
parent | f39da702c61685dc9b2437c533f74a3eed04a3e2 (diff) | |
download | kube-9e937c1d987d407d974c9a2840a9b0581e43dcd0.tar.gz kube-9e937c1d987d407d974c9a2840a9b0581e43dcd0.zip |
Support unlocking the keyring from the commandline
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | applications/kube/CMakeLists.txt | 1 | ||||
-rw-r--r-- | applications/kube/main.cpp | 30 | ||||
-rw-r--r-- | framework/src/CMakeLists.txt | 16 |
4 files changed, 42 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f52c825..2cbde180 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -25,6 +25,7 @@ include(KDECMakeSettings NO_POLICY_SCOPE) | |||
25 | 25 | ||
26 | enable_testing() | 26 | enable_testing() |
27 | 27 | ||
28 | include_directories(.) | ||
28 | add_subdirectory(framework) | 29 | add_subdirectory(framework) |
29 | add_subdirectory(components) | 30 | add_subdirectory(components) |
30 | add_subdirectory(icons) | 31 | add_subdirectory(icons) |
diff --git a/applications/kube/CMakeLists.txt b/applications/kube/CMakeLists.txt index 2d4c9da7..c206f22a 100644 --- a/applications/kube/CMakeLists.txt +++ b/applications/kube/CMakeLists.txt | |||
@@ -22,6 +22,7 @@ target_link_libraries(${PROJECT_NAME} | |||
22 | Qt5::WebEngine | 22 | Qt5::WebEngine |
23 | KF5::Package | 23 | KF5::Package |
24 | ${CMAKE_DL_LIBS} | 24 | ${CMAKE_DL_LIBS} |
25 | kubeframework | ||
25 | ) | 26 | ) |
26 | 27 | ||
27 | install(TARGETS ${PROJECT_NAME} DESTINATION ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) | 28 | install(TARGETS ${PROJECT_NAME} DESTINATION ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) |
diff --git a/applications/kube/main.cpp b/applications/kube/main.cpp index a6b51c38..88e44eac 100644 --- a/applications/kube/main.cpp +++ b/applications/kube/main.cpp | |||
@@ -32,6 +32,8 @@ | |||
32 | 32 | ||
33 | #include <QApplication> | 33 | #include <QApplication> |
34 | #include <QQmlApplicationEngine> | 34 | #include <QQmlApplicationEngine> |
35 | #include <QCommandLineParser> | ||
36 | #include <QJsonDocument> | ||
35 | 37 | ||
36 | #include <QStandardPaths> | 38 | #include <QStandardPaths> |
37 | #include <KPackage/PackageLoader> | 39 | #include <KPackage/PackageLoader> |
@@ -40,6 +42,7 @@ | |||
40 | #include <QtWebEngine> | 42 | #include <QtWebEngine> |
41 | 43 | ||
42 | #include <QDebug> | 44 | #include <QDebug> |
45 | #include "framework/src/keyring.h" | ||
43 | 46 | ||
44 | //Print a demangled stacktrace | 47 | //Print a demangled stacktrace |
45 | void printStacktrace() | 48 | void printStacktrace() |
@@ -169,14 +172,39 @@ public: | |||
169 | 172 | ||
170 | int main(int argc, char *argv[]) | 173 | int main(int argc, char *argv[]) |
171 | { | 174 | { |
172 | |||
173 | std::signal(SIGSEGV, crashHandler); | 175 | std::signal(SIGSEGV, crashHandler); |
174 | std::signal(SIGABRT, crashHandler); | 176 | std::signal(SIGABRT, crashHandler); |
175 | std::set_terminate(terminateHandler); | 177 | std::set_terminate(terminateHandler); |
176 | 178 | ||
177 | QApplication app(argc, argv); | 179 | QApplication app(argc, argv); |
180 | app.setApplicationName("kube"); | ||
178 | app.setFont(QFont{"Noto Sans", app.font().pointSize(), QFont::Normal}); | 181 | app.setFont(QFont{"Noto Sans", app.font().pointSize(), QFont::Normal}); |
179 | 182 | ||
183 | QCommandLineParser parser; | ||
184 | parser.setApplicationDescription("A communication and collaboration client."); | ||
185 | parser.addHelpOption(); | ||
186 | parser.addOption({{"k", "keyring"}, | ||
187 | QCoreApplication::translate("main", "To automatically unlock the keyring pass in a keyring in the form of {\"accountId\": {\"resourceId\": \"secret\", *}}"), | ||
188 | "keyring dictionary"} | ||
189 | ); | ||
190 | parser.process(app); | ||
191 | |||
192 | if (parser.isSet("keyring")) { | ||
193 | auto keyringDict = parser.value("keyring"); | ||
194 | auto json = QJsonDocument::fromJson(keyringDict.toUtf8()); | ||
195 | if (!json.isObject()) { | ||
196 | qWarning() << "Not a valid keyring dict " << keyringDict; | ||
197 | return -1; | ||
198 | } | ||
199 | auto object = json.object(); | ||
200 | for (const auto accountId : object.keys()) { | ||
201 | auto dict = object.value(accountId).toObject(); | ||
202 | for (const auto resourceId : dict.keys()) { | ||
203 | Kube::AccountKeyring{accountId.toUtf8()}.storePassword(resourceId.toUtf8(), dict.value(resourceId).toString().toUtf8()); | ||
204 | } | ||
205 | } | ||
206 | } | ||
207 | |||
180 | QtWebEngine::initialize(); | 208 | QtWebEngine::initialize(); |
181 | QIcon::setThemeName("kube"); | 209 | QIcon::setThemeName("kube"); |
182 | 210 | ||
diff --git a/framework/src/CMakeLists.txt b/framework/src/CMakeLists.txt index 7b188a49..2febf91b 100644 --- a/framework/src/CMakeLists.txt +++ b/framework/src/CMakeLists.txt | |||
@@ -14,7 +14,9 @@ set(CMAKE_CXX_VISIBILITY_PRESET default) | |||
14 | include_directories(. domain/mime/mimetreeparser domain/ domain/mime) | 14 | include_directories(. domain/mime/mimetreeparser domain/ domain/mime) |
15 | 15 | ||
16 | set(SRCS | 16 | set(SRCS |
17 | frameworkplugin.cpp | 17 | ) |
18 | |||
19 | add_library(kubeframework SHARED | ||
18 | settings/settings.cpp | 20 | settings/settings.cpp |
19 | domain/maillistmodel.cpp | 21 | domain/maillistmodel.cpp |
20 | domain/folderlistmodel.cpp | 22 | domain/folderlistmodel.cpp |
@@ -48,10 +50,8 @@ set(SRCS | |||
48 | webengineprofile.cpp | 50 | webengineprofile.cpp |
49 | startupcheck.cpp | 51 | startupcheck.cpp |
50 | keyring.cpp | 52 | keyring.cpp |
51 | ) | 53 | ) |
52 | 54 | target_link_libraries(kubeframework | |
53 | add_library(frameworkplugin SHARED ${SRCS}) | ||
54 | target_link_libraries(frameworkplugin | ||
55 | sink | 55 | sink |
56 | kube_otp | 56 | kube_otp |
57 | Qt5::Core | 57 | Qt5::Core |
@@ -66,6 +66,12 @@ target_link_libraries(frameworkplugin | |||
66 | KAsync | 66 | KAsync |
67 | QGpgme | 67 | QGpgme |
68 | ) | 68 | ) |
69 | install(TARGETS kubeframework DESTINATION ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) | ||
70 | |||
71 | add_library(frameworkplugin SHARED frameworkplugin.cpp) | ||
72 | target_link_libraries(frameworkplugin | ||
73 | kubeframework | ||
74 | ) | ||
69 | install(TARGETS frameworkplugin DESTINATION ${FRAMEWORK_INSTALL_DIR}) | 75 | install(TARGETS frameworkplugin DESTINATION ${FRAMEWORK_INSTALL_DIR}) |
70 | 76 | ||
71 | set(BUILD_TESTING ON) | 77 | set(BUILD_TESTING ON) |