1
/*********************************************************
2
* Copyright (C) 2002 VMware, Inc. All rights reserved.
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU Lesser General Public License as published
6
* by the Free Software Foundation version 2.1 and no later version.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10
* or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
11
* License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program; if not, write to the Free Software Foundation, Inc.,
15
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17
*********************************************************/
22
* Manage the tools configuration file.
33
#include "vm_assert.h"
38
#include "eventManager.h"
43
*----------------------------------------------------------------------
47
* Set the conf dict's default values then attempt to load the
48
* conf file into memory.
58
*----------------------------------------------------------------------
64
GuestApp_Dict *confDict;
66
char *confPath = GuestApp_GetConfPath();
67
char *installPath = GuestApp_GetInstallPath();
69
/* We really can't proceed without these paths. */
72
if (confPath == NULL) {
73
Panic("Could not get path to Tools configuration file.\n");
76
if (installPath == NULL) {
77
Panic("Could not get path to Tools installation.\n");
80
path = Str_Asprintf(NULL, "%s%c%s", confPath, DIRSEPC, CONF_FILE);
81
ASSERT_NOT_IMPLEMENTED(path);
82
confDict = GuestApp_ConstructDict(path);
83
// don't free path; it's used by the dict
85
/* Set default conf values */
86
path = Str_Asprintf(NULL, "%s%c%s", installPath, DIRSEPC,
87
CONFVAL_POWERONSCRIPT_DEFAULT);
88
ASSERT_NOT_IMPLEMENTED(path);
89
GuestApp_SetDictEntryDefault(confDict, CONFNAME_POWERONSCRIPT, path);
92
path = Str_Asprintf(NULL, "%s%c%s", installPath, DIRSEPC,
93
CONFVAL_POWEROFFSCRIPT_DEFAULT);
94
ASSERT_NOT_IMPLEMENTED(path);
95
GuestApp_SetDictEntryDefault(confDict, CONFNAME_POWEROFFSCRIPT, path);
98
path = Str_Asprintf(NULL, "%s%c%s", installPath, DIRSEPC,
99
CONFVAL_RESUMESCRIPT_DEFAULT);
100
ASSERT_NOT_IMPLEMENTED(path);
101
GuestApp_SetDictEntryDefault(confDict, CONFNAME_RESUMESCRIPT, path);
104
path = Str_Asprintf(NULL, "%s%c%s", installPath, DIRSEPC,
105
CONFVAL_SUSPENDSCRIPT_DEFAULT);
106
ASSERT_NOT_IMPLEMENTED(path);
107
GuestApp_SetDictEntryDefault(confDict, CONFNAME_SUSPENDSCRIPT, path);
110
GuestApp_SetDictEntryDefault(confDict, CONFNAME_MAX_WIPERSIZE,
111
CONFVAL_MAX_WIPERSIZE_DEFAULT);
113
/* Load the user-configured values from the conf file if it's there */
114
GuestApp_LoadDict(confDict);
124
*----------------------------------------------------------------------
128
* Reload the conf dict if the conf file has changed.
129
* Callers are expected to add this function to the event loop to
130
* periodically read in configuration values.
134
* TRUE is file was reloaded, FALSE otherwise.
140
*----------------------------------------------------------------------
144
Conf_ReloadFile(GuestApp_Dict **pConfDict) // IN/OUT
149
if (GuestApp_WasDictFileChanged(*pConfDict)) {
150
Debug("Conf file out of date; reloading...\n");
152
GuestApp_FreeDict(*pConfDict);
153
*pConfDict = Conf_Load();