From b2269a81668efaf157d541f2ffd67e52b89417c6 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 1 Mar 2013 21:11:59 +0000 Subject: useless Folders support checks removed git-svn-id: http://svn.miranda-ng.org/main/trunk@3824 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/AVS/src/main.cpp | 10 ++----- plugins/AvatarHistory/src/AvatarHistory.cpp | 6 ++--- plugins/BASS_interface/src/Main.cpp | 22 +++++++-------- plugins/CrashDumper/src/crshdmp.cpp | 2 +- plugins/Db_autobackups/src/main.cpp | 42 +++++++++-------------------- plugins/MirOTR/MirOTR/src/options.cpp | 13 +++++---- plugins/NewsAggregator/Src/Services.cpp | 12 +++------ plugins/PackUpdater/Src/PackUpdater.cpp | 8 +++--- plugins/PluginUpdater/src/PluginUpdater.cpp | 10 +++---- plugins/SecureIM/src/main.cpp | 9 +++---- plugins/SendScreenshotPlus/src/Main.cpp | 4 +-- plugins/SmileyAdd/src/download.cpp | 10 +++---- plugins/SpellChecker/src/spellchecker.cpp | 20 ++++++-------- plugins/StopSpamMod/src/init.cpp | 6 ++--- plugins/TabSRMM/src/include/mim.h | 1 - plugins/TabSRMM/src/mim.cpp | 27 +++++++------------ plugins/VersionInfo/src/CVersionInfo.cpp | 2 +- plugins/VersionInfo/src/common.h | 1 - plugins/VersionInfo/src/dlgHandlers.cpp | 8 +++--- plugins/VersionInfo/src/hooked_events.cpp | 2 -- plugins/VersionInfo/src/main.cpp | 1 - plugins/YAMN/src/main.cpp | 4 +-- protocols/IcqOscarJ/src/icq_avatar.cpp | 17 +++++------- protocols/JabberG/src/jabber_misc.cpp | 9 +++---- protocols/MRA/src/MraAvatars.cpp | 26 +++++------------- protocols/Xfire/src/main.cpp | 16 +++++------ protocols/Xfire/src/variables.cpp | 5 ++-- protocols/Yahoo/src/avatar.cpp | 13 +++++---- 28 files changed, 110 insertions(+), 196 deletions(-) diff --git a/plugins/AVS/src/main.cpp b/plugins/AVS/src/main.cpp index 70edca3ffb..4deb34af1c 100644 --- a/plugins/AVS/src/main.cpp +++ b/plugins/AVS/src/main.cpp @@ -2026,14 +2026,8 @@ static int ModulesLoaded(WPARAM wParam, LPARAM lParam) SetThreadPriority(hLoaderThread, THREAD_PRIORITY_IDLE); // Folders plugin support - if (ServiceExists(MS_FOLDERS_REGISTER_PATH)) - { - hMyAvatarsFolder = (HANDLE) FoldersRegisterCustomPathT("Avatars", "My Avatars", - MIRANDA_USERDATAT _T("\\Avatars")); - - hGlobalAvatarFolder = (HANDLE) FoldersRegisterCustomPathT("Avatars", "My Global Avatar Cache", - MIRANDA_USERDATAT _T("\\Avatars")); - } + hMyAvatarsFolder = FoldersRegisterCustomPathT("Avatars", "My Avatars", MIRANDA_USERDATAT _T("\\Avatars")); + hGlobalAvatarFolder = FoldersRegisterCustomPathT("Avatars", "My Global Avatar Cache", MIRANDA_USERDATAT _T("\\Avatars")); g_AvatarHistoryAvail = ServiceExists(MS_AVATARHISTORY_ENABLED); diff --git a/plugins/AvatarHistory/src/AvatarHistory.cpp b/plugins/AvatarHistory/src/AvatarHistory.cpp index 7c07aacd51..a7698bca12 100644 --- a/plugins/AvatarHistory/src/AvatarHistory.cpp +++ b/plugins/AvatarHistory/src/AvatarHistory.cpp @@ -196,15 +196,15 @@ static int ModulesLoaded(WPARAM wParam, LPARAM lParam) { mir_sntprintf(basedir, MAX_REGS(basedir), _T("%s\\Avatars History"), profilePath); - hFolder = FoldersRegisterCustomPathT(LPGEN("Avatars"), LPGEN("Avatar History"), + hFolder = FoldersRegisterCustomPathT( LPGEN("Avatars"), LPGEN("Avatar History"), PROFILE_PATHT _T("\\") CURRENT_PROFILET _T("\\Avatars History")); + InitPopups(); if (ServiceExists(MS_MC_GETPROTOCOLNAME)) metacontacts_proto = (char *) CallService(MS_MC_GETPROTOCOLNAME, 0, 0); - if (DBGetContactSettingByte(NULL, MODULE_NAME, "LogToHistory", AVH_DEF_LOGTOHISTORY)) - { + if (DBGetContactSettingByte(NULL, MODULE_NAME, "LogToHistory", AVH_DEF_LOGTOHISTORY)) { char *templates[] = { "Avatar change\nchanged his/her avatar", "Avatar removal\nremoved his/her avatar" }; HICON hIcon = createDefaultOverlayedIcon(FALSE); HistoryEvents_RegisterWithTemplates(MODULE_NAME, "avatarchange", "Avatar change", EVENTTYPE_AVATAR_CHANGE, hIcon, diff --git a/plugins/BASS_interface/src/Main.cpp b/plugins/BASS_interface/src/Main.cpp index e72a855339..d477ba81bb 100644 --- a/plugins/BASS_interface/src/Main.cpp +++ b/plugins/BASS_interface/src/Main.cpp @@ -555,24 +555,20 @@ int OnFoldersChanged(WPARAM, LPARAM) int OnModulesLoaded(WPARAM wParam, LPARAM lParam) { - if (ServiceExists(MS_FOLDERS_REGISTER_PATH)) - { - hBASSFolder = FoldersRegisterCustomPathT("Bass Interface", "Bass library", PLUGINS_PATHT _T("\\Bass")); + if (hBASSFolder = FoldersRegisterCustomPathT("Bass Interface", "Bass library", PLUGINS_PATHT _T("\\Bass"))) { FoldersGetCustomPathT(hBASSFolder, CurrBassPath, MAX_PATH, _T("")); _tcscat(CurrBassPath, _T("\\bass.dll")); } - else - { - DBVARIANT dbv = {0}; - if (db_get_ts(NULL, ModuleName, OPT_BASSPATH, &dbv)) - { - TCHAR* tszFolder = Utils_ReplaceVarsT(_T("%miranda_path%\\plugins\\Bass\\bass.dll")); - lstrcpyn(CurrBassPath, tszFolder, SIZEOF(CurrBassPath)); - mir_free(tszFolder); + else { + DBVARIANT dbv; + if ( db_get_ts(NULL, ModuleName, OPT_BASSPATH, &dbv)) { + lstrcpyn(CurrBassPath, VARST( _T("%miranda_path%\\plugins\\Bass\\bass.dll")), SIZEOF(CurrBassPath)); db_set_ts(NULL, ModuleName, OPT_BASSPATH, CurrBassPath); } - else lstrcpy(CurrBassPath, dbv.ptszVal); - DBFreeVariant(&dbv); + else { + lstrcpy(CurrBassPath, dbv.ptszVal); + DBFreeVariant(&dbv); + } } LoadBassLibrary(CurrBassPath); diff --git a/plugins/CrashDumper/src/crshdmp.cpp b/plugins/CrashDumper/src/crshdmp.cpp index 9aff808c1a..5af1c0b20a 100644 --- a/plugins/CrashDumper/src/crshdmp.cpp +++ b/plugins/CrashDumper/src/crshdmp.cpp @@ -236,7 +236,7 @@ static int ModulesLoaded(WPARAM, LPARAM) crs_a2t(vertxt, temp); profname = Utils_ReplaceVarsT(_T("%miranda_profilename%.dat")); - if (ServiceExists(MS_FOLDERS_REGISTER_PATH)) + if ( ServiceExists(MS_FOLDERS_REGISTER_PATH)) profpath = mir_tstrdup( _T("%miranda_userdata%")); else profpath = Utils_ReplaceVarsT(_T("%miranda_userdata%")); diff --git a/plugins/Db_autobackups/src/main.cpp b/plugins/Db_autobackups/src/main.cpp index 93865adbcd..d5c0116e75 100644 --- a/plugins/Db_autobackups/src/main.cpp +++ b/plugins/Db_autobackups/src/main.cpp @@ -6,8 +6,6 @@ TCHAR *profilePath; int hLangpack; HANDLE hFolder; -HANDLE hHooks[4]; -HANDLE hServices[3]; PLUGININFOEX pluginInfo={ sizeof(PLUGININFOEX), @@ -42,12 +40,12 @@ static int FoldersGetBackupPath(WPARAM wParam, LPARAM lParam) return 0; } -static int FoldersInit(void) +static void FoldersInit(void) { - hFolder = (HANDLE) FoldersRegisterCustomPathT("Database Backups", "Backup Folder", DIR SUB_DIR); - hHooks[0] = HookEvent(ME_FOLDERS_PATH_CHANGED, FoldersGetBackupPath); - FoldersGetBackupPath(0, 0); - return 0; + if (hFolder = FoldersRegisterCustomPathT("Database Backups", "Backup Folder", DIR SUB_DIR)) { + HookEvent(ME_FOLDERS_PATH_CHANGED, FoldersGetBackupPath); + FoldersGetBackupPath(0, 0); + } } static void MenuInit(void) @@ -85,16 +83,15 @@ static int ModulesLoad(WPARAM wParam, LPARAM lParam) Icon_Register(hInst, LPGEN("Database/Database Backups"), iconList, SIZEOF(iconList)); - if(ServiceExists(MS_FOLDERS_REGISTER_PATH)) - FoldersInit(); + FoldersInit(); LoadOptions(); MenuInit(); // register trigger action for triggerplugin - if(ServiceExists(MS_TRIGGER_REGISTERACTION)) + if ( ServiceExists(MS_TRIGGER_REGISTERACTION)) TriggerActionInit(); - hHooks[1] = HookEvent(ME_OPT_INITIALISE, OptionsInit); + HookEvent(ME_OPT_INITIALISE, OptionsInit); if(options.backup_types & BT_START) mir_forkthread(BackupThread, NULL); return 0; @@ -117,12 +114,12 @@ void SysInit() mir_getLP(&pluginInfo); OleInitialize(0); - hServices[0] = CreateServiceFunction(MS_AB_BACKUP, ABService); - hServices[1] = CreateServiceFunction(MS_AB_BACKUPTRGR, BackupServiceTrgr); - hServices[2] = CreateServiceFunction(MS_AB_SAVEAS, DBSaveAs); + CreateServiceFunction(MS_AB_BACKUP, ABService); + CreateServiceFunction(MS_AB_BACKUPTRGR, BackupServiceTrgr); + CreateServiceFunction(MS_AB_SAVEAS, DBSaveAs); - hHooks[2] = HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown); - hHooks[3] = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoad); + HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown); + HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoad); } BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) @@ -138,7 +135,6 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda extern "C" __declspec(dllexport) int Load(void) { - SysInit(); return 0; } @@ -146,18 +142,6 @@ extern "C" __declspec(dllexport) int Load(void) extern "C" __declspec(dllexport) int Unload(void) { OleUninitialize(); - - for (int i = 0; i < SIZEOF(hHooks); ++i) - { - if (hHooks[i]) - UnhookEvent(hHooks[i]); - } - for (int i = 0; i < SIZEOF(hServices); ++i) - { - if (hServices[i]) - DestroyServiceFunction(hServices[i]); - } - return 0; } diff --git a/plugins/MirOTR/MirOTR/src/options.cpp b/plugins/MirOTR/MirOTR/src/options.cpp index b561ff9c21..39aa01d639 100644 --- a/plugins/MirOTR/MirOTR/src/options.cpp +++ b/plugins/MirOTR/MirOTR/src/options.cpp @@ -41,17 +41,16 @@ int FoldersChanged(WPARAM wParam, LPARAM lParam) { return 0; } -void LoadFilenames() { - if(ServiceExists(MS_FOLDERS_REGISTER_PATH)) { - hPATH_MIROTR = FoldersRegisterCustomPath(MODULENAME, "Private Data", DATA_DIRECTORY); +void LoadFilenames() +{ + if (hPATH_MIROTR = FoldersRegisterCustomPath(MODULENAME, "Private Data", DATA_DIRECTORY)) { HookEvent(ME_FOLDERS_PATH_CHANGED, FoldersChanged); // get the path - above are only defaults - there may be a different value in the db FoldersChanged(0, 0); - } else { - char *path = Utils_ReplaceVars(DATA_DIRECTORY); - SetFilenames(path); - mir_free(path); + } + else { + SetFilenames( VARS(DATA_DIRECTORY)); ReadPrivkeyFiles(); } } diff --git a/plugins/NewsAggregator/Src/Services.cpp b/plugins/NewsAggregator/Src/Services.cpp index c302abdff2..e742cdb803 100644 --- a/plugins/NewsAggregator/Src/Services.cpp +++ b/plugins/NewsAggregator/Src/Services.cpp @@ -51,17 +51,11 @@ int OnFoldersChanged(WPARAM, LPARAM) int NewsAggrInit(WPARAM wParam, LPARAM lParam) { - if (ServiceExists(MS_FOLDERS_REGISTER_PATH)) - { - hNewsAggregatorFolder = FoldersRegisterCustomPathT("News Aggregator", "Avatars", MIRANDA_USERDATAT _T("\\Avatars\\")_T(DEFAULT_AVATARS_FOLDER)); + hNewsAggregatorFolder = FoldersRegisterCustomPathT("News Aggregator", "Avatars", MIRANDA_USERDATAT _T("\\Avatars\\")_T(DEFAULT_AVATARS_FOLDER)); + if (hNewsAggregatorFolder) FoldersGetCustomPathT(hNewsAggregatorFolder, tszRoot, MAX_PATH, _T("")); - } else - { - TCHAR* tszFolder = Utils_ReplaceVarsT(_T("%miranda_userdata%\\"_T(DEFAULT_AVATARS_FOLDER))); - lstrcpyn(tszRoot, tszFolder, SIZEOF(tszRoot)); - mir_free(tszFolder); - } + lstrcpyn(tszRoot, VARST( _T("%miranda_userdata%\\"_T(DEFAULT_AVATARS_FOLDER))), SIZEOF(tszRoot)); HANDLE hContact = db_find_first(); while (hContact != NULL) diff --git a/plugins/PackUpdater/Src/PackUpdater.cpp b/plugins/PackUpdater/Src/PackUpdater.cpp index 7ab4ab7e50..1dde3c429f 100644 --- a/plugins/PackUpdater/Src/PackUpdater.cpp +++ b/plugins/PackUpdater/Src/PackUpdater.cpp @@ -56,11 +56,11 @@ extern "C" __declspec(dllexport) int Load(void) TCHAR* tszFolder = Utils_ReplaceVarsT(_T("%miranda_userdata%\\"DEFAULT_UPDATES_FOLDER)); lstrcpyn(tszRoot, tszFolder, SIZEOF(tszRoot)); - if (ServiceExists(MS_FOLDERS_REGISTER_PATH)) - { - hPackUpdaterFolder = FoldersRegisterCustomPathT(MODULEA, "Pack Updater", MIRANDA_USERDATAT _T("\\")DEFAULT_UPDATES_FOLDER); + + hPackUpdaterFolder = FoldersRegisterCustomPathT(MODULEA, "Pack Updater", MIRANDA_USERDATAT _T("\\")DEFAULT_UPDATES_FOLDER); + if (hPackUpdaterFolder) FoldersGetCustomPathT(hPackUpdaterFolder, tszRoot, MAX_PATH, _T("")); - } + mir_free(tszFolder); LoadOptions(); InitPopupList(); diff --git a/plugins/PluginUpdater/src/PluginUpdater.cpp b/plugins/PluginUpdater/src/PluginUpdater.cpp index 3ee3dabaae..383773cade 100644 --- a/plugins/PluginUpdater/src/PluginUpdater.cpp +++ b/plugins/PluginUpdater/src/PluginUpdater.cpp @@ -85,15 +85,11 @@ extern "C" __declspec(dllexport) int Load(void) { mir_getLP(&pluginInfoEx); #endif - if (ServiceExists(MS_FOLDERS_REGISTER_PATH)) - hPluginUpdaterFolder = FoldersRegisterCustomPathT(MODULEA, "Plugin Updater", MIRANDA_PATHT _T("\\")DEFAULT_UPDATES_FOLDER); - + hPluginUpdaterFolder = FoldersRegisterCustomPathT(MODULEA, "Plugin Updater", MIRANDA_PATHT _T("\\")DEFAULT_UPDATES_FOLDER); if (hPluginUpdaterFolder) OnFoldersChanged(0, 0); - else { - mir_ptr tszFolder( Utils_ReplaceVarsT(_T("%miranda_path%\\"DEFAULT_UPDATES_FOLDER))); - lstrcpyn(tszRoot, tszFolder, SIZEOF(tszRoot)); - } + else + lstrcpyn(tszRoot, VARST( _T("%miranda_path%\\"DEFAULT_UPDATES_FOLDER)), SIZEOF(tszRoot)); DWORD dwLen = GetTempPath( SIZEOF(tszTempPath), tszTempPath); if (tszTempPath[dwLen-1] == '\\') diff --git a/plugins/SecureIM/src/main.cpp b/plugins/SecureIM/src/main.cpp index f8bf8c57fa..2c5aec0cb0 100644 --- a/plugins/SecureIM/src/main.cpp +++ b/plugins/SecureIM/src/main.cpp @@ -160,12 +160,11 @@ int onModulesLoaded(WPARAM wParam, LPARAM lParam) Sent_NetLog("onModuleLoaded begin"); #endif - if ( ServiceExists(MS_FOLDERS_GET_PATH)) - g_hFolders = FoldersRegisterCustomPathT(szModuleName, "Icons", _T(MIRANDA_PATH"\\icons")); + g_hFolders = FoldersRegisterCustomPathT(szModuleName, "Icons", _T(MIRANDA_PATH"\\icons")); - InitIcons(); - GetFlags(); - ModuleLoad(0, 0); + InitIcons(); + GetFlags(); + ModuleLoad(0, 0); #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("rsa_init"); diff --git a/plugins/SendScreenshotPlus/src/Main.cpp b/plugins/SendScreenshotPlus/src/Main.cpp index 4cb19a1e5b..ec9dbc30f9 100644 --- a/plugins/SendScreenshotPlus/src/Main.cpp +++ b/plugins/SendScreenshotPlus/src/Main.cpp @@ -134,10 +134,8 @@ int hook_ModulesLoaded(WPARAM, LPARAM) { } // Folders plugin support - if (ServiceExists(MS_FOLDERS_REGISTER_PATH)) { - hFolderScreenshot = FoldersRegisterCustomPathT("SendSS", "Screenshots", + hFolderScreenshot = FoldersRegisterCustomPathT("SendSS", "Screenshots", _T(PROFILE_PATH)_T("\\")_T(CURRENT_PROFILE)_T("\\Screenshots")); - } return 0; } diff --git a/plugins/SmileyAdd/src/download.cpp b/plugins/SmileyAdd/src/download.cpp index ca228d8ee2..5ac7acfc59 100644 --- a/plugins/SmileyAdd/src/download.cpp +++ b/plugins/SmileyAdd/src/download.cpp @@ -22,7 +22,7 @@ along with this program. If not, see . extern HANDLE hEvent1; HANDLE hNetlibUser; -static HANDLE hFolder, hFolderHook; +static HANDLE hFolder; struct QueueElem { @@ -227,11 +227,10 @@ int FolderChanged(WPARAM, LPARAM) void GetSmileyCacheFolder(void) { - if (ServiceExists(MS_FOLDERS_REGISTER_PATH)) - { - hFolder = FoldersRegisterCustomPathT("SmileyAdd", "Smiley Cache", MIRANDA_USERDATAT _T("\\SmileyCache")); + hFolder = FoldersRegisterCustomPathT("SmileyAdd", "Smiley Cache", MIRANDA_USERDATAT _T("\\SmileyCache")); + if (hFolder) { FoldersGetCustomPathT(hFolder, cachepath, MAX_PATH, _T("")); - hFolderHook = HookEvent(ME_FOLDERS_PATH_CHANGED, FolderChanged); + HookEvent(ME_FOLDERS_PATH_CHANGED, FolderChanged); } else { @@ -256,7 +255,6 @@ void DownloadInit(void) void DownloadClose(void) { - UnhookEvent(hFolderHook); CloseHandle(g_hDlMutex); Netlib_CloseHandle(hNetlibUser); } diff --git a/plugins/SpellChecker/src/spellchecker.cpp b/plugins/SpellChecker/src/spellchecker.cpp index c6ec132a74..2b554dfe69 100644 --- a/plugins/SpellChecker/src/spellchecker.cpp +++ b/plugins/SpellChecker/src/spellchecker.cpp @@ -119,27 +119,23 @@ static int ModulesLoaded(WPARAM wParam, LPARAM lParam) CallService("DBEditorpp/RegisterSingleModule", (WPARAM) MODULE_NAME, 0); // Folders plugin support - if ( ServiceExists(MS_FOLDERS_REGISTER_PATH)) { - hDictionariesFolder = FoldersRegisterCustomPathT(LPGEN("Spell Checker"), LPGEN("Dictionaries"), DICTIONARIES_FOLDER); - + if (hDictionariesFolder = FoldersRegisterCustomPathT(LPGEN("Spell Checker"), LPGEN("Dictionaries"), DICTIONARIES_FOLDER)) { dictionariesFolder = (TCHAR *) mir_alloc(sizeof(TCHAR) * MAX_PATH); FoldersGetCustomPathT(hDictionariesFolder, dictionariesFolder, MAX_PATH, _T(".")); + } + else dictionariesFolder = Utils_ReplaceVarsT(DICTIONARIES_FOLDER); - hCustomDictionariesFolder = FoldersRegisterCustomPathT(LPGEN("Spell Checker"), LPGEN("Custom Dictionaries"), CUSTOM_DICTIONARIES_FOLDER); - + if (hCustomDictionariesFolder = FoldersRegisterCustomPathT(LPGEN("Spell Checker"), LPGEN("Custom Dictionaries"), CUSTOM_DICTIONARIES_FOLDER)) { customDictionariesFolder = (TCHAR *) mir_alloc(sizeof(TCHAR) * MAX_PATH); FoldersGetCustomPathT(hCustomDictionariesFolder, customDictionariesFolder, MAX_PATH, _T(".")); + } + else customDictionariesFolder = Utils_ReplaceVarsT(CUSTOM_DICTIONARIES_FOLDER); - hFlagsDllFolder = FoldersRegisterCustomPathT(LPGEN("Spell Checker"), LPGEN("Flags DLL"), FLAGS_DLL_FOLDER); - + if (hFlagsDllFolder = FoldersRegisterCustomPathT(LPGEN("Spell Checker"), LPGEN("Flags DLL"), FLAGS_DLL_FOLDER)) { flagsDllFolder = (TCHAR *) mir_alloc(sizeof(TCHAR) * MAX_PATH); FoldersGetCustomPathT(hFlagsDllFolder, flagsDllFolder, MAX_PATH, _T(".")); } - else { - dictionariesFolder = Utils_ReplaceVarsT(DICTIONARIES_FOLDER); - customDictionariesFolder = Utils_ReplaceVarsT(CUSTOM_DICTIONARIES_FOLDER); - flagsDllFolder = Utils_ReplaceVarsT(FLAGS_DLL_FOLDER); - } + else flagsDllFolder = Utils_ReplaceVarsT(FLAGS_DLL_FOLDER); InitOptions(); diff --git a/plugins/StopSpamMod/src/init.cpp b/plugins/StopSpamMod/src/init.cpp index 8e3f1fca46..63665337f9 100755 --- a/plugins/StopSpamMod/src/init.cpp +++ b/plugins/StopSpamMod/src/init.cpp @@ -129,11 +129,9 @@ static int OnSystemModulesLoaded(WPARAM wParam,LPARAM lParam) void CleanThread(); if(gbDelAllTempory || gbDelExcluded) boost::thread *thr = new boost::thread(&CleanThread); + // Folders plugin support - if (ServiceExists(MS_FOLDERS_REGISTER_PATH)) - { - hStopSpamLogDirH = (HANDLE) FoldersRegisterCustomPath("StopSpam", "StopSpam Logs", PROFILE_PATH "\\" CURRENT_PROFILE "\\StopSpamLog"); - } + hStopSpamLogDirH = FoldersRegisterCustomPath("StopSpam", "StopSpam Logs", PROFILE_PATH "\\" CURRENT_PROFILE "\\StopSpamLog"); return 0; } diff --git a/plugins/TabSRMM/src/include/mim.h b/plugins/TabSRMM/src/include/mim.h index c971cb7fdf..30d89406e6 100644 --- a/plugins/TabSRMM/src/include/mim.h +++ b/plugins/TabSRMM/src/include/mim.h @@ -159,7 +159,6 @@ public: const TCHAR* getSkinPath() const { return(m_szSkinsPath); } const TCHAR* getSavedAvatarPath() const { return(m_szSavedAvatarsPath); } const TCHAR* getChatLogPath() const { return(m_szChatLogsPath); } - const bool haveFoldersPlugin() const { return(m_haveFolders); } const TCHAR* getUserDir(); void configureCustomFolders(); diff --git a/plugins/TabSRMM/src/mim.cpp b/plugins/TabSRMM/src/mim.cpp index f491210554..809a7b0a56 100644 --- a/plugins/TabSRMM/src/mim.cpp +++ b/plugins/TabSRMM/src/mim.cpp @@ -318,17 +318,13 @@ int CMimAPI::FoldersPathChanged(WPARAM wParam, LPARAM lParam) void CMimAPI::configureCustomFolders() { - m_haveFolders = false; - if (ServiceExists(MS_FOLDERS_REGISTER_PATH)) { - m_hDataPath = (HANDLE)FoldersRegisterCustomPathT("TabSRMM", "Data path", const_cast(getDataPath())); - m_hSkinsPath = (HANDLE)FoldersRegisterCustomPathT("TabSRMM", "Skins root", const_cast(getSkinPath())); - m_hAvatarsPath = (HANDLE)FoldersRegisterCustomPathT("TabSRMM", "Saved Avatars", const_cast(getSavedAvatarPath())); - m_hChatLogsPath = (HANDLE)FoldersRegisterCustomPathT("TabSRMM", "Group chat logs root", const_cast(getChatLogPath())); + m_hDataPath = FoldersRegisterCustomPathT("TabSRMM", "Data path", const_cast(getDataPath())); + m_hSkinsPath = FoldersRegisterCustomPathT("TabSRMM", "Skins root", const_cast(getSkinPath())); + m_hAvatarsPath = FoldersRegisterCustomPathT("TabSRMM", "Saved Avatars", const_cast(getSavedAvatarPath())); + m_hChatLogsPath = FoldersRegisterCustomPathT("TabSRMM", "Group chat logs root", const_cast(getChatLogPath())); + + if (m_hDataPath) CGlobals::m_event_FoldersChanged = HookEvent(ME_FOLDERS_PATH_CHANGED, CMimAPI::FoldersPathChanged); - m_haveFolders = true; - } - else - m_hDataPath = m_hSkinsPath = m_hAvatarsPath = m_hChatLogsPath = 0; foldersPathChanged(); } @@ -381,15 +377,12 @@ INT_PTR CMimAPI::foldersPathChanged() const TCHAR* CMimAPI::getUserDir() { if (m_userDir[0] == 0) { - wchar_t* userdata; - if (ServiceExists(MS_FOLDERS_REGISTER_PATH)) - userdata = L"%%miranda_userdata%%"; + if ( ServiceExists(MS_FOLDERS_REGISTER_PATH)) + lstrcpyn(m_userDir, L"%%miranda_userdata%%", SIZEOF(m_userDir)); else - userdata = ::Utils_ReplaceVarsT(L"%miranda_userdata%"); - mir_sntprintf(m_userDir, MAX_PATH, userdata); + lstrcpyn(m_userDir, VARST( _T("%miranda_userdata%")), SIZEOF(m_userDir)); + Utils::ensureTralingBackslash(m_userDir); - if (!ServiceExists(MS_FOLDERS_REGISTER_PATH)) - mir_free(userdata); } return(m_userDir); } diff --git a/plugins/VersionInfo/src/CVersionInfo.cpp b/plugins/VersionInfo/src/CVersionInfo.cpp index 1604babb81..e26a6dc233 100644 --- a/plugins/VersionInfo/src/CVersionInfo.cpp +++ b/plugins/VersionInfo/src/CVersionInfo.cpp @@ -1113,7 +1113,7 @@ std::tstring CVersionInfo::GetInformationsAsString(int bDisableForumStyle) { void CVersionInfo::PrintInformationsToFile(const TCHAR *info) { TCHAR buffer[MAX_PATH], outputFileName[MAX_PATH]; - if (bFoldersAvailable) { + if (hOutputLocation) { FoldersGetCustomPathT(hOutputLocation, buffer, SIZEOF(buffer), _T("%miranda_path%")); _tcscat(buffer, _T("\\VersionInfo.txt")); } diff --git a/plugins/VersionInfo/src/common.h b/plugins/VersionInfo/src/common.h index 20d48e5f3b..cbbf057daa 100644 --- a/plugins/VersionInfo/src/common.h +++ b/plugins/VersionInfo/src/common.h @@ -82,7 +82,6 @@ extern HICON hiVIIcon; extern DWORD EnglishLocale; //for folders support -extern BOOL bFoldersAvailable; extern HANDLE hOutputLocation; //services.cpp diff --git a/plugins/VersionInfo/src/dlgHandlers.cpp b/plugins/VersionInfo/src/dlgHandlers.cpp index a1a81e6a51..733a4cd3dc 100644 --- a/plugins/VersionInfo/src/dlgHandlers.cpp +++ b/plugins/VersionInfo/src/dlgHandlers.cpp @@ -264,7 +264,7 @@ INT_PTR CALLBACK DlgProcOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) else RelativePathToAbsolute( _T("VersionInfo.txt"), notFound, SIZEOF(notFound)); - if (bFoldersAvailable) + if (hOutputLocation) _tcscpy(buffer, TranslateT("Customize using folders plugin")); else _tcsncpy(buffer, notFound, SIZEOF(notFound)); @@ -345,7 +345,7 @@ INT_PTR CALLBACK DlgProcOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) EnableWindow(GetDlgItem(hWnd, IDC_SHOWINTASKBAR), IsDlgButtonChecked(hWnd, IDC_TODIALOGBOX) ? TRUE : FALSE); //only enable for to dialog box EnableWindow(GetDlgItem(hWnd, IDC_DISABLEDTOO), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? FALSE : TRUE); //if forum style disable show disabled plugins EnableWindow(GetDlgItem(hWnd, IDC_CLIPBOARDALSO), IsDlgButtonChecked(hWnd, IDC_TOCLIPBOARD) ? FALSE : TRUE); //don't enable always clipboard if we're printing to clipboard - EnableWindow(GetDlgItem(hWnd, IDC_FILENAME), ((IsDlgButtonChecked(hWnd, IDC_TOFILE)) && (!bFoldersAvailable)) ? TRUE : FALSE); + EnableWindow(GetDlgItem(hWnd, IDC_FILENAME), ((IsDlgButtonChecked(hWnd, IDC_TOFILE)) && (!hOutputLocation)) ? TRUE : FALSE); EnableUploadSettings(hWnd, IsDlgButtonChecked(hWnd, IDC_TOUPLOAD) ? TRUE : FALSE); { OSVERSIONINFO osvi = { 0 }; @@ -378,7 +378,7 @@ INT_PTR CALLBACK DlgProcOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) EnableWindow(GetDlgItem(hWnd, IDC_SIZECOMBOBOX), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); //forum style only EnableWindow(GetDlgItem(hWnd, IDC_BOLDVERSION), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); //forum style only EnableWindow(GetDlgItem(hWnd, IDC_BOLDCOMBOBOX), (IsDlgButtonChecked(hWnd, IDC_BOLDVERSION) & IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE)) ? TRUE : FALSE); //both forum style and bold version checked - EnableWindow(GetDlgItem(hWnd, IDC_FILENAME), ((IsDlgButtonChecked(hWnd, IDC_TOFILE)) && (!bFoldersAvailable)) ? TRUE : FALSE); + EnableWindow(GetDlgItem(hWnd, IDC_FILENAME), ((IsDlgButtonChecked(hWnd, IDC_TOFILE)) && (!hOutputLocation)) ? TRUE : FALSE); EnableWindow(GetDlgItem(hWnd, IDC_SHOWINTASKBAR), IsDlgButtonChecked(hWnd, IDC_TODIALOGBOX) ? TRUE : FALSE); //only enable for to dialog box EnableWindow(GetDlgItem(hWnd, IDC_DISABLEDTOO), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? FALSE : TRUE); //if forum style disable show disabled plugins EnableWindow(GetDlgItem(hWnd, IDC_CLIPBOARDALSO), IsDlgButtonChecked(hWnd, IDC_TOCLIPBOARD) ? FALSE : TRUE); //don't enable always clipboard if we're printing to clipboard @@ -461,7 +461,7 @@ INT_PTR CALLBACK DlgProcOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) DBWriteContactSettingByte(NULL, ModuleName, "ShowUUIDs", IsDlgButtonChecked(hWnd, IDC_SHOWUUIDS) ? TRUE : FALSE); DBWriteContactSettingByte(NULL, ModuleName, "ShowInstalledLanguages", IsDlgButtonChecked(hWnd, IDC_SHOWINSTALLEDLANGUAGES) ? TRUE : FALSE); - if (!bFoldersAvailable) { + if (!hOutputLocation) { TCHAR filePath[MAX_PATH], fileName[MAX_PATH]; GetDlgItemText(hWnd, IDC_FILENAME, fileName, MAX_PATH); AbsolutePathToRelative(fileName, filePath, SIZEOF(filePath)); diff --git a/plugins/VersionInfo/src/hooked_events.cpp b/plugins/VersionInfo/src/hooked_events.cpp index fb28978377..44c24ec9ef 100644 --- a/plugins/VersionInfo/src/hooked_events.cpp +++ b/plugins/VersionInfo/src/hooked_events.cpp @@ -49,8 +49,6 @@ int UnhookEvents() int OnModulesLoaded(WPARAM wParam, LPARAM lParam) { - - bFoldersAvailable = ServiceExists(MS_FOLDERS_REGISTER_PATH); hOutputLocation = FoldersRegisterCustomPathT("VersionInfo", "Output folder", _T("%miranda_path%")); GetStringFromDatabase("UUIDCharMark", _T(DEF_UUID_CHARMARK), PLUGIN_UUID_MARK, cPLUGIN_UUID_MARK); diff --git a/plugins/VersionInfo/src/main.cpp b/plugins/VersionInfo/src/main.cpp index 5068fceece..7a5810917d 100644 --- a/plugins/VersionInfo/src/main.cpp +++ b/plugins/VersionInfo/src/main.cpp @@ -30,7 +30,6 @@ HICON hiVIIcon; DWORD EnglishLocale; -BOOL bFoldersAvailable = FALSE; HANDLE hOutputLocation = NULL; //for folders plugin void * (* MirandaMalloc)(size_t); diff --git a/plugins/YAMN/src/main.cpp b/plugins/YAMN/src/main.cpp index 07a6ce0e85..96344c2f80 100644 --- a/plugins/YAMN/src/main.cpp +++ b/plugins/YAMN/src/main.cpp @@ -226,10 +226,8 @@ int SystemModulesLoaded(WPARAM, LPARAM) CheckMenuItems(); - if (ServiceExists(MS_FOLDERS_GET_PATH)) { - hAccountFolder = FoldersRegisterCustomPathT(YAMN_DBMODULE, YAMN_DBMODULE" Account Folder", UserDirectory); + if (hAccountFolder = FoldersRegisterCustomPathT(YAMN_DBMODULE, YAMN_DBMODULE" Account Folder", UserDirectory)) FoldersGetCustomPathT(hAccountFolder, UserDirectory, MAX_PATH, UserDirectory); - } RegisterPOP3Plugin(0, 0); return 0; diff --git a/protocols/IcqOscarJ/src/icq_avatar.cpp b/protocols/IcqOscarJ/src/icq_avatar.cpp index 65b69db92a..f1db812a5e 100644 --- a/protocols/IcqOscarJ/src/icq_avatar.cpp +++ b/protocols/IcqOscarJ/src/icq_avatar.cpp @@ -85,18 +85,15 @@ avatars_request* CIcqProto::ReleaseAvatarRequestInQueue(avatars_request *request void CIcqProto::InitAvatars() { - if (!bAvatarsFolderInited) - { // do it only once - bAvatarsFolderInited = TRUE; + if (bAvatarsFolderInited) + return; - if (ServiceExists(MS_FOLDERS_REGISTER_PATH)) - { // check if it does make sense - TCHAR tszPath[MAX_PATH * 2]; - null_snprintf(tszPath, MAX_PATH * 2, _T("%%miranda_avatarcache%%\\") _T(TCHAR_STR_PARAM) _T("\\"), m_szModuleName); + bAvatarsFolderInited = TRUE; - hAvatarsFolder = FoldersRegisterCustomPathT(m_szModuleName, "Avatars Cache", tszPath); - } - } + // check if it does make sense + TCHAR tszPath[MAX_PATH * 2]; + null_snprintf(tszPath, MAX_PATH * 2, _T("%%miranda_avatarcache%%\\") _T(TCHAR_STR_PARAM) _T("\\"), m_szModuleName); + hAvatarsFolder = FoldersRegisterCustomPathT(m_szModuleName, "Avatars Cache", tszPath); } diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp index 7ddace9373..abb15774a3 100644 --- a/protocols/JabberG/src/jabber_misc.cpp +++ b/protocols/JabberG/src/jabber_misc.cpp @@ -255,11 +255,10 @@ void CJabberProto::InitCustomFolders(void) return; bInitDone = true; - if (ServiceExists(MS_FOLDERS_REGISTER_PATH)) { - TCHAR AvatarsFolder[MAX_PATH]; - mir_sntprintf(AvatarsFolder, SIZEOF(AvatarsFolder), _T("%%miranda_avatarcache%%\\Jabber")); - hJabberAvatarsFolder = FoldersRegisterCustomPathT(m_szModuleName, "Avatars", AvatarsFolder); // title!!!!!!!!!!! -} } + TCHAR AvatarsFolder[MAX_PATH]; + mir_sntprintf(AvatarsFolder, SIZEOF(AvatarsFolder), _T("%%miranda_avatarcache%%\\Jabber")); + hJabberAvatarsFolder = FoldersRegisterCustomPathT(m_szModuleName, "Avatars", AvatarsFolder); +} void CJabberProto::GetAvatarFileName(HANDLE hContact, TCHAR* pszDest, size_t cbLen) { diff --git a/protocols/MRA/src/MraAvatars.cpp b/protocols/MRA/src/MraAvatars.cpp index df329a072d..aec806c687 100644 --- a/protocols/MRA/src/MraAvatars.cpp +++ b/protocols/MRA/src/MraAvatars.cpp @@ -53,14 +53,6 @@ struct MRA_AVATARS_QUEUE_ITEM : public FIFO_MT_ITEM char szAvtSectName[MAX_PATH]; #define MRA_AVT_SECT_NAME szAvtSectName - -static bool bFoldersPresent = false; - - -//#define mir_calloc(Size) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (Size+sizeof(size_t))) -//#define mir_realloc(Mem, Size) HeapReAlloc(GetProcessHeap(), (HEAP_ZERO_MEMORY), (LPVOID)Mem, (Size+sizeof(size_t))) -//#define mir_free(Mem) if (Mem) {HeapFree(GetProcessHeap(), 0, (LPVOID)Mem);Mem = NULL;} - #define NETLIB_CLOSEHANDLE(hConnection) {Netlib_CloseHandle(hConnection);hConnection = NULL;} HANDLE MraAvatarsHttpConnect(HANDLE hNetlibUser, LPSTR lpszHost, DWORD dwPort); @@ -75,7 +67,6 @@ DWORD MraAvatarsGetFileFormat (LPTSTR lpszPath, size_t dwPathSize); DWORD CMraProto::MraAvatarsQueueInitialize(HANDLE *phAvatarsQueueHandle) { - bFoldersPresent = ServiceExists( MS_FOLDERS_REGISTER_PATH ) != 0; mir_snprintf(szAvtSectName, SIZEOF(szAvtSectName), "%s Avatars", m_szModuleName); if (phAvatarsQueueHandle == NULL) @@ -97,12 +88,9 @@ DWORD CMraProto::MraAvatarsQueueInitialize(HANDLE *phAvatarsQueueHandle) nlu.szDescriptiveName = szBuffer; pmraaqAvatarsQueue->hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu); if (pmraaqAvatarsQueue->hNetlibUser) { - if (bFoldersPresent) { - TCHAR tszPath[ MAX_PATH ]; - mir_sntprintf( tszPath, SIZEOF(tszPath), _T("%%miranda_avatarcache%%\\%s"), m_tszUserName); - pmraaqAvatarsQueue->hAvatarsPath = FoldersRegisterCustomPathT(MRA_AVT_SECT_NAME, "AvatarsPath", tszPath); - } - else pmraaqAvatarsQueue->hAvatarsPath = NULL; + TCHAR tszPath[ MAX_PATH ]; + mir_sntprintf( tszPath, SIZEOF(tszPath), _T("%%miranda_avatarcache%%\\%s"), m_tszUserName); + pmraaqAvatarsQueue->hAvatarsPath = FoldersRegisterCustomPathT(MRA_AVT_SECT_NAME, "AvatarsPath", tszPath); InterlockedExchange((volatile LONG*)&pmraaqAvatarsQueue->bIsRunning, TRUE); pmraaqAvatarsQueue->hThreadEvent = CreateEvent(NULL, FALSE, FALSE, NULL); @@ -547,13 +535,11 @@ DWORD CMraProto::MraAvatarsGetFileName(HANDLE hAvatarsQueueHandle, HANDLE hConta size_t dwEMailSize; MRA_AVATARS_QUEUE *pmraaqAvatarsQueue = (MRA_AVATARS_QUEUE*)hAvatarsQueueHandle; - if ( !bFoldersPresent ) { + if (pmraaqAvatarsQueue->hAvatarsPath == NULL) // default path - mir_ptr lpszPathToAvatarsCache( Utils_ReplaceVarsT( _T("%miranda_avatarcache%"))); - dwEMailSize = mir_sntprintf(lpszPath, dwPathSize, _T("%s\\%s\\"), (TCHAR*)lpszPathToAvatarsCache, m_tszUserName); - } + dwEMailSize = mir_sntprintf(lpszPath, dwPathSize, _T("%s\\%s\\"), (TCHAR*)VARST( _T("%miranda_avatarcache%")), m_tszUserName); else { - FoldersGetCustomPathT( pmraaqAvatarsQueue->hAvatarsPath, lpszCurPath, int(dwPathSize), _T("")); + FoldersGetCustomPathT(pmraaqAvatarsQueue->hAvatarsPath, lpszCurPath, int(dwPathSize), _T("")); dwEMailSize = lstrlen( lpszCurPath ); _tcscpy( lpszCurPath + dwEMailSize, _T("\\")); dwEMailSize++; diff --git a/protocols/Xfire/src/main.cpp b/protocols/Xfire/src/main.cpp index e723338788..d15a51e169 100644 --- a/protocols/Xfire/src/main.cpp +++ b/protocols/Xfire/src/main.cpp @@ -1200,18 +1200,14 @@ extern "C" __declspec(dllexport) int Load(void) strcat(AvatarsFolder, CurProfile); strcat(AvatarsFolder, "\\"); strcat(AvatarsFolder, "XFire"); - if (ServiceExists(MS_FOLDERS_REGISTER_PATH)){ - XFireWorkingFolder = FoldersRegisterCustomPath(protocolname, "Working Folder", AvatarsFolder); - XFireIconFolder = FoldersRegisterCustomPath(protocolname, "Game Icon Folder", AvatarsFolder); - } - else - CreateDirectory(AvatarsFolder,NULL); + + XFireWorkingFolder = FoldersRegisterCustomPath(protocolname, "Working Folder", AvatarsFolder); + if ( !(XFireIconFolder = FoldersRegisterCustomPath(protocolname, "Game Icon Folder", AvatarsFolder))) + CreateDirectory(AvatarsFolder, NULL); strcat(AvatarsFolder, "\\Avatars"); - if (ServiceExists(MS_FOLDERS_REGISTER_PATH)) - XFireAvatarFolder = FoldersRegisterCustomPath(protocolname, "Avatars", AvatarsFolder); - else - CreateDirectory(AvatarsFolder,NULL); + if ( !(XFireAvatarFolder = FoldersRegisterCustomPath(protocolname, "Avatars", AvatarsFolder))) + CreateDirectory(AvatarsFolder,NULL); //erweiterte Kontextmenüpunkte CLISTMENUITEM mi = { sizeof(mi) }; diff --git a/protocols/Xfire/src/variables.cpp b/protocols/Xfire/src/variables.cpp index 1ba54f6ddd..d1e0d64df0 100644 --- a/protocols/Xfire/src/variables.cpp +++ b/protocols/Xfire/src/variables.cpp @@ -4,6 +4,8 @@ #include "variables.h" #include +extern HANDLE XFireWorkingFolder, XFireIconFolder, XFireAvatarFolder; + using namespace std; char* Varxfiregame(ARGUMENTSINFO *ai) @@ -169,9 +171,6 @@ char* Varmyxfirevoice(ARGUMENTSINFO *ai) char* XFireGetFoldersPath(char * pathtype) {// Get XFire folder path -extern HANDLE XFireWorkingFolder; -extern HANDLE XFireIconFolder; -extern HANDLE XFireAvatarFolder; static char path[1024]; path[0] = 0; if (ServiceExists(MS_FOLDERS_REGISTER_PATH)){ if (!strcmp(pathtype,"Avatar")){ diff --git a/protocols/Yahoo/src/avatar.cpp b/protocols/Yahoo/src/avatar.cpp index 69d771ee94..bc0a6ef32f 100644 --- a/protocols/Yahoo/src/avatar.cpp +++ b/protocols/Yahoo/src/avatar.cpp @@ -619,15 +619,14 @@ void CYahooProto::request_avatar(const char* who) void CYahooProto::InitCustomFolders(void) { - if ( InitCstFldRan ) return; + if (InitCstFldRan) + return; InitCstFldRan = true; - if ( ServiceExists( MS_FOLDERS_REGISTER_PATH )) - { - TCHAR AvatarsFolder[MAX_PATH]; - mir_sntprintf(AvatarsFolder, MAX_PATH, _T("%%miranda_avatarcache%%\\") _T(TCHAR_STR_PARAM), m_szModuleName); - hYahooAvatarsFolder = FoldersRegisterCustomPathT(m_szModuleName, "Avatars", AvatarsFolder); - } + + TCHAR AvatarsFolder[MAX_PATH]; + mir_sntprintf(AvatarsFolder, MAX_PATH, _T("%%miranda_avatarcache%%\\") _T(TCHAR_STR_PARAM), m_szModuleName); + hYahooAvatarsFolder = FoldersRegisterCustomPathT(m_szModuleName, "Avatars", AvatarsFolder); } void CYahooProto::GetAvatarFileName(HANDLE hContact, TCHAR* pszDest, int cbLen, int type) -- cgit v1.2.3