Browse Source

add pEp_import calling support

argv Release_2.0.0.RC1
Claudio Luck 10 months ago
parent
commit
2319ac4ffb
3 changed files with 32 additions and 6 deletions
  1. +28
    -6
      src/tb_setup.cc
  2. +3
    -0
      src/tb_setup.h
  3. +1
    -0
      src/tb_setup_events.h

+ 28
- 6
src/tb_setup.cc View File

@ -29,6 +29,7 @@ using namespace redi;
wxIMPLEMENT_APP(TbSetupApp);
#define PEP_TBSETUP_OPT_SCRIPT "script"
#define PEP_TBSETUP_OPT_IMPORT_SCRIPT "import-script"
#define PEP_TBSETUP_OPT_WITH_UNINSTALL "with-uninstall"
#define PEP_TBSETUP_OPT_ADAP_PKG_VER "adapter-package-version"
#define PEP_TBSETUP_OPT_ADAP_PKG_PLAT "adapter-package-platform"
@ -49,6 +50,9 @@ static const wxCmdLineEntryDesc g_cmdLineDesc [] =
{ wxCMD_LINE_OPTION, "s", PEP_TBSETUP_OPT_SCRIPT,
"internal install script",
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
{ wxCMD_LINE_OPTION, "I", PEP_TBSETUP_OPT_IMPORT_SCRIPT,
"internal data import script",
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
{ wxCMD_LINE_OPTION, NULL, PEP_TBSETUP_OPT_ADAP_PKG_VER,
"adapter package version to install",
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
@ -78,6 +82,8 @@ bool TbSetupApp::OnCmdLineParsed(wxCmdLineParser& parser)
m_opt_prefer_user_install = parser.Found(PEP_TBSETUP_OPT_USER_INSTALL);
if (parser.Found(PEP_TBSETUP_OPT_SCRIPT, &s))
m_opt_script = s.ToStdString();
if (parser.Found(PEP_TBSETUP_OPT_IMPORT_SCRIPT, &s))
m_opt_import_script = s.ToStdString();
if (parser.Found(PEP_TBSETUP_OPT_ADAP_PKG_VER, &s))
m_opt_adapter_package_ver = s.ToStdString();
if (parser.Found(PEP_TBSETUP_OPT_ADAP_PKG_PLAT, &s))
@ -109,6 +115,7 @@ bool TbSetupApp::OnCmdLineParsed(wxCmdLineParser& parser)
bool xdg_pref_user = reader.GetBoolean("Desktop Entry", "X-pEp-Prefer-User-Install", m_opt_prefer_user_install);
string xdg_script = reader.Get("Desktop Entry", "X-pEp-Exec", "");
string xdg_imp_script = reader.Get("Desktop Entry", "X-pEp-Import-Exec", "");
string xdg_mda_ver = reader.Get("Desktop Entry", "X-pEp-MDA-Version", "");
string xdg_mda_plat = reader.Get("Desktop Entry", "X-pEp-MDA-Platform", "");
string xdg_mda_os = reader.Get("Desktop Entry", "X-pEp-MDA-OS", "");
@ -116,6 +123,8 @@ bool TbSetupApp::OnCmdLineParsed(wxCmdLineParser& parser)
m_opt_prefer_user_install = xdg_pref_user;
if (xdg_script.length())
m_opt_script = xdg_script;
if (xdg_imp_script.length())
m_opt_import_script = xdg_imp_script;
if (xdg_mda_ver.length())
m_opt_adapter_package_ver = xdg_mda_ver;
if (xdg_mda_plat.length())
@ -135,6 +144,7 @@ bool TbSetupApp::OnInit()
Bind(pEpWxEvt_TbSetup, &TbSetupApp::OnStartSetup, this, PEP_TBSETUP_START_SETUP);
Bind(pEpWxEvt_TbSetup, &TbSetupApp::OnStartUninstall, this, PEP_TBSETUP_START_UNINSTALL);
Bind(pEpWxEvt_TbSetup, &TbSetupApp::OnInteractionComplete, this, PEP_TBSETUP_INTERACTION_COMPLETED);
Bind(pEpWxEvt_TbSetup, &TbSetupApp::OnInteractionCheckPending, this, PEP_TBSETUP_INTERACTION_CHECK_PENDING);
Bind(pEpWxEvt_TbSetup, &TbSetupApp::OnAdminPasswordRequired, this, PEP_TBSETUP_ADMIN_PASSWORD_REQUIRED);
Bind(pEpWxEvt_TbSetup, &TbSetupApp::OnAdminPasswordProvided, this, PEP_TBSETUP_ADMIN_PASSWORD_ENTERED);
Bind(pEpWxEvt_TbSetup, &TbSetupApp::OnClose, this, PEP_TBSETUP_CLOSE);
@ -147,11 +157,6 @@ bool TbSetupApp::OnInit()
void TbSetupApp::OnStartSetup(wxCommandEvent& event)
{
m_windowFrame->ResetLogText();
cout << "A ver: " << m_opt_adapter_package_ver << endl;
cout << "A plat: " << m_opt_adapter_package_plat << endl;
cout << "A os: " << m_opt_adapter_package_os << endl;
cout << "Script: " << m_opt_script << endl;
string cmd = Abspath(m_opt_script.c_str());
string sfx = "";
if (m_opt_xdg.length())
@ -159,6 +164,7 @@ void TbSetupApp::OnStartSetup(wxCommandEvent& event)
if (!(this->th_interact))
{
m_windowFrame->EnableForward(0);
m_import_script_pending = true;
if (m_windowFrame->IsSystemInstall())
{
cmd += " --system" + sfx;
@ -197,6 +203,22 @@ void TbSetupApp::OnStartUninstall(wxCommandEvent& event)
}
}
void TbSetupApp::OnInteractionCheckPending(wxCommandEvent& event)
{
bool deferred = false;
if (m_import_script_pending)
{
m_import_script_pending = false;
if (m_opt_import_script.length())
{
this->th_interact = new std::thread(&TbSetupApp::Interact, this, m_opt_import_script);
deferred = true;
}
}
if (!deferred)
wxPostEvent(this, wxCommandEvent(pEpWxEvt_TbSetup, PEP_TBSETUP_INTERACTION_COMPLETED));
}
void TbSetupApp::OnAdminPasswordRequired(wxCommandEvent& event)
{
m_windowFrame->EnablePasswordPrompt(true, true);
@ -371,7 +393,7 @@ int TbSetupApp::Interact(string cmd)
data_written = werr.pos() + wout.pos();
}
m_script = NULL;
wxPostEvent(this, wxCommandEvent(pEpWxEvt_TbSetup, PEP_TBSETUP_INTERACTION_COMPLETED));
wxPostEvent(this, wxCommandEvent(pEpWxEvt_TbSetup, PEP_TBSETUP_INTERACTION_CHECK_PENDING));
return 0;
}


+ 3
- 0
src/tb_setup.h View File

@ -23,6 +23,8 @@ protected:
string m_opt_xdg = "";
bool m_opt_prefer_user_install = false;
string m_opt_script = "./asrootbin";
string m_opt_import_script = "./pEp_import";
bool m_import_script_pending = false;
string m_opt_adapter_package_ver = "2.0.0";
string m_opt_adapter_package_plat = "x86_64";
#if __linux__
@ -47,6 +49,7 @@ public:
void OnAdminPasswordRequired(wxCommandEvent&);
void OnAdminPasswordProvided(wxCommandEvent&);
void OnInteractionComplete(wxCommandEvent&);
void OnInteractionCheckPending(wxCommandEvent&);
void OnClose(wxCommandEvent&);
int InteractElevated(string);
int Interact(string);


+ 1
- 0
src/tb_setup_events.h View File

@ -11,6 +11,7 @@ enum {
PEP_TBSETUP_START_UNINSTALL,
PEP_TBSETUP_ADMIN_PASSWORD_REQUIRED,
PEP_TBSETUP_ADMIN_PASSWORD_ENTERED,
PEP_TBSETUP_INTERACTION_CHECK_PENDING,
PEP_TBSETUP_INTERACTION_COMPLETED,
PEP_TBSETUP_CLOSE,
PEP_TBSETUP_LOG,


Loading…
Cancel
Save