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/res/resource.rc | 5 ++--- protocols/Tox/src/tox_events.cpp | 22 +++++++++++++++++----- protocols/Tox/src/tox_options.cpp | 3 --- protocols/Tox/src/tox_proto.cpp | 2 +- 4 files changed, 20 insertions(+), 12 deletions(-) (limited to 'protocols/Tox') diff --git a/protocols/Tox/res/resource.rc b/protocols/Tox/res/resource.rc index cb3a04498b..a3e05e5e83 100644 --- a/protocols/Tox/res/resource.rc +++ b/protocols/Tox/res/resource.rc @@ -106,7 +106,7 @@ BEGIN CONTROL "Disable UDP (force Tox to use TCP)",IDC_DISABLE_UDP, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,101,288,10 CONTROL "Disable IPv6",IDC_DISABLE_IPV6,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,116,288,10 - GROUPBOX "Tox",IDC_STATIC,7,7,298,72 + GROUPBOX "Tox",IDC_STATIC,7,7,298,67 LTEXT "Default group:",IDC_STATIC,12,53,60,12 EDITTEXT IDC_GROUP,81,51,219,12,ES_AUTOHSCROLL PUSHBUTTON "C",IDC_CLIPBOARD,284,35,16,13 @@ -117,8 +117,7 @@ STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTI CAPTION "Tox profile" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - DEFPUSHBUTTON "OK",IDOK,126,90,50,14 - PUSHBUTTON "Cancel",IDCANCEL,178,90,50,14 + DEFPUSHBUTTON "OK",IDOK,178,90,50,14 LTEXT "Tox profile contains your ID and friend list.\r\nYou may create new profile if you never used tox or use existing profile from other tox client.",IDC_STATIC,7,7,221,33 CONTROL "Create new profile",IDC_CREATE_NEW,"Button",BS_AUTORADIOBUTTON,7,43,221,10 CONTROL "Use existing profile",IDC_USE_EXISTING,"Button",BS_AUTORADIOBUTTON,7,55,221,10 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