diff options
Diffstat (limited to 'protocols/Tox/src')
-rw-r--r-- | protocols/Tox/src/resource.h | 8 | ||||
-rw-r--r-- | protocols/Tox/src/tox_accounts.cpp | 15 | ||||
-rw-r--r-- | protocols/Tox/src/tox_core.cpp | 12 | ||||
-rw-r--r-- | protocols/Tox/src/tox_options.cpp | 153 | ||||
-rw-r--r-- | protocols/Tox/src/tox_profile.cpp | 79 |
5 files changed, 121 insertions, 146 deletions
diff --git a/protocols/Tox/src/resource.h b/protocols/Tox/src/resource.h index 0d79a20d1e..044399e482 100644 --- a/protocols/Tox/src/resource.h +++ b/protocols/Tox/src/resource.h @@ -1,10 +1,9 @@ //{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
-// Used by e:\Projects\C++\MirandaNG\protocols\Tox\res\resource.rc
+// Used by d:\Miranda_orig\protocols\Tox\res\resource.rc
//
#define IDD_USER_INFO 101
#define IDD_PASSWORD 102
-#define IDD_PROFILE_IMPORT 103
#define IDD_ACCOUNT_MANAGER 104
#define IDD_SEARCH 105
#define IDD_OPTIONS_MAIN 106
@@ -14,10 +13,8 @@ #define IDI_TOX 120
#define IDC_TOXID 1001
#define IDC_CLIPBOARD 1002
-#define IDC_PROFILE_PATH 1003
#define IDC_SEARCH 1004
#define IDC_PASSWORD 1005
-#define IDC_BROWSE_PROFILE 1006
#define IDC_NAME 1007
#define IDC_GROUP 1008
#define IDC_DISABLE_UDP 1009
@@ -31,6 +28,7 @@ #define IDC_IPV6 1019
#define IDC_PORT 1020
#define IDC_PKEY 1021
+#define IDC_IMPORT_PROFILE 1024
// Next default values for new objects
//
@@ -38,7 +36,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 108
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1024
+#define _APS_NEXT_CONTROL_VALUE 1025
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/protocols/Tox/src/tox_accounts.cpp b/protocols/Tox/src/tox_accounts.cpp index 369fbf5fdd..2e18334a4c 100644 --- a/protocols/Tox/src/tox_accounts.cpp +++ b/protocols/Tox/src/tox_accounts.cpp @@ -9,21 +9,8 @@ int CToxProto::CompareAccounts(const CToxProto *p1, const CToxProto *p2) CToxProto* CToxProto::InitAccount(const char *protoName, const wchar_t *userName)
{
- ptrA address(db_get_sa(NULL, protoName, TOX_SETTINGS_ID));
- if (address == NULL)
- {
- if (DialogBoxParam(
- g_hInstance,
- MAKEINTRESOURCE(IDD_PROFILE_IMPORT),
- GetActiveWindow(),
- CToxProto::ToxProfileImportProc,
- (LPARAM)userName) == IDOK)
- {
- db_set_s(NULL, protoName, TOX_SETTINGS_ID, "");
- }
- }
-
CToxProto *proto = new CToxProto(protoName, userName);
+ accounts.insert(proto);
return proto;
}
diff --git a/protocols/Tox/src/tox_core.cpp b/protocols/Tox/src/tox_core.cpp index 7d97b875f0..0cd6e045c3 100644 --- a/protocols/Tox/src/tox_core.cpp +++ b/protocols/Tox/src/tox_core.cpp @@ -58,13 +58,19 @@ bool CToxProto::InitToxCore() uint8_t data[TOX_FRIEND_ADDRESS_SIZE];
tox_get_address(tox, data);
ToxHexAddress address(data, TOX_FRIEND_ADDRESS_SIZE);
- setString(NULL, TOX_SETTINGS_ID, address);
+ setString(TOX_SETTINGS_ID, address);
int size = tox_get_self_name_size(tox);
std::string nick(size, 0);
tox_get_self_name(tox, (uint8_t*)nick.data());
setWString("Nick", ptrW(Utf8DecodeW(nick.c_str())));
+ //temporary
+ size = tox_get_self_status_message_size(tox);
+ std::string statusmes(size, 0);
+ tox_get_self_status_message(tox, (uint8_t*)statusmes.data(), size);
+ setWString("StatusMsg", ptrW(Utf8DecodeW(statusmes.c_str())));
+
std::tstring avatarPath = GetAvatarFilePath();
if (IsFileExists(avatarPath))
{
@@ -98,6 +104,10 @@ void CToxProto::UninitToxCore() ptrA nickname(mir_utf8encodeW(ptrT(getTStringA("Nick"))));
tox_set_name(tox, (uint8_t*)(char*)nickname, mir_strlen(nickname));
+ //temporary
+ ptrA statusmes(mir_utf8encodeW(ptrT(getTStringA("StatusMsg"))));
+ tox_set_status_message(tox, (uint8_t*)(char*)statusmes, mir_strlen(statusmes));
+
SaveToxProfile();
if (password != NULL)
{
diff --git a/protocols/Tox/src/tox_options.cpp b/protocols/Tox/src/tox_options.cpp index b56bd1d9cf..8c05d633e8 100644 --- a/protocols/Tox/src/tox_options.cpp +++ b/protocols/Tox/src/tox_options.cpp @@ -27,7 +27,10 @@ INT_PTR CToxProto::MainOptionsProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l }
ptrT group(proto->getTStringA(TOX_SETTINGS_GROUP));
- SetDlgItemText(hwnd, IDC_GROUP, group);
+ if (group)
+ SetDlgItemText(hwnd, IDC_GROUP, group);
+ else
+ SetDlgItemText(hwnd, IDC_GROUP, _T("Tox"));
SendDlgItemMessage(hwnd, IDC_GROUP, EM_LIMITTEXT, 64, 0);
CheckDlgButton(hwnd, IDC_DISABLE_UDP, proto->getBool("DisableUDP", 0));
@@ -53,9 +56,8 @@ INT_PTR CToxProto::MainOptionsProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l case IDC_DISABLE_IPV6:
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
break;
- }
- case IDC_CLIPBOARD:
+ case IDC_CLIPBOARD:
{
char toxId[TOX_FRIEND_ADDRESS_SIZE * 2 + 1];
GetDlgItemTextA(hwnd, IDC_TOXID, toxId, SIZEOF(toxId));
@@ -70,6 +72,63 @@ INT_PTR CToxProto::MainOptionsProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l }
}
break;
+
+ case IDC_IMPORT_PROFILE:
+ {
+ 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;
+ ofn.lpstrFilter = filter;
+ ofn.nFilterIndex = 1;
+ ofn.lpstrFile = profilePath;
+ ofn.lpstrTitle = TranslateT("Select tox profile");
+ ofn.nMaxFile = MAX_PATH;
+ ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_EXPLORER;
+
+ if (GetOpenFileName(&ofn)) {
+ std::tstring defaultProfilePath = GetToxProfilePath(proto->accountName);
+ if (profilePath && _tcslen(profilePath))
+ {
+ if (_tcsicmp(profilePath, defaultProfilePath.c_str()) != 0)
+ {
+ CopyFile(profilePath, defaultProfilePath.c_str(), FALSE);
+ }
+ }
+
+ proto->InitToxCore();
+ TCHAR group[64];
+ GetDlgItemText(hwnd, IDC_GROUP, group, SIZEOF(group));
+ if (_tcslen(group) > 0)
+ {
+ proto->setTString(TOX_SETTINGS_GROUP, group);
+ Clist_CreateGroup(0, group);
+ }
+ else
+ {
+ proto->delSetting(NULL, TOX_SETTINGS_GROUP);
+ }
+ proto->LoadFriendList((void*)0);
+ proto->UninitToxCore();
+
+ ptrT nick(proto->getTStringA("Nick"));
+ SetDlgItemText(hwnd, IDC_NAME, nick);
+
+ ptrT pass(proto->getTStringA("Password"));
+ SetDlgItemText(hwnd, IDC_PASSWORD, pass);
+
+ ptrA address(proto->getStringA(TOX_SETTINGS_ID));
+ if (address != NULL)
+ {
+ SetDlgItemTextA(hwnd, IDC_TOXID, address);
+ }
+ }
+
+ }
+ break;
+ }
}
break;
@@ -94,7 +153,7 @@ INT_PTR CToxProto::MainOptionsProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l GetDlgItemText(hwnd, IDC_GROUP, group, SIZEOF(group));
if (_tcslen(group) > 0)
{
- proto->setTString(NULL, TOX_SETTINGS_GROUP, group);
+ proto->setTString(TOX_SETTINGS_GROUP, group);
Clist_CreateGroup(0, group);
}
else
@@ -414,55 +473,55 @@ INT_PTR CALLBACK ToxNodesOptionsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR break;
case PSN_APPLY:
- {
- char setting[MAX_PATH];
+ {
+ char setting[MAX_PATH];
- LVITEMA lvi = { 0 };
- lvi.mask = LVIF_TEXT;
- lvi.cchTextMax = MAX_PATH;
- lvi.pszText = (char*)mir_alloc(MAX_PATH);
+ LVITEMA lvi = { 0 };
+ lvi.mask = LVIF_TEXT;
+ lvi.cchTextMax = MAX_PATH;
+ lvi.pszText = (char*)mir_alloc(MAX_PATH);
- int itemCount = ListView_GetItemCount(hwndList);
- for (lvi.iItem = 0; lvi.iItem < itemCount; lvi.iItem++)
- {
- if (itemCount)
+ int itemCount = ListView_GetItemCount(hwndList);
+ for (lvi.iItem = 0; lvi.iItem < itemCount; lvi.iItem++)
+ {
+ if (itemCount)
lvi.iSubItem = 0;
- SendMessage(hwndList, LVM_GETITEMA, 0, (LPARAM)&lvi);
- mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_IPV4, lvi.iItem + 1);
- db_set_s(NULL, MODULE, setting, lvi.pszText);
-
- lvi.iSubItem = 1;
- SendMessage(hwndList, LVM_GETITEMA, 0, (LPARAM)&lvi);
- mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_IPV6, lvi.iItem + 1);
- db_set_s(NULL, MODULE, setting, lvi.pszText);
-
- lvi.iSubItem = 2;
- SendMessage(hwndList, LVM_GETITEMA, 0, (LPARAM)&lvi);
- mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_PORT, lvi.iItem + 1);
- db_set_w(NULL, MODULE, setting, atoi(lvi.pszText));
-
- lvi.iSubItem = 3;
- SendMessage(hwndList, LVM_GETITEMA, 0, (LPARAM)&lvi);
- mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_PKEY, lvi.iItem + 1);
- db_set_s(NULL, MODULE, setting, lvi.pszText);
- }
+ SendMessage(hwndList, LVM_GETITEMA, 0, (LPARAM)&lvi);
+ mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_IPV4, lvi.iItem + 1);
+ db_set_s(NULL, MODULE, setting, lvi.pszText);
- int nodeCount = db_get_b(NULL, MODULE, TOX_SETTINGS_NODE_COUNT, 0);
- for (lvi.iItem = itemCount; lvi.iItem < nodeCount; lvi.iItem++)
- {
- mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_IPV4, lvi.iItem + 1);
- db_unset(NULL, MODULE, setting);
- mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_IPV6, lvi.iItem + 1);
- db_unset(NULL, MODULE, setting);
- mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_PORT, lvi.iItem + 1);
- db_unset(NULL, MODULE, setting);
- mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_PKEY, lvi.iItem + 1);
- db_unset(NULL, MODULE, setting);
- }
+ lvi.iSubItem = 1;
+ SendMessage(hwndList, LVM_GETITEMA, 0, (LPARAM)&lvi);
+ mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_IPV6, lvi.iItem + 1);
+ db_set_s(NULL, MODULE, setting, lvi.pszText);
+
+ lvi.iSubItem = 2;
+ SendMessage(hwndList, LVM_GETITEMA, 0, (LPARAM)&lvi);
+ mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_PORT, lvi.iItem + 1);
+ db_set_w(NULL, MODULE, setting, atoi(lvi.pszText));
- db_set_b(NULL, MODULE, TOX_SETTINGS_NODE_COUNT, itemCount);
+ lvi.iSubItem = 3;
+ SendMessage(hwndList, LVM_GETITEMA, 0, (LPARAM)&lvi);
+ mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_PKEY, lvi.iItem + 1);
+ db_set_s(NULL, MODULE, setting, lvi.pszText);
}
- return TRUE;
+
+ int nodeCount = db_get_b(NULL, MODULE, TOX_SETTINGS_NODE_COUNT, 0);
+ for (lvi.iItem = itemCount; lvi.iItem < nodeCount; lvi.iItem++)
+ {
+ mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_IPV4, lvi.iItem + 1);
+ db_unset(NULL, MODULE, setting);
+ mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_IPV6, lvi.iItem + 1);
+ db_unset(NULL, MODULE, setting);
+ mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_PORT, lvi.iItem + 1);
+ db_unset(NULL, MODULE, setting);
+ mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_PKEY, lvi.iItem + 1);
+ db_unset(NULL, MODULE, setting);
+ }
+
+ db_set_b(NULL, MODULE, TOX_SETTINGS_NODE_COUNT, itemCount);
+ }
+ return TRUE;
}
}
return FALSE;
diff --git a/protocols/Tox/src/tox_profile.cpp b/protocols/Tox/src/tox_profile.cpp index f5a35c6629..a404d080ca 100644 --- a/protocols/Tox/src/tox_profile.cpp +++ b/protocols/Tox/src/tox_profile.cpp @@ -137,85 +137,6 @@ void CToxProto::SaveToxProfile() mir_free(data);
}
-INT_PTR CToxProto::ToxProfileImportProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- TCHAR *accountName = (TCHAR*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- TCHAR *profilePath = (TCHAR*)GetWindowLongPtr(hwnd, DWLP_USER);
-
- switch (uMsg)
- {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwnd);
- {
- accountName = (TCHAR*)lParam;
- SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam);
-
- profilePath = (TCHAR*)mir_calloc(sizeof(TCHAR)*MAX_PATH);
- SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)profilePath);
- }
- return TRUE;
-
- case WM_DESTROY:
- mir_free(profilePath);
- return TRUE;
-
- case WM_COMMAND:
- switch (LOWORD(wParam))
- {
- case IDC_PROFILE_PATH:
- if ((HWND)lParam == GetFocus())
- {
- if (HIWORD(wParam) != EN_CHANGE) return 0;
- EnableWindow(GetDlgItem(hwnd, IDOK), TRUE);
- }
- break;
-
- case IDC_BROWSE_PROFILE:
- {
- TCHAR filter[MAX_PATH] = { 0 };
- mir_sntprintf(filter, MAX_PATH, _T("%s\0*.*"), TranslateT("All files (*.*)"));
-
- OPENFILENAME ofn = { sizeof(ofn) };
- ofn.hwndOwner = hwnd;
- ofn.lpstrFilter = filter;
- ofn.nFilterIndex = 1;
- ofn.lpstrFile = profilePath;
- ofn.lpstrTitle = TranslateT("Select tox profile");
- ofn.nMaxFile = MAX_PATH;
- ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_EXPLORER;
-
- if (GetOpenFileName(&ofn) && profilePath)
- {
- EnableWindow(GetDlgItem(hwnd, IDOK), TRUE);
- SetDlgItemText(hwnd, IDC_PROFILE_PATH, profilePath);
- }
- }
- break;
-
- case IDOK:
- {
- std::tstring defaultProfilePath = GetToxProfilePath(accountName);
- if (profilePath && _tcslen(profilePath))
- {
- if (_tcsicmp(profilePath, defaultProfilePath.c_str()) != 0)
- {
- CopyFile(profilePath, defaultProfilePath.c_str(), FALSE);
- }
- }
- EndDialog(hwnd, 1);
- }
- break;
-
- case IDCANCEL:
- EndDialog(hwnd, 0);
- break;
- }
- break;
- }
-
- return FALSE;
-}
-
INT_PTR CToxProto::ToxProfilePasswordProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
CToxProto *proto = (CToxProto*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
|