00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00031
00032
00033
00034
00035 #include <stdlib.h>
00036 #include <glib.h>
00037
00038 #include <libermanifest/ermanifest.h>
00039
00040 #include "logging.h"
00041 #include "constants.h"
00042 #include "settings.h"
00043
00044
00045 static pcShareCfg_t* makeDefaultCfg()
00046 {
00047 pcShareCfg_t* thePCShareSettings = NULL;
00048
00049 thePCShareSettings = g_new0(pcShareCfg_t, 1);
00050
00051 if (NULL == thePCShareSettings)
00052 {
00053 DL_ERRORPRINTF("Memory allocation failed.");
00054 g_assert_not_reached();
00055 }
00056
00057 thePCShareSettings->overwrite = FALSE;
00058 return thePCShareSettings;
00059 }
00060
00061 pcShareCfg_t* get_pc_share_settings()
00062 {
00063 DL_LOGPRINTF("entry");
00064
00065
00066 char szCfgFilePath[MAX_PATH];
00067 snprintf(szCfgFilePath, sizeof(szCfgFilePath), "%s/%s", SHARE_MOUNT_POINT, CONFIG_FILE);
00068
00069 erManifest manifest;
00070 if (RET_OK != ermXmlOpenFile(szCfgFilePath, &manifest))
00071 {
00072 DL_ERRORPRINTF("Could not open manifest file [%s]", szCfgFilePath);
00073 return makeDefaultCfg();
00074 }
00075
00076 pcShareCfg_t* thePCShareSettings = NULL;
00077 thePCShareSettings = g_new0(pcShareCfg_t, 1);
00078
00079 if (NULL == thePCShareSettings)
00080 {
00081 DL_ERRORPRINTF("Memory allocation failed.");
00082 g_assert_not_reached();
00083 }
00084
00085 int ret = ermXmlGetBoolean(&manifest, OVERWRITE_SETTING_XPATH, &thePCShareSettings->overwrite);
00086 if (ret == RET_ERR)
00087 {
00088 thePCShareSettings->overwrite = FALSE;
00089 }
00090
00091 ermXmlClose(&manifest);
00092 return thePCShareSettings;
00093 }
00094
00095 void free_pc_share_settings(pcShareCfg_t* thePCShareSettings)
00096 {
00097 DL_LOGPRINTF("entry");
00098 g_free(thePCShareSettings);
00099 }
00100