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 | |
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
41 files changed, 62 insertions, 278 deletions
diff --git a/plugins/FlashAvatars/src/cflash.cpp b/plugins/FlashAvatars/src/cflash.cpp index 87961b5c0b..e6be9eea82 100644 --- a/plugins/FlashAvatars/src/cflash.cpp +++ b/plugins/FlashAvatars/src/cflash.cpp @@ -169,12 +169,10 @@ static void __cdecl loadFlash_Thread(void *p) { fgd.szPathT = path;
fgd.flags = FF_TCHAR;
if (!hAvatarsFolder || CallService(MS_FOLDERS_GET_PATH, (WPARAM)hAvatarsFolder, (LPARAM)&fgd)) {
- if(ServiceExists(MS_UTILS_REPLACEVARS)) {
- TCHAR *tmpPath = Utils_ReplaceVarsT(_T("%miranda_avatarcache%"));
- mir_sntprintf(path, MAX_PATH, _T("%s\\%s"), tmpPath, _T("Flash"));
- mir_free(tmpPath);
- }
- else PathToAbsoluteT( _T("Flash"), path);
+ if(ServiceExists(MS_UTILS_REPLACEVARS))
+ mir_sntprintf(path, MAX_PATH, _T("%s\\%s"), VARST(_T("%miranda_avatarcache%")), _T("Flash"));
+ else
+ PathToAbsoluteT( _T("Flash"), path);
}
else {
if(_tcslen(path) && path[_tcslen(path)-1]=='\\')
@@ -592,15 +590,7 @@ static int systemModulesLoaded(WPARAM /*wParam*/, LPARAM /*lParam*/) hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nl_user);
TCHAR path[MAX_PATH];
- if (ServiceExists(MS_UTILS_REPLACEVARS))
- { // default Avatar Cache path for MIM 0.8+
- TCHAR *tmpPath = Utils_ReplaceVarsT(_T("%miranda_avatarcache%"));
- mir_sntprintf(path, MAX_PATH, _T("%s\\%s\\"), tmpPath, _T("Flash"));
- mir_free(tmpPath);
- }
- // default for older Mirandas
- else PathToAbsoluteT( _T("Flash\\"), path);
-
+ mir_sntprintf(path, MAX_PATH, _T("%s\\%s\\"), VARST(_T("%miranda_avatarcache%")), _T("Flash"));
hAvatarsFolder = FoldersRegisterCustomPathT(LPGEN("Avatars"), LPGEN("Flash Avatars"), path);
return 0;
}
diff --git a/protocols/AimOscar/src/avatars.cpp b/protocols/AimOscar/src/avatars.cpp index dea8de177e..f0bd5d9480 100644 --- a/protocols/AimOscar/src/avatars.cpp +++ b/protocols/AimOscar/src/avatars.cpp @@ -123,31 +123,9 @@ void CAimProto::avatar_retrieval_handler(const char* sn, const char* hash, const ProtoBroadcastAck(AI.hContact, ACKTYPE_AVATAR, res ? ACKRESULT_SUCCESS : ACKRESULT_FAILED, &AI, 0);
}
-void CAimProto::init_custom_folders(void)
-{
- if (init_cst_fld_ran) return;
-
- TCHAR AvatarsFolder[MAX_PATH];
-
- mir_sntprintf(AvatarsFolder, SIZEOF(AvatarsFolder), _T("%%miranda_avatarcache%%\\%S"), m_szModuleName);
- hAvatarsFolder = FoldersRegisterCustomPathT(LPGEN("Avatars"), m_szModuleName, AvatarsFolder, m_tszUserName);
- init_cst_fld_ran = true;
-}
-
int CAimProto::get_avatar_filename(HANDLE hContact, TCHAR* pszDest, size_t cbLen, const TCHAR *ext)
{
- size_t tPathLen;
- bool found = false;
-
- init_custom_folders();
-
- TCHAR* path = (TCHAR*)alloca(cbLen * sizeof(TCHAR));
- if (hAvatarsFolder == NULL || FoldersGetCustomPathT(hAvatarsFolder, path, (int)cbLen, _T("")))
- tPathLen = mir_sntprintf(pszDest, cbLen, _T("%s\\%S"), (TCHAR*)VARST( _T("%miranda_avatarcache%")), m_szModuleName);
- else {
- _tcscpy(pszDest, path);
- tPathLen = _tcslen(pszDest);
- }
+ int tPathLen = mir_sntprintf(pszDest, cbLen, _T("%s\\%S"), VARST( _T("%miranda_avatarcache%")), m_szModuleName);
if (ext && _taccess(pszDest, 0))
CreateDirectoryTreeT(pszDest);
@@ -159,6 +137,7 @@ int CAimProto::get_avatar_filename(HANDLE hContact, TCHAR* pszDest, size_t cbLen tPathLen += mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T("\\%s"), dbv.ptszVal);
db_free(&dbv);
+ bool found = false;
if (ext == NULL)
{
mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T(".*"));
diff --git a/protocols/AimOscar/src/proto.cpp b/protocols/AimOscar/src/proto.cpp index bdc2568b7b..61f1e8cdf5 100644 --- a/protocols/AimOscar/src/proto.cpp +++ b/protocols/AimOscar/src/proto.cpp @@ -47,7 +47,6 @@ CAimProto::CAimProto(const char* aProtoName, const TCHAR* aUserName) : HookProtoEvent(ME_CLIST_GROUPCHANGE, &CAimProto::OnGroupChange);
HookProtoEvent(ME_OPT_INITIALISE, &CAimProto::OnOptionsInit);
- init_custom_folders();
offline_contacts();
TCHAR descr[MAX_PATH];
diff --git a/protocols/AimOscar/src/proto.h b/protocols/AimOscar/src/proto.h index 9900ff937b..e7460fbe8c 100644 --- a/protocols/AimOscar/src/proto.h +++ b/protocols/AimOscar/src/proto.h @@ -161,13 +161,11 @@ struct CAimProto : public PROTO<CAimProto> unsigned short mail_seqno;
//avatar connection stuff
- bool init_cst_fld_ran;
unsigned short avatar_seqno;
unsigned short avatar_id_sm;
unsigned short avatar_id_lg;
HANDLE hAvatarConn;
HANDLE hAvatarEvent;
- HANDLE hAvatarsFolder;
ft_list_type ft_list;
@@ -218,7 +216,6 @@ struct CAimProto : public PROTO<CAimProto> void avatar_request_handler(HANDLE hContact, char* hash, unsigned char type);
void avatar_retrieval_handler(const char* sn, const char* hash, const char* data, int data_len);
int get_avatar_filename(HANDLE hContact, TCHAR* pszDest, size_t cbLen, const TCHAR *ext);
- void init_custom_folders(void);
//////////////////////////////////////////////////////////////////////////////////////
// away.cpp
diff --git a/protocols/FacebookRM/src/avatars.cpp b/protocols/FacebookRM/src/avatars.cpp index 5540bd1848..16b2218e68 100644 --- a/protocols/FacebookRM/src/avatars.cpp +++ b/protocols/FacebookRM/src/avatars.cpp @@ -133,8 +133,7 @@ void FacebookProto::UpdateAvatarWorker(void *) std::tstring FacebookProto::GetAvatarFolder()
{
TCHAR path[MAX_PATH];
- if (!hAvatarFolder_ || FoldersGetCustomPathT(hAvatarFolder_, path, SIZEOF(path), _T("")))
- mir_sntprintf(path, SIZEOF(path), _T("%s\\%s"), (TCHAR*)VARST(_T("%miranda_avatarcache%")), m_tszUserName);
+ mir_sntprintf(path, SIZEOF(path), _T("%s\\%s"), VARST(_T("%miranda_avatarcache%")), m_tszUserName);
return path;
}
diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp index 4c122c8f99..ceaca0e8e3 100644 --- a/protocols/FacebookRM/src/proto.cpp +++ b/protocols/FacebookRM/src/proto.cpp @@ -73,9 +73,6 @@ FacebookProto::FacebookProto(const char* proto_name,const TCHAR* username) : facy.set_handle(m_hNetlibUser);
- mir_sntprintf(descr, SIZEOF(descr), _T("%%miranda_avatarcache%%\\%s"), m_tszUserName);
- hAvatarFolder_ = FoldersRegisterCustomPathT(LPGEN("Avatars"), m_szModuleName, descr, m_tszUserName);
-
// Set all contacts offline -- in case we crashed
SetAllContactStatuses(ID_STATUS_OFFLINE, true);
}
diff --git a/protocols/FacebookRM/src/proto.h b/protocols/FacebookRM/src/proto.h index 1c934f0a72..857c30c20e 100644 --- a/protocols/FacebookRM/src/proto.h +++ b/protocols/FacebookRM/src/proto.h @@ -227,7 +227,6 @@ public: std::vector<HANDLE> popupClasses;
std::string last_status_msg_;
- HANDLE hAvatarFolder_;
HANDLE hSmileysFolder_;
std::vector<HANDLE> avatar_queue;
diff --git a/protocols/Gadu-Gadu/src/avatar.cpp b/protocols/Gadu-Gadu/src/avatar.cpp index 33418c0fcd..c3e2448567 100644 --- a/protocols/Gadu-Gadu/src/avatar.cpp +++ b/protocols/Gadu-Gadu/src/avatar.cpp @@ -28,15 +28,7 @@ void GGPROTO::getAvatarFilename(HANDLE hContact, TCHAR *pszDest, int cbLen)
{
- int tPathLen;
- TCHAR *path = (TCHAR*)alloca(cbLen * sizeof(TCHAR));
-
- if (hAvatarsFolder == NULL || FoldersGetCustomPathT(hAvatarsFolder, path, cbLen, _T("")))
- tPathLen = mir_sntprintf(pszDest, cbLen, _T("%s\\%S"), VARST( _T("%miranda_avatarcache%")), m_szModuleName);
- else {
- _tcscpy(pszDest, path);
- tPathLen = (int)_tcslen(pszDest);
- }
+ int tPathLen = mir_sntprintf(pszDest, cbLen, _T("%s\\%S"), VARST( _T("%miranda_avatarcache%")), m_szModuleName);
if (_taccess(pszDest, 0)) {
int ret = CreateDirectoryTreeT(pszDest);
diff --git a/protocols/Gadu-Gadu/src/gg.cpp b/protocols/Gadu-Gadu/src/gg.cpp index e10057af73..932d3410a1 100644 --- a/protocols/Gadu-Gadu/src/gg.cpp +++ b/protocols/Gadu-Gadu/src/gg.cpp @@ -147,20 +147,16 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_PROTOCO void GGPROTO::cleanuplastplugin(DWORD version)
{
-
// Store current plugin version
setDword(GG_PLUGINVERSION, pluginInfo.version);
-
//1. clean files: %miranda_avatarcache%\GG\*.(null)
if (version < PLUGIN_MAKE_VERSION(0, 11, 0, 2)){
netlog("cleanuplastplugin() 1: version=%d Cleaning junk avatar files from < 0.11.0.2", version);
TCHAR avatarsPath[MAX_PATH];
- if (hAvatarsFolder == NULL || FoldersGetCustomPathT(hAvatarsFolder, avatarsPath, MAX_PATH, _T(""))) {
- ptrT tmpPath( Utils_ReplaceVarsT( _T("%miranda_avatarcache%")));
- mir_sntprintf(avatarsPath, MAX_PATH, _T("%s\\%s"), (TCHAR*)tmpPath, m_tszUserName);
- }
+ mir_sntprintf(avatarsPath, MAX_PATH, _T("%s\\%s"), VARST( _T("%miranda_avatarcache%")), m_tszUserName);
+
netlog("cleanuplastplugin() 1: miranda_avatarcache = %S", avatarsPath);
if (avatarsPath != NULL){
diff --git a/protocols/Gadu-Gadu/src/gg_proto.cpp b/protocols/Gadu-Gadu/src/gg_proto.cpp index 991b30ee5f..d8dabc0b56 100644 --- a/protocols/Gadu-Gadu/src/gg_proto.cpp +++ b/protocols/Gadu-Gadu/src/gg_proto.cpp @@ -69,9 +69,6 @@ GGPROTO::GGPROTO(const char* pszProtoName, const TCHAR* tszUserName) : db_set_resident(m_szModuleName, GG_KEY_AVATARREQUESTED);
TCHAR szPath[MAX_PATH];
- mir_sntprintf(szPath, MAX_PATH, _T("%s\\%s"), (TCHAR*)VARST( _T("%miranda_avatarcache%")), m_tszUserName);
- hAvatarsFolder = FoldersRegisterCustomPathT(LPGEN("Avatars"), m_szModuleName, szPath, m_tszUserName);
-
mir_sntprintf(szPath, MAX_PATH, _T("%s\\%s\\ImageCache"), (TCHAR*)VARST( _T("%miranda_userdata%")), m_tszUserName);
hImagesFolder = FoldersRegisterCustomPathT(LPGEN("Images"), m_szModuleName, szPath, m_tszUserName);
diff --git a/protocols/Gadu-Gadu/src/gg_proto.h b/protocols/Gadu-Gadu/src/gg_proto.h index f10435168d..1f91546bce 100644 --- a/protocols/Gadu-Gadu/src/gg_proto.h +++ b/protocols/Gadu-Gadu/src/gg_proto.h @@ -267,7 +267,6 @@ struct GGPROTO : public PROTO<GGPROTO> HGENMENU hMainMenu[7];
HGENMENU hBlockMenuItem, hImageMenuItem, hInstanceMenuItem;
HANDLE hPrebuildMenuHook;
- HANDLE hAvatarsFolder;
HANDLE hImagesFolder;
HWND hwndSessionsDlg;
HANDLE hPopupNotify, hPopupError;
diff --git a/protocols/IcqOscarJ/src/icq_avatar.cpp b/protocols/IcqOscarJ/src/icq_avatar.cpp index 07dd17fc0f..b50330a1b9 100644 --- a/protocols/IcqOscarJ/src/icq_avatar.cpp +++ b/protocols/IcqOscarJ/src/icq_avatar.cpp @@ -83,20 +83,6 @@ avatars_request* CIcqProto::ReleaseAvatarRequestInQueue(avatars_request *request }
-void CIcqProto::InitAvatars()
-{
- if (bAvatarsFolderInited)
- return;
-
- bAvatarsFolderInited = TRUE;
-
- // check if it does make sense
- TCHAR tszPath[MAX_PATH * 2];
- mir_sntprintf(tszPath, MAX_PATH * 2, _T("%%miranda_avatarcache%%\\%S"), m_szModuleName);
- hAvatarsFolder = FoldersRegisterCustomPathT(LPGEN("Avatars"), m_szModuleName, tszPath, m_tszUserName);
-}
-
-
TCHAR* CIcqProto::GetOwnAvatarFileName()
{
DBVARIANT dbvFile = {DBVT_DELETED};
@@ -123,22 +109,13 @@ void CIcqProto::GetFullAvatarFileName(int dwUin, const char *szUid, int dwFormat void CIcqProto::GetAvatarFileName(int dwUin, const char *szUid, TCHAR *pszDest, int cbLen)
{
TCHAR szPath[MAX_PATH * 2];
- FOLDERSGETDATA fgd = {0};
-
- InitAvatars();
+ mir_sntprintf(szPath, MAX_PATH * 2, _T("%s\\%S\\"), VARST(_T("%miranda_avatarcache%")), m_szModuleName);
+ FOLDERSGETDATA fgd = {0};
fgd.cbSize = sizeof(FOLDERSGETDATA);
fgd.nMaxPathSize = MAX_PATH * 2;
fgd.szPathT = szPath;
fgd.flags = FF_TCHAR;
- if (CallService(MS_FOLDERS_GET_PATH, (WPARAM)hAvatarsFolder, (LPARAM)&fgd))
- {
- TCHAR *tmpPath = Utils_ReplaceVarsT(_T("%miranda_avatarcache%"));
- mir_sntprintf(szPath, MAX_PATH * 2, _T("%s\\%S\\"), tmpPath, m_szModuleName);
- mir_free(tmpPath);
- }
- else
- _tcscat(szPath, _T("\\"));
// fill the destination
lstrcpyn(pszDest, szPath, cbLen - 1);
diff --git a/protocols/IcqOscarJ/src/icq_proto.cpp b/protocols/IcqOscarJ/src/icq_proto.cpp index 7a283eff23..42f6c95d75 100644 --- a/protocols/IcqOscarJ/src/icq_proto.cpp +++ b/protocols/IcqOscarJ/src/icq_proto.cpp @@ -289,8 +289,6 @@ int CIcqProto::OnModulesLoaded( WPARAM wParam, LPARAM lParam ) HookProtoEvent(ME_USERINFO_INITIALISE, &CIcqProto::OnUserInfoInit);
HookProtoEvent(ME_IDLE_CHANGED, &CIcqProto::OnIdleChanged);
- InitAvatars();
-
// Init extra optional modules
ModuleLoad(0, 0);
InitXStatusItems(FALSE);
diff --git a/protocols/IcqOscarJ/src/icq_proto.h b/protocols/IcqOscarJ/src/icq_proto.h index 31f6047af3..9d392110cc 100644 --- a/protocols/IcqOscarJ/src/icq_proto.h +++ b/protocols/IcqOscarJ/src/icq_proto.h @@ -393,16 +393,12 @@ struct CIcqProto : public PROTO<CIcqProto> BOOL m_avatarsConnectionPending;
avatars_server_connection *m_avatarsConnection;
- int bAvatarsFolderInited;
- HANDLE hAvatarsFolder;
-
void requestAvatarConnection();
void __cdecl AvatarThread(avatars_server_connection *pInfo);
void handleAvatarOwnerHash(WORD wItemID, BYTE bFlags, BYTE *pData, BYTE nDataLen);
void handleAvatarContactHash(DWORD dwUIN, char *szUID, HANDLE hContact, BYTE *pHash, int nHashLen, WORD wOldStatus);
- void InitAvatars();
avatars_request *ReleaseAvatarRequestInQueue(avatars_request *request);
TCHAR* GetOwnAvatarFileName();
diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp index 4a94d5fd70..1a50b27e70 100644 --- a/protocols/JabberG/src/jabber_misc.cpp +++ b/protocols/JabberG/src/jabber_misc.cpp @@ -178,28 +178,9 @@ BOOL CJabberProto::AddDbPresenceEvent(HANDLE hContact, BYTE btEventType) ///////////////////////////////////////////////////////////////////////////////
// JabberGetAvatarFileName() - gets a file name for the avatar image
-void CJabberProto::InitCustomFolders(void)
-{
- if (m_bFoldersInitDone)
- return;
-
- m_bFoldersInitDone = true;
- TCHAR AvatarsFolder[MAX_PATH];
- mir_sntprintf(AvatarsFolder, SIZEOF(AvatarsFolder), _T("%%miranda_avatarcache%%\\%S"), m_szModuleName);
- m_hJabberAvatarsFolder = FoldersRegisterCustomPathT(LPGEN("Avatars"), m_szModuleName, AvatarsFolder, m_tszUserName);
-}
-
void CJabberProto::GetAvatarFileName(HANDLE hContact, TCHAR* pszDest, size_t cbLen)
{
- size_t tPathLen;
- TCHAR *path = (TCHAR*)alloca(cbLen * sizeof(TCHAR));
-
- InitCustomFolders();
-
- if (m_hJabberAvatarsFolder == NULL || FoldersGetCustomPathT(m_hJabberAvatarsFolder, path, (int)cbLen, _T("")))
- tPathLen = mir_sntprintf(pszDest, cbLen, _T("%s\\%S"), (TCHAR*)VARST(_T("%miranda_avatarcache%")), m_szModuleName);
- else
- tPathLen = mir_sntprintf(pszDest, cbLen, _T("%s"), path);
+ int tPathLen = mir_sntprintf(pszDest, cbLen, _T("%s\\%S"), VARST(_T("%miranda_avatarcache%")), m_szModuleName);
DWORD dwAttributes = GetFileAttributes(pszDest);
if (dwAttributes == 0xffffffff || (dwAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index 11524d4b56..f1004adeda 100644 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -140,7 +140,6 @@ CJabberProto::CJabberProto(const char *aProtoName, const TCHAR *aUserName) : GlobalMenuInit();
WsInit();
ConsoleInit();
- InitCustomFolders();
m_pepServices.insert(new CPepMood(this));
m_pepServices.insert(new CPepActivity(this));
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index 5ddaf38618..9f60bc998b 100644 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -612,7 +612,6 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface void UpdateMirVer(HANDLE hContact, pResourceStatus &resource);
void UpdateSubscriptionInfo(HANDLE hContact, JABBER_LIST_ITEM *item);
void SetContactOfflineStatus(HANDLE hContact);
- void InitCustomFolders(void);
void InitPopups(void);
void MsgPopup(HANDLE hContact, const TCHAR *szMsg, const TCHAR *szTitle);
@@ -849,9 +848,6 @@ private: HANDLE m_hPopupClass;
- HANDLE m_hJabberAvatarsFolder;
- BOOL m_bFoldersInitDone;
-
LONG m_nSerial;
HGENMENU m_hPrivacyMenuRoot;
diff --git a/protocols/MRA/src/MraAvatars.cpp b/protocols/MRA/src/MraAvatars.cpp index bef9b87180..f4a22c4d06 100644 --- a/protocols/MRA/src/MraAvatars.cpp +++ b/protocols/MRA/src/MraAvatars.cpp @@ -24,7 +24,6 @@ struct MRA_AVATARS_QUEUE : public FIFO_MT int iThreadsCount;
HANDLE hThread[MAXIMUM_WAIT_OBJECTS];
LONG lThreadsRunningCount;
- HANDLE hAvatarsPath;
};
struct MRA_AVATARS_QUEUE_ITEM : public FIFO_MT_ITEM
@@ -68,17 +67,12 @@ DWORD CMraProto::MraAvatarsQueueInitialize(HANDLE *phAvatarsQueueHandle) char szBuffer[MAX_PATH];
mir_snprintf(szBuffer, SIZEOF(szBuffer), "%s %s", m_szModuleName, Translate("Avatars' plugin connections"));
- NETLIBUSER nlu = {0};
- nlu.cbSize = sizeof(nlu);
+ NETLIBUSER nlu = { sizeof(nlu) };
nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS;
nlu.szSettingsModule = MRA_AVT_SECT_NAME;
nlu.szDescriptiveName = szBuffer;
pmraaqAvatarsQueue->m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
if (pmraaqAvatarsQueue->m_hNetlibUser) {
- TCHAR tszPath[ MAX_PATH ];
- mir_sntprintf( tszPath, SIZEOF(tszPath), _T("%%miranda_avatarcache%%\\%s"), m_tszUserName);
- pmraaqAvatarsQueue->hAvatarsPath = FoldersRegisterCustomPathT(LPGEN("Avatars"), m_szModuleName, tszPath, m_tszUserName);
-
InterlockedExchange((volatile LONG*)&pmraaqAvatarsQueue->bIsRunning, TRUE);
pmraaqAvatarsQueue->hThreadEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
pmraaqAvatarsQueue->iThreadsCount = db_get_dw(NULL, MRA_AVT_SECT_NAME, "WorkThreadsCount", MRA_AVT_DEFAULT_WRK_THREAD_COUNTS);
@@ -504,13 +498,7 @@ DWORD CMraProto::MraAvatarsGetFileName(HANDLE hAvatarsQueueHandle, HANDLE hConta MRA_AVATARS_QUEUE *pmraaqAvatarsQueue = (MRA_AVATARS_QUEUE*)hAvatarsQueueHandle;
TCHAR tszBase[MAX_PATH];
- if (pmraaqAvatarsQueue->hAvatarsPath == NULL)
- // default path
- mir_sntprintf(tszBase, MAX_PATH, _T("%s\\%s\\"), VARST( _T("%miranda_avatarcache%")), m_tszUserName);
- else {
- FoldersGetCustomPathT(pmraaqAvatarsQueue->hAvatarsPath, tszBase, MAX_PATH, _T(""));
- _tcsncat(tszBase, _T("\\"), MAX_PATH);
- }
+ mir_sntprintf(tszBase, SIZEOF(tszBase), _T("%s\\%s\\"), VARST( _T("%miranda_avatarcache%")), m_tszUserName);
res = tszBase;
// some path in buff and free space for file name is avaible
diff --git a/protocols/MSN/src/msn_misc.cpp b/protocols/MSN/src/msn_misc.cpp index 072cb70951..96c5e236e0 100644 --- a/protocols/MSN/src/msn_misc.cpp +++ b/protocols/MSN/src/msn_misc.cpp @@ -139,15 +139,9 @@ void CMsnProto::InitCustomFolders(void) if (InitCstFldRan) return;
TCHAR folder[MAX_PATH];
- TCHAR *tszModuleName = mir_a2t(m_szModuleName);
-
- mir_sntprintf(folder, SIZEOF(folder), _T("%%miranda_avatarcache%%\\%s"), tszModuleName);
- hMSNAvatarsFolder = FoldersRegisterCustomPathT(LPGEN("Avatars"), m_szModuleName, folder, m_tszUserName);
-
- mir_sntprintf(folder, SIZEOF(folder), _T("%%miranda_avatarcache%%\\%s"), tszModuleName);
+ mir_sntprintf(folder, SIZEOF(folder), _T("%%miranda_avatarcache%%\\%S"), m_szModuleName);
hCustomSmileyFolder = FoldersRegisterCustomPathT(LPGEN("Custom Smileys"), m_szModuleName, folder, m_tszUserName);
- mir_free(tszModuleName);
InitCstFldRan = true;
}
@@ -199,22 +193,7 @@ char* MSN_GetAvatarHash(char* szContext, char** pszUrl) void CMsnProto::MSN_GetAvatarFileName(HANDLE hContact, TCHAR* pszDest, size_t cbLen, const TCHAR *ext)
{
- size_t tPathLen;
-
- InitCustomFolders();
-
- TCHAR* path = (TCHAR*)alloca(cbLen * sizeof(TCHAR));
- if (hMSNAvatarsFolder == NULL || FoldersGetCustomPathT(hMSNAvatarsFolder, path, (int)cbLen, _T(""))) {
- TCHAR *tmpPath = Utils_ReplaceVarsT(_T("%miranda_userdata%"));
- TCHAR *sztModuleName = mir_a2t(m_szModuleName);
- tPathLen = mir_sntprintf(pszDest, cbLen, _T("%s\\AvatarCache\\%s"), tmpPath, sztModuleName);
- mir_free(sztModuleName);
- mir_free(tmpPath);
- }
- else {
- _tcscpy(pszDest, path);
- tPathLen = _tcslen(pszDest);
- }
+ size_t tPathLen = mir_sntprintf(pszDest, cbLen, _T("%s\\%S"), VARST(_T("%miranda_avatarcache%")), m_szModuleName);
if (_taccess(pszDest, 0))
CreateDirectoryTreeT(pszDest);
diff --git a/protocols/MSN/src/msn_proto.h b/protocols/MSN/src/msn_proto.h index 03daa11483..eef0a1313e 100644 --- a/protocols/MSN/src/msn_proto.h +++ b/protocols/MSN/src/msn_proto.h @@ -184,7 +184,6 @@ struct CMsnProto : public PROTO<CMsnProto> HANDLE hMSNNudge;
HANDLE hPopupError, hPopupHotmail, hPopupNotify;
- HANDLE hMSNAvatarsFolder;
HANDLE hCustomSmileyFolder;
bool InitCstFldRan;
bool isConnectSuccess;
diff --git a/protocols/Skype/src/skype_avatars.cpp b/protocols/Skype/src/skype_avatars.cpp index 24c44299fc..0c3be45a88 100644 --- a/protocols/Skype/src/skype_avatars.cpp +++ b/protocols/Skype/src/skype_avatars.cpp @@ -23,15 +23,8 @@ bool CSkypeProto::IsAvatarChanged(const SEBinary &avatar, HANDLE hContact) wchar_t * CSkypeProto::GetContactAvatarFilePath(HANDLE hContact)
{
- wchar_t *path = (wchar_t*)::mir_alloc(MAX_PATH * sizeof(wchar_t));
-
- this->InitCustomFolders();
-
- if (m_hAvatarsFolder == NULL || FoldersGetCustomPathT(m_hAvatarsFolder, path, MAX_PATH, _T("")))
- {
- ptrW tmpPath( ::Utils_ReplaceVarsT(L"%miranda_avatarcache%"));
- ::mir_sntprintf(path, MAX_PATH, _T("%s\\%S"), tmpPath, this->m_szModuleName);
- }
+ TCHAR path[MAX_PATH];
+ ::mir_sntprintf(path, SIZEOF(path), _T("%s\\%S"), VARST(_T("%miranda_avatarcache%")), this->m_szModuleName);
DWORD dwAttributes = GetFileAttributes(path);
if (dwAttributes == 0xffffffff || (dwAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
@@ -43,12 +36,9 @@ wchar_t * CSkypeProto::GetContactAvatarFilePath(HANDLE hContact) else if (sid != NULL)
::mir_sntprintf(path, MAX_PATH, _T("%s\\%s avatar.jpg"), path, sid);
else
- {
- ::mir_free(path);
return NULL;
- }
- return path;
+ return mir_wstrdup(path);
}
INT_PTR __cdecl CSkypeProto::GetAvatarInfo(WPARAM, LPARAM lParam)
diff --git a/protocols/Skype/src/skype_events.cpp b/protocols/Skype/src/skype_events.cpp index a42e1ea31d..e86de2e396 100644 --- a/protocols/Skype/src/skype_events.cpp +++ b/protocols/Skype/src/skype_events.cpp @@ -15,7 +15,6 @@ int CSkypeProto::OnProtoModulesLoaded(WPARAM, LPARAM) {
this->InitNetLib();
this->InitChatModule();
- this->InitCustomFolders();
this->InitInstanceHookList();
if (::ServiceExists(MS_BB_ADDBUTTON))
diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h index 2b5f7998b2..186cf34ea3 100644 --- a/protocols/Skype/src/skype_proto.h +++ b/protocols/Skype/src/skype_proto.h @@ -447,11 +447,6 @@ protected: // utils
static wchar_t* ValidationReasons[];
- void InitCustomFolders();
-
- HANDLE m_hAvatarsFolder;
- bool m_bInitDone;
-
static int SkypeToMirandaLoginError(CAccount::LOGOUTREASON logoutReason);
static char *RemoveHtml(const char *data);
diff --git a/protocols/Skype/src/skype_utils.cpp b/protocols/Skype/src/skype_utils.cpp index 82fd39404c..27be882ada 100644 --- a/protocols/Skype/src/skype_utils.cpp +++ b/protocols/Skype/src/skype_utils.cpp @@ -239,18 +239,6 @@ void CSkypeProto::InitLanguages() result[L"yo"] = L"Yoruba";
result[L"za"] = L"Zhuang";
result[L"zu"] = L"Zulu";
- }
-
-void CSkypeProto::InitCustomFolders()
-{
- if (m_bInitDone)
- return;
-
- m_bInitDone = true;
-
- TCHAR AvatarsFolder[MAX_PATH];
- ::mir_sntprintf(AvatarsFolder, SIZEOF(AvatarsFolder), _T("%%miranda_avatarcache%%\\%S"), this->m_szModuleName);
- m_hAvatarsFolder = ::FoldersRegisterCustomPathT(LPGEN("Avatars"), m_szModuleName, AvatarsFolder, m_tszUserName);
}
// ---
diff --git a/protocols/Tlen/src/tlen_avatar.cpp b/protocols/Tlen/src/tlen_avatar.cpp index 2fd8436226..478ae81e92 100644 --- a/protocols/Tlen/src/tlen_avatar.cpp +++ b/protocols/Tlen/src/tlen_avatar.cpp @@ -34,9 +34,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void TlenGetAvatarFileName(TlenProtocol *proto, TLEN_LIST_ITEM *item, TCHAR* ptszDest, int cbLen)
{
int format = PA_FORMAT_PNG;
- TCHAR* tmpPath = Utils_ReplaceVarsT( TEXT("%miranda_avatarcache%") );
- int tPathLen = mir_sntprintf(ptszDest, cbLen, TEXT("%s\\Tlen"), tmpPath );
- mir_free(tmpPath);
+ int tPathLen = mir_sntprintf(ptszDest, cbLen, TEXT("%s\\Tlen"), VARST( TEXT("%miranda_avatarcache%")));
DWORD dwAttributes = GetFileAttributes( ptszDest );
if (dwAttributes == 0xffffffff || ( dwAttributes & FILE_ATTRIBUTE_DIRECTORY ) == 0)
CreateDirectoryTreeT(ptszDest);
diff --git a/protocols/Twitter/src/proto.cpp b/protocols/Twitter/src/proto.cpp index f60e2c1d82..c4279e6bf8 100644 --- a/protocols/Twitter/src/proto.cpp +++ b/protocols/Twitter/src/proto.cpp @@ -48,9 +48,6 @@ TwitterProto::TwitterProto(const char *proto_name,const TCHAR *username) : HookProtoEvent(ME_CLIST_PREBUILDSTATUSMENU, &TwitterProto::OnBuildStatusMenu);
HookProtoEvent(ME_OPT_INITIALISE, &TwitterProto::OnOptionsInit);
- tstring defFolder = std::tstring( _T("%miranda_avatarcache%\\")) + m_tszUserName;
- hAvatarFolder_ = FoldersRegisterCustomPathT(LPGEN("Avatars"), m_szModuleName, defFolder.c_str(), m_tszUserName);
-
// Initialize hotkeys
char text[512];
mir_snprintf(text,SIZEOF(text),"%s/Tweet",m_szModuleName);
@@ -510,8 +507,7 @@ void TwitterProto::UpdateSettings() std::tstring TwitterProto::GetAvatarFolder()
{
TCHAR path[MAX_PATH];
- if (!hAvatarFolder_ || FoldersGetCustomPathT(hAvatarFolder_, path, SIZEOF(path), _T("")))
- mir_sntprintf(path, SIZEOF(path), _T("%s\\%s"), (TCHAR*)VARST( _T("%miranda_avatarcache%")), m_tszUserName);
+ mir_sntprintf(path, SIZEOF(path), _T("%s\\%s"), VARST( _T("%miranda_avatarcache%")), m_tszUserName);
return path;
}
diff --git a/protocols/Twitter/src/proto.h b/protocols/Twitter/src/proto.h index 1bae62f510..71b22cd3ea 100644 --- a/protocols/Twitter/src/proto.h +++ b/protocols/Twitter/src/proto.h @@ -160,8 +160,6 @@ private: twitter_id since_id_;
twitter_id dm_since_id_;
- HANDLE hAvatarFolder_;
-
bool in_chat_;
int disconnectionCount;
diff --git a/protocols/VKontakte/src/vk_avatars.cpp b/protocols/VKontakte/src/vk_avatars.cpp index 17a43318dc..b2b6ef7fb8 100644 --- a/protocols/VKontakte/src/vk_avatars.cpp +++ b/protocols/VKontakte/src/vk_avatars.cpp @@ -93,13 +93,7 @@ INT_PTR CVkProto::SvcGetAvatarInfo(WPARAM wParam, LPARAM lParam) void CVkProto::GetAvatarFileName(HANDLE hContact, TCHAR* pszDest, size_t cbLen)
{
- size_t tPathLen;
- TCHAR *path = (TCHAR*)_alloca(cbLen * sizeof(TCHAR));
-
- if (m_hAvatarFolder == NULL || FoldersGetCustomPathT(m_hAvatarFolder, path, (int)cbLen, _T("")))
- tPathLen = mir_sntprintf(pszDest, cbLen, _T("%s\\%S"), (TCHAR*)VARST(_T("%miranda_avatarcache%")), m_szModuleName);
- else
- tPathLen = mir_sntprintf(pszDest, cbLen, _T("%s"), path);
+ int tPathLen = mir_sntprintf(pszDest, cbLen, _T("%s\\%S"), VARST(_T("%miranda_avatarcache%")), m_szModuleName);
DWORD dwAttributes = GetFileAttributes(pszDest);
if (dwAttributes == 0xffffffff || (dwAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index eebd495e3b..c544fbd5f1 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -37,9 +37,6 @@ CVkProto::CVkProto(const char *szModuleName, const TCHAR *ptszUserName) : nlu.ptszDescriptiveName = descr;
m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
- mir_sntprintf(descr, SIZEOF(descr), _T("%%miranda_avatarcache%%\\%s"), m_tszUserName);
- m_hAvatarFolder = FoldersRegisterCustomPathT(LPGEN("Avatars"), m_szModuleName, descr, m_tszUserName);
-
m_defaultGroup = getTStringA("ProtoGroup");
if (m_defaultGroup == NULL)
m_defaultGroup = mir_tstrdup( TranslateT("VKontakte"));
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 7efe705fa8..d6a6a3259e 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -145,7 +145,6 @@ private: bool m_bOnline;
HANDLE m_hNetlibUser, m_hNetlibConn;
- HANDLE m_hAvatarFolder;
ptrA m_szAccessToken, m_myUserId;
ptrT m_defaultGroup;
UINT_PTR m_timer;
diff --git a/protocols/WhatsApp/src/proto.cpp b/protocols/WhatsApp/src/proto.cpp index a3bc4bd041..b362c7a059 100644 --- a/protocols/WhatsApp/src/proto.cpp +++ b/protocols/WhatsApp/src/proto.cpp @@ -34,10 +34,7 @@ WhatsAppProto::WhatsAppProto(const char* proto_name, const TCHAR* username) : WASocketConnection::initNetwork(m_hNetlibUser);
- TCHAR *profile = Utils_ReplaceVarsT( _T("%miranda_avatarcache%"));
- def_avatar_folder_ = std::tstring(profile) + _T("\\") + m_tszUserName;
- mir_free(profile);
- hAvatarFolder_ = FoldersRegisterCustomPathT(m_szModuleName, "Avatars", def_avatar_folder_.c_str());
+ def_avatar_folder_ = std::tstring( VARST( _T("%miranda_avatarcache%"))) + _T("\\") + m_tszUserName;
// Register group chat
GCREGISTER gcr = {0};
@@ -316,11 +313,7 @@ int WhatsAppProto::RequestFriendship(WPARAM wParam, LPARAM lParam) std::tstring WhatsAppProto::GetAvatarFolder()
{
- TCHAR path[MAX_PATH];
- if ( hAvatarFolder_ && FoldersGetCustomPathT(hAvatarFolder_, path, SIZEOF(path), _T("")) == 0 )
- return path;
- else
- return def_avatar_folder_;
+ return def_avatar_folder_;
}
int WhatsAppProto::Log(const char* fn, const char *fmt,...)
diff --git a/protocols/WhatsApp/src/proto.h b/protocols/WhatsApp/src/proto.h index 778db45ccf..a2be9e9e5a 100644 --- a/protocols/WhatsApp/src/proto.h +++ b/protocols/WhatsApp/src/proto.h @@ -151,7 +151,6 @@ public: HANDLE update_loop_lock_;
std::tstring def_avatar_folder_;
- HANDLE hAvatarFolder_;
HANDLE m_hNetlibUser;
WASocketConnection* conn;
diff --git a/protocols/Yahoo/src/avatar.cpp b/protocols/Yahoo/src/avatar.cpp index adb05e8e08..2e3c71cacf 100644 --- a/protocols/Yahoo/src/avatar.cpp +++ b/protocols/Yahoo/src/avatar.cpp @@ -607,34 +607,9 @@ void CYahooProto::request_avatar(const char* who) else LOG(("Avatar Not Available for: %s Last Check: %ld Current: %ld (Flood Check in Effect)", who, last_chk, cur_time));
}
-void CYahooProto::InitCustomFolders(void)
-{
- if (InitCstFldRan)
- return;
-
- InitCstFldRan = true;
-
- TCHAR AvatarsFolder[MAX_PATH];
- mir_sntprintf(AvatarsFolder, MAX_PATH, _T("%%miranda_avatarcache%%\\%S"), m_szModuleName);
- hYahooAvatarsFolder = FoldersRegisterCustomPathT(LPGEN("Avatars"), m_szModuleName, AvatarsFolder, m_tszUserName);
-}
-
void CYahooProto::GetAvatarFileName(HANDLE hContact, TCHAR* pszDest, int cbLen, int type)
{
- size_t tPathLen;
-
- InitCustomFolders();
-
- TCHAR* path = ( TCHAR* )alloca( sizeof(TCHAR)*( cbLen+1 ));
- if ( hYahooAvatarsFolder != NULL && !FoldersGetCustomPathT( hYahooAvatarsFolder, path, (int)cbLen, _T("")))
- {
- _tcscpy( pszDest, path );
- tPathLen = _tcslen( pszDest );
- } else {
- TCHAR *tmpPath = Utils_ReplaceVarsT( _T("%miranda_avatarcache%"));
- tPathLen = mir_sntprintf(pszDest, cbLen, _T("%s\\%S"), tmpPath, m_szModuleName);
- mir_free(tmpPath);
- }
+ int tPathLen = mir_sntprintf(pszDest, cbLen, _T("%s\\%S"), VARST( _T("%miranda_avatarcache%")), m_szModuleName);
if ( _taccess(pszDest, 0))
CreateDirectoryTreeT(pszDest);
diff --git a/protocols/Yahoo/src/proto.cpp b/protocols/Yahoo/src/proto.cpp index 4bf27e2cbf..4769e91e22 100644 --- a/protocols/Yahoo/src/proto.cpp +++ b/protocols/Yahoo/src/proto.cpp @@ -39,7 +39,6 @@ CYahooProto::CYahooProto( const char* aProtoName, const TCHAR* aUserName ) : LoadYahooServices();
IconsInit();
- InitCustomFolders();
}
CYahooProto::~CYahooProto()
diff --git a/protocols/Yahoo/src/proto.h b/protocols/Yahoo/src/proto.h index ea358abdbd..4124737890 100644 --- a/protocols/Yahoo/src/proto.h +++ b/protocols/Yahoo/src/proto.h @@ -298,10 +298,6 @@ private: HGENMENU mainMenuRoot;
HGENMENU hShowProfileMenuItem;
HGENMENU menuItemsAll[ 8 ];
-
- HANDLE hYahooAvatarsFolder;
- bool InitCstFldRan;
- void InitCustomFolders(void);
};
extern LIST<CYahooProto> g_instances;
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);
|