summaryrefslogtreecommitdiff
path: root/protocols/YAMN/main.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-08-10 19:43:29 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-08-10 19:43:29 +0000
commit96d3def2839a417ea2f7a5a5965c0fcade059f29 (patch)
tree23a3c43c61992d2a7cdaf6e00f4f4385c35c7570 /protocols/YAMN/main.cpp
parent0996744b4778f4004f6cca94f9cea38b8879a23b (diff)
added YAMN books migration inside the profile's folder
git-svn-id: http://svn.miranda-ng.org/main/trunk@1434 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/YAMN/main.cpp')
-rw-r--r--protocols/YAMN/main.cpp49
1 files changed, 24 insertions, 25 deletions
diff --git a/protocols/YAMN/main.cpp b/protocols/YAMN/main.cpp
index a24a681481..da9e0a1f53 100644
--- a/protocols/YAMN/main.cpp
+++ b/protocols/YAMN/main.cpp
@@ -119,25 +119,25 @@ int FreeVSApi()
static void GetProfileDirectory(TCHAR *szPath, int cbPath)
//This is copied from Miranda's sources. In 0.2.1.0 it is needed, in newer vesions of Miranda use MS_DB_GETPROFILEPATH service
{
- if (ServiceExists(MS_DB_GETPROFILEPATH))
- if (!CallService(MS_DB_GETPROFILEPATHT, (WPARAM)cbPath, (LPARAM)szPath)) {
- lstrcpy(szProfileDir, szPath);
- return; //success
- }
-
- TCHAR szMirandaIni[MAX_PATH], szExpandedProfileDir[MAX_PATH];
- DWORD dwAttributes;
-
- lstrcpy(szMirandaIni, szMirandaDir);
- lstrcat(szMirandaIni, _T("\\mirandaboot.ini"));
- GetPrivateProfileString( _T("Database"), _T("ProfileDir"), _T("."), szProfileDir, sizeof(szProfileDir), szMirandaIni);
- ExpandEnvironmentStrings(szProfileDir, szExpandedProfileDir, sizeof(szExpandedProfileDir));
- _tchdir(szMirandaDir);
- if (!_tfullpath(szPath, szExpandedProfileDir, cbPath))
- lstrcpyn(szPath, szMirandaDir, cbPath);
- if (szPath[lstrlen(szPath)-1] == '\\') szPath[lstrlen(szPath)-1] = '\0';
- if ((dwAttributes = GetFileAttributes(szPath))!=0xffffffff&&dwAttributes&FILE_ATTRIBUTE_DIRECTORY) return;
- CreateDirectory(szPath, NULL);
+ TCHAR tszOldPath[MAX_PATH];
+ CallService(MS_DB_GETPROFILEPATHT, SIZEOF(tszOldPath), (LPARAM)tszOldPath);
+ _tcscat(tszOldPath, _T("\\*.book"));
+
+ TCHAR* ptszNewPath = Utils_ReplaceVarsT( _T("%miranda_userdata%"));
+
+ SHFILEOPSTRUCT file_op = {
+ NULL,
+ FO_MOVE,
+ tszOldPath,
+ ptszNewPath,
+ FOF_NOERRORUI | FOF_NOCONFIRMATION | FOF_SILENT,
+ false,
+ 0,
+ _T("") };
+ SHFileOperation(&file_op);
+
+ _tcsncpy(szPath, ptszNewPath, cbPath);
+ mir_free(ptszNewPath);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -374,8 +374,6 @@ static void LoadPlugins()
extern "C" int __declspec(dllexport) Load(void)
{
int i, k;
-
-
mir_getLP(&pluginInfo);
YAMN_STATUS = ID_STATUS_OFFLINE;
@@ -389,6 +387,11 @@ extern "C" int __declspec(dllexport) Load(void)
if (str2!=NULL) *str2 = 0;
}
+ // retrieve the current profile name
+ CallService(MS_DB_GETPROFILENAMET, (WPARAM)SIZEOF(ProfileName), (LPARAM)ProfileName); //not to pass entire array to fcn
+ TCHAR *fc = _tcsrchr(ProfileName, '.');
+ if ( fc != NULL ) *fc = 0;
+
// we get the user path where our yamn-account.book.ini is stored from mirandaboot.ini file
GetProfileDirectory(UserDirectory, SIZEOF(UserDirectory));
@@ -408,10 +411,6 @@ extern "C" int __declspec(dllexport) Load(void)
pd.type = PROTOTYPE_PROTOCOL;
CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd);
- CallService(MS_DB_GETPROFILENAMET, (WPARAM)SIZEOF(ProfileName), (LPARAM)ProfileName); //not to pass entire array to fcn
- TCHAR *fc = _tcsrchr(ProfileName, '.');
- if ( fc != NULL ) *fc = 0;
-
InitializeCriticalSection(&AccountStatusCS);
InitializeCriticalSection(&FileWritingCS);
InitializeCriticalSection(&PluginRegCS);