Shared GUI for Bridge and Import/Export

This commit is contained in:
Jakub
2020-05-27 15:58:50 +02:00
committed by Michal Horejsek
parent b598779c0f
commit 49316a935c
96 changed files with 11469 additions and 209 deletions

View File

@ -0,0 +1,89 @@
// Copyright (c) 2020 Proton Technologies AG
//
// This file is part of ProtonMail Bridge.
//
// ProtonMail Bridge 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.
//
// ProtonMail Bridge 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 ProtonMail Bridge. If not, see <https://www.gnu.org/licenses/>.
// +build !nogui
package qtie
import "github.com/ProtonMail/proton-bridge/internal/transfer"
// wrapper for QML
func (f *FrontendQt) setupAndLoadForImport(isFromIMAP bool, sourcePath, sourceEmail, sourcePassword, sourceServer, sourcePort, targetAddress string) {
var err error
defer func() {
if err != nil {
f.showError(err)
f.Qml.ImportStructuresLoadFinished(false)
} else {
f.Qml.ImportStructuresLoadFinished(true)
}
}()
if isFromIMAP {
f.transfer, err = f.ie.GetRemoteImporter(targetAddress, sourceEmail, sourcePassword, sourceServer, sourcePort)
if err != nil {
return
}
} else {
f.transfer, err = f.ie.GetLocalImporter(targetAddress, sourcePath)
if err != nil {
return
}
}
if err := f.loadStructuresForImport(); err != nil {
return
}
}
func (f *FrontendQt) loadStructuresForImport() error {
f.PMStructure.Clear()
targetMboxes, err := f.transfer.TargetMailboxes()
if err != nil {
return err
}
for _, mbox := range targetMboxes {
rule := &transfer.Rule{}
f.PMStructure.addEntry(newFolderInfo(mbox, rule))
}
f.ExternalStructure.Clear()
sourceMboxes, err := f.transfer.SourceMailboxes()
if err != nil {
return err
}
for _, mbox := range sourceMboxes {
rule := f.transfer.GetRule(mbox)
f.ExternalStructure.addEntry(newFolderInfo(mbox, rule))
}
f.ExternalStructure.transfer = f.transfer
return nil
}
func (f *FrontendQt) StartImport(email string) { // TODO email not needed
f.Qml.SetProgressDescription("init") // TODO use const
f.Qml.SetProgressFails(0)
f.Qml.SetProgress(0.0)
f.Qml.SetTotal(1)
f.Qml.SetImportLogFileName("")
f.ErrorList.Clear()
progress := f.transfer.Start()
f.setProgressManager(progress)
}