Store preferences in a File

This commit is contained in:
urnenfeld 2010-05-22 14:18:11 +00:00
parent 8e956baea7
commit f45da3af40
3 changed files with 18 additions and 11 deletions

View File

@ -40,6 +40,7 @@ Application Caya :
AccountDialog.cpp AccountDialog.cpp
AccountListItem.cpp AccountListItem.cpp
AccountView.cpp AccountView.cpp
CayaPreferences.cpp
PreferencesDialog.cpp PreferencesDialog.cpp
PreferencesAccounts.cpp PreferencesAccounts.cpp
PreferencesBehavior.cpp PreferencesBehavior.cpp

View File

@ -34,6 +34,7 @@
#include "CayaConstants.h" #include "CayaConstants.h"
#include "CayaMessages.h" #include "CayaMessages.h"
#include "CayaProtocolMessages.h" #include "CayaProtocolMessages.h"
#include "CayaPreferences.h"
#include "CayaResources.h" #include "CayaResources.h"
#include "CayaUtils.h" #include "CayaUtils.h"
#include "NotifyMessage.h" #include "NotifyMessage.h"
@ -53,7 +54,7 @@ const uint32 kPreferences = 'WPRF';
MainWindow::MainWindow() MainWindow::MainWindow()
: :
BWindow(BRect(0, 0, 300, 400), "Caya", B_DOCUMENT_WINDOW, 0) BWindow(BRect(0, 0, 300, 400), "Caya", B_DOCUMENT_WINDOW, 0)
{ {
fStatusView = new StatusView("statusView"); fStatusView = new StatusView("statusView");
BTextControl* searchBox = new BTextControl("searchBox", NULL, NULL, BTextControl* searchBox = new BTextControl("searchBox", NULL, NULL,
@ -119,6 +120,7 @@ MainWindow::QuitRequested()
{ {
fListView->MakeEmpty(); fListView->MakeEmpty();
fServer->Quit(); fServer->Quit();
CayaPreferences::Get()->Save();
be_app->PostMessage(B_QUIT_REQUESTED); be_app->PostMessage(B_QUIT_REQUESTED);
return true; return true;
} }
@ -178,7 +180,7 @@ MainWindow::MessageReceived(BMessage* message)
break; break;
default: default:
BWindow::MessageReceived(message); BWindow::MessageReceived(message);
} }
} }
@ -193,11 +195,11 @@ MainWindow::ImError(BMessage* msg)
void void
MainWindow::ImMessage(BMessage* msg) MainWindow::ImMessage(BMessage* msg)
{ {
int32 im_what = msg->FindInt32("im_what"); int32 im_what = msg->FindInt32("im_what");
switch (im_what) { switch (im_what) {
case IM_OWN_CONTACT_INFO: case IM_OWN_CONTACT_INFO:
{ {
fStatusView->SetName(msg->FindString("name")); fStatusView->SetName(msg->FindString("name"));
entry_ref ref; entry_ref ref;
@ -260,7 +262,7 @@ MainWindow::ObserveInteger(int32 what, int32 val)
} }
void void
MainWindow::UpdateListItem(RosterItem* item) MainWindow::UpdateListItem(RosterItem* item)
{ {
if (fListView->HasItem(item)) if (fListView->HasItem(item))
@ -275,14 +277,14 @@ MainWindow::CountItems() const
} }
RosterItem* RosterItem*
MainWindow::ItemAt(int index) MainWindow::ItemAt(int index)
{ {
return dynamic_cast<RosterItem*>(fListView->ItemAt(index)); return dynamic_cast<RosterItem*>(fListView->ItemAt(index));
} }
void void
MainWindow::AddItem(RosterItem* item) MainWindow::AddItem(RosterItem* item)
{ {
// Don't add offline items and avoid duplicates // Don't add offline items and avoid duplicates
@ -295,15 +297,15 @@ MainWindow::AddItem(RosterItem* item)
} }
bool bool
MainWindow::HasItem(RosterItem* item) MainWindow::HasItem(RosterItem* item)
{ {
return fListView->HasItem(item); return fListView->HasItem(item);
} }
void void
MainWindow::RemoveItem(RosterItem* item) MainWindow::RemoveItem(RosterItem* item)
{ {
// Remove item and sort // Remove item and sort
fListView->RemoveItem(item); fListView->RemoveItem(item);

View File

@ -0,0 +1,4 @@
#include "CayaPreferences.h"
template<> const char* CayaPreferences::fFolder = "Caya";
template<> const char* CayaPreferences::fFilename = "preferences";