BMailAccountSettings: use BPathFinder.
* This allows to put add-ons in non-packaged folders, too.
* Also, Set{In|Out}boundAddOn() only ever looked in the system dir.
This commit is contained in:
@@ -171,6 +171,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
status_t _CreateAccountFilePath();
|
status_t _CreateAccountFilePath();
|
||||||
|
status_t _GetAddOnRef(const char* subPath,
|
||||||
|
const char* name, entry_ref& ref);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
status_t fStatus;
|
status_t fStatus;
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
#include <Messenger.h>
|
#include <Messenger.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
|
#include <PathFinder.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
@@ -431,23 +432,24 @@ BMailAddOnSettings::Load(const BMessage& message)
|
|||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
BPath path(pathString);
|
BPath path(pathString);
|
||||||
|
|
||||||
if (!path.IsAbsolute()) {
|
if (!path.IsAbsolute()) {
|
||||||
directory_which which[] = {
|
BStringList paths;
|
||||||
B_USER_ADDONS_DIRECTORY,
|
BPathFinder().FindPaths(B_FIND_PATH_ADD_ONS_DIRECTORY, "mail_daemon",
|
||||||
B_SYSTEM_ADDONS_DIRECTORY
|
paths);
|
||||||
};
|
|
||||||
|
|
||||||
for (size_t i = 0; i < sizeof(which) / sizeof(which[0]); i++) {
|
status_t status = B_ENTRY_NOT_FOUND;
|
||||||
status_t status = find_directory(which[i], &path);
|
|
||||||
if (status != B_OK)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
path.Append("mail_daemon");
|
for (int32 i = 0; i < paths.CountStrings(); i++) {
|
||||||
path.Append(pathString);
|
path.SetTo(paths.StringAt(i), pathString);
|
||||||
|
BEntry entry(path.Path());
|
||||||
if (BEntry(path.Path()).Exists())
|
if (entry.Exists()) {
|
||||||
|
status = B_OK;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (status != B_OK)
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t status = get_ref_for_path(path.Path(), &fRef);
|
status_t status = get_ref_for_path(path.Path(), &fRef);
|
||||||
@@ -737,17 +739,11 @@ BMailAccountSettings::ReturnAddress() const
|
|||||||
bool
|
bool
|
||||||
BMailAccountSettings::SetInboundAddOn(const char* name)
|
BMailAccountSettings::SetInboundAddOn(const char* name)
|
||||||
{
|
{
|
||||||
BPath path;
|
|
||||||
status_t status = find_directory(B_BEOS_ADDONS_DIRECTORY, &path);
|
|
||||||
if (status != B_OK)
|
|
||||||
return false;
|
|
||||||
path.Append("mail_daemon");
|
|
||||||
path.Append("inbound_protocols");
|
|
||||||
path.Append(name);
|
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
get_ref_for_path(path.Path(), &ref);
|
if (_GetAddOnRef("mail_daemon/inbound_protocols", name, ref) != B_OK)
|
||||||
fInboundSettings.SetAddOnRef(ref);
|
return false;
|
||||||
|
|
||||||
|
fInboundSettings.SetAddOnRef(ref);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -755,17 +751,11 @@ BMailAccountSettings::SetInboundAddOn(const char* name)
|
|||||||
bool
|
bool
|
||||||
BMailAccountSettings::SetOutboundAddOn(const char* name)
|
BMailAccountSettings::SetOutboundAddOn(const char* name)
|
||||||
{
|
{
|
||||||
BPath path;
|
|
||||||
status_t status = find_directory(B_BEOS_ADDONS_DIRECTORY, &path);
|
|
||||||
if (status != B_OK)
|
|
||||||
return false;
|
|
||||||
path.Append("mail_daemon");
|
|
||||||
path.Append("outbound_protocols");
|
|
||||||
path.Append(name);
|
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
get_ref_for_path(path.Path(), &ref);
|
if (_GetAddOnRef("mail_daemon/outbound_protocols", name, ref) != B_OK)
|
||||||
fOutboundSettings.SetAddOnRef(ref);
|
return false;
|
||||||
|
|
||||||
|
fOutboundSettings.SetAddOnRef(ref);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -980,3 +970,22 @@ BMailAccountSettings::_CreateAccountFilePath()
|
|||||||
path.Append(fileName);
|
path.Append(fileName);
|
||||||
return fAccountFile.SetTo(path.Path());
|
return fAccountFile.SetTo(path.Path());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BMailAccountSettings::_GetAddOnRef(const char* subPath, const char* name,
|
||||||
|
entry_ref& ref)
|
||||||
|
{
|
||||||
|
BStringList paths;
|
||||||
|
BPathFinder().FindPaths(B_FIND_PATH_ADD_ONS_DIRECTORY, subPath, paths);
|
||||||
|
|
||||||
|
for (int32 i = 0; i < paths.CountStrings(); i++) {
|
||||||
|
BPath path(paths.StringAt(i), name);
|
||||||
|
BEntry entry(path.Path());
|
||||||
|
if (entry.Exists()) {
|
||||||
|
if (entry.GetRef(&ref) == B_OK)
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user