1/*
2	Copyright (c) 2002, Thomas Kurschel
3
4
5	Part of Radeon accelerant
6
7	Settings file
8
9	We shouldn't really need settings as this info
10	should be stored by app_server, but especially
11	BWindowScreen programs cannot now about extra
12	features/settings, so we need to store the flags
13	internally (until I have a better idea ;)
14
15	Especially "SwapWindow" should be mode-independant
16	(you don't swap monitors when you select another
17	workspace, do you?)
18*/
19
20#include "radeon_accelerant.h"
21#include "generic.h"
22#include "GlobalData.h"
23
24#include <FindDirectory.h>
25#include <Path.h>
26#include <File.h>
27
28void Radeon_ReadSettings( virtual_card *vc )
29{
30	BPath path;
31	int32 tmp;
32
33	vc->swap_displays = false;
34	vc->use_laptop_panel = false;
35	vc->tv_standard = ts_ntsc;
36
37	// this is problematic during boot: if there is	multi-user support,
38	// you don't have a user when app_server gets launched;
39	// on the other hand, storing settings globally is not user-friendly...
40	if( find_directory( B_USER_SETTINGS_DIRECTORY, &path ) != B_OK )
41		return;
42
43	path.Append( "radeon" );
44
45	BFile file( path.Path(), B_READ_ONLY );
46
47	if( file.InitCheck() != B_OK )
48		return;
49
50	BMessage settings;
51
52	if( settings.Unflatten( &file ) != B_OK )
53		return;
54
55	settings.FindBool( "SwapDisplays", &vc->swap_displays );
56	settings.FindBool( "UseLaptopPanel", &vc->use_laptop_panel );
57	settings.FindInt32( "TVStandard", &tmp );
58
59	if( tmp >= 0 && tmp <= ts_max )
60		vc->tv_standard = (tv_standard_e)tmp;
61}
62
63void Radeon_WriteSettings( virtual_card *vc )
64{
65	BPath path;
66	int32 tmp;
67
68	// this is problematic during boot: if there is	multi-user support,
69	// you don't have a user when app_server gets launched;
70	// on the other hand, storing settings globally is not user-friendly...
71	if( find_directory( B_USER_SETTINGS_DIRECTORY, &path ) != B_OK )
72		return;
73
74	path.Append( "radeon" );
75
76	BFile file( path.Path(), B_CREATE_FILE | B_WRITE_ONLY );
77
78	if( file.InitCheck() != B_OK )
79		return;
80
81	BMessage settings;
82
83	settings.AddBool( "SwapDisplays", vc->swap_displays );
84	settings.AddBool( "UseLaptopPanel", vc->use_laptop_panel );
85	tmp = vc->tv_standard;
86	settings.AddInt32( "TVStandard", tmp );
87
88	settings.Flatten( &file );
89}
90