Import/Export backend prep

This commit is contained in:
Michal Horejsek
2020-05-14 15:22:29 +02:00
parent 9d65192ad7
commit b598779c0f
92 changed files with 6983 additions and 188 deletions

View File

@ -22,8 +22,10 @@ import (
"github.com/0xAX/notificator"
"github.com/ProtonMail/proton-bridge/internal/bridge"
"github.com/ProtonMail/proton-bridge/internal/frontend/cli"
cliie "github.com/ProtonMail/proton-bridge/internal/frontend/cli-ie"
"github.com/ProtonMail/proton-bridge/internal/frontend/qt"
"github.com/ProtonMail/proton-bridge/internal/frontend/types"
"github.com/ProtonMail/proton-bridge/internal/importexport"
"github.com/ProtonMail/proton-bridge/pkg/config"
"github.com/ProtonMail/proton-bridge/pkg/listener"
"github.com/sirupsen/logrus"
@ -86,3 +88,37 @@ func new(
return qt.New(version, buildVersion, showWindowOnStart, panicHandler, config, preferences, eventListener, updates, bridge, noEncConfirmator)
}
}
// NewImportExport returns initialized frontend based on `frontendType`, which can be `cli` or `qt`.
func NewImportExport(
version,
buildVersion,
frontendType string,
panicHandler types.PanicHandler,
config *config.Config,
eventListener listener.Listener,
updates types.Updater,
ie *importexport.ImportExport,
) Frontend {
ieWrap := types.NewImportExportWrap(ie)
return newImportExport(version, buildVersion, frontendType, panicHandler, config, eventListener, updates, ieWrap)
}
func newImportExport(
version,
buildVersion,
frontendType string,
panicHandler types.PanicHandler,
config *config.Config,
eventListener listener.Listener,
updates types.Updater,
ie types.ImportExporter,
) Frontend {
switch frontendType {
case "cli":
return cliie.New(panicHandler, config, eventListener, updates, ie)
default:
return cliie.New(panicHandler, config, eventListener, updates, ie)
//return qt.New(panicHandler, config, eventListener, updates, ie)
}
}