From d770f3eb807b9b1c9f844a005179f93893183133 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Thu, 5 Mar 2015 19:18:03 +0000 Subject: Tox: add folders support git-svn-id: http://svn.miranda-ng.org/main/trunk@12331 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tox/Tox_12.vcxproj | 1 + protocols/Tox/Tox_12.vcxproj.filters | 3 +++ protocols/Tox/src/common.h | 2 ++ protocols/Tox/src/main.cpp | 1 + protocols/Tox/src/tox_folders.cpp | 8 ++++++++ protocols/Tox/src/tox_options.cpp | 13 +++++++++++-- protocols/Tox/src/tox_profile.cpp | 9 ++++----- protocols/Tox/src/tox_proto.h | 13 +++++++++++-- protocols/Tox/src/tox_search.cpp | 2 -- 9 files changed, 41 insertions(+), 11 deletions(-) create mode 100644 protocols/Tox/src/tox_folders.cpp (limited to 'protocols') diff --git a/protocols/Tox/Tox_12.vcxproj b/protocols/Tox/Tox_12.vcxproj index 9afe2be779..31c52283a9 100644 --- a/protocols/Tox/Tox_12.vcxproj +++ b/protocols/Tox/Tox_12.vcxproj @@ -232,6 +232,7 @@ copy docs\tox.ini "$(SolutionDir)$(Configuration)64\Plugins" /y + diff --git a/protocols/Tox/Tox_12.vcxproj.filters b/protocols/Tox/Tox_12.vcxproj.filters index d04033b672..526b86f4ff 100644 --- a/protocols/Tox/Tox_12.vcxproj.filters +++ b/protocols/Tox/Tox_12.vcxproj.filters @@ -143,6 +143,9 @@ Source Files + + Source Files + diff --git a/protocols/Tox/src/common.h b/protocols/Tox/src/common.h index d6bdc6e1c4..a0fa494107 100644 --- a/protocols/Tox/src/common.h +++ b/protocols/Tox/src/common.h @@ -34,6 +34,8 @@ #include #include +#include + #include #include #include diff --git a/protocols/Tox/src/main.cpp b/protocols/Tox/src/main.cpp index 6d9711e12d..fedd47ccc0 100644 --- a/protocols/Tox/src/main.cpp +++ b/protocols/Tox/src/main.cpp @@ -52,6 +52,7 @@ extern "C" int __declspec(dllexport) Load(void) CToxProto::InitIcons(); CToxProto::InitMenus(); + CToxProto::InitFolders(); return 0; } diff --git a/protocols/Tox/src/tox_folders.cpp b/protocols/Tox/src/tox_folders.cpp new file mode 100644 index 0000000000..a082aeb1b4 --- /dev/null +++ b/protocols/Tox/src/tox_folders.cpp @@ -0,0 +1,8 @@ +#include "common.h" + +HANDLE CToxProto::hProfileFolderPath = NULL; + +void CToxProto::InitFolders() +{ + hProfileFolderPath = FoldersRegisterCustomPathT("Tox", Translate("Profiles folder"), MIRANDA_USERDATAT); +} diff --git a/protocols/Tox/src/tox_options.cpp b/protocols/Tox/src/tox_options.cpp index 623b05c673..764d3d9469 100644 --- a/protocols/Tox/src/tox_options.cpp +++ b/protocols/Tox/src/tox_options.cpp @@ -74,9 +74,17 @@ INT_PTR CToxProto::MainOptionsProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l case IDC_IMPORT_PROFILE: { + TCHAR *pFilter, filter[MAX_PATH] = { 0 }; + pFilter = &filter[0]; + mir_tstrcat(pFilter, TranslateT("Tox profile(*.tox)")); + pFilter += mir_tstrlen(pFilter) + 1; + mir_tstrcat(pFilter, _T("*.tox")); + pFilter += mir_tstrlen(pFilter) + 1; + mir_tstrcat(pFilter, TranslateT("All files(*.*)")); + pFilter += mir_tstrlen(pFilter) + 1; + mir_tstrcat(pFilter, _T("*.*")); + TCHAR profilePath[MAX_PATH] = { 0 }; - TCHAR filter[MAX_PATH] = { 0 }; - mir_sntprintf(filter, MAX_PATH, _T("%s\0*.*"), TranslateT("All files (*.*)")); OPENFILENAME ofn = { sizeof(ofn) }; ofn.hwndOwner = hwnd; @@ -86,6 +94,7 @@ INT_PTR CToxProto::MainOptionsProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l ofn.lpstrTitle = TranslateT("Select tox profile"); ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_EXPLORER; + ofn.lpstrInitialDir = _T("%APPDATA%\\Tox"); if (GetOpenFileName(&ofn)) { diff --git a/protocols/Tox/src/tox_profile.cpp b/protocols/Tox/src/tox_profile.cpp index cdfbbe5fb8..9d1d446099 100644 --- a/protocols/Tox/src/tox_profile.cpp +++ b/protocols/Tox/src/tox_profile.cpp @@ -7,11 +7,10 @@ std::tstring CToxProto::GetToxProfilePath() std::tstring CToxProto::GetToxProfilePath(const TCHAR *accountName) { - std::tstring profilePath; - TCHAR defaultPath[MAX_PATH]; - mir_sntprintf(defaultPath, MAX_PATH, _T("%s\\%s.tox"), VARST(_T("%miranda_userdata%")), accountName); - profilePath = defaultPath; - + TCHAR profilePath[MAX_PATH]; + TCHAR profileRootPath[MAX_PATH]; + FoldersGetCustomPathT(hProfileFolderPath, profileRootPath, SIZEOF(profileRootPath), VARST(_T("%miranda_userdata%"))); + mir_sntprintf(profilePath, MAX_PATH, _T("%s\\%s.tox"), profileRootPath, accountName); return profilePath; } diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h index f6292bdc20..9932a74aca 100644 --- a/protocols/Tox/src/tox_proto.h +++ b/protocols/Tox/src/tox_proto.h @@ -71,6 +71,9 @@ public: static void InitMenus(); static void UninitMenus(); + // folders + static void InitFolders(); + private: Tox *tox; char *password; @@ -138,6 +141,12 @@ private: int OnInitStatusMenu(); + // folders + static HANDLE hProfileFolderPath; + + //services + INT_PTR __cdecl CToxProto::SetMyNickname(WPARAM wParam, LPARAM lParam); + // options static INT_PTR CALLBACK MainOptionsProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); static INT_PTR CALLBACK NodesOptionsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); @@ -239,11 +248,11 @@ private: INT_PTR __cdecl GetMyAvatar(WPARAM wParam, LPARAM lParam); INT_PTR __cdecl SetMyAvatar(WPARAM wParam, LPARAM lParam); - INT_PTR __cdecl CToxProto::SetMyNickname(WPARAM wParam, LPARAM lParam); - static void OnGotFriendAvatarInfo(Tox *tox, int32_t number, uint8_t format, uint8_t *hash, void *arg); static void OnGotFriendAvatarData(Tox *tox, int32_t number, uint8_t format, uint8_t *hash, uint8_t *data, uint32_t length, void *arg); + // folders + // utils TOX_USERSTATUS MirandaToToxStatus(int status); int ToxToMirandaStatus(TOX_USERSTATUS userstatus); diff --git a/protocols/Tox/src/tox_search.cpp b/protocols/Tox/src/tox_search.cpp index 49a1b54099..ea2a571a32 100644 --- a/protocols/Tox/src/tox_search.cpp +++ b/protocols/Tox/src/tox_search.cpp @@ -137,8 +137,6 @@ void CToxProto::SearchByNameAsync(void *arg) psr.email = mir_tstrdup(email); ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)1, (LPARAM)&psr); - - resolved++; break; } } -- cgit v1.2.3