From af48b464ef40e855a27adbba1c9a2ac51d6062b8 Mon Sep 17 00:00:00 2001 From: plfiorini Date: Fri, 28 May 2010 17:11:16 +0000 Subject: [PATCH] Hide implementation details. --- application/CayaProtocolAddOn.h | 1 + application/ProtocolManager.cpp | 40 +++++++++++++------ application/ProtocolManager.h | 17 ++++---- .../preferences/PreferencesAccounts.cpp | 6 +-- 4 files changed, 40 insertions(+), 24 deletions(-) diff --git a/application/CayaProtocolAddOn.h b/application/CayaProtocolAddOn.h index 9d4c4d7..857cbea 100644 --- a/application/CayaProtocolAddOn.h +++ b/application/CayaProtocolAddOn.h @@ -22,6 +22,7 @@ public: const char* Path() const; CayaProtocol* Protocol() const; + const char* Signature() const; const char* FriendlySignature() const; BBitmap* Icon() const; diff --git a/application/ProtocolManager.cpp b/application/ProtocolManager.cpp index 8b3db0c..c0579a9 100644 --- a/application/ProtocolManager.cpp +++ b/application/ProtocolManager.cpp @@ -62,24 +62,17 @@ ProtocolManager::Get() } -ProtocolAddOns -ProtocolManager::Protocols() +uint32 +ProtocolManager::CountProtocolAddOns() const { - return fAddOnMap.Values(); + return fAddOnMap.CountItems(); } -ProtocolMap -ProtocolManager::ProtocolInstances() const +CayaProtocolAddOn* +ProtocolManager::ProtocolAddOnAt(uint32 i) const { - return fProtocolMap; -} - - -CayaProtocol* -ProtocolManager::ProtocolInstance(bigtime_t identifier) -{ - return fProtocolMap.ValueFor(identifier); + return fAddOnMap.ValueAt(i); } @@ -90,6 +83,27 @@ ProtocolManager::ProtocolAddOn(const char* signature) } +uint32 +ProtocolManager::CountProtocolInstances() const +{ + return fProtocolMap.CountItems(); +} + + +CayaProtocol* +ProtocolManager::ProtocolInstanceAt(uint32 i) const +{ + return fProtocolMap.ValueAt(i); +} + + +CayaProtocol* +ProtocolManager::ProtocolInstance(bigtime_t identifier) +{ + return fProtocolMap.ValueFor(identifier); +} + + void ProtocolManager::AddAccount(CayaProtocolAddOn* addOn, const char* account, BHandler* target) diff --git a/application/ProtocolManager.h b/application/ProtocolManager.h index 6d420a5..4a6081b 100644 --- a/application/ProtocolManager.h +++ b/application/ProtocolManager.h @@ -18,27 +18,28 @@ class BBitmap; class BDirectory; class BHandler; -typedef List ProtocolAddOns; -typedef KeyMap AddOnMap; -typedef KeyMap ProtocolMap; - class ProtocolManager { public: void Init(BDirectory dir, BHandler* target); static ProtocolManager* Get(); - ProtocolAddOns Protocols(); - ProtocolMap ProtocolInstances() const; - - CayaProtocol* ProtocolInstance(bigtime_t identifier); + uint32 CountProtocolAddOns() const; + CayaProtocolAddOn* ProtocolAddOnAt(uint32 i) const; CayaProtocolAddOn* ProtocolAddOn(const char* signature); + uint32 CountProtocolInstances() const; + CayaProtocol* ProtocolInstanceAt(uint32 i) const; + CayaProtocol* ProtocolInstance(bigtime_t identifier); + void AddAccount(CayaProtocolAddOn* addOn, const char* account, BHandler* target); private: + typedef KeyMap AddOnMap; + typedef KeyMap ProtocolMap; + ProtocolManager(); void _GetAccounts(CayaProtocolAddOn* addOn, BHandler* target); diff --git a/application/preferences/PreferencesAccounts.cpp b/application/preferences/PreferencesAccounts.cpp index a16e43c..cb4232c 100644 --- a/application/preferences/PreferencesAccounts.cpp +++ b/application/preferences/PreferencesAccounts.cpp @@ -52,11 +52,11 @@ PreferencesAccounts::PreferencesAccounts() BScrollView* scrollView = new BScrollView("scrollView", fListView, B_WILL_DRAW, false, true); - ProtocolAddOns addOns = ProtocolManager::Get()->Protocols(); + ProtocolManager* pm = ProtocolManager::Get(); fProtosMenu = new BPopUpMenu(NULL, true); - for (uint32 i = 0; i < addOns.CountItems(); i++) { - CayaProtocolAddOn* addOn = addOns.ItemAt(i); + for (uint32 i = 0; i < pm->CountProtocolAddOns(); i++) { + CayaProtocolAddOn* addOn = pm->ProtocolAddOnAt(i); ProtocolSettings* settings = new ProtocolSettings(addOn); // Add accounts to list view