summaryrefslogtreecommitdiff
path: root/protocols/Tox/src/tox_options.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-04-24 10:19:38 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-04-24 10:19:38 +0000
commit8c8b40f747b52bc5c8aa796b03ac5e7a2eb23eaf (patch)
tree6dbc4fe8a22ca14ba4d6eccfc794ed40cedd2374 /protocols/Tox/src/tox_options.cpp
parentab90002f47192dcbb88fe5926faf52299179d815 (diff)
Tox:
- fixed profile creation logic - enabled "export profile" button git-svn-id: http://svn.miranda-ng.org/main/trunk@13078 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tox/src/tox_options.cpp')
-rw-r--r--protocols/Tox/src/tox_options.cpp53
1 files changed, 50 insertions, 3 deletions
diff --git a/protocols/Tox/src/tox_options.cpp b/protocols/Tox/src/tox_options.cpp
index 8081a6a8d1..d80e08370e 100644
--- a/protocols/Tox/src/tox_options.cpp
+++ b/protocols/Tox/src/tox_options.cpp
@@ -35,7 +35,7 @@ void CToxOptionsMain::OnInitDialog()
ShowWindow(m_profileImport.GetHwnd(), FALSE);
ShowWindow(m_toxAddressCopy.GetHwnd(), TRUE);
- //ShowWindow(m_profileExport.GetHwnd(), TRUE);
+ ShowWindow(m_profileExport.GetHwnd(), TRUE);
}
if (m_proto->IsOnline())
@@ -68,6 +68,26 @@ void CToxOptionsMain::ToxAddressCopy_OnClick(CCtrlButton*)
void CToxOptionsMain::ProfileCreate_OnClick(CCtrlButton*)
{
+ std::tstring profilePath = m_proto->GetToxProfilePath();
+ if (!m_proto->IsFileExists(profilePath))
+ {
+ HANDLE hProfile = CreateFile(profilePath.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
+ if (hProfile == NULL)
+ {
+ // TODO: warh error
+ return;
+ }
+ CloseHandle(hProfile);
+
+ TOX_ERR_NEW initError;
+ m_proto->tox = tox_new(NULL, NULL, 0, &initError);
+ if (initError != TOX_ERR_NEW_OK)
+ {
+ // TODO: warh error
+ return;
+ }
+ }
+
if (m_proto->InitToxCore())
{
TCHAR *group = m_group.GetText();
@@ -88,7 +108,7 @@ void CToxOptionsMain::ProfileCreate_OnClick(CCtrlButton*)
ShowWindow(m_profileImport.GetHwnd(), FALSE);
ShowWindow(m_toxAddressCopy.GetHwnd(), TRUE);
- //ShowWindow(m_profileExport.GetHwnd(), TRUE);
+ ShowWindow(m_profileExport.GetHwnd(), TRUE);
}
}
@@ -116,7 +136,7 @@ void CToxOptionsMain::ProfileImport_OnClick(CCtrlButton*)
}
std::tstring defaultProfilePath = m_proto->GetToxProfilePath();
- if (_tcsicmp(profilePath, defaultProfilePath.c_str()) != 0)
+ if (mir_tstrcmpi(profilePath, defaultProfilePath.c_str()) != 0)
{
CopyFile(profilePath, defaultProfilePath.c_str(), FALSE);
}
@@ -126,6 +146,33 @@ void CToxOptionsMain::ProfileImport_OnClick(CCtrlButton*)
void CToxOptionsMain::ProfileExport_OnClick(CCtrlButton*)
{
+ TCHAR filter[MAX_PATH];
+ mir_sntprintf(filter, SIZEOF(filter), _T("%s(*.tox)%c*.tox%c%c"),
+ TranslateT("Tox profile"), 0, 0, 0);
+
+ TCHAR profilePath[MAX_PATH];
+ mir_tstrncpy(profilePath, _T("tox_save.tox"), SIZEOF(profilePath));
+
+ OPENFILENAME ofn = { sizeof(ofn) };
+ ofn.hwndOwner = m_hwnd;
+ ofn.lpstrFilter = filter;
+ ofn.nFilterIndex = 0;
+ ofn.lpstrFile = profilePath;
+ ofn.lpstrTitle = TranslateT("Save tox profile");\
+ ofn.nMaxFile = MAX_PATH;
+ ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_EXPLORER;
+ ofn.lpstrInitialDir = _T("%HOMEPATH%");
+
+ if (!GetSaveFileName(&ofn))
+ {
+ return;
+ }
+
+ std::tstring defaultProfilePath = m_proto->GetToxProfilePath();
+ if (mir_tstrcmpi(profilePath, defaultProfilePath.c_str()) != 0)
+ {
+ CopyFile(defaultProfilePath.c_str(), profilePath, FALSE);
+ }
}
void CToxOptionsMain::OnApply()