summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Tox/res/resource.rc61
-rw-r--r--protocols/Tox/src/main.cpp24
-rw-r--r--protocols/Tox/src/resource.h24
-rw-r--r--protocols/Tox/src/stdafx.h14
-rw-r--r--protocols/Tox/src/tox_accounts.cpp3
-rw-r--r--protocols/Tox/src/tox_events.cpp32
-rw-r--r--protocols/Tox/src/tox_menus.cpp29
-rw-r--r--protocols/Tox/src/tox_menus.h3
-rw-r--r--protocols/Tox/src/tox_messages.cpp11
-rw-r--r--protocols/Tox/src/tox_options.cpp102
-rw-r--r--protocols/Tox/src/tox_profile.cpp125
-rw-r--r--protocols/Tox/src/tox_profile.h33
-rw-r--r--protocols/Tox/src/tox_proto.cpp25
-rw-r--r--protocols/Tox/src/tox_proto.h48
14 files changed, 250 insertions, 284 deletions
diff --git a/protocols/Tox/res/resource.rc b/protocols/Tox/res/resource.rc
index 478f13fe9f..3ba18ad5cb 100644
--- a/protocols/Tox/res/resource.rc
+++ b/protocols/Tox/res/resource.rc
@@ -141,17 +141,17 @@ BEGIN
EDITTEXT IDC_DNS_ID,2,13,217,14,ES_AUTOHSCROLL
END
-IDD_PASSWORD DIALOGEX 0, 0, 209, 75
+IDD_PASSWORD_ENTER DIALOGEX 0, 0, 211, 76
STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
-EXSTYLE WS_EX_TOOLWINDOW | WS_EX_APPWINDOW
+EXSTYLE WS_EX_TOPMOST | WS_EX_TOOLWINDOW | WS_EX_CONTROLPARENT | WS_EX_APPWINDOW
CAPTION "Enter password"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- EDITTEXT IDC_PASSWORD,7,24,197,12,ES_PASSWORD | ES_AUTOHSCROLL
- CONTROL "Save password",IDC_SAVEPERMANENTLY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,40,197,12
- DEFPUSHBUTTON "OK",IDOK,101,56,50,14,WS_DISABLED
- PUSHBUTTON "Cancel",IDCANCEL,154,56,50,14
- LTEXT "Tox profile is encrypted. Enter the password to continue.",IDC_STATIC,7,5,197,18
+ EDITTEXT IDC_PASSWORD,7,24,199,12,ES_PASSWORD | ES_AUTOHSCROLL
+ CONTROL "Save password",IDC_SAVEPERMANENTLY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,40,199,12
+ DEFPUSHBUTTON "OK",IDOK,101,57,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,156,57,50,14
+ LTEXT "Tox profile is encrypted. Enter the password to continue.",IDC_STATIC,7,5,199,18
END
IDD_OPTIONS_NODES DIALOGEX 0, 0, 310, 230
@@ -181,18 +181,21 @@ BEGIN
PUSHBUTTON "Cancel",IDCANCEL,156,97,50,14
END
-IDD_OPTIONS_MULTIMEDIA DIALOGEX 0, 0, 310, 230
-STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
-EXSTYLE WS_EX_CONTROLPARENT
+IDD_PASSWORD_CHANGE DIALOGEX 0, 0, 209, 112
+STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+EXSTYLE WS_EX_TOPMOST | WS_EX_TOOLWINDOW | WS_EX_CONTROLPARENT | WS_EX_APPWINDOW
+CAPTION "Change password"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- GROUPBOX "Multimedia",-1,7,7,296,89
- LTEXT "Audio input device",-1,12,17,60,8
- COMBOBOX IDC_AUDIOINPUT,12,26,286,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
- LTEXT "Audio output device",-1,12,42,65,8
- COMBOBOX IDC_AUDIOOUTPUT,12,52,286,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
- LTEXT "Video input device",-1,15,68,59,8,NOT WS_VISIBLE
- COMBOBOX IDC_COMBO_VIDEOINPUT,12,78,286,30,CBS_DROPDOWN | CBS_SORT | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP
+ EDITTEXT IDC_PASSWORD,7,14,197,12,ES_PASSWORD | ES_AUTOHSCROLL
+ DEFPUSHBUTTON "OK",IDOK,101,93,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,154,93,50,14
+ EDITTEXT IDC_PASSWORD_NEW,7,40,197,12,ES_PASSWORD | ES_AUTOHSCROLL
+ LTEXT "Old password:",IDC_STATIC,7,4,197,8
+ LTEXT "New password:",IDC_STATIC,7,30,197,8
+ EDITTEXT IDC_PASSWORD_CONFIRM,7,65,197,12,ES_PASSWORD | ES_AUTOHSCROLL
+ LTEXT "Confirm password:",IDC_STATIC,7,55,197,8
+ LTEXT "",IDC_PASSWORD_VALIDATION,7,81,197,8
END
@@ -234,11 +237,11 @@ BEGIN
VERTGUIDE, 219
END
- IDD_PASSWORD, DIALOG
+ IDD_PASSWORD_ENTER, DIALOG
BEGIN
- RIGHTMARGIN, 204
+ RIGHTMARGIN, 206
VERTGUIDE, 7
- BOTTOMMARGIN, 70
+ BOTTOMMARGIN, 71
END
IDD_OPTIONS_NODES, DIALOG
@@ -260,15 +263,11 @@ BEGIN
HORZGUIDE, 67
END
- IDD_OPTIONS_MULTIMEDIA, DIALOG
+ IDD_PASSWORD_CHANGE, DIALOG
BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 303
- VERTGUIDE, 12
- VERTGUIDE, 81
- VERTGUIDE, 298
- TOPMARGIN, 7
- BOTTOMMARGIN, 228
+ RIGHTMARGIN, 204
+ VERTGUIDE, 7
+ BOTTOMMARGIN, 107
END
END
#endif // APSTUDIO_INVOKED
@@ -279,17 +278,17 @@ END
// AFX_DIALOG_LAYOUT
//
-IDD_OPTIONS_MULTIMEDIA AFX_DIALOG_LAYOUT
+IDD_OPTIONS_MAIN AFX_DIALOG_LAYOUT
BEGIN
0
END
-IDD_OPTIONS_MAIN AFX_DIALOG_LAYOUT
+IDD_PASSWORD_ENTER AFX_DIALOG_LAYOUT
BEGIN
0
END
-IDD_PASSWORD AFX_DIALOG_LAYOUT
+IDD_PASSWORD_CHANGE AFX_DIALOG_LAYOUT
BEGIN
0
END
diff --git a/protocols/Tox/src/main.cpp b/protocols/Tox/src/main.cpp
index 95c14d25f4..3d40928abf 100644
--- a/protocols/Tox/src/main.cpp
+++ b/protocols/Tox/src/main.cpp
@@ -4,7 +4,7 @@ int hLangpack;
CHAT_MANAGER *pci;
CLIST_INTERFACE *pcli;
HINSTANCE g_hInstance;
-HMODULE g_hToxLibrary = nullptr;
+HANDLE hProfileFolderPath;
PLUGININFOEX pluginInfo =
{
@@ -34,20 +34,34 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST };
+int OnModulesLoaded(WPARAM, LPARAM)
+{
+ CToxProto::InitIcons();
+ CToxProto::InitContactMenu();
+
+ hProfileFolderPath = FoldersRegisterCustomPathT("Tox", "ProfilesFolder", MIRANDA_USERDATAT, TranslateT("Profiles folder"));
+
+ if (ServiceExists(MS_ASSOCMGR_ADDNEWURLTYPE)) {
+ CreateServiceFunction(MODULE "/ParseUri", CToxProto::ParseToxUri);
+ AssocMgr_AddNewUrlTypeT("tox:", TranslateT("Tox URI scheme"), g_hInstance, IDI_TOX, MODULE "/ParseUri", 0);
+ }
+
+ return 0;
+}
+
extern "C" int __declspec(dllexport) Load(void)
{
if (!TOX_VERSION_IS_ABI_COMPATIBLE())
{
wchar_t message[100];
- mir_snwprintf(message, TranslateT("Current version of plugin is support Tox API version %i.%i.%i which is incompatible with %s"), TOX_VERSION_MAJOR, TOX_VERSION_MINOR, TOX_VERSION_PATCH, "");
+ mir_snwprintf(message, TranslateT("Current version of plugin is support Tox API version %i.%i.%i which is incompatible with libtox.mir"), TOX_VERSION_MAJOR, TOX_VERSION_MINOR, TOX_VERSION_PATCH);
CToxProto::ShowNotification(message, MB_ICONERROR);
- FreeLibrary(g_hToxLibrary);
return 2;
}
+ mir_getLP(&pluginInfo);
pci = Chat_GetInterface();
pcli = Clist_GetInterface();
- mir_getLP(&pluginInfo);
PROTOCOLDESCRIPTOR pd = { 0 };
pd.cbSize = sizeof(pd);
@@ -57,7 +71,7 @@ extern "C" int __declspec(dllexport) Load(void)
pd.fnUninit = (pfnUninitProto)CToxProto::UninitAccount;
Proto_RegisterModule(&pd);
- HookEvent(ME_SYSTEM_MODULESLOADED, &CToxProto::OnModulesLoaded);
+ HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
return 0;
}
diff --git a/protocols/Tox/src/resource.h b/protocols/Tox/src/resource.h
index b5f13e9d32..bc2b71876f 100644
--- a/protocols/Tox/src/resource.h
+++ b/protocols/Tox/src/resource.h
@@ -4,18 +4,15 @@
//
#define IDI_TOX 100
#define IDD_USER_INFO 101
-#define IDD_PASSWORD 102
+#define IDD_PASSWORD_ENTER 102
+#define IDD_PASSWORD_CHANGE 103
#define IDD_ACCOUNT_MANAGER 104
#define IDD_SEARCH 105
#define IDD_OPTIONS_MAIN 106
#define IDD_OPTIONS_NODES 107
#define IDD_ADDNODE 108
#define IDD_NODE_EDITOR 109
-#define IDD_OPTIONS_MULTIMEDIA 110
-#define IDI_AUDIO_END 112
-#define IDI_AUDIO_RING 113
-#define IDI_AUDIO_START 114
-#define IDI_AUDIO_CALL 115
+
#define IDC_EDITSCR 174
#define IDC_TOXID 1001
#define IDC_CLIPBOARD 1002
@@ -38,17 +35,16 @@
#define IDC_IPV6 1018
#define IDC_PORT 1019
#define IDC_PKEY 1020
-#define IDC_COMBO_AUDIOINPUT 1021
-#define IDC_AUDIOINPUT 1021
-#define IDC_COMBO_AUDIOOUTPUT 1022
-#define IDC_AUDIOOUTPUT 1022
-#define IDC_AUDIOFILTER 1023
-#define IDC_COMBO_VIDEOINPUT 1024
+#define IDC_UPDATENODES 1021
#define IDC_MAXCONNECTRETRIES 1025
#define IDC_MAXRECONNECTRETRIES 1026
#define IDC_MAXCONNECTRETRIESSPIN 1027
#define IDC_MAXRECONNECTRETRIESSPIN 1028
-#define IDC_UPDATENODES 1081
+#define IDC_PASSWORD_NEW 1029
+#define IDC_PASSWORD_CONFIRM 1030
+#define IDC_PASSWORD_VALIDATION 1031
+
+
// Next default values for new objects
//
@@ -56,7 +52,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 117
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1029
+#define _APS_NEXT_CONTROL_VALUE 1032
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/protocols/Tox/src/stdafx.h b/protocols/Tox/src/stdafx.h
index b69c0fd629..86da917de9 100644
--- a/protocols/Tox/src/stdafx.h
+++ b/protocols/Tox/src/stdafx.h
@@ -76,14 +76,13 @@ extern HINSTANCE g_hInstance;
#define TOX_MAX_CONNECT_RETRIES 10
#define TOX_MAX_RECONNECT_RETRIES 10
-#define TOX_MAX_CALLS 1
-
#define TOX_INI_PATH "%miranda_path%\\Plugins\\tox.ini"
#define TOX_JSON_PATH "%miranda_userdata%\\tox.json"
#define TOX_SETTINGS_ID "ToxID"
#define TOX_SETTINGS_DNS "DnsID"
#define TOX_SETTINGS_CHAT_ID "ChatID"
+#define TOX_SETTINGS_PASSWORD "Password"
#define TOX_SETTINGS_GROUP "DefaultGroup"
#define TOX_SETTINGS_AVATAR_HASH "AvatarHash"
@@ -94,14 +93,9 @@ extern HINSTANCE g_hInstance;
#define TOX_SETTINGS_NODE_PKEY TOX_SETTINGS_NODE_PREFIX"%d_PubKey"
#define TOX_SETTINGS_NODE_COUNT TOX_SETTINGS_NODE_PREFIX"Count"
-enum TOX_DB_EVENT
-{
- DB_EVENT_ACTION = 10001,
- DB_EVENT_CALL = 20001
-};
-
-#define PSR_AUDIO "/RecvAudio"
-
+#define DB_EVENT_ACTION 10001
#define TOX_MAX_AVATAR_SIZE 1 << 16 // 2 ^ 16 bytes
+extern HANDLE hProfileFolderPath;
+
#endif //_COMMON_H_ \ No newline at end of file
diff --git a/protocols/Tox/src/tox_accounts.cpp b/protocols/Tox/src/tox_accounts.cpp
index b1bfa58490..fb7834f1db 100644
--- a/protocols/Tox/src/tox_accounts.cpp
+++ b/protocols/Tox/src/tox_accounts.cpp
@@ -36,13 +36,12 @@ int CToxProto::OnAccountLoaded(WPARAM, LPARAM)
HookProtoEvent(ME_MSG_PRECREATEEVENT, &CToxProto::OnPreCreateMessage);
InitCustomDbEvents();
-
return 0;
}
int CToxProto::OnAccountRenamed(WPARAM, LPARAM)
{
- mir_cslock locker(profileLock);
+ mir_cslock lock(profileLock);
ptrW newPath(GetToxProfilePath());
wchar_t oldPath[MAX_PATH];
diff --git a/protocols/Tox/src/tox_events.cpp b/protocols/Tox/src/tox_events.cpp
deleted file mode 100644
index f0afe46dbd..0000000000
--- a/protocols/Tox/src/tox_events.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-#include "stdafx.h"
-
-int CToxProto::OnModulesLoaded(WPARAM, LPARAM)
-{
- CToxProto::InitIcons();
- CToxProto::InitMenus();
-
- hProfileFolderPath = FoldersRegisterCustomPathT("Tox", "ProfilesFolder", MIRANDA_USERDATAT, TranslateT("Profiles folder"));
-
- if (ServiceExists(MS_ASSOCMGR_ADDNEWURLTYPE)) {
- CreateServiceFunction(MODULE "/ParseUri", CToxProto::ParseToxUri);
- AssocMgr_AddNewUrlTypeT("tox:", TranslateT("Tox URI scheme"), g_hInstance, IDI_TOX, MODULE "/ParseUri", 0);
- }
-
- return 0;
-}
-
-void CToxProto::InitCustomDbEvents()
-{
- DBEVENTTYPEDESCR dbEventType = { sizeof(dbEventType) };
- dbEventType.module = m_szModuleName;
- dbEventType.flags = DETF_HISTORY | DETF_MSGWINDOW;
-
- dbEventType.eventType = DB_EVENT_ACTION;
- dbEventType.descr = Translate("Action");
- DbEvent_RegisterType(&dbEventType);
-
- dbEventType.eventType = DB_EVENT_CALL;
- dbEventType.descr = Translate("Call");
- dbEventType.eventIcon = GetIconHandle(IDI_AUDIO_START);
- DbEvent_RegisterType(&dbEventType);
-}
diff --git a/protocols/Tox/src/tox_menus.cpp b/protocols/Tox/src/tox_menus.cpp
index 205fb11979..ffa47b8621 100644
--- a/protocols/Tox/src/tox_menus.cpp
+++ b/protocols/Tox/src/tox_menus.cpp
@@ -32,7 +32,7 @@ int CToxProto::PrebuildContactMenu(WPARAM hContact, LPARAM lParam)
return proto ? proto->OnPrebuildContactMenu(hContact, lParam) : 0;
}
-void CToxProto::InitMenus()
+void CToxProto::InitContactMenu()
{
HookEvent(ME_CLIST_PREBUILDCONTACTMENU, &CToxProto::PrebuildContactMenu);
@@ -58,8 +58,17 @@ void CToxProto::InitMenus()
CreateServiceFunction(mi.pszService, GlobalService<&CToxProto::OnGrantAuth>);
}
+int CToxProto::PrebuildStatusMenu(WPARAM, LPARAM)
+{
+ bool isOnline = IsOnline();
+ Menu_EnableItem(StatusMenuItems[SMI_PASSWORD_CHANGE], isOnline);
+ return 0;
+}
+
int CToxProto::OnInitStatusMenu()
{
+ HookProtoEvent(ME_CLIST_PREBUILDSTATUSMENU, &CToxProto::PrebuildStatusMenu);
+
CMenuItem mi;
mi.flags = CMIF_UNICODE;
mi.root = Menu_GetProtocolRoot(this);
@@ -69,16 +78,14 @@ int CToxProto::OnInitStatusMenu()
CreateProtoService(mi.pszService, &CToxProto::OnCopyToxID);
mi.name.w = LPGENW("Copy Tox ID");
mi.position = SMI_POSITION + SMI_TOXID_COPY;
- Menu_AddProtoMenuItem(&mi, m_szModuleName);
-
- // Create group chat command
- /*
- mi.pszService = "/CreateChatRoom";
- CreateProtoService(mi.pszService, &CToxProto::OnCreateChatRoom);
- mi.name.w = LPGENW("Create group chat");
- mi.position = SMI_POSITION + SMI_GROUPCHAT_CREATE;
- mi.hIcolibItem = Skin_GetIconHandle("conference");
- HGENMENU hCreateChatRoom = Menu_AddProtoMenuItem(&mi, m_szModuleName);*/
+ StatusMenuItems[SMI_TOXID_COPY] = Menu_AddProtoMenuItem(&mi, m_szModuleName);
+
+ // Change password command
+ mi.pszService = "/ChangePassword";
+ CreateProtoService(mi.pszService, &CToxProto::OnChangePassword);
+ mi.name.w = LPGENW("Change password");
+ mi.position = SMI_POSITION + SMI_PASSWORD_CHANGE;
+ StatusMenuItems[SMI_PASSWORD_CHANGE] = Menu_AddProtoMenuItem(&mi, m_szModuleName);
return 0;
}
diff --git a/protocols/Tox/src/tox_menus.h b/protocols/Tox/src/tox_menus.h
index f4930265a2..8c23f6dd28 100644
--- a/protocols/Tox/src/tox_menus.h
+++ b/protocols/Tox/src/tox_menus.h
@@ -7,7 +7,6 @@ enum CMI_MENU_ITEMS
{
CMI_AUTH_REQUEST,
CMI_AUTH_GRANT,
- CMI_AUDIO_CALL,
CMI_MAX // this item shall be the last one
};
@@ -16,7 +15,7 @@ enum CMI_MENU_ITEMS
enum SMI_MENU_ITEMS
{
SMI_TOXID_COPY,
- SMI_GROUPCHAT_CREATE,
+ SMI_PASSWORD_CHANGE,
SMI_MAX // this item shall be the last one
};
diff --git a/protocols/Tox/src/tox_messages.cpp b/protocols/Tox/src/tox_messages.cpp
index 761294cbf7..2fd5eb761b 100644
--- a/protocols/Tox/src/tox_messages.cpp
+++ b/protocols/Tox/src/tox_messages.cpp
@@ -1,5 +1,16 @@
#include "stdafx.h"
+void CToxProto::InitCustomDbEvents()
+{
+ DBEVENTTYPEDESCR dbEventType = { sizeof(dbEventType) };
+ dbEventType.module = m_szModuleName;
+ dbEventType.flags = DETF_HISTORY | DETF_MSGWINDOW;
+
+ dbEventType.eventType = DB_EVENT_ACTION;
+ dbEventType.descr = Translate("Action");
+ DbEvent_RegisterType(&dbEventType);
+}
+
/* MESSAGE RECEIVING */
// incoming message flow
diff --git a/protocols/Tox/src/tox_options.cpp b/protocols/Tox/src/tox_options.cpp
index cdd12f7089..08a4ab8cdc 100644
--- a/protocols/Tox/src/tox_options.cpp
+++ b/protocols/Tox/src/tox_options.cpp
@@ -217,108 +217,6 @@ void CToxOptionsMain::OnApply()
/////////////////////////////////////////////////////////////////////////////////
-CToxOptionsMultimedia::CToxOptionsMultimedia(CToxProto *proto)
- : CToxDlgBase(proto, IDD_OPTIONS_MULTIMEDIA, false),
- m_audioInput(this, IDC_AUDIOINPUT),
- m_audioOutput(this, IDC_AUDIOOUTPUT)
-{}
-
-void CToxOptionsMultimedia::EnumDevices(CCtrlCombo &combo, IMMDeviceEnumerator *pEnumerator, EDataFlow dataFlow, const char* setting)
-{
- LPWSTR pwszDefID = nullptr;
- ptrW wszDefID(m_proto->getWStringA(setting));
- if (wszDefID != NULL) {
- size_t len = mir_wstrlen(wszDefID) + 1;
- pwszDefID = (LPWSTR)CoTaskMemAlloc(len * 2);
- mir_wstrncpy(pwszDefID, wszDefID, len);
- }
- else {
- CComPtr<IMMDevice> pDevice = nullptr;
- if (FAILED(pEnumerator->GetDefaultAudioEndpoint(dataFlow, eConsole, &pDevice))) return;
- if (FAILED(pDevice->GetId(&pwszDefID))) return;
- }
-
- CComPtr<IMMDeviceCollection> pDevices = nullptr;
- EXIT_ON_ERROR(pEnumerator->EnumAudioEndpoints(dataFlow, DEVICE_STATE_ACTIVE, &pDevices));
-
- UINT count;
- EXIT_ON_ERROR(pDevices->GetCount(&count));
-
- for (UINT i = 0; i < count; i++) {
- CComPtr<IMMDevice> pDevice = nullptr;
- EXIT_ON_ERROR(pDevices->Item(i, &pDevice));
-
- CComPtr<IPropertyStore> pProperties = nullptr;
- EXIT_ON_ERROR(pDevice->OpenPropertyStore(STGM_READ, &pProperties));
-
- PROPVARIANT varName;
- PropVariantInit(&varName);
- EXIT_ON_ERROR(pProperties->GetValue(PKEY_Device_FriendlyName, &varName));
-
- LPWSTR pwszID = nullptr;
- EXIT_ON_ERROR(pDevice->GetId(&pwszID));
- combo.InsertString(varName.pwszVal, i, (LPARAM)mir_wstrdup(pwszID));
- if (mir_wstrcmpi(pwszID, pwszDefID) == 0)
- combo.SetCurSel(i);
- CoTaskMemFree(pwszID);
-
- PropVariantClear(&varName);
- }
-
-Exit:
- CoTaskMemFree(pwszDefID);
-}
-
-void CToxOptionsMultimedia::OnInitDialog()
-{
- CToxDlgBase::OnInitDialog();
-
- CComPtr<IMMDeviceEnumerator> pEnumerator = nullptr;
- if (FAILED(CoCreateInstance(__uuidof(MMDeviceEnumerator), nullptr, CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), (void**)&pEnumerator)))
- return;
-
- EnumDevices(m_audioInput, pEnumerator, eCapture, "AudioInputDeviceID");
- EnumDevices(m_audioOutput, pEnumerator, eRender, "AudioOutputDeviceID");
-}
-
-void CToxOptionsMultimedia::OnApply()
-{
- int i = m_audioInput.GetCurSel();
- if (i == -1)
- m_proto->delSetting("AudioInputDeviceID");
- else {
- wchar_t* data = (wchar_t*)m_audioInput.GetItemData(i);
- m_proto->setWString("AudioInputDeviceID", data);
- }
-
- i = m_audioOutput.GetCurSel();
- if (i == -1)
- m_proto->delSetting("AudioOutputDeviceID");
- else {
- wchar_t* data = (wchar_t*)m_audioOutput.GetItemData(i);
- m_proto->setWString("AudioOutputDeviceID", data);
- }
-}
-
-void CToxOptionsMultimedia::OnDestroy()
-{
- int count = m_audioInput.GetCount();
- for (int i = 0; i < count; i++) {
- wchar_t* data = (wchar_t*)m_audioInput.GetItemData(i);
- mir_free(data);
-
- }
-
- count = m_audioOutput.GetCount();
- for (int i = 0; i < count; i++) {
- wchar_t* data = (wchar_t*)m_audioOutput.GetItemData(i);
- mir_free(data);
-
- }
-}
-
-/////////////////////////////////////////////////////////////////////////////////
-
CToxNodeEditor::CToxNodeEditor(int iItem, CCtrlListView *m_nodes)
: CSuper(g_hInstance, IDD_NODE_EDITOR),
m_ipv4(this, IDC_IPV4), m_ipv6(this, IDC_IPV6),
diff --git a/protocols/Tox/src/tox_profile.cpp b/protocols/Tox/src/tox_profile.cpp
index c10269e40f..21198eb7f1 100644
--- a/protocols/Tox/src/tox_profile.cpp
+++ b/protocols/Tox/src/tox_profile.cpp
@@ -18,17 +18,15 @@ wchar_t* CToxProto::GetToxProfilePath(const wchar_t *accountName)
static INT_PTR CALLBACK EnterPassword(void *param)
{
- CToxProto *pThis = (CToxProto*)param;
+ CToxProto *proto = (CToxProto*)param;
- pass_ptrA password(mir_utf8encodeW(pass_ptrT(pThis->getWStringA("Password"))));
- if (password == NULL || mir_strlen(password) == 0) {
- CToxPasswordEditor passwordEditor(pThis);
- if (!passwordEditor.DoModal())
+ pass_ptrW password(proto->getWStringA("Password"));
+ if (mir_wstrlen(password) == 0) {
+ CToxEnterPasswordDlg passwordDlg(proto);
+ if (!passwordDlg.DoModal())
return 0;
-
- password = mir_utf8encodeW(pass_ptrT(passwordEditor.GetPassword()));
+ password = passwordDlg.GetPassword();
}
-
return (INT_PTR)password.detach();
}
@@ -73,8 +71,8 @@ bool CToxProto::LoadToxProfile(Tox_Options *options)
fclose(profile);
if (tox_is_data_encrypted(data)) {
- pass_ptrA password((char*)CallFunctionSync(EnterPassword, this));
- if (password == nullptr) {
+ pass_ptrA password(mir_utf8encodeW(pass_ptrW((wchar_t*)CallFunctionSync(EnterPassword, this))));
+ if (mir_strlen(password) == 0) {
mir_free(data);
return false;
}
@@ -91,7 +89,6 @@ bool CToxProto::LoadToxProfile(Tox_Options *options)
mir_free(data);
data = decryptedData;
size = decryptedSize;
- return true;
}
if (data) {
@@ -146,6 +143,13 @@ void CToxProto::SaveToxProfile(Tox *tox)
mir_free(data);
}
+int CToxProto::OnDeleteToxProfile()
+{
+ ptrW profilePath(GetToxProfilePath());
+ _wunlink(profilePath);
+ return 0;
+}
+
INT_PTR CToxProto::OnCopyToxID(WPARAM, LPARAM)
{
ptrA address(getStringA(TOX_SETTINGS_ID));
@@ -161,29 +165,108 @@ INT_PTR CToxProto::OnCopyToxID(WPARAM, LPARAM)
return 0;
}
-CToxPasswordEditor::CToxPasswordEditor(CToxProto *proto) :
- CToxDlgBase(proto, IDD_PASSWORD, false), m_ok(this, IDOK),
- m_password(this, IDC_PASSWORD), m_savePermanently(this, IDC_SAVEPERMANENTLY)
+INT_PTR CToxProto::OnChangePassword(WPARAM, LPARAM)
+{
+ CToxChangePasswordDlg passwordDlg(this);
+ return passwordDlg.DoModal();
+}
+
+/* CHANGE PASSWORD */
+
+CToxChangePasswordDlg::CToxChangePasswordDlg(CToxProto *proto)
+ : CToxDlgBase(proto, IDD_PASSWORD_CHANGE, false),
+ m_oldPassword(this, IDC_PASSWORD),
+ m_newPassword(this, IDC_PASSWORD_NEW),
+ m_confirmPassword(this, IDC_PASSWORD_CONFIRM),
+ m_passwordValidation(this, IDC_PASSWORD_VALIDATION),
+ m_ok(this, IDOK)
+{
+ m_oldPassword.OnChange = Callback(this, &CToxChangePasswordDlg::Password_OnChange);
+ m_newPassword.OnChange = Callback(this, &CToxChangePasswordDlg::Password_OnChange);
+ m_confirmPassword.OnChange = Callback(this, &CToxChangePasswordDlg::Password_OnChange);
+ m_ok.OnClick = Callback(this, &CToxChangePasswordDlg::OnOk);
+}
+
+void CToxChangePasswordDlg::OnInitDialog()
+{
+ pass_ptrW password(m_proto->getWStringA("Password"));
+ if (mir_wstrlen(password) == 0)
+ m_oldPassword.Disable();
+ m_ok.Disable();
+}
+
+void CToxChangePasswordDlg::Password_OnChange(CCtrlBase*)
+{
+ pass_ptrW password(m_proto->getWStringA("Password"));
+ pass_ptrW oldPassword(m_oldPassword.GetText());
+ if (mir_wstrlen(password) > 0 && mir_wstrcmp(password, oldPassword) != 0) {
+ m_ok.Disable();
+ m_passwordValidation.SetText(TranslateT("Old password is not valid"));
+ return;
+ }
+
+ pass_ptrW newPassword(m_newPassword.GetText());
+ if (mir_wstrlen(newPassword) == 0) {
+ m_ok.Disable();
+ m_passwordValidation.SetText(TranslateT("New password is empty"));
+ return;
+ }
+
+ pass_ptrW confirmPassword(m_confirmPassword.GetText());
+ if (mir_wstrcmp(newPassword, confirmPassword) != 0) {
+ m_ok.Disable();
+ m_passwordValidation.SetText(TranslateT("New password is not equal to confirmation"));
+ return;
+ }
+
+ m_passwordValidation.SetText(L"");
+ m_ok.Enable();
+}
+
+void CToxChangePasswordDlg::OnOk(CCtrlButton*)
+{
+ //if(m_proto->m_savePermanently.Enabled())
+ m_proto->setWString("Password", pass_ptrT(m_newPassword.GetText()));
+ m_proto->SaveToxProfile(m_proto->toxThread->Tox());
+ EndDialog(m_hwnd, 1);
+}
+
+wchar_t* CToxChangePasswordDlg::GetPassword()
+{
+ return m_newPassword.GetText();
+}
+
+/* ENTER PASSWORD */
+
+CToxEnterPasswordDlg::CToxEnterPasswordDlg(CToxProto *proto)
+ : CToxDlgBase(proto, IDD_PASSWORD_ENTER, false),
+ m_password(this, IDC_PASSWORD),
+ m_savePermanently(this, IDC_SAVEPERMANENTLY),
+ m_ok(this, IDOK)
+{
+ //m_savePermanently
+ m_password.OnChange = Callback(this, &CToxEnterPasswordDlg::Password_OnChange);
+ m_ok.OnClick = Callback(this, &CToxEnterPasswordDlg::OnOk);
+}
+
+void CToxEnterPasswordDlg::OnInitDialog()
{
- m_password.OnChange = Callback(this, &CToxPasswordEditor::OnOk);
- m_ok.OnClick = Callback(this, &CToxPasswordEditor::OnOk);
m_ok.Disable();
}
-void CToxPasswordEditor::OnChange(CCtrlBase*)
+void CToxEnterPasswordDlg::Password_OnChange(CCtrlBase*)
{
m_ok.Enable(GetWindowTextLength(m_password.GetHwnd()) != 0);
}
-void CToxPasswordEditor::OnOk(CCtrlButton*)
+void CToxEnterPasswordDlg::OnOk(CCtrlButton*)
{
- pass_ptrT tszPassword(m_password.GetText());
if (m_savePermanently.Enabled())
- m_proto->setWString("Password", tszPassword);
+ m_proto->setWString("Password", pass_ptrT(m_password.GetText()));
EndDialog(m_hwnd, 1);
}
-wchar_t* CToxPasswordEditor::GetPassword()
+wchar_t* CToxEnterPasswordDlg::GetPassword()
{
return m_password.GetText();
}
diff --git a/protocols/Tox/src/tox_profile.h b/protocols/Tox/src/tox_profile.h
index 6a0b31f1f5..446a4b7c03 100644
--- a/protocols/Tox/src/tox_profile.h
+++ b/protocols/Tox/src/tox_profile.h
@@ -1,7 +1,9 @@
#ifndef _TOX_PROFILE_H_
#define _TOX_PROFILE_H_
-class CToxPasswordEditor : public CToxDlgBase
+/* ENTER PASSWORD */
+
+class CToxEnterPasswordDlg : public CToxDlgBase
{
private:
CCtrlEdit m_password;
@@ -10,11 +12,36 @@ private:
CCtrlButton m_ok;
protected:
- void OnChange(CCtrlBase*);
+ void OnInitDialog();
+ void Password_OnChange(CCtrlBase*);
+ void OnOk(CCtrlButton*);
+
+public:
+ CToxEnterPasswordDlg(CToxProto *proto);
+
+ wchar_t* GetPassword();
+};
+
+/* CHANGE PASSWORD */
+
+class CToxChangePasswordDlg : public CToxDlgBase
+{
+private:
+ CCtrlEdit m_oldPassword;
+
+ CCtrlEdit m_newPassword;
+ CCtrlEdit m_confirmPassword;
+
+ CCtrlBase m_passwordValidation;
+ CCtrlButton m_ok;
+
+protected:
+ void OnInitDialog();
+ void Password_OnChange(CCtrlBase*);
void OnOk(CCtrlButton*);
public:
- CToxPasswordEditor(CToxProto *proto);
+ CToxChangePasswordDlg(CToxProto *proto);
wchar_t* GetPassword();
};
diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp
index 7e4036f92a..419ef2ff2a 100644
--- a/protocols/Tox/src/tox_proto.cpp
+++ b/protocols/Tox/src/tox_proto.cpp
@@ -143,15 +143,13 @@ int CToxProto::SetStatus(int iNewStatus)
int old_status = m_iStatus;
m_iDesiredStatus = iNewStatus;
+ // logout
if (iNewStatus == ID_STATUS_OFFLINE) {
- // logout
isTerminated = true;
SetEvent(hTerminateEvent);
- if (!Miranda_IsTerminated()) {
+ if (!Miranda_IsTerminated())
SetAllContactsStatus(ID_STATUS_OFFLINE);
- //CloseAllChatChatSessions();
- }
m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE;
ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus);
@@ -161,19 +159,20 @@ int CToxProto::SetStatus(int iNewStatus)
if (old_status >= ID_STATUS_CONNECTING && old_status < ID_STATUS_OFFLINE)
return 0;
+ // login
if (old_status == ID_STATUS_OFFLINE && !IsOnline()) {
- // login
isTerminated = false;
m_iStatus = ID_STATUS_CONNECTING;
hPollingThread = ForkThreadEx(&CToxProto::PollingThread, nullptr, nullptr);
+ ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus);
+ return 0;
}
- else {
- // set tox status
- m_iStatus = iNewStatus;
- tox_self_set_status(toxThread->Tox(), MirandaToToxStatus(iNewStatus));
- }
-
+
+ // change status
+ m_iStatus = iNewStatus;
+ tox_self_set_status(toxThread->Tox(), MirandaToToxStatus(iNewStatus));
ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus);
+
return 0;
}
@@ -220,9 +219,7 @@ int CToxProto::OnEvent(PROTOEVENTTYPE iEventType, WPARAM wParam, LPARAM lParam)
return OnInitStatusMenu();
case EV_PROTO_ONERASE:
- ptrW profilePath(GetToxProfilePath());
- _wunlink(profilePath);
- break;
+ return OnDeleteToxProfile();
}
return 1;
diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h
index 4eb2bee085..8e88d7bca1 100644
--- a/protocols/Tox/src/tox_proto.h
+++ b/protocols/Tox/src/tox_proto.h
@@ -3,7 +3,8 @@
struct CToxProto : public PROTO<CToxProto>
{
- friend CToxPasswordEditor;
+ friend CToxChangePasswordDlg;
+ friend CToxEnterPasswordDlg;
friend CToxOptionsMain;
friend CToxOptionsNodeList;
@@ -54,16 +55,13 @@ public:
static void InitIcons();
// menus
- static void InitMenus();
-
- // events
- void InitCustomDbEvents();
-
- static int OnModulesLoaded(WPARAM, LPARAM);
+ static void InitContactMenu();
// utils
static void ShowNotification(const wchar_t *message, int flags = 0, MCONTACT hContact = NULL);
+ static INT_PTR ParseToxUri(WPARAM, LPARAM lParam);
+
private:
CToxThread *toxThread;
mir_cs profileLock;
@@ -86,8 +84,10 @@ private:
bool LoadToxProfile(Tox_Options *options);
void SaveToxProfile(Tox *tox);
+ int OnDeleteToxProfile();
INT_PTR __cdecl OnCopyToxID(WPARAM, LPARAM);
+ INT_PTR __cdecl OnChangePassword(WPARAM, LPARAM);
// tox core
Tox_Options* GetToxOptions();
@@ -137,7 +137,9 @@ private:
int OnPrebuildContactMenu(WPARAM hContact, LPARAM);
static int PrebuildContactMenu(WPARAM hContact, LPARAM lParam);
+ HGENMENU StatusMenuItems[SMI_MAX];
int OnInitStatusMenu();
+ int __cdecl PrebuildStatusMenu(WPARAM, LPARAM);
//services
INT_PTR __cdecl SetMyNickname(WPARAM wParam, LPARAM lParam);
@@ -145,8 +147,6 @@ private:
// options
int __cdecl OnOptionsInit(WPARAM wParam, LPARAM lParam);
- // events
-
// userinfo
static INT_PTR CALLBACK UserInfoProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
int __cdecl OnUserInfoInit(WPARAM wParam, LPARAM lParam);
@@ -189,35 +189,11 @@ private:
HWND __cdecl OnSearchAdvanced(HWND owner);
HWND __cdecl OnCreateExtendedSearchUI(HWND owner);
- // chat rooms
- //MCONTACT GetChatRoom(const char *pubKey);
- MCONTACT GetChatRoom(int groupNumber);
-
- //MCONTACT GetChatRoom(const char *pubKey);
- MCONTACT AddChatRoom(int groupNumber);
-
- void __cdecl LoadChatRoomList(void*);
-
- int __cdecl OnGroupChatEventHook(WPARAM, LPARAM lParam);
- int __cdecl OnGroupChatMenuHook(WPARAM, LPARAM lParam);
-
- INT_PTR __cdecl OnJoinChatRoom(WPARAM hContact, LPARAM);
- INT_PTR __cdecl OnLeaveChatRoom(WPARAM hContact, LPARAM);
- INT_PTR __cdecl OnCreateChatRoom(WPARAM, LPARAM);
-
- //void InitGroupChatModule();
- //void CloseAllChatChatSessions();
-
- static void OnGroupChatInvite(Tox *tox, int32_t friendNumber, uint8_t type, const uint8_t *data, const uint16_t length, void *arg);
-
- void ChatValidateContact(HWND hwndList, const std::vector<MCONTACT> &contacts, MCONTACT hContact = NULL);
- void ChatPrepare(HWND hwndList, const std::vector<MCONTACT> &contacts, MCONTACT hContact = NULL);
- static std::vector<MCONTACT> GetInvitedContacts(HWND hwndList, MCONTACT hContact = NULL);
- static INT_PTR CALLBACK ChatRoomInviteProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-
// messages
std::map<uint64_t, UINT> messages;
+ void InitCustomDbEvents();
+
void __cdecl SendMessageAsync(void *arg);
int OnSendMessage(MCONTACT hContact, const char *message);
@@ -276,8 +252,6 @@ private:
MEVENT AddEventToDb(MCONTACT hContact, WORD type, DWORD timestamp, DWORD flags, PBYTE pBlob, size_t cbBlob);
- static INT_PTR ParseToxUri(WPARAM, LPARAM lParam);
-
template<INT_PTR(__cdecl CToxProto::*Service)(WPARAM, LPARAM)>
static INT_PTR __cdecl GlobalService(WPARAM wParam, LPARAM lParam)
{