* loadSettings() * * Load the parameters of plugin */
| 215 | * Load the parameters of plugin |
| 216 | */ |
| 217 | void loadSettings(void) |
| 218 | { |
| 219 | /* initialize the config directory */ |
| 220 | ::SendMessage(nppData._nppHandle, NPPM_GETPLUGINSCONFIGDIR, MAX_PATH, (LPARAM)configPath); |
| 221 | |
| 222 | /* Test if config path exist */ |
| 223 | if (PathFileExists(configPath) == FALSE) { |
| 224 | ::CreateDirectory(configPath, NULL); |
| 225 | } |
| 226 | |
| 227 | _tcscpy_s(iniFilePath, MAX_PATH, configPath); |
| 228 | _tcscat_s(iniFilePath, MAX_PATH, PLUGINMANAGER_INI); |
| 229 | if (PathFileExists(iniFilePath) == FALSE) |
| 230 | { |
| 231 | ::CloseHandle(::CreateFile(iniFilePath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)); |
| 232 | } |
| 233 | |
| 234 | g_options.notifyUpdates = ::GetPrivateProfileInt(SETTINGS_GROUP, KEY_NOTIFYUPDATES, 1, iniFilePath); |
| 235 | |
| 236 | g_options.showUnstable = ::GetPrivateProfileInt(SETTINGS_GROUP, KEY_SHOWUNSTABLE, 0, iniFilePath); |
| 237 | |
| 238 | g_options.forceHttp = ::GetPrivateProfileInt(SETTINGS_GROUP, KEY_FORCEHTTP, 0, iniFilePath); |
| 239 | g_options.useDevPluginList = ::GetPrivateProfileInt(SETTINGS_GROUP, KEY_USEDEVPLUGINLIST, 0, iniFilePath); |
| 240 | |
| 241 | |
| 242 | g_options.daysToCheck = ::GetPrivateProfileInt(SETTINGS_GROUP, KEY_DAYSTOCHECK, DAYSCHECK_DEFAULT, iniFilePath); |
| 243 | if (g_options.daysToCheck < DAYSCHECK_MIN) |
| 244 | { |
| 245 | g_options.daysToCheck = DAYSCHECK_MIN; |
| 246 | } |
| 247 | |
| 248 | g_options.installLocation = static_cast<INSTALLLOCATION>(::GetPrivateProfileInt(SETTINGS_GROUP, KEY_INSTALLLOCATION, 2, iniFilePath)); |
| 249 | g_options.appDataPluginsSupported = static_cast<BOOL>(::SendMessage(nppData._nppHandle, NPPM_GETAPPDATAPLUGINSALLOWED, 0, 0)); |
| 250 | // TODO Test |
| 251 | |
| 252 | |
| 253 | |
| 254 | // If AppData plugins are not supported, then reset the install location. |
| 255 | if (FALSE == g_options.appDataPluginsSupported) |
| 256 | { |
| 257 | if (g_options.installLocation == INSTALLLOC_APPDATA |
| 258 | || g_options.installLocation == INSTALLLOC_ALLUSERS) |
| 259 | { |
| 260 | g_options.installLocation = INSTALLLOC_ALLUSERSNOAPPDATA; |
| 261 | } |
| 262 | } |
| 263 | // Else, if we've "upgraded" to support for all users, assume we want appdata plugins |
| 264 | else if (TRUE == g_options.appDataPluginsSupported |
| 265 | && g_options.installLocation == INSTALLLOC_ALLUSERSNOAPPDATA) |
| 266 | { |
| 267 | g_options.installLocation = INSTALLLOC_APPDATA; |
| 268 | } |
| 269 | |
| 270 | TCHAR tmpLastCheck[20]; |
| 271 | ::GetPrivateProfileString(SETTINGS_GROUP, KEY_LASTCHECK, _T("0"), tmpLastCheck, 20, iniFilePath); |
| 272 | |
| 273 | g_options.lastCheck = (time_t)_ttol(tmpLastCheck); |
| 274 |