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