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> 4*91cbfa85SFredrik Modéen * Copyright 2021, Haiku, Inc. 5*91cbfa85SFredrik Modéen * Distributed under the terms of the MIT License. 6e381b025STri-Edge AI * 7*91cbfa85SFredrik Modéen * Authors: 8*91cbfa85SFredrik Modéen * Fredrik Modéen <fredrik_at_modeen.se> 9e381b025STri-Edge AI */ 10e381b025STri-Edge AI #include "BluetoothSettings.h" 11e381b025STri-Edge AI 12e381b025STri-Edge AI BluetoothSettings::BluetoothSettings() 13e381b025STri-Edge AI { 14e381b025STri-Edge AI find_directory(B_USER_SETTINGS_DIRECTORY, &fPath); 15e381b025STri-Edge AI fPath.Append("Bluetooth_settings", true); 16e381b025STri-Edge AI } 17e381b025STri-Edge AI 18e381b025STri-Edge AI 19e381b025STri-Edge AI BluetoothSettings::~BluetoothSettings() 20e381b025STri-Edge AI { 21e381b025STri-Edge AI } 22e381b025STri-Edge AI 23e381b025STri-Edge AI 24e381b025STri-Edge AI void 25e381b025STri-Edge AI BluetoothSettings::Defaults() 26e381b025STri-Edge AI { 27e381b025STri-Edge AI Data.PickedDevice = bdaddrUtils::NullAddress(); 28be7b42eaSTri-Edge AI Data.LocalDeviceClass = DeviceClass(); 29*91cbfa85SFredrik Modéen Data.Policy = 0; 30*91cbfa85SFredrik Modéen Data.InquiryTime = 15; 31e381b025STri-Edge AI } 32e381b025STri-Edge AI 33e381b025STri-Edge AI 34e381b025STri-Edge AI void 35e381b025STri-Edge AI BluetoothSettings::Load() 36e381b025STri-Edge AI { 37e381b025STri-Edge AI fFile = new BFile(fPath.Path(), B_READ_ONLY); 38e381b025STri-Edge AI 39e381b025STri-Edge AI if (fFile->InitCheck() == B_OK) { 40e381b025STri-Edge AI fFile->Read(&Data, sizeof(Data)); 41e381b025STri-Edge AI } else 42e381b025STri-Edge AI Defaults(); 43e381b025STri-Edge AI 44e381b025STri-Edge AI delete fFile; 45e381b025STri-Edge AI } 46e381b025STri-Edge AI 47e381b025STri-Edge AI 48e381b025STri-Edge AI void 49e381b025STri-Edge AI BluetoothSettings::Save() 50e381b025STri-Edge AI { 51e381b025STri-Edge AI fFile = new BFile(fPath.Path(), B_WRITE_ONLY | B_CREATE_FILE); 52e381b025STri-Edge AI 53e381b025STri-Edge AI if (fFile->InitCheck() == B_OK) { 54e381b025STri-Edge AI fFile->Write(&Data, sizeof(Data)); 55e381b025STri-Edge AI } 56e381b025STri-Edge AI 57e381b025STri-Edge AI delete fFile; 58e381b025STri-Edge AI } 59