From 32aac6884eeff071503b70d7e441244a5690382c Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Wed, 20 Aug 2014 18:30:56 +0000 Subject: Tox: fixed status message git-svn-id: http://svn.miranda-ng.org/main/trunk@10244 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tox/src/tox_events.cpp | 22 +++++++++++++++++----- protocols/Tox/src/tox_options.cpp | 3 --- protocols/Tox/src/tox_proto.cpp | 2 +- 3 files changed, 18 insertions(+), 9 deletions(-) (limited to 'protocols/Tox/src') diff --git a/protocols/Tox/src/tox_events.cpp b/protocols/Tox/src/tox_events.cpp index ee439c8fdf..eeedc29ac2 100644 --- a/protocols/Tox/src/tox_events.cpp +++ b/protocols/Tox/src/tox_events.cpp @@ -129,11 +129,22 @@ int CToxProto::OnContactDeleted(MCONTACT hContact, LPARAM lParam) int CToxProto::OnSettingsChanged(MCONTACT hContact, LPARAM lParam) { DBCONTACTWRITESETTING* dbcws = (DBCONTACTWRITESETTING*)lParam; - if (hContact == NULL && !strcmp(dbcws->szModule, m_szModuleName) && !strcmp(dbcws->szSetting, "Nick")) + if (hContact == NULL && !strcmp(dbcws->szModule, m_szModuleName)) { - if (tox_set_name(tox, (uint8_t*)(char*)ptrA(mir_utf8encodeW(dbcws->value.ptszVal)), (uint16_t)_tcslen(dbcws->value.ptszVal))) + if (!strcmp(dbcws->szSetting, "Nick")) { - SaveToxData(); + if (tox_set_name(tox, (uint8_t*)(char*)ptrA(mir_utf8encodeW(dbcws->value.ptszVal)), (uint16_t)_tcslen(dbcws->value.ptszVal))) + { + SaveToxData(); + } + } + + if (!strcmp(dbcws->szSetting, "StatusMsg") || !strcmp(dbcws->szSetting, "StatusNote")) + { + if (tox_set_status_message(tox, (uint8_t*)(char*)ptrA(mir_utf8encodeW(dbcws->value.ptszVal)), (uint16_t)_tcslen(dbcws->value.ptszVal))) + { + SaveToxData(); + } } } @@ -148,7 +159,7 @@ void CToxProto::OnFriendRequest(Tox *tox, const uint8_t *userId, const uint8_t * std::string toxId = proto->DataToHexString(clientId); proto->RaiseAuthRequestEvent(time(NULL), toxId.c_str(), (char*)message); - + proto->SaveToxData(); } @@ -198,7 +209,8 @@ void CToxProto::OnStatusMessageChanged(Tox *tox, const int friendnumber, const u MCONTACT hContact = proto->FindContact(toxId.c_str()); if (hContact) { - db_set_s(hContact, "CList", "StatusMsg", (char*)message); + ptrW statusMessage(mir_utf8decodeW((char*)message)); + db_set_ws(hContact, "CList", "StatusMsg", statusMessage); } } diff --git a/protocols/Tox/src/tox_options.cpp b/protocols/Tox/src/tox_options.cpp index e048769ce1..9571014deb 100644 --- a/protocols/Tox/src/tox_options.cpp +++ b/protocols/Tox/src/tox_options.cpp @@ -173,9 +173,6 @@ INT_PTR CALLBACK CToxProto::ToxProfileManagerProc(HWND hwnd, UINT uMsg, WPARAM w } break; - case IDCANCEL: - EndDialog(hwnd, 0); - break; } break; } diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp index 1f618a5b58..0bcba5d09b 100644 --- a/protocols/Tox/src/tox_proto.cpp +++ b/protocols/Tox/src/tox_proto.cpp @@ -14,7 +14,7 @@ CToxProto::CToxProto(const char* protoName, const TCHAR* userName) : GetModuleFileName(g_hInstance, filePath, MAX_PATH); wchar_t sectionName[100]; - mir_sntprintf(sectionName, SIZEOF(sectionName), _T("%s/%s"), LPGENT("Protocols"), LPGENT(MODULE)); + mir_sntprintf(sectionName, SIZEOF(sectionName), _T("%s/%s"), LPGENT("Protocols"), MODULE); char settingName[100]; mir_snprintf(settingName, SIZEOF(settingName), "%s_%s", MODULE, "main"); -- cgit v1.2.3