diff options
-rw-r--r-- | accounts.cpp | 7 | ||||
-rw-r--r-- | accounts.h | 1 | ||||
-rw-r--r-- | context.cpp | 7 | ||||
-rw-r--r-- | context.h | 1 | ||||
-rw-r--r-- | qml/AccountsPage.qml | 28 | ||||
-rw-r--r-- | qml/ConfigurePage.qml | 23 |
6 files changed, 31 insertions, 36 deletions
diff --git a/accounts.cpp b/accounts.cpp index 3662dcc..8a71668 100644 --- a/accounts.cpp +++ b/accounts.cpp @@ -22,13 +22,6 @@ DcAccounts::addAccount() } uint32_t -DcAccounts::importAccount(QString tarfile) -{ - QByteArray utf8Text = tarfile.toUtf8(); - return dc_accounts_import_account(m_accounts, utf8Text.constData()); -} - -uint32_t DcAccounts::migrateAccount(QString dbfile) { QByteArray utf8Text = dbfile.toUtf8(); @@ -14,7 +14,6 @@ public: ~DcAccounts(); Q_INVOKABLE uint32_t addAccount(); - Q_INVOKABLE uint32_t importAccount(QString tarfile); Q_INVOKABLE uint32_t migrateAccount(QString dbfile); Q_INVOKABLE bool removeAccount(uint32_t accountId); Q_INVOKABLE QVariantList getAll(); diff --git a/context.cpp b/context.cpp index ea9c5c4..fbd4129 100644 --- a/context.cpp +++ b/context.cpp @@ -224,3 +224,10 @@ Context::newMessage(int viewtype) dc_msg_t *message = dc_msg_new(m_context, viewtype); return new DcMessage{message}; } + +void +Context::importBackup(QString tarfile) +{ + QByteArray utf8Text = tarfile.toUtf8(); + return dc_imex(m_context, DC_IMEX_IMPORT_BACKUP, utf8Text.constData(), NULL); +} @@ -49,6 +49,7 @@ public: Q_INVOKABLE QString getMessageHtml(uint32_t msgId); Q_INVOKABLE uint32_t decideOnContactRequest(uint32_t msgId, int decision); Q_INVOKABLE DcMessage *newMessage(int viewtype); + Q_INVOKABLE void importBackup(QString tarfile); private: dc_context_t *m_context{nullptr}; diff --git a/qml/AccountsPage.qml b/qml/AccountsPage.qml index 0088777..bf39d7e 100644 --- a/qml/AccountsPage.qml +++ b/qml/AccountsPage.qml @@ -1,7 +1,6 @@ import QtQuick 2.12 import QtQuick.Controls 2.12 import QtQuick.Layouts 1.12 -import QtQuick.Dialogs 1.3 import org.kde.kirigami 2.12 as Kirigami Kirigami.Page { @@ -30,33 +29,6 @@ Kirigami.Page { } } - contextualActions: [ - Kirigami.Action { - text: "Import account" - iconName: "document-import" - onTriggered: importAccountDialog.open() - } - ] - - FileDialog { - id: importAccountDialog - title: "Import account" - folder: shortcuts.home - onAccepted: { - var url = importAccountDialog.fileUrl.toString() - if (url.startsWith("file://")) { - var filename = url.substring(7) - console.log("Importing " + filename) - var accountId = dcAccounts.importAccount(filename) - if (accountId == 0) { - console.log("Import failed") - } else { - console.log("Import succeeded") - } - } - } - } - ListModel { id: accountsModel } diff --git a/qml/ConfigurePage.qml b/qml/ConfigurePage.qml index 8a5d9d3..4e0dd49 100644 --- a/qml/ConfigurePage.qml +++ b/qml/ConfigurePage.qml @@ -2,6 +2,7 @@ import QtQuick 2.12 import QtQuick.Controls 2.12 import QtQuick.Layouts 1.12 import QtQml.Models 2.1 +import QtQuick.Dialogs 1.3 import org.kde.kirigami 2.12 as Kirigami import DeltaChat 1.0 @@ -13,6 +14,28 @@ Kirigami.Page { required property DcContext context required property DcAccountsEventEmitter eventEmitter + contextualActions: [ + Kirigami.Action { + text: "Import backup" + iconName: "document-import" + onTriggered: importBackupDialog.open() + } + ] + + FileDialog { + id: importBackupDialog + title: "Import backup" + folder: shortcuts.home + onAccepted: { + var url = importBackupDialog.fileUrl.toString() + if (url.startsWith("file://")) { + var filename = url.substring(7) + console.log("Importing " + filename) + configurePage.context.importBackup(filename) + } + } + } + Kirigami.FormLayout { anchors.fill: parent |