IMAP: Use useful default without destination.

* We now use the account name as destination directory.
* Turns out that an empty string is written as destination which worked
  around the GetString() solution.
This commit is contained in:
Axel Dörfler
2015-01-06 15:25:51 +01:00
parent eba458b940
commit 28ee6c2839
4 changed files with 16 additions and 7 deletions
@@ -256,7 +256,7 @@ FolderConfigWindow::FolderConfigWindow(BRect parent, const BMessage& settings)
BWindow(BRect(0, 0, 350, 350), B_TRANSLATE("IMAP Folders"), BWindow(BRect(0, 0, 350, 350), B_TRANSLATE("IMAP Folders"),
B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL,
B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS), B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS),
fSettings(settings) fSettings("in", settings)
{ {
fQuotaView = new BStringView("quota view", fQuotaView = new BStringView("quota view",
B_TRANSLATE("Failed to fetch available storage.")); B_TRANSLATE("Failed to fetch available storage."));
@@ -16,14 +16,14 @@
IMAPProtocol::IMAPProtocol(const BMailAccountSettings& settings) IMAPProtocol::IMAPProtocol(const BMailAccountSettings& settings)
: :
BInboundMailProtocol(settings), BInboundMailProtocol(settings),
fSettings(settings.InboundSettings()), fSettings(settings.Name(), settings.InboundSettings()),
fWorkers(5, false) fWorkers(5, false)
{ {
BPath destination = fSettings.Destination(); BPath destination = fSettings.Destination();
status_t status = create_directory(destination.Path(), 0755); status_t status = create_directory(destination.Path(), 0755);
if (status != B_OK) { if (status != B_OK) {
fprintf(stderr, "imap: Could not create destination directory %s: %s\n", fprintf(stderr, "IMAP: Could not create destination directory %s: %s\n",
destination.Path(), strerror(status)); destination.Path(), strerror(status));
} }
@@ -9,9 +9,10 @@
#include <crypt.h> #include <crypt.h>
Settings::Settings(const BMessage& archive) Settings::Settings(const char* accountName, const BMessage& archive)
: :
fMessage(archive) fMessage(archive),
fAccountName(accountName)
{ {
} }
@@ -78,7 +79,13 @@ Settings::Password() const
BPath BPath
Settings::Destination() const Settings::Destination() const
{ {
return BPath(fMessage.GetString("destination", "/boot/home/mail/in")); BPath path(fMessage.FindString("destination"));
if (path.Path() == NULL) {
// Use default directory
path = "/boot/home/mail";
path.Append(fAccountName.String());
}
return path;
} }
@@ -13,7 +13,8 @@
class Settings { class Settings {
public: public:
Settings(const BMessage& archive); Settings(const char* accountName,
const BMessage& archive);
~Settings(); ~Settings();
BNetworkAddress ServerAddress() const; BNetworkAddress ServerAddress() const;
@@ -32,6 +33,7 @@ public:
private: private:
const BMessage fMessage; const BMessage fMessage;
BString fAccountName;
}; };