diff options
-rw-r--r-- | plugins/ExternalAPI/m_smileyadd.h | 6 | ||||
-rw-r--r-- | plugins/SmileyAdd/src/services.cpp | 28 | ||||
-rw-r--r-- | protocols/Facebook/src/proto.cpp | 2 | ||||
-rw-r--r-- | protocols/Facebook/src/server.cpp | 2 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/proto.cpp | 2 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/server.cpp | 2 | ||||
-rw-r--r-- | protocols/Telegram/src/avatars.cpp | 2 | ||||
-rw-r--r-- | protocols/Telegram/src/proto.cpp | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/misc.cpp | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.cpp | 2 |
10 files changed, 22 insertions, 28 deletions
diff --git a/plugins/ExternalAPI/m_smileyadd.h b/plugins/ExternalAPI/m_smileyadd.h index cfb46fb509..8b832479fd 100644 --- a/plugins/ExternalAPI/m_smileyadd.h +++ b/plugins/ExternalAPI/m_smileyadd.h @@ -209,9 +209,13 @@ struct FVCNDATA_NMHDR // wParam = (WPARAM) 0; not used
// lParam = (LPARAM) (SMADD_CONT*) &dir; // pointer to directory to load smiley from
+#define SMADD_SMILEPACK 0
+#define SMADD_FILE 1
+#define SMADD_FOLDER 2
+
struct SMADD_CONT
{
- int type; // 0 - directory, 1 - file;
+ int type; // SMADD_* constant
const char *pszModule; // module name
const wchar_t *path; // smiley category name for reference
};
diff --git a/plugins/SmileyAdd/src/services.cpp b/plugins/SmileyAdd/src/services.cpp index 1856f2b619..922f3289a6 100644 --- a/plugins/SmileyAdd/src/services.cpp +++ b/plugins/SmileyAdd/src/services.cpp @@ -338,33 +338,23 @@ static INT_PTR LoadContactSmileys(WPARAM, LPARAM lParam) SMADD_CONT *cont = (SMADD_CONT *)lParam;
switch (cont->type) {
- case 0:
+ case SMADD_SMILEPACK:
g_SmileyPackCStore.AddSmileyPack(cont->pszModule, cont->path);
NotifyEventHooks(g_hevOptionsChanged, 0, (WPARAM)cont->pszModule);
break;
- case 1:
+ case SMADD_FILE:
g_SmileyPackCStore.AddSmiley(cont->pszModule, cont->path);
NotifyEventHooks(g_hevOptionsChanged, 0, (WPARAM)cont->pszModule);
break;
- case 2:
- WIN32_FIND_DATAW findData;
- CMStringW wszPath(cont->path);
- HANDLE hFind = FindFirstFileW(wszPath, &findData);
- if (hFind != INVALID_HANDLE_VALUE) {
- int idx = wszPath.ReverseFind('\\');
- if (idx != -1)
- wszPath.Truncate(idx + 1);
-
- do {
- if (!mir_wstrcmp(findData.cFileName, L".") || !mir_wstrcmp(findData.cFileName, L".."))
- continue;
-
- CMStringW wszFileName = wszPath + findData.cFileName;
- g_SmileyPackCStore.AddSmiley(cont->pszModule, wszFileName);
- } while (FindNextFileW(hFind, &findData));
- }
+ case SMADD_FOLDER:
+ auto *p = wcsrchr(cont->path, '\\');
+ CMStringW wszPath(cont->path, (p == nullptr) ? lstrlen(cont->path) : p - cont->path + 1);
+
+ for (auto &it : MFilePath(cont->path).search())
+ if (mir_wstrcmp(it.getPath(), L".") && mir_wstrcmp(it.getPath(), L".."))
+ g_SmileyPackCStore.AddSmiley(cont->pszModule, wszPath + it.getPath());
}
return 0;
}
diff --git a/protocols/Facebook/src/proto.cpp b/protocols/Facebook/src/proto.cpp index 5e896c6f4e..6f3209fe02 100644 --- a/protocols/Facebook/src/proto.cpp +++ b/protocols/Facebook/src/proto.cpp @@ -137,7 +137,7 @@ void FacebookProto::OnModulesLoaded() VARSW wszCache(L"%miranda_avatarcache%");
CMStringW wszPath(FORMAT, L"%s\\%S\\Stickers\\*.png", wszCache.get(), m_szModuleName);
- SMADD_CONT cont = { 2, m_szModuleName, wszPath };
+ SMADD_CONT cont = { SMADD_FOLDER, m_szModuleName, wszPath };
CallService(MS_SMILEYADD_LOADCONTACTSMILEYS, 0, LPARAM(&cont));
wszPath.Format(L"%s\\%S\\Stickers\\*.webp", wszCache.get(), m_szModuleName);
diff --git a/protocols/Facebook/src/server.cpp b/protocols/Facebook/src/server.cpp index b2f424a0e0..482db30bd7 100644 --- a/protocols/Facebook/src/server.cpp +++ b/protocols/Facebook/src/server.cpp @@ -783,7 +783,7 @@ void FacebookProto::OnPublishPrivateMessage(const JSONNode &root) szBody += "\r\n";
szBody += "STK{" + stickerId + "}";
- SMADD_CONT cont = { 1, m_szModuleName, wszFileName };
+ SMADD_CONT cont = { SMADD_FILE, m_szModuleName, wszFileName };
CallService(MS_SMILEYADD_LOADCONTACTSMILEYS, 0, LPARAM(&cont));
}
else szBody += TranslateU("Sticker received");
diff --git a/protocols/ICQ-WIM/src/proto.cpp b/protocols/ICQ-WIM/src/proto.cpp index 0eeab208f5..0633783f9d 100644 --- a/protocols/ICQ-WIM/src/proto.cpp +++ b/protocols/ICQ-WIM/src/proto.cpp @@ -139,7 +139,7 @@ void CIcqProto::OnModulesLoaded() // load custom smilies
CMStringW wszPath(GetAvatarPath() + L"\\Stickers\\*.png");
- SMADD_CONT cont = { 2, m_szModuleName, wszPath };
+ SMADD_CONT cont = { SMADD_FOLDER, m_szModuleName, wszPath };
CallService(MS_SMILEYADD_LOADCONTACTSMILEYS, 0, LPARAM(&cont));
}
diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp index 15064b4408..853e9ccde7 100644 --- a/protocols/ICQ-WIM/src/server.cpp +++ b/protocols/ICQ-WIM/src/server.cpp @@ -1010,7 +1010,7 @@ void CIcqProto::OnGetSticker(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq) fwrite(pReply->pData, 1, pReply->dataLength, out);
fclose(out);
- SMADD_CONT cont = { 1, m_szModuleName, wszFileName };
+ SMADD_CONT cont = { SMADD_FILE, m_szModuleName, wszFileName };
CallService(MS_SMILEYADD_LOADCONTACTSMILEYS, 0, LPARAM(&cont));
}
diff --git a/protocols/Telegram/src/avatars.cpp b/protocols/Telegram/src/avatars.cpp index 143692f8a2..11646a681d 100644 --- a/protocols/Telegram/src/avatars.cpp +++ b/protocols/Telegram/src/avatars.cpp @@ -193,7 +193,7 @@ void CTelegramProto::ProcessFile(TD::updateFile *pObj) }
else MoveFileW(wszExistingFile, wszFullName);
- SMADD_CONT cont = { 1, m_szModuleName, wszFullName };
+ SMADD_CONT cont = { SMADD_FILE, m_szModuleName, wszFullName };
CallService(MS_SMILEYADD_LOADCONTACTSMILEYS, 0, LPARAM(&cont));
mir_cslock lck(m_csFiles);
diff --git a/protocols/Telegram/src/proto.cpp b/protocols/Telegram/src/proto.cpp index 4f62a300a0..61ecf9c132 100644 --- a/protocols/Telegram/src/proto.cpp +++ b/protocols/Telegram/src/proto.cpp @@ -153,7 +153,7 @@ void CTelegramProto::OnModulesLoaded() m_bSmileyAdd = ServiceExists(MS_SMILEYADD_LOADCONTACTSMILEYS); if (m_bSmileyAdd) { CMStringW wszStickersPath(GetAvatarPath() + L"\\Stickers\\*.*"); - SMADD_CONT cont = {2, m_szModuleName, wszStickersPath}; + SMADD_CONT cont = { SMADD_FOLDER, m_szModuleName, wszStickersPath }; CallService(MS_SMILEYADD_LOADCONTACTSMILEYS, 0, LPARAM(&cont)); } } diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index 6cd5957735..73ae348edc 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -1467,7 +1467,7 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport if (bSuccess) {
res.AppendFormat(L"[sticker-%d]", iStickerId);
- SMADD_CONT cont = { 1, m_szModuleName, wszFileName };
+ SMADD_CONT cont = { SMADD_FILE, m_szModuleName, wszFileName };
CallService(MS_SMILEYADD_LOADCONTACTSMILEYS, 0, LPARAM(&cont));
}
else res += SetBBCString(TranslateT("Sticker"), iBBC, vkbbcUrl, wszUrl);
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index 6af4cfd606..4c6b79951a 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -128,7 +128,7 @@ void CVkProto::InitSmileys() return;
CMStringW wszPath(FORMAT, L"%s\\%S\\Stickers\\*.png", VARSW(L"%miranda_avatarcache%").get(), m_szModuleName);
- SMADD_CONT cont = { 2, m_szModuleName, wszPath };
+ SMADD_CONT cont = { SMADD_FOLDER, m_szModuleName, wszPath };
CallService(MS_SMILEYADD_LOADCONTACTSMILEYS, 0, LPARAM(&cont));
}
|