Menu

[r13158]: / trunk / src / sdk / scriptsecuritywarningdlg.cpp  Maximize  Restore  History

Download this file

83 lines (72 with data), 2.7 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
* This file is part of the Code::Blocks IDE and licensed under the GNU Lesser General Public License, version 3
* http://www.gnu.org/licenses/lgpl-3.0.html
*
* $Revision$
* $Id$
* $HeadURL$
*/
#include "sdk_precomp.h"
#include "scriptsecuritywarningdlg.h"
#ifndef CB_PRECOMP
#include <wx/button.h>
#include <wx/combobox.h>
#include <wx/intl.h>
#include <wx/settings.h>
#include <wx/stattext.h>
#include <wx/textctrl.h>
#include <wx/xrc/xmlres.h>
#endif // CB_PRECOMP
ScriptSecurityWarningDlg::ScriptSecurityWarningDlg(wxWindow* parent, const wxString& operation, const wxString& command, bool hasPath)
{
//ctor
m_hasPath = hasPath;
wxXmlResource::Get()->LoadObject(this, parent, "ScriptingSecurityDlg", "wxScrollingDialog");
XRCCTRL(*this, "wxID_OK", wxButton)->SetDefault();
wxColour c = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE);
XRCCTRL(*this, "txtCommand", wxTextCtrl)->SetBackgroundColour(c);
XRCCTRL(*this, "lblOperation", wxStaticText)->SetLabel(_("Operation: ") + operation);
XRCCTRL(*this, "txtCommand", wxTextCtrl)->SetValue(command);
wxChoice* cmbAnswer = XRCCTRL(*this, "cmbAnswer", wxChoice);
if (m_hasPath)
{
// The operation to ask has its origin in a valid file, so we can ask the user if he wants to trust this file
cmbAnswer->Append(_("ALLOW execution of this command"));
cmbAnswer->Append(_("ALLOW execution of this command for all scripts from now on"));
cmbAnswer->Append(_("DENY execution of this command"));
cmbAnswer->Append(_("Mark this script as TRUSTED for this session"));
cmbAnswer->Append(_("Mark this script as TRUSTED permanently"));
cmbAnswer->SetSelection(2);
}
else
{
// The operation is not called from a file, so we can ask only for current permission
cmbAnswer->Append(_("ALLOW execution of this command"));
cmbAnswer->Append(_("DENY execution of this command"));
cmbAnswer->SetSelection(1);
}
}
ScriptSecurityWarningDlg::~ScriptSecurityWarningDlg()
{
//dtor
}
ScriptSecurityResponse ScriptSecurityWarningDlg::GetResponse()
{
int selection = XRCCTRL(*this, "cmbAnswer", wxChoice)->GetSelection();
if (m_hasPath)
return (ScriptSecurityResponse) selection;
else
{
// We have to map the response, because there are only two selections...
switch(selection)
{
case 0: return ScriptSecurityResponse::ssrAllow;
case 1: return ScriptSecurityResponse::ssrDeny;
}
return ScriptSecurityResponse::ssrDeny;
}
}
void ScriptSecurityWarningDlg::EndModal(int retCode)
{
wxScrollingDialog::EndModal(retCode);
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.