Load/Save account settings from correct paths
This commit is contained in:
parent
61a1f0baf1
commit
6ca134f9f6
|
@ -19,7 +19,7 @@
|
|||
|
||||
|
||||
Account::Account(bigtime_t instanceId, CayaProtocol* cayap,
|
||||
const char* name, BHandler* target)
|
||||
const char* name, const char* addOnSignature, BHandler* target)
|
||||
:
|
||||
fIdentifier(instanceId),
|
||||
fName(name),
|
||||
|
@ -30,7 +30,7 @@ Account::Account(bigtime_t instanceId, CayaProtocol* cayap,
|
|||
fProtocol->Init(this);
|
||||
|
||||
// Find user's settings path
|
||||
BPath path(CayaAccountPath(fProtocol->Signature()));
|
||||
BPath path(CayaAccountPath(addOnSignature, fProtocol->Signature()));
|
||||
if (path.InitCheck() == B_OK) {
|
||||
path.Append(name);
|
||||
|
||||
|
@ -68,3 +68,5 @@ Account::SendMessage(BMessage* message)
|
|||
message->AddInt64("instance", fIdentifier);
|
||||
return fMessenger.SendMessage(message);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
class Account : public CayaProtocolMessengerInterface {
|
||||
public:
|
||||
Account(bigtime_t instanceId, CayaProtocol* cayap,
|
||||
const char* name, BHandler* target);
|
||||
const char* name, const char* addOnSignature,
|
||||
BHandler* target);
|
||||
virtual ~Account();
|
||||
|
||||
bigtime_t Identifier() const;
|
||||
|
|
|
@ -78,6 +78,16 @@ CayaProtocolAddOn::FriendlySignature() const
|
|||
}
|
||||
|
||||
|
||||
const char*
|
||||
CayaProtocolAddOn::SubSignature() const
|
||||
{
|
||||
CayaProtocol* proto = Protocol();
|
||||
const char* signature = proto->Signature();
|
||||
delete proto;
|
||||
return signature;
|
||||
}
|
||||
|
||||
|
||||
uint32
|
||||
CayaProtocolAddOn::Version() const
|
||||
{
|
||||
|
|
|
@ -29,6 +29,7 @@ public:
|
|||
|
||||
const char* Signature() const;
|
||||
const char* FriendlySignature() const;
|
||||
const char* SubSignature() const;
|
||||
uint32 Version() const;
|
||||
|
||||
BBitmap* Icon() const;
|
||||
|
|
|
@ -124,7 +124,7 @@ ProtocolManager::AddAccount(CayaProtocolAddOn* addOn, const char* account,
|
|||
{
|
||||
bigtime_t instanceId = system_time();
|
||||
CayaProtocol* cayap = addOn->Protocol();
|
||||
(void)new Account(instanceId, cayap, account, target);
|
||||
(void)new Account(instanceId, cayap, account, addOn->Signature(), target);
|
||||
fProtocolMap.AddItem(instanceId, cayap);
|
||||
|
||||
TheApp* theApp = reinterpret_cast<TheApp*>(be_app);
|
||||
|
@ -151,7 +151,7 @@ ProtocolManager::_GetAccounts(CayaProtocolAddOn* addOn, const char* subProtocol,
|
|||
if (msg.Unflatten(&file) == B_OK) {
|
||||
char buffer[B_PATH_NAME_LENGTH];
|
||||
if (entry.GetName(buffer) == B_OK) {
|
||||
printf("Found %s for protocol %s!\n", buffer, addOn->Signature());
|
||||
printf("Found %s for protocol %s!\n", buffer, subProtocol);
|
||||
AddAccount(addOn, buffer, target);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,12 +75,9 @@ ProtocolSettings::Accounts() const
|
|||
{
|
||||
BObjectList<BString> list(true);
|
||||
|
||||
CayaProtocol* proto = fAddOn->Protocol();
|
||||
|
||||
BPath path(CayaAccountPath(fAddOn->Signature(), proto->Signature()));
|
||||
BPath path(CayaAccountPath(fAddOn->Signature(), fAddOn->SubSignature()));
|
||||
if (path.InitCheck() != B_OK)
|
||||
return list;
|
||||
delete proto;
|
||||
|
||||
BDirectory dir(path.Path());
|
||||
BEntry entry;
|
||||
|
@ -364,7 +361,7 @@ ProtocolSettings::Rename(const char* from, const char* to)
|
|||
status_t ret = B_ERROR;
|
||||
|
||||
// Find user's settings path
|
||||
BPath path(CayaAccountPath(fAddOn->Signature()));
|
||||
BPath path(CayaAccountPath(fAddOn->Signature(), fAddOn->SubSignature()));
|
||||
if ((ret = path.InitCheck()) != B_OK)
|
||||
return ret;
|
||||
|
||||
|
@ -385,7 +382,7 @@ ProtocolSettings::Delete(const char* account)
|
|||
status_t ret = B_ERROR;
|
||||
|
||||
// Find user's settings path
|
||||
BPath path(CayaAccountPath(fAddOn->Signature()));
|
||||
BPath path(CayaAccountPath(fAddOn->Signature(), fAddOn->SubSignature()));
|
||||
if ((ret = path.InitCheck()) != B_OK)
|
||||
return ret;
|
||||
|
||||
|
@ -420,7 +417,7 @@ ProtocolSettings::_Load(const char* account, BMessage** settings)
|
|||
status_t ret = B_ERROR;
|
||||
|
||||
// Find user's settings path
|
||||
BPath path(CayaAccountPath(fAddOn->Signature()));
|
||||
BPath path(CayaAccountPath(fAddOn->Signature(), fAddOn->SubSignature()));
|
||||
if ((ret = path.InitCheck()) != B_OK)
|
||||
return ret;
|
||||
|
||||
|
@ -443,7 +440,7 @@ ProtocolSettings::_Save(const char* account, BMessage* settings)
|
|||
status_t ret = B_ERROR;
|
||||
|
||||
// Find user's settings path
|
||||
BPath path(CayaAccountPath(fAddOn->Signature()));
|
||||
BPath path(CayaAccountPath(fAddOn->Signature(), fAddOn->SubSignature()));
|
||||
if ((ret = path.InitCheck()) != B_OK)
|
||||
return ret;
|
||||
|
||||
|
|
Ŝarĝante…
Reference in New Issue