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