Skip to content

Commit

Permalink
Use new settings handling in VSS component selection
Browse files Browse the repository at this point in the history
  • Loading branch information
uroni committed Jul 12, 2020
1 parent 64862ae commit cf5933d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
36 changes: 28 additions & 8 deletions SelectWindowsComponents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ SelectWindowsComponents::SelectWindowsComponents(wxWindow * parent)
settings = new CFileSettingsReader(VARDIR "/urbackup/data/settings.cfg");
#endif

use_orig = 0;
std::string use_orig_str;
if (settings->getValue("vss_select_components.use", &use_orig_str))
use_orig = atoi(use_orig_str.c_str());

use_lm_orig = 0;
std::string use_lm_orig_str;
if (settings->getValue("vss_select_components.use_lm", &use_lm_orig_str))
wxString(use_lm_orig_str).ToLongLong(&use_lm_orig);

componentReader.Run();
}

Expand Down Expand Up @@ -80,10 +90,7 @@ void SelectWindowsComponents::Notify(void)
m_treeCtrl1->SetImageList(iconList);

std::string componentsStr = "default=1";
if (!settings->getValue("vss_select_components", &componentsStr))
{
settings->getValue("vss_select_components_def", &componentsStr);
}
settings->getValue("vss_select_components.client", &componentsStr);

std::map<std::string, std::string> comps;
ParseParamStrHttp(componentsStr, &comps);
Expand Down Expand Up @@ -192,8 +199,6 @@ void SelectWindowsComponents::evtOnTreeStateImageClick(wxTreeEvent & event)

void SelectWindowsComponents::onOkClick(wxCommandEvent & event)
{
std::map<std::string, std::string> n_vals;

std::string res;
if (m_treeCtrl1->GetItemState(tree_items[componentReader.getRoot()]) == 1)
{
Expand All @@ -205,9 +210,24 @@ void SelectWindowsComponents::onOkClick(wxCommandEvent & event)
collectComponents(componentReader.getRoot(), idx, res);
}

n_vals["vss_select_components"] = res;
int use = use_orig;

use |= c_use_value_client;

std::string s_data = "vss_select_components=" + res+"\n";

if (use != use_orig)
{
s_data += "vss_select_components.use=" + nconvert(use) + "\n";
int64 ctime = wxGetUTCTimeMillis().GetValue() / 1000;

if (use_lm_orig > ctime)
ctime = use_lm_orig + 1;

s_data += "default_dirs.use_lm=" + nconvert(ctime) + "\n";
}

Connector::updateSettings(Settings::mergeNewSettings(settings, n_vals));
Connector::updateSettings(s_data);

Close();
}
Expand Down
5 changes: 5 additions & 0 deletions SelectWindowsComponents.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <vector>
#include <map>

typedef wxLongLong_t int64;

struct SComponent
{
SComponent()
Expand Down Expand Up @@ -99,6 +101,9 @@ class SelectWindowsComponents : public GUIWindowsComponents, public wxTimer

int icon_width;
int icon_height;

int use_orig;
int64 use_lm_orig;
};

namespace
Expand Down

0 comments on commit cf5933d

Please sign in to comment.