From 6ca134f9f63276d2daff2083283775783121c416 Mon Sep 17 00:00:00 2001 From: Jaidyn Ann Date: Fri, 21 May 2021 15:52:33 -0500 Subject: [PATCH] Load/Save account settings from correct paths --- application/Account.cpp | 6 ++++-- application/Account.h | 3 ++- application/CayaProtocolAddOn.cpp | 10 ++++++++++ application/CayaProtocolAddOn.h | 1 + application/ProtocolManager.cpp | 4 ++-- application/ProtocolSettings.cpp | 13 +++++-------- 6 files changed, 24 insertions(+), 13 deletions(-) diff --git a/application/Account.cpp b/application/Account.cpp index 3af1de9..2caf297 100644 --- a/application/Account.cpp +++ b/application/Account.cpp @@ -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); } + + diff --git a/application/Account.h b/application/Account.h index 9a81f7b..ac01e93 100644 --- a/application/Account.h +++ b/application/Account.h @@ -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; diff --git a/application/CayaProtocolAddOn.cpp b/application/CayaProtocolAddOn.cpp index 17ead69..00107aa 100644 --- a/application/CayaProtocolAddOn.cpp +++ b/application/CayaProtocolAddOn.cpp @@ -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 { diff --git a/application/CayaProtocolAddOn.h b/application/CayaProtocolAddOn.h index 33cb452..ff91bc0 100644 --- a/application/CayaProtocolAddOn.h +++ b/application/CayaProtocolAddOn.h @@ -29,6 +29,7 @@ public: const char* Signature() const; const char* FriendlySignature() const; + const char* SubSignature() const; uint32 Version() const; BBitmap* Icon() const; diff --git a/application/ProtocolManager.cpp b/application/ProtocolManager.cpp index 6cb03c0..d6b793c 100644 --- a/application/ProtocolManager.cpp +++ b/application/ProtocolManager.cpp @@ -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(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); } } diff --git a/application/ProtocolSettings.cpp b/application/ProtocolSettings.cpp index d9cd9e4..14f097d 100644 --- a/application/ProtocolSettings.cpp +++ b/application/ProtocolSettings.cpp @@ -75,12 +75,9 @@ ProtocolSettings::Accounts() const { BObjectList 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;