1e381b025STri-Edge AI /* 2e381b025STri-Edge AI * Copyright 2008-2009, Oliver Ruiz Dorantes, <oliver.ruiz.dorantes@gmail.com> 3e381b025STri-Edge AI * Copyright 2012-2013, Tri-Edge AI <triedgeai@gmail.com> 4e381b025STri-Edge AI * 5e381b025STri-Edge AI * All rights reserved. Distributed under the terms of the MIT license. 6e381b025STri-Edge AI */ 7e381b025STri-Edge AI 8e381b025STri-Edge AI #include "BluetoothSettings.h" 9e381b025STri-Edge AI 10e381b025STri-Edge AI BluetoothSettings::BluetoothSettings() 11e381b025STri-Edge AI { 12e381b025STri-Edge AI find_directory(B_USER_SETTINGS_DIRECTORY, &fPath); 13e381b025STri-Edge AI fPath.Append("Bluetooth_settings", true); 14e381b025STri-Edge AI } 15e381b025STri-Edge AI 16e381b025STri-Edge AI 17e381b025STri-Edge AI BluetoothSettings::~BluetoothSettings() 18e381b025STri-Edge AI { 19e381b025STri-Edge AI 20e381b025STri-Edge AI } 21e381b025STri-Edge AI 22e381b025STri-Edge AI 23e381b025STri-Edge AI void 24e381b025STri-Edge AI BluetoothSettings::Defaults() 25e381b025STri-Edge AI { 26e381b025STri-Edge AI Data.PickedDevice = bdaddrUtils::NullAddress(); 27*be7b42eaSTri-Edge AI Data.LocalDeviceClass = DeviceClass(); 28e381b025STri-Edge AI } 29e381b025STri-Edge AI 30e381b025STri-Edge AI 31e381b025STri-Edge AI void 32e381b025STri-Edge AI BluetoothSettings::Load() 33e381b025STri-Edge AI { 34e381b025STri-Edge AI fFile = new BFile(fPath.Path(), B_READ_ONLY); 35e381b025STri-Edge AI 36e381b025STri-Edge AI if (fFile->InitCheck() == B_OK) { 37e381b025STri-Edge AI fFile->Read(&Data, sizeof(Data)); 38e381b025STri-Edge AI // TODO: Add more settings here. 39e381b025STri-Edge AI } else 40e381b025STri-Edge AI Defaults(); 41e381b025STri-Edge AI 42e381b025STri-Edge AI delete fFile; 43e381b025STri-Edge AI } 44e381b025STri-Edge AI 45e381b025STri-Edge AI 46e381b025STri-Edge AI void 47e381b025STri-Edge AI BluetoothSettings::Save() 48e381b025STri-Edge AI { 49e381b025STri-Edge AI fFile = new BFile(fPath.Path(), B_WRITE_ONLY | B_CREATE_FILE); 50e381b025STri-Edge AI 51e381b025STri-Edge AI if (fFile->InitCheck() == B_OK) { 52e381b025STri-Edge AI fFile->Write(&Data, sizeof(Data)); 53e381b025STri-Edge AI // TODO: Add more settings here. 54e381b025STri-Edge AI } 55e381b025STri-Edge AI 56e381b025STri-Edge AI delete fFile; 57e381b025STri-Edge AI } 58