From f038c492f7065b7a99922555c6fc78ea1593e49c Mon Sep 17 00:00:00 2001 From: Jaidyn Ann Date: Wed, 28 Jul 2021 19:10:09 -0500 Subject: [PATCH] Refactor preference saving/loading --- application/Conversation.cpp | 2 +- application/Server.cpp | 7 +- application/Utils.cpp | 44 ++- application/Utils.h | 2 + application/preferences/AppPreferences.cpp | 258 ++++-------------- application/preferences/AppPreferences.h | 60 ++-- .../preferences/PreferencesBehavior.cpp | 36 +-- .../preferences/PreferencesChatWindow.cpp | 4 +- .../preferences/PreferencesContainer.h | 84 ------ .../preferences/PreferencesReplicant.cpp | 10 +- application/views/ReplicantStatusView.cpp | 2 +- application/views/RosterView.cpp | 2 +- application/windows/MainWindow.cpp | 2 +- 13 files changed, 148 insertions(+), 365 deletions(-) delete mode 100644 application/preferences/PreferencesContainer.h diff --git a/application/Conversation.cpp b/application/Conversation.cpp index 6550cb3..ddc2f1b 100644 --- a/application/Conversation.cpp +++ b/application/Conversation.cpp @@ -96,7 +96,7 @@ Conversation::ImMessage(BMessage* msg) || (text.IFindFirst(contact->GetName()) != B_ERROR)); // Send a notification, if appropriate - if (winFocused == false && AppPreferences::Item()->NotifyNewMessage + if (winFocused == false && AppPreferences::Get()->NotifyNewMessage && (fUsers.CountItems() <= 2 || mentioned == true)) { BString notifyTitle = B_TRANSLATE("New mention"); diff --git a/application/Server.cpp b/application/Server.cpp index 3f61d4f..f54e5d2 100644 --- a/application/Server.cpp +++ b/application/Server.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -136,7 +137,7 @@ Server::Filter(BMessage* message, BHandler **target) return result; // "Whoops" notification - if (AppPreferences::Item()->NotifyProtocolStatus == true + if (AppPreferences::Get()->NotifyProtocolStatus == true && message->FindString("name", &name) == B_OK) { BBitmap* icon = new BBitmap(message); BString content(B_TRANSLATE("%user% has been disabled!")); @@ -552,7 +553,7 @@ Server::ImMessage(BMessage* msg) if (msg->FindFloat("progress", &progress) != B_OK) return result; - if (!AppPreferences::Item()->NotifyProtocolStatus) + if (!AppPreferences::Get()->NotifyProtocolStatus) break; BNotification notification(B_PROGRESS_NOTIFICATION); @@ -586,7 +587,7 @@ Server::ImMessage(BMessage* msg) fAccountEnabled.AddItem(looper->Protocol()->GetName(), true); // Ready notification - if (AppPreferences::Item()->NotifyProtocolStatus == true) + if (AppPreferences::Get()->NotifyProtocolStatus == true) _ProtocolNotification(looper, BString(B_TRANSLATE("Connected")), BString(B_TRANSLATE("%user% has connected!"))); diff --git a/application/Utils.cpp b/application/Utils.cpp index 6635255..709493f 100644 --- a/application/Utils.cpp +++ b/application/Utils.cpp @@ -113,16 +113,29 @@ ChatResources() const char* -AccountsPath() +SettingsPath() { BPath path; if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK) return NULL; - path.Append(APP_NAME "/Accounts"); + path.Append(APP_NAME); if (create_directory(path.Path(), 0755) != B_OK) return NULL; + return path.Path(); +} + +const char* +AccountsPath() +{ + BPath path(SettingsPath()); + if (path.InitCheck() != B_OK) + return NULL; + + path.Append("Accounts"); + if (create_directory(path.Path(), 0755) != B_OK) + return NULL; return path.Path(); } @@ -148,10 +161,11 @@ AccountPath(const char* signature, const char* subsignature) const char* CachePath() { - BPath path; - if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK) + BPath path(SettingsPath()); + if (path.InitCheck() != B_OK) return NULL; - path.Append(APP_NAME "/Cache"); + + path.Append("Cache"); if (create_directory(path.Path(), 0755) != B_OK) return NULL; return path.Path(); @@ -165,6 +179,7 @@ AccountCachePath(const char* accountName) path.Append("Accounts"); if (path.InitCheck() != B_OK) return NULL; + path.Append(accountName); if (create_directory(path.Path(), 0755) != B_OK) return NULL; @@ -178,6 +193,7 @@ RoomsCachePath(const char* accountName) BPath path(AccountCachePath(accountName)); if (path.InitCheck() != B_OK) return NULL; + path.Append("Rooms"); if (create_directory(path.Path(), 0755) != B_OK) return NULL; @@ -189,7 +205,9 @@ const char* RoomCachePath(const char* accountName, const char* roomIdentifier) { BPath path(RoomsCachePath(accountName)); - if (path.InitCheck() != B_OK) return NULL; + if (path.InitCheck() != B_OK) + return NULL; + path.Append(roomIdentifier); return path.Path(); } @@ -199,9 +217,12 @@ const char* UserCachePath(const char* accountName, const char* userIdentifier) { BPath path(AccountCachePath(accountName)); - if (path.InitCheck() != B_OK) return NULL; + if (path.InitCheck() != B_OK) + return NULL; + path.Append("Users"); - if (create_directory(path.Path(), 0755) != B_OK) return NULL; + if (create_directory(path.Path(), 0755) != B_OK) + return NULL; path.Append(userIdentifier); return path.Path(); } @@ -211,9 +232,12 @@ const char* ContactCachePath(const char* accountName, const char* userIdentifier) { BPath path(AccountCachePath(accountName)); - if (path.InitCheck() != B_OK) return NULL; + if (path.InitCheck() != B_OK) + return NULL; path.Append("Contacts"); - if (create_directory(path.Path(), 0755) != B_OK) return NULL; + + if (create_directory(path.Path(), 0755) != B_OK) + return NULL; path.Append(userIdentifier); return path.Path(); } diff --git a/application/Utils.h b/application/Utils.h index f5f6087..a6d4556 100644 --- a/application/Utils.h +++ b/application/Utils.h @@ -31,6 +31,8 @@ BString CommandArgs(BString line); BResources* ChatResources(); +const char* SettingsPath(); + const char* AccountsPath(); const char* AccountPath(const char* signature, const char* subsignature); diff --git a/application/preferences/AppPreferences.cpp b/application/preferences/AppPreferences.cpp index 883f6c3..9edeeee 100644 --- a/application/preferences/AppPreferences.cpp +++ b/application/preferences/AppPreferences.cpp @@ -1,230 +1,82 @@ /* * Copyright 2012, Casalinuovo Dario. All rights reserved. - * Distributed under the terms of the MIT License. + * Copyright 2021, Jaidyn Levesque + * All rights reserved. Distributed under the terms of the MIT license. */ + #include "AppPreferences.h" -#include "Cardie.h" -#include -#include +#include "Utils.h" -template<> const char* AppPreferences::fFolder = APP_NAME; -template<> const char* AppPreferences::fFilename = "preferences"; -/* TODO update _Add* methods to - don't take the BPositionIO argument - and to automatically increase - length counters. For example - the _AddBool() method, should - take the BPositionIO argument from - a private class value, and increase - the the size of another class value - respectively. This way the api looks better - and the possibility of bugs related to - size become very minimal : ). -*/ +AppPreferences* AppPreferences::fInstance = NULL; -AppPreferencesData::AppPreferencesData() - : - MoveToCurrentWorkspace(true), - RaiseOnMessageReceived(false), - RaiseUserIsTyping(false), - MarkUnreadWindow(true), - HideDeskbar(false), - DisableReplicant(true), - IgnoreEmoticons(true), - NotifyProtocolStatus(true), - NotifyContactStatus(false), - NotifyNewMessage(true), - HideOffline(true), - DisableQuitConfirm(true) + +AppPreferences* +AppPreferences::Get() { -} - - -AppPreferencesData::~AppPreferencesData() -{ -} - - -bool -AppPreferencesData::IsFixedSize() const -{ - return false; -} - - -type_code -AppPreferencesData::TypeCode() const -{ - return APP_PREFERENCES_TYPE; -} - - -bool -AppPreferencesData::AllowsTypeCode(type_code code) const -{ - if (code == APP_PREFERENCES_TYPE) - return true; - - return false; -} - - -ssize_t -AppPreferencesData::FlattenedSize() const -{ - // NOTE add the size of every settings - // you added. - - ssize_t size = sizeof(bool) * 11; - - return size; -} - - -status_t -AppPreferencesData::Flatten(BPositionIO* flatData) const -{ - if (flatData == NULL) - return B_BAD_VALUE; - - // Write our type code - type_code code = APP_PREFERENCES_TYPE; - flatData->Write(&code, sizeof(type_code)); - - // Behaviour - _AddBool(flatData, MoveToCurrentWorkspace); - _AddBool(flatData, RaiseOnMessageReceived); - _AddBool(flatData, RaiseUserIsTyping); - _AddBool(flatData, MarkUnreadWindow); - - _AddBool(flatData, NotifyProtocolStatus); - _AddBool(flatData, NotifyContactStatus); - _AddBool(flatData, NotifyNewMessage); - _AddBool(flatData, DisableQuitConfirm); - - // Replicant - _AddBool(flatData, HideDeskbar); - _AddBool(flatData, DisableReplicant); - - // Chat window - _AddBool(flatData, IgnoreEmoticons); - - // Contact list - _AddBool(flatData, HideOffline); - - // Usage example for strings : - // _AddString(flatData, yourBString.String()); - - // NOTE : The order is very important, Unflatten and Flatten - // classes should read/write the values in the same order. - - return B_OK; -} - - -status_t -AppPreferencesData::Flatten(void* buffer, ssize_t size) const -{ - if (buffer == NULL) - return B_BAD_VALUE; - - BMemoryIO flatData(buffer, size); - return Flatten(&flatData, size); -} - - - -status_t -AppPreferencesData::Unflatten(type_code code, const void* buffer, ssize_t size) -{ - if (buffer == NULL) - return B_BAD_VALUE; - - BMemoryIO flatData(buffer, size); - return Unflatten(code, &flatData); -} - - -status_t -AppPreferencesData::Unflatten(type_code code, BPositionIO* flatData) -{ - if (code != APP_PREFERENCES_TYPE || flatData == NULL) - return B_BAD_VALUE; - - // Reading our type code - type_code typeCode; - flatData->Read(&typeCode, sizeof(type_code)); - - // checking if the typecode is correct - if (code != typeCode) - return B_BAD_VALUE; - - // Behaviour - MoveToCurrentWorkspace = _ReadBool(flatData); - RaiseOnMessageReceived = _ReadBool(flatData); - RaiseUserIsTyping = _ReadBool(flatData); - MarkUnreadWindow = _ReadBool(flatData); - - NotifyProtocolStatus = _ReadBool(flatData); - NotifyContactStatus = _ReadBool(flatData); - NotifyNewMessage = _ReadBool(flatData); - DisableQuitConfirm = _ReadBool(flatData); - - // Replicant - HideDeskbar = _ReadBool(flatData); - DisableReplicant = _ReadBool(flatData); - - // Chat window - IgnoreEmoticons = _ReadBool(flatData); - - // Contact list - HideOffline = _ReadBool(flatData); - - // Usage example for strings : - // const char* str = _ReadString(flatData); - // yourBString.SetTo(str); - - // NOTE : The order is very important, Unflatten and Flatten - // classes should read/write the values in the same order. - - return B_OK; + if (fInstance == NULL) { + fInstance = new AppPreferences(); + fInstance->Load(); + } + return fInstance; } void -AppPreferencesData::_AddBool(BPositionIO* data, bool value) const +AppPreferences::Load() { - data->Write(&value, sizeof(value)); + const char* path = _PreferencesPath(); + BFile file(_PreferencesPath(), B_READ_ONLY); + BMessage settings; + + if (file.InitCheck() == B_OK) + settings.Unflatten(&file); + + MoveToCurrentWorkspace = settings.GetBool("MoveToCurrentWorkpace", false); + RaiseOnMessageReceived = settings.GetBool("RaiseOnMessageReceived", false); + RaiseUserIsTyping = settings.GetBool("RaiseUserIsTyping", false); + MarkUnreadWindow = settings.GetBool("MarkUnreadWindow", true); + NotifyProtocolStatus = settings.GetBool("NotifyProtocolStatus", true); + NotifyNewMessage = settings.GetBool("NotifyNewMessage", true); + NotifyContactStatus = settings.GetBool("NotifyContactStatus", false); + HideDeskbar = settings.GetBool("HideDeskbar", false); + DisableReplicant = settings.GetBool("DisableReplicant", true); + DisableQuitConfirm = settings.GetBool("DisableQuitConfirm", false); + IgnoreEmoticons = settings.GetBool("IgnoreEmoticons", true); + HideOffline = settings.GetBool("HideOffline", false); } void -AppPreferencesData::_AddString(BPositionIO* data, const char* value) const +AppPreferences::Save() { - size_t len = strlen(value); - data->Write(&len, sizeof(size_t)); - data->Write(value, len); -} + const char* path = _PreferencesPath(); + BFile file(_PreferencesPath(), B_WRITE_ONLY); + BMessage settings; + settings.AddBool("MoveToCurrentWorkpace", MoveToCurrentWorkspace); + settings.AddBool("RaiseOnMessageReceived", RaiseOnMessageReceived); + settings.AddBool("RaiseUserIsTyping", RaiseUserIsTyping); + settings.AddBool("MarkUnreadWindow", MarkUnreadWindow); + settings.AddBool("NotifyProtocolStatus", NotifyProtocolStatus); + settings.AddBool("NotifyNewMessage", NotifyNewMessage); + settings.AddBool("NotifyContactStatus", NotifyContactStatus); + settings.AddBool("HideDeskbar", HideDeskbar); + settings.AddBool("DisableReplicant", DisableReplicant); + settings.AddBool("DisableQuitConfirm", DisableQuitConfirm); + settings.AddBool("IgnoreEmoticons", IgnoreEmoticons); + settings.AddBool("HideOffline", HideOffline); -bool -AppPreferencesData::_ReadBool(BPositionIO* data) -{ - bool ret; - data->Read(&ret, sizeof(bool)); - return ret; + if (file.InitCheck() == B_OK) + settings.Flatten(&file); } const char* -AppPreferencesData::_ReadString(BPositionIO* data) +AppPreferences::_PreferencesPath() { - size_t len; - data->Read(&len, sizeof(size_t)); - char* ret = new char[len]; - data->Read(ret, len); - - return ret; + BPath path(SettingsPath()); + path.Append("preferences"); + return path.Path(); } diff --git a/application/preferences/AppPreferences.h b/application/preferences/AppPreferences.h index 52db474..386842d 100644 --- a/application/preferences/AppPreferences.h +++ b/application/preferences/AppPreferences.h @@ -1,54 +1,42 @@ /* * Copyright 2010, Oliver Ruiz Dorantes. All rights reserved. * Copyright 2012, Casalinuovo Dario. All rights reserved. - * Distributed under the terms of the MIT License. + * Copyright 2021, Jaidyn Levesque + * All rights reserved. Distributed under the terms of the MIT license. */ #ifndef _APP_PREFERENCES_H #define _APP_PREFERENCES_H -#include "PreferencesContainer.h" +#include -class AppPreferencesData : public BFlattenable { +class AppPreferences { public: - AppPreferencesData(); - virtual ~AppPreferencesData(); + static AppPreferences* Get(); - virtual bool IsFixedSize() const; - virtual type_code TypeCode() const; - virtual bool AllowsTypeCode(type_code code) const; - virtual ssize_t FlattenedSize() const; + void Load(); + void Save(); - status_t Flatten(BPositionIO* flatData) const; - virtual status_t Flatten(void* buffer, ssize_t size) const; - virtual status_t Unflatten(type_code code, const void* buffer, - ssize_t size); - status_t Unflatten(type_code code, BPositionIO* flatData); + bool MoveToCurrentWorkspace; + bool RaiseOnMessageReceived; + bool RaiseUserIsTyping; + bool MarkUnreadWindow; + bool NotifyProtocolStatus; + bool NotifyContactStatus; + bool NotifyNewMessage; - bool MoveToCurrentWorkspace; - bool RaiseOnMessageReceived; - bool RaiseUserIsTyping; - bool MarkUnreadWindow; - bool NotifyProtocolStatus; - bool NotifyContactStatus; - bool NotifyNewMessage; + bool HideDeskbar; + bool DisableReplicant; + bool DisableQuitConfirm; - bool HideDeskbar; - bool DisableReplicant; - bool DisableQuitConfirm; - - bool IgnoreEmoticons; + bool IgnoreEmoticons; - bool HideOffline; -private: - void _AddBool(BPositionIO* data, bool value) const; - void _AddString(BPositionIO* data, - const char* value) const; + bool HideOffline; - bool _ReadBool(BPositionIO* data); - const char* _ReadString(BPositionIO* data); +private: + const char* _PreferencesPath(); + + static AppPreferences* fInstance; }; -typedef PreferencesContainer AppPreferences; - -#endif // _APP_PREFERENCES_H +#endif // _APP_PREFERENCES_H diff --git a/application/preferences/PreferencesBehavior.cpp b/application/preferences/PreferencesBehavior.cpp index 63fda6e..b2623d4 100644 --- a/application/preferences/PreferencesBehavior.cpp +++ b/application/preferences/PreferencesBehavior.cpp @@ -138,23 +138,23 @@ PreferencesBehavior::AttachedToWindow() fDisableQuitConfirm->SetTarget(this); fHideOffline->SetValue( - AppPreferences::Item()->HideOffline); + AppPreferences::Get()->HideOffline); fToCurrentWorkspace->SetValue( - AppPreferences::Item()->MoveToCurrentWorkspace); + AppPreferences::Get()->MoveToCurrentWorkspace); fRaiseUserIsTyping->SetValue( - AppPreferences::Item()->RaiseUserIsTyping); + AppPreferences::Get()->RaiseUserIsTyping); fRaiseOnMessageReceived->SetValue( - AppPreferences::Item()->RaiseOnMessageReceived); + AppPreferences::Get()->RaiseOnMessageReceived); fMarkUnreadWindow->SetValue( - AppPreferences::Item()->MarkUnreadWindow); + AppPreferences::Get()->MarkUnreadWindow); fNotifyProtocols->SetValue( - AppPreferences::Item()->NotifyProtocolStatus); + AppPreferences::Get()->NotifyProtocolStatus); fNotifyContactStatus->SetValue( - AppPreferences::Item()->NotifyContactStatus); + AppPreferences::Get()->NotifyContactStatus); fNotifyNewMessage->SetValue( - AppPreferences::Item()->NotifyNewMessage); + AppPreferences::Get()->NotifyNewMessage); fDisableQuitConfirm->SetValue( - AppPreferences::Item()->DisableQuitConfirm); + AppPreferences::Get()->DisableQuitConfirm); } @@ -163,39 +163,39 @@ PreferencesBehavior::MessageReceived(BMessage* message) { switch (message->what) { case kHideOffline: - AppPreferences::Item()->HideOffline + AppPreferences::Get()->HideOffline = fHideOffline->Value(); break; case kToCurrentWorkspace: - AppPreferences::Item()->MoveToCurrentWorkspace + AppPreferences::Get()->MoveToCurrentWorkspace = fToCurrentWorkspace->Value(); break; case kRaiseOnMessageReceived: - AppPreferences::Item()->RaiseOnMessageReceived + AppPreferences::Get()->RaiseOnMessageReceived = fRaiseOnMessageReceived->Value(); break; case kRaiseUserIsTyping: - AppPreferences::Item()->RaiseUserIsTyping + AppPreferences::Get()->RaiseUserIsTyping = fRaiseUserIsTyping->Value(); break; case kNotifyProtocolsLogin: - AppPreferences::Item()->NotifyProtocolStatus + AppPreferences::Get()->NotifyProtocolStatus = fNotifyProtocols->Value(); break; case kNotifyContactStatus: - AppPreferences::Item()->NotifyContactStatus + AppPreferences::Get()->NotifyContactStatus = fNotifyContactStatus->Value(); break; case kNotifyNewMessage: - AppPreferences::Item()->NotifyNewMessage + AppPreferences::Get()->NotifyNewMessage = fNotifyNewMessage->Value(); break; case kMarkUnreadWindow: - AppPreferences::Item()->MarkUnreadWindow + AppPreferences::Get()->MarkUnreadWindow = fMarkUnreadWindow->Value(); break; case kDisablePrompt: - AppPreferences::Item()->DisableQuitConfirm + AppPreferences::Get()->DisableQuitConfirm = fDisableQuitConfirm->Value(); break; default: diff --git a/application/preferences/PreferencesChatWindow.cpp b/application/preferences/PreferencesChatWindow.cpp index 0233736..bdab76b 100644 --- a/application/preferences/PreferencesChatWindow.cpp +++ b/application/preferences/PreferencesChatWindow.cpp @@ -53,7 +53,7 @@ void PreferencesChatWindow::AttachedToWindow() { fIgnoreEmoticons->SetTarget(this); - fIgnoreEmoticons->SetValue(AppPreferences::Item()->IgnoreEmoticons); + fIgnoreEmoticons->SetValue(AppPreferences::Get()->IgnoreEmoticons); } @@ -62,7 +62,7 @@ PreferencesChatWindow::MessageReceived(BMessage* message) { switch (message->what) { case kIgnoreEmoticons: - AppPreferences::Item()->IgnoreEmoticons + AppPreferences::Get()->IgnoreEmoticons = fIgnoreEmoticons->Value(); break; default: diff --git a/application/preferences/PreferencesContainer.h b/application/preferences/PreferencesContainer.h deleted file mode 100644 index 3636b19..0000000 --- a/application/preferences/PreferencesContainer.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2010, Oliver Ruiz Dorantes. All rights reserved. - * Copyright 2012, Casalinuovo Dario. All rights reserved. - * Distributed under the terms of the MIT License. - */ -#ifndef _PREFERENCES_CONTAINER_H -#define _PREFERENCES_CONTAINER_H - -#include - -#include -#include -#include -#include - -enum { - APP_PREFERENCES_TYPE = 'CPTY' -}; - -// TODO: added to main singleton class? -template T* Singleton::fInstance = 0; - - -template -class PreferencesContainer - : public Singleton > { - -public: - - static AppPreferencesData* - Item() - { - return &(Singleton > - ::Get()->fSettings); - } - - - status_t Load() - { - if (fPreferencesFile.SetTo(&fDirectory, fFilename, - B_READ_WRITE | B_FAIL_IF_EXISTS) == B_OK) { - - return fSettings.Unflatten(APP_PREFERENCES_TYPE, - &fPreferencesFile); - } - return B_ERROR; - } - - - status_t Save() - { - if (fPreferencesFile.SetTo(&fDirectory, fFilename, - B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE) == B_OK) { - - return fSettings.Flatten(&fPreferencesFile); - } - return B_ERROR; - } - -private: - PreferencesContainer() - : Singleton >() - { - BPath path; - - find_directory(B_USER_SETTINGS_DIRECTORY, &path); - path.Append(fFolder); - fDirectory.SetTo(path.Path()); - - Load(); - } - - AppPreferencesData fSettings; - BFile fPreferencesFile; - BDirectory fDirectory; - - static const char* fFilename; - static const char* fFolder; - - friend class Singleton >; -}; - - -#endif // _PREFERENCES_CONTAINER_H diff --git a/application/preferences/PreferencesReplicant.cpp b/application/preferences/PreferencesReplicant.cpp index e1f96c3..2ff11f1 100644 --- a/application/preferences/PreferencesReplicant.cpp +++ b/application/preferences/PreferencesReplicant.cpp @@ -36,7 +36,7 @@ PreferencesReplicant::PreferencesReplicant() B_TRANSLATE("Disable deskbar replicant"), new BMessage(kDisableReplicant)); - if (!AppPreferences::Item()->HideDeskbar) + if (!AppPreferences::Get()->HideDeskbar) Looper()->PostMessage(new BMessage(kDisableReplicant)); fPermanentReplicant = new BCheckBox("PermanentReplicant", @@ -72,9 +72,9 @@ PreferencesReplicant::AttachedToWindow() fDisableReplicant->SetTarget(this); fHideDeskbar->SetValue( - AppPreferences::Item()->HideDeskbar); + AppPreferences::Get()->HideDeskbar); fDisableReplicant->SetValue( - AppPreferences::Item()->DisableReplicant); + AppPreferences::Get()->DisableReplicant); } @@ -83,11 +83,11 @@ PreferencesReplicant::MessageReceived(BMessage* message) { switch (message->what) { case kHideDeskbar: - AppPreferences::Item()->HideDeskbar + AppPreferences::Get()->HideDeskbar = fHideDeskbar->Value(); break; case kDisableReplicant: - AppPreferences::Item()->DisableReplicant + AppPreferences::Get()->DisableReplicant = fDisableReplicant->Value(); if (fDisableReplicant->Value() == true) diff --git a/application/views/ReplicantStatusView.cpp b/application/views/ReplicantStatusView.cpp index 64b5a75..c75c88f 100644 --- a/application/views/ReplicantStatusView.cpp +++ b/application/views/ReplicantStatusView.cpp @@ -361,7 +361,7 @@ instantiate_deskbar_item(void) status_t ReplicantStatusView::InstallReplicant() { - if (AppPreferences::Item()->DisableReplicant == true) + if (AppPreferences::Get()->DisableReplicant == true) return B_OK; BDeskbar deskbar; diff --git a/application/views/RosterView.cpp b/application/views/RosterView.cpp index 05b6565..c2350c9 100644 --- a/application/views/RosterView.cpp +++ b/application/views/RosterView.cpp @@ -149,7 +149,7 @@ RosterView::ImMessage(BMessage* msg) UpdateListItem(rosterItem); // Check if the user want the notification - if (!AppPreferences::Item()->NotifyContactStatus) + if (!AppPreferences::Get()->NotifyContactStatus) break; switch (status) { diff --git a/application/windows/MainWindow.cpp b/application/windows/MainWindow.cpp index 6ac3e83..1afa6ca 100644 --- a/application/windows/MainWindow.cpp +++ b/application/windows/MainWindow.cpp @@ -80,7 +80,7 @@ bool MainWindow::QuitRequested() { int32 button_index = 0; - if(!AppPreferences::Item()->DisableQuitConfirm) + if(!AppPreferences::Get()->DisableQuitConfirm) { BAlert* alert = new BAlert(B_TRANSLATE("Closing"), B_TRANSLATE("Are you sure you want to quit?"),