diff options
author | George Hazan <george.hazan@gmail.com> | 2013-10-08 18:28:51 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-10-08 18:28:51 +0000 |
commit | a075d35ca850f06170553d17ca464f0f5feadd97 (patch) | |
tree | 5a86b9dd53d495f6ab987fe72ad2d4f06a85caa2 /src | |
parent | 5ba216d4b0d9a98ff6dfe0e4dd3117dcd417ce3a (diff) |
separate Folders handles removed from protocols
git-svn-id: http://svn.miranda-ng.org/main/trunk@6405 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r-- | src/core/miranda.cpp | 1 | ||||
-rw-r--r-- | src/core/miranda.h | 4 | ||||
-rw-r--r-- | src/mir_core/miranda.h | 4 | ||||
-rw-r--r-- | src/modules/database/database.cpp | 7 | ||||
-rw-r--r-- | src/modules/database/profilemanager.h | 3 | ||||
-rw-r--r-- | src/modules/utils/path.cpp | 40 |
6 files changed, 35 insertions, 24 deletions
diff --git a/src/core/miranda.cpp b/src/core/miranda.cpp index 4ec80c2fe5..522843e919 100644 --- a/src/core/miranda.cpp +++ b/src/core/miranda.cpp @@ -234,6 +234,7 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE, LPTSTR cmdLine, int) result = 1;
goto exit;
}
+ InitPathVar();
NotifyEventHooks(hModulesLoadedEvent, 0, 0);
bModulesLoadedFired = true;
diff --git a/src/core/miranda.h b/src/core/miranda.h index 4b5f3b053f..044b16f38c 100644 --- a/src/core/miranda.h +++ b/src/core/miranda.h @@ -79,6 +79,10 @@ extern HANDLE hOkToExitEvent, hModulesLoadedEvent, hevLoadModule, hevUnloadModul char* GetPluginNameByInstance(HINSTANCE hInstance);
int GetPluginFakeId(const MUUID &uuid, int hLangpack);
+/**** path.cpp *************************************************************************/
+
+void InitPathVar(void);
+
/**** srmm.cpp *************************************************************************/
void KillModuleSrmmIcons(int hLangpack);
diff --git a/src/mir_core/miranda.h b/src/mir_core/miranda.h index d7d03cccbb..84541a819d 100644 --- a/src/mir_core/miranda.h +++ b/src/mir_core/miranda.h @@ -29,10 +29,10 @@ extern "C" void UnloadLangPackModule(void);
-int InitialiseModularEngine(void);
+int InitialiseModularEngine(void);
void DestroyModularEngine(void);
-int InitPathUtils(void);
+int InitPathUtils(void);
void InitProtocols();
void UninitProtocols();
diff --git a/src/modules/database/database.cpp b/src/modules/database/database.cpp index 240daf3277..bdf8422569 100644 --- a/src/modules/database/database.cpp +++ b/src/modules/database/database.cpp @@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // contains the location of mirandaboot.ini
extern TCHAR mirandabootini[MAX_PATH];
bool g_bDbCreated;
-TCHAR g_profileDir[MAX_PATH], g_profileName[MAX_PATH];
+TCHAR g_profileDir[MAX_PATH], g_profileName[MAX_PATH], g_profileRoot[MAX_PATH];
TCHAR* g_defaultProfile;
void EnsureCheckerLoaded(bool);
@@ -51,6 +51,11 @@ static void fillProfileName(const TCHAR* ptszFileName) p++;
_tcsncpy(g_profileName, p, SIZEOF(g_profileName));
+
+ TCHAR *szProfile = NEWTSTR_ALLOCA(p);
+ TCHAR *pExt = _tcsstr( _tcslwr(szProfile), _T(".dat"));
+ if (pExt) *pExt = 0;
+ mir_sntprintf(g_profileRoot, SIZEOF(g_profileRoot), _T("%s\\%s"), g_profileDir, szProfile);
}
bool IsInsideRootDir(TCHAR* profiledir, bool exact)
diff --git a/src/modules/database/profilemanager.h b/src/modules/database/profilemanager.h index f289a77ef8..58fd1d747d 100644 --- a/src/modules/database/profilemanager.h +++ b/src/modules/database/profilemanager.h @@ -37,6 +37,5 @@ int isValidProfileName(const TCHAR *name); bool fileExist(TCHAR* fname);
bool shouldAutoCreate(TCHAR *szProfile);
-extern TCHAR g_profileDir[MAX_PATH];
-extern TCHAR g_profileName[MAX_PATH];
+extern TCHAR g_profileDir[MAX_PATH], g_profileName[MAX_PATH], g_profilePath[MAX_PATH];
extern bool g_bDbCreated;
diff --git a/src/modules/utils/path.cpp b/src/modules/utils/path.cpp index 8eebd9ef09..74d12bd3ba 100644 --- a/src/modules/utils/path.cpp +++ b/src/modules/utils/path.cpp @@ -24,9 +24,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "..\..\core\commonheaders.h"
#include "../database/profilemanager.h"
-extern TCHAR g_profileDir[MAX_PATH];
+#include "..\..\..\plugins\ExternalAPI\m_folders.h"
-static INT_PTR replaceVars(WPARAM wParam, LPARAM lParam);
+extern TCHAR g_profileDir[MAX_PATH], g_profileRoot[MAX_PATH];
+
+static HANDLE hAvatarFolder;
static INT_PTR pathToRelative(WPARAM wParam, LPARAM lParam)
{
@@ -162,22 +164,18 @@ static __forceinline char *GetProfileNameX(char *) }
static __forceinline char *GetPathVarX(char *, int code)
{
- TCHAR szFullPath[MAX_PATH], szProfileName[MAX_PATH];
- _tcscpy(szProfileName, g_profileName);
- _tcslwr(szProfileName);
- TCHAR *pos = _tcsrchr(szProfileName, '.');
- if (lstrcmp(pos, _T(".dat")) == 0)
- *pos = 0;
+ TCHAR szFullPath[MAX_PATH];
switch(code) {
case 1:
- mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("%s\\%s\\AvatarCache"), g_profileDir, szProfileName);
+ if (hAvatarFolder == NULL || FoldersGetCustomPathT(hAvatarFolder, szFullPath, SIZEOF(szFullPath), _T("")))
+ mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("%s\\AvatarCache"), g_profileRoot);
break;
case 2:
- mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("%s\\%s\\Logs"), g_profileDir, szProfileName);
+ mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("%s\\Logs"), g_profileRoot);
break;
case 3:
- mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("%s\\%s"), g_profileDir, szProfileName);
+ _tcsncpy_s(szFullPath, SIZEOF(szFullPath), g_profileRoot, _TRUNCATE);
break;
}
return makeFileName(szFullPath);
@@ -244,21 +242,18 @@ static __forceinline TCHAR *GetProfileNameX(TCHAR *) }
static __forceinline TCHAR *GetPathVarX(TCHAR *, int code)
{
- TCHAR szFullPath[MAX_PATH], szProfileName[MAX_PATH];
- _tcscpy(szProfileName, g_profileName);
- TCHAR *pos = _tcsrchr(szProfileName, '.');
- if (lstrcmp(pos, _T(".dat")) == 0)
- *pos = 0;
+ TCHAR szFullPath[MAX_PATH];
switch(code) {
case 1:
- mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("%s\\%s\\AvatarCache"), g_profileDir, szProfileName);
+ if (hAvatarFolder == NULL || FoldersGetCustomPathT(hAvatarFolder, szFullPath, SIZEOF(szFullPath), _T("")))
+ mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("%s\\AvatarCache"), g_profileRoot);
break;
case 2:
- mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("%s\\%s\\Logs"), g_profileDir, szProfileName);
+ mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("%s\\Logs"), g_profileRoot);
break;
case 3:
- mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("%s\\%s"), g_profileDir, szProfileName);
+ _tcsncpy_s(szFullPath, SIZEOF(szFullPath), g_profileRoot, _TRUNCATE);
break;
}
return mir_tstrdup(szFullPath);
@@ -394,6 +389,13 @@ static INT_PTR replaceVars(WPARAM wParam, LPARAM lParam) return (INT_PTR)ReplaceVariables<char>((char *)wParam, data);
}
+void InitPathVar()
+{
+ TCHAR szFullPath[MAX_PATH];
+ mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("%s\\AvatarCache"), g_profileRoot);
+ hAvatarFolder = FoldersRegisterCustomPathT( LPGEN("Avatars"), LPGEN("Avatars root folder"), szFullPath);
+}
+
int InitPathUtils(void)
{
CreateServiceFunction(MS_UTILS_PATHTORELATIVE, pathToRelative);
|