New upstream version 1.0.5
This commit is contained in:
137
.gitignore
vendored
Normal file
137
.gitignore
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
memres.h
|
||||
.deps/
|
||||
autom4te.cache/
|
||||
Makefile
|
||||
bin2hdr
|
||||
*.o
|
||||
config.h
|
||||
config.log
|
||||
config.status
|
||||
docs/Makefile
|
||||
libtool
|
||||
opennx
|
||||
opensc/opensc-config
|
||||
packaging/MacOSX/Makefile
|
||||
packaging/MacOSX/opennx-main.plist
|
||||
packaging/MacOSX/opennx.plist
|
||||
packaging/MacOSX/pkg.plist
|
||||
packaging/MacOSX/pulse/Makefile
|
||||
packaging/win32/Makefile
|
||||
packaging/win32/cygnx/Makefile
|
||||
packaging/win32/findrequires.pl
|
||||
packaging/win32/isccwrap.sh
|
||||
packaging/win32/nx/Makefile
|
||||
packaging/win32/pulse/Makefile
|
||||
packaging/win32/xming/Makefile
|
||||
pconnect
|
||||
po/Makefile
|
||||
po/Makefile.in
|
||||
po/POTFILES
|
||||
pulsetest
|
||||
res/opennx.rc
|
||||
stamp-h1
|
||||
tmpres.zip
|
||||
watchreader
|
||||
config.h.in~
|
||||
watchusbip
|
||||
ChangeLog
|
||||
aclocal.m4
|
||||
conf/config.sub
|
||||
conf/ltmain.sh
|
||||
config.h.in
|
||||
configure
|
||||
opennx.spec
|
||||
bin2hdr.exe
|
||||
opennx.exe
|
||||
packaging/win32/.dlldeps
|
||||
packaging/win32/.miscfonts
|
||||
packaging/win32/.setupdir
|
||||
packaging/win32/.stripsetup
|
||||
packaging/win32/OpenNX-0.16.0.0-Setup.exe
|
||||
packaging/win32/cygnx/dist/
|
||||
packaging/win32/cygnx/innounp.exe
|
||||
packaging/win32/cygnx/innounp*.rar
|
||||
packaging/win32/cygnx/install_script.iss
|
||||
packaging/win32/cygnx/nxsetup.exe
|
||||
packaging/win32/cygnx/unrar.available
|
||||
packaging/win32/cygnx/{app}/
|
||||
packaging/win32/dejavu-fonts-ttf-*.tar.bz2
|
||||
packaging/win32/dejavu-fonts-ttf-*/
|
||||
packaging/win32/font-misc-misc-*.tar.bz2
|
||||
packaging/win32/font-misc-misc-*/
|
||||
packaging/win32/pulse/.tmpinstall
|
||||
packaging/win32/pulse/dist/
|
||||
packaging/win32/pulse/include/
|
||||
packaging/win32/pulse/json-c-*.tar.gz
|
||||
packaging/win32/pulse/json-c-*/
|
||||
packaging/win32/pulse/json-c-build-cross
|
||||
packaging/win32/pulse/json-c-checkarchive
|
||||
packaging/win32/pulse/json-c-srcdir
|
||||
packaging/win32/pulse/libsamplerate-*.tar.gz
|
||||
packaging/win32/pulse/libsamplerate-*/
|
||||
packaging/win32/pulse/libsamplerate-build-cross
|
||||
packaging/win32/pulse/libsamplerate-checkarchive
|
||||
packaging/win32/pulse/libsamplerate-srcdir
|
||||
packaging/win32/pulse/libsndfile-*.tar.gz
|
||||
packaging/win32/pulse/libsndfile-*/
|
||||
packaging/win32/pulse/libsndfile-build-cross
|
||||
packaging/win32/pulse/libsndfile-checkarchive
|
||||
packaging/win32/pulse/libsndfile-srcdir
|
||||
packaging/win32/pulse/pkg-config
|
||||
packaging/win32/pulse/pulseaudio-*.tar.gz
|
||||
packaging/win32/pulse/pulseaudio-*/
|
||||
packaging/win32/pulse/pulseaudio-build-cross
|
||||
packaging/win32/pulse/pulseaudio-checkarchive
|
||||
packaging/win32/pulse/pulseaudio-srcdir
|
||||
packaging/win32/pulse/speex-*.tar.gz
|
||||
packaging/win32/pulse/speex-*/
|
||||
packaging/win32/pulse/speex-build-cross
|
||||
packaging/win32/pulse/speex-checkarchive
|
||||
packaging/win32/pulse/speex-srcdir
|
||||
packaging/win32/setupdir/
|
||||
pconnect.exe
|
||||
pulsetest.exe
|
||||
testxauth.exe
|
||||
tracelog.exe
|
||||
watchreader.exe
|
||||
packaging/win32/OpenNX*.exe
|
||||
packaging/win32/pulse/pa-win32-*
|
||||
aclocal.m4
|
||||
config.h.in
|
||||
configure
|
||||
opennx.spec
|
||||
po/de.gmo
|
||||
po/ja.gmo
|
||||
po/ru.gmo
|
||||
po/de.po~
|
||||
po/ja.po~
|
||||
po/ru.po~
|
||||
conf/compile
|
||||
packaging/win32/pulse/*.h
|
||||
Makefile.in
|
||||
conf/config.guess
|
||||
conf/depcomp
|
||||
conf/install-sh
|
||||
conf/missing
|
||||
docs/Makefile.in
|
||||
packaging/MacOSX/Makefile.in
|
||||
packaging/MacOSX/pulse/Makefile.in
|
||||
packaging/win32/Makefile.in
|
||||
packaging/win32/cygnx/Makefile.in
|
||||
packaging/win32/nx/Makefile.in
|
||||
packaging/win32/pulse/Makefile.in
|
||||
packaging/win32/xming/Makefile.in
|
||||
build.lin/
|
||||
build.win/
|
||||
nxssh/
|
||||
nxssh.tar.gz
|
||||
config.guess
|
||||
config.sub
|
||||
|
||||
debian/.debhelper/
|
||||
debian/autoreconf.after
|
||||
debian/autoreconf.before
|
||||
debian/files
|
||||
debian/opennx.debhelper.log
|
||||
debian/opennx.substvars
|
||||
po/stamp-po
|
||||
195
AboutDialog.cpp
Normal file
195
AboutDialog.cpp
Normal file
@@ -0,0 +1,195 @@
|
||||
// $Id: AboutDialog.cpp 281 2009-07-01 14:43:00Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma implementation "AboutDialog.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
////@begin includes
|
||||
////@end includes
|
||||
#include "AboutDialog.h"
|
||||
#include "ExtHtmlWindow.h"
|
||||
#include "Icon.h"
|
||||
#include "opennxApp.h"
|
||||
|
||||
////@begin XPM images
|
||||
////@end XPM images
|
||||
|
||||
/*!
|
||||
* AboutDialog type definition
|
||||
*/
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS( AboutDialog, wxDialog )
|
||||
|
||||
/*!
|
||||
* AboutDialog event table definition
|
||||
*/
|
||||
|
||||
BEGIN_EVENT_TABLE( AboutDialog, wxDialog )
|
||||
|
||||
////@begin AboutDialog event table entries
|
||||
EVT_BUTTON( wxID_OK, AboutDialog::OnOKClick )
|
||||
|
||||
////@end AboutDialog event table entries
|
||||
|
||||
END_EVENT_TABLE()
|
||||
|
||||
/*!
|
||||
* AboutDialog constructors
|
||||
*/
|
||||
|
||||
AboutDialog::AboutDialog( )
|
||||
{
|
||||
}
|
||||
|
||||
AboutDialog::AboutDialog( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
||||
{
|
||||
Create(parent, id, caption, pos, size, style);
|
||||
}
|
||||
|
||||
/*!
|
||||
* AboutDialog creator
|
||||
*/
|
||||
|
||||
bool AboutDialog::Create( wxWindow* parent, wxWindowID WXUNUSED(id), const wxString& WXUNUSED(caption), const wxPoint& WXUNUSED(pos), const wxSize& WXUNUSED(size), long WXUNUSED(style) )
|
||||
{
|
||||
////@begin AboutDialog member initialisation
|
||||
m_pHtmlWindow = NULL;
|
||||
////@end AboutDialog member initialisation
|
||||
|
||||
////@begin AboutDialog creation
|
||||
SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
|
||||
SetParent(parent);
|
||||
CreateControls();
|
||||
SetIcon(GetIconResource(wxT("res/nx.png")));
|
||||
if (GetSizer())
|
||||
{
|
||||
GetSizer()->SetSizeHints(this);
|
||||
}
|
||||
Centre();
|
||||
////@end AboutDialog creation
|
||||
|
||||
int fs[7];
|
||||
wxFont fv = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
|
||||
wxFont ff = wxSystemSettings::GetFont(wxSYS_ANSI_FIXED_FONT);
|
||||
for (int i = 0; i < 7; i++)
|
||||
fs[i] = fv.GetPointSize();
|
||||
m_pHtmlWindow->SetFonts(fv.GetFaceName(), ff.GetFaceName(), fs);
|
||||
m_pHtmlWindow->SetBorders(0);
|
||||
|
||||
wxString version = _("Version") + wxString::Format(wxT(" <B>%s</B>"),
|
||||
::wxGetApp().GetVersion().c_str());
|
||||
|
||||
wxString content = ::wxGetApp().LoadFileFromResource(wxT("res/about.html"));
|
||||
content.Replace(wxT("<VERSION>"), version);
|
||||
content.Replace(wxT("<WXVERSION>"), wxVERSION_STRING);
|
||||
content.Replace(wxT("\"res:"), wxT("\"") + ::wxGetApp().GetResourcePrefix());
|
||||
|
||||
m_pHtmlWindow->SetPage(content);
|
||||
m_pHtmlWindow->SetBackgroundColour(GetBackgroundColour());
|
||||
if (!content.IsEmpty()) {
|
||||
int width, height;
|
||||
m_pHtmlWindow->GetSize(&width, &height);
|
||||
m_pHtmlWindow->GetInternalRepresentation()->Layout(width);
|
||||
height = m_pHtmlWindow->GetInternalRepresentation()->GetHeight();
|
||||
width = m_pHtmlWindow->GetInternalRepresentation()->GetWidth();
|
||||
m_pHtmlWindow->SetSize(width, height);
|
||||
m_pHtmlWindow->SetSizeHints(width, height);
|
||||
Fit();
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Control creation for AboutDialog
|
||||
*/
|
||||
|
||||
void AboutDialog::CreateControls()
|
||||
{
|
||||
////@begin AboutDialog content construction
|
||||
if (!wxXmlResource::Get()->LoadDialog(this, GetParent(), _T("ID_DIALOG_ABOUT")))
|
||||
wxLogError(wxT("Missing wxXmlResource::Get()->Load() in OnInit()?"));
|
||||
m_pHtmlWindow = XRCCTRL(*this, "ID_HTMLWINDOW_ABOUT", extHtmlWindow);
|
||||
////@end AboutDialog content construction
|
||||
|
||||
// Create custom windows not generated automatically here.
|
||||
|
||||
////@begin AboutDialog content initialisation
|
||||
////@end AboutDialog content initialisation
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
* Should we show tooltips?
|
||||
*/
|
||||
|
||||
bool AboutDialog::ShowToolTips()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get bitmap resources
|
||||
*/
|
||||
|
||||
wxBitmap AboutDialog::GetBitmapResource( const wxString& name )
|
||||
{
|
||||
// Bitmap retrieval
|
||||
return CreateBitmapFromFile(name);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get icon resources
|
||||
*/
|
||||
|
||||
wxIcon AboutDialog::GetIconResource( const wxString& name )
|
||||
{
|
||||
// Icon retrieval
|
||||
return CreateIconFromFile(name);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
|
||||
*/
|
||||
|
||||
void AboutDialog::OnOKClick( wxCommandEvent& event )
|
||||
{
|
||||
wxUnusedVar(event);
|
||||
EndDialog(0);
|
||||
}
|
||||
|
||||
116
AboutDialog.h
Normal file
116
AboutDialog.h
Normal file
@@ -0,0 +1,116 @@
|
||||
// $Id: AboutDialog.h 151 2009-02-10 22:30:59Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _ABOUTDIALOG_H_
|
||||
#define _ABOUTDIALOG_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "AboutDialog.cpp"
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* Includes
|
||||
*/
|
||||
|
||||
////@begin includes
|
||||
#include "AboutDialog_symbols.h"
|
||||
#include "wx/xrc/xmlres.h"
|
||||
#include "wx/html/htmlwin.h"
|
||||
////@end includes
|
||||
|
||||
/*!
|
||||
* Forward declarations
|
||||
*/
|
||||
|
||||
////@begin forward declarations
|
||||
class extHtmlWindow;
|
||||
////@end forward declarations
|
||||
|
||||
/*!
|
||||
* Control identifiers
|
||||
*/
|
||||
|
||||
////@begin control identifiers
|
||||
#define ID_DIALOG_ABOUT 10036
|
||||
#define SYMBOL_ABOUTDIALOG_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX
|
||||
#define SYMBOL_ABOUTDIALOG_TITLE _("About OpenNX")
|
||||
#define SYMBOL_ABOUTDIALOG_IDNAME ID_DIALOG_ABOUT
|
||||
#define SYMBOL_ABOUTDIALOG_SIZE wxDefaultSize
|
||||
#define SYMBOL_ABOUTDIALOG_POSITION wxDefaultPosition
|
||||
////@end control identifiers
|
||||
|
||||
/*!
|
||||
* Compatibility
|
||||
*/
|
||||
|
||||
#ifndef wxCLOSE_BOX
|
||||
#define wxCLOSE_BOX 0x1000
|
||||
#endif
|
||||
#ifndef wxFIXED_MINSIZE
|
||||
#define wxFIXED_MINSIZE 0
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* AboutDialog class declaration
|
||||
*/
|
||||
|
||||
class AboutDialog: public wxDialog
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS( AboutDialog )
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
public:
|
||||
/// Constructors
|
||||
AboutDialog( );
|
||||
AboutDialog( wxWindow* parent, wxWindowID id = SYMBOL_ABOUTDIALOG_IDNAME, const wxString& caption = SYMBOL_ABOUTDIALOG_TITLE, const wxPoint& pos = SYMBOL_ABOUTDIALOG_POSITION, const wxSize& size = SYMBOL_ABOUTDIALOG_SIZE, long style = SYMBOL_ABOUTDIALOG_STYLE );
|
||||
|
||||
/// Creation
|
||||
bool Create( wxWindow* parent, wxWindowID id = SYMBOL_ABOUTDIALOG_IDNAME, const wxString& caption = SYMBOL_ABOUTDIALOG_TITLE, const wxPoint& pos = SYMBOL_ABOUTDIALOG_POSITION, const wxSize& size = SYMBOL_ABOUTDIALOG_SIZE, long style = SYMBOL_ABOUTDIALOG_STYLE );
|
||||
|
||||
/// Creates the controls and sizers
|
||||
void CreateControls();
|
||||
|
||||
////@begin AboutDialog event handler declarations
|
||||
|
||||
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
|
||||
void OnOKClick( wxCommandEvent& event );
|
||||
|
||||
////@end AboutDialog event handler declarations
|
||||
|
||||
////@begin AboutDialog member function declarations
|
||||
|
||||
/// Retrieves bitmap resources
|
||||
wxBitmap GetBitmapResource( const wxString& name );
|
||||
|
||||
/// Retrieves icon resources
|
||||
wxIcon GetIconResource( const wxString& name );
|
||||
////@end AboutDialog member function declarations
|
||||
|
||||
/// Should we show tooltips?
|
||||
static bool ShowToolTips();
|
||||
|
||||
////@begin AboutDialog member variables
|
||||
extHtmlWindow* m_pHtmlWindow;
|
||||
////@end AboutDialog member variables
|
||||
};
|
||||
|
||||
#endif
|
||||
// _ABOUTDIALOG_H_
|
||||
23
AboutDialog_symbols.h
Normal file
23
AboutDialog_symbols.h
Normal file
@@ -0,0 +1,23 @@
|
||||
// $Id: AboutDialog_symbols.h 151 2009-02-10 22:30:59Z felfert $
|
||||
//
|
||||
// Copyright (C) 2008 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#define ID_DIALOG_ABOUT_SYMBOL_0 _("About OpenNX")
|
||||
#define ID_DIALOG_ABOUT_SYMBOL_1 _("&OK")
|
||||
331
AsyncProcess.cpp
Normal file
331
AsyncProcess.cpp
Normal file
@@ -0,0 +1,331 @@
|
||||
// $Id: AsyncProcess.cpp 603 2011-02-21 19:18:11Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma implementation "AsyncProcess.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#include <wx/filename.h>
|
||||
#include <wx/txtstrm.h>
|
||||
|
||||
#include "AsyncProcess.h"
|
||||
|
||||
#include "trace.h"
|
||||
ENABLE_TRACE;
|
||||
|
||||
#if 0
|
||||
// trying to get rid of file descriptors which are left
|
||||
// open by redirected wxExecute ...
|
||||
#define private public
|
||||
#define protected public
|
||||
#include <wx/file.h>
|
||||
#include <wx/wfstream.h>
|
||||
#undef private
|
||||
#undef protected
|
||||
#endif
|
||||
|
||||
DEFINE_LOCAL_EVENT_TYPE(wxEVT_PROCESS_STDOUT);
|
||||
DEFINE_LOCAL_EVENT_TYPE(wxEVT_PROCESS_STDERR);
|
||||
DEFINE_LOCAL_EVENT_TYPE(wxEVT_PROCESS_EXIT);
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(AsyncProcess, wxProcess)
|
||||
|
||||
AsyncProcess::AsyncProcess()
|
||||
: wxProcess(),
|
||||
wxThreadHelper(),
|
||||
m_pEvtHandler(NULL)
|
||||
{
|
||||
Redirect();
|
||||
}
|
||||
|
||||
AsyncProcess::AsyncProcess(const wxString& cmd, const wxString &wdir, const wxString &special, wxEvtHandler *h /* = NULL */)
|
||||
: wxProcess(),
|
||||
wxThreadHelper(),
|
||||
m_pEvtHandler(h),
|
||||
m_sCmd(cmd),
|
||||
m_sDir(wdir),
|
||||
m_sSpecial(special)
|
||||
{
|
||||
Redirect();
|
||||
}
|
||||
|
||||
AsyncProcess::AsyncProcess(const wxString& cmd, const wxString &wdir, wxEvtHandler *h /* = NULL */)
|
||||
: wxProcess(),
|
||||
wxThreadHelper(),
|
||||
m_pEvtHandler(h),
|
||||
m_sCmd(cmd),
|
||||
m_sDir(wdir)
|
||||
{
|
||||
Redirect();
|
||||
}
|
||||
|
||||
AsyncProcess::AsyncProcess(const wxString& cmd, wxEvtHandler *h /* = NULL */)
|
||||
: wxProcess(),
|
||||
wxThreadHelper(),
|
||||
m_pEvtHandler(h),
|
||||
m_sCmd(cmd),
|
||||
m_sDir(::wxGetCwd())
|
||||
{
|
||||
Redirect();
|
||||
}
|
||||
|
||||
AsyncProcess::~AsyncProcess()
|
||||
{
|
||||
myLogTrace(MYTRACETAG, wxT("~AsyncProcess"));
|
||||
if (m_thread && m_thread->IsRunning()) {
|
||||
m_thread->Delete();
|
||||
while (m_thread->IsRunning())
|
||||
wxThread::Sleep(100);
|
||||
m_thread = NULL;
|
||||
}
|
||||
myLogTrace(MYTRACETAG, wxT("~AsyncProcess exit"));
|
||||
m_pEvtHandler = NULL;
|
||||
}
|
||||
|
||||
wxThread::ExitCode
|
||||
AsyncProcess::Entry()
|
||||
{
|
||||
myLogTrace(MYTRACETAG, wxT("IoThread starting"));
|
||||
while (!m_thread->TestDestroy()) {
|
||||
while (IsInputAvailable()) {
|
||||
char c = GetInputStream()->GetC();
|
||||
if (m_pEvtHandler) {
|
||||
m_cOutWatch.Start();
|
||||
switch (c) {
|
||||
case '\r':
|
||||
break;
|
||||
case '\n':
|
||||
{
|
||||
wxCommandEvent event(wxEVT_PROCESS_STDOUT, wxID_ANY);
|
||||
event.SetString(m_sOutBuf);
|
||||
event.SetClientData(this);
|
||||
m_pEvtHandler->AddPendingEvent(event);
|
||||
m_sOutBuf.Empty();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (c >= ' ')
|
||||
m_sOutBuf += c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (m_pEvtHandler) {
|
||||
// If no LF received within a second, send buffer anyway
|
||||
//if ((m_sSpecial.Len() && m_sOutBuf.StartsWith(m_sSpecial)) || ((m_cOutWatch.Time() > 100) && (!m_sOutBuf.IsEmpty()))) {
|
||||
//
|
||||
// +Djelf: there is no need to wait, all data should already be in
|
||||
// the buffer, with the exception of a long list of
|
||||
// sessions, more than a TCP/IP packet
|
||||
if (!m_sOutBuf.IsEmpty()) {
|
||||
myLogTrace(MYTRACETAG, wxT("IoThread outwatch timed out"));
|
||||
wxCommandEvent event(wxEVT_PROCESS_STDOUT, wxID_ANY);
|
||||
event.SetString(m_sOutBuf);
|
||||
event.SetClientData(this);
|
||||
m_pEvtHandler->AddPendingEvent(event);
|
||||
m_sOutBuf.Empty();
|
||||
}
|
||||
}
|
||||
while (IsErrorAvailable()) {
|
||||
char c = GetErrorStream()->GetC();
|
||||
if (m_pEvtHandler) {
|
||||
m_cErrWatch.Start();
|
||||
switch (c) {
|
||||
case '\r':
|
||||
break;
|
||||
case '\n':
|
||||
{
|
||||
wxCommandEvent event(wxEVT_PROCESS_STDERR, wxID_ANY);
|
||||
event.SetString(m_sErrBuf);
|
||||
event.SetClientData(this);
|
||||
m_pEvtHandler->AddPendingEvent(event);
|
||||
m_sErrBuf.Empty();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (c >= ' ')
|
||||
m_sErrBuf += c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (m_pEvtHandler) {
|
||||
// If no LF received within a second, send buffer anyway
|
||||
//if ((m_sSpecial.Len() && m_sErrBuf.StartsWith(m_sSpecial)) ||
|
||||
// ((m_cErrWatch.Time() > 100) && (!m_sErrBuf.IsEmpty()))) {
|
||||
//
|
||||
// +Djelf: there is no need to wait, all data should already be in
|
||||
// the buffer, with the exception of a long list of
|
||||
// sessions, more than a TCP/IP packet
|
||||
if (!m_sErrBuf.IsEmpty()) {
|
||||
myLogTrace(MYTRACETAG, wxT("IoThread errwatch timed out"));
|
||||
wxCommandEvent event(wxEVT_PROCESS_STDERR, wxID_ANY);
|
||||
event.SetString(m_sErrBuf);
|
||||
event.SetClientData(this);
|
||||
m_pEvtHandler->AddPendingEvent(event);
|
||||
m_sErrBuf.Empty();
|
||||
}
|
||||
}
|
||||
wxThread::Sleep(10);
|
||||
}
|
||||
myLogTrace(MYTRACETAG, wxT("IoThread exiting"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool
|
||||
AsyncProcess::IsRunning() {
|
||||
bool ret = ((m_pid > 0) && Exists(m_pid));
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool
|
||||
AsyncProcess::Print(const wxString &s, bool doLog)
|
||||
{
|
||||
wxOutputStream *os = GetOutputStream();
|
||||
if (os) {
|
||||
if (doLog)
|
||||
myLogTrace(MYTRACETAG, wxT("Sending: '%s'"), VMB(s));
|
||||
else
|
||||
myLogTrace(MYTRACETAG, wxT("Sending (hidden): '************'"));
|
||||
wxString sbuf = s + (s.IsEmpty() ? wxT("NullCommand\n") : wxT("\n")) ;
|
||||
const wxWX2MBbuf buf = wxConvCurrent->cWX2MB(sbuf);
|
||||
os->Write(buf, strlen(buf));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
AsyncProcess::OnTerminate(int pid, int status)
|
||||
{
|
||||
myLogTrace(MYTRACETAG, wxT("Process %u terminated with exit code %d."), pid, status);
|
||||
wxLog::FlushActive();
|
||||
m_iStatus = status;
|
||||
if (m_thread && m_thread->IsRunning()) {
|
||||
while ((m_cOutWatch.Time() < 2000) || (m_cErrWatch.Time() < 2000))
|
||||
wxThread::Sleep(100);
|
||||
m_thread->Delete();
|
||||
while (m_thread->IsRunning())
|
||||
wxThread::Sleep(100);
|
||||
myLogTrace(MYTRACETAG, wxT("OnTerminate(): IoThread has ended."));
|
||||
m_thread = NULL;
|
||||
}
|
||||
if (m_pEvtHandler) {
|
||||
wxCommandEvent event(wxEVT_PROCESS_EXIT, wxID_ANY);
|
||||
event.SetInt(m_iStatus);
|
||||
event.SetClientData(this);
|
||||
m_pEvtHandler->AddPendingEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
AsyncProcess::Start()
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
if (!m_sCmd.IsEmpty()) {
|
||||
wxString cwd = ::wxGetCwd();
|
||||
myLogTrace(MYTRACETAG, wxT("Starting '%s'"), VMB(m_sCmd));
|
||||
if (!m_sDir.IsEmpty())
|
||||
wxFileName::SetCwd(m_sDir);
|
||||
m_sOutBuf.Empty();
|
||||
m_sErrBuf.Empty();
|
||||
m_pid = ::wxExecute(m_sCmd, wxEXEC_ASYNC, this);
|
||||
myLogTrace(MYTRACETAG, wxT("wxExecute returned %d"), (int)m_pid);
|
||||
ret = (m_pid > 0);
|
||||
if (!m_sDir.IsEmpty())
|
||||
wxFileName::SetCwd(cwd);
|
||||
if (ret) {
|
||||
myLogTrace(MYTRACETAG, wxT(">Create()"));
|
||||
if (IsRunning())
|
||||
CreateThread();
|
||||
myLogTrace(MYTRACETAG, wxT("<Create()"));
|
||||
if (IsRunning())
|
||||
m_thread->Run();
|
||||
myLogTrace(MYTRACETAG, wxT("Run()"));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
AsyncProcess::Detach()
|
||||
{
|
||||
myLogTrace(MYTRACETAG, wxT("Detach() called"));
|
||||
m_pEvtHandler = NULL;
|
||||
#if 0
|
||||
int out_fd = reinterpret_cast<wxFileOutputStream*>(m_outputStream)->m_file->m_fd;
|
||||
int err_fd = reinterpret_cast<wxFileInputStream*>(m_errorStream)->m_file->m_fd;
|
||||
int inp_fd = reinterpret_cast<wxFileInputStream*>(m_inputStream)->m_file->m_fd;
|
||||
myLogTrace(MYTRACETAG, wxT("inp=%d out=%d err=%d"), inp_fd, out_fd, err_fd);
|
||||
#endif
|
||||
wxProcess::Detach();
|
||||
if (m_thread && m_thread->IsRunning()) {
|
||||
m_thread->Delete();
|
||||
myLogTrace(MYTRACETAG, wxT("Detatch(): waiting for IoThread"));
|
||||
while (m_thread->IsRunning())
|
||||
wxThread::Sleep(100);
|
||||
myLogTrace(MYTRACETAG, wxT("Detatch(): IoThread has ended"));
|
||||
m_thread = NULL;
|
||||
}
|
||||
#if 0
|
||||
close(inp_fd);
|
||||
close(out_fd);
|
||||
close(err_fd);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
AsyncProcess::Kill()
|
||||
{
|
||||
myLogTrace(MYTRACETAG, wxT("Kill() called"));
|
||||
bool ret = false;
|
||||
if (IsRunning()) {
|
||||
myLogTrace(MYTRACETAG, wxT("Kill(): actually send sig"));
|
||||
switch (wxProcess::Kill(GetPid(), wxSIGKILL)) {
|
||||
case wxKILL_OK:
|
||||
Detach();
|
||||
case wxKILL_NO_PROCESS:
|
||||
ret = true;
|
||||
break;
|
||||
case wxKILL_BAD_SIGNAL:
|
||||
case wxKILL_ACCESS_DENIED:
|
||||
case wxKILL_ERROR:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
74
AsyncProcess.h
Normal file
74
AsyncProcess.h
Normal file
@@ -0,0 +1,74 @@
|
||||
// $Id: AsyncProcess.h 603 2011-02-21 19:18:11Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _ASYNCPROCESS_H_
|
||||
#define _ASYNCPROCESS_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "AsyncProcess.cpp"
|
||||
#endif
|
||||
|
||||
#include <wx/event.h>
|
||||
#include <wx/process.h>
|
||||
#include <wx/thread.h>
|
||||
|
||||
DECLARE_LOCAL_EVENT_TYPE(wxEVT_PROCESS_STDOUT, -3);
|
||||
DECLARE_LOCAL_EVENT_TYPE(wxEVT_PROCESS_STDERR, -4);
|
||||
DECLARE_LOCAL_EVENT_TYPE(wxEVT_PROCESS_EXIT, -5);
|
||||
|
||||
class AsyncProcess : public wxProcess, wxThreadHelper
|
||||
{
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(AsyncProcess)
|
||||
|
||||
public:
|
||||
AsyncProcess();
|
||||
AsyncProcess(const wxString& cmd, const wxString &wdir, const wxString &special, wxEvtHandler *h = NULL);
|
||||
AsyncProcess(const wxString& cmd, const wxString &wdir, wxEvtHandler *h = NULL);
|
||||
AsyncProcess(const wxString& cmd, wxEvtHandler *h = NULL);
|
||||
|
||||
virtual ~AsyncProcess();
|
||||
|
||||
bool Start();
|
||||
bool Kill();
|
||||
bool Print(const wxString &, bool doLog);
|
||||
bool IsRunning();
|
||||
int GetStatus() { return m_iStatus; }
|
||||
void Detach();
|
||||
virtual void OnTerminate(int pid, int status);
|
||||
|
||||
private:
|
||||
virtual wxThread::ExitCode Entry();
|
||||
|
||||
int m_iStatus;
|
||||
wxEvtHandler *m_pEvtHandler;
|
||||
|
||||
wxString m_sOutBuf;
|
||||
wxString m_sErrBuf;
|
||||
wxString m_sCmd;
|
||||
wxString m_sDir;
|
||||
wxString m_sSpecial;
|
||||
wxStopWatch m_cOutWatch;
|
||||
wxStopWatch m_cErrWatch;
|
||||
};
|
||||
|
||||
#endif
|
||||
// _ASCYNCPROCESS_H_
|
||||
504
COPYING
Normal file
504
COPYING
Normal file
@@ -0,0 +1,504 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
|
||||
|
||||
199
CardWaiterDialog.cpp
Normal file
199
CardWaiterDialog.cpp
Normal file
@@ -0,0 +1,199 @@
|
||||
// $Id: CardWaiterDialog.cpp 281 2009-07-01 14:43:00Z felfert $
|
||||
//
|
||||
// Copyright (C) 2008 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
||||
#pragma implementation "CardWaiterDialog.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
////@begin includes
|
||||
////@end includes
|
||||
|
||||
#include "CardWaiterDialog.h"
|
||||
#include "LibOpenSC.h"
|
||||
#include "Icon.h"
|
||||
|
||||
////@begin XPM images
|
||||
////@end XPM images
|
||||
|
||||
|
||||
/*!
|
||||
* CardWaiterDialog type definition
|
||||
*/
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS( CardWaiterDialog, wxDialog )
|
||||
|
||||
|
||||
/*!
|
||||
* CardWaiterDialog event table definition
|
||||
*/
|
||||
|
||||
BEGIN_EVENT_TABLE( CardWaiterDialog, wxDialog )
|
||||
|
||||
////@begin CardWaiterDialog event table entries
|
||||
////@end CardWaiterDialog event table entries
|
||||
EVT_COMMAND(wxID_ANY, wxEVT_CARDINSERTED, CardWaiterDialog::OnCardInserted)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
/*!
|
||||
* CardWaiterDialog constructors
|
||||
*/
|
||||
|
||||
CardWaiterDialog::CardWaiterDialog()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
CardWaiterDialog::CardWaiterDialog( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
||||
{
|
||||
Init();
|
||||
Create(parent, id, caption, pos, size, style);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* CardWaiterDialog creator
|
||||
*/
|
||||
|
||||
bool CardWaiterDialog::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
||||
{
|
||||
wxUnusedVar(id);
|
||||
wxUnusedVar(caption);
|
||||
wxUnusedVar(pos);
|
||||
wxUnusedVar(size);
|
||||
wxUnusedVar(style);
|
||||
////@begin CardWaiterDialog creation
|
||||
SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
|
||||
SetParent(parent);
|
||||
CreateControls();
|
||||
SetIcon(GetIconResource(wxT("res/nx.png")));
|
||||
if (GetSizer())
|
||||
{
|
||||
GetSizer()->SetSizeHints(this);
|
||||
}
|
||||
Centre();
|
||||
////@end CardWaiterDialog creation
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* CardWaiterDialog destructor
|
||||
*/
|
||||
|
||||
CardWaiterDialog::~CardWaiterDialog()
|
||||
{
|
||||
////@begin CardWaiterDialog destruction
|
||||
////@end CardWaiterDialog destruction
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* Member initialisation
|
||||
*/
|
||||
|
||||
void CardWaiterDialog::Init()
|
||||
{
|
||||
////@begin CardWaiterDialog member initialisation
|
||||
////@end CardWaiterDialog member initialisation
|
||||
m_iReader = -1;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* Control creation for CardWaiterDialog
|
||||
*/
|
||||
|
||||
void CardWaiterDialog::CreateControls()
|
||||
{
|
||||
////@begin CardWaiterDialog content construction
|
||||
if (!wxXmlResource::Get()->LoadDialog(this, GetParent(), _T("ID_CARDWAITERDIALOG")))
|
||||
wxLogError(wxT("Missing wxXmlResource::Get()->Load() in OnInit()?"));
|
||||
////@end CardWaiterDialog content construction
|
||||
|
||||
// Create custom windows not generated automatically here.
|
||||
////@begin CardWaiterDialog content initialisation
|
||||
////@end CardWaiterDialog content initialisation
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* Should we show tooltips?
|
||||
*/
|
||||
|
||||
bool CardWaiterDialog::ShowToolTips()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void CardWaiterDialog::OnCardInserted(wxCommandEvent &ev)
|
||||
{
|
||||
m_iReader = ev.GetInt();
|
||||
ev.Skip();
|
||||
EndModal(wxID_OK);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get bitmap resources
|
||||
*/
|
||||
|
||||
wxBitmap CardWaiterDialog::GetBitmapResource( const wxString& name )
|
||||
{
|
||||
// Bitmap retrieval
|
||||
return CreateBitmapFromFile(name);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get icon resources
|
||||
*/
|
||||
|
||||
wxIcon CardWaiterDialog::GetIconResource( const wxString& name )
|
||||
{
|
||||
// Icon retrieval
|
||||
////@begin CardWaiterDialog icon retrieval
|
||||
wxUnusedVar(name);
|
||||
return wxNullIcon;
|
||||
////@end CardWaiterDialog icon retrieval
|
||||
}
|
||||
|
||||
int CardWaiterDialog::WaitForCard(wxWindow *parent) {
|
||||
Init();
|
||||
if (Create(parent)) {
|
||||
LibOpenSC osc;
|
||||
return osc.WaitForCard(this);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
112
CardWaiterDialog.h
Normal file
112
CardWaiterDialog.h
Normal file
@@ -0,0 +1,112 @@
|
||||
// $Id: CardWaiterDialog.h 209 2009-03-25 14:48:16Z felfert $
|
||||
//
|
||||
// Copyright (C) 2008 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _CARDWAITERDIALOG_H_
|
||||
#define _CARDWAITERDIALOG_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
||||
#pragma interface "CardWaiterDialog.h"
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* Includes
|
||||
*/
|
||||
|
||||
////@begin includes
|
||||
#include "CardWaiterDialog_symbols.h"
|
||||
#include "wx/xrc/xmlres.h"
|
||||
////@end includes
|
||||
|
||||
/*!
|
||||
* Forward declarations
|
||||
*/
|
||||
|
||||
////@begin forward declarations
|
||||
////@end forward declarations
|
||||
|
||||
/*!
|
||||
* Control identifiers
|
||||
*/
|
||||
|
||||
////@begin control identifiers
|
||||
#define ID_CARDWAITERDIALOG 10106
|
||||
#define SYMBOL_CARDWAITERDIALOG_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL
|
||||
#define SYMBOL_CARDWAITERDIALOG_TITLE _("Insert card - OpenNX")
|
||||
#define SYMBOL_CARDWAITERDIALOG_IDNAME ID_CARDWAITERDIALOG
|
||||
#define SYMBOL_CARDWAITERDIALOG_SIZE wxSize(400, 300)
|
||||
#define SYMBOL_CARDWAITERDIALOG_POSITION wxDefaultPosition
|
||||
////@end control identifiers
|
||||
|
||||
|
||||
/*!
|
||||
* CardWaiterDialog class declaration
|
||||
*/
|
||||
|
||||
class CardWaiterDialog: public wxDialog
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS( CardWaiterDialog )
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
public:
|
||||
/// Constructors
|
||||
CardWaiterDialog();
|
||||
CardWaiterDialog( wxWindow* parent, wxWindowID id = SYMBOL_CARDWAITERDIALOG_IDNAME, const wxString& caption = SYMBOL_CARDWAITERDIALOG_TITLE, const wxPoint& pos = SYMBOL_CARDWAITERDIALOG_POSITION, const wxSize& size = SYMBOL_CARDWAITERDIALOG_SIZE, long style = SYMBOL_CARDWAITERDIALOG_STYLE );
|
||||
|
||||
/// Creation
|
||||
bool Create( wxWindow* parent, wxWindowID id = SYMBOL_CARDWAITERDIALOG_IDNAME, const wxString& caption = SYMBOL_CARDWAITERDIALOG_TITLE, const wxPoint& pos = SYMBOL_CARDWAITERDIALOG_POSITION, const wxSize& size = SYMBOL_CARDWAITERDIALOG_SIZE, long style = SYMBOL_CARDWAITERDIALOG_STYLE );
|
||||
|
||||
/// Destructor
|
||||
~CardWaiterDialog();
|
||||
|
||||
/// Initialises member variables
|
||||
void Init();
|
||||
|
||||
/// Creates the controls and sizers
|
||||
void CreateControls();
|
||||
|
||||
////@begin CardWaiterDialog event handler declarations
|
||||
|
||||
////@end CardWaiterDialog event handler declarations
|
||||
|
||||
////@begin CardWaiterDialog member function declarations
|
||||
|
||||
/// Retrieves bitmap resources
|
||||
wxBitmap GetBitmapResource( const wxString& name );
|
||||
|
||||
/// Retrieves icon resources
|
||||
wxIcon GetIconResource( const wxString& name );
|
||||
////@end CardWaiterDialog member function declarations
|
||||
|
||||
/// Should we show tooltips?
|
||||
static bool ShowToolTips();
|
||||
void OnCardInserted(wxCommandEvent &);
|
||||
int GetReader() { return m_iReader; }
|
||||
int WaitForCard(wxWindow *parent);
|
||||
|
||||
private:
|
||||
int m_iReader;
|
||||
|
||||
////@begin CardWaiterDialog member variables
|
||||
////@end CardWaiterDialog member variables
|
||||
};
|
||||
|
||||
#endif
|
||||
// _CARDWAITERDIALOG_H_
|
||||
24
CardWaiterDialog_symbols.h
Normal file
24
CardWaiterDialog_symbols.h
Normal file
@@ -0,0 +1,24 @@
|
||||
// $Id: CardWaiterDialog_symbols.h 209 2009-03-25 14:48:16Z felfert $
|
||||
//
|
||||
// Copyright (C) 2009 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#define ID_CARDWAITERDIALOG_SYMBOL_0 _("Insert card - OpenNX")
|
||||
#define ID_CARDWAITERDIALOG_SYMBOL_1 _("Please insert smart card")
|
||||
#define ID_CARDWAITERDIALOG_SYMBOL_2 _("&Cancel")
|
||||
181
ConnectDialog.cpp
Normal file
181
ConnectDialog.cpp
Normal file
@@ -0,0 +1,181 @@
|
||||
// $Id: ConnectDialog.cpp 157 2009-02-12 14:46:23Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma implementation "ConnectDialog.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
////@begin includes
|
||||
////@end includes
|
||||
|
||||
#include "ConnectDialog.h"
|
||||
#include "Icon.h"
|
||||
|
||||
////@begin XPM images
|
||||
////@end XPM images
|
||||
|
||||
/*!
|
||||
* ConnectDialog type definition
|
||||
*/
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS( ConnectDialog, wxDialog )
|
||||
|
||||
/*!
|
||||
* ConnectDialog event table definition
|
||||
*/
|
||||
|
||||
BEGIN_EVENT_TABLE( ConnectDialog, wxDialog )
|
||||
|
||||
////@begin ConnectDialog event table entries
|
||||
EVT_BUTTON( wxID_CANCEL, ConnectDialog::OnCancelClick )
|
||||
|
||||
////@end ConnectDialog event table entries
|
||||
|
||||
END_EVENT_TABLE()
|
||||
|
||||
/*!
|
||||
* ConnectDialog constructors
|
||||
*/
|
||||
|
||||
ConnectDialog::ConnectDialog( )
|
||||
{
|
||||
}
|
||||
|
||||
ConnectDialog::ConnectDialog( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
||||
{
|
||||
Create(parent, id, caption, pos, size, style);
|
||||
}
|
||||
|
||||
/*!
|
||||
* ConnectDialog creator
|
||||
*/
|
||||
|
||||
bool ConnectDialog::Create( wxWindow* parent, wxWindowID WXUNUSED(id), const wxString& WXUNUSED(caption), const wxPoint& WXUNUSED(pos), const wxSize& WXUNUSED(size), long WXUNUSED(style) )
|
||||
{
|
||||
////@begin ConnectDialog member initialisation
|
||||
m_bAbort = false;
|
||||
m_pCtrlStatus = NULL;
|
||||
m_pCtrlProgress = NULL;
|
||||
////@end ConnectDialog member initialisation
|
||||
|
||||
////@begin ConnectDialog creation
|
||||
SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
|
||||
SetParent(parent);
|
||||
CreateControls();
|
||||
SetIcon(GetIconResource(wxT("res/nx.png")));
|
||||
if (GetSizer())
|
||||
{
|
||||
GetSizer()->SetSizeHints(this);
|
||||
}
|
||||
Centre();
|
||||
////@end ConnectDialog creation
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Control creation for ConnectDialog
|
||||
*/
|
||||
|
||||
void ConnectDialog::CreateControls()
|
||||
{
|
||||
////@begin ConnectDialog content construction
|
||||
if (!wxXmlResource::Get()->LoadDialog(this, GetParent(), _T("ID_DIALOG_CONNECT")))
|
||||
wxLogError(wxT("Missing wxXmlResource::Get()->Load() in OnInit()?"));
|
||||
m_pCtrlStatus = XRCCTRL(*this, "ID_STATIC_STATUS", wxStaticText);
|
||||
m_pCtrlProgress = XRCCTRL(*this, "ID_GAUGE", wxGauge);
|
||||
////@end ConnectDialog content construction
|
||||
|
||||
// Create custom windows not generated automatically here.
|
||||
|
||||
////@begin ConnectDialog content initialisation
|
||||
////@end ConnectDialog content initialisation
|
||||
}
|
||||
|
||||
/*!
|
||||
* Should we show tooltips?
|
||||
*/
|
||||
|
||||
bool ConnectDialog::ShowToolTips()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get bitmap resources
|
||||
*/
|
||||
|
||||
wxBitmap ConnectDialog::GetBitmapResource( const wxString& name)
|
||||
{
|
||||
// Bitmap retrieval
|
||||
return CreateBitmapFromFile(name);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get icon resources
|
||||
*/
|
||||
|
||||
wxIcon ConnectDialog::GetIconResource( const wxString& name )
|
||||
{
|
||||
// Icon retrieval
|
||||
return CreateIconFromFile(name);
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_ABORT
|
||||
*/
|
||||
|
||||
void ConnectDialog::OnCancelClick( wxCommandEvent& WXUNUSED(event) )
|
||||
{
|
||||
m_bAbort = true;
|
||||
}
|
||||
|
||||
|
||||
void ConnectDialog::SetStatusText(wxString txt)
|
||||
{
|
||||
m_pCtrlStatus->SetLabel(txt);
|
||||
Update();
|
||||
}
|
||||
|
||||
void ConnectDialog::SetProgress(int i)
|
||||
{
|
||||
if (i < 0)
|
||||
i = 0;
|
||||
if (i > 100)
|
||||
i = 100;
|
||||
m_pCtrlProgress->SetValue(i);
|
||||
Update();
|
||||
}
|
||||
|
||||
122
ConnectDialog.h
Normal file
122
ConnectDialog.h
Normal file
@@ -0,0 +1,122 @@
|
||||
// $Id: ConnectDialog.h 209 2009-03-25 14:48:16Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _CONNECTDIALOG_H_
|
||||
#define _CONNECTDIALOG_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "ConnectDialog.cpp"
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* Includes
|
||||
*/
|
||||
|
||||
////@begin includes
|
||||
#include "ConnectDialog_symbols.h"
|
||||
#include "wx/xrc/xmlres.h"
|
||||
////@end includes
|
||||
|
||||
/*!
|
||||
* Forward declarations
|
||||
*/
|
||||
|
||||
////@begin forward declarations
|
||||
////@end forward declarations
|
||||
|
||||
/*!
|
||||
* Control identifiers
|
||||
*/
|
||||
|
||||
////@begin control identifiers
|
||||
#define ID_DIALOG_CONNECT 10060
|
||||
#define SYMBOL_CONNECTDIALOG_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX
|
||||
#define SYMBOL_CONNECTDIALOG_TITLE _("Connecting - OpenNX")
|
||||
#define SYMBOL_CONNECTDIALOG_IDNAME ID_DIALOG_CONNECT
|
||||
#define SYMBOL_CONNECTDIALOG_SIZE wxSize(200, 150)
|
||||
#define SYMBOL_CONNECTDIALOG_POSITION wxDefaultPosition
|
||||
////@end control identifiers
|
||||
|
||||
/*!
|
||||
* Compatibility
|
||||
*/
|
||||
|
||||
#ifndef wxCLOSE_BOX
|
||||
#define wxCLOSE_BOX 0x1000
|
||||
#endif
|
||||
#ifndef wxFIXED_MINSIZE
|
||||
#define wxFIXED_MINSIZE 0
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* ConnectDialog class declaration
|
||||
*/
|
||||
|
||||
class ConnectDialog: public wxDialog
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS( ConnectDialog )
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
public:
|
||||
/// Constructors
|
||||
ConnectDialog( );
|
||||
ConnectDialog( wxWindow* parent, wxWindowID id = SYMBOL_CONNECTDIALOG_IDNAME, const wxString& caption = SYMBOL_CONNECTDIALOG_TITLE, const wxPoint& pos = SYMBOL_CONNECTDIALOG_POSITION, const wxSize& size = SYMBOL_CONNECTDIALOG_SIZE, long style = SYMBOL_CONNECTDIALOG_STYLE );
|
||||
|
||||
/// Creation
|
||||
bool Create( wxWindow* parent, wxWindowID id = SYMBOL_CONNECTDIALOG_IDNAME, const wxString& caption = SYMBOL_CONNECTDIALOG_TITLE, const wxPoint& pos = SYMBOL_CONNECTDIALOG_POSITION, const wxSize& size = SYMBOL_CONNECTDIALOG_SIZE, long style = SYMBOL_CONNECTDIALOG_STYLE );
|
||||
|
||||
/// Creates the controls and sizers
|
||||
void CreateControls();
|
||||
|
||||
void SetStatusText(wxString);
|
||||
void SetProgress(int);
|
||||
bool bGetAbort() {return m_bAbort;}
|
||||
|
||||
////@begin ConnectDialog event handler declarations
|
||||
|
||||
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
|
||||
void OnCancelClick( wxCommandEvent& event );
|
||||
|
||||
////@end ConnectDialog event handler declarations
|
||||
|
||||
////@begin ConnectDialog member function declarations
|
||||
|
||||
/// Retrieves bitmap resources
|
||||
wxBitmap GetBitmapResource( const wxString& name );
|
||||
|
||||
/// Retrieves icon resources
|
||||
wxIcon GetIconResource( const wxString& name );
|
||||
////@end ConnectDialog member function declarations
|
||||
|
||||
/// Should we show tooltips?
|
||||
static bool ShowToolTips();
|
||||
|
||||
private:
|
||||
|
||||
////@begin ConnectDialog member variables
|
||||
wxStaticText* m_pCtrlStatus;
|
||||
wxGauge* m_pCtrlProgress;
|
||||
bool m_bAbort;
|
||||
////@end ConnectDialog member variables
|
||||
};
|
||||
|
||||
#endif
|
||||
// _CONNECTDIALOG_H_
|
||||
24
ConnectDialog_symbols.h
Normal file
24
ConnectDialog_symbols.h
Normal file
@@ -0,0 +1,24 @@
|
||||
// $Id: ConnectDialog_symbols.h 475 2010-02-08 03:01:38Z felfert $
|
||||
//
|
||||
// Copyright (C) 2010 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#define ID_DIALOG_CONNECT_SYMBOL_0 _("Connecting - OpenNX")
|
||||
#define ID_DIALOG_CONNECT_SYMBOL_1 _(" ")
|
||||
#define ID_DIALOG_CONNECT_SYMBOL_2 _("&Cancel")
|
||||
157
DebugStringGrabber.cpp
Normal file
157
DebugStringGrabber.cpp
Normal file
@@ -0,0 +1,157 @@
|
||||
// $Id: DebugStringGrabber.cpp 484 2010-02-20 20:33:35Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma implementation "DebugStringGrabber.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#ifdef __WXMSW__
|
||||
|
||||
#include "DebugStringGrabber.h"
|
||||
#include <windows.h>
|
||||
|
||||
DEFINE_LOCAL_EVENT_TYPE(wxEVT_DEBUGSTRING);
|
||||
|
||||
typedef struct {
|
||||
DWORD pid;
|
||||
char msg[1];
|
||||
} tDebugBuffer;
|
||||
|
||||
class DebugStringGrabberData {
|
||||
friend class DebugStringGrabber;
|
||||
private:
|
||||
DWORD FilterPID;
|
||||
HANDLE hDataReady;
|
||||
bool bTerminate;
|
||||
};
|
||||
|
||||
DebugStringGrabber::DebugStringGrabber(wxEvtHandler *handler, pid_t filterPID)
|
||||
: wxThreadHelper()
|
||||
, m_pEvtHandler(handler)
|
||||
, m_bOk(false)
|
||||
{
|
||||
m_pData = new DebugStringGrabberData();
|
||||
m_pData->FilterPID = filterPID;
|
||||
m_pData->hDataReady = NULL;
|
||||
m_pData->bTerminate = false;
|
||||
if (CreateThread(
|
||||
#ifdef __OPENBSD__
|
||||
32768
|
||||
#endif
|
||||
) == wxTHREAD_NO_ERROR) {
|
||||
GetThread()->Run();
|
||||
while ((!m_bOk) && GetThread()->IsRunning())
|
||||
wxThread::Sleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
DebugStringGrabber::~DebugStringGrabber()
|
||||
{
|
||||
m_pEvtHandler = NULL;
|
||||
if (m_bOk) {
|
||||
m_pData->bTerminate = true;
|
||||
if (m_pData->hDataReady)
|
||||
::SetEvent(m_pData->hDataReady);
|
||||
GetThread()->Delete();
|
||||
while (m_bOk)
|
||||
wxThread::Sleep(100);
|
||||
}
|
||||
delete m_pData;
|
||||
}
|
||||
|
||||
wxThread::ExitCode
|
||||
DebugStringGrabber::Entry()
|
||||
{
|
||||
HANDLE bufferready = ::CreateEvent(NULL, FALSE, FALSE, wxT("DBWIN_BUFFER_READY"));
|
||||
if (NULL == bufferready)
|
||||
return 0;
|
||||
if (::GetLastError() == ERROR_ALREADY_EXISTS)
|
||||
return 0;
|
||||
m_pData->hDataReady = ::CreateEvent(NULL, FALSE, FALSE, wxT("DBWIN_DATA_READY"));
|
||||
if (NULL == m_pData->hDataReady) {
|
||||
::CloseHandle(bufferready);
|
||||
return 0;
|
||||
}
|
||||
HANDLE hBuf = ::CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 4096, wxT("DBWIN_BUFFER"));
|
||||
if (NULL == hBuf) {
|
||||
::CloseHandle(bufferready);
|
||||
::CloseHandle(m_pData->hDataReady);
|
||||
m_pData->hDataReady = NULL;
|
||||
return 0;
|
||||
}
|
||||
tDebugBuffer *buf = (tDebugBuffer *)::MapViewOfFile(hBuf, FILE_MAP_READ, 0, 0, 4096);
|
||||
if (buf == NULL) {
|
||||
::CloseHandle(bufferready);
|
||||
::CloseHandle(m_pData->hDataReady);
|
||||
m_pData->hDataReady = NULL;
|
||||
::CloseHandle(hBuf);
|
||||
return 0;
|
||||
}
|
||||
DWORD lastpid = 0xffffffff;
|
||||
|
||||
m_bOk = true;
|
||||
while (!m_thread->TestDestroy()) {
|
||||
if (::SetEvent(bufferready) == FALSE) {
|
||||
break;
|
||||
}
|
||||
if (::WaitForSingleObject(m_pData->hDataReady, INFINITE) != WAIT_OBJECT_0)
|
||||
break;
|
||||
if (m_pData->bTerminate)
|
||||
break;
|
||||
if (lastpid != buf->pid)
|
||||
lastpid = buf->pid;
|
||||
if (m_pData->FilterPID && (lastpid != m_pData->FilterPID))
|
||||
continue;
|
||||
if (m_pEvtHandler) {
|
||||
wxString msg(buf->msg, wxConvUTF8);
|
||||
wxCommandEvent ev(wxEVT_DEBUGSTRING, wxID_ANY);
|
||||
ev.SetInt(lastpid);
|
||||
ev.SetString(msg.Trim());
|
||||
m_pEvtHandler->AddPendingEvent(ev);
|
||||
} else
|
||||
fprintf(stderr, "%s\n", buf->msg); fflush(stderr);
|
||||
}
|
||||
m_bOk = false;
|
||||
::CloseHandle(bufferready);
|
||||
::CloseHandle(m_pData->hDataReady);
|
||||
m_pData->hDataReady = NULL;
|
||||
::UnmapViewOfFile(buf);
|
||||
::CloseHandle(hBuf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // __WXMSW__
|
||||
62
DebugStringGrabber.h
Normal file
62
DebugStringGrabber.h
Normal file
@@ -0,0 +1,62 @@
|
||||
// $Id: DebugStringGrabber.h 148 2009-02-10 20:04:38Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _DEBUGSTRINGGRABBER_H_
|
||||
#define _DEBUGSTRINGGRABBER_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "DebugStringGrabber.cpp"
|
||||
#endif
|
||||
|
||||
#include <wx/event.h>
|
||||
#include <wx/thread.h>
|
||||
|
||||
#ifdef __WXMSW__
|
||||
DECLARE_LOCAL_EVENT_TYPE(wxEVT_DEBUGSTRING, -4);
|
||||
|
||||
class DebugStringGrabberData;
|
||||
|
||||
/**
|
||||
* DebugStringGrabber uses the Windows debugger API to
|
||||
* fetch messages, sent by OutputDebugString() API.
|
||||
* For each message, it delivers an wxWidgets event to
|
||||
* the wxEventHandler, specified in it's constructor.
|
||||
*/
|
||||
class DebugStringGrabber : public wxThreadHelper
|
||||
{
|
||||
public:
|
||||
DebugStringGrabber(wxEvtHandler *handler = NULL, pid_t filterPID = 0);
|
||||
virtual ~DebugStringGrabber();
|
||||
|
||||
virtual wxThread::ExitCode Entry();
|
||||
|
||||
bool IsOk() { return m_bOk; }
|
||||
void SetHandler(wxEvtHandler *handler) { m_pEvtHandler = handler; }
|
||||
|
||||
private:
|
||||
wxEvtHandler *m_pEvtHandler;
|
||||
bool m_bOk;
|
||||
DebugStringGrabberData *m_pData;
|
||||
};
|
||||
|
||||
#endif // __WXMSW__
|
||||
|
||||
#endif
|
||||
66
ExtHtmlWindow.cpp
Normal file
66
ExtHtmlWindow.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
// $Id: ExtHtmlWindow.cpp 202 2009-03-24 07:26:30Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma implementation "ExtHtmlWindow.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#include "ExtHtmlWindow.h"
|
||||
#include "TextViewer.h"
|
||||
|
||||
#include <wx/utils.h>
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS( extHtmlWindow, wxHtmlWindow )
|
||||
|
||||
void extHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link)
|
||||
{
|
||||
wxString href = link.GetHref();
|
||||
wxString target = link.GetTarget();
|
||||
if (target.StartsWith(wxT("TV:"))) {
|
||||
TextViewer *tw = new TextViewer(this);
|
||||
tw->LoadFile(href);
|
||||
target = target.AfterFirst(wxT(':'));
|
||||
if (!target.IsEmpty())
|
||||
tw->SetTitle(target);
|
||||
tw->ShowModal();
|
||||
return;
|
||||
}
|
||||
#ifdef __WXMSW__
|
||||
ShellExecute((HWND)GetHandle(), wxT("open"), href.wc_str(), NULL, NULL, SW_SHOWNORMAL);
|
||||
#else
|
||||
::wxLaunchDefaultBrowser(href, wxBROWSER_NEW_WINDOW);
|
||||
#endif
|
||||
}
|
||||
56
ExtHtmlWindow.h
Normal file
56
ExtHtmlWindow.h
Normal file
@@ -0,0 +1,56 @@
|
||||
// $Id: ExtHtmlWindow.h 193 2009-03-19 09:52:42Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _EXTHTMLWINDOW_H_
|
||||
#define _EXTHTMLWINDOW_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "ExtHtmlWindow.cpp"
|
||||
#endif
|
||||
|
||||
#include "wx/html/htmlwin.h"
|
||||
|
||||
/**
|
||||
* Custom HTML window.
|
||||
* This derivate of wxHtmlWindow interpretes links in a special
|
||||
* way:<br>
|
||||
* <ul>
|
||||
* <li>If "TV" is specified as target, a builting TextViewer is used.
|
||||
* <li>Other links are opened in an external browser.
|
||||
* </ul>
|
||||
*/
|
||||
class extHtmlWindow : public wxHtmlWindow
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS( extHtmlWindow )
|
||||
|
||||
public:
|
||||
extHtmlWindow() : wxHtmlWindow() { }
|
||||
|
||||
/**
|
||||
* Performs the actual action.
|
||||
* If target is TV, open url in internal TextViewer,
|
||||
* otherwise in external browser.
|
||||
*/
|
||||
virtual void OnLinkClicked(const wxHtmlLinkInfo&);
|
||||
};
|
||||
|
||||
#endif
|
||||
// _EXTHTMLWINDOW_H_
|
||||
240
ForeignFrame.cpp
Normal file
240
ForeignFrame.cpp
Normal file
@@ -0,0 +1,240 @@
|
||||
// $Id: ForeignFrame.cpp 591 2010-10-24 23:58:47Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
||||
#pragma implementation "ForeignFrame.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Defines canonicalized platform names (e.g. __LINUX__)
|
||||
*/
|
||||
#include <wx/platform.h>
|
||||
|
||||
#ifndef __WXMSW__
|
||||
|
||||
////@begin includes
|
||||
////@end includes
|
||||
|
||||
#include "ForeignFrame.h"
|
||||
#include "osdep.h"
|
||||
|
||||
////@begin XPM images
|
||||
////@end XPM images
|
||||
|
||||
/*!
|
||||
* ForeignFrame type definition
|
||||
*/
|
||||
|
||||
#define ID_TIMER 5999
|
||||
|
||||
IMPLEMENT_CLASS( ForeignFrame, wxFrame )
|
||||
|
||||
/*!
|
||||
* ForeignFrame event table definition
|
||||
*/
|
||||
|
||||
BEGIN_EVENT_TABLE( ForeignFrame, wxFrame )
|
||||
|
||||
////@begin ForeignFrame event table entries
|
||||
EVT_WINDOW_CREATE( ForeignFrame::OnCreate )
|
||||
|
||||
EVT_MENU( XRCID("ID_FOREIGN_SUSPEND"), ForeignFrame::OnForeignSuspendClick )
|
||||
|
||||
EVT_MENU( XRCID("ID_FOREIGN_TERMINATE"), ForeignFrame::OnForeignTerminateClick )
|
||||
|
||||
EVT_MENU( XRCID("ID_FOREIGN_CLOSE"), ForeignFrame::OnForeignCloseClick )
|
||||
|
||||
////@end ForeignFrame event table entries
|
||||
|
||||
EVT_TIMER(ID_TIMER, ForeignFrame::OnTimer)
|
||||
|
||||
END_EVENT_TABLE()
|
||||
|
||||
/*!
|
||||
* ForeignFrame constructors
|
||||
*/
|
||||
|
||||
ForeignFrame::ForeignFrame( )
|
||||
: m_cTimer(this, ID_TIMER)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
ForeignFrame::ForeignFrame( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
||||
: m_cTimer(this, ID_TIMER)
|
||||
{
|
||||
Init();
|
||||
Create( parent, id, caption, pos, size, style );
|
||||
}
|
||||
|
||||
/*!
|
||||
* ForeignFrame creator
|
||||
*/
|
||||
|
||||
bool ForeignFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
||||
{
|
||||
////@begin ForeignFrame creation
|
||||
SetParent(parent);
|
||||
CreateControls();
|
||||
////@end ForeignFrame creation
|
||||
wxUnusedVar(style);
|
||||
wxUnusedVar(size);
|
||||
wxUnusedVar(pos);
|
||||
wxUnusedVar(caption);
|
||||
wxUnusedVar(id);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Member initialisation
|
||||
*/
|
||||
|
||||
void ForeignFrame::Init()
|
||||
{
|
||||
////@begin ForeignFrame member initialisation
|
||||
////@end ForeignFrame member initialisation
|
||||
}
|
||||
/*!
|
||||
* Control creation for ForeignFrame
|
||||
*/
|
||||
|
||||
void ForeignFrame::CreateControls()
|
||||
{
|
||||
////@begin ForeignFrame content construction
|
||||
if (!wxXmlResource::Get()->LoadFrame(this, GetParent(), wxT("ID_FOREIGNFRAME")))
|
||||
wxLogError(wxT("Missing wxXmlResource::Get()->Load() in OnInit()?"));
|
||||
////@end ForeignFrame content construction
|
||||
|
||||
// Create custom windows not generated automatically here.
|
||||
////@begin ForeignFrame content initialisation
|
||||
////@end ForeignFrame content initialisation
|
||||
|
||||
wxToolBar *tb = GetToolBar();
|
||||
tb->Fit();
|
||||
wxSize sz = tb->GetBestSize();
|
||||
SetMinSize(sz);
|
||||
SetMaxSize(sz);
|
||||
SetSize(sz);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Should we show tooltips?
|
||||
*/
|
||||
|
||||
bool ForeignFrame::ShowToolTips()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get bitmap resources
|
||||
*/
|
||||
|
||||
wxBitmap ForeignFrame::GetBitmapResource( const wxString& name )
|
||||
{
|
||||
// Bitmap retrieval
|
||||
////@begin ForeignFrame bitmap retrieval
|
||||
wxUnusedVar(name);
|
||||
return wxNullBitmap;
|
||||
////@end ForeignFrame bitmap retrieval
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get icon resources
|
||||
*/
|
||||
|
||||
wxIcon ForeignFrame::GetIconResource( const wxString& name )
|
||||
{
|
||||
// Icon retrieval
|
||||
////@begin ForeignFrame icon retrieval
|
||||
wxUnusedVar(name);
|
||||
return wxNullIcon;
|
||||
////@end ForeignFrame icon retrieval
|
||||
}
|
||||
|
||||
void ForeignFrame::OnTimer( wxTimerEvent& event )
|
||||
{
|
||||
Hide();
|
||||
Close();
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_FOREIGN_SUSPEND
|
||||
*/
|
||||
|
||||
void ForeignFrame::OnForeignSuspendClick( wxCommandEvent& event )
|
||||
{
|
||||
Close();
|
||||
event.Skip();
|
||||
::wxKill(getppid(), wxSIGHUP);
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_FOREIGN_TERMINATE
|
||||
*/
|
||||
|
||||
void ForeignFrame::OnForeignTerminateClick( wxCommandEvent& event )
|
||||
{
|
||||
Close();
|
||||
event.Skip();
|
||||
::wxKill(m_nOtherPID, wxSIGTERM);
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_FOREIGN_CLOSE
|
||||
*/
|
||||
|
||||
void ForeignFrame::OnForeignCloseClick( wxCommandEvent& event )
|
||||
{
|
||||
Close();
|
||||
event.Skip();
|
||||
close_foreign(m_nForeignWindowID);
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_CREATE event handler for ID_FOREIGNFRAME
|
||||
*/
|
||||
|
||||
void ForeignFrame::OnCreate( wxWindowCreateEvent& event )
|
||||
{
|
||||
reparent_pulldown(m_nForeignWindowID);
|
||||
m_cTimer.Start(6000, wxTIMER_ONE_SHOT);
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
#endif
|
||||
// !__WXMSW__
|
||||
143
ForeignFrame.h
Normal file
143
ForeignFrame.h
Normal file
@@ -0,0 +1,143 @@
|
||||
// $Id: ForeignFrame.h 591 2010-10-24 23:58:47Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _FOREIGNFRAME_H_
|
||||
#define _FOREIGNFRAME_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
||||
#pragma interface "ForeignFrame.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Defines canonicalized platform names (e.g. __LINUX__)
|
||||
*/
|
||||
#include <wx/platform.h>
|
||||
|
||||
#ifndef __WXMSW__
|
||||
/*!
|
||||
* Includes
|
||||
*/
|
||||
|
||||
////@begin includes
|
||||
#include "ForeignFrame_symbols.h"
|
||||
#include "wx/xrc/xmlres.h"
|
||||
#include "wx/frame.h"
|
||||
#include "wx/toolbar.h"
|
||||
////@end includes
|
||||
|
||||
/*!
|
||||
* Forward declarations
|
||||
*/
|
||||
|
||||
////@begin forward declarations
|
||||
////@end forward declarations
|
||||
|
||||
/*!
|
||||
* Control identifiers
|
||||
*/
|
||||
|
||||
////@begin control identifiers
|
||||
#define ID_FOREIGNFRAME 10152
|
||||
#define SYMBOL_FOREIGNFRAME_STYLE wxFRAME_NO_TASKBAR|wxSTAY_ON_TOP|wxNO_BORDER
|
||||
#define SYMBOL_FOREIGNFRAME_TITLE _("OPENNX-PULLDOWN")
|
||||
#define SYMBOL_FOREIGNFRAME_IDNAME ID_FOREIGNFRAME
|
||||
#define SYMBOL_FOREIGNFRAME_SIZE wxDefaultSize
|
||||
#define SYMBOL_FOREIGNFRAME_POSITION wxDefaultPosition
|
||||
////@end control identifiers
|
||||
|
||||
/*!
|
||||
* Compatibility
|
||||
*/
|
||||
|
||||
#ifndef wxCLOSE_BOX
|
||||
#define wxCLOSE_BOX 0x1000
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* ForeignFrame class declaration
|
||||
*/
|
||||
|
||||
class ForeignFrame: public wxFrame
|
||||
{
|
||||
DECLARE_CLASS( ForeignFrame )
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
public:
|
||||
/// Constructors
|
||||
ForeignFrame( );
|
||||
ForeignFrame( wxWindow* parent, wxWindowID id = SYMBOL_FOREIGNFRAME_IDNAME, const wxString& caption = SYMBOL_FOREIGNFRAME_TITLE, const wxPoint& pos = SYMBOL_FOREIGNFRAME_POSITION, const wxSize& size = SYMBOL_FOREIGNFRAME_SIZE, long style = SYMBOL_FOREIGNFRAME_STYLE );
|
||||
|
||||
bool Create( wxWindow* parent, wxWindowID id = SYMBOL_FOREIGNFRAME_IDNAME, const wxString& caption = SYMBOL_FOREIGNFRAME_TITLE, const wxPoint& pos = SYMBOL_FOREIGNFRAME_POSITION, const wxSize& size = SYMBOL_FOREIGNFRAME_SIZE, long style = SYMBOL_FOREIGNFRAME_STYLE );
|
||||
|
||||
/// Initialises member variables
|
||||
void Init();
|
||||
|
||||
/// Creates the controls and sizers
|
||||
void CreateControls();
|
||||
|
||||
void OnTimer( wxTimerEvent &);
|
||||
|
||||
////@begin ForeignFrame event handler declarations
|
||||
|
||||
/// wxEVT_CREATE event handler for ID_FOREIGNFRAME
|
||||
void OnCreate( wxWindowCreateEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_MENU_SELECTED event handler for ID_FOREIGN_SUSPEND
|
||||
void OnForeignSuspendClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_MENU_SELECTED event handler for ID_FOREIGN_TERMINATE
|
||||
void OnForeignTerminateClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_MENU_SELECTED event handler for ID_FOREIGN_CLOSE
|
||||
void OnForeignCloseClick( wxCommandEvent& event );
|
||||
|
||||
////@end ForeignFrame event handler declarations
|
||||
|
||||
////@begin ForeignFrame member function declarations
|
||||
|
||||
long GetForeignWindowID() const { return m_nForeignWindowID ; }
|
||||
void SetForeignWindowID(long value) { m_nForeignWindowID = value ; }
|
||||
|
||||
long GetOtherPID() const { return m_nOtherPID ; }
|
||||
void SetOtherPID(long value) { m_nOtherPID = value ; }
|
||||
|
||||
/// Retrieves bitmap resources
|
||||
wxBitmap GetBitmapResource( const wxString& name );
|
||||
|
||||
/// Retrieves icon resources
|
||||
wxIcon GetIconResource( const wxString& name );
|
||||
////@end ForeignFrame member function declarations
|
||||
|
||||
/// Should we show tooltips?
|
||||
static bool ShowToolTips();
|
||||
|
||||
////@begin ForeignFrame member variables
|
||||
private:
|
||||
long m_nForeignWindowID;
|
||||
long m_nOtherPID;
|
||||
wxTimer m_cTimer;
|
||||
////@end ForeignFrame member variables
|
||||
};
|
||||
|
||||
#endif
|
||||
// !__WXMSW__
|
||||
#endif
|
||||
// _FOREIGNFRAME_H_
|
||||
22
ForeignFrame_symbols.h
Normal file
22
ForeignFrame_symbols.h
Normal file
@@ -0,0 +1,22 @@
|
||||
// $Id: ForeignFrame_symbols.h 97 2006-12-21 09:18:48Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#define ID_FOREIGNFRAME_SYMBOL_0 _("OPENNX-PULLDOWN")
|
||||
94
INSTALL
Normal file
94
INSTALL
Normal file
@@ -0,0 +1,94 @@
|
||||
This file contains instructions specivic to OpenNX only. Generic
|
||||
installation instructions are described in INSTALL.generic.
|
||||
|
||||
1. Supported target systems:
|
||||
|
||||
This package has been tested on Linux, OpenBSD, Mac OSX and
|
||||
Windows (with MinGW)
|
||||
|
||||
1. Prerequisites:
|
||||
|
||||
OpenNX uses wxWidgets, libsmbclient and libcups so you will need the
|
||||
corresponding development packages on your system.
|
||||
|
||||
For building on Windows, you need the latest MinGW/MSYS development
|
||||
system (See http://www.mingw.org). Since currently (Sep. 2008) only old
|
||||
installers are officially available at SourceForge, you probably are
|
||||
better suited when using my custom installer. Fetch it from
|
||||
http://www.fritz-elfert.de/downloads/mingw+msys-092008-setup.exe
|
||||
It contains a complete MinGW/MSYS environment plus a pre-built
|
||||
wxWidgets-2.8.8 framework, containing the patches mentioned below.
|
||||
|
||||
On all other systems, you will just need wxWidgets of
|
||||
version 2.8.9 or later.
|
||||
|
||||
When using an SVN-checkout, in addition, you need GNU autotools,
|
||||
GNU gettext and GNU libtool, svn2cl (and their dependencies, of course)
|
||||
in order to generate the necessary support files.
|
||||
|
||||
You also can cross-build for windows on Fedora F11, using the latest
|
||||
mingw32 cross environment.
|
||||
|
||||
2. Configuring the package:
|
||||
|
||||
When using an SVN-checkout, the missing support files can be generated
|
||||
by invoking
|
||||
|
||||
make -f Makefile.am
|
||||
|
||||
This step needs svn access (because it generates the ChangeLog and
|
||||
derives the Build-# from the SVN revision) an is *NOT* necessary when
|
||||
building from a source tarball.
|
||||
|
||||
Normally, you simply will run the command sequence:
|
||||
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
|
||||
Options to ./configure, specific to OpenNX are:
|
||||
|
||||
Application features:
|
||||
--enable-unicode
|
||||
Enables a unicode build [Default: YES]
|
||||
--enable-staticwx
|
||||
Link against a static wxWidgets lib [Default: NO]
|
||||
--enable-debug
|
||||
Link against a debug wxWidgets lib [Default: NO]
|
||||
--enable-warn
|
||||
Enables some additional compiler warnings [Default: NO]
|
||||
--with-nxproto=x.x.x
|
||||
Can be used to tweak the NX protocol version [Default: 2.1.0]
|
||||
|
||||
Build environment tweaks:
|
||||
--with-samba=DIR
|
||||
Can be used to specify the samba source for finding smbclient.h
|
||||
--with-wxdir=PATH
|
||||
Can be used to specify an uninstalled version of wxWidgets
|
||||
--with-wx-config=CONFIG
|
||||
Can be used to specify a custom wx-config script to use
|
||||
|
||||
All other (generic) options are documented in the file INSTALL.generic
|
||||
|
||||
3. Running OpenNX:
|
||||
|
||||
OpenNX is a drop-in replacement for nxclient. Therefore, in order to be
|
||||
of any practical use, you need the usual NX client environment for your
|
||||
platform. Furthermore, the application binary MUST be named nxclient
|
||||
(because that name is hardcoded in Nomachine's nxssh)! In order to use
|
||||
the SmartCard feature, you also need to rebuild nxssh from source,
|
||||
enabling it's already existing SmartCard feature(s) during
|
||||
nxssh's ./configure. Enabling this feature adds a dependency on
|
||||
openct/opensc (See http://www.opensc-project.org). The SmartCard
|
||||
is currently used for storing the client's SSH key and NOT forwarded
|
||||
thru the NX session.
|
||||
|
||||
4. USB forwarding:
|
||||
For those who are curious: There is a configure option named
|
||||
--enable-usbip (Default: NO) which is intended to activate support
|
||||
for USB forwarding. Enabling this will *NOT* work, because it depends on
|
||||
additional software which is *currently* closed source. The additional
|
||||
software will be released to OpenSource in approx. 1 year.
|
||||
|
||||
Have fun
|
||||
-Fritz
|
||||
229
INSTALL.generic
Normal file
229
INSTALL.generic
Normal file
@@ -0,0 +1,229 @@
|
||||
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This file is free documentation; the Free Software Foundation gives
|
||||
unlimited permission to copy, distribute and modify it.
|
||||
|
||||
Basic Installation
|
||||
==================
|
||||
|
||||
These are generic installation instructions.
|
||||
|
||||
The `configure' shell script attempts to guess correct values for
|
||||
various system-dependent variables used during compilation. It uses
|
||||
those values to create a `Makefile' in each directory of the package.
|
||||
It may also create one or more `.h' files containing system-dependent
|
||||
definitions. Finally, it creates a shell script `config.status' that
|
||||
you can run in the future to recreate the current configuration, and a
|
||||
file `config.log' containing compiler output (useful mainly for
|
||||
debugging `configure').
|
||||
|
||||
It can also use an optional file (typically called `config.cache'
|
||||
and enabled with `--cache-file=config.cache' or simply `-C') that saves
|
||||
the results of its tests to speed up reconfiguring. (Caching is
|
||||
disabled by default to prevent problems with accidental use of stale
|
||||
cache files.)
|
||||
|
||||
If you need to do unusual things to compile the package, please try
|
||||
to figure out how `configure' could check whether to do them, and mail
|
||||
diffs or instructions to the address given in the `README' so they can
|
||||
be considered for the next release. If you are using the cache, and at
|
||||
some point `config.cache' contains results you don't want to keep, you
|
||||
may remove or edit it.
|
||||
|
||||
The file `configure.ac' (or `configure.in') is used to create
|
||||
`configure' by a program called `autoconf'. You only need
|
||||
`configure.ac' if you want to change it or regenerate `configure' using
|
||||
a newer version of `autoconf'.
|
||||
|
||||
The simplest way to compile this package is:
|
||||
|
||||
1. `cd' to the directory containing the package's source code and type
|
||||
`./configure' to configure the package for your system. If you're
|
||||
using `csh' on an old version of System V, you might need to type
|
||||
`sh ./configure' instead to prevent `csh' from trying to execute
|
||||
`configure' itself.
|
||||
|
||||
Running `configure' takes awhile. While running, it prints some
|
||||
messages telling which features it is checking for.
|
||||
|
||||
2. Type `make' to compile the package.
|
||||
|
||||
3. Optionally, type `make check' to run any self-tests that come with
|
||||
the package.
|
||||
|
||||
4. Type `make install' to install the programs and any data files and
|
||||
documentation.
|
||||
|
||||
5. You can remove the program binaries and object files from the
|
||||
source code directory by typing `make clean'. To also remove the
|
||||
files that `configure' created (so you can compile the package for
|
||||
a different kind of computer), type `make distclean'. There is
|
||||
also a `make maintainer-clean' target, but that is intended mainly
|
||||
for the package's developers. If you use it, you may have to get
|
||||
all sorts of other programs in order to regenerate files that came
|
||||
with the distribution.
|
||||
|
||||
Compilers and Options
|
||||
=====================
|
||||
|
||||
Some systems require unusual options for compilation or linking that
|
||||
the `configure' script does not know about. Run `./configure --help'
|
||||
for details on some of the pertinent environment variables.
|
||||
|
||||
You can give `configure' initial values for configuration parameters
|
||||
by setting variables in the command line or in the environment. Here
|
||||
is an example:
|
||||
|
||||
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
|
||||
|
||||
*Note Defining Variables::, for more details.
|
||||
|
||||
Compiling For Multiple Architectures
|
||||
====================================
|
||||
|
||||
You can compile the package for more than one kind of computer at the
|
||||
same time, by placing the object files for each architecture in their
|
||||
own directory. To do this, you must use a version of `make' that
|
||||
supports the `VPATH' variable, such as GNU `make'. `cd' to the
|
||||
directory where you want the object files and executables to go and run
|
||||
the `configure' script. `configure' automatically checks for the
|
||||
source code in the directory that `configure' is in and in `..'.
|
||||
|
||||
If you have to use a `make' that does not support the `VPATH'
|
||||
variable, you have to compile the package for one architecture at a
|
||||
time in the source code directory. After you have installed the
|
||||
package for one architecture, use `make distclean' before reconfiguring
|
||||
for another architecture.
|
||||
|
||||
Installation Names
|
||||
==================
|
||||
|
||||
By default, `make install' will install the package's files in
|
||||
`/usr/local/bin', `/usr/local/man', etc. You can specify an
|
||||
installation prefix other than `/usr/local' by giving `configure' the
|
||||
option `--prefix=PATH'.
|
||||
|
||||
You can specify separate installation prefixes for
|
||||
architecture-specific files and architecture-independent files. If you
|
||||
give `configure' the option `--exec-prefix=PATH', the package will use
|
||||
PATH as the prefix for installing programs and libraries.
|
||||
Documentation and other data files will still use the regular prefix.
|
||||
|
||||
In addition, if you use an unusual directory layout you can give
|
||||
options like `--bindir=PATH' to specify different values for particular
|
||||
kinds of files. Run `configure --help' for a list of the directories
|
||||
you can set and what kinds of files go in them.
|
||||
|
||||
If the package supports it, you can cause programs to be installed
|
||||
with an extra prefix or suffix on their names by giving `configure' the
|
||||
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
||||
|
||||
Optional Features
|
||||
=================
|
||||
|
||||
Some packages pay attention to `--enable-FEATURE' options to
|
||||
`configure', where FEATURE indicates an optional part of the package.
|
||||
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
||||
is something like `gnu-as' or `x' (for the X Window System). The
|
||||
`README' should mention any `--enable-' and `--with-' options that the
|
||||
package recognizes.
|
||||
|
||||
For packages that use the X Window System, `configure' can usually
|
||||
find the X include and library files automatically, but if it doesn't,
|
||||
you can use the `configure' options `--x-includes=DIR' and
|
||||
`--x-libraries=DIR' to specify their locations.
|
||||
|
||||
Specifying the System Type
|
||||
==========================
|
||||
|
||||
There may be some features `configure' cannot figure out
|
||||
automatically, but needs to determine by the type of machine the package
|
||||
will run on. Usually, assuming the package is built to be run on the
|
||||
_same_ architectures, `configure' can figure that out, but if it prints
|
||||
a message saying it cannot guess the machine type, give it the
|
||||
`--build=TYPE' option. TYPE can either be a short name for the system
|
||||
type, such as `sun4', or a canonical name which has the form:
|
||||
|
||||
CPU-COMPANY-SYSTEM
|
||||
|
||||
where SYSTEM can have one of these forms:
|
||||
|
||||
OS KERNEL-OS
|
||||
|
||||
See the file `config.sub' for the possible values of each field. If
|
||||
`config.sub' isn't included in this package, then this package doesn't
|
||||
need to know the machine type.
|
||||
|
||||
If you are _building_ compiler tools for cross-compiling, you should
|
||||
use the `--target=TYPE' option to select the type of system they will
|
||||
produce code for.
|
||||
|
||||
If you want to _use_ a cross compiler, that generates code for a
|
||||
platform different from the build platform, you should specify the
|
||||
"host" platform (i.e., that on which the generated programs will
|
||||
eventually be run) with `--host=TYPE'.
|
||||
|
||||
Sharing Defaults
|
||||
================
|
||||
|
||||
If you want to set default values for `configure' scripts to share,
|
||||
you can create a site shell script called `config.site' that gives
|
||||
default values for variables like `CC', `cache_file', and `prefix'.
|
||||
`configure' looks for `PREFIX/share/config.site' if it exists, then
|
||||
`PREFIX/etc/config.site' if it exists. Or, you can set the
|
||||
`CONFIG_SITE' environment variable to the location of the site script.
|
||||
A warning: not all `configure' scripts look for a site script.
|
||||
|
||||
Defining Variables
|
||||
==================
|
||||
|
||||
Variables not defined in a site shell script can be set in the
|
||||
environment passed to `configure'. However, some packages may run
|
||||
configure again during the build, and the customized values of these
|
||||
variables may be lost. In order to avoid this problem, you should set
|
||||
them in the `configure' command line, using `VAR=value'. For example:
|
||||
|
||||
./configure CC=/usr/local2/bin/gcc
|
||||
|
||||
will cause the specified gcc to be used as the C compiler (unless it is
|
||||
overridden in the site shell script).
|
||||
|
||||
`configure' Invocation
|
||||
======================
|
||||
|
||||
`configure' recognizes the following options to control how it
|
||||
operates.
|
||||
|
||||
`--help'
|
||||
`-h'
|
||||
Print a summary of the options to `configure', and exit.
|
||||
|
||||
`--version'
|
||||
`-V'
|
||||
Print the version of Autoconf used to generate the `configure'
|
||||
script, and exit.
|
||||
|
||||
`--cache-file=FILE'
|
||||
Enable the cache: use and save the results of the tests in FILE,
|
||||
traditionally `config.cache'. FILE defaults to `/dev/null' to
|
||||
disable caching.
|
||||
|
||||
`--config-cache'
|
||||
`-C'
|
||||
Alias for `--cache-file=config.cache'.
|
||||
|
||||
`--quiet'
|
||||
`--silent'
|
||||
`-q'
|
||||
Do not print messages saying which checks are being made. To
|
||||
suppress all normal output, redirect it to `/dev/null' (any error
|
||||
messages will still be shown).
|
||||
|
||||
`--srcdir=DIR'
|
||||
Look for the package's source code in directory DIR. Usually
|
||||
`configure' can determine that directory automatically.
|
||||
|
||||
`configure' also accepts some other, not widely useful, options. Run
|
||||
`configure --help' for more details.
|
||||
|
||||
149
Icon.cpp
Normal file
149
Icon.cpp
Normal file
@@ -0,0 +1,149 @@
|
||||
// $Id: Icon.cpp 206 2009-03-24 15:22:10Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <wx/mimetype.h>
|
||||
#include <wx/filename.h>
|
||||
#include <wx/bitmap.h>
|
||||
#include <wx/icon.h>
|
||||
#include <wx/image.h>
|
||||
#include <wx/filesys.h>
|
||||
|
||||
#ifdef APP_OPENNX
|
||||
# include "opennxApp.h"
|
||||
#endif
|
||||
#ifdef APP_TRACELOG
|
||||
# include "tracelogApp.h"
|
||||
#endif
|
||||
#ifdef APP_WATCHUSBIP
|
||||
# include "watchUsbIpApp.h"
|
||||
#endif
|
||||
|
||||
static const char * broken_xpm[] = {
|
||||
"14 16 17 1",
|
||||
" c None",
|
||||
". c #000000",
|
||||
"+ c #800000",
|
||||
"@ c #008000",
|
||||
"# c #808000",
|
||||
"$ c #000080",
|
||||
"% c #800080",
|
||||
"& c #008080",
|
||||
"* c #C0C0C0",
|
||||
"= c #808080",
|
||||
"- c #FF0000",
|
||||
"; c #00FF00",
|
||||
"> c #FFFF00",
|
||||
", c #0000FF",
|
||||
"' c #FF00FF",
|
||||
") c #00FFFF",
|
||||
"! c #FFFFFF",
|
||||
"..........= ",
|
||||
".!!!!!!!!!== ",
|
||||
".!********=!= ",
|
||||
".!***@@***=!!=",
|
||||
".!**@;@.**....",
|
||||
".!**@@@.****!.",
|
||||
".!***..*****!.",
|
||||
".!******,,,.! ",
|
||||
".!*-****,),.! ",
|
||||
".!*'-***,,$ ",
|
||||
".!*''-**.. !.",
|
||||
".!*'''-* *!.",
|
||||
".!*... *!.",
|
||||
".!** ***!.",
|
||||
".!! !!!!!.",
|
||||
".. ......"
|
||||
};
|
||||
|
||||
wxBitmap CreateBitmapFromFile(const wxString &filename, int width, int height)
|
||||
{
|
||||
wxFileName fn(filename);
|
||||
wxFileType *ft = wxTheMimeTypesManager->GetFileTypeFromExtension(fn.GetExt());
|
||||
|
||||
wxBitmap bm(broken_xpm);
|
||||
if (ft) {
|
||||
wxString mt;
|
||||
if (ft->GetMimeType(&mt)) {
|
||||
wxBitmapType t = wxBITMAP_TYPE_INVALID;
|
||||
|
||||
if (mt == _T("image/png"))
|
||||
t = wxBITMAP_TYPE_PNG;
|
||||
if (mt == _T("image/bmp"))
|
||||
t = wxBITMAP_TYPE_BMP;
|
||||
if (mt == _T("image/gif"))
|
||||
t = wxBITMAP_TYPE_GIF;
|
||||
if (mt == _T("image/x-bitmap"))
|
||||
t = wxBITMAP_TYPE_XBM;
|
||||
if (mt == _T("image/jpeg"))
|
||||
t = wxBITMAP_TYPE_JPEG;
|
||||
if (mt == _T("image/tiff"))
|
||||
t = wxBITMAP_TYPE_TIF;
|
||||
if (mt == _T("image/pcx"))
|
||||
t = wxBITMAP_TYPE_PCX;
|
||||
if (mt == _T("image/pnm"))
|
||||
t = wxBITMAP_TYPE_PNM;
|
||||
|
||||
if (t != wxBITMAP_TYPE_INVALID) {
|
||||
wxBitmap rbm;
|
||||
wxFileSystem fs;
|
||||
wxFSFile *f = fs.OpenFile(::wxGetApp().GetResourcePrefix() + filename);
|
||||
if (f) {
|
||||
wxInputStream *s = f->GetStream();
|
||||
if (s && s->IsOk()) {
|
||||
wxImage wi(*s, t);
|
||||
rbm = wxBitmap(wi);
|
||||
}
|
||||
delete f;
|
||||
}
|
||||
if (rbm.Ok())
|
||||
bm = rbm;
|
||||
}
|
||||
}
|
||||
delete ft;
|
||||
}
|
||||
if (width == -1)
|
||||
width = bm.GetWidth();
|
||||
if (height == -1)
|
||||
height = bm.GetHeight();
|
||||
if ((width != bm.GetWidth()) || (height != bm.GetHeight()))
|
||||
bm = wxBitmap(bm.ConvertToImage().Scale(width, height));
|
||||
return bm;
|
||||
}
|
||||
|
||||
wxIcon CreateIconFromFile(const wxString &filename, int width, int height)
|
||||
{
|
||||
wxIcon icon = wxNullIcon;
|
||||
wxBitmap bm = CreateBitmapFromFile(filename, width, height);
|
||||
if (bm.Ok())
|
||||
icon.CopyFromBitmap(bm);
|
||||
return icon;
|
||||
}
|
||||
27
Icon.h
Normal file
27
Icon.h
Normal file
@@ -0,0 +1,27 @@
|
||||
// $Id: Icon.h 84 2006-12-13 06:14:36Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _ICON_H_
|
||||
#define _ICON_H_
|
||||
|
||||
extern wxIcon CreateIconFromFile(const wxString &, int width = -1, int height = -1);
|
||||
extern wxBitmap CreateBitmapFromFile(const wxString &, int width = -1, int height = -1);
|
||||
#endif
|
||||
259
KeyDialog.cpp
Normal file
259
KeyDialog.cpp
Normal file
@@ -0,0 +1,259 @@
|
||||
// $Id: KeyDialog.cpp 683 2012-02-09 23:37:19Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
||||
#pragma implementation "KeyDialog.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
////@begin includes
|
||||
////@end includes
|
||||
|
||||
#include "KeyDialog.h"
|
||||
#include "Icon.h"
|
||||
#include "opennxApp.h"
|
||||
|
||||
#include <wx/config.h>
|
||||
#include <wx/cshelp.h>
|
||||
|
||||
////@begin XPM images
|
||||
////@end XPM images
|
||||
|
||||
/*!
|
||||
* KeyDialog type definition
|
||||
*/
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS( KeyDialog, wxDialog )
|
||||
|
||||
/*!
|
||||
* KeyDialog event table definition
|
||||
*/
|
||||
|
||||
BEGIN_EVENT_TABLE( KeyDialog, wxDialog )
|
||||
|
||||
////@begin KeyDialog event table entries
|
||||
EVT_TEXT( XRCID("ID_TEXTCTRL_SSHKEY"), KeyDialog::OnTextctrlSshkeyUpdated )
|
||||
|
||||
EVT_BUTTON( XRCID("ID_BUTTON_IMPORT"), KeyDialog::OnButtonImportClick )
|
||||
|
||||
EVT_BUTTON( wxID_DEFAULT, KeyDialog::OnDEFAULTClick )
|
||||
|
||||
EVT_BUTTON( wxID_SAVE, KeyDialog::OnSAVEClick )
|
||||
|
||||
////@end KeyDialog event table entries
|
||||
|
||||
EVT_MENU(wxID_CONTEXT_HELP, KeyDialog::OnContextHelp)
|
||||
|
||||
END_EVENT_TABLE()
|
||||
|
||||
/*!
|
||||
* KeyDialog constructors
|
||||
*/
|
||||
|
||||
KeyDialog::KeyDialog( )
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
KeyDialog::KeyDialog( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
||||
{
|
||||
Init();
|
||||
Create(parent, id, caption, pos, size, style);
|
||||
}
|
||||
|
||||
/*!
|
||||
* KeyDialog creator
|
||||
*/
|
||||
|
||||
bool KeyDialog::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
||||
{
|
||||
////@begin KeyDialog creation
|
||||
SetExtraStyle(wxWS_EX_BLOCK_EVENTS|wxDIALOG_EX_CONTEXTHELP);
|
||||
SetParent(parent);
|
||||
CreateControls();
|
||||
SetIcon(GetIconResource(wxT("res/nx.png")));
|
||||
if (GetSizer())
|
||||
{
|
||||
GetSizer()->SetSizeHints(this);
|
||||
}
|
||||
Centre();
|
||||
////@end KeyDialog creation
|
||||
wxUnusedVar(style);
|
||||
wxUnusedVar(size);
|
||||
wxUnusedVar(pos);
|
||||
wxUnusedVar(caption);
|
||||
wxUnusedVar(id);
|
||||
::wxGetApp().EnableContextHelp(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Member initialisation
|
||||
*/
|
||||
|
||||
void KeyDialog::Init()
|
||||
{
|
||||
////@begin KeyDialog member initialisation
|
||||
m_sSshKey = wxT("");
|
||||
m_pCtrlSshKey = NULL;
|
||||
m_pCtrlSave = NULL;
|
||||
////@end KeyDialog member initialisation
|
||||
}
|
||||
/*!
|
||||
* Control creation for KeyDialog
|
||||
*/
|
||||
|
||||
void KeyDialog::CreateControls()
|
||||
{
|
||||
////@begin KeyDialog content construction
|
||||
if (!wxXmlResource::Get()->LoadDialog(this, GetParent(), _T("ID_KEYDIALOG")))
|
||||
wxLogError(wxT("Missing wxXmlResource::Get()->Load() in OnInit()?"));
|
||||
m_pCtrlSshKey = XRCCTRL(*this, "ID_TEXTCTRL_SSHKEY", wxTextCtrl);
|
||||
m_pCtrlSave = XRCCTRL(*this, "wxID_SAVE", wxButton);
|
||||
// Set validators
|
||||
if (FindWindow(XRCID("ID_TEXTCTRL_SSHKEY")))
|
||||
FindWindow(XRCID("ID_TEXTCTRL_SSHKEY"))->SetValidator( wxGenericValidator(& m_sSshKey) );
|
||||
////@end KeyDialog content construction
|
||||
// Create custom windows not generated automatically here.
|
||||
////@begin KeyDialog content initialisation
|
||||
////@end KeyDialog content initialisation
|
||||
}
|
||||
|
||||
/*!
|
||||
* Should we show tooltips?
|
||||
*/
|
||||
|
||||
bool KeyDialog::ShowToolTips()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get bitmap resources
|
||||
*/
|
||||
|
||||
wxBitmap KeyDialog::GetBitmapResource( const wxString& name )
|
||||
{
|
||||
// Bitmap retrieval
|
||||
return CreateBitmapFromFile(name);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get icon resources
|
||||
*/
|
||||
|
||||
wxIcon KeyDialog::GetIconResource( const wxString& name )
|
||||
{
|
||||
// Icon retrieval
|
||||
////@begin KeyDialog icon retrieval
|
||||
wxUnusedVar(name);
|
||||
return wxNullIcon;
|
||||
////@end KeyDialog icon retrieval
|
||||
}
|
||||
|
||||
void KeyDialog::CheckChanged()
|
||||
{
|
||||
m_pCtrlSave->Enable(m_pCtrlSshKey->GetValue() != m_sSshKey);
|
||||
}
|
||||
|
||||
void KeyDialog::OnContextHelp(wxCommandEvent &)
|
||||
{
|
||||
wxContextHelp contextHelp(this);
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_IMPORT
|
||||
*/
|
||||
|
||||
void KeyDialog::OnButtonImportClick( wxCommandEvent& event )
|
||||
{
|
||||
wxString keyDir;
|
||||
if (!wxConfigBase::Get()->Read(wxT("Recent/KeyImport"), &keyDir)) {
|
||||
keyDir = ::wxGetHomeDir() + wxFileName::GetPathSeparator() + wxT(".ssh");
|
||||
if (!wxFileName(keyDir).IsDirReadable())
|
||||
keyDir = ::wxGetHomeDir();
|
||||
}
|
||||
wxFileDialog d(this, _("Select key to import"), keyDir, wxEmptyString,
|
||||
_("SSh key files (*.key)|*.key|All files (*)|*"), wxFD_OPEN|wxFD_FILE_MUST_EXIST);
|
||||
d.SetDirectory(keyDir);
|
||||
if (d.ShowModal() == wxID_OK) {
|
||||
m_pCtrlSshKey->LoadFile(d.GetPath());
|
||||
wxConfigBase::Get()->Write(wxT("Recent/KeyImport"), d.GetDirectory());
|
||||
CheckChanged();
|
||||
}
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_DEFAULT
|
||||
*/
|
||||
|
||||
void KeyDialog::OnDEFAULTClick( wxCommandEvent& event )
|
||||
{
|
||||
wxString fn;
|
||||
wxConfigBase::Get()->Read(wxT("Config/SystemNxDir"), &fn);
|
||||
fn << wxFileName::GetPathSeparator() << wxT("share")
|
||||
<< wxFileName::GetPathSeparator() << wxT("keys")
|
||||
<< wxFileName::GetPathSeparator() << wxT("server.id_dsa.key");
|
||||
m_pCtrlSshKey->LoadFile(fn);
|
||||
CheckChanged();
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_SAVE
|
||||
*/
|
||||
|
||||
void KeyDialog::OnSAVEClick( wxCommandEvent& event )
|
||||
{
|
||||
wxUnusedVar(event);
|
||||
TransferDataFromWindow();
|
||||
CheckChanged();
|
||||
EndModal(wxID_OK);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_TEXT_UPDATED event handler for ID_TEXTCTRL_SSHKEY
|
||||
*/
|
||||
|
||||
void KeyDialog::OnTextctrlSshkeyUpdated( wxCommandEvent& event )
|
||||
{
|
||||
CheckChanged();
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
|
||||
|
||||
140
KeyDialog.h
Normal file
140
KeyDialog.h
Normal file
@@ -0,0 +1,140 @@
|
||||
// $Id: KeyDialog.h 590 2010-10-23 22:42:11Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _KEYDIALOG_H_
|
||||
#define _KEYDIALOG_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
||||
#pragma interface "KeyDialog.h"
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* Includes
|
||||
*/
|
||||
|
||||
////@begin includes
|
||||
#include "KeyDialog_symbols.h"
|
||||
#include "wx/xrc/xmlres.h"
|
||||
#include "wx/valgen.h"
|
||||
#include "wx/statline.h"
|
||||
////@end includes
|
||||
|
||||
/*!
|
||||
* Forward declarations
|
||||
*/
|
||||
|
||||
////@begin forward declarations
|
||||
////@end forward declarations
|
||||
|
||||
/*!
|
||||
* Control identifiers
|
||||
*/
|
||||
|
||||
////@begin control identifiers
|
||||
#define ID_KEYDIALOG 10122
|
||||
#define SYMBOL_KEYDIALOG_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX
|
||||
#define SYMBOL_KEYDIALOG_TITLE _("Key Management - OpenNX")
|
||||
#define SYMBOL_KEYDIALOG_IDNAME ID_KEYDIALOG
|
||||
#define SYMBOL_KEYDIALOG_SIZE wxSize(400, 300)
|
||||
#define SYMBOL_KEYDIALOG_POSITION wxDefaultPosition
|
||||
////@end control identifiers
|
||||
|
||||
/*!
|
||||
* Compatibility
|
||||
*/
|
||||
|
||||
#ifndef wxCLOSE_BOX
|
||||
#define wxCLOSE_BOX 0x1000
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* KeyDialog class declaration
|
||||
*/
|
||||
|
||||
class KeyDialog: public wxDialog
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS( KeyDialog )
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
public:
|
||||
/// Constructors
|
||||
KeyDialog( );
|
||||
KeyDialog( wxWindow* parent, wxWindowID id = SYMBOL_KEYDIALOG_IDNAME, const wxString& caption = SYMBOL_KEYDIALOG_TITLE, const wxPoint& pos = SYMBOL_KEYDIALOG_POSITION, const wxSize& size = SYMBOL_KEYDIALOG_SIZE, long style = SYMBOL_KEYDIALOG_STYLE );
|
||||
|
||||
/// Creation
|
||||
bool Create( wxWindow* parent, wxWindowID id = SYMBOL_KEYDIALOG_IDNAME, const wxString& caption = SYMBOL_KEYDIALOG_TITLE, const wxPoint& pos = SYMBOL_KEYDIALOG_POSITION, const wxSize& size = SYMBOL_KEYDIALOG_SIZE, long style = SYMBOL_KEYDIALOG_STYLE );
|
||||
|
||||
/// Initialises member variables
|
||||
void Init();
|
||||
|
||||
/// Creates the controls and sizers
|
||||
void CreateControls();
|
||||
|
||||
private:
|
||||
|
||||
void CheckChanged();
|
||||
|
||||
void OnContextHelp(wxCommandEvent &);
|
||||
|
||||
////@begin KeyDialog event handler declarations
|
||||
|
||||
/// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_TEXTCTRL_SSHKEY
|
||||
void OnTextctrlSshkeyUpdated( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_IMPORT
|
||||
void OnButtonImportClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_DEFAULT
|
||||
void OnDEFAULTClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_SAVE
|
||||
void OnSAVEClick( wxCommandEvent& event );
|
||||
|
||||
////@end KeyDialog event handler declarations
|
||||
|
||||
public:
|
||||
|
||||
////@begin KeyDialog member function declarations
|
||||
|
||||
wxString GetSshKey() const { return m_sSshKey ; }
|
||||
void SetSshKey(wxString value) { m_sSshKey = value ; }
|
||||
|
||||
/// Retrieves bitmap resources
|
||||
wxBitmap GetBitmapResource( const wxString& name );
|
||||
|
||||
/// Retrieves icon resources
|
||||
wxIcon GetIconResource( const wxString& name );
|
||||
////@end KeyDialog member function declarations
|
||||
|
||||
/// Should we show tooltips?
|
||||
static bool ShowToolTips();
|
||||
|
||||
private:
|
||||
////@begin KeyDialog member variables
|
||||
wxTextCtrl* m_pCtrlSshKey;
|
||||
wxButton* m_pCtrlSave;
|
||||
private:
|
||||
wxString m_sSshKey;
|
||||
////@end KeyDialog member variables
|
||||
};
|
||||
|
||||
#endif
|
||||
// _KEYDIALOG_H_
|
||||
26
KeyDialog_symbols.h
Normal file
26
KeyDialog_symbols.h
Normal file
@@ -0,0 +1,26 @@
|
||||
// $Id: KeyDialog_symbols.h 590 2010-10-23 22:42:11Z felfert $
|
||||
//
|
||||
// Copyright (C) 2010 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#define ID_KEYDIALOG_SYMBOL_0 _("Key Management - OpenNX")
|
||||
#define ID_KEYDIALOG_SYMBOL_1 _("&Import")
|
||||
#define ID_KEYDIALOG_SYMBOL_2 _("&Default")
|
||||
#define ID_KEYDIALOG_SYMBOL_3 _("&Save")
|
||||
#define ID_KEYDIALOG_SYMBOL_4 _("&Cancel")
|
||||
387
LibOpenSC.cpp
Normal file
387
LibOpenSC.cpp
Normal file
@@ -0,0 +1,387 @@
|
||||
// $Id: LibOpenSC.cpp 451 2010-01-27 12:24:56Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma implementation "LibOpenSC.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#include <wx/event.h>
|
||||
#include <wx/thread.h>
|
||||
#include <wx/process.h>
|
||||
#include <wx/config.h>
|
||||
|
||||
#include "MyDynlib.h"
|
||||
#include "LibOpenSC.h"
|
||||
#ifdef APP_OPENNX
|
||||
# include "opennxApp.h"
|
||||
# include "CardWaiterDialog.h"
|
||||
#endif
|
||||
#ifdef APP_WATCHREADER
|
||||
# include "watchReaderApp.h"
|
||||
#endif
|
||||
|
||||
#include "trace.h"
|
||||
ENABLE_TRACE;
|
||||
|
||||
#ifdef __WXMAC__
|
||||
// Current SCA implementation on MacOSX does not
|
||||
// allow multiple applications. So we use the same
|
||||
// context like nxssh.
|
||||
# define OPENSC_CTXNAME "openssh"
|
||||
#else
|
||||
# define OPENSC_CTXNAME "opennx"
|
||||
#endif
|
||||
|
||||
#include <opensc/opensc.h>
|
||||
typedef int (*Tsc_establish_context)(sc_context_t **ctx, const char *app_name);
|
||||
typedef int (*Tsc_release_context)(sc_context_t *ctx);
|
||||
typedef int (*Tsc_detect_card_presence)(sc_reader_t *reader, int slot_id);
|
||||
|
||||
#ifdef APP_OPENNX
|
||||
DEFINE_LOCAL_EVENT_TYPE(wxEVT_CARDINSERTED);
|
||||
|
||||
class CardWaitThread : public wxThreadHelper
|
||||
{
|
||||
public:
|
||||
CardWaitThread(wxEvtHandler *handler = NULL);
|
||||
virtual ~CardWaitThread();
|
||||
|
||||
virtual wxThread::ExitCode Entry();
|
||||
|
||||
bool IsOk() { return m_bOk; }
|
||||
int GetReader() { return m_iFoundID; }
|
||||
void SetHandler(wxEvtHandler *handler) { m_pEvtHandler = handler; }
|
||||
|
||||
private:
|
||||
wxEvtHandler *m_pEvtHandler;
|
||||
bool m_bOk;
|
||||
bool m_bTerminate;
|
||||
bool m_bFirstLoopDone;
|
||||
int m_iFoundID;
|
||||
};
|
||||
|
||||
CardWaitThread::CardWaitThread(wxEvtHandler *handler)
|
||||
: wxThreadHelper()
|
||||
, m_pEvtHandler(handler)
|
||||
, m_bOk(false)
|
||||
, m_bTerminate(false)
|
||||
, m_bFirstLoopDone(false)
|
||||
, m_iFoundID(-1)
|
||||
{
|
||||
if (CreateThread(
|
||||
#ifdef __OPENBSD__
|
||||
32768
|
||||
#endif
|
||||
) == wxTHREAD_NO_ERROR) {
|
||||
GetThread()->Run();
|
||||
while ((!m_bFirstLoopDone) && GetThread()->IsRunning())
|
||||
wxThread::Sleep(100);
|
||||
myLogTrace(MYTRACETAG, wxT("opensc API is %savailable"), m_bOk ? wxT("") : wxT("un"));
|
||||
if (m_bOk)
|
||||
myLogTrace(MYTRACETAG, wxT("reader-ID: %d"), (int)m_iFoundID);
|
||||
} else
|
||||
myLogTrace(MYTRACETAG, wxT("could not create waiter thread"));
|
||||
}
|
||||
|
||||
CardWaitThread::~CardWaitThread()
|
||||
{
|
||||
m_pEvtHandler = NULL;
|
||||
if (m_bOk) {
|
||||
m_bTerminate = true;
|
||||
GetThread()->Delete();
|
||||
while (m_bOk)
|
||||
wxThread::Sleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
wxThread::ExitCode
|
||||
CardWaitThread::Entry()
|
||||
{
|
||||
#ifdef __WXMAC__
|
||||
m_bOk = true;
|
||||
wxString cmd;
|
||||
wxConfigBase::Get()->Read(wxT("Config/SystemNxDir"), &cmd);
|
||||
cmd << wxFileName::GetPathSeparator() << wxT("bin")
|
||||
<< wxFileName::GetPathSeparator() << wxT("macfindreader");
|
||||
while (!m_thread->TestDestroy()) {
|
||||
int res = system(cmd.mb_str());
|
||||
if ((res >= 0) && (res < 255)) {
|
||||
if (res != m_iFoundID) {
|
||||
m_iFoundID = res;
|
||||
if (m_pEvtHandler) {
|
||||
wxCommandEvent ev(wxEVT_CARDINSERTED, wxID_ANY);
|
||||
ev.SetInt(m_iFoundID);
|
||||
m_pEvtHandler->AddPendingEvent(ev);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (m_bFirstLoopDone)
|
||||
wxThread::Sleep(500);
|
||||
m_bFirstLoopDone = true;
|
||||
}
|
||||
#else
|
||||
sc_context *ctx;
|
||||
MyDynamicLibrary dll;
|
||||
{
|
||||
wxLogNull ignoreErrors;
|
||||
if (!dll.Load(wxT("libopensc")))
|
||||
return 0;
|
||||
}
|
||||
|
||||
wxDYNLIB_FUNCTION(Tsc_establish_context, sc_establish_context, dll);
|
||||
if (!pfnsc_establish_context)
|
||||
return 0;
|
||||
if (SC_SUCCESS != pfnsc_establish_context(&ctx, OPENSC_CTXNAME))
|
||||
return 0;
|
||||
wxDYNLIB_FUNCTION(Tsc_release_context, sc_release_context, dll);
|
||||
if (!pfnsc_release_context)
|
||||
return 0;
|
||||
|
||||
wxDYNLIB_FUNCTION(Tsc_detect_card_presence, sc_detect_card_presence, dll);
|
||||
if (!pfnsc_detect_card_presence)
|
||||
return 0;
|
||||
|
||||
m_bOk = true;
|
||||
while (!m_thread->TestDestroy()) {
|
||||
if (m_bTerminate)
|
||||
break;
|
||||
int found_id = -1;
|
||||
int r, j;
|
||||
unsigned int i;
|
||||
|
||||
unsigned int rc = ctx->reader_count;
|
||||
if (rc > 0) {
|
||||
unsigned int errc = 0;
|
||||
|
||||
for (i = 0; i < rc; i++) {
|
||||
sc_reader_t *reader = ctx->reader[i];
|
||||
if (!reader)
|
||||
continue;
|
||||
myLogTrace(MYTRACETAG, wxT("Trying reader %d"), i);
|
||||
for (j = 0; j < reader->slot_count; j++) {
|
||||
r = pfnsc_detect_card_presence(reader, j);
|
||||
if (r > 0) {
|
||||
found_id = i;
|
||||
break;
|
||||
}
|
||||
if (r < 0) {
|
||||
errc++;
|
||||
myLogTrace(MYTRACETAG, wxT("error %d during sc_detect_card_presence"), r);
|
||||
}
|
||||
}
|
||||
if (found_id != -1)
|
||||
break;
|
||||
}
|
||||
if (errc >= rc) {
|
||||
myLogTrace(MYTRACETAG, wxT("All readers returned an error"));
|
||||
pfnsc_release_context(ctx);
|
||||
m_bOk = false;
|
||||
return 0;
|
||||
}
|
||||
} else
|
||||
myLogTrace(MYTRACETAG, wxT("no readers found"));
|
||||
if (found_id == -1)
|
||||
myLogTrace(MYTRACETAG, wxT("no cards found"));
|
||||
else {
|
||||
myLogTrace(MYTRACETAG, wxT("found card in reader %d"), found_id);
|
||||
if (found_id != m_iFoundID) {
|
||||
m_iFoundID = found_id;
|
||||
if (m_pEvtHandler) {
|
||||
wxCommandEvent ev(wxEVT_CARDINSERTED, wxID_ANY);
|
||||
ev.SetInt(m_iFoundID);
|
||||
m_pEvtHandler->AddPendingEvent(ev);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (m_bFirstLoopDone)
|
||||
wxThread::Sleep(500);
|
||||
m_bFirstLoopDone = true;
|
||||
}
|
||||
pfnsc_release_context(ctx);
|
||||
#endif
|
||||
m_bOk = false;
|
||||
myLogTrace(MYTRACETAG, wxT("terminating waiter thread"));
|
||||
return 0;
|
||||
}
|
||||
#endif // APP_OPENNX
|
||||
|
||||
LibOpenSC::LibOpenSC()
|
||||
{
|
||||
myLogTrace(MYTRACETAG, wxT("LibOpenSC()"));
|
||||
}
|
||||
|
||||
LibOpenSC::~LibOpenSC()
|
||||
{
|
||||
myLogTrace(MYTRACETAG, wxT("~LibOpenSC()"));
|
||||
}
|
||||
|
||||
bool LibOpenSC::HasOpenSC() {
|
||||
wxLogNull ignoreErrors;
|
||||
MyDynamicLibrary dll;
|
||||
if (!dll.Load(wxT("libopensc")))
|
||||
return false;
|
||||
wxDYNLIB_FUNCTION(Tsc_establish_context, sc_establish_context, dll);
|
||||
if (!pfnsc_establish_context)
|
||||
return false;
|
||||
wxDYNLIB_FUNCTION(Tsc_release_context, sc_release_context, dll);
|
||||
if (!pfnsc_release_context)
|
||||
return false;
|
||||
wxDYNLIB_FUNCTION(Tsc_detect_card_presence, sc_detect_card_presence, dll);
|
||||
if (!pfnsc_detect_card_presence)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef APP_OPENNX
|
||||
int LibOpenSC::WaitForCard(CardWaiterDialog *d) {
|
||||
CardWaitThread t(d);
|
||||
if (t.IsOk() && (t.GetReader() != -1))
|
||||
return t.GetReader();
|
||||
d->ShowModal();
|
||||
return d->GetReader();
|
||||
}
|
||||
#endif
|
||||
|
||||
bool LibOpenSC::WatchHotRemove(unsigned int ridx, long sshpid) {
|
||||
|
||||
MyDynamicLibrary dll;
|
||||
myLogTrace(MYTRACETAG, wxT("WatchHotRemove loading OpenSC"));
|
||||
{
|
||||
wxLogNull ignoreErrors;
|
||||
if (!dll.Load(wxT("libopensc")))
|
||||
return false;
|
||||
}
|
||||
|
||||
myLogTrace(MYTRACETAG, wxT("WatchHotRemove checking OpenSC functions"));
|
||||
wxDYNLIB_FUNCTION(Tsc_establish_context, sc_establish_context, dll);
|
||||
if (!pfnsc_establish_context)
|
||||
return false;
|
||||
wxDYNLIB_FUNCTION(Tsc_release_context, sc_release_context, dll);
|
||||
if (!pfnsc_release_context)
|
||||
return false;
|
||||
wxDYNLIB_FUNCTION(Tsc_detect_card_presence, sc_detect_card_presence, dll);
|
||||
if (!pfnsc_detect_card_presence)
|
||||
return false;
|
||||
|
||||
sc_context *ctx = NULL;
|
||||
myLogTrace(MYTRACETAG, wxT("WatchHotRemove waiting for card removal"));
|
||||
myLogTrace(MYTRACETAG, wxT("WatchHotRemove trying to establish context"));
|
||||
if (SC_SUCCESS == pfnsc_establish_context(&ctx, OPENSC_CTXNAME)) {
|
||||
while (true) {
|
||||
if (sshpid != 0) {
|
||||
if (!wxProcess::Exists(sshpid)) {
|
||||
myLogTrace(MYTRACETAG, wxT("nxssh pid %d has terminated"), (int)sshpid);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
unsigned int rc = ctx->reader_count;
|
||||
if (rc <= ridx) {
|
||||
// reader is gone
|
||||
myLogTrace(MYTRACETAG, wxT("reader is gone"));
|
||||
break;
|
||||
}
|
||||
sc_reader_t *reader = ctx->reader[ridx];
|
||||
if (reader) {
|
||||
int r = 1;
|
||||
int j;
|
||||
for (j = 0; j < reader->slot_count; j++) {
|
||||
myLogTrace(MYTRACETAG, wxT("WatchHotRemove checking for card in reader %d, slot %d"), ridx, j);
|
||||
r = pfnsc_detect_card_presence(reader, j);
|
||||
if (r == 0) {
|
||||
// card is gone
|
||||
myLogTrace(MYTRACETAG, wxT("card is gone"));
|
||||
break;
|
||||
}
|
||||
if (r < 0) {
|
||||
myLogTrace(MYTRACETAG, wxT("error %d during sc_detect_card_presence"), r);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (r <= 0)
|
||||
break;
|
||||
} else {
|
||||
myLogTrace(MYTRACETAG, wxT("no readers found"));
|
||||
break;
|
||||
}
|
||||
while (wxGetApp().Pending())
|
||||
wxGetApp().Dispatch();
|
||||
wxThread::Sleep(1000);
|
||||
}
|
||||
} else
|
||||
myLogTrace(MYTRACETAG, wxT("could not establish context"));
|
||||
if (ctx)
|
||||
pfnsc_release_context(ctx);
|
||||
if (sshpid != 0) {
|
||||
myLogTrace(MYTRACETAG, wxT("Sending HUP to nxssh pid %d"), (int)sshpid);
|
||||
int trycount = 10;
|
||||
while (wxProcess::Exists(sshpid) && (0 < trycount)) {
|
||||
wxProcess::Kill(sshpid, wxSIGHUP);
|
||||
while (::wxGetApp().Pending())
|
||||
::wxGetApp().Dispatch();
|
||||
wxThread::Sleep(500);
|
||||
trycount--;
|
||||
}
|
||||
if (!wxProcess::Exists(sshpid))
|
||||
return true;
|
||||
// Again, this time SIGTERM
|
||||
myLogTrace(MYTRACETAG, wxT("Sending TERM to nxssh pid %d"), (int)sshpid);
|
||||
trycount = 10;
|
||||
while (wxProcess::Exists(sshpid) && (0 < trycount)) {
|
||||
wxProcess::Kill(sshpid, wxSIGTERM);
|
||||
while (::wxGetApp().Pending())
|
||||
::wxGetApp().Dispatch();
|
||||
wxThread::Sleep(500);
|
||||
trycount--;
|
||||
}
|
||||
if (!wxProcess::Exists(sshpid))
|
||||
return true;
|
||||
// Finally, use brute force
|
||||
myLogTrace(MYTRACETAG, wxT("Sending KILL to nxssh pid %d"), (int)sshpid);
|
||||
trycount = 10;
|
||||
while (wxProcess::Exists(sshpid) && (0 < trycount)) {
|
||||
wxProcess::Kill(sshpid, wxSIGKILL);
|
||||
while (::wxGetApp().Pending())
|
||||
::wxGetApp().Dispatch();
|
||||
wxThread::Sleep(500);
|
||||
trycount--;
|
||||
}
|
||||
if (!wxProcess::Exists(sshpid))
|
||||
return true;
|
||||
wxLogError(_("Could not terminate nxssh"));
|
||||
} else
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
64
LibOpenSC.h
Normal file
64
LibOpenSC.h
Normal file
@@ -0,0 +1,64 @@
|
||||
// $Id: LibOpenSC.h 325 2009-07-29 21:38:53Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _LIBOPENSC_H_
|
||||
#define _LIBOPENSC_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "LibOpenSC.cpp"
|
||||
#endif
|
||||
|
||||
#ifdef APP_OPENNX
|
||||
DECLARE_LOCAL_EVENT_TYPE(wxEVT_CARDINSERTED, -5);
|
||||
#endif
|
||||
|
||||
class CardWaiterDialog;
|
||||
|
||||
/**
|
||||
* LibOpenSC uses opensc (http://www.opensc-project.org/) to access
|
||||
* local smart cards. It watches for insertion of a smart card
|
||||
* and shows a message box for instructing the user to insert a
|
||||
* smart card if none is found.
|
||||
*/
|
||||
class LibOpenSC
|
||||
{
|
||||
public:
|
||||
LibOpenSC();
|
||||
virtual ~LibOpenSC();
|
||||
|
||||
/**
|
||||
* Waits for insertion of a smart card.
|
||||
* Returns immediately, if a card is already
|
||||
* inserted. Otherwise, shows a dialog which instructs
|
||||
* the user to insert a card. The user can hit a Cancel
|
||||
* button in that dialog to abort the transaction.
|
||||
*
|
||||
* @return: -1 on abort or error. The reader-number where
|
||||
* the card was inserted otherwise.
|
||||
*/
|
||||
#ifdef APP_OPENNX
|
||||
int WaitForCard(CardWaiterDialog *);
|
||||
#endif
|
||||
bool HasOpenSC();
|
||||
bool WatchHotRemove(unsigned int, long);
|
||||
};
|
||||
|
||||
#endif
|
||||
266
LibUSB.cpp
Normal file
266
LibUSB.cpp
Normal file
@@ -0,0 +1,266 @@
|
||||
// $Id: LibUSB.cpp 605 2011-02-22 04:00:58Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
||||
#pragma implementation "LibUSB.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/defs.h"
|
||||
#endif
|
||||
|
||||
#include "MyDynlib.h"
|
||||
#include "LibUSB.h"
|
||||
|
||||
#include <wx/wfstream.h>
|
||||
#include <wx/txtstrm.h>
|
||||
#include <wx/log.h>
|
||||
#include <wx/arrimpl.cpp>
|
||||
|
||||
#include "trace.h"
|
||||
ENABLE_TRACE;
|
||||
|
||||
WX_DEFINE_OBJARRAY(ArrayOfUSBDevices);
|
||||
|
||||
#ifdef SUPPORT_USBIP
|
||||
#include <usb.h>
|
||||
|
||||
typedef void (*Tusb_init)(void);
|
||||
typedef int (*Tusb_find_busses)(void);
|
||||
typedef int (*Tusb_find_devices)(void);
|
||||
typedef struct usb_bus *(*Tusb_get_busses)(void);
|
||||
typedef int (*Tusb_get_string_simple)(usb_dev_handle *dev, int index, char *buf,
|
||||
size_t buflen);
|
||||
typedef usb_dev_handle *(*Tusb_open)(struct usb_device *dev);
|
||||
typedef int (*Tusb_close)(usb_dev_handle *dev);
|
||||
#endif
|
||||
|
||||
USBDevice::USBDevice(int v, int p, unsigned char c) {
|
||||
m_iVendor = v;
|
||||
m_iProduct = p;
|
||||
m_iClass = c;
|
||||
}
|
||||
|
||||
wxString USBDevice::toString() {
|
||||
wxString ret = wxString::Format(wxT("%d-%d %04X/%04X/%02X"),
|
||||
(int)m_iBusNum, (int)m_iDevNum, (int)m_iVendor,
|
||||
(int)m_iProduct, (int)m_iClass);
|
||||
if (!m_sVendor.IsEmpty())
|
||||
ret.Append(wxT(" ")).Append(m_sVendor);
|
||||
if (!m_sProduct.IsEmpty())
|
||||
ret.Append(wxT(" ")).Append(m_sProduct);
|
||||
if (!m_sSerial.IsEmpty())
|
||||
ret.Append(wxT(" #")).Append(m_sSerial);
|
||||
return ret;
|
||||
}
|
||||
|
||||
wxString USBDevice::toShortString() {
|
||||
wxString ret = m_sVendor;
|
||||
if ((!ret.IsEmpty()) && (!m_sProduct.IsEmpty()))
|
||||
ret.Append(wxT(" "));
|
||||
ret.Append(m_sProduct);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_USBIP
|
||||
static wxString readSysfs(int bus, int dev, const wxString &attr)
|
||||
{
|
||||
wxLogNull nolog;
|
||||
int i;
|
||||
// Find the device with the specified devnum
|
||||
for (i = 0; i < 16 ; ++i) {
|
||||
wxString path(wxString::Format(wxT("/sys/bus/usb/devices/%d-%d/devnum"), bus, i));
|
||||
wxFileInputStream fis(path);
|
||||
wxTextInputStream tis(fis);
|
||||
if (dev == tis.Read16S())
|
||||
break;
|
||||
}
|
||||
// Read the attribute
|
||||
wxString path(wxString::Format(wxT("/sys/bus/usb/devices/%d-%d/%s"), bus, i, attr.c_str()));
|
||||
wxFileInputStream fis(path);
|
||||
wxTextInputStream tis(fis);
|
||||
return tis.ReadLine();
|
||||
}
|
||||
#endif
|
||||
|
||||
void USB::adddev(MyDynamicLibrary *dll, struct usb_device *dev, unsigned char dclass)
|
||||
{
|
||||
#ifdef SUPPORT_USBIP
|
||||
usb_dev_handle *udev;
|
||||
char string[256];
|
||||
|
||||
switch (dclass) {
|
||||
case USB_CLASS_HUB:
|
||||
case USB_CLASS_HID:
|
||||
return;
|
||||
}
|
||||
|
||||
wxDYNLIB_FUNCTION(Tusb_open, usb_open, *dll);
|
||||
if (!pfnusb_open)
|
||||
return;
|
||||
wxDYNLIB_FUNCTION(Tusb_close, usb_close, *dll);
|
||||
if (!pfnusb_close)
|
||||
return;
|
||||
wxDYNLIB_FUNCTION(Tusb_get_string_simple, usb_get_string_simple, *dll);
|
||||
if (!pfnusb_get_string_simple)
|
||||
return;
|
||||
udev = pfnusb_open(dev);
|
||||
if (!udev)
|
||||
return;
|
||||
USBDevice d(dev->descriptor.idVendor, dev->descriptor.idProduct, dclass);
|
||||
if (dev->descriptor.iManufacturer) {
|
||||
if (0 < pfnusb_get_string_simple(udev,
|
||||
dev->descriptor.iManufacturer, string, sizeof(string)))
|
||||
d.m_sVendor = wxConvUTF8.cMB2WX(string);
|
||||
}
|
||||
|
||||
if (dev->descriptor.iProduct) {
|
||||
if (0 < pfnusb_get_string_simple(udev,
|
||||
dev->descriptor.iProduct, string, sizeof(string)))
|
||||
d.m_sProduct = wxConvUTF8.cMB2WX(string);
|
||||
}
|
||||
if (dev->descriptor.iSerialNumber) {
|
||||
if (0 < pfnusb_get_string_simple(udev,
|
||||
dev->descriptor.iSerialNumber, string, sizeof(string)))
|
||||
d.m_sSerial = wxConvUTF8.cMB2WX(string);
|
||||
}
|
||||
wxString tmp(dev->bus->dirname, wxConvUTF8);
|
||||
long lval;
|
||||
tmp.ToLong(&lval);
|
||||
d.m_iBusNum = lval;
|
||||
tmp = wxConvUTF8.cMB2WX(dev->filename);
|
||||
tmp.ToLong(&lval);
|
||||
d.m_iDevNum = lval;
|
||||
|
||||
// Try fallback to sysfs, if libusb could not read info due to
|
||||
// permission problems.
|
||||
if (d.m_sVendor.IsEmpty()) {
|
||||
d.m_sVendor = readSysfs(d.m_iBusNum, d.m_iDevNum, wxT("manufacturer"));
|
||||
}
|
||||
if (d.m_sProduct.IsEmpty()) {
|
||||
d.m_sProduct = readSysfs(d.m_iBusNum, d.m_iDevNum, wxT("product"));
|
||||
}
|
||||
if (d.m_sSerial.IsEmpty()) {
|
||||
d.m_sSerial = readSysfs(d.m_iBusNum, d.m_iDevNum, wxT("serial"));
|
||||
}
|
||||
|
||||
myLogTrace(MYTRACETAG, wxT("Device found: %s"), VMB(d.toString()));
|
||||
m_aDevices.Add(d);
|
||||
pfnusb_close(udev);
|
||||
#else
|
||||
wxUnusedVar(dll);
|
||||
wxUnusedVar(dev);
|
||||
wxUnusedVar(dclass);
|
||||
#endif
|
||||
}
|
||||
|
||||
void USB::usbscan(MyDynamicLibrary *dll)
|
||||
{
|
||||
#ifdef SUPPORT_USBIP
|
||||
struct usb_bus *bus;
|
||||
|
||||
wxDYNLIB_FUNCTION(Tusb_find_busses, usb_find_busses, *dll);
|
||||
if (!pfnusb_find_busses)
|
||||
return;
|
||||
wxDYNLIB_FUNCTION(Tusb_find_devices, usb_find_devices, *dll);
|
||||
if (!pfnusb_find_devices)
|
||||
return;
|
||||
wxDYNLIB_FUNCTION(Tusb_get_busses, usb_get_busses, *dll);
|
||||
if (!pfnusb_get_busses)
|
||||
return;
|
||||
pfnusb_find_busses();
|
||||
pfnusb_find_devices();
|
||||
for (bus = pfnusb_get_busses(); bus; bus = bus->next) {
|
||||
struct usb_device *dev;
|
||||
for (dev = bus->devices; dev; dev = dev->next) {
|
||||
int devclass = dev->descriptor.bDeviceClass;
|
||||
|
||||
if ((devclass == USB_CLASS_PER_INTERFACE) && (dev->config)) {
|
||||
for (int c = 0; c < dev->descriptor.bNumConfigurations; c++) {
|
||||
struct usb_config_descriptor *cfg = &dev->config[c];
|
||||
for (int i = 0; i < cfg->bNumInterfaces; i++) {
|
||||
struct usb_interface *uif = &cfg->interface[i];
|
||||
for (int ac = 0; ac < uif->num_altsetting; ac++)
|
||||
adddev(dll, dev, uif->altsetting[ac].bInterfaceClass);
|
||||
}
|
||||
}
|
||||
} else
|
||||
adddev(dll, dev, devclass);
|
||||
}
|
||||
}
|
||||
#else
|
||||
wxUnusedVar(dll);
|
||||
#endif
|
||||
}
|
||||
|
||||
USB::USB() {
|
||||
m_bAvailable = false;
|
||||
#ifdef SUPPORT_USBIP
|
||||
wxLogNull noerrors;
|
||||
MyDynamicLibrary dll;
|
||||
if (dll.Load(wxT("libusb"))) {
|
||||
wxDYNLIB_FUNCTION(Tusb_init, usb_init, dll);
|
||||
if (!pfnusb_init)
|
||||
return;
|
||||
wxDYNLIB_FUNCTION(Tusb_find_busses, usb_find_busses, dll);
|
||||
if (!pfnusb_find_busses)
|
||||
return;
|
||||
wxDYNLIB_FUNCTION(Tusb_find_devices, usb_find_devices, dll);
|
||||
if (!pfnusb_find_devices)
|
||||
return;
|
||||
wxDYNLIB_FUNCTION(Tusb_get_busses, usb_get_busses, dll);
|
||||
if (!pfnusb_get_busses)
|
||||
return;
|
||||
wxDYNLIB_FUNCTION(Tusb_open, usb_open, dll);
|
||||
if (!pfnusb_open)
|
||||
return;
|
||||
wxDYNLIB_FUNCTION(Tusb_close, usb_close, dll);
|
||||
if (!pfnusb_close)
|
||||
return;
|
||||
wxDYNLIB_FUNCTION(Tusb_get_string_simple, usb_get_string_simple, dll);
|
||||
if (!pfnusb_get_string_simple)
|
||||
return;
|
||||
pfnusb_init();
|
||||
m_bAvailable = true;
|
||||
usbscan(&dll);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
ArrayOfUSBDevices USB::GetDevices() {
|
||||
return m_aDevices;
|
||||
}
|
||||
|
||||
bool USB::IsAvailable() {
|
||||
myLogTrace(MYTRACETAG, wxT("USB::IsAvailable() = %s"), m_bAvailable ? "true" : "false");
|
||||
return m_bAvailable;
|
||||
}
|
||||
|
||||
87
LibUSB.h
Normal file
87
LibUSB.h
Normal file
@@ -0,0 +1,87 @@
|
||||
// $Id: LibUSB.h 277 2009-06-19 12:28:58Z felfert $
|
||||
//
|
||||
// Copyright (C) 2009 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _LIBUSB_H_
|
||||
#define _LIBUSB_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
||||
#pragma interface "LibUSB.h"
|
||||
#endif
|
||||
|
||||
#include <wx/dynarray.h>
|
||||
#include <wx/string.h>
|
||||
#include <wx/object.h>
|
||||
#include <memory>
|
||||
|
||||
class USB;
|
||||
|
||||
class USBDevice : public wxObject {
|
||||
public:
|
||||
USBDevice(int, int, unsigned char);
|
||||
|
||||
wxString toString();
|
||||
wxString toShortString();
|
||||
int GetVendorID() const { return m_iVendor; }
|
||||
int GetProductID() const { return m_iProduct; }
|
||||
int GetBusNum() const { return m_iBusNum; }
|
||||
int GetDevNum() const { return m_iDevNum; }
|
||||
unsigned char GetDeviceClass() const { return m_iClass; }
|
||||
const wxString& GetVendor() const { return m_sVendor; }
|
||||
const wxString& GetProduct() const { return m_sProduct; }
|
||||
const wxString& GetSerial() const { return m_sSerial; }
|
||||
wxString GetBusID() const {
|
||||
return wxString::Format(wxT("%d-%d"), m_iBusNum, m_iDevNum);
|
||||
}
|
||||
|
||||
private:
|
||||
int m_iVendor;
|
||||
int m_iProduct;
|
||||
int m_iBusNum;
|
||||
int m_iDevNum;
|
||||
unsigned char m_iClass;
|
||||
wxString m_sVendor;
|
||||
wxString m_sProduct;
|
||||
wxString m_sSerial;
|
||||
|
||||
friend class USB;
|
||||
};
|
||||
|
||||
WX_DECLARE_OBJARRAY(USBDevice, ArrayOfUSBDevices);
|
||||
|
||||
class MyDynamicLibrary;
|
||||
struct usb_device;
|
||||
|
||||
class USB {
|
||||
public:
|
||||
USB();
|
||||
bool IsAvailable();
|
||||
ArrayOfUSBDevices GetDevices();
|
||||
|
||||
private:
|
||||
void adddev(MyDynamicLibrary *, struct usb_device *, unsigned char);
|
||||
void usbscan(MyDynamicLibrary *);
|
||||
|
||||
ArrayOfUSBDevices m_aDevices;
|
||||
bool m_bAvailable;
|
||||
};
|
||||
|
||||
#endif
|
||||
// _LIBUSB_H_
|
||||
180
LogDialog.cpp
Normal file
180
LogDialog.cpp
Normal file
@@ -0,0 +1,180 @@
|
||||
// $Id: LogDialog.cpp 688 2012-02-18 02:36:07Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma implementation "LogDialog.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
////@begin includes
|
||||
////@end includes
|
||||
#include <wx/textfile.h>
|
||||
#include <wx/config.h>
|
||||
|
||||
#include "LogDialog.h"
|
||||
#include "Icon.h"
|
||||
|
||||
////@begin XPM images
|
||||
////@end XPM images
|
||||
|
||||
#include "trace.h"
|
||||
ENABLE_TRACE;
|
||||
|
||||
/*!
|
||||
* LogDialog type definition
|
||||
*/
|
||||
|
||||
IMPLEMENT_CLASS( LogDialog, wxDialog )
|
||||
|
||||
/*!
|
||||
* LogDialog event table definition
|
||||
*/
|
||||
|
||||
BEGIN_EVENT_TABLE( LogDialog, wxDialog )
|
||||
|
||||
////@begin LogDialog event table entries
|
||||
////@end LogDialog event table entries
|
||||
|
||||
END_EVENT_TABLE()
|
||||
|
||||
/*!
|
||||
* LogDialog constructors
|
||||
*/
|
||||
|
||||
LogDialog::LogDialog( )
|
||||
{
|
||||
}
|
||||
|
||||
LogDialog::LogDialog( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
||||
{
|
||||
Create(parent, id, caption, pos, size, style);
|
||||
}
|
||||
|
||||
/*!
|
||||
* LogDialog creator
|
||||
*/
|
||||
|
||||
bool LogDialog::Create( wxWindow* parent, wxWindowID WXUNUSED(id), const wxString& WXUNUSED(caption), const wxPoint& WXUNUSED(pos), const wxSize& WXUNUSED(size), long WXUNUSED(style) )
|
||||
{
|
||||
////@begin LogDialog member initialisation
|
||||
m_TextCtrl = NULL;
|
||||
////@end LogDialog member initialisation
|
||||
|
||||
////@begin LogDialog creation
|
||||
SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
|
||||
SetParent(parent);
|
||||
CreateControls();
|
||||
SetIcon(GetIconResource(wxT("res/nx.png")));
|
||||
if (GetSizer())
|
||||
{
|
||||
GetSizer()->SetSizeHints(this);
|
||||
}
|
||||
Centre();
|
||||
////@end LogDialog creation
|
||||
if (!m_sFileName.IsEmpty())
|
||||
ReadLogFile(m_sFileName);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Control creation for LogDialog
|
||||
*/
|
||||
|
||||
void LogDialog::CreateControls()
|
||||
{
|
||||
////@begin LogDialog content construction
|
||||
if (!wxXmlResource::Get()->LoadDialog(this, GetParent(), _T("ID_DIALOG_LOG")))
|
||||
wxLogError(wxT("Missing wxXmlResource::Get()->Load() in OnInit()?"));
|
||||
m_TextCtrl = XRCCTRL(*this, "ID_TEXTCTRL", wxTextCtrl);
|
||||
////@end LogDialog content construction
|
||||
|
||||
// Create custom windows not generated automatically here.
|
||||
|
||||
////@begin LogDialog content initialisation
|
||||
////@end LogDialog content initialisation
|
||||
|
||||
wxFont ff(10, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
|
||||
myLogTrace(MYTRACETAG, wxT("Font=%s"), VMB(ff.GetNativeFontInfoDesc()));
|
||||
m_TextCtrl->SetFont(ff);
|
||||
}
|
||||
|
||||
void LogDialog::SetFileName(wxString fn)
|
||||
{
|
||||
m_sFileName = fn;
|
||||
}
|
||||
|
||||
void LogDialog::ReadLogFile(wxString name)
|
||||
{
|
||||
if (!name.IsEmpty())
|
||||
m_sFileName = name;
|
||||
|
||||
if (!m_sFileName.IsEmpty()) {
|
||||
m_TextCtrl->LoadFile(m_sFileName);
|
||||
long n = m_TextCtrl->GetLastPosition();
|
||||
if (m_TextCtrl->GetRange(n - 1, n) == wxT("\004"))
|
||||
m_TextCtrl->Remove(n - 1, n);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* Should we show tooltips?
|
||||
*/
|
||||
|
||||
bool LogDialog::ShowToolTips()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get bitmap resources
|
||||
*/
|
||||
|
||||
wxBitmap LogDialog::GetBitmapResource( const wxString& name )
|
||||
{
|
||||
// Bitmap retrieval
|
||||
return CreateBitmapFromFile(name);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get icon resources
|
||||
*/
|
||||
|
||||
wxIcon LogDialog::GetIconResource( const wxString& name )
|
||||
{
|
||||
// Icon retrieval
|
||||
return CreateIconFromFile(name);
|
||||
}
|
||||
|
||||
|
||||
115
LogDialog.h
Normal file
115
LogDialog.h
Normal file
@@ -0,0 +1,115 @@
|
||||
// $Id: LogDialog.h 84 2006-12-13 06:14:36Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _LOGDIALOG_H_
|
||||
#define _LOGDIALOG_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "LogDialog.cpp"
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* Includes
|
||||
*/
|
||||
|
||||
////@begin includes
|
||||
#include "LogDialog_symbols.h"
|
||||
#include "wx/xrc/xmlres.h"
|
||||
////@end includes
|
||||
|
||||
/*!
|
||||
* Forward declarations
|
||||
*/
|
||||
|
||||
////@begin forward declarations
|
||||
////@end forward declarations
|
||||
|
||||
/*!
|
||||
* Control identifiers
|
||||
*/
|
||||
|
||||
////@begin control identifiers
|
||||
#define ID_DIALOG_LOG 10104
|
||||
#define SYMBOL_LOGDIALOG_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxMAXIMIZE_BOX|wxMINIMIZE_BOX
|
||||
#define SYMBOL_LOGDIALOG_TITLE _("Session Log - OpenNX")
|
||||
#define SYMBOL_LOGDIALOG_IDNAME ID_DIALOG_LOG
|
||||
#define SYMBOL_LOGDIALOG_SIZE wxSize(200, 150)
|
||||
#define SYMBOL_LOGDIALOG_POSITION wxDefaultPosition
|
||||
////@end control identifiers
|
||||
|
||||
/*!
|
||||
* Compatibility
|
||||
*/
|
||||
|
||||
#ifndef wxCLOSE_BOX
|
||||
#define wxCLOSE_BOX 0x1000
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* LogDialog class declaration
|
||||
*/
|
||||
|
||||
class LogDialog: public wxDialog
|
||||
{
|
||||
DECLARE_CLASS( LogDialog )
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
public:
|
||||
/// Constructors
|
||||
LogDialog( );
|
||||
LogDialog( wxWindow* parent, wxWindowID id = SYMBOL_LOGDIALOG_IDNAME, const wxString& caption = SYMBOL_LOGDIALOG_TITLE, const wxPoint& pos = SYMBOL_LOGDIALOG_POSITION, const wxSize& size = SYMBOL_LOGDIALOG_SIZE, long style = SYMBOL_LOGDIALOG_STYLE );
|
||||
|
||||
/// Creation
|
||||
bool Create( wxWindow* parent, wxWindowID id = SYMBOL_LOGDIALOG_IDNAME, const wxString& caption = SYMBOL_LOGDIALOG_TITLE, const wxPoint& pos = SYMBOL_LOGDIALOG_POSITION, const wxSize& size = SYMBOL_LOGDIALOG_SIZE, long style = SYMBOL_LOGDIALOG_STYLE );
|
||||
|
||||
/// Creates the controls and sizers
|
||||
void CreateControls();
|
||||
|
||||
void SetFileName(wxString);
|
||||
void ReadLogFile(wxString);
|
||||
|
||||
////@begin LogDialog event handler declarations
|
||||
|
||||
////@end LogDialog event handler declarations
|
||||
|
||||
private:
|
||||
|
||||
////@begin LogDialog member function declarations
|
||||
|
||||
/// Retrieves bitmap resources
|
||||
wxBitmap GetBitmapResource( const wxString& name );
|
||||
|
||||
/// Retrieves icon resources
|
||||
wxIcon GetIconResource( const wxString& name );
|
||||
////@end LogDialog member function declarations
|
||||
|
||||
/// Should we show tooltips?
|
||||
static bool ShowToolTips();
|
||||
|
||||
////@begin LogDialog member variables
|
||||
wxTextCtrl* m_TextCtrl;
|
||||
////@end LogDialog member variables
|
||||
|
||||
wxString m_sFileName;
|
||||
};
|
||||
|
||||
#endif
|
||||
// _LOGDIALOG_H_
|
||||
23
LogDialog_symbols.h
Normal file
23
LogDialog_symbols.h
Normal file
@@ -0,0 +1,23 @@
|
||||
// $Id: LogDialog_symbols.h 689 2012-02-19 00:30:54Z felfert $
|
||||
//
|
||||
// Copyright (C) 2011 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#define ID_DIALOG_LOG_SYMBOL_0 _("Session Log - OpenNX")
|
||||
#define ID_DIALOG_LOG_SYMBOL_1 _("Close")
|
||||
619
LoginDialog.cpp
Normal file
619
LoginDialog.cpp
Normal file
@@ -0,0 +1,619 @@
|
||||
// $Id: LoginDialog.cpp 692 2012-02-20 10:35:37Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma implementation "LoginDialog.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#include <wx/config.h>
|
||||
#include <wx/dir.h>
|
||||
#include <wx/file.h>
|
||||
#include <wx/xml/xml.h>
|
||||
#include <wx/cshelp.h>
|
||||
|
||||
////@begin includes
|
||||
////@end includes
|
||||
|
||||
#include "LoginDialog.h"
|
||||
#include "MyXmlConfig.h"
|
||||
#include "SessionProperties.h"
|
||||
#include "MySession.h"
|
||||
#include "Icon.h"
|
||||
#include "opennxApp.h"
|
||||
#include "SupressibleMessageDialog.h"
|
||||
|
||||
////@begin XPM images
|
||||
////@end XPM images
|
||||
|
||||
#include "trace.h"
|
||||
ENABLE_TRACE;
|
||||
|
||||
#ifdef SINGLE_SESSION
|
||||
# define NXSSH_TIMER 5432
|
||||
#endif
|
||||
#define AUTOLOGIN_TIMER 5433
|
||||
|
||||
/*!
|
||||
* LoginDialog type definition
|
||||
*/
|
||||
|
||||
IMPLEMENT_CLASS( LoginDialog, wxDialog )
|
||||
|
||||
/*!
|
||||
* LoginDialog event table definition
|
||||
*/
|
||||
|
||||
BEGIN_EVENT_TABLE( LoginDialog, wxDialog )
|
||||
|
||||
////@begin LoginDialog event table entries
|
||||
EVT_INIT_DIALOG( LoginDialog::OnInitDialog )
|
||||
|
||||
EVT_TEXT( XRCID("ID_TEXTCTRL_USERNAME"), LoginDialog::OnTextctrlUsernameUpdated )
|
||||
|
||||
EVT_COMBOBOX( XRCID("ID_COMBOBOX_SESSION"), LoginDialog::OnComboboxSessionSelected )
|
||||
|
||||
EVT_CHECKBOX( XRCID("ID_CHECKBOX_SMARTCARD"), LoginDialog::OnCheckboxSmartcardClick )
|
||||
|
||||
EVT_CHECKBOX( XRCID("ID_CHECKBOX_GUESTLOGIN"), LoginDialog::OnCheckboxGuestloginClick )
|
||||
|
||||
EVT_BUTTON( XRCID("ID_BUTTON_CONFIGURE"), LoginDialog::OnButtonConfigureClick )
|
||||
|
||||
EVT_BUTTON( wxID_OK, LoginDialog::OnOkClick )
|
||||
|
||||
////@end LoginDialog event table entries
|
||||
|
||||
EVT_MENU(wxID_CONTEXT_HELP, LoginDialog::OnContextHelp)
|
||||
#ifdef __WXMAC__
|
||||
EVT_MENU(wxID_EXIT, LoginDialog::OnMenuExit)
|
||||
#endif
|
||||
|
||||
#ifdef SINGLE_SESSION
|
||||
EVT_TIMER(NXSSH_TIMER, LoginDialog::OnTimer)
|
||||
#endif
|
||||
EVT_TIMER(AUTOLOGIN_TIMER, LoginDialog::OnLoginTimer)
|
||||
|
||||
END_EVENT_TABLE()
|
||||
|
||||
/*!
|
||||
* LoginDialog constructors
|
||||
*/
|
||||
|
||||
LoginDialog::LoginDialog( )
|
||||
: m_pCurrentCfg(NULL)
|
||||
#ifdef SINGLE_SESSION
|
||||
, m_cNxSshWatchTimer(this, NXSSH_TIMER)
|
||||
#endif
|
||||
, m_cAutoLoginTimer(this, AUTOLOGIN_TIMER)
|
||||
{
|
||||
m_bGuestLogin = false;
|
||||
m_bUseSmartCard = false;
|
||||
}
|
||||
|
||||
LoginDialog::LoginDialog( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
||||
: m_pCurrentCfg(NULL)
|
||||
#ifdef SINGLE_SESSION
|
||||
, m_cNxSshWatchTimer(this, NXSSH_TIMER)
|
||||
#endif
|
||||
, m_cAutoLoginTimer(this, AUTOLOGIN_TIMER)
|
||||
{
|
||||
m_bGuestLogin = false;
|
||||
m_bUseSmartCard = false;
|
||||
Create(parent, id, caption, pos, size, style);
|
||||
}
|
||||
|
||||
LoginDialog::~LoginDialog()
|
||||
{
|
||||
if (m_pCurrentCfg)
|
||||
delete m_pCurrentCfg;
|
||||
m_pCurrentCfg = NULL;
|
||||
}
|
||||
|
||||
void LoginDialog::SetInitialFocus()
|
||||
{
|
||||
if (m_pCtrlUsername->GetValue().IsEmpty()) {
|
||||
m_pCtrlUsername->SetFocus();
|
||||
myLogTrace(MYTRACETAG, wxT("set initial focus on user name"));
|
||||
} else {
|
||||
wxString p = m_pCtrlPassword->GetValue();
|
||||
if (p.IsEmpty() || p.IsSameAs(wxT("\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010"))) {
|
||||
m_pCtrlPassword->SetFocus();
|
||||
myLogTrace(MYTRACETAG, wxT("set initial focus on password"));
|
||||
} else {
|
||||
m_pCtrlLoginButton->SetFocus();
|
||||
myLogTrace(MYTRACETAG, wxT("set initial focus on login button"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LoginDialog::ReadConfigDirectory()
|
||||
{
|
||||
wxString cfgdir;
|
||||
wxConfigBase::Get()->Read(wxT("Config/UserNxDir"), &cfgdir);
|
||||
cfgdir = cfgdir + wxFileName::GetPathSeparator() + wxT("config");
|
||||
m_aConfigFiles.Empty();
|
||||
|
||||
wxDir::GetAllFiles(cfgdir, &m_aConfigFiles, wxT("*.nxs"), wxDIR_FILES);
|
||||
size_t i;
|
||||
m_sSessionName.Empty();
|
||||
if (m_pCurrentCfg)
|
||||
delete m_pCurrentCfg;
|
||||
m_pCurrentCfg = NULL;
|
||||
m_pCtrlSessionName->Clear();
|
||||
myLogTrace(MYTRACETAG, wxT("ReadConfigDirectory: LastSession='%s'"), VMB(m_sLastSessionFilename));
|
||||
if (m_sLastSessionFilename.StartsWith(wxT("http://")) ||
|
||||
m_sLastSessionFilename.StartsWith(wxT("https://")) ||
|
||||
m_sLastSessionFilename.StartsWith(wxT("ftp://")) ||
|
||||
((m_aConfigFiles.Index(m_sLastSessionFilename) == wxNOT_FOUND) &&
|
||||
(wxFile::Exists(m_sLastSessionFilename)))) {
|
||||
m_aConfigFiles.Add(m_sLastSessionFilename);
|
||||
myLogTrace(MYTRACETAG, wxT("ReadConfigDirectory: Adding '%s'"), VMB(m_sLastSessionFilename));
|
||||
}
|
||||
for (i = 0; i < m_aConfigFiles.GetCount(); i++) {
|
||||
MyXmlConfig cfg(m_aConfigFiles[i]);
|
||||
if (cfg.IsValid()) {
|
||||
m_pCtrlSessionName->Append(cfg.sGetName(), (void*) m_aConfigFiles[i].wx_str());
|
||||
if ((cfg.sGetFileName() == m_sLastSessionFilename) ||
|
||||
(cfg.sGetName() == m_sLastSessionFilename)) {
|
||||
m_pCurrentCfg = new MyXmlConfig(m_aConfigFiles[i]);
|
||||
m_sSessionName = cfg.sGetName();
|
||||
m_bGuestLogin = cfg.bGetGuestMode();
|
||||
if (m_bGuestLogin) {
|
||||
m_sTmpUsername = cfg.sGetUsername();
|
||||
m_sTmpPassword = cfg.sGetPassword();
|
||||
m_sUsername = wxEmptyString;
|
||||
m_sPassword = wxEmptyString;
|
||||
} else {
|
||||
m_sUsername = cfg.sGetUsername();
|
||||
m_sPassword = cfg.sGetPassword();
|
||||
}
|
||||
m_bUseSmartCard = ::wxGetApp().NxSmartCardSupport() && cfg.bGetUseSmartCard();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (m_pCurrentCfg) {
|
||||
myLogTrace(MYTRACETAG, wxT("SS1='%s'"), VMB(m_sSessionName));
|
||||
m_pCtrlSessionName->SetStringSelection(m_sSessionName);
|
||||
wxCommandEvent event;
|
||||
OnComboboxSessionSelected(event);
|
||||
} else {
|
||||
myLogTrace(MYTRACETAG, wxT("SS2='%s'"), VMB(m_sLastSessionFilename));
|
||||
// Last session name might be a plain session name (backward compatibility)
|
||||
m_pCtrlSessionName->SetStringSelection(m_sLastSessionFilename);
|
||||
wxCommandEvent event;
|
||||
OnComboboxSessionSelected(event);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __WXMAC__
|
||||
void LoginDialog::SelectSession(wxString name)
|
||||
{
|
||||
MyXmlConfig cfg(name);
|
||||
if (cfg.IsValid()) {
|
||||
m_pCtrlSessionName->Append(cfg.sGetName(), VMB(name);
|
||||
m_pCtrlSessionName->SetStringSelection(cfg.sGetName());
|
||||
wxCommandEvent event;
|
||||
OnComboboxSessionSelected(event);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* LoginDialog creator
|
||||
*/
|
||||
|
||||
bool LoginDialog::Create( wxWindow* parent, wxWindowID WXUNUSED(id), const wxString& WXUNUSED(caption), const wxPoint& WXUNUSED(pos), const wxSize& WXUNUSED(size), long WXUNUSED(style) )
|
||||
{
|
||||
////@begin LoginDialog member initialisation
|
||||
m_sTmpUsername = wxT("");
|
||||
m_sTmpPassword = wxT("");
|
||||
m_pCtrlUsername = NULL;
|
||||
m_pCtrlPassword = NULL;
|
||||
m_pCtrlSessionName = NULL;
|
||||
m_pCtrlUseSmartCard = NULL;
|
||||
m_pCtrlGuestLogin = NULL;
|
||||
m_pCtrlConfigure = NULL;
|
||||
m_pCtrlLoginButton = NULL;
|
||||
////@end LoginDialog member initialisation
|
||||
|
||||
////@begin LoginDialog creation
|
||||
SetExtraStyle(wxWS_EX_BLOCK_EVENTS|wxDIALOG_EX_CONTEXTHELP);
|
||||
SetParent(parent);
|
||||
CreateControls();
|
||||
SetIcon(GetIconResource(wxT("res/nx.png")));
|
||||
if (GetSizer())
|
||||
{
|
||||
GetSizer()->SetSizeHints(this);
|
||||
}
|
||||
Centre();
|
||||
////@end LoginDialog creation
|
||||
::wxGetApp().EnableContextHelp(this);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void LoginDialog::Run()
|
||||
{
|
||||
wxCommandEvent event;
|
||||
OnOkClick(event);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Control creation for LoginDialog
|
||||
*/
|
||||
|
||||
void LoginDialog::CreateControls()
|
||||
{
|
||||
|
||||
////@begin LoginDialog content construction
|
||||
if (!wxXmlResource::Get()->LoadDialog(this, GetParent(), _T("ID_DIALOG_LOGIN")))
|
||||
wxLogError(wxT("Missing wxXmlResource::Get()->Load() in OnInit()?"));
|
||||
m_pCtrlUsername = XRCCTRL(*this, "ID_TEXTCTRL_USERNAME", wxTextCtrl);
|
||||
m_pCtrlPassword = XRCCTRL(*this, "ID_TEXTCTRL_PASSWORD", wxTextCtrl);
|
||||
m_pCtrlSessionName = XRCCTRL(*this, "ID_COMBOBOX_SESSION", wxComboBox);
|
||||
m_pCtrlUseSmartCard = XRCCTRL(*this, "ID_CHECKBOX_SMARTCARD", wxCheckBox);
|
||||
m_pCtrlGuestLogin = XRCCTRL(*this, "ID_CHECKBOX_GUESTLOGIN", wxCheckBox);
|
||||
m_pCtrlConfigure = XRCCTRL(*this, "ID_BUTTON_CONFIGURE", wxButton);
|
||||
m_pCtrlLoginButton = XRCCTRL(*this, "wxID_OK", wxButton);
|
||||
// Set validators
|
||||
if (FindWindow(XRCID("ID_TEXTCTRL_USERNAME")))
|
||||
FindWindow(XRCID("ID_TEXTCTRL_USERNAME"))->SetValidator( wxGenericValidator(& m_sUsername) );
|
||||
if (FindWindow(XRCID("ID_TEXTCTRL_PASSWORD")))
|
||||
FindWindow(XRCID("ID_TEXTCTRL_PASSWORD"))->SetValidator( wxGenericValidator(& m_sPassword) );
|
||||
if (FindWindow(XRCID("ID_COMBOBOX_SESSION")))
|
||||
FindWindow(XRCID("ID_COMBOBOX_SESSION"))->SetValidator( wxGenericValidator(& m_sSessionName) );
|
||||
if (FindWindow(XRCID("ID_CHECKBOX_SMARTCARD")))
|
||||
FindWindow(XRCID("ID_CHECKBOX_SMARTCARD"))->SetValidator( wxGenericValidator(& m_bUseSmartCard) );
|
||||
if (FindWindow(XRCID("ID_CHECKBOX_GUESTLOGIN")))
|
||||
FindWindow(XRCID("ID_CHECKBOX_GUESTLOGIN"))->SetValidator( wxGenericValidator(& m_bGuestLogin) );
|
||||
////@end LoginDialog content construction
|
||||
|
||||
// Create custom windows not generated automatically here.
|
||||
|
||||
////@begin LoginDialog content initialisation
|
||||
////@end LoginDialog content initialisation
|
||||
|
||||
ReadConfigDirectory();
|
||||
m_bUseSmartCard = ::wxGetApp().NxSmartCardSupport() && m_pCurrentCfg && m_pCurrentCfg->bGetUseSmartCard();
|
||||
m_pCtrlUseSmartCard->SetValue(m_bUseSmartCard);
|
||||
m_pCtrlUseSmartCard->Enable(::wxGetApp().NxSmartCardSupport() && m_pCurrentCfg && m_pCurrentCfg->IsWritable());
|
||||
if (m_bGuestLogin) {
|
||||
m_pCtrlUsername->Enable(false);
|
||||
m_pCtrlPassword->Enable(false);
|
||||
}
|
||||
m_pCtrlGuestLogin->Enable(m_pCurrentCfg && m_pCurrentCfg->IsWritable());
|
||||
m_pCtrlConfigure->Enable(m_pCurrentCfg && m_pCurrentCfg->IsWritable());
|
||||
#ifdef SINGLE_SESSION
|
||||
m_pCtrlLoginButton->Enable(false);
|
||||
m_cNxSshWatchTimer.Start(1000);
|
||||
myLogTrace(MYTRACETAG, wxT("Starting nxssh watch timer"));
|
||||
#endif
|
||||
}
|
||||
|
||||
void LoginDialog::OnContextHelp(wxCommandEvent &)
|
||||
{
|
||||
wxContextHelp contextHelp(this);
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX_SMARTCARD
|
||||
*/
|
||||
|
||||
void LoginDialog::OnCheckboxSmartcardClick( wxCommandEvent& event )
|
||||
{
|
||||
// Nothing to do here (validator sets var already)
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX_GUESTLOGIN
|
||||
*/
|
||||
|
||||
void LoginDialog::OnCheckboxGuestloginClick( wxCommandEvent& event )
|
||||
{
|
||||
if (m_pCtrlGuestLogin->IsChecked()) {
|
||||
m_sTmpUsername = m_pCtrlUsername->GetValue();
|
||||
m_sTmpPassword = m_pCtrlPassword->GetValue();
|
||||
m_pCtrlUsername->SetValue(wxEmptyString);
|
||||
m_pCtrlPassword->SetValue(wxEmptyString);
|
||||
m_pCtrlUsername->Enable(false);
|
||||
m_pCtrlPassword->Enable(false);
|
||||
} else {
|
||||
m_pCtrlUsername->SetValue(m_sTmpUsername);
|
||||
m_pCtrlPassword->SetValue(m_sTmpPassword);
|
||||
m_pCtrlUsername->Enable(true);
|
||||
m_pCtrlPassword->Enable(true);
|
||||
}
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
/*!
|
||||
* Should we show tooltips?
|
||||
*/
|
||||
|
||||
bool LoginDialog::ShowToolTips()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get bitmap resources
|
||||
*/
|
||||
|
||||
wxBitmap LoginDialog::GetBitmapResource( const wxString& name )
|
||||
{
|
||||
// Bitmap retrieval
|
||||
return CreateBitmapFromFile(name);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get icon resources
|
||||
*/
|
||||
|
||||
wxIcon LoginDialog::GetIconResource( const wxString& name )
|
||||
{
|
||||
// Icon retrieval
|
||||
return CreateIconFromFile(name);
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_CONFIGURE
|
||||
*/
|
||||
|
||||
void LoginDialog::OnButtonConfigureClick( wxCommandEvent& event )
|
||||
{
|
||||
if (m_pCurrentCfg) {
|
||||
SessionProperties d;
|
||||
d.SetConfig(m_pCurrentCfg);
|
||||
wxString fn = m_pCurrentCfg->sGetFileName();
|
||||
d.Create(this);
|
||||
switch (d.ShowModal()) {
|
||||
case wxID_CANCEL:
|
||||
delete m_pCurrentCfg;
|
||||
m_pCurrentCfg = new MyXmlConfig(fn);
|
||||
break;
|
||||
case wxID_CLEAR:
|
||||
myLogTrace(MYTRACETAG, wxT("deleting '%s'"), VMB(fn));
|
||||
::wxRemoveFile(fn);
|
||||
ReadConfigDirectory();
|
||||
break;
|
||||
case wxID_OK:
|
||||
m_bUseSmartCard = ::wxGetApp().NxSmartCardSupport() &&
|
||||
m_pCurrentCfg->bGetUseSmartCard();
|
||||
m_pCtrlUseSmartCard->SetValue(m_bUseSmartCard);
|
||||
if (!m_pCurrentCfg->SaveToFile())
|
||||
wxMessageBox(wxString::Format(_("Could not save session to\n%s"),
|
||||
VMB(m_pCurrentCfg->sGetFileName())), _("Error saving - OpenNX"),
|
||||
wxICON_ERROR | wxOK);
|
||||
wxConfigBase::Get()->Write(wxT("Config/UserNxDir"), d.GetsUserNxDir());
|
||||
wxConfigBase::Get()->Write(wxT("Config/SystemNxDir"), d.GetsSystemNxDir());
|
||||
#ifdef SUPPORT_USBIP
|
||||
wxConfigBase::Get()->Write(wxT("Config/UsbipdSocket"), d.GetUsbipdSocket());
|
||||
wxConfigBase::Get()->Write(wxT("Config/UsbipPort"), d.GetUsbLocalPort());
|
||||
#endif
|
||||
bool bDTI = ::wxGetApp().CheckDesktopEntry(m_pCurrentCfg);
|
||||
if (d.GetbCreateDesktopIcon() != bDTI) {
|
||||
if (d.GetbCreateDesktopIcon())
|
||||
::wxGetApp().CreateDesktopEntry(m_pCurrentCfg);
|
||||
else
|
||||
::wxGetApp().RemoveDesktopEntry(m_pCurrentCfg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_COMBOBOX_SESSION
|
||||
*/
|
||||
|
||||
void LoginDialog::OnComboboxSessionSelected( wxCommandEvent& event )
|
||||
{
|
||||
if (m_pCurrentCfg)
|
||||
delete m_pCurrentCfg;
|
||||
m_pCurrentCfg = NULL;
|
||||
int i = m_pCtrlSessionName->GetSelection();
|
||||
if (i != wxNOT_FOUND) {
|
||||
wxString fn = (wxChar *)m_pCtrlSessionName->GetClientData(i);
|
||||
MyXmlConfig cfg(fn);
|
||||
if (cfg.IsValid()) {
|
||||
m_pCurrentCfg = new MyXmlConfig(cfg.sGetFileName());
|
||||
m_bGuestLogin = cfg.bGetGuestMode();
|
||||
m_pCtrlGuestLogin->SetValue(m_bGuestLogin);
|
||||
if (m_bGuestLogin) {
|
||||
m_sTmpUsername = cfg.sGetUsername();
|
||||
m_pCtrlUsername->SetValue(wxEmptyString);
|
||||
m_sTmpPassword = cfg.sGetPassword();
|
||||
m_pCtrlPassword->SetValue(wxEmptyString);
|
||||
m_pCtrlPassword->Enable(false);
|
||||
m_pCtrlUsername->Enable(false);
|
||||
} else {
|
||||
m_pCtrlPassword->SetValue(cfg.sGetPassword());
|
||||
m_pCtrlUsername->SetValue(cfg.sGetUsername());
|
||||
m_pCtrlPassword->Enable(true);
|
||||
m_pCtrlUsername->Enable(true);
|
||||
}
|
||||
m_pCtrlUseSmartCard->SetValue(::wxGetApp().NxSmartCardSupport() && cfg.bGetUseSmartCard());
|
||||
m_sSessionName = cfg.sGetName();
|
||||
}
|
||||
SetTitle(wxT("OpenNX - ") + m_sUsername + (m_sSessionName.IsEmpty() ? wxT("")
|
||||
: wxT("@") + m_sSessionName));
|
||||
}
|
||||
m_pCtrlUseSmartCard->Enable(m_pCurrentCfg && m_pCurrentCfg->IsWritable());
|
||||
m_pCtrlGuestLogin->Enable(m_pCurrentCfg && m_pCurrentCfg->IsWritable());
|
||||
m_pCtrlConfigure->Enable(m_pCurrentCfg && m_pCurrentCfg->IsWritable());
|
||||
if (m_pCurrentCfg && m_pCurrentCfg->WasOldConfig()) {
|
||||
wxString msg;
|
||||
if (m_pCurrentCfg->IsWritable()) {
|
||||
// m_pCurrentCfg->SaveToFile();
|
||||
msg = _("An old session configuration has been detected.\nThe session '%s' has been converted to the new format.\nPlease verify the custom image compression settings.");
|
||||
} else {
|
||||
msg = _("An old session configuration has been detected.\nThe session '%s' has been converted but could not be saved.\nPlease verify the custom image compression settings.");
|
||||
}
|
||||
wxString cfgid(wxT("oldcfg."));
|
||||
SupressibleMessageDialog d(this, wxString::Format(msg, VMB(m_pCurrentCfg->sGetName())),
|
||||
_("Warning - OpenNX"), wxOK|wxICON_EXCLAMATION);
|
||||
d.ShowConditional(cfgid.Append(msg.Left(15)), wxID_OK);
|
||||
}
|
||||
if (!m_bGuestLogin)
|
||||
SetInitialFocus();
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_TEXT_UPDATED event handler for ID_TEXTCTRL_USERNAME
|
||||
*/
|
||||
|
||||
void LoginDialog::OnTextctrlUsernameUpdated( wxCommandEvent& event )
|
||||
{
|
||||
wxString un = m_pCtrlUsername->GetValue();
|
||||
SetTitle(wxT("OpenNX - ") + un + (m_sSessionName.IsEmpty() ? wxT("")
|
||||
: wxT("@") + m_sSessionName));
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
|
||||
*/
|
||||
|
||||
void LoginDialog::OnOkClick(wxCommandEvent& event)
|
||||
{
|
||||
if (m_pCurrentCfg) {
|
||||
TransferDataFromWindow();
|
||||
m_pCurrentCfg->bSetGuestMode(m_bGuestLogin);
|
||||
if (!m_bGuestLogin) {
|
||||
m_pCurrentCfg->sSetUsername(m_sUsername);
|
||||
if (m_pCurrentCfg->bGetRememberPassword())
|
||||
m_pCurrentCfg->sSetPassword(m_sPassword);
|
||||
}
|
||||
m_pCurrentCfg->bSetUseSmartCard(m_bUseSmartCard);
|
||||
if (m_bUseSmartCard)
|
||||
m_pCurrentCfg->bSetEnableSSL(true);
|
||||
|
||||
// Workaround for a bug-compatibility to original nxclient:
|
||||
// At least in guest mode, original stores RDP password,
|
||||
// even if remember is false.
|
||||
if (m_bGuestLogin)
|
||||
m_pCurrentCfg->bSetRdpRememberPassword(true);
|
||||
|
||||
MySession s;
|
||||
#ifdef SINGLE_SESSION
|
||||
m_cNxSshWatchTimer.Stop();
|
||||
myLogTrace(MYTRACETAG, wxT("Stopping nxssh watch timer"));
|
||||
#endif
|
||||
Disable();
|
||||
bool b = s.Create(*m_pCurrentCfg, m_sPassword, this);
|
||||
Enable();
|
||||
if (!b) {
|
||||
// Clear password after failure or abort.
|
||||
if (!m_bGuestLogin) {
|
||||
bool clpw = true;
|
||||
wxConfigBase::Get()->Read(wxT("Config/ClearPassOnAbort"), &clpw, true);
|
||||
if (clpw) {
|
||||
m_pCtrlPassword->SetValue(wxEmptyString);
|
||||
m_pCtrlPassword->SetFocus();
|
||||
}
|
||||
}
|
||||
#ifdef SINGLE_SESSION
|
||||
m_cNxSshWatchTimer.Start(1000);
|
||||
myLogTrace(MYTRACETAG, wxT("Starting nxssh watch timer"));
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
if (m_pCurrentCfg->IsWritable()) {
|
||||
if (!m_pCurrentCfg->SaveToFile())
|
||||
wxMessageBox(wxString::Format(_("Could not save session to\n%s"),
|
||||
VMB(m_pCurrentCfg->sGetFileName())), _("Error saving - OpenNX"),
|
||||
wxICON_ERROR | wxOK);
|
||||
|
||||
}
|
||||
m_sLastSessionFilename = m_pCurrentCfg->sGetFileName();
|
||||
}
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
#ifdef __WXMAC__
|
||||
/*!
|
||||
* Handle quit event on Mac OSX
|
||||
*/
|
||||
void LoginDialog::OnMenuExit(wxCommandEvent& event)
|
||||
{
|
||||
EndModal(wxID_CANCEL);
|
||||
event.Skip();
|
||||
}
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* Handle events from AutoLoginTimer
|
||||
*/
|
||||
void LoginDialog::OnLoginTimer(wxTimerEvent&)
|
||||
{
|
||||
wxCommandEvent ev(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
|
||||
AddPendingEvent(ev);
|
||||
}
|
||||
|
||||
#ifdef SINGLE_SESSION
|
||||
/*!
|
||||
* Handle events from NxSshWatchTimer
|
||||
*/
|
||||
void LoginDialog::OnTimer(wxTimerEvent&)
|
||||
{
|
||||
wxArrayString cmdout;
|
||||
wxExecute(wxT("ps h -C nxssh"), cmdout, wxEXEC_SYNC|wxEXEC_NODISABLE);
|
||||
bool enable = (cmdout.GetCount() == 0);
|
||||
if (NULL != m_pCtrlLoginButton)
|
||||
m_pCtrlLoginButton->Enable(enable);
|
||||
if (enable && ::wxGetApp().AutoLogin()) {
|
||||
wxCommandEvent ev(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
|
||||
AddPendingEvent(ev);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*!
|
||||
* wxEVT_INIT_DIALOG event handler for ID_DIALOG_LOGIN
|
||||
*/
|
||||
|
||||
void LoginDialog::OnInitDialog( wxInitDialogEvent& event )
|
||||
{
|
||||
wxDialog::OnInitDialog(event);
|
||||
#ifndef SINGLE_SESSION
|
||||
if (::wxGetApp().AutoLogin())
|
||||
m_cAutoLoginTimer.Start(1000, wxTIMER_ONE_SHOT);
|
||||
#endif
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
187
LoginDialog.h
Normal file
187
LoginDialog.h
Normal file
@@ -0,0 +1,187 @@
|
||||
// $Id: LoginDialog.h 631 2011-06-12 19:20:21Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _LOGINDIALOG_H_
|
||||
#define _LOGINDIALOG_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "LoginDialog.cpp"
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* Includes
|
||||
*/
|
||||
|
||||
////@begin includes
|
||||
#include "LoginDialog_symbols.h"
|
||||
#include "wx/xrc/xmlres.h"
|
||||
#include "wx/valgen.h"
|
||||
#include "wx/statline.h"
|
||||
////@end includes
|
||||
|
||||
/*!
|
||||
* Forward declarations
|
||||
*/
|
||||
|
||||
class MyXmlConfig;
|
||||
|
||||
////@begin forward declarations
|
||||
////@end forward declarations
|
||||
|
||||
/*!
|
||||
* Control identifiers
|
||||
*/
|
||||
|
||||
////@begin control identifiers
|
||||
#define ID_DIALOG_LOGIN 10000
|
||||
#define SYMBOL_LOGINDIALOG_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX
|
||||
#define SYMBOL_LOGINDIALOG_TITLE _("OpenNX - ")
|
||||
#define SYMBOL_LOGINDIALOG_IDNAME ID_DIALOG_LOGIN
|
||||
#define SYMBOL_LOGINDIALOG_SIZE wxSize(200, 150)
|
||||
#define SYMBOL_LOGINDIALOG_POSITION wxDefaultPosition
|
||||
////@end control identifiers
|
||||
|
||||
/*!
|
||||
* Compatibility
|
||||
*/
|
||||
|
||||
#ifndef wxCLOSE_BOX
|
||||
#define wxCLOSE_BOX 0x1000
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* LoginDialog class declaration
|
||||
*/
|
||||
|
||||
class LoginDialog: public wxDialog
|
||||
{
|
||||
DECLARE_CLASS( LoginDialog )
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
public:
|
||||
/// Constructors
|
||||
LoginDialog( );
|
||||
LoginDialog( wxWindow* parent, wxWindowID id = SYMBOL_LOGINDIALOG_IDNAME, const wxString& caption = SYMBOL_LOGINDIALOG_TITLE, const wxPoint& pos = SYMBOL_LOGINDIALOG_POSITION, const wxSize& size = SYMBOL_LOGINDIALOG_SIZE, long style = SYMBOL_LOGINDIALOG_STYLE );
|
||||
|
||||
/// Creation
|
||||
bool Create( wxWindow* parent, wxWindowID id = SYMBOL_LOGINDIALOG_IDNAME, const wxString& caption = SYMBOL_LOGINDIALOG_TITLE, const wxPoint& pos = SYMBOL_LOGINDIALOG_POSITION, const wxSize& size = SYMBOL_LOGINDIALOG_SIZE, long style = SYMBOL_LOGINDIALOG_STYLE );
|
||||
|
||||
~LoginDialog();
|
||||
|
||||
private:
|
||||
/// Creates the controls and sizers
|
||||
void CreateControls();
|
||||
|
||||
void OnContextHelp(wxCommandEvent &);
|
||||
#ifdef __WXMAC__
|
||||
void OnMenuExit(wxCommandEvent &);
|
||||
#endif
|
||||
#ifdef SINGLE_SESSION
|
||||
// Event handler for events from nxssh watch timer
|
||||
void OnTimer(wxTimerEvent& event);
|
||||
#endif
|
||||
void OnLoginTimer(wxTimerEvent& event);
|
||||
|
||||
////@begin LoginDialog event handler declarations
|
||||
|
||||
/// wxEVT_INIT_DIALOG event handler for ID_DIALOG_LOGIN
|
||||
void OnInitDialog( wxInitDialogEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_TEXTCTRL_USERNAME
|
||||
void OnTextctrlUsernameUpdated( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_COMBOBOX_SESSION
|
||||
void OnComboboxSessionSelected( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX_SMARTCARD
|
||||
void OnCheckboxSmartcardClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX_GUESTLOGIN
|
||||
void OnCheckboxGuestloginClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_CONFIGURE
|
||||
void OnButtonConfigureClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
|
||||
void OnOkClick( wxCommandEvent& event );
|
||||
|
||||
////@end LoginDialog event handler declarations
|
||||
|
||||
public:
|
||||
////@begin LoginDialog member function declarations
|
||||
|
||||
bool GetUseSmartCard() const { return m_bUseSmartCard ; }
|
||||
void SetUseSmartCard(bool value) { m_bUseSmartCard = value ; }
|
||||
|
||||
wxString GetSessionName() const { return m_sSessionName ; }
|
||||
void SetSessionName(wxString value) { m_sSessionName = value ; }
|
||||
|
||||
/// Retrieves bitmap resources
|
||||
wxBitmap GetBitmapResource( const wxString& name );
|
||||
|
||||
/// Retrieves icon resources
|
||||
wxIcon GetIconResource( const wxString& name );
|
||||
////@end LoginDialog member function declarations
|
||||
|
||||
/// Should we show tooltips?
|
||||
static bool ShowToolTips();
|
||||
|
||||
// Return filename of last successfully connected config
|
||||
wxString GetLastSessionFilename() const { return m_sLastSessionFilename; }
|
||||
void SetLastSessionFilename(wxString value) { m_sLastSessionFilename = value; }
|
||||
void Run();
|
||||
#ifdef __WXMAC__
|
||||
void SelectSession(wxString name);
|
||||
#endif
|
||||
|
||||
private:
|
||||
void ReadConfigDirectory();
|
||||
void SetInitialFocus();
|
||||
|
||||
////@begin LoginDialog member variables
|
||||
wxTextCtrl* m_pCtrlUsername;
|
||||
wxTextCtrl* m_pCtrlPassword;
|
||||
wxComboBox* m_pCtrlSessionName;
|
||||
wxCheckBox* m_pCtrlUseSmartCard;
|
||||
wxCheckBox* m_pCtrlGuestLogin;
|
||||
wxButton* m_pCtrlConfigure;
|
||||
wxButton* m_pCtrlLoginButton;
|
||||
private:
|
||||
wxString m_sUsername;
|
||||
wxString m_sPassword;
|
||||
bool m_bUseSmartCard;
|
||||
wxString m_sSessionName;
|
||||
bool m_bGuestLogin;
|
||||
wxString m_sTmpUsername;
|
||||
wxString m_sTmpPassword;
|
||||
////@end LoginDialog member variables
|
||||
|
||||
MyXmlConfig *m_pCurrentCfg;
|
||||
#ifdef SINGLE_SESSION
|
||||
wxTimer m_cNxSshWatchTimer;
|
||||
#endif
|
||||
wxTimer m_cAutoLoginTimer;
|
||||
wxSortedArrayString m_aConfigFiles;
|
||||
wxString m_sLastSessionFilename;
|
||||
};
|
||||
|
||||
#endif
|
||||
// _LOGINDIALOG_H_
|
||||
30
LoginDialog_symbols.h
Normal file
30
LoginDialog_symbols.h
Normal file
@@ -0,0 +1,30 @@
|
||||
// $Id: LoginDialog_symbols.h 476 2010-02-10 00:06:14Z felfert $
|
||||
//
|
||||
// Copyright (C) 2010 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#define ID_DIALOG_LOGIN_SYMBOL_0 _("OpenNX - ")
|
||||
#define ID_DIALOG_LOGIN_SYMBOL_1 _("Login")
|
||||
#define ID_DIALOG_LOGIN_SYMBOL_2 _("Password")
|
||||
#define ID_DIALOG_LOGIN_SYMBOL_3 _("Session")
|
||||
#define ID_DIALOG_LOGIN_SYMBOL_4 _("Use SmartCard")
|
||||
#define ID_DIALOG_LOGIN_SYMBOL_5 _("Login as guest user")
|
||||
#define ID_DIALOG_LOGIN_SYMBOL_6 _("Con&figure...")
|
||||
#define ID_DIALOG_LOGIN_SYMBOL_7 _("L&ogin")
|
||||
#define ID_DIALOG_LOGIN_SYMBOL_8 _("&Cancel")
|
||||
84
MacOSX.c
Normal file
84
MacOSX.c
Normal file
@@ -0,0 +1,84 @@
|
||||
/* $Id: MacOSX.c 680 2012-02-09 23:31:11Z felfert $
|
||||
*
|
||||
* Copyright (C) 2006 The OpenNX Team
|
||||
* Author: Fritz Elfert
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Defines canonicalized platform names (e.g. __LINUX__)
|
||||
*/
|
||||
#include <wx/platform.h>
|
||||
|
||||
#ifdef __WXMAC__
|
||||
/*
|
||||
* Allow app to be started from the commandline
|
||||
*/
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
static void __attribute__ ((constructor))
|
||||
makeForegroundApp()
|
||||
{
|
||||
ProcessSerialNumber PSN;
|
||||
if (noErr == GetCurrentProcess(&PSN)) {
|
||||
# ifdef APP_WATCHREADER
|
||||
TransformProcessType(&PSN, 0);
|
||||
# else
|
||||
TransformProcessType(&PSN, kProcessTransformToForegroundApplication);
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 10.4 compatibility. Hence the use of deprecated keyboard services.
|
||||
*/
|
||||
#include <Carbon/Carbon.h>
|
||||
const char *getMacKeyboard() {
|
||||
static char ret[256];
|
||||
KeyboardLayoutRef klr;
|
||||
memset(ret, 0, sizeof(ret));
|
||||
if (noErr == KLGetCurrentKeyboardLayout(&klr)) {
|
||||
unsigned int pt = kKLLanguageCode;
|
||||
const void *oValue;
|
||||
if (noErr == KLGetKeyboardLayoutProperty(klr, pt, &oValue)) {
|
||||
char buf[128];
|
||||
if (CFStringGetCString((CFStringRef)oValue, buf, sizeof(buf), kCFStringEncodingISOLatin1)) {
|
||||
const char *ktype = "pc105";
|
||||
snprintf(ret, sizeof(ret), "%s/%s", ktype, buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#include <IOKit/IOKitLib.h>
|
||||
#ifndef kIOPlatformUUIDKey
|
||||
# define kIOPlatformUUIDKey "IOPlatformUUID"
|
||||
#endif
|
||||
const char *getMacMachineID()
|
||||
{
|
||||
static char ret[256];
|
||||
io_registry_entry_t ioRegistryRoot =
|
||||
IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/");
|
||||
CFStringRef uuidCf =
|
||||
(CFStringRef)IORegistryEntryCreateCFProperty(ioRegistryRoot, CFSTR(kIOPlatformUUIDKey), kCFAllocatorDefault, 0);
|
||||
IOObjectRelease(ioRegistryRoot);
|
||||
CFStringGetCString(uuidCf, ret, sizeof(ret), kCFStringEncodingMacRoman);
|
||||
CFRelease(uuidCf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
687
MacUninstallApp.cpp
Normal file
687
MacUninstallApp.cpp
Normal file
@@ -0,0 +1,687 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: macuninstallapp.cpp
|
||||
// Purpose:
|
||||
// Author: Fritz Elfert
|
||||
// Modified by:
|
||||
// Created: Fri 11 Sep 2009 01:17:42 PM CEST
|
||||
// RCS-ID:
|
||||
// Copyright: (C) 2009 by Fritz Elfert
|
||||
// Licence:
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#include <wx/stdpaths.h>
|
||||
#include <wx/apptrait.h>
|
||||
#include <wx/filename.h>
|
||||
#include <wx/cmdline.h>
|
||||
#include <wx/xml/xml.h>
|
||||
#include <wx/arrstr.h>
|
||||
#include <wx/dir.h>
|
||||
#include <wx/mstream.h>
|
||||
#include <wx/wfstream.h>
|
||||
#include <Security/Authorization.h>
|
||||
#include <Security/AuthorizationTags.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <fstream>
|
||||
|
||||
#include "macuninstallapp.h"
|
||||
|
||||
static unsigned long failed_files;
|
||||
static unsigned long failed_dirs;
|
||||
|
||||
class RmRfTraverser : public wxDirTraverser
|
||||
{
|
||||
public:
|
||||
RmRfTraverser(bool testMode)
|
||||
: m_bTestMode(testMode) { }
|
||||
|
||||
~RmRfTraverser()
|
||||
{
|
||||
int n = m_aFiles.GetCount() - 1;
|
||||
wxString fn;
|
||||
while (n >= 0) {
|
||||
fn = m_aFiles[n--];
|
||||
if (m_bTestMode) {
|
||||
wxLogMessage(_("TEST: Would delete file: %s"), fn.c_str());
|
||||
} else {
|
||||
if (::wxRemoveFile(fn))
|
||||
wxLogMessage(_("Deleted file: %s"), fn.c_str());
|
||||
else {
|
||||
failed_files++;
|
||||
wxLogWarning(_("Could not delete file %s"), fn.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
n = m_aDirs.GetCount() - 1;
|
||||
while (n >= 0) {
|
||||
fn = m_aDirs[n--];
|
||||
if (m_bTestMode) {
|
||||
wxLogMessage(_("TEST: Would delete diretory %s"), fn.c_str());
|
||||
} else {
|
||||
if (::wxRmdir(fn))
|
||||
wxLogMessage(_("Deleted diretory %s"), fn.c_str());
|
||||
else {
|
||||
failed_dirs++;
|
||||
wxLogWarning(_("Could not delete directory %s"), fn.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual wxDirTraverseResult OnFile(const wxString& filename)
|
||||
{
|
||||
m_aFiles.Add(filename);
|
||||
return wxDIR_CONTINUE;
|
||||
}
|
||||
|
||||
virtual wxDirTraverseResult OnDir(const wxString& dirpath)
|
||||
{
|
||||
m_aDirs.Add(dirpath);
|
||||
return wxDIR_CONTINUE;
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_bTestMode;
|
||||
wxArrayString m_aDirs;
|
||||
wxArrayString m_aFiles;
|
||||
};
|
||||
|
||||
IMPLEMENT_APP(MacUninstallApp)
|
||||
IMPLEMENT_CLASS(MacUninstallApp, wxApp)
|
||||
|
||||
BEGIN_EVENT_TABLE(MacUninstallApp, wxApp)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
MacUninstallApp::MacUninstallApp()
|
||||
{
|
||||
failed_files = failed_dirs = 0;
|
||||
m_bBatchMode = false;
|
||||
m_bTestMode = false;
|
||||
m_bCancelled = false;
|
||||
m_sSelfPath = wxFileName(
|
||||
GetTraits()->GetStandardPaths().GetExecutablePath()).GetFullPath();
|
||||
m_nodelete.insert(wxT("."));
|
||||
m_nodelete.insert(wxT("./Applications"));
|
||||
m_nodelete.insert(wxT("./Library"));
|
||||
m_nodelete.insert(wxT("./usr/share/man/man1"));
|
||||
m_nodelete.insert(wxT("./usr/share/man"));
|
||||
m_nodelete.insert(wxT("./usr/share"));
|
||||
m_nodelete.insert(wxT("./usr"));
|
||||
}
|
||||
|
||||
void MacUninstallApp::OnInitCmdLine(wxCmdLineParser& parser)
|
||||
{
|
||||
// Init standard options (--help, --verbose);
|
||||
wxApp::OnInitCmdLine(parser);
|
||||
parser.AddSwitch(wxEmptyString, wxT("test"),
|
||||
_("Test mode. Just create log file reporting what would happen."));
|
||||
parser.AddSwitch(wxEmptyString, wxT("batch"),
|
||||
_("Uninstall without asking the user (needs admin rights)."));
|
||||
}
|
||||
|
||||
bool MacUninstallApp::OnCmdLineParsed(wxCmdLineParser& parser)
|
||||
{
|
||||
m_bBatchMode = parser.Found(wxT("batch"));
|
||||
m_bTestMode = parser.Found(wxT("test"));
|
||||
if (m_bTestMode)
|
||||
m_bBatchMode = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialisation for MacUninstallApp
|
||||
*/
|
||||
|
||||
bool MacUninstallApp::OnInit()
|
||||
{
|
||||
wxFileName fn(m_sSelfPath);
|
||||
fn.RemoveLastDir();
|
||||
fn.AppendDir(wxT("share"));
|
||||
fn.AppendDir(wxT("locale"));
|
||||
m_cLocale.AddCatalogLookupPathPrefix(fn.GetPath());
|
||||
m_cLocale.Init();
|
||||
m_cLocale.AddCatalog(wxT("opennx"));
|
||||
wxString targetPkg = wxT("OpenNX");
|
||||
wxString targetPkgId = wxT("org.opennx.OpenNX");
|
||||
|
||||
// Call to base class needed for initializing command line processing
|
||||
if (!wxApp::OnInit())
|
||||
return false;
|
||||
|
||||
wxInitAllImageHandlers();
|
||||
wxBitmap::InitStandardHandlers();
|
||||
m_sLogName << wxT("/tmp/uninstall-") << targetPkgId << wxT(".log");
|
||||
if (m_bBatchMode) {
|
||||
if ((!m_bTestMode) && (0 != geteuid())) {
|
||||
::wxMessageBox(_("Batch uninstall needs to be started as root."),
|
||||
wxString::Format(_("Uninstall %s"), targetPkg.c_str()),
|
||||
wxOK|wxICON_ERROR);
|
||||
while (Pending())
|
||||
Dispatch();
|
||||
return false;
|
||||
}
|
||||
bool ok = DoUninstall(targetPkg, targetPkgId);
|
||||
wxLogMessage(_("Uninstall finished at %s"), wxDateTime::Now().Format().c_str());
|
||||
wxLogMessage(_("Status: %s, failed files: %lu, failed dirs: %lu"),
|
||||
(ok ? _("OK") : _("FAILED")), failed_files, failed_dirs);
|
||||
// Print result to stdout for parent (elevation wrapper)
|
||||
wxString ptmp;
|
||||
if (::wxGetEnv(wxT("MACUNINST_ELEVATION_PID"), &ptmp)) {
|
||||
long epid;
|
||||
if (ptmp.ToLong(&epid)) {
|
||||
if (getppid() == epid) {
|
||||
wxLogMessage(_("Reporting result to elevation wrapper %s"), ptmp.c_str());
|
||||
printf("%d %lu %lu\n", ok ? 0 : 1, failed_files, failed_dirs);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int r = ::wxMessageBox(
|
||||
wxString::Format(
|
||||
_("This operation can not be undone!\nDo you really want to uninstall %s?"),
|
||||
targetPkg.c_str()),
|
||||
wxString::Format(_("Uninstall %s"), targetPkg.c_str()),
|
||||
wxYES_NO|wxNO_DEFAULT|wxICON_EXCLAMATION);
|
||||
if (wxYES == r) {
|
||||
if (!TestReceipt(targetPkg, targetPkgId)) {
|
||||
while (Pending())
|
||||
Dispatch();
|
||||
return false;
|
||||
}
|
||||
if (ElevatedUninstall(targetPkg, targetPkgId)) {
|
||||
if (!m_bCancelled) {
|
||||
if (0 == (failed_files + failed_dirs)) {
|
||||
::wxMessageBox(
|
||||
wxString::Format(_("%s has been removed successfully."),
|
||||
targetPkg.c_str()),
|
||||
_("Uninstallation complete"), wxOK|wxICON_INFORMATION);
|
||||
} else {
|
||||
::wxMessageBox(
|
||||
wxString::Format(
|
||||
_("%s could not be removed completely.\nSome files or directories could not be deleted.\nPlease investigate the log file\n%s\n for more information."),
|
||||
targetPkg.c_str(), m_sLogName.c_str()),
|
||||
_("Uninstallation incomplete"), wxOK|wxICON_EXCLAMATION);
|
||||
}
|
||||
}
|
||||
} else
|
||||
::wxMessageBox(
|
||||
wxString::Format(
|
||||
_("Uninstallation has failed.\nThe reason should have been logged in the file\n%s"),
|
||||
m_sLogName.c_str()),
|
||||
_("Uninstallation failed"), wxOK|wxICON_ERROR);
|
||||
}
|
||||
}
|
||||
while (Pending())
|
||||
Dispatch();
|
||||
return false;
|
||||
}
|
||||
|
||||
int MacUninstallApp::OnExit()
|
||||
{
|
||||
return wxApp::OnExit();
|
||||
}
|
||||
|
||||
wxVariant MacUninstallApp::GetPlistValue(
|
||||
const wxXmlDocument &doc, const wxString &docname, const wxString &keyname)
|
||||
{
|
||||
wxVariant ret;
|
||||
ret.Clear();
|
||||
if (doc.GetRoot()->GetName() != wxT("plist")) {
|
||||
wxLogError(_("Not an XML plist: %s"), docname.c_str());
|
||||
return ret;
|
||||
}
|
||||
wxXmlNode *child = doc.GetRoot()->GetChildren();
|
||||
if (child->GetName() != wxT("dict")) {
|
||||
wxLogError(
|
||||
_("Invalid plist (missing toplevel <dict> in %s"),
|
||||
docname.c_str());
|
||||
return ret;
|
||||
}
|
||||
child = child->GetChildren();
|
||||
bool needkey = true;
|
||||
bool found = false;
|
||||
while (child) {
|
||||
if (needkey) {
|
||||
if (child->GetName() != wxT("key")) {
|
||||
wxLogError(
|
||||
_("Invalid plist (expected a key) in %s"),
|
||||
docname.c_str());
|
||||
return ret;
|
||||
}
|
||||
if (child->GetNodeContent().IsSameAs(keyname))
|
||||
found = true;
|
||||
} else {
|
||||
if (found) {
|
||||
if (child->GetName().IsSameAs(wxT("array"))) {
|
||||
wxLogError(
|
||||
_("Unsupported type array in %s"), docname.c_str());
|
||||
return ret;
|
||||
}
|
||||
if (child->GetName().IsSameAs(wxT("real"))) {
|
||||
double val;
|
||||
if (!child->GetNodeContent().ToDouble(&val)) {
|
||||
wxLogError(
|
||||
_("Invalid plist (invalid real value %s) in %s"),
|
||||
child->GetNodeContent().c_str(), docname.c_str());
|
||||
} else
|
||||
ret = val;
|
||||
return ret;
|
||||
}
|
||||
if (child->GetName().IsSameAs(wxT("integer"))) {
|
||||
long val;
|
||||
if (!child->GetNodeContent().ToLong(&val)) {
|
||||
wxLogError(
|
||||
_("Invalid plist (invalid integer value %s) in %s"),
|
||||
child->GetNodeContent().c_str(), docname.c_str());
|
||||
} else
|
||||
ret = val;
|
||||
return ret;
|
||||
}
|
||||
if (child->GetName().IsSameAs(wxT("string"))) {
|
||||
ret = child->GetNodeContent();
|
||||
return ret;
|
||||
}
|
||||
if (child->GetName().IsSameAs(wxT("true")) ||
|
||||
child->GetName().IsSameAs(wxT("false"))) {
|
||||
ret = child->GetName().IsSameAs(wxT("true"));
|
||||
return ret;
|
||||
}
|
||||
if (child->GetName().IsSameAs(wxT("date"))) {
|
||||
wxDateTime dt;
|
||||
if (NULL == dt.ParseDateTime(child->GetNodeContent())) {
|
||||
wxLogError(
|
||||
_("Invalid plist (invalid date value %s) in %s"),
|
||||
child->GetNodeContent().c_str(), docname.c_str());
|
||||
} else
|
||||
ret = dt;
|
||||
return ret;
|
||||
}
|
||||
wxLogError(
|
||||
_("Invalid plist (unexpected type %s) in %s"),
|
||||
child->GetName().c_str(), docname.c_str());
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
needkey = (!needkey);
|
||||
child = child->GetNext();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
wxString MacUninstallApp::GetInstalledPath(const wxString &rcpt)
|
||||
{
|
||||
wxXmlDocument doc;
|
||||
|
||||
// Test for binary plist and convert it to xml if necessary.
|
||||
wxFileInputStream fis(rcpt);
|
||||
if (fis.IsOk()) {
|
||||
char buf[8];
|
||||
memset(buf, 0, 8);
|
||||
fis.Read(&buf, 7);
|
||||
if (0 == memcmp(buf, "bplist0", 7)) {
|
||||
wxString cmd(wxT("plutil -convert xml1 -o - "));
|
||||
cmd << rcpt;
|
||||
wxArrayString lines;
|
||||
if (0 == ::wxExecute(cmd, lines)) {
|
||||
size_t i;
|
||||
wxString fbuf;
|
||||
for (i = 0; i < lines.GetCount(); ++i) {
|
||||
// wxLogMessage(_("RLINE: %s"), lines[i].c_str());
|
||||
fbuf.Append(lines[i]).Append(wxT("\n"));
|
||||
}
|
||||
wxMemoryInputStream mis(fbuf.mb_str(), fbuf.Length());
|
||||
doc.Load(mis);
|
||||
}
|
||||
} else {
|
||||
doc.Load(rcpt);
|
||||
}
|
||||
}
|
||||
|
||||
if (doc.IsOk()) {
|
||||
wxVariant v = GetPlistValue(doc, rcpt, wxT("InstallPrefixPath"));
|
||||
if (v.IsNull()) {
|
||||
// Old variant
|
||||
v = GetPlistValue(doc, rcpt, wxT("IFPkgFlagRelocatable"));
|
||||
if (v.IsNull()) {
|
||||
wxLogError(_("Could not find requested key 'IFPkgFlagRelocatable' in receipt %s"),
|
||||
rcpt.c_str());
|
||||
return wxEmptyString;
|
||||
}
|
||||
wxString t = v.GetType();
|
||||
if (t != wxT("bool")) {
|
||||
wxLogError(_("Unexpected type '%s' of 'IFPkgFlagRelocatable' in receipt %s"),
|
||||
t.c_str(), rcpt.c_str());
|
||||
return wxEmptyString;
|
||||
}
|
||||
wxString pkey = (v.GetBool() ?
|
||||
wxT("IFPkgRelocatedPath") : wxT("IFPkgFlagDefaultLocation"));
|
||||
v = GetPlistValue(doc, rcpt, pkey);
|
||||
if (v.IsNull()) {
|
||||
wxLogError(_("Could not find requested key '%s' in receipt %s"),
|
||||
pkey.c_str(), rcpt.c_str());
|
||||
return wxEmptyString;
|
||||
}
|
||||
t = v.GetType();
|
||||
if (t != wxT("string")) {
|
||||
wxLogError(_("Unexpected type '%s' of '%s' in receipt %s"),
|
||||
t.c_str(), pkey.c_str(), rcpt.c_str());
|
||||
return wxEmptyString;
|
||||
}
|
||||
return v.GetString();
|
||||
} else {
|
||||
// New variant
|
||||
return v.GetString().Append(wxT("/"));
|
||||
}
|
||||
} else
|
||||
wxLogError(_("Could not read package receipt %s"), rcpt.c_str());
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
bool MacUninstallApp::FetchBOM(const wxString &bom,
|
||||
wxArrayString &dirs, wxArrayString &files)
|
||||
{
|
||||
if (!wxFileName::FileExists(bom)) {
|
||||
wxLogError(
|
||||
_("Missing BOM (Bill Of Materials) '%s'. Already unistalled?"), bom.c_str());
|
||||
return false;
|
||||
}
|
||||
wxString cmd(wxT("lsbom -fbcl -p f "));
|
||||
cmd << bom;
|
||||
wxArrayString err;
|
||||
if (0 != ::wxExecute(cmd, files, err)) {
|
||||
wxLogError(
|
||||
_("Could not list BOM (Bill Of Materials) '%s'. Already unistalled?"), bom.c_str());
|
||||
return false;
|
||||
}
|
||||
if (0 != err.GetCount() != 0) {
|
||||
wxLogError(
|
||||
_("Invalid BOM (Bill Of Materials) '%s'. Already unistalled?"), bom.c_str());
|
||||
return false;
|
||||
}
|
||||
cmd = wxT("lsbom -d -p f ");
|
||||
cmd << bom;
|
||||
err.Empty();
|
||||
if (0 != ::wxExecute(cmd, dirs, err)) {
|
||||
wxLogError(
|
||||
_("Could not list BOM (Bill Of Materials) '%s'. Already unistalled?"), bom.c_str());
|
||||
return false;
|
||||
}
|
||||
if (0 != err.GetCount() != 0) {
|
||||
wxLogError(
|
||||
_("Invalid BOM (Bill Of Materials) '%s'. Already unistalled?"), bom.c_str());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MacUninstallApp::TestReceipt(const wxString &pkg, const wxString &pkgid)
|
||||
{
|
||||
wxString rpath = wxT("/Library/Receipts/");
|
||||
wxString proot;
|
||||
wxString bompath;
|
||||
rpath.Append(pkg).Append(wxT(".pkg"));
|
||||
if (wxFileName::DirExists(rpath)) {
|
||||
proot = GetInstalledPath(rpath + wxT("/Contents/Info.plist"));
|
||||
bompath = rpath + wxT("/Contents/Archive.bom");
|
||||
} else {
|
||||
rpath = wxT("/var/db/receipts/");
|
||||
bompath = rpath;
|
||||
rpath.Append(pkgid).Append(wxT(".plist"));
|
||||
if (wxFileName::FileExists(rpath)) {
|
||||
proot = GetInstalledPath(rpath);
|
||||
bompath.Append(pkgid).Append(wxT(".bom"));
|
||||
} else {
|
||||
wxLogWarning(
|
||||
_("The package receipt does not exist. Already unistalled?"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (proot.IsEmpty())
|
||||
return false;
|
||||
if (!wxFileName::DirExists(proot)) {
|
||||
wxLogWarning(
|
||||
_("The package install path does not exist. Already unistalled?"));
|
||||
return false;
|
||||
}
|
||||
wxArrayString d;
|
||||
wxArrayString f;
|
||||
if (!FetchBOM(bompath, d, f))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MacUninstallApp::DoUninstall(const wxString &pkg, const wxString &pkgid)
|
||||
{
|
||||
std::ofstream *log = new std::ofstream();
|
||||
log->open(m_sLogName.mb_str());
|
||||
delete wxLog::SetActiveTarget(new wxLogStream(log));
|
||||
wxLogMessage(_("Uninstall started at %s"), wxDateTime::Now().Format().c_str());
|
||||
wxString rpath = wxT("/Library/Receipts/");
|
||||
wxString proot;
|
||||
wxString bompath;
|
||||
bool oldreceipt = true;
|
||||
rpath.Append(pkg).Append(wxT(".pkg"));
|
||||
if (wxFileName::DirExists(rpath)) {
|
||||
proot = GetInstalledPath(rpath + wxT("/Contents/Info.plist"));
|
||||
bompath = rpath + wxT("/Contents/Archive.bom");
|
||||
} else {
|
||||
rpath = wxT("/var/db/receipts/");
|
||||
bompath = rpath;
|
||||
rpath.Append(pkgid).Append(wxT(".plist"));
|
||||
proot = GetInstalledPath(rpath);
|
||||
bompath.Append(pkgid).Append(wxT(".bom"));
|
||||
oldreceipt = false;
|
||||
}
|
||||
if (proot.IsEmpty())
|
||||
return false;
|
||||
wxArrayString d;
|
||||
wxArrayString f;
|
||||
if (!FetchBOM(bompath, d, f))
|
||||
return false;
|
||||
size_t i;
|
||||
wxLogMessage(_("Deleting package content"));
|
||||
for (i = 0; i < f.GetCount(); i++) {
|
||||
if (m_nodelete.find(f[i]) != m_nodelete.end()) {
|
||||
f.RemoveAt(i--);
|
||||
continue;
|
||||
}
|
||||
wxFileName fn(proot + f[i]);
|
||||
if (fn.Normalize(wxPATH_NORM_DOTS|wxPATH_NORM_ABSOLUTE)) {
|
||||
wxString name = fn.GetFullPath();
|
||||
if (m_bTestMode) {
|
||||
f.RemoveAt(i--);
|
||||
wxLogMessage(_("TEST: Would delete file: %s"), name.c_str());
|
||||
} else {
|
||||
if (::wxRemoveFile(name) || (!fn.FileExists())) {
|
||||
f.RemoveAt(i--);
|
||||
wxLogMessage(_("Deleted file: %s"), name.c_str());
|
||||
} else {
|
||||
failed_files++;
|
||||
wxLogWarning(_("Could not delete file %s"), name.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
size_t lcd;
|
||||
do {
|
||||
lcd = d.GetCount();
|
||||
for (i = 0; i < d.GetCount(); i++) {
|
||||
if (m_nodelete.find(d[i]) != m_nodelete.end()) {
|
||||
d.RemoveAt(i--);
|
||||
continue;
|
||||
}
|
||||
wxFileName fn(proot + d[i]);
|
||||
if (fn.Normalize(wxPATH_NORM_DOTS|wxPATH_NORM_ABSOLUTE)) {
|
||||
wxString name = fn.GetFullPath();
|
||||
if (m_bTestMode) {
|
||||
d.RemoveAt(i--);
|
||||
wxLogMessage(_("TEST: Would delete directory: %s"), name.c_str());
|
||||
} else {
|
||||
if (::wxRmdir(name) || (!fn.DirExists())) {
|
||||
d.RemoveAt(i--);
|
||||
wxLogMessage(_("Deleted directory: %s"), name.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (lcd != d.GetCount());
|
||||
if (0 < d.GetCount()) {
|
||||
for (i = 0; i < d.GetCount(); i++) {
|
||||
failed_dirs++;
|
||||
wxLogWarning(_("Could not delete directory %s"), d[i].c_str());
|
||||
}
|
||||
}
|
||||
if (0 == (d.GetCount() + f.GetCount())) {
|
||||
// Finally delete the receipe itself
|
||||
wxLogMessage(_("Deleting receipt"));
|
||||
if (oldreceipt) {
|
||||
{
|
||||
wxDir d(rpath);
|
||||
RmRfTraverser t(m_bTestMode);
|
||||
d.Traverse(t);
|
||||
}
|
||||
if (m_bTestMode) {
|
||||
wxLogMessage(_("TEST: Would delete directory: %s"), rpath.c_str());
|
||||
} else {
|
||||
if (::wxRmdir(rpath))
|
||||
wxLogMessage(_("Deleted directory: %s"), rpath.c_str());
|
||||
else {
|
||||
failed_dirs++;
|
||||
wxLogWarning(_("Could not delete directory %s"), rpath.c_str());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (m_bTestMode) {
|
||||
wxLogMessage(_("TEST: Would delete receipt: %s"), rpath.c_str());
|
||||
wxLogMessage(_("TEST: Would delete BOM: %s"), bompath.c_str());
|
||||
} else {
|
||||
if (::wxRemoveFile(rpath)) {
|
||||
wxLogMessage(_("Deleted receipt: %s"), rpath.c_str());
|
||||
} else {
|
||||
wxLogWarning(_("Could not delete receipt %s"), rpath.c_str());
|
||||
}
|
||||
if (::wxRemoveFile(bompath)) {
|
||||
wxLogMessage(_("Deleted BOM: %s"), bompath.c_str());
|
||||
} else {
|
||||
wxLogWarning(_("Could not delete BOM %s"), bompath.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
wxLogMessage(_("Receipt NOT deleted, because package files have been left."));
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute with administrative rights.
|
||||
*/
|
||||
bool MacUninstallApp::ElevatedUninstall(const wxString &pkg, const wxString &pkgid)
|
||||
{
|
||||
// If we are already root, do the uninstall directly
|
||||
if (geteuid() == 0)
|
||||
return DoUninstall(pkg, pkgid);
|
||||
|
||||
wxString msg = wxString::Format(
|
||||
_("In order to uninstall %s, administrative rights are required.\n\n"),
|
||||
pkg.c_str());
|
||||
char *prompt = strdup(msg.utf8_str());
|
||||
|
||||
OSStatus st;
|
||||
AuthorizationFlags aFlags = kAuthorizationFlagDefaults;
|
||||
AuthorizationRef aRef;
|
||||
AuthorizationItem promptItem = {
|
||||
kAuthorizationEnvironmentPrompt, strlen(prompt), prompt, 0
|
||||
};
|
||||
AuthorizationEnvironment aEnv = { 1, &promptItem };
|
||||
|
||||
st = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment,
|
||||
kAuthorizationFlagDefaults, &aRef);
|
||||
if (errAuthorizationSuccess != st) {
|
||||
wxLogError(_("Authorization could not be created: %s"), MacAuthError(st).c_str());
|
||||
return true;
|
||||
}
|
||||
AuthorizationItem aItems = { kAuthorizationRightExecute, 0, NULL, 0 };
|
||||
AuthorizationRights aRights = { 1, &aItems };
|
||||
aFlags = kAuthorizationFlagDefaults |
|
||||
kAuthorizationFlagInteractionAllowed |
|
||||
kAuthorizationFlagPreAuthorize |
|
||||
kAuthorizationFlagExtendRights;
|
||||
st = AuthorizationCopyRights(aRef, &aRights, &aEnv, aFlags, NULL );
|
||||
bool ret = true;
|
||||
if (errAuthorizationSuccess == st) {
|
||||
char *executable = strdup(m_sSelfPath.utf8_str());
|
||||
char *args[] = { "--batch", NULL };
|
||||
FILE *pout = NULL;
|
||||
|
||||
if (!::wxGetEnv(wxT("TMPDIR"), NULL))
|
||||
::wxSetEnv(wxT("TMPDIR"), wxFileName::GetTempDir());
|
||||
::wxSetEnv(wxT("MACUNINST_ELEVATION_PID"), wxString::Format(wxT("%d"), ::wxGetProcessId()));
|
||||
st = AuthorizationExecuteWithPrivileges(aRef,
|
||||
executable, kAuthorizationFlagDefaults, args, &pout);
|
||||
if (errAuthorizationSuccess == st) {
|
||||
int status;
|
||||
fscanf(pout, "%d %lu %lu", &status, &failed_files, &failed_dirs);
|
||||
ret = (0 == status);
|
||||
} else
|
||||
wxLogError(_("Could not execute with administrative rights:\n%s"), MacAuthError(st).c_str());
|
||||
} else {
|
||||
if (st) {
|
||||
m_bCancelled = (errAuthorizationCanceled == st);
|
||||
if (!m_bCancelled)
|
||||
wxLogError(_("Authorization failed: %s"), MacAuthError(st).c_str());
|
||||
}
|
||||
}
|
||||
AuthorizationFree(aRef, kAuthorizationFlagDefaults);
|
||||
return ret;
|
||||
}
|
||||
|
||||
wxString MacUninstallApp::MacAuthError(long code)
|
||||
{
|
||||
wxString ret;
|
||||
switch (code) {
|
||||
case errAuthorizationSuccess:
|
||||
return wxT("The operation completed successfully.");
|
||||
case errAuthorizationInvalidSet:
|
||||
return wxT("The set parameter is invalid.");
|
||||
case errAuthorizationInvalidRef:
|
||||
return wxT("The authorization parameter is invalid.");
|
||||
case errAuthorizationInvalidTag:
|
||||
return wxT("The tag parameter is invalid.");
|
||||
case errAuthorizationInvalidPointer:
|
||||
return wxT("The authorizedRights parameter is invalid.");
|
||||
case errAuthorizationDenied:
|
||||
return wxT("The Security Server denied authorization for one or more requested rights.");
|
||||
case errAuthorizationCanceled:
|
||||
return wxT("The user canceled the operation.");
|
||||
case errAuthorizationInteractionNotAllowed:
|
||||
return wxT("The Security Server denied authorization because no user interaction is allowed.");
|
||||
case errAuthorizationInternal:
|
||||
return wxT("An unrecognized internal error occurred.");
|
||||
case errAuthorizationExternalizeNotAllowed:
|
||||
return wxT("The Security Server denied externalization of the authorization reference.");
|
||||
case errAuthorizationInternalizeNotAllowed:
|
||||
return wxT("The Security Server denied internalization of the authorization reference.");
|
||||
case errAuthorizationInvalidFlags:
|
||||
return wxT("The flags parameter is invalid.");
|
||||
case errAuthorizationToolExecuteFailure:
|
||||
return wxT("The tool failed to execute.");
|
||||
case errAuthorizationToolEnvironmentError:
|
||||
return wxT("The attempt to execute the tool failed to return a success or an error code.");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
57
MacUninstallApp.h
Normal file
57
MacUninstallApp.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: macuninstallapp.h
|
||||
// Purpose:
|
||||
// Author: Fritz Elfert
|
||||
// Modified by:
|
||||
// Created: Fri 11 Sep 2009 01:17:42 PM CEST
|
||||
// RCS-ID:
|
||||
// Copyright: (C) 2009 by Fritz Elfert
|
||||
// Licence:
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _MACUNINSTALLAPP_H_
|
||||
#define _MACUNINSTALLAPP_H_
|
||||
|
||||
#include "wx/image.h"
|
||||
#include <wx/intl.h>
|
||||
#include <wx/hashset.h>
|
||||
|
||||
class wxArrayString;
|
||||
|
||||
WX_DECLARE_HASH_SET(wxString, wxStringHash, wxStringEqual, StringSet);
|
||||
|
||||
class MacUninstallApp: public wxApp
|
||||
{
|
||||
DECLARE_CLASS( MacUninstallApp )
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
public:
|
||||
MacUninstallApp();
|
||||
|
||||
virtual void OnInitCmdLine(wxCmdLineParser& parser);
|
||||
virtual bool OnCmdLineParsed(wxCmdLineParser& parser);
|
||||
virtual bool OnInit();
|
||||
virtual int OnExit();
|
||||
|
||||
private:
|
||||
wxVariant GetPlistValue(const wxXmlDocument &doc, const wxString &docname, const wxString &keyname);
|
||||
bool ElevatedUninstall(const wxString &, const wxString &);
|
||||
bool DoUninstall(const wxString &, const wxString &);
|
||||
bool TestReceipt(const wxString &, const wxString &);
|
||||
bool FetchBOM(const wxString &, wxArrayString &, wxArrayString &);
|
||||
wxString GetInstalledPath(const wxString &);
|
||||
wxString MacAuthError(long);
|
||||
|
||||
bool m_bBatchMode;
|
||||
bool m_bTestMode;
|
||||
bool m_bCancelled;
|
||||
wxLocale m_cLocale;
|
||||
wxString m_sSelfPath;
|
||||
wxString m_sLogName;
|
||||
StringSet m_nodelete;
|
||||
};
|
||||
|
||||
DECLARE_APP(MacUninstallApp)
|
||||
|
||||
#endif
|
||||
// _MACUNINSTALLAPP_H_
|
||||
308
Makefile.am
Normal file
308
Makefile.am
Normal file
@@ -0,0 +1,308 @@
|
||||
AM_LIBTOOLFLAGS = --silent
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
SUBDIRS = po docs $(PLATFORM_SUBDIRS)
|
||||
DIST_SUBDIRS = po docs packaging/win32 packaging/MacOSX
|
||||
|
||||
noinst_PROGRAMS = bin2hdr pulsetest $(TESTXAUTH) $(MACTESTKBD)
|
||||
|
||||
bin2hdr_SOURCES = bin2hdr.cpp
|
||||
bin2hdr_LDFLAGS = -all-static
|
||||
|
||||
bin_PROGRAMS = opennx pconnect $(TRACELOG) $(WATCHREADER) $(WATCHUSBIP) \
|
||||
$(MACFINDREADER) $(MACUNINSTALL)
|
||||
|
||||
EXTRA_PROGRAMS = tracelog$(EXEEXT) watchreader$(EXEEXT) \
|
||||
watchusbip$(EXEEXT) macfindreader$(EXEEXT) macuninstall$(EXEEXT) \
|
||||
mactestkbd$(EXEEXT) testxauth$(EXEEXT)
|
||||
|
||||
opennx_SOURCES = AboutDialog.cpp AsyncProcess.cpp LibOpenSC.cpp \
|
||||
CardWaiterDialog.cpp ConnectDialog.cpp ExtHtmlWindow.cpp \
|
||||
ForeignFrame.cpp Icon.cpp LogDialog.cpp KeyDialog.cpp LibUSB.cpp \
|
||||
LoginDialog.cpp mylog.cpp md5.c MyIPC.cpp MyDynlib.cpp MySession.cpp \
|
||||
MyValidator.cpp MyWizard.cpp MyXmlConfig.cpp opennxApp.cpp \
|
||||
osdep.c PanicDialog.cpp pwcrypt.cpp ProxyPasswordDialog.cpp \
|
||||
PulseAudio.cpp QuitDialog.cpp RdpImageSettingsDialog.cpp \
|
||||
RdpPropertyDialog.cpp ResumeDialog.cpp ProxyPropertyDialog.cpp \
|
||||
SessionAdmin.cpp SessionList.cpp SessionProperties.cpp \
|
||||
SimpleXauth.cpp ShareProperties.cpp TextViewer.cpp \
|
||||
UnixImageSettingsDialog.cpp UsbFilterDetailsDialog.cpp \
|
||||
UsbIp.cpp VncImageSettingsDialog.cpp VncPropertyDialog.cpp \
|
||||
wxprec.cpp WinShare.cpp X11PropertyDialog.cpp \
|
||||
MacOSX.c WrappedStatic.cpp SupressibleMessageDialog.cpp \
|
||||
XdmPropertyDialog.cpp
|
||||
|
||||
noinst_HEADERS = AboutDialog.h AboutDialog_symbols.h AsyncProcess.h \
|
||||
LibOpenSC.h CardWaiterDialog.h CardWaiterDialog_symbols.h \
|
||||
ConnectDialog.h ConnectDialog_symbols.h debugleak.h \
|
||||
DebugStringGrabber.h ExtHtmlWindow.h ForeignFrame.h \
|
||||
ForeignFrame_symbols.h Icon.h KeyDialog.h KeyDialog_symbols.h \
|
||||
LibUSB.h LogDialog.h LogDialog_symbols.h LoginDialog.h mylog.h \
|
||||
LoginDialog_symbols.h md5.h memres.h MyIPC.h MyDynlib.h MySession.h \
|
||||
MyValidator.h MyWizard.h MyWizard_symbols.h MyXmlConfig.h opennxApp.h \
|
||||
osdep.h PanicDialog.h PanicDialog_symbols.h PulseAudio.h pwcrypt.h \
|
||||
QuitDialog.h QuitDialog_symbols.h ProxyPasswordDialog.h \
|
||||
ProxyPasswordDialog_symbols.h ProxyPropertyDialog.h pulseTest.h \
|
||||
ProxyPropertyDialog_symbols.h RdpImageSettingsDialog.h \
|
||||
RdpImageSettingsDialog_symbols.h RdpPropertyDialog.h \
|
||||
RdpPropertyDialog_symbols.h ResumeDialog.h ResumeDialog_symbols.h \
|
||||
SessionAdmin.h SessionAdmin_symbols.h SessionList.h SimpleXauth.h \
|
||||
SessionProperties.h SessionProperties_symbols.h ShareProperties.h \
|
||||
ShareProperties_symbols.h TextViewer.h TextViewer_symbols.h \
|
||||
TraceLogFrame.h TraceLogFrame_symbols.h UnixImageSettingsDialog.h \
|
||||
UnixImageSettingsDialog_symbols.h UsbFilterDetailsDialog.h \
|
||||
UsbFilterDetailsDialog_symbols.h UsbIp.h \
|
||||
VncImageSettingsDialog.h VncImageSettingsDialog_symbols.h \
|
||||
VncPropertyDialog.h VncPropertyDialog_symbols.h WinShare.h \
|
||||
X11PropertyDialog.h X11PropertyDialog_symbols.h trace.h tracelogApp.h \
|
||||
watchReaderApp.h watchUsbIpApp.h MacUninstallApp.h \
|
||||
WrappedStatic.h SupressibleMessageDialog.h SupressibleMessageDialog_symbols.h \
|
||||
TraceLogRemote_symbols.h TraceLogRemote.h \
|
||||
opensc/errors.h opensc/opensc.h opensc/scconf.h opensc/types.h opensc/pkcs15.h \
|
||||
libsmbclient.h \
|
||||
XdmPropertyDialog.h XdmPropertyDialog_symbols.h
|
||||
|
||||
pconnect_SOURCES = pconnect.c
|
||||
pconnect_LDADD = $(WS2LIB) $(RESLIB)
|
||||
|
||||
pulsetest_SOURCES = pulseTest.cpp PulseAudio.cpp MyDynlib.cpp mylog.cpp osdep.c MacOSX.c
|
||||
pulsetest_LDADD = $(WX_LIBS) $(X_LIBS) $(X_PRE_LIBS) $(X_EXTRA_LIBS) $(APP_LDADD)
|
||||
pulsetest_CPPFLAGS = $(WX_CPPFLAGS) $(PLATFORM_INCLUDES) -DAPP_PULSETEST
|
||||
pulsetest_DEPENDENCIES = $(OPENNX_RES) $(PLATFORM_DEPENDENCIES)
|
||||
pulsetest_CXXFLAGS = $(WX_CXXFLAGS)
|
||||
pulsetest_CFLAGS = $(WX_CFLAGS)
|
||||
|
||||
|
||||
testxauth_SOURCES = testxauth.cpp SimpleXauth.cpp pwcrypt.cpp md5.c
|
||||
testxauth_LDADD = $(WX_LIBS)
|
||||
testxauth_CPPFLAGS = $(WX_CPPFLAGS) -DAPP_TESTXAUTH
|
||||
testxauth_CXXFLAGS = $(WX_CXXFLAGS)
|
||||
testxauth_CFLAGS = $(WX_CFLAGS)
|
||||
|
||||
watchreader_SOURCES = watchReaderApp.cpp LibOpenSC.cpp MyDynlib.cpp MacOSX.c osdep.c mylog.cpp
|
||||
watchreader_DEPENDENCIES = $(WATCHREADER_RES)
|
||||
watchreader_LDADD = $(WATCHREADER_RES) $(WX_LIBS) $(X_LIBS) \
|
||||
$(X_PRE_LIBS) $(X_EXTRA_LIBS) $(APP_LDADD)
|
||||
watchreader_CPPFLAGS = $(WX_CPPFLAGS) $(X_CFLAGS) -DAPP_WATCHREADER
|
||||
watchreader_CXXFLAGS = $(WX_CXXFLAGS)
|
||||
watchreader_CFLAGS = $(WX_CFLAGS)
|
||||
|
||||
watchusbip_SOURCES = watchUsbIpApp.cpp UsbIp.cpp Icon.cpp LibUSB.cpp \
|
||||
md5.c MyValidator.cpp MyXmlConfig.cpp osdep.c pwcrypt.cpp mylog.cpp \
|
||||
UsbFilterDetailsDialog.cpp wxprec.cpp MyDynlib.cpp
|
||||
|
||||
watchusbip_LDADD = $(WX_LIBS) $(X_LIBS) $(X_PRE_LIBS) $(X_EXTRA_LIBS) \
|
||||
$(APP_LDADD)
|
||||
watchusbip_CPPFLAGS = $(WX_CPPFLAGS) $(X_CFLAGS) -DAPP_WATCHUSBIP
|
||||
watchusbip_CXXFLAGS = $(WX_CXXFLAGS)
|
||||
watchusbip_CFLAGS = $(WX_CFLAGS)
|
||||
|
||||
tracelog_SOURCES = tracelogApp.cpp TraceLogFrame.cpp \
|
||||
DebugStringGrabber.cpp wxprec.cpp Icon.cpp TraceLogRemote.cpp
|
||||
tracelog_LDADD = $(TRACELOG_RES) $(WX_LIBS)
|
||||
tracelog_DEPENDENCIES = $(TRACELOG_RES)
|
||||
tracelog_CPPFLAGS = $(WX_CPPFLAGS) -DAPP_TRACELOG
|
||||
tracelog_CXXFLAGS = $(WX_CXXFLAGS)
|
||||
tracelog_CFLAGS = $(WX_CFLAGS)
|
||||
|
||||
macfindreader_SOURCES = macfindreader.c
|
||||
macfindreader_CFLAGS = $(UNIFLAGS) $(OSX_SDKFLAGS)
|
||||
macfindreader_LDADD = -ldl
|
||||
|
||||
macuninstall_SOURCES = MacUninstallApp.cpp MacOSX.c
|
||||
macuninstall_LDADD = $(WX_LIBS)
|
||||
macuninstall_LDFLAGS = -framework Security
|
||||
macuninstall_CPPFLAGS = $(WX_CPPFLAGS) -DAPP_MACUNINSTALL
|
||||
macuninstall_CXXFLAGS = $(WX_CXXFLAGS)
|
||||
macuninstall_CFLAGS = $(WX_CFLAGS)
|
||||
|
||||
mactestkbd_SOURCES = mactestkbd.c MacOSX.c
|
||||
mactestkbd_LDADD = $(WX_LIBS)
|
||||
mactextkbd_CPPFLAGS = $(WX_CPPFLAGS) -DAPP_MACTESTKBD
|
||||
mactestkbd_CFLAGS = $(WX_CFLAGS) -DAPP_MACTESTKBD
|
||||
|
||||
EXTRA_HEADERS = res/opennx.rc
|
||||
|
||||
EXTRA_opennx_SOURCES = opennx.rc
|
||||
EXTRA_tracelog_SOURCES = tracelog.rc
|
||||
EXTRA_watchreader_SOURCES = watchreader.rc
|
||||
|
||||
opennx_LDADD = $(OPENNX_RES) $(WX_LIBS) $(X_LIBS) $(X_PRE_LIBS) \
|
||||
$(X_EXTRA_LIBS) $(APP_LDADD) $(LIBCURL)
|
||||
opennx_DEPENDENCIES = $(OPENNX_RES) $(PLATFORM_DEPENDENCIES)
|
||||
opennx_CPPFLAGS = $(WX_CPPFLAGS) $(PLATFORM_INCLUDES) $(X_CFLAGS) -DAPP_OPENNX
|
||||
opennx_CXXFLAGS = $(WX_CXXFLAGS)
|
||||
opennx_CFLAGS = $(WX_CFLAGS)
|
||||
|
||||
|
||||
GETTEXTIZE = $(shell which gettextize)
|
||||
|
||||
bootstrap:
|
||||
# TODO: Needed here to update ChangeLog from git repo?
|
||||
autoreconf -if
|
||||
|
||||
bundle:
|
||||
$(srcdir)/packaging/MacOSX/mkbundle OpenNX.app OpenNXapp \
|
||||
$(srcdir)/extres/nx.icns $(abs_builddir)/opennx \
|
||||
$(builddir)/packaging/MacOSX/opennx-main.plist "OPNX"
|
||||
$(INSTALL) -m 0644 $(srcdir)/extres/nx-desktop.icns OpenNX.app/Contents/Resources
|
||||
$(srcdir)/packaging/MacOSX/mkbundle OpenNXAdmin.app OpenNXAdmin \
|
||||
$(srcdir)/extres/opennx-admin.icns $(abs_builddir)/opennx \
|
||||
$(builddir)/packaging/MacOSX/opennx.plist "" --admin
|
||||
$(srcdir)/packaging/MacOSX/mkbundle OpenNXWizard.app OpenNXWizard \
|
||||
$(srcdir)/extres/opennx-wizard.icns $(abs_builddir)/opennx \
|
||||
$(builddir)/packaging/MacOSX/opennx.plist "" --wizard
|
||||
$(srcdir)/packaging/MacOSX/mkbundle "Uninstall OpenNX.app" "" \
|
||||
$(srcdir)/extres/opennx-uninstall.icns $(abs_builddir)/macuninstall \
|
||||
$(builddir)/packaging/MacOSX/opennx.plist ""
|
||||
$(srcdir)/packaging/MacOSX/mkbundle Message.app OpenNXMessage \
|
||||
$(srcdir)/extres/nx.icns $(abs_builddir)/opennx \
|
||||
$(builddir)/packaging/MacOSX/opennx.plist "" \
|
||||
--dialog ok --style info --caption CARDREMOVED --message CARDREMOVED
|
||||
|
||||
all-local: $(BUNDLE)
|
||||
|
||||
clean-local:
|
||||
rm -rf OpenNX.app OpenNXAdmin.app OpenNXWizard.app Message.app \
|
||||
"Uninstall OpenNX.app"
|
||||
|
||||
distclean-local:
|
||||
rm -f po/stamp-po
|
||||
|
||||
install-wxstdmo-local:
|
||||
for lang in $(shell cat $(top_srcdir)/po/LINGUAS) ; do \
|
||||
$(INSTALL) -d $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES ; \
|
||||
$(INSTALL_DATA) $(WX_PREFIX)/share/locale/$$lang/LC_MESSAGES/wxstd.mo \
|
||||
$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/ ; \
|
||||
done
|
||||
|
||||
install-data-local: $(STATIC_LOCAL_INSTALLDATA_TARGET)
|
||||
|
||||
RESDEPS = $(wildcard $(srcdir)/res/*.xrc $(srcdir)/res/*.png \
|
||||
$(srcdir)/res/*.html $(srcdir)/res/*.xml)
|
||||
RESSRC = $(subst $(srcdir)/,,$(RESDEPS))
|
||||
|
||||
tmpres.zip: $(RESDEPS)
|
||||
$(AM_V_GEN)cd $(srcdir) && zip -q9r $(abs_builddir)/$(@F) $(RESSRC)
|
||||
|
||||
memres.h: tmpres.zip bin2hdr$(EXEEXT)
|
||||
$(AM_V_GEN)./bin2hdr$(EXEEXT) tmpres.zip memres.h mem_res
|
||||
|
||||
$(top_srcdir)/opennxApp.cpp: memres.h
|
||||
|
||||
opennxApp.cpp: memres.h
|
||||
|
||||
tracelogApp.cpp: memres.h
|
||||
|
||||
watchUsbIpApp.cpp: memres.h
|
||||
|
||||
SUFFIXES = .rc
|
||||
|
||||
.rc.o: $(OSRESDEPS)
|
||||
$(AM_V_GEN)$(WX_RESCOMP) -I$(top_builddir) -o $@ $<
|
||||
|
||||
CLEANFILES = memres.h tmpres.zip *~ po/*~ *.bak *~ \#.* .\#* OpenNX.app
|
||||
|
||||
MAINTAINERCLEANFILES = ABOUT-NLS Makefile.in configure aclocal.m4 \
|
||||
conf/config.guess conf/config.sub conf/depcomp conf/install-sh \
|
||||
conf/missing conf/mkinstalldirs conf/ltmain.sh conf/config.rpath \
|
||||
m4/*~ m4/[cgilnpuwx]*.m4 m4/s[it]*.m4 \
|
||||
po/*.sin po/*.sed po/*.header po/Rules-quot po/*.template po/Makefile*.in
|
||||
|
||||
DISTCLEANFILES = mingw32-config.cache res/*.prv.*
|
||||
|
||||
man_MANS = docs/pconnect.1
|
||||
|
||||
data_DATA = share/keyboards
|
||||
|
||||
keydir = $(datadir)/keys
|
||||
key_DATA = $(top_srcdir)/share/keys/*
|
||||
|
||||
install-data-local:
|
||||
$(MAKE) -C po stamp-po install-data-yes
|
||||
$(INSTALL) -d $(DESTDIR)$(datadir)/icons
|
||||
cd $(top_srcdir)/extres && \
|
||||
for d in 16x16 32x32 48x48 128x128 256x256 512x512 scalable ; do \
|
||||
$(INSTALL) -d $(DESTDIR)$(datadir)/icons/$$d ; \
|
||||
( \
|
||||
cd $$d && \
|
||||
for subd in * ; do \
|
||||
$(INSTALL) -d $(DESTDIR)$(datadir)/icons/$$d/$$subd ; \
|
||||
for f in $$subd/* ; do \
|
||||
$(INSTALL_DATA) $$f $(DESTDIR)$(datadir)/icons/$$d/$$subd ; \
|
||||
done \
|
||||
done \
|
||||
) \
|
||||
done
|
||||
$(INSTALL) -d $(DESTDIR)$(datadir)/applnk/xdg
|
||||
cd $(top_srcdir)/extres/xdg && \
|
||||
for d in * ; do \
|
||||
$(INSTALL_DATA) $$d $(DESTDIR)$(datadir)/applnk/xdg ; \
|
||||
done
|
||||
|
||||
uninstall-local:
|
||||
cd $(top_srcdir)/extres/xdg && \
|
||||
for d in * ; do \
|
||||
$(RM) -r $(DESTDIR)$(datadir)/applnk/xdg/$$d ; \
|
||||
done
|
||||
-rmdir $(DESTDIR)$(datadir)/applnk/xdg
|
||||
-rmdir $(DESTDIR)$(datadir)/applnk
|
||||
cd $(top_srcdir)/extres && \
|
||||
for d in 16x16 32x32 48x48 128x128 256x256 512x512 scalable ; do \
|
||||
( \
|
||||
cd $$d && \
|
||||
for subd in * ; do \
|
||||
for f in $$subd/* ; do \
|
||||
$(RM) $(DESTDIR)$(datadir)/icons/$$d/$$f ; \
|
||||
done ; \
|
||||
rmdir $(DESTDIR)$(datadir)/icons/$$d/$$subd || true ; \
|
||||
done \
|
||||
) ; \
|
||||
rmdir $(DESTDIR)$(datadir)/icons/$$d || true ; \
|
||||
done
|
||||
-rmdir $(DESTDIR)$(datadir)/icons
|
||||
|
||||
dist-hook:
|
||||
find $(distdir) -type d -name .svn | xargs $(RM) -r
|
||||
|
||||
# Platform specific special targets
|
||||
debprep: distcheck
|
||||
tar xfz $(PACKAGE)-$(VERSION).tar.gz
|
||||
cd $(PACKAGE)-$(VERSION) && ./getnxsrcpkg
|
||||
cd $(PACKAGE)-$(VERSION) && perl debian/mkchangelog.pl $(VERSION) \
|
||||
< ChangeLog > debian/changelog
|
||||
|
||||
# Create debian source package
|
||||
debsrc: debprep
|
||||
ln -snf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)_$(VERSION).orig.tar.gz
|
||||
dpkg-source -b -sP $(PACKAGE)-$(VERSION) $(PACKAGE)_$(VERSION).orig.tar.gz
|
||||
echo "Debtransform-Tar: $(PACKAGE)_$(VERSION).orig.tar.gz" >> $(PACKAGE)_$(VERSION)-$(SVNREV).dsc
|
||||
|
||||
deb: debprep
|
||||
cd $(PACKAGE)-$(VERSION) && dpkg-buildpackage -us -uc
|
||||
lintian -i $(PACKAGE)_$(VERSION).$(SVNREV)_*.changes
|
||||
$(RM) -r $(PACKAGE)-$(VERSION)
|
||||
|
||||
dmg:
|
||||
$(MAKE) -C packaging/MacOSX dmg
|
||||
|
||||
rpm: distcheck
|
||||
$(RPMBUILD) $(RPMBUILD_OPTS) -ta --with fetchnx $(PACKAGE)-$(VERSION).tar.gz
|
||||
|
||||
setup: all
|
||||
$(MAKE) -C packaging/win32 setup
|
||||
|
||||
unknown:
|
||||
@echo "Don't know how to build a distribution for $(target)"
|
||||
@exit 1
|
||||
|
||||
dist-platform: $(PLATFORMDIST)
|
||||
|
||||
packaging/MacOSX/pulse/include/pulse/pulseaudio.h:
|
||||
$(MAKE) -C packaging/MacOSX/pulse cachedinstall
|
||||
|
||||
EXTRA_DIST = conf/mkinstalldirs conf/mkinstalldirs conf/mkinstalldirs conf/mkinstalldirs conf/mkinstalldirs conf/mkinstalldirs conf/config.rpath conf/authors.xml \
|
||||
INSTALL INSTALL.generic COPYING share etc/60-opennx.rules \
|
||||
opennx.pjd opennx.rc tracelog.rc watchreader.rc \
|
||||
opennx.spec patches getnxsrcpkg $(RESDEPS) ChangeLog extres debian \
|
||||
$(wildcard m4/*.m4) $(man_MANS)
|
||||
95
MyDynlib.cpp
Normal file
95
MyDynlib.cpp
Normal file
@@ -0,0 +1,95 @@
|
||||
// $Id: MyDynlib.cpp 682 2012-02-09 23:34:48Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
||||
#pragma implementation "MyDynlib.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/defs.h"
|
||||
#endif
|
||||
|
||||
#include "MyDynlib.h"
|
||||
|
||||
#include <wx/dynlib.h>
|
||||
#include <wx/log.h>
|
||||
#include <wx/utils.h>
|
||||
#include <wx/tokenzr.h>
|
||||
|
||||
#include "trace.h"
|
||||
ENABLE_TRACE;
|
||||
|
||||
#ifdef __WXMAC__
|
||||
# define LD_LIBRARY_PATH wxT("DYLD_LIBRARY_PATH")
|
||||
#else
|
||||
# define LD_LIBRARY_PATH wxT("LD_LIBRARY_PATH")
|
||||
#endif
|
||||
|
||||
bool MyDynamicLibrary::Load(const wxString& name, int flags /* = wxDL_DEFAULT */)
|
||||
{
|
||||
myLogTrace(MYTRACETAG, wxT("Load(%s, 0x%0x)"), VMB(name), flags);
|
||||
#ifdef __WXMSW__
|
||||
return wxDynamicLibrary::Load(name, flags);
|
||||
#else
|
||||
wxString ldpath;
|
||||
if (::wxGetEnv(LD_LIBRARY_PATH, &ldpath)) {
|
||||
wxStringTokenizer t(ldpath, wxT(":"));
|
||||
while (t.HasMoreTokens()) {
|
||||
wxString abslib = t.GetNextToken() + wxFileName::GetPathSeparator() + name;
|
||||
myLogTrace(MYTRACETAG, wxT("Trying to load(%s 0x%0x)"), VMB(abslib), flags);
|
||||
if (wxDynamicLibrary::Load(abslib, flags))
|
||||
return true;
|
||||
#ifdef __WXMAC__
|
||||
if (!abslib.EndsWith(wxT(".dylib"))) {
|
||||
abslib += wxT(".dylib");
|
||||
myLogTrace(MYTRACETAG, wxT("Trying to load(%s, 0x%0x)"), VMB(abslib), flags|wxDL_VERBATIM);
|
||||
if (wxDynamicLibrary::Load(abslib, flags|wxDL_VERBATIM))
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
myLogTrace(MYTRACETAG, wxT("Falling back to default load"));
|
||||
if (wxDynamicLibrary::Load(name, flags))
|
||||
return true;
|
||||
#ifdef __WXMAC__
|
||||
if (!name.EndsWith(wxT(".dylib"))) {
|
||||
wxString dlib(name);
|
||||
dlib.Append(wxT(".dylib"));
|
||||
myLogTrace(MYTRACETAG, wxT("Trying to load(%s, 0x%0x)"), VMB(dlib), flags|wxDL_VERBATIM);
|
||||
if (wxDynamicLibrary::Load(dlib, flags|wxDL_VERBATIM))
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
myLogTrace(MYTRACETAG, wxT("Failed to load %s"), VMB(name));
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
40
MyDynlib.h
Normal file
40
MyDynlib.h
Normal file
@@ -0,0 +1,40 @@
|
||||
// $Id: MyDynlib.h 222 2009-04-17 12:06:07Z felfert $
|
||||
//
|
||||
// Copyright (C) 2009 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _MYDYNLIB_H_
|
||||
#define _MYDYNLIB_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
||||
#pragma interface "MyDynlib.h"
|
||||
#endif
|
||||
|
||||
#include <wx/dynlib.h>
|
||||
|
||||
class MyDynamicLibrary : public wxDynamicLibrary
|
||||
{
|
||||
public:
|
||||
MyDynamicLibrary() : wxDynamicLibrary() {}
|
||||
MyDynamicLibrary(const wxString& name, int flags = wxDL_DEFAULT) : wxDynamicLibrary() { Load(name, flags); }
|
||||
bool Load(const wxString& name, int flags = wxDL_DEFAULT);
|
||||
};
|
||||
|
||||
#endif
|
||||
// _MYDYNLIB_H_
|
||||
762
MyIPC.cpp
Normal file
762
MyIPC.cpp
Normal file
@@ -0,0 +1,762 @@
|
||||
// $Id: MyIPC.cpp 700 2012-02-22 11:56:52Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma implementation "MyIPC.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#include <wx/process.h>
|
||||
#include <wx/txtstrm.h>
|
||||
#include <wx/filename.h>
|
||||
#include <wx/regex.h>
|
||||
|
||||
#include "MyIPC.h"
|
||||
#include "AsyncProcess.h"
|
||||
|
||||
#include "trace.h"
|
||||
ENABLE_TRACE;
|
||||
|
||||
DEFINE_LOCAL_EVENT_TYPE(wxEVT_NXSSH);
|
||||
DEFINE_LOCAL_EVENT_TYPE(wxEVT_NXSERVICE);
|
||||
DEFINE_LOCAL_EVENT_TYPE(wxEVT_GENERIC);
|
||||
|
||||
IMPLEMENT_CLASS(MyIPC, wxEvtHandler);
|
||||
|
||||
BEGIN_EVENT_TABLE(MyIPC, wxEvtHandler)
|
||||
EVT_COMMAND(wxID_ANY, wxEVT_PROCESS_STDOUT, MyIPC::OnOutReceived )
|
||||
EVT_COMMAND(wxID_ANY, wxEVT_PROCESS_STDERR, MyIPC::OnErrReceived )
|
||||
EVT_COMMAND(wxID_ANY, wxEVT_PROCESS_EXIT, MyIPC::OnTerminate )
|
||||
END_EVENT_TABLE();
|
||||
|
||||
MyIPC::MyIPC()
|
||||
: m_pProcess(NULL)
|
||||
, m_pEvtHandler(NULL)
|
||||
, m_cEvhMutex()
|
||||
, m_eType(TypeNone)
|
||||
, m_iOutCollect(0)
|
||||
, m_iErrCollect(0)
|
||||
, m_nLines618(0)
|
||||
, m_sOutMessage(wxEmptyString)
|
||||
, m_sErrMessage(wxEmptyString)
|
||||
{
|
||||
#ifdef __WXMSW__
|
||||
m_MsgSession = ::RegisterWindowMessage(wxT("NX_SESSION_MESSAGE"));
|
||||
m_MsgKill = ::RegisterWindowMessage(wxT("NxKill"));
|
||||
#endif
|
||||
m_re = new wxRegEx();
|
||||
m_re->Compile(wxT("\\(yes/no\\)\\?"), wxRE_ADVANCED|wxRE_ICASE);
|
||||
}
|
||||
|
||||
MyIPC::~MyIPC()
|
||||
{
|
||||
myLogTrace(MYTRACETAG, wxT("~MyIPC() called"));
|
||||
Detach();
|
||||
delete m_re;
|
||||
}
|
||||
|
||||
void
|
||||
MyIPC::Detach()
|
||||
{
|
||||
myLogTrace(MYTRACETAG, wxT("Detach() called"));
|
||||
m_cEvhMutex.Lock();
|
||||
m_pEvtHandler = NULL;
|
||||
m_cEvhMutex.Unlock();
|
||||
if (m_pProcess) {
|
||||
if (m_pProcess->IsRunning())
|
||||
m_pProcess->Detach();
|
||||
else
|
||||
delete m_pProcess;
|
||||
m_pProcess = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MyIPC::sendUpEvent(wxCommandEvent &event)
|
||||
{
|
||||
wxMutexLocker lock(m_cEvhMutex);
|
||||
if (lock.IsOk() && (NULL != m_pEvtHandler)) {
|
||||
m_pEvtHandler->AddPendingEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
MyIPC::IsRunning()
|
||||
{
|
||||
return (m_pProcess && m_pProcess->IsRunning());
|
||||
}
|
||||
|
||||
int MyIPC::GetResult()
|
||||
{
|
||||
return m_pProcess ? m_pProcess->GetStatus() : -1;
|
||||
}
|
||||
|
||||
bool
|
||||
MyIPC::Kill()
|
||||
{
|
||||
bool ret (m_pProcess && m_pProcess->Kill());
|
||||
m_pProcess = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
MyIPC::Print(const wxString &s, bool doLog /* = true */ )
|
||||
{
|
||||
if (m_pProcess)
|
||||
m_pProcess->Print(s, doLog);
|
||||
}
|
||||
|
||||
bool
|
||||
MyIPC::GenericProcess(const wxString &cmd, const wxString &dir, wxEvtHandler *h)
|
||||
{
|
||||
m_eType = TypeNone;
|
||||
bool ret = false;
|
||||
m_iOutCollect = 0;
|
||||
m_iErrCollect = 0;
|
||||
m_sOutMessage.Empty();
|
||||
m_sErrMessage.Empty();
|
||||
m_pEvtHandler = h;
|
||||
m_pProcess = new AsyncProcess(cmd, dir, this);
|
||||
ret = m_pProcess->Start();
|
||||
if (!ret) {
|
||||
delete m_pProcess;
|
||||
m_pProcess = NULL;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool
|
||||
MyIPC::SshProcess(const wxString &cmd, const wxString &dir, wxEvtHandler *h)
|
||||
{
|
||||
m_eType = TypeSsh;
|
||||
bool ret = false;
|
||||
m_iOutCollect = 0;
|
||||
m_iErrCollect = 0;
|
||||
m_sOutMessage.Empty();
|
||||
m_sErrMessage.Empty();
|
||||
m_pEvtHandler = h;
|
||||
m_pProcess = new AsyncProcess(cmd, dir, wxT("NX> 105 "), this);
|
||||
ret = m_pProcess->Start();
|
||||
if (!ret) {
|
||||
delete m_pProcess;
|
||||
m_pProcess = NULL;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
MyIPC::parseCode(const wxString &buf)
|
||||
{
|
||||
int ret = -1;
|
||||
long n;
|
||||
if (buf.Find(wxT("NX> ")) == 0) {
|
||||
int idx = 0;
|
||||
while (buf.Mid(4+idx, 1).IsNumber()) {
|
||||
if (ret == -1)
|
||||
ret = 0;
|
||||
buf.Mid(4+idx, 1).ToLong(&n);
|
||||
ret *= 10;
|
||||
ret += n;
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
MyIPC::OnTerminate(wxCommandEvent &event)
|
||||
{
|
||||
switch (m_eType) {
|
||||
case TypeNone:
|
||||
myLogTrace(MYTRACETAG, wxT("process terminated"));
|
||||
if (m_pEvtHandler) {
|
||||
wxCommandEvent upevent(wxEVT_GENERIC, wxID_ANY);
|
||||
upevent.SetInt(ActionTerminated);
|
||||
sendUpEvent(upevent);
|
||||
}
|
||||
break;
|
||||
case TypeSsh:
|
||||
myLogTrace(MYTRACETAG, wxT("nxssh terminated"));
|
||||
if (m_pEvtHandler) {
|
||||
wxCommandEvent upevent(wxEVT_NXSSH, wxID_ANY);
|
||||
upevent.SetInt(ActionTerminated);
|
||||
sendUpEvent(upevent);
|
||||
}
|
||||
break;
|
||||
}
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void
|
||||
MyIPC::OnOutReceived(wxCommandEvent &event)
|
||||
{
|
||||
wxString msg;
|
||||
int code;
|
||||
|
||||
switch (m_eType) {
|
||||
case TypeNone:
|
||||
myLogTrace(MYTRACETAG, wxT("process O: '%s'"), VMB(msg));
|
||||
if (m_pEvtHandler) {
|
||||
wxCommandEvent upevent(wxEVT_GENERIC, wxID_ANY);
|
||||
upevent.SetInt(ActionStdout);
|
||||
upevent.SetString(event.GetString());
|
||||
sendUpEvent(upevent);
|
||||
}
|
||||
break;
|
||||
case TypeSsh:
|
||||
msg = event.GetString();
|
||||
// Normalize "FREENX>" -> "NX>"
|
||||
if (msg.StartsWith(wxT("FREENX>")))
|
||||
msg = msg.Mid(4);
|
||||
code = parseCode(msg);
|
||||
myLogTrace(MYTRACETAG, wxT("nxssh O[%04d]: '%s'"), code, VMB(msg));
|
||||
if (m_pEvtHandler) {
|
||||
wxCommandEvent upevent(wxEVT_NXSSH, wxID_ANY);
|
||||
upevent.SetInt(ActionLog);
|
||||
upevent.SetString(msg);
|
||||
sendUpEvent(upevent);
|
||||
switch (code) {
|
||||
case -1:
|
||||
// No code found
|
||||
if (m_iOutCollect) {
|
||||
m_iOutCollect--;
|
||||
m_sOutMessage << wxT("\n") << msg;
|
||||
if (m_iOutCollect == 0) {
|
||||
m_re->Replace(&m_sOutMessage, wxEmptyString);
|
||||
upevent.SetString(m_sOutMessage + wxT("?"));
|
||||
upevent.SetInt(ActionPromptYesNo);
|
||||
sendUpEvent(upevent);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (msg.StartsWith(wxT("HELLO NXSERVER - Version "))) {
|
||||
upevent.SetString(msg.Mid(25).BeforeFirst(wxT(' ')).Strip(wxString::both));
|
||||
upevent.SetInt(ActionHello);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
}
|
||||
if (msg.StartsWith(wxT("Warning: the RSA host key"))) {
|
||||
m_sOutMessage = msg;
|
||||
m_iOutCollect = 4;
|
||||
break;
|
||||
}
|
||||
if (msg.StartsWith(wxT("Enter PIN for"))) {
|
||||
// Generated by scard-opensc
|
||||
upevent.SetInt(ActionPinDialog);
|
||||
sendUpEvent(upevent);
|
||||
}
|
||||
break;
|
||||
case 100:
|
||||
// Server version & licence
|
||||
upevent.SetString(msg.Mid(8));
|
||||
upevent.SetInt(ActionStatus);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 101:
|
||||
// request username
|
||||
upevent.SetInt(ActionSendUsername);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 102:
|
||||
// request password
|
||||
upevent.SetInt(ActionSendPassword);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 103:
|
||||
// Welcome message
|
||||
upevent.SetInt(ActionWelcome);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 104:
|
||||
// NX4 resource list
|
||||
upevent.SetInt(ActionResList);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 105:
|
||||
// request for next command
|
||||
upevent.SetInt(ActionNextCommand);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 106:
|
||||
// Result: server parameters
|
||||
case 110:
|
||||
// Result: server status (running|stopped)
|
||||
case 113:
|
||||
// Announce: changing password
|
||||
case 114:
|
||||
// Announce: password changed
|
||||
case 122:
|
||||
// Result: service started
|
||||
case 123:
|
||||
// Result: service stopped
|
||||
break;
|
||||
case 127:
|
||||
// Result: session list
|
||||
upevent.SetInt(ActionSessionListStart);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 134:
|
||||
// NX> 134 Accepted protocol: <version>
|
||||
break;
|
||||
case 140:
|
||||
// Set length for push session config
|
||||
upevent.SetString(msg.Mid(8));
|
||||
upevent.SetInt(ActionSessionPushLength);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 141:
|
||||
// Push session config
|
||||
upevent.SetInt(ActionSessionPushStart);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 146:
|
||||
// Result: user list
|
||||
break;
|
||||
case 147:
|
||||
// Result: server capacity reached
|
||||
case 148:
|
||||
// Result: server capacity not reached
|
||||
upevent.SetInt(ActionSessionListEnd);
|
||||
upevent.SetExtraLong(code);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
// Codes 200 - 299 are from local nxssh
|
||||
case 200:
|
||||
// Connected to adress ...
|
||||
break;
|
||||
#ifdef OBSOLETE_CODE
|
||||
// Apparently gone
|
||||
case 201:
|
||||
ret = wxT("NX Server not installed or the server access has been disabled");
|
||||
return ActionError;
|
||||
#endif
|
||||
case 202:
|
||||
// Authenticating user ...
|
||||
upevent.SetString(msg.Mid(8));
|
||||
upevent.SetInt(ActionStatus);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 203:
|
||||
// NXSSH started with pid: ...
|
||||
msg = msg.AfterFirst(wxT(':')).Strip(wxString::both);
|
||||
if (msg.IsNumber()) {
|
||||
long n;
|
||||
msg.ToLong(&n);
|
||||
m_iSshPid = n;
|
||||
}
|
||||
break;
|
||||
case 204:
|
||||
// Authentication failed
|
||||
upevent.SetString(_("Authentication failed"));
|
||||
upevent.SetInt(ActionError);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 205:
|
||||
// ?? generic
|
||||
m_iOutCollect = 2;
|
||||
m_sOutMessage = msg.Mid(8);
|
||||
break;
|
||||
case 208:
|
||||
// Using auth method: ...
|
||||
break;
|
||||
case 209:
|
||||
// Remote host authentication has changed
|
||||
upevent.SetString(msg.Mid(8));
|
||||
upevent.SetInt(ActionWarning);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 210:
|
||||
// Enter passphrase for key ...
|
||||
upevent.SetString(msg.Mid(8));
|
||||
upevent.SetInt(ActionPassphraseDialog);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 211:
|
||||
// The authenticity of host ... can't be verified ... (multiline message)
|
||||
m_iOutCollect = 2;
|
||||
m_sOutMessage = msg.Mid(8);
|
||||
break;
|
||||
case 250:
|
||||
// NX4 request username or password
|
||||
if (msg.Find(wxT("login required")) != wxNOT_FOUND) {
|
||||
upevent.SetInt(ActionSendUsername);
|
||||
sendUpEvent(upevent);
|
||||
}
|
||||
if (msg.Find(wxT("password required")) != wxNOT_FOUND) {
|
||||
upevent.SetInt(ActionSendPassword);
|
||||
sendUpEvent(upevent);
|
||||
}
|
||||
break;
|
||||
case 280:
|
||||
case 282:
|
||||
case 285:
|
||||
case 286:
|
||||
break;
|
||||
case 287:
|
||||
// Successfully redirected ports
|
||||
upevent.SetInt(ActionSessionRunning);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 288:
|
||||
case 289:
|
||||
// Debug messages ?
|
||||
case 290:
|
||||
case 291:
|
||||
case 292:
|
||||
case 294:
|
||||
case 295:
|
||||
case 296:
|
||||
case 297:
|
||||
case 298:
|
||||
case 299:
|
||||
// Subchannel system ?
|
||||
break;
|
||||
#ifdef OBSOLETE_CODE
|
||||
// Apparently gone
|
||||
case 300:
|
||||
case 301:
|
||||
ret = wxT("Connection error");
|
||||
return -99;
|
||||
case 302:
|
||||
case 303:
|
||||
ret = wxT("Connection refused");
|
||||
return -99;
|
||||
case 304:
|
||||
case 305:
|
||||
ret = wxT("Host not found");
|
||||
return -99;
|
||||
case 306:
|
||||
ret = wxT("Network unreachable");
|
||||
return -99;
|
||||
case 307:
|
||||
case 310:
|
||||
ret = wxT("Host key verification failed");
|
||||
return -99;
|
||||
#endif
|
||||
case 404:
|
||||
// Error: wrong password or login
|
||||
case 500:
|
||||
// Generic error
|
||||
upevent.SetString(m_s595msg + msg.Mid(8));
|
||||
m_s595msg.Empty();
|
||||
upevent.SetInt(ActionError);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 595:
|
||||
// Fatal server error (usually multiline and
|
||||
// followed by a 500
|
||||
m_s595msg << msg.Mid(15) << wxT("\n");
|
||||
break;
|
||||
case 503:
|
||||
// Unknown command
|
||||
case 504:
|
||||
// Session startup failed
|
||||
case 536:
|
||||
// User limit exceeded
|
||||
case 537:
|
||||
// Passwords did not match
|
||||
case 542:
|
||||
// Max # of guest sessions reached
|
||||
case 596:
|
||||
// No running session, resp. Session startup failed
|
||||
case 598:
|
||||
// Unrecoverable exception
|
||||
case 599:
|
||||
// Reached the maximum number of concurrent sessions on this server.
|
||||
upevent.SetString(msg.Mid(8));
|
||||
upevent.SetInt(ActionError);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 618:
|
||||
// Evaluation license expired (commercial NoMachine server) - 3 lines
|
||||
if (3 > ++m_nLines618) {
|
||||
m_s618msg.Append(msg.Mid(8)).Append(wxT("\n"));
|
||||
} else {
|
||||
m_nLines618 = 0;
|
||||
m_s618msg.Append(msg.Mid(8));
|
||||
upevent.SetString(m_s618msg);
|
||||
upevent.SetInt(ActionError);
|
||||
sendUpEvent(upevent);
|
||||
}
|
||||
break;
|
||||
case 700:
|
||||
// Session ID
|
||||
upevent.SetString(msg.AfterFirst(wxT(':')).Strip(wxString::both));
|
||||
upevent.SetInt(ActionSetSessionID);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 701:
|
||||
// Session proxy cookie
|
||||
upevent.SetString(msg.AfterFirst(wxT(':')).Strip(wxString::both));
|
||||
upevent.SetInt(ActionSetProxyCookie);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 702:
|
||||
// Session proxy IP
|
||||
upevent.SetString(msg.AfterFirst(wxT(':')).Strip(wxString::both));
|
||||
upevent.SetInt(ActionSetProxyIP);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 703:
|
||||
// Session type
|
||||
upevent.SetString(msg.AfterFirst(wxT(':')).Strip(wxString::both));
|
||||
upevent.SetInt(ActionSetSessionType);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 704:
|
||||
// Session cache
|
||||
upevent.SetString(msg.AfterFirst(wxT(':')).Strip(wxString::both));
|
||||
upevent.SetInt(ActionSetSessionCache);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 705:
|
||||
// Session display
|
||||
upevent.SetString(msg.AfterFirst(wxT(':')).Strip(wxString::both));
|
||||
upevent.SetInt(ActionSetSessionDisplay);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 706:
|
||||
// Session agent cookie
|
||||
upevent.SetString(msg.AfterFirst(wxT(':')).Strip(wxString::both));
|
||||
upevent.SetInt(ActionSetAgentCookie);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 707:
|
||||
// Session ssl tunneling
|
||||
upevent.SetString(msg.AfterFirst(wxT(':')).Strip(wxString::both));
|
||||
upevent.SetInt(ActionSetSslTunneling);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 708:
|
||||
// Subscription
|
||||
upevent.SetString(msg.AfterFirst(wxT(':')).Strip(wxString::both));
|
||||
upevent.SetInt(ActionSetSubscription);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 709:
|
||||
// SMB Port
|
||||
upevent.SetString(msg.AfterFirst(wxT(':')).Strip(wxString::both));
|
||||
upevent.SetInt(ActionSetSmbPort);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 710:
|
||||
// session running
|
||||
upevent.SetInt(ActionStartProxy);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 716:
|
||||
// terminationg session on user request
|
||||
case 718:
|
||||
// session restore successful
|
||||
break;
|
||||
case 719:
|
||||
// SMB filesystem: running
|
||||
/* Workaround for newer nxnodes (since 3.2.0?):
|
||||
* On those, the message "NX> 709 Filesharing Port: nnn" is missing.
|
||||
* Therefore, we now use message 719 and hardcode the port
|
||||
* to SMBFS (139) if running on Windows and CIFS (445) otherwise.
|
||||
*/
|
||||
#ifdef __WXMSW__
|
||||
upevent.SetString(wxT("139"));
|
||||
#else
|
||||
upevent.SetString(wxT("445"));
|
||||
#endif
|
||||
upevent.SetInt(ActionSetSmbPort);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 720:
|
||||
// CUPS printer: running
|
||||
upevent.SetString(msg.Mid(8));
|
||||
upevent.SetInt(ActionStatus);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 725:
|
||||
// Shadow: Geometry 1024x768x24
|
||||
upevent.SetString(msg.Mid(25).Strip(wxString::both));
|
||||
upevent.SetInt(ActionSetShadowGeometry);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 726:
|
||||
// Asking user for authorization to attach to session
|
||||
upevent.SetString(msg.Mid(8));
|
||||
upevent.SetInt(ActionStatus);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 728:
|
||||
// Session caption: NX - felfert@nx3-test.id-testlab.str.topalis:1008 - nx3-test
|
||||
upevent.SetString(msg.Mid(8));
|
||||
upevent.SetInt(ActionStatus);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 900:
|
||||
// Terminating session
|
||||
case 1000:
|
||||
// nxnode version
|
||||
case 1001:
|
||||
// Bye
|
||||
case 1002:
|
||||
// Commit
|
||||
break;
|
||||
case 1004:
|
||||
// Session status: failed
|
||||
upevent.SetString(msg.Mid(8));
|
||||
upevent.SetInt(ActionError);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 1005:
|
||||
// Session status: suspended
|
||||
case 1006:
|
||||
// Session status: running|closed
|
||||
case 1009:
|
||||
// Session status: terminating
|
||||
break;
|
||||
case 999:
|
||||
// Terminating
|
||||
upevent.SetInt(ActionExit);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void
|
||||
MyIPC::OnErrReceived(wxCommandEvent &event)
|
||||
{
|
||||
wxString msg = event.GetString();
|
||||
int code;
|
||||
|
||||
switch (m_eType) {
|
||||
case TypeNone:
|
||||
myLogTrace(MYTRACETAG, wxT("process E: '%s'"), VMB(msg));
|
||||
if (m_pEvtHandler) {
|
||||
wxCommandEvent upevent(wxEVT_GENERIC, wxID_ANY);
|
||||
upevent.SetInt(ActionStderr);
|
||||
upevent.SetString(event.GetString());
|
||||
sendUpEvent(upevent);
|
||||
}
|
||||
break;
|
||||
case TypeSsh:
|
||||
code = parseCode(msg);
|
||||
myLogTrace(MYTRACETAG, wxT("nxssh E[%04d]: '%s'"), code, VMB(msg));
|
||||
if (m_pEvtHandler) {
|
||||
wxCommandEvent upevent(wxEVT_NXSSH, wxID_ANY);
|
||||
upevent.SetInt(ActionLog);
|
||||
upevent.SetString(event.GetString());
|
||||
sendUpEvent(upevent);
|
||||
switch (code) {
|
||||
case -1:
|
||||
// No code found
|
||||
if (m_iErrCollect) {
|
||||
m_iErrCollect--;
|
||||
m_sErrMessage << wxT("\n") << msg;
|
||||
if (m_iErrCollect == 0) {
|
||||
upevent.SetString(m_sErrMessage);
|
||||
upevent.SetInt(ActionError);
|
||||
sendUpEvent(upevent);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (msg.StartsWith(wxT("Offending key in "))) {
|
||||
upevent.SetString(msg.Mid(17));
|
||||
upevent.SetInt(ActionOffendingKey);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
}
|
||||
if (msg.Contains(wxT("WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!"))) {
|
||||
m_sErrMessage = msg.AfterFirst(wxT('@')).BeforeLast(wxT('@')).Strip(wxString::both);
|
||||
m_iErrCollect = 99;
|
||||
break;
|
||||
}
|
||||
if (msg.Contains(wxT("usage:"))) {
|
||||
m_sErrMessage = msg;
|
||||
m_iErrCollect = 6;
|
||||
break;
|
||||
}
|
||||
if (msg.Contains(wxT("Connection refused")) ||
|
||||
msg.Contains(wxT("onnection closed")) ||
|
||||
msg.Contains(wxT("no address associated")) ||
|
||||
msg.Contains(wxT("failed with error")) ||
|
||||
msg.Contains(wxT("Smartcard init failed")) ||
|
||||
msg.Contains(wxT("PIN code verification failed")) ||
|
||||
msg.Contains(wxT("No certificates found on smartcard")) ||
|
||||
msg.Contains(wxT("proxy error:"))
|
||||
) {
|
||||
upevent.SetString(msg);
|
||||
upevent.SetInt(ActionError);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
}
|
||||
if (msg.Contains(wxT("Warning:"))) {
|
||||
upevent.SetString(msg.Mid(8));
|
||||
upevent.SetInt(ActionWarning);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 209:
|
||||
// Remote host identification changed
|
||||
m_iErrCollect = 0;
|
||||
m_sErrMessage.Replace(wxT("@"), wxEmptyString);
|
||||
m_sErrMessage.Remove(m_sErrMessage.Find(wxT("Please contact")));
|
||||
upevent.SetString(m_sErrMessage);
|
||||
upevent.SetInt(ActionKeyChangedYesNo);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 287:
|
||||
// Successfully redirected ports
|
||||
upevent.SetInt(ActionSessionRunning);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
case 999:
|
||||
upevent.SetInt(ActionExit);
|
||||
sendUpEvent(upevent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
long MyIPC::GetPID()
|
||||
{
|
||||
if (m_pProcess && (m_pProcess->IsRunning()))
|
||||
return m_pProcess->GetPid();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// vim:cindent:expandtab:shiftwidth=4
|
||||
127
MyIPC.h
Normal file
127
MyIPC.h
Normal file
@@ -0,0 +1,127 @@
|
||||
// $Id: MyIPC.h 700 2012-02-22 11:56:52Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _MYIPC_H_
|
||||
#define _MYIPC_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "MyIPC.cpp"
|
||||
#endif
|
||||
|
||||
#include <wx/event.h>
|
||||
|
||||
DECLARE_LOCAL_EVENT_TYPE(wxEVT_NXSSH, -1);
|
||||
DECLARE_LOCAL_EVENT_TYPE(wxEVT_GENERIC, -2);
|
||||
|
||||
class AsyncProcess;
|
||||
class wxRegEx;
|
||||
|
||||
class MyIPC : public wxEvtHandler
|
||||
{
|
||||
DECLARE_CLASS(MyIPC);
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
public:
|
||||
typedef enum {
|
||||
ActionNone,
|
||||
ActionStatus,
|
||||
ActionHello,
|
||||
ActionLog,
|
||||
ActionWarning,
|
||||
ActionError,
|
||||
ActionPromptYesNo,
|
||||
ActionKeyChangedYesNo,
|
||||
ActionOffendingKey,
|
||||
ActionSendUsername,
|
||||
ActionSendPassword,
|
||||
ActionNextCommand,
|
||||
ActionWelcome,
|
||||
ActionPassphraseDialog,
|
||||
ActionPinDialog,
|
||||
ActionSetSessionID,
|
||||
ActionSetProxyCookie,
|
||||
ActionSetProxyIP,
|
||||
ActionSetSessionType,
|
||||
ActionSetSessionCache,
|
||||
ActionSetSessionDisplay,
|
||||
ActionSetAgentCookie,
|
||||
ActionSetSslTunneling,
|
||||
ActionSetSubscription,
|
||||
ActionSetSmbPort,
|
||||
ActionSetShadowGeometry,
|
||||
ActionExit,
|
||||
ActionStartProxy,
|
||||
ActionSessionRunning,
|
||||
ActionSessionListStart,
|
||||
ActionSessionListEnd,
|
||||
ActionSessionPushLength,
|
||||
ActionSessionPushStart,
|
||||
ActionResList,
|
||||
ActionTerminated,
|
||||
ActionStdout,
|
||||
ActionStderr,
|
||||
} tSessionEvents;
|
||||
|
||||
MyIPC();
|
||||
virtual ~MyIPC();
|
||||
bool GenericProcess(const wxString&, const wxString&, wxEvtHandler *);
|
||||
bool SshProcess(const wxString&, const wxString&, wxEvtHandler *);
|
||||
bool IsRunning();
|
||||
bool Kill();
|
||||
void Print(const wxString &s, bool doLog = true);
|
||||
int GetResult();
|
||||
long GetPID();
|
||||
void Detach();
|
||||
|
||||
private:
|
||||
typedef enum {
|
||||
TypeNone,
|
||||
TypeSsh,
|
||||
} ProcessType;
|
||||
|
||||
int parseCode(const wxString &);
|
||||
virtual void OnOutReceived(wxCommandEvent &);
|
||||
virtual void OnErrReceived(wxCommandEvent &);
|
||||
virtual void OnTerminate(wxCommandEvent &);
|
||||
|
||||
void sendUpEvent(wxCommandEvent &event);
|
||||
|
||||
#ifdef __WXMSW__
|
||||
unsigned int m_MsgSession;
|
||||
unsigned int m_MsgKill;
|
||||
#endif
|
||||
AsyncProcess *m_pProcess;
|
||||
wxEvtHandler *m_pEvtHandler;
|
||||
wxMutex m_cEvhMutex;
|
||||
wxRegEx *m_re;
|
||||
ProcessType m_eType;
|
||||
int m_iSshPid;
|
||||
int m_iOutCollect;
|
||||
int m_iErrCollect;
|
||||
int m_nLines618;;
|
||||
wxString m_sOutMessage;
|
||||
wxString m_sErrMessage;
|
||||
wxString m_s595msg;
|
||||
wxString m_s618msg;
|
||||
};
|
||||
|
||||
#endif
|
||||
// _MYIPC_
|
||||
2396
MySession.cpp
Normal file
2396
MySession.cpp
Normal file
File diff suppressed because it is too large
Load Diff
207
MySession.h
Normal file
207
MySession.h
Normal file
@@ -0,0 +1,207 @@
|
||||
// $Id: MySession.h 704 2012-03-14 14:55:15Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _MYSESSION_H_
|
||||
#define _MYSESSION_H_
|
||||
|
||||
#include <wx/regex.h>
|
||||
|
||||
#include "MyXmlConfig.h"
|
||||
|
||||
class ConnectDialog;
|
||||
class MyIPC;
|
||||
class SessionWatch;
|
||||
class MyXmlConfig;
|
||||
|
||||
class MySession : public wxEvtHandler
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(MySession);
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
public:
|
||||
typedef enum {
|
||||
None,
|
||||
Client,
|
||||
Server,
|
||||
} tSessionType;
|
||||
|
||||
typedef enum {
|
||||
Unknown,
|
||||
Failed,
|
||||
Terminated,
|
||||
Running,
|
||||
} tSessionStatus;
|
||||
|
||||
typedef enum {
|
||||
XARCH_NONE,
|
||||
XARCH_CYGWIN,
|
||||
XARCH_XMING,
|
||||
} tXarch;
|
||||
|
||||
MySession();
|
||||
MySession(wxString dir, wxString status, wxString stype, wxString host, int port, wxString md5);
|
||||
MySession(const MySession &src);
|
||||
virtual ~MySession();
|
||||
|
||||
// session admin
|
||||
wxString sGetCreationTime();
|
||||
wxString sGetPID() { return wxString::Format(_T("%d"), (int)m_lPid); }
|
||||
wxString sGetPort() { return wxString::Format(_T("%d"), (int)m_iPort); }
|
||||
const wxString& sGetHost() { return m_sHost; }
|
||||
const wxString& sGetMd5() { return m_sMd5; }
|
||||
const wxString& sGetDir() { return m_sDir; }
|
||||
tSessionStatus eGetSessionStatus() { return m_eSessionStatus; }
|
||||
tSessionType eGetSessionType() { return m_eSessionType; }
|
||||
wxString sGetSessionStatus();
|
||||
wxString sGetSessionType();
|
||||
void bSetTouched(bool b) { m_bTouched = b; }
|
||||
bool bGetTouched() { return m_bTouched; }
|
||||
long lGetPID() { return m_lPid; }
|
||||
bool bGetPidFromFile();
|
||||
void CheckState();
|
||||
bool IsValid() { return m_bValid; }
|
||||
MySession &operator =(const MySession &src);
|
||||
|
||||
// connection setup
|
||||
bool Create(MyXmlConfig& cfg, const wxString password, wxWindow *parent = NULL);
|
||||
|
||||
private:
|
||||
// locals for connection setup
|
||||
typedef enum {
|
||||
STATE_INIT,
|
||||
STATE_HELLO,
|
||||
STATE_SHELLMODE,
|
||||
STATE_AUTHMODE,
|
||||
STATE_LOGIN,
|
||||
STATE_LIST_SESSIONS,
|
||||
STATE_PARSE_SESSIONS,
|
||||
STATE_LIST_RESOURCES,
|
||||
STATE_PARSE_RESOURCES,
|
||||
STATE_START_SESSION,
|
||||
STATE_ATTACH_SESSION,
|
||||
STATE_ATTACH_VIEW_SESSION,
|
||||
STATE_RESUME_SESSION,
|
||||
STATE_KILL_SESSION,
|
||||
STATE_ABORT,
|
||||
STATE_FINISH,
|
||||
STATE_WAIT,
|
||||
} tConnectState;
|
||||
|
||||
wxArrayString m_aParseBuffer;
|
||||
wxString getXauthCookie(int display = 0, wxString = wxT("/unix"));
|
||||
wxString getXauthPath(tXarch = XARCH_XMING);
|
||||
wxString formatOptFilename();
|
||||
unsigned short getFirstFreePort(unsigned short);
|
||||
void setTurboPath(bool enable);
|
||||
void checkXarch();
|
||||
void startProxy();
|
||||
void startSharing();
|
||||
void parseSessions(bool moreAllowed);
|
||||
void parseResources();
|
||||
void initversion(const wxString &s = wxEmptyString);
|
||||
bool isCupsRunning();
|
||||
void printSsh(const wxString &s, bool doLog = true, const wxString &reason = wxT(""));
|
||||
void cleanupOldSessions();
|
||||
void clearSshKeys(const wxString &);
|
||||
ArrayOfShareGroups getActiveCupsPrinters();
|
||||
virtual void OnSshEvent(wxCommandEvent &);
|
||||
virtual void OnSessionEvent(wxCommandEvent &);
|
||||
void SshLog(const wxChar *fmt, ...);
|
||||
|
||||
#ifdef __WXMSW__
|
||||
wxString getXfontPath(tXarch);
|
||||
bool startXserver();
|
||||
void unhideNXWin();
|
||||
void terminateXserver();
|
||||
#endif
|
||||
|
||||
tConnectState m_eConnectState;
|
||||
tXarch m_eXarch;
|
||||
bool m_bGotError;
|
||||
bool m_bAbort;
|
||||
bool m_bSslTunneling;
|
||||
bool m_bSessionRunning;
|
||||
bool m_bEsdRunning;
|
||||
bool m_bNativePARunning;
|
||||
bool m_bSessionEstablished;
|
||||
bool m_bCollectSessions;
|
||||
bool m_bCollectConfig;
|
||||
bool m_bCollectResources;
|
||||
bool m_bIsShadow;
|
||||
bool m_bInParseSessions;
|
||||
bool m_bCupsRunning;
|
||||
bool m_bRemoveKey;
|
||||
bool m_bNextCmd;
|
||||
int m_iProgress;
|
||||
int m_iReader;
|
||||
int m_iHttpPort;
|
||||
int m_iXserverPID;
|
||||
long m_lEsdPort;
|
||||
long m_lProtocolVersion;
|
||||
long m_lSrvProtocolVersion;
|
||||
unsigned long m_nSessionPushLength;
|
||||
wxLog *m_pSshLog;
|
||||
MyIPC *m_pNxSsh;
|
||||
MyXmlConfig *m_pCfg;
|
||||
ConnectDialog *m_pDlg;
|
||||
wxString m_sConfigBuffer;
|
||||
wxString m_sClearPassword;
|
||||
wxString m_sSessionID;
|
||||
wxString m_sSessionType;
|
||||
wxString m_sSessionCache;
|
||||
wxString m_sSessionDisplay;
|
||||
wxString m_sProxyCookie;
|
||||
wxString m_sProxyIP;
|
||||
wxString m_sProxyPort;
|
||||
wxString m_sSmbPort;
|
||||
wxString m_sSubscription;
|
||||
wxString m_sAgentCookie;
|
||||
wxString m_sOptFilename;
|
||||
wxString m_sOffendingKey;
|
||||
wxString m_sSessionDir;
|
||||
wxString m_sUserDir;
|
||||
wxString m_sSysDir;
|
||||
wxString m_sXauthCookie;
|
||||
wxString m_sResumeName;
|
||||
wxString m_sResumeType;
|
||||
wxString m_sResumeId;
|
||||
wxString m_sResumePort;
|
||||
wxString m_sKillId;
|
||||
wxString m_sTempDir;
|
||||
wxString m_sProtocolVersion;
|
||||
wxString m_sShadowGeometry;
|
||||
wxWindow *m_pParent;
|
||||
SessionWatch *m_pSessionWatch;
|
||||
|
||||
// locals for admin tool
|
||||
bool m_bTouched;
|
||||
bool m_bValid;
|
||||
int m_iPort;
|
||||
long m_lPid;
|
||||
tSessionType m_eSessionType;
|
||||
tSessionStatus m_eSessionStatus;
|
||||
wxString m_sHost;
|
||||
wxString m_sMd5;
|
||||
wxString m_sDir;
|
||||
wxRegEx m_rePID;
|
||||
};
|
||||
|
||||
#endif
|
||||
671
MyValidator.cpp
Normal file
671
MyValidator.cpp
Normal file
@@ -0,0 +1,671 @@
|
||||
// $Id: MyValidator.cpp 557 2010-09-03 18:18:04Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
||||
#pragma implementation "MyValidator.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/defs.h"
|
||||
#endif
|
||||
#include <wx/config.h>
|
||||
#include <wx/filename.h>
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/utils.h"
|
||||
#include "wx/intl.h"
|
||||
#include "wx/dynarray.h"
|
||||
#include "wx/choice.h"
|
||||
#include "wx/combobox.h"
|
||||
#include "wx/radiobox.h"
|
||||
#include "wx/radiobut.h"
|
||||
#include "wx/checkbox.h"
|
||||
#include "wx/scrolbar.h"
|
||||
#include "wx/gauge.h"
|
||||
#include "wx/stattext.h"
|
||||
#include "wx/textctrl.h"
|
||||
#include "wx/button.h"
|
||||
#include "wx/listbox.h"
|
||||
#include "wx/slider.h"
|
||||
#endif
|
||||
|
||||
#include "wx/spinctrl.h"
|
||||
|
||||
#if wxUSE_SPINBTN
|
||||
#include "wx/spinbutt.h"
|
||||
#endif
|
||||
#if wxUSE_CHECKLISTBOX
|
||||
#include "wx/checklst.h"
|
||||
#endif
|
||||
|
||||
#include "MyValidator.h"
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(MyValidator, wxValidator)
|
||||
|
||||
BEGIN_EVENT_TABLE(MyValidator, wxValidator)
|
||||
EVT_CHAR(MyValidator::OnChar)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
MyValidator::~MyValidator()
|
||||
{
|
||||
}
|
||||
|
||||
MyValidator::MyValidator(MyValidatorType t, const MyValidator &v)
|
||||
: wxValidator()
|
||||
, m_type(t)
|
||||
{
|
||||
Copy(v);
|
||||
}
|
||||
|
||||
MyValidator::MyValidator(MyValidatorType t, bool *val)
|
||||
: wxValidator()
|
||||
, m_type(t)
|
||||
{
|
||||
Init();
|
||||
m_pBool = val;
|
||||
}
|
||||
|
||||
MyValidator::MyValidator(MyValidatorType t, int *val)
|
||||
: wxValidator()
|
||||
, m_type(t)
|
||||
{
|
||||
Init();
|
||||
m_pInt = val;
|
||||
}
|
||||
|
||||
MyValidator::MyValidator(MyValidatorType t, wxString *val)
|
||||
: wxValidator()
|
||||
, m_type(t)
|
||||
{
|
||||
Init();
|
||||
m_pString = val;
|
||||
}
|
||||
|
||||
MyValidator::MyValidator(MyValidatorType t, wxArrayInt *val)
|
||||
: wxValidator()
|
||||
, m_type(t)
|
||||
{
|
||||
Init();
|
||||
m_pArrayInt = val;
|
||||
}
|
||||
|
||||
MyValidator::MyValidator(const MyValidator &v)
|
||||
: wxValidator()
|
||||
, m_type(v.m_type)
|
||||
{
|
||||
Copy(v);
|
||||
}
|
||||
|
||||
MyValidator::MyValidator(bool *val)
|
||||
: wxValidator()
|
||||
, m_type(MYVAL_ANY)
|
||||
{
|
||||
Init();
|
||||
m_pBool = val;
|
||||
}
|
||||
|
||||
MyValidator::MyValidator(int *val)
|
||||
: wxValidator()
|
||||
, m_type(MYVAL_ANY)
|
||||
{
|
||||
Init();
|
||||
m_pInt = val;
|
||||
}
|
||||
|
||||
MyValidator::MyValidator(wxString *val)
|
||||
: wxValidator()
|
||||
, m_type(MYVAL_ANY)
|
||||
{
|
||||
Init();
|
||||
m_pString = val;
|
||||
}
|
||||
|
||||
MyValidator::MyValidator(wxArrayInt *val)
|
||||
: wxValidator()
|
||||
, m_type(MYVAL_ANY)
|
||||
{
|
||||
Init();
|
||||
m_pArrayInt = val;
|
||||
}
|
||||
|
||||
void MyValidator::Init()
|
||||
{
|
||||
m_pBool = NULL;
|
||||
m_pInt = NULL;
|
||||
m_pString = NULL;
|
||||
m_pArrayInt = NULL;
|
||||
m_ktc = NULL;
|
||||
}
|
||||
|
||||
bool MyValidator::Copy(const MyValidator& v)
|
||||
{
|
||||
wxValidator::Copy(v);
|
||||
|
||||
m_pBool = v.m_pBool;
|
||||
m_pInt = v.m_pInt;
|
||||
m_pString = v.m_pString;
|
||||
m_pArrayInt = v.m_pArrayInt;
|
||||
m_ktc = v.m_ktc;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool MyValidator::TransferToWindow(void)
|
||||
{
|
||||
if ( !m_validatorWindow )
|
||||
return FALSE;
|
||||
|
||||
// bool controls
|
||||
#if wxUSE_CHECKBOX
|
||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxCheckBox)) )
|
||||
{
|
||||
wxCheckBox* pControl = (wxCheckBox*) m_validatorWindow;
|
||||
if (m_pBool)
|
||||
{
|
||||
pControl->SetValue(*m_pBool);
|
||||
return TRUE;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
#if wxUSE_RADIOBTN
|
||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxRadioButton)) )
|
||||
{
|
||||
wxRadioButton* pControl = (wxRadioButton*) m_validatorWindow;
|
||||
if (m_pBool)
|
||||
{
|
||||
pControl->SetValue(*m_pBool) ;
|
||||
return TRUE;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
|
||||
// int controls
|
||||
#if wxUSE_GAUGE
|
||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxGauge)) )
|
||||
{
|
||||
wxGauge* pControl = (wxGauge*) m_validatorWindow;
|
||||
if (m_pInt)
|
||||
{
|
||||
pControl->SetValue(*m_pInt);
|
||||
return TRUE;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
#if wxUSE_RADIOBOX
|
||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxRadioBox)) )
|
||||
{
|
||||
wxRadioBox* pControl = (wxRadioBox*) m_validatorWindow;
|
||||
if (m_pInt)
|
||||
{
|
||||
pControl->SetSelection(*m_pInt) ;
|
||||
return TRUE;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
#if wxUSE_SCROLLBAR
|
||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxScrollBar)) )
|
||||
{
|
||||
wxScrollBar* pControl = (wxScrollBar*) m_validatorWindow;
|
||||
if (m_pInt)
|
||||
{
|
||||
pControl->SetThumbPosition(*m_pInt) ;
|
||||
return TRUE;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
#if wxUSE_SPINCTRL && !defined(__WXMOTIF__)
|
||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxSpinCtrl)) )
|
||||
{
|
||||
wxSpinCtrl* pControl = (wxSpinCtrl*) m_validatorWindow;
|
||||
if (m_pInt)
|
||||
{
|
||||
pControl->SetValue(*m_pInt);
|
||||
return TRUE;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
#if wxUSE_SPINBTN
|
||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxSpinButton)) )
|
||||
{
|
||||
wxSpinButton* pControl = (wxSpinButton*) m_validatorWindow;
|
||||
if (m_pInt)
|
||||
{
|
||||
pControl->SetValue(*m_pInt) ;
|
||||
return TRUE;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
#if wxUSE_SLIDER
|
||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxSlider)) )
|
||||
{
|
||||
wxSlider* pControl = (wxSlider*) m_validatorWindow;
|
||||
if (m_pInt)
|
||||
{
|
||||
pControl->SetValue(*m_pInt) ;
|
||||
return TRUE;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
|
||||
// string controls
|
||||
#if wxUSE_BUTTON
|
||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxButton)) )
|
||||
{
|
||||
wxButton* pControl = (wxButton*) m_validatorWindow;
|
||||
if (m_pString)
|
||||
{
|
||||
pControl->SetLabel(*m_pString) ;
|
||||
return TRUE;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
#if wxUSE_COMBOBOX
|
||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxComboBox)) )
|
||||
{
|
||||
wxComboBox* pControl = (wxComboBox*) m_validatorWindow;
|
||||
if (m_pInt)
|
||||
{
|
||||
pControl->SetSelection(*m_pInt) ;
|
||||
return TRUE;
|
||||
}
|
||||
else if (m_pString)
|
||||
{
|
||||
if (pControl->FindString(* m_pString) > -1)
|
||||
{
|
||||
pControl->SetStringSelection(* m_pString);
|
||||
}
|
||||
else
|
||||
{
|
||||
pControl->SetValue(* m_pString);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
#if wxUSE_CHOICE
|
||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxChoice)) )
|
||||
{
|
||||
wxChoice* pControl = (wxChoice*) m_validatorWindow;
|
||||
if (m_pInt)
|
||||
{
|
||||
pControl->SetSelection(*m_pInt) ;
|
||||
return TRUE;
|
||||
}
|
||||
else if (m_pString)
|
||||
{
|
||||
if (pControl->FindString(* m_pString) > -1)
|
||||
{
|
||||
pControl->SetStringSelection(* m_pString);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxStaticText)) )
|
||||
{
|
||||
wxStaticText* pControl = (wxStaticText*) m_validatorWindow;
|
||||
if (m_pString)
|
||||
{
|
||||
pControl->SetLabel(*m_pString) ;
|
||||
return TRUE;
|
||||
}
|
||||
} else
|
||||
#if wxUSE_TEXTCTRL
|
||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxTextCtrl)) )
|
||||
{
|
||||
wxTextCtrl* pControl = (wxTextCtrl*) m_validatorWindow;
|
||||
if (m_pString)
|
||||
{
|
||||
pControl->SetValue(*m_pString) ;
|
||||
return TRUE;
|
||||
}
|
||||
else if (m_pInt)
|
||||
{
|
||||
wxString str;
|
||||
str.Printf(((m_type == MYVAL_HEX) ? wxT("%X") : wxT("%d")), *m_pInt);
|
||||
pControl->SetValue(str);
|
||||
return TRUE;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
// array controls
|
||||
#if wxUSE_CHECKLISTBOX
|
||||
// NOTE: wxCheckListBox is a wxListBox, so wxCheckListBox MUST come first:
|
||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxCheckListBox)) )
|
||||
{
|
||||
wxCheckListBox* pControl = (wxCheckListBox*) m_validatorWindow;
|
||||
if (m_pArrayInt)
|
||||
{
|
||||
// clear all selections
|
||||
size_t i,
|
||||
count = pControl->GetCount();
|
||||
for ( i = 0 ; i < count; i++ )
|
||||
pControl->Check(i, FALSE);
|
||||
|
||||
// select each item in our array
|
||||
count = m_pArrayInt->GetCount();
|
||||
for ( i = 0 ; i < count; i++ )
|
||||
pControl->Check(m_pArrayInt->Item(i));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
} else
|
||||
#endif
|
||||
#if wxUSE_LISTBOX
|
||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxListBox)) )
|
||||
{
|
||||
wxListBox* pControl = (wxListBox*) m_validatorWindow;
|
||||
if (m_pArrayInt)
|
||||
{
|
||||
// clear all selections
|
||||
size_t i,
|
||||
count = pControl->GetCount();
|
||||
for ( i = 0 ; i < count; i++ )
|
||||
pControl->Deselect(i);
|
||||
|
||||
// select each item in our array
|
||||
count = m_pArrayInt->GetCount();
|
||||
for ( i = 0 ; i < count; i++ )
|
||||
pControl->SetSelection(m_pArrayInt->Item(i));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{ } // to match the last 'else' above
|
||||
|
||||
// unrecognized control, or bad pointer
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool MyValidator::TransferFromWindow(void)
|
||||
{
|
||||
if ( !m_validatorWindow )
|
||||
return FALSE;
|
||||
|
||||
// bool controls
|
||||
#if wxUSE_CHECKBOX
|
||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxCheckBox)) )
|
||||
{
|
||||
wxCheckBox* pControl = (wxCheckBox*) m_validatorWindow;
|
||||
if (m_pBool)
|
||||
{
|
||||
*m_pBool = pControl->GetValue() ;
|
||||
return TRUE;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
#if wxUSE_RADIOBTN
|
||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxRadioButton)) )
|
||||
{
|
||||
wxRadioButton* pControl = (wxRadioButton*) m_validatorWindow;
|
||||
if (m_pBool)
|
||||
{
|
||||
*m_pBool = pControl->GetValue() ;
|
||||
return TRUE;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
// int controls
|
||||
#if wxUSE_GAUGE
|
||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxGauge)) )
|
||||
{
|
||||
wxGauge* pControl = (wxGauge*) m_validatorWindow;
|
||||
if (m_pInt)
|
||||
{
|
||||
*m_pInt = pControl->GetValue() ;
|
||||
return TRUE;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
#if wxUSE_RADIOBOX
|
||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxRadioBox)) )
|
||||
{
|
||||
wxRadioBox* pControl = (wxRadioBox*) m_validatorWindow;
|
||||
if (m_pInt)
|
||||
{
|
||||
*m_pInt = pControl->GetSelection() ;
|
||||
return TRUE;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
#if wxUSE_SCROLLBAR
|
||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxScrollBar)) )
|
||||
{
|
||||
wxScrollBar* pControl = (wxScrollBar*) m_validatorWindow;
|
||||
if (m_pInt)
|
||||
{
|
||||
*m_pInt = pControl->GetThumbPosition() ;
|
||||
return TRUE;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
#if wxUSE_SPINCTRL && !defined(__WXMOTIF__)
|
||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxSpinCtrl)) )
|
||||
{
|
||||
wxSpinCtrl* pControl = (wxSpinCtrl*) m_validatorWindow;
|
||||
if (m_pInt)
|
||||
{
|
||||
*m_pInt=pControl->GetValue();
|
||||
return TRUE;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
#if wxUSE_SPINBTN
|
||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxSpinButton)) )
|
||||
{
|
||||
wxSpinButton* pControl = (wxSpinButton*) m_validatorWindow;
|
||||
if (m_pInt)
|
||||
{
|
||||
*m_pInt = pControl->GetValue() ;
|
||||
return TRUE;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
#if wxUSE_SLIDER
|
||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxSlider)) )
|
||||
{
|
||||
wxSlider* pControl = (wxSlider*) m_validatorWindow;
|
||||
if (m_pInt)
|
||||
{
|
||||
*m_pInt = pControl->GetValue() ;
|
||||
return TRUE;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
// string controls
|
||||
#if wxUSE_BUTTON
|
||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxButton)) )
|
||||
{
|
||||
wxButton* pControl = (wxButton*) m_validatorWindow;
|
||||
if (m_pString)
|
||||
{
|
||||
*m_pString = pControl->GetLabel() ;
|
||||
return TRUE;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
#if wxUSE_COMBOBOX
|
||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxComboBox)) )
|
||||
{
|
||||
wxComboBox* pControl = (wxComboBox*) m_validatorWindow;
|
||||
if (m_pInt)
|
||||
{
|
||||
*m_pInt = pControl->GetSelection() ;
|
||||
return TRUE;
|
||||
}
|
||||
else if (m_pString)
|
||||
{
|
||||
*m_pString = pControl->GetValue();
|
||||
return TRUE;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
#if wxUSE_CHOICE
|
||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxChoice)) )
|
||||
{
|
||||
wxChoice* pControl = (wxChoice*) m_validatorWindow;
|
||||
if (m_pInt)
|
||||
{
|
||||
*m_pInt = pControl->GetSelection() ;
|
||||
return TRUE;
|
||||
}
|
||||
else if (m_pString)
|
||||
{
|
||||
*m_pString = pControl->GetStringSelection();
|
||||
return TRUE;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxStaticText)) )
|
||||
{
|
||||
wxStaticText* pControl = (wxStaticText*) m_validatorWindow;
|
||||
if (m_pString)
|
||||
{
|
||||
*m_pString = pControl->GetLabel() ;
|
||||
return TRUE;
|
||||
}
|
||||
} else
|
||||
#if wxUSE_TEXTCTRL
|
||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxTextCtrl)) )
|
||||
{
|
||||
wxTextCtrl* pControl = (wxTextCtrl*) m_validatorWindow;
|
||||
if (m_pString)
|
||||
{
|
||||
*m_pString = pControl->GetValue() ;
|
||||
return TRUE;
|
||||
}
|
||||
else if (m_pInt)
|
||||
{
|
||||
*m_pInt = wxAtoi(pControl->GetValue());
|
||||
return TRUE;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
// array controls
|
||||
#if wxUSE_CHECKLISTBOX
|
||||
// NOTE: wxCheckListBox isa wxListBox, so wxCheckListBox MUST come first:
|
||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxCheckListBox)) )
|
||||
{
|
||||
wxCheckListBox* pControl = (wxCheckListBox*) m_validatorWindow;
|
||||
if (m_pArrayInt)
|
||||
{
|
||||
// clear our array
|
||||
m_pArrayInt->Clear();
|
||||
|
||||
// add each selected item to our array
|
||||
size_t i,
|
||||
count = pControl->GetCount();
|
||||
for ( i = 0; i < count; i++ )
|
||||
{
|
||||
if (pControl->IsChecked(i))
|
||||
m_pArrayInt->Add(i);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
} else
|
||||
#endif
|
||||
#if wxUSE_LISTBOX
|
||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxListBox)) )
|
||||
{
|
||||
wxListBox* pControl = (wxListBox*) m_validatorWindow;
|
||||
if (m_pArrayInt)
|
||||
{
|
||||
// clear our array
|
||||
m_pArrayInt->Clear();
|
||||
|
||||
// add each selected item to our array
|
||||
size_t i,
|
||||
count = pControl->GetCount();
|
||||
for ( i = 0; i < count; i++ )
|
||||
{
|
||||
if (pControl->IsSelected(i))
|
||||
m_pArrayInt->Add(i);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
|
||||
// unrecognized control, or bad pointer
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void MyValidator::SetKeyTyped(KeyTypeCallback *cb)
|
||||
{
|
||||
m_ktc = cb;
|
||||
}
|
||||
|
||||
void MyValidator::OnChar(wxKeyEvent& event)
|
||||
{
|
||||
if (m_validatorWindow) {
|
||||
int keyCode = event.GetKeyCode();
|
||||
|
||||
// we don't filter special keys and Delete
|
||||
if (!(keyCode < WXK_SPACE || keyCode == WXK_DELETE || keyCode > WXK_START)) {
|
||||
bool chOk = true;
|
||||
switch (m_type) {
|
||||
case MYVAL_ANY:
|
||||
break;
|
||||
case MYVAL_NUMERIC:
|
||||
chOk = (wxIsdigit(keyCode) != 0);
|
||||
break;
|
||||
case MYVAL_HEX:
|
||||
chOk = (wxIsxdigit(keyCode) != 0);
|
||||
break;
|
||||
case MYVAL_HOST:
|
||||
chOk = (wxIsalnum(keyCode) || (keyCode == _T('.')) || (keyCode == _T('-')));
|
||||
break;
|
||||
case MYVAL_FILENAME:
|
||||
chOk = (wxFileName::GetForbiddenChars().Find((wchar_t)keyCode) == -1);
|
||||
break;
|
||||
}
|
||||
if (!chOk) {
|
||||
if (!wxValidator::IsSilent())
|
||||
wxBell();
|
||||
// eat message
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_ktc)
|
||||
m_ktc->KeyTyped();
|
||||
event.Skip();
|
||||
}
|
||||
102
MyValidator.h
Normal file
102
MyValidator.h
Normal file
@@ -0,0 +1,102 @@
|
||||
// $Id: MyValidator.h 175 2009-02-22 04:11:02Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _MYVALIDATOR_H_
|
||||
#define _MYVALIDATOR_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
||||
#pragma interface "MyValidator.h"
|
||||
#endif
|
||||
|
||||
#include "wx/validate.h"
|
||||
|
||||
class KeyTypeCallback
|
||||
{
|
||||
public:
|
||||
virtual ~KeyTypeCallback() {};
|
||||
virtual void KeyTyped() = 0;
|
||||
};
|
||||
|
||||
class MyValidator : public wxValidator
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(MyValidator)
|
||||
|
||||
public:
|
||||
|
||||
typedef enum {
|
||||
MYVAL_ANY,
|
||||
MYVAL_NUMERIC,
|
||||
MYVAL_HEX,
|
||||
MYVAL_HOST,
|
||||
MYVAL_FILENAME,
|
||||
} MyValidatorType;
|
||||
|
||||
|
||||
MyValidator() { };
|
||||
MyValidator(bool*);
|
||||
MyValidator(int*);
|
||||
MyValidator(wxString*);
|
||||
MyValidator(wxArrayInt*);
|
||||
MyValidator(const MyValidator&);
|
||||
|
||||
MyValidator(MyValidatorType, bool*);
|
||||
MyValidator(MyValidatorType, int*);
|
||||
MyValidator(MyValidatorType, wxString*);
|
||||
MyValidator(MyValidatorType, wxArrayInt*);
|
||||
MyValidator(MyValidatorType, const MyValidator&);
|
||||
|
||||
virtual wxObject *Clone() const { return new MyValidator(*this); }
|
||||
bool Copy(const MyValidator& val);
|
||||
|
||||
// Called when the value in the window must be validated.
|
||||
// This function can pop up an error message.
|
||||
virtual bool Validate(wxWindow * WXUNUSED(parent)) { return TRUE; }
|
||||
|
||||
// Called to transfer data to the window
|
||||
virtual bool TransferToWindow();
|
||||
|
||||
// Called to transfer data to the window
|
||||
virtual bool TransferFromWindow();
|
||||
|
||||
void SetKeyTyped(KeyTypeCallback *);
|
||||
|
||||
virtual ~MyValidator();
|
||||
|
||||
void OnChar(wxKeyEvent& event);
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
protected:
|
||||
void Init();
|
||||
|
||||
bool* m_pBool;
|
||||
int* m_pInt;
|
||||
wxString* m_pString;
|
||||
wxArrayInt* m_pArrayInt;
|
||||
KeyTypeCallback *m_ktc;
|
||||
|
||||
private:
|
||||
|
||||
MyValidatorType m_type;
|
||||
};
|
||||
|
||||
#endif
|
||||
// _MYVALIDATOR_H_
|
||||
1406
MyWizard.cpp
Normal file
1406
MyWizard.cpp
Normal file
File diff suppressed because it is too large
Load Diff
464
MyWizard.h
Normal file
464
MyWizard.h
Normal file
@@ -0,0 +1,464 @@
|
||||
// $Id: MyWizard.h 625 2011-06-09 14:50:12Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _MYWIZARD_H_
|
||||
#define _MYWIZARD_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "MyWizard.cpp"
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* Includes
|
||||
*/
|
||||
|
||||
////@begin includes
|
||||
#include "MyWizard_symbols.h"
|
||||
#include "wx/xrc/xmlres.h"
|
||||
#include "wx/wizard.h"
|
||||
#include "wx/valgen.h"
|
||||
#include "wx/spinctrl.h"
|
||||
////@end includes
|
||||
|
||||
#include "MyValidator.h"
|
||||
|
||||
/*!
|
||||
* Forward declarations
|
||||
*/
|
||||
|
||||
////@begin forward declarations
|
||||
class WizardPageWelcome;
|
||||
class WizardPageSession;
|
||||
class WizardPageDesktop;
|
||||
class wxSpinCtrl;
|
||||
class WizardPageSecurity;
|
||||
class WizardPageFinish;
|
||||
class WrappedStaticText;
|
||||
////@end forward declarations
|
||||
class MyXmlConfig;
|
||||
|
||||
/*!
|
||||
* Control identifiers
|
||||
*/
|
||||
|
||||
////@begin control identifiers
|
||||
#define ID_WIZARD 10076
|
||||
#define ID_WIZARDPAGE_WELCOME 10077
|
||||
#define ID_WIZARDPAGE_SESSION 10084
|
||||
#define ID_WIZARDPAGE_DESKTOP 10133
|
||||
#define ID_WIZARDPAGE_SECURITY 10141
|
||||
#define ID_WIZARDPAGE_FINISH 10179
|
||||
#define SYMBOL_MYWIZARD_IDNAME ID_WIZARD
|
||||
////@end control identifiers
|
||||
|
||||
/*!
|
||||
* Compatibility
|
||||
*/
|
||||
|
||||
#ifndef wxCLOSE_BOX
|
||||
#define wxCLOSE_BOX 0x1000
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* MyWizard class declaration
|
||||
*/
|
||||
|
||||
class MyWizard: public wxWizard, public KeyTypeCallback
|
||||
{
|
||||
DECLARE_CLASS( MyWizard )
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
public:
|
||||
/// Constructors
|
||||
MyWizard( );
|
||||
MyWizard( wxWindow* parent, wxWindowID id = SYMBOL_MYWIZARD_IDNAME, const wxPoint& pos = wxDefaultPosition );
|
||||
|
||||
~MyWizard();
|
||||
|
||||
/// Creation
|
||||
bool Create( wxWindow* parent, wxWindowID id = SYMBOL_MYWIZARD_IDNAME, const wxPoint& pos = wxDefaultPosition );
|
||||
|
||||
/// Creates the controls and sizers
|
||||
void CreateControls();
|
||||
|
||||
// Local implementation handles modality
|
||||
// on OSX differently.
|
||||
virtual bool RunWizard(wxWizardPage *firstPage);
|
||||
|
||||
virtual wxSize GetPageSize() const;
|
||||
|
||||
void EnableNext(bool enable = true);
|
||||
virtual void KeyTyped();
|
||||
void SetCancelled() { m_bCancelForced = true; }
|
||||
|
||||
wxString sGetConfigName();
|
||||
|
||||
MyXmlConfig *pGetConfig() { return m_pCfg; }
|
||||
|
||||
////@begin MyWizard event handler declarations
|
||||
|
||||
////@end MyWizard event handler declarations
|
||||
|
||||
////@begin MyWizard member function declarations
|
||||
|
||||
/// Runs the wizard
|
||||
bool Run();
|
||||
|
||||
/// Retrieves bitmap resources
|
||||
wxBitmap GetBitmapResource( const wxString& name );
|
||||
|
||||
/// Retrieves icon resources
|
||||
wxIcon GetIconResource( const wxString& name );
|
||||
////@end MyWizard member function declarations
|
||||
|
||||
private:
|
||||
/// Should we show tooltips?
|
||||
static bool ShowToolTips();
|
||||
|
||||
////@begin MyWizard member variables
|
||||
WizardPageWelcome* m_pPageWelcome;
|
||||
WizardPageSession* m_pPageSession;
|
||||
WizardPageDesktop* m_pPageDesktop;
|
||||
WizardPageSecurity* m_pPageSecurity;
|
||||
WizardPageFinish* m_pPageFinish;
|
||||
////@end MyWizard member variables
|
||||
|
||||
wxButton *nextButton;
|
||||
MyXmlConfig *m_pCfg;
|
||||
bool m_bCancelForced;
|
||||
int minW, minH;
|
||||
};
|
||||
|
||||
/*!
|
||||
* WizardPageWelcome class declaration
|
||||
*/
|
||||
|
||||
class WizardPageWelcome: public wxWizardPageSimple
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS( WizardPageWelcome )
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
public:
|
||||
/// Constructors
|
||||
WizardPageWelcome( );
|
||||
|
||||
WizardPageWelcome( wxWizard* parent );
|
||||
|
||||
/// Creation
|
||||
bool Create( wxWizard* parent );
|
||||
|
||||
private:
|
||||
|
||||
/// Creates the controls and sizers
|
||||
void CreateControls();
|
||||
|
||||
////@begin WizardPageWelcome event handler declarations
|
||||
|
||||
/// wxEVT_WIZARD_PAGE_CHANGED event handler for ID_WIZARDPAGE_WELCOME
|
||||
void OnWizardpageWelcomePageChanged( wxWizardEvent& event );
|
||||
|
||||
////@end WizardPageWelcome event handler declarations
|
||||
|
||||
////@begin WizardPageWelcome member function declarations
|
||||
|
||||
/// Retrieves bitmap resources
|
||||
wxBitmap GetBitmapResource( const wxString& name );
|
||||
|
||||
/// Retrieves icon resources
|
||||
wxIcon GetIconResource( const wxString& name );
|
||||
////@end WizardPageWelcome member function declarations
|
||||
|
||||
/// Should we show tooltips?
|
||||
static bool ShowToolTips();
|
||||
|
||||
////@begin WizardPageWelcome member variables
|
||||
////@end WizardPageWelcome member variables
|
||||
};
|
||||
|
||||
/*!
|
||||
* WizardPageSession class declaration
|
||||
*/
|
||||
|
||||
class WizardPageSession: public wxWizardPageSimple
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS( WizardPageSession )
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
public:
|
||||
/// Constructors
|
||||
WizardPageSession( );
|
||||
|
||||
WizardPageSession( wxWizard* parent );
|
||||
|
||||
/// Creation
|
||||
bool Create( wxWizard* parent );
|
||||
|
||||
void KeyTyped();
|
||||
|
||||
private:
|
||||
|
||||
/// Creates the controls and sizers
|
||||
void CreateControls();
|
||||
|
||||
bool ConfigExists(wxString &);
|
||||
|
||||
void CheckNextEnable();
|
||||
|
||||
////@begin WizardPageSession event handler declarations
|
||||
|
||||
/// wxEVT_WIZARD_PAGE_CHANGED event handler for ID_WIZARDPAGE_SESSION
|
||||
void OnWizardpageSessionPageChanged( wxWizardEvent& event );
|
||||
|
||||
/// wxEVT_WIZARD_PAGE_CHANGING event handler for ID_WIZARDPAGE_SESSION
|
||||
void OnWizardpageSessionPageChanging( wxWizardEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_TEXTCTRL_SESSION_NAME
|
||||
void OnTextctrlSessionNameUpdated( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_TEXTCTRL_SVRNAME
|
||||
void OnTextctrlSvrnameUpdated( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_TEXTCTRL_SVRPORT
|
||||
void OnTextctrlSvrportUpdated( wxCommandEvent& event );
|
||||
|
||||
////@end WizardPageSession event handler declarations
|
||||
|
||||
////@begin WizardPageSession member function declarations
|
||||
|
||||
/// Retrieves bitmap resources
|
||||
wxBitmap GetBitmapResource( const wxString& name );
|
||||
|
||||
/// Retrieves icon resources
|
||||
wxIcon GetIconResource( const wxString& name );
|
||||
////@end WizardPageSession member function declarations
|
||||
|
||||
/// Should we show tooltips?
|
||||
static bool ShowToolTips();
|
||||
|
||||
////@begin WizardPageSession member variables
|
||||
wxTextCtrl* m_pCtrlSessionName;
|
||||
wxTextCtrl* m_pCtrlHostName;
|
||||
wxTextCtrl* m_pCtrlPort;
|
||||
wxString m_sHostName;
|
||||
int m_iPort;
|
||||
int m_iConnectionSpeed;
|
||||
wxString m_sSessionName;
|
||||
////@end WizardPageSession member variables
|
||||
|
||||
bool m_bKeyTyped;
|
||||
};
|
||||
|
||||
/*!
|
||||
* WizardPageDesktop class declaration
|
||||
*/
|
||||
|
||||
class WizardPageDesktop: public wxWizardPageSimple
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS( WizardPageDesktop )
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
public:
|
||||
/// Constructors
|
||||
WizardPageDesktop( );
|
||||
WizardPageDesktop( wxWizard* parent );
|
||||
~WizardPageDesktop( );
|
||||
|
||||
/// Creation
|
||||
bool Create( wxWizard* parent );
|
||||
|
||||
private:
|
||||
void UpdateDialogConstraints(bool);
|
||||
void ShowRdpPropertyDialog();
|
||||
void ShowVncPropertyDialog();
|
||||
|
||||
/// Creates the controls and sizers
|
||||
void CreateControls();
|
||||
|
||||
void CheckNextEnable();
|
||||
|
||||
////@begin WizardPageDesktop event handler declarations
|
||||
|
||||
/// wxEVT_WIZARD_PAGE_CHANGED event handler for ID_WIZARDPAGE_DESKTOP
|
||||
void OnWizardpageDesktopPageChanged( wxWizardEvent& event );
|
||||
|
||||
/// wxEVT_WIZARD_PAGE_CHANGING event handler for ID_WIZARDPAGE_DESKTOP
|
||||
void OnWizardpageDesktopPageChanging( wxWizardEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_COMBOBOX_DPROTO
|
||||
void OnComboboxDprotoSelected( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_COMBOBOX_DTYPE
|
||||
void OnComboboxDtypeSelected( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_DSETTINGS
|
||||
void OnButtonDsettingsClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_COMBOBOX_DISPTYPE
|
||||
void OnComboboxDisptypeSelected( wxCommandEvent& event );
|
||||
|
||||
////@end WizardPageDesktop event handler declarations
|
||||
|
||||
void OnRdpDialogTimer(wxTimerEvent &);
|
||||
void OnVncDialogTimer(wxTimerEvent &);
|
||||
|
||||
////@begin WizardPageDesktop member function declarations
|
||||
|
||||
/// Retrieves bitmap resources
|
||||
wxBitmap GetBitmapResource( const wxString& name );
|
||||
|
||||
/// Retrieves icon resources
|
||||
wxIcon GetIconResource( const wxString& name );
|
||||
////@end WizardPageDesktop member function declarations
|
||||
|
||||
/// Should we show tooltips?
|
||||
static bool ShowToolTips();
|
||||
|
||||
////@begin WizardPageDesktop member variables
|
||||
wxComboBox* m_pCtrlDesktopType;
|
||||
wxButton* m_pCtrlDesktopSettings;
|
||||
wxComboBox* m_pCtrlDisplayType;
|
||||
wxSpinCtrl* m_pCtrlDisplayWidth;
|
||||
wxSpinCtrl* m_pCtrlDisplayHeight;
|
||||
int m_iSessionType;
|
||||
int m_iDesktopTypeDialog;
|
||||
int m_iDisplayType;
|
||||
int m_iDisplayWidth;
|
||||
int m_iDisplayHeight;
|
||||
private:
|
||||
int m_iPseudoDesktopTypeIndex;
|
||||
int m_iPseudoDisplayTypeIndex;
|
||||
////@end WizardPageDesktop member variables
|
||||
int m_iDesktopType;
|
||||
int m_iUnixDesktopType;
|
||||
wxTimer *m_pRdpDialogTimer;
|
||||
wxTimer *m_pVncDialogTimer;
|
||||
};
|
||||
|
||||
/*!
|
||||
* WizardPageSecurity class declaration
|
||||
*/
|
||||
|
||||
class WizardPageSecurity: public wxWizardPageSimple
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS( WizardPageSecurity )
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
public:
|
||||
/// Constructors
|
||||
WizardPageSecurity( );
|
||||
|
||||
WizardPageSecurity( wxWizard* parent );
|
||||
|
||||
/// Creation
|
||||
bool Create( wxWizard* parent );
|
||||
|
||||
private:
|
||||
|
||||
/// Creates the controls and sizers
|
||||
void CreateControls();
|
||||
|
||||
////@begin WizardPageSecurity event handler declarations
|
||||
|
||||
/// wxEVT_WIZARD_PAGE_CHANGED event handler for ID_WIZARDPAGE_SECURITY
|
||||
void OnWizardpageSecurityPageChanged( wxWizardEvent& event );
|
||||
|
||||
/// wxEVT_WIZARD_PAGE_CHANGING event handler for ID_WIZARDPAGE_SECURITY
|
||||
void OnWizardpageSecurityPageChanging( wxWizardEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX_SCARD
|
||||
void OnCheckboxScardClick( wxCommandEvent& event );
|
||||
|
||||
////@end WizardPageSecurity event handler declarations
|
||||
|
||||
////@begin WizardPageSecurity member function declarations
|
||||
|
||||
/// Retrieves bitmap resources
|
||||
wxBitmap GetBitmapResource( const wxString& name );
|
||||
|
||||
/// Retrieves icon resources
|
||||
wxIcon GetIconResource( const wxString& name );
|
||||
////@end WizardPageSecurity member function declarations
|
||||
|
||||
/// Should we show tooltips?
|
||||
static bool ShowToolTips();
|
||||
|
||||
////@begin WizardPageSecurity member variables
|
||||
wxCheckBox* m_pCtrlUseSmartCard;
|
||||
wxCheckBox* m_pCtrlEnableSSL;
|
||||
bool m_bUseSmartCard;
|
||||
bool m_bEnableSSL;
|
||||
////@end WizardPageSecurity member variables
|
||||
};
|
||||
|
||||
/*!
|
||||
* WizardPageFinish class declaration
|
||||
*/
|
||||
|
||||
class WizardPageFinish: public wxWizardPageSimple
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS( WizardPageFinish )
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
public:
|
||||
/// Constructors
|
||||
WizardPageFinish( );
|
||||
|
||||
WizardPageFinish( wxWizard* parent );
|
||||
|
||||
/// Creation
|
||||
bool Create( wxWizard* parent );
|
||||
|
||||
private:
|
||||
|
||||
/// Creates the controls and sizers
|
||||
void CreateControls();
|
||||
|
||||
////@begin WizardPageFinish event handler declarations
|
||||
|
||||
/// wxEVT_WIZARD_PAGE_CHANGED event handler for ID_WIZARDPAGE_FINISH
|
||||
void OnWizardpageFinishPageChanged( wxWizardEvent& event );
|
||||
|
||||
/// wxEVT_WIZARD_PAGE_CHANGING event handler for ID_WIZARDPAGE_FINISH
|
||||
void OnWizardpageFinishPageChanging( wxWizardEvent& event );
|
||||
|
||||
////@end WizardPageFinish event handler declarations
|
||||
|
||||
////@begin WizardPageFinish member function declarations
|
||||
|
||||
/// Retrieves bitmap resources
|
||||
wxBitmap GetBitmapResource( const wxString& name );
|
||||
|
||||
/// Retrieves icon resources
|
||||
wxIcon GetIconResource( const wxString& name );
|
||||
////@end WizardPageFinish member function declarations
|
||||
|
||||
/// Should we show tooltips?
|
||||
static bool ShowToolTips();
|
||||
|
||||
////@begin WizardPageFinish member variables
|
||||
WrappedStaticText* m_pCtrlHeader;
|
||||
bool m_bCreateShortcut;
|
||||
bool m_bShowAdvancedConfig;
|
||||
////@end WizardPageFinish member variables
|
||||
};
|
||||
|
||||
#endif
|
||||
// _MYWIZARD_H_
|
||||
65
MyWizard_symbols.h
Normal file
65
MyWizard_symbols.h
Normal file
@@ -0,0 +1,65 @@
|
||||
// $Id: MyWizard_symbols.h 657 2011-12-09 20:41:21Z felfert $
|
||||
//
|
||||
// Copyright (C) 2010 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#define ID_WIZARD_SYMBOL_0 _("Connection Wizard - OpenNX")
|
||||
#define ID_WIZARD_SYMBOL_1 _("Welcome to the OpenNX Client Connection Wizard which will guide you through the steps needed to setup your login. Please select the 'Next' button to start.")
|
||||
#define ID_WIZARD_SYMBOL_2 _("Insert the name of the session. Your configuration settings will be saved with this name.")
|
||||
#define ID_WIZARD_SYMBOL_3 _("Session")
|
||||
#define ID_WIZARD_SYMBOL_4 _("Insert the name and port of the server you want to connect.")
|
||||
#define ID_WIZARD_SYMBOL_5 _("Host")
|
||||
#define ID_WIZARD_SYMBOL_6 _("Port")
|
||||
#define ID_WIZARD_SYMBOL_7 _("Select the type of your internet connection.")
|
||||
#define ID_WIZARD_SYMBOL_8 _("MODEM")
|
||||
#define ID_WIZARD_SYMBOL_9 _("ISDN")
|
||||
#define ID_WIZARD_SYMBOL_10 _("ADSL")
|
||||
#define ID_WIZARD_SYMBOL_11 _("WAN")
|
||||
#define ID_WIZARD_SYMBOL_12 _("LAN")
|
||||
#define ID_WIZARD_SYMBOL_13 _("Using OpenNX Client, you can run RDP, VNC and X desktops, depending on what your service provider has made available.")
|
||||
#define ID_WIZARD_SYMBOL_14 _("Unix")
|
||||
#define ID_WIZARD_SYMBOL_15 _("Windows")
|
||||
#define ID_WIZARD_SYMBOL_16 _("VNC")
|
||||
#define ID_WIZARD_SYMBOL_17 _("Shadow")
|
||||
#define ID_WIZARD_SYMBOL_18 _("KDE")
|
||||
#define ID_WIZARD_SYMBOL_19 _("GNOME")
|
||||
#define ID_WIZARD_SYMBOL_20 _("CDE")
|
||||
#define ID_WIZARD_SYMBOL_21 _("XFCE")
|
||||
#define ID_WIZARD_SYMBOL_22 _("XDMCP")
|
||||
#define ID_WIZARD_SYMBOL_23 _("Custom")
|
||||
#define ID_WIZARD_SYMBOL_24 _("Settings...")
|
||||
#define ID_WIZARD_SYMBOL_25 _("Select the size of your remote desktop.")
|
||||
#define ID_WIZARD_SYMBOL_26 _("640x480")
|
||||
#define ID_WIZARD_SYMBOL_27 _("800x600")
|
||||
#define ID_WIZARD_SYMBOL_28 _("1024x768")
|
||||
#define ID_WIZARD_SYMBOL_29 _("Available Area")
|
||||
#define ID_WIZARD_SYMBOL_30 _("Fullscreen")
|
||||
#define ID_WIZARD_SYMBOL_31 _("W")
|
||||
#define ID_WIZARD_SYMBOL_32 _("H")
|
||||
#define ID_WIZARD_SYMBOL_33 _("OpenNX Client supports authentication using a variety of USB SmartCard tokens. Enable this option if you intend to use such a token.")
|
||||
#define ID_WIZARD_SYMBOL_34 _("Use SmartCard")
|
||||
#define ID_WIZARD_SYMBOL_35 _("Authorization credentials are always encrypted while establishing a connection. For increased security, you can enable the following option.")
|
||||
#define ID_WIZARD_SYMBOL_36 _("Enable SSL encryption of all traffic")
|
||||
#define ID_WIZARD_SYMBOL_37 _("Create shortcut on desktop")
|
||||
#define ID_WIZARD_SYMBOL_38 _("Show the Advanced Configuration dialog")
|
||||
#define ID_WIZARD_SYMBOL_39 _("1280x1024")
|
||||
#define ID_WIZARD_SYMBOL_40 _("1400x1050")
|
||||
#define ID_WIZARD_SYMBOL_41 _("1440x900")
|
||||
#define ID_WIZARD_SYMBOL_42 _("1680x1050")
|
||||
#define ID_WIZARD_SYMBOL_43 _("1920x1080")
|
||||
2759
MyXmlConfig.cpp
Normal file
2759
MyXmlConfig.cpp
Normal file
File diff suppressed because it is too large
Load Diff
546
MyXmlConfig.h
Normal file
546
MyXmlConfig.h
Normal file
@@ -0,0 +1,546 @@
|
||||
// $Id: MyXmlConfig.h 679 2012-02-09 23:29:53Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _MYXMLCONFIG_H_
|
||||
#define _MYXMLCONFIG_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "MyXmlConfig.cpp"
|
||||
#endif
|
||||
|
||||
#include <wx/dynarray.h>
|
||||
#include <wx/string.h>
|
||||
#include <wx/object.h>
|
||||
|
||||
#include "WinShare.h"
|
||||
|
||||
class wxXmlNode;
|
||||
|
||||
class ShareGroup : public wxObject
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(ShareGroup)
|
||||
|
||||
public:
|
||||
ShareGroup() : wxObject() {m_eType = SharedResource::SHARE_UNKNOWN; }
|
||||
virtual ~ShareGroup() {}
|
||||
|
||||
bool operator ==(const ShareGroup &);
|
||||
bool operator !=(const ShareGroup &);
|
||||
wxString toString();
|
||||
|
||||
bool m_bDefault; // CUPS only
|
||||
bool m_bPublic; // CUPS only
|
||||
SharedResource::ShareType m_eType;
|
||||
wxString m_sGroupName;
|
||||
wxString m_sAlias; // SMB Only
|
||||
wxString m_sDriver; // CUPS Only
|
||||
wxString m_sPassword;
|
||||
wxString m_sShareName;
|
||||
wxString m_sUsername;
|
||||
};
|
||||
|
||||
WX_DECLARE_OBJARRAY(ShareGroup, ArrayOfShareGroups);
|
||||
|
||||
class USBDevice;
|
||||
|
||||
class SharedUsbDevice : public wxObject
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(SharedUsbDevice)
|
||||
|
||||
public:
|
||||
typedef enum {
|
||||
MODE_UNKNOWN = 0,
|
||||
MODE_LOCAL,
|
||||
MODE_REMOTE,
|
||||
} Mode;
|
||||
|
||||
SharedUsbDevice() : wxObject() { m_eMode = MODE_UNKNOWN; }
|
||||
virtual ~SharedUsbDevice() {}
|
||||
wxString toShortString();
|
||||
bool cmpNoMode(const SharedUsbDevice &);
|
||||
bool operator ==(const SharedUsbDevice &);
|
||||
bool operator !=(const SharedUsbDevice &);
|
||||
bool MatchHotplug(const USBDevice &);
|
||||
|
||||
Mode m_eMode;
|
||||
wxString m_sVendor;
|
||||
wxString m_sProduct;
|
||||
wxString m_sSerial;
|
||||
int m_iClass;
|
||||
int m_iVendorID;
|
||||
int m_iProductID;
|
||||
};
|
||||
|
||||
WX_DECLARE_OBJARRAY(SharedUsbDevice, ArrayOfUsbForwards);
|
||||
|
||||
class MyXmlConfig
|
||||
{
|
||||
public:
|
||||
typedef enum {
|
||||
SPEED_MODEM = 0,
|
||||
SPEED_ISDN,
|
||||
SPEED_ADSL,
|
||||
SPEED_WAN,
|
||||
SPEED_LAN,
|
||||
} ConnectionSpeed;
|
||||
|
||||
typedef enum {
|
||||
STYPE_UNIX = 0,
|
||||
STYPE_WINDOWS,
|
||||
STYPE_VNC,
|
||||
STYPE_SHADOW,
|
||||
STYPE_ADMIN,
|
||||
} SessionType;
|
||||
|
||||
typedef enum {
|
||||
DTYPE_ANY = -3,
|
||||
DTYPE_RDP = -2,
|
||||
DTYPE_RFB = -1,
|
||||
DTYPE_KDE = 0,
|
||||
DTYPE_GNOME,
|
||||
DTYPE_CDE,
|
||||
DTYPE_XFCE,
|
||||
DTYPE_XDM,
|
||||
DTYPE_CUSTOM,
|
||||
} DesktopType;
|
||||
|
||||
typedef enum {
|
||||
DPTYPE_640x480 = 0,
|
||||
DPTYPE_800x600,
|
||||
DPTYPE_1024x768,
|
||||
DPTYPE_1280x1024,
|
||||
DPTYPE_1400x1050,
|
||||
DPTYPE_1440x900,
|
||||
DPTYPE_1680x1050,
|
||||
DPTYPE_1920x1080,
|
||||
DPTYPE_AVAILABLE,
|
||||
DPTYPE_FULLSCREEN,
|
||||
DPTYPE_CUSTOM,
|
||||
DPTYPE_NODECORATION,
|
||||
DPTYPE_REMOTE,
|
||||
} DisplayType;
|
||||
|
||||
typedef enum {
|
||||
CACHEMEM_0MB = 0,
|
||||
CACHEMEM_1MB,
|
||||
CACHEMEM_2MB,
|
||||
CACHEMEM_4MB,
|
||||
CACHEMEM_8MB,
|
||||
CACHEMEM_16MB,
|
||||
CACHEMEM_32MB,
|
||||
CACHEMEM_64MB,
|
||||
CACHEMEM_128MB,
|
||||
} CacheMemory;
|
||||
|
||||
typedef enum CacheDisk {
|
||||
CACHEDISK_0MB = 0,
|
||||
CACHEDISK_4MB,
|
||||
CACHEDISK_8MB,
|
||||
CACHEDISK_16MB,
|
||||
CACHEDISK_32MB,
|
||||
CACHEDISK_64MB,
|
||||
CACHEDISK_128MB,
|
||||
CACHEDISK_256MB,
|
||||
CACHEDISK_512MB,
|
||||
} CacheDisk;
|
||||
|
||||
typedef enum XdmMode {
|
||||
XDM_MODE_SERVER,
|
||||
XDM_MODE_QUERY,
|
||||
XDM_MODE_BROADCAST,
|
||||
XDM_MODE_LIST,
|
||||
} XdmMode;
|
||||
|
||||
typedef enum RatePA {
|
||||
RATEPA_NORESAMPLE = 0,
|
||||
RATEPA_48000,
|
||||
RATEPA_44100,
|
||||
RATEPA_32000,
|
||||
RATEPA_16000,
|
||||
RATEPA_8000,
|
||||
} RatePA;
|
||||
|
||||
MyXmlConfig();
|
||||
MyXmlConfig(const wxString &);
|
||||
virtual ~MyXmlConfig();
|
||||
|
||||
MyXmlConfig &operator =(const MyXmlConfig &);
|
||||
bool operator ==(const MyXmlConfig &);
|
||||
|
||||
void saveState();
|
||||
bool checkChanged();
|
||||
bool SaveToFile();
|
||||
bool LoadFromFile(const wxString &);
|
||||
bool LoadFromURL(const wxString &);
|
||||
bool LoadFromString(const wxString &, bool);
|
||||
|
||||
wxString sGetSessionParams(const long, bool, const wxString &);
|
||||
wxString sGetListParams(const long);
|
||||
wxString sGetProxyParams(const long);
|
||||
#ifdef __WXMSW__
|
||||
wxString sGetXserverParams(bool forNXWin);
|
||||
#endif
|
||||
|
||||
bool IsValid() { return m_bValid; }
|
||||
bool IsWritable() { return m_bWritable; }
|
||||
bool WasOldConfig() { return m_bOldConfig; }
|
||||
|
||||
bool bGetDisableBackingstore() { return m_bDisableBackingstore; }
|
||||
bool bGetDisableComposite() { return m_bDisableComposite; }
|
||||
bool bGetDisableRender() { return m_bDisableRender; }
|
||||
bool bGetDisableShmem() { return m_bDisableShmem; }
|
||||
bool bGetDisableShpix() { return m_bDisableShpix; }
|
||||
bool bGetDisableTaint() { return m_bDisableTaint; }
|
||||
bool bGetDisableTcpNoDelay() { return m_bDisableTcpNoDelay; }
|
||||
bool bGetDisableXagent() { return m_bDisableXagent; }
|
||||
bool bGetDisableZlibCompression() { return m_bDisableZlibCompression; }
|
||||
bool bGetEnableMultimedia() { return m_bEnableMultimedia; }
|
||||
bool bGetEnableNativePA() { return m_bEnableNativePA; }
|
||||
bool bGetEnableMonoPA() { return m_bEnableMonoPA; }
|
||||
bool bGetEnableSmbSharing() { return m_bEnableSmbSharing; }
|
||||
bool bGetEnableSSL() { return m_bEnableSSL; }
|
||||
bool bGetExternalProxy() { return m_bExternalProxy; }
|
||||
bool bGetGuestMode() { return m_bGuestMode; }
|
||||
bool bGetKbdLayoutOther() { return m_bKbdLayoutOther; }
|
||||
bool bGetProxyPassRemember() { return m_bProxyPassRemember; }
|
||||
bool bGetRdpCache() { return m_bRdpCache; }
|
||||
bool bGetRdpRememberPassword() { return m_bRdpRememberPassword; }
|
||||
bool bGetRdpRootless() { return m_bRdpRootless; }
|
||||
bool bGetRdpRunApplication() { return m_bRdpRunApplication; }
|
||||
bool bGetRememberPassword() { return m_bRememberPassword || m_bGuestMode; }
|
||||
bool bGetRemoveOldSessionFiles() { return m_bRemoveOldSessionFiles; }
|
||||
bool bGetRunConsole() { return m_bRunConsole; }
|
||||
bool bGetRunXclients() { return m_bRunXclients; }
|
||||
bool bGetUseCups() { return m_bUseCups; }
|
||||
bool bGetUseCustomImageEncoding() { return m_bUseCustomImageEncoding; }
|
||||
bool bGetUseProxy() { return m_bUseProxy; }
|
||||
bool bGetUseSmartCard() { return m_bUseSmartCard; }
|
||||
bool bGetVirtualDesktop() { return m_bVirtualDesktop; }
|
||||
bool bGetVncRememberPassword() { return m_bVncRememberPassword; }
|
||||
bool bGetVncRootless() { return m_bVncRootless; }
|
||||
bool bGetVncUseNxAuth() { return m_bVncUseNxAuth; }
|
||||
bool bGetEnableUSBIP() { return m_bEnableUSBIP; }
|
||||
bool bGetDisableDirectDraw() { return m_bDisableDirectDraw; }
|
||||
bool bGetDisableDeferredUpdates() { return m_bDisableDeferredUpdates; }
|
||||
bool bGetGrabKeyboard() { return m_bGrabKeyboard; }
|
||||
|
||||
MyXmlConfig::ConnectionSpeed eGetConnectionSpeed() { return m_eConnectionSpeed; }
|
||||
MyXmlConfig::DesktopType eGetDesktopType() { return m_eDesktopType; }
|
||||
MyXmlConfig::DisplayType eGetDisplayType() { return m_eDisplayType; }
|
||||
MyXmlConfig::SessionType eGetSessionType() { return m_eSessionType; }
|
||||
MyXmlConfig::CacheMemory eGetCacheMemory() { return m_eCacheMemory; }
|
||||
MyXmlConfig::CacheDisk eGetCacheDisk() { return m_eCacheDisk; }
|
||||
MyXmlConfig::XdmMode eGetXdmMode() { return m_eXdmMode; }
|
||||
MyXmlConfig::RatePA eGetRatePA() { return m_eRatePA; }
|
||||
|
||||
int iGetClipFilter() { return m_iClipFilter; }
|
||||
int iGetCupsPort() { return m_iCupsPort; }
|
||||
int iGetDisplayHeight() { return m_iDisplayHeight; }
|
||||
int iGetDisplayWidth() { return m_iDisplayWidth; }
|
||||
int iGetImageEncoding() { return m_iImageEncoding; }
|
||||
int iGetJpegQuality() { return m_iJpegQuality; }
|
||||
int iGetProxyPort() { return m_iProxyPort; }
|
||||
int iGetRdpAuthType() { return m_iRdpAuthType; }
|
||||
int iGetRdpColors() { return m_iRdpColors; }
|
||||
int iGetRdpImageEncoding() { return m_iRdpImageEncoding; }
|
||||
int iGetRdpJpegQuality() { return m_iRdpJpegQuality; }
|
||||
int iGetServerPort() { return m_iServerPort; }
|
||||
int iGetSmbPort() { return m_iSmbPort; }
|
||||
int iGetUsedShareGroups() { return m_iUsedShareGroups; }
|
||||
int iGetVncDisplayNumber() { return m_iVncDisplayNumber; }
|
||||
int iGetVncImageEncoding() { return m_iVncImageEncoding; }
|
||||
int iGetVncJpegQuality() { return m_iVncJpegQuality; }
|
||||
int iGetXdmBroadcastPort() { return m_iXdmBroadcastPort; }
|
||||
int iGetXdmListPort() { return m_iXdmListPort; }
|
||||
int iGetXdmQueryPort() { return m_iXdmQueryPort; }
|
||||
|
||||
wxString sGetCommandLine() { return m_sCommandLine; }
|
||||
wxString sGetCupsPath() { return m_sCupsPath; }
|
||||
wxString sGetFileName() { return m_sFileName; }
|
||||
wxString sGetGuestUser() { return m_sGuestUser; }
|
||||
wxString sGetGuestPassword() { return m_sGuestPassword; }
|
||||
wxString sGetKbdLayoutLanguage() { return m_sKbdLayoutLanguage; }
|
||||
wxString sGetName() { return m_sName; }
|
||||
wxString sGetPassword() { return m_sPassword; }
|
||||
wxString sGetProxyCommand() { return m_sProxyCommand; }
|
||||
wxString sGetProxyHost() { return m_sProxyHost; }
|
||||
wxString sGetProxyPass() { return m_sProxyPass; }
|
||||
wxString sGetProxyUser() { return m_sProxyUser; }
|
||||
wxString sGetRdpApplication() { return m_sRdpApplication; }
|
||||
wxString sGetRdpDomain() { return m_sRdpDomain; }
|
||||
wxString sGetRdpHostName() { return m_sRdpHostName; }
|
||||
wxString sGetRdpPassword() { return m_sRdpPassword; }
|
||||
wxString sGetRdpUsername() { return m_sRdpUsername; }
|
||||
wxString sGetServerHost() { return m_sServerHost; }
|
||||
wxString sGetSshKey() { return m_sSshKey; }
|
||||
wxString sGetUsername() { return m_sUsername; }
|
||||
wxString sGetVncHostName() { return m_sVncHostName; }
|
||||
wxString sGetVncPassword() { return m_sVncPassword; }
|
||||
wxString sGetXdmListHost() { return m_sXdmListHost; }
|
||||
wxString sGetXdmQueryHost() { return m_sXdmQueryHost; }
|
||||
|
||||
// For use by MySession
|
||||
wxString sGetSessionUser();
|
||||
wxString sGetSessionPassword();
|
||||
|
||||
wxArrayString aGetUsedShareGroups() { return m_aUsedShareGroups; }
|
||||
ArrayOfShareGroups aGetShareGroups() { return m_aShareGroups; }
|
||||
ArrayOfUsbForwards aGetUsbForwards() { return m_aUsbForwards; }
|
||||
|
||||
void bSetDisableBackingstore(const bool b) { m_bDisableBackingstore = b; }
|
||||
void bSetDisableComposite(const bool b) { m_bDisableComposite = b; }
|
||||
void bSetDisableRender(const bool b) { m_bDisableRender = b; }
|
||||
void bSetDisableShmem(const bool b) { m_bDisableShmem = b; }
|
||||
void bSetDisableShpix(const bool b) { m_bDisableShpix = b; }
|
||||
void bSetDisableTaint(const bool b) { m_bDisableTaint = b; }
|
||||
void bSetDisableTcpNoDelay(const bool b) { m_bDisableTcpNoDelay = b; }
|
||||
void bSetDisableXagent(const bool b) { m_bDisableXagent = b; }
|
||||
void bSetDisableZlibCompression(const bool b) { m_bDisableZlibCompression = b; }
|
||||
void bSetEnableMultimedia(const bool b) { m_bEnableMultimedia = b; }
|
||||
void bSetEnableNativePA(const bool b) { m_bEnableNativePA = b; }
|
||||
void bSetEnableMonoPA(const bool b) { m_bEnableMonoPA = b; }
|
||||
void bSetEnableSmbSharing(const bool b) { m_bEnableSmbSharing = b; }
|
||||
void bSetEnableSSL(const bool b) { m_bEnableSSL = b; }
|
||||
void bSetExternalProxy(const bool b) { m_bExternalProxy = b; }
|
||||
void bSetGuestMode(const bool b) { m_bGuestMode = b; }
|
||||
void bSetKbdLayoutOther(const bool b) { m_bKbdLayoutOther = b; }
|
||||
void bSetProxyPassRemember(const bool b) { m_bProxyPassRemember = b; }
|
||||
void bSetRdpCache(const bool b) { m_bRdpCache = b; }
|
||||
void bSetRdpRememberPassword(const bool b) { m_bRdpRememberPassword = b; }
|
||||
void bSetRdpRootless(const bool b) { m_bRdpRootless = b; }
|
||||
void bSetRdpRunApplication(const bool b) { m_bRdpRunApplication = b; }
|
||||
void bSetRememberPassword(const bool b) { m_bRememberPassword = b; }
|
||||
void bSetRemoveOldSessionFiles(const bool b) { m_bRemoveOldSessionFiles = b; }
|
||||
void bSetRunConsole(const bool b) { m_bRunConsole = b; }
|
||||
void bSetRunXclients(const bool b) { m_bRunXclients = b; }
|
||||
void bSetUseCups(const bool b) { m_bUseCups = b; }
|
||||
void bSetUseCustomImageEncoding(const bool b) { m_bUseCustomImageEncoding = b; }
|
||||
void bSetUseProxy(const bool b) { m_bUseProxy = b; }
|
||||
void bSetUseSmartCard(const bool b) { m_bUseSmartCard = b; }
|
||||
void bSetVirtualDesktop(const bool b) { m_bVirtualDesktop = b; }
|
||||
void bSetVncRememberPassword(const bool b) { m_bVncRememberPassword = b; }
|
||||
void bSetVncRootless(const bool b) { m_bVncRootless = b; }
|
||||
void bSetVncUseNxAuth(const bool b) { m_bVncUseNxAuth = b; }
|
||||
void bSetEnableUSBIP(const bool b) { m_bEnableUSBIP = b; }
|
||||
void bSetDisableDirectDraw(const bool b) { m_bDisableDirectDraw = b; }
|
||||
void bSetDisableDeferredUpdates(const bool b) { m_bDisableDeferredUpdates = b; }
|
||||
void bSetGrabKeyboard(const bool b) { m_bGrabKeyboard = b; }
|
||||
|
||||
void eSetCacheDisk(MyXmlConfig::CacheDisk e) { m_eCacheDisk = e; }
|
||||
void eSetCacheMemory(MyXmlConfig::CacheMemory e) { m_eCacheMemory = e; }
|
||||
void eSetConnectionSpeed(MyXmlConfig::ConnectionSpeed e) { m_eConnectionSpeed = e; }
|
||||
void eSetDesktopType(MyXmlConfig::DesktopType e) { m_eDesktopType = e; }
|
||||
void eSetDisplayType(MyXmlConfig::DisplayType e) { m_eDisplayType = e; }
|
||||
void eSetSessionType(MyXmlConfig::SessionType e) { m_eSessionType = e; }
|
||||
void eSetXdmMode(MyXmlConfig::XdmMode e) { m_eXdmMode = e; }
|
||||
void eSetRatePA(MyXmlConfig::RatePA e) { m_eRatePA = e; }
|
||||
|
||||
void iSetClipFilter(int i) { m_iClipFilter = i; }
|
||||
void iSetCupsPort(int i) { m_iCupsPort = i; }
|
||||
void iSetDisplayHeight(int i) { m_iDisplayHeight = i; }
|
||||
void iSetDisplayWidth(int i) { m_iDisplayWidth = i; }
|
||||
void iSetImageEncoding(int i) { m_iImageEncoding = i; }
|
||||
void iSetJpegQuality(int i) { m_iJpegQuality = i; }
|
||||
void iSetProxyPort(int i) { m_iProxyPort = i; }
|
||||
void iSetRdpAuthType(int i) { m_iRdpAuthType = i; }
|
||||
void iSetRdpColors(int i) { m_iRdpColors = i; }
|
||||
void iSetRdpImageEncoding(int i) { m_iRdpImageEncoding = i; }
|
||||
void iSetRdpJpegQuality(int i) { m_iRdpJpegQuality = i; }
|
||||
void iSetServerPort(int i) { m_iServerPort = i; }
|
||||
void iSetSmbPort(int i) { m_iSmbPort = i; }
|
||||
void iSetUsedShareGroups(int i) { m_iUsedShareGroups = i; }
|
||||
void iSetVncDisplayNumber(int i) { m_iVncDisplayNumber = i; }
|
||||
void iSetVncImageEncoding(int i) { m_iVncImageEncoding = i; }
|
||||
void iSetVncJpegQuality(int i) { m_iVncJpegQuality = i; }
|
||||
void iSetXdmBroadcastPort(int i) { m_iXdmBroadcastPort = i; }
|
||||
void iSetXdmListPort(int i) { m_iXdmListPort = i; }
|
||||
void iSetXdmQueryPort(int i) { m_iXdmQueryPort = i; }
|
||||
|
||||
void sSetCommandLine(const wxString &s) { m_sCommandLine = s; }
|
||||
void sSetCupsPath(const wxString &s) { m_sCupsPath = s; }
|
||||
void sSetFileName(const wxString &s) { m_sFileName = s; }
|
||||
void sSetGuestUser(const wxString &s) { m_sGuestUser = s; }
|
||||
void sSetGuestPassword(const wxString &s) { m_sGuestPassword = s; }
|
||||
void sSetKbdLayoutLanguage(const wxString &s) { m_sKbdLayoutLanguage = s; }
|
||||
void sSetName(const wxString &s) { m_sName = s; }
|
||||
void sSetPassword(const wxString &s) { m_sPassword = s; }
|
||||
void sSetProxyCommand(const wxString &s) { m_sProxyCommand = s; }
|
||||
void sSetProxyHost(const wxString &s) { m_sProxyHost = s; }
|
||||
void sSetProxyPass(const wxString &s) { m_sProxyPass = s; }
|
||||
void sSetProxyUser(const wxString &s) { m_sProxyUser = s; }
|
||||
void sSetRdpApplication(const wxString &s) { m_sRdpApplication = s; }
|
||||
void sSetRdpDomain(const wxString &s) { m_sRdpDomain = s; }
|
||||
void sSetRdpHostName(const wxString &s) { m_sRdpHostName = s; }
|
||||
void sSetRdpPassword(const wxString &s) { m_sRdpPassword = s; }
|
||||
void sSetRdpUsername(const wxString &s) { m_sRdpUsername = s; }
|
||||
void sSetServerHost(const wxString &s) { m_sServerHost = s; }
|
||||
void sSetSshKey(const wxString &s) { m_sSshKey = s; }
|
||||
void sSetVncHostName(const wxString &s) { m_sVncHostName = s; }
|
||||
void sSetVncPassword(const wxString &s) { m_sVncPassword = s; }
|
||||
void sSetXdmListHost(const wxString &s) { m_sXdmListHost = s; }
|
||||
void sSetXdmQueryHost(const wxString &s) { m_sXdmQueryHost = s; }
|
||||
|
||||
void aSetShareGroups(const ArrayOfShareGroups &a) { m_aShareGroups = a; }
|
||||
void aSetUsedShareGroups(const wxArrayString &a) { m_aUsedShareGroups = a; }
|
||||
void aSetUsbForwards(const ArrayOfUsbForwards &a) { m_aUsbForwards = a; }
|
||||
|
||||
void sSetUsername(const wxString &s);
|
||||
|
||||
static wxString UrlEsc(const wxString &s);
|
||||
|
||||
private:
|
||||
static size_t CurlWriteCallback(void *, size_t, size_t, void *);
|
||||
|
||||
private:
|
||||
// Disable copy constructor
|
||||
MyXmlConfig(const MyXmlConfig &);
|
||||
|
||||
void init();
|
||||
bool getBool(wxXmlNode *, const wxString &, bool defval = false);
|
||||
long getLong(wxXmlNode *, const wxString &, long defval = 0);
|
||||
bool getLongBool(wxXmlNode *, const wxString &, bool defval = false);
|
||||
wxString getString(wxXmlNode *, const wxString &, const wxString &defval = _T(""));
|
||||
wxString getPassword(wxXmlNode *, const wxString &, const wxString &defval = _T(""));
|
||||
wxString *getStringNew(wxXmlNode *, const wxString &, wxString *defval = NULL);
|
||||
bool cmpShareGroups(const ArrayOfShareGroups, const ArrayOfShareGroups);
|
||||
bool cmpUsbForwards(const ArrayOfUsbForwards, const ArrayOfUsbForwards);
|
||||
bool cmpUsedShareGroups(const wxArrayString, const wxArrayString);
|
||||
ShareGroup &findShare(const wxString &);
|
||||
void bAddOption(wxXmlNode *, const wxString &, const bool);
|
||||
void iAddOption(wxXmlNode *, const wxString &, const long);
|
||||
void iAddOptionBool(wxXmlNode *, const wxString &, const bool);
|
||||
void sAddOption(wxXmlNode *, const wxString &, const wxString &);
|
||||
wxXmlNode *AddGroup(wxXmlNode *, const wxString &);
|
||||
bool loadFromStream(wxInputStream &is, bool);
|
||||
void getDesktopSize(int &dw, int &dh, int &ww, int &wh);
|
||||
|
||||
// Special: This gets set, if a pre 0.16.173 "Images" section was detected
|
||||
// during reading. If this is set, we inform the user, suggesting a re-check
|
||||
// of his image settings.
|
||||
bool m_bOldConfig;
|
||||
|
||||
bool m_bDisableBackingstore;
|
||||
bool m_bDisableComposite;
|
||||
bool m_bDisableRender;
|
||||
bool m_bDisableShmem;
|
||||
bool m_bDisableShpix;
|
||||
bool m_bDisableTaint;
|
||||
bool m_bDisableTcpNoDelay;
|
||||
bool m_bDisableXagent;
|
||||
bool m_bDisableZlibCompression;
|
||||
bool m_bEnableMultimedia;
|
||||
bool m_bEnableNativePA;
|
||||
bool m_bEnableMonoPA;
|
||||
bool m_bEnableSmbSharing;
|
||||
bool m_bEnableSSL;
|
||||
bool m_bEnableUSBIP;
|
||||
bool m_bExternalProxy;
|
||||
bool m_bGuestMode;
|
||||
bool m_bKbdLayoutOther;
|
||||
bool m_bProxyPassRemember;
|
||||
bool m_bRdpCache;
|
||||
bool m_bRdpRememberPassword;
|
||||
bool m_bRdpRootless;
|
||||
bool m_bRdpRunApplication;
|
||||
bool m_bWritable;
|
||||
bool m_bRememberPassword;
|
||||
bool m_bRemoveOldSessionFiles;
|
||||
bool m_bRunConsole;
|
||||
bool m_bRunXclients;
|
||||
bool m_bUseCups;
|
||||
bool m_bUseCustomImageEncoding;
|
||||
bool m_bUseProxy;
|
||||
bool m_bUseSmartCard;
|
||||
bool m_bValid;
|
||||
bool m_bVirtualDesktop;
|
||||
bool m_bVncRememberPassword;
|
||||
bool m_bVncRootless;
|
||||
bool m_bVncUseNxAuth;
|
||||
bool m_bDisableDirectDraw;
|
||||
bool m_bGrabKeyboard;
|
||||
bool m_bDisableDeferredUpdates;
|
||||
|
||||
int m_iCupsPort;
|
||||
int m_iDisplayHeight;
|
||||
int m_iDisplayWidth;
|
||||
int m_iImageEncoding;
|
||||
int m_iJpegQuality;
|
||||
int m_iProxyPort;
|
||||
int m_iRdpAuthType;
|
||||
int m_iRdpColors;
|
||||
int m_iRdpImageEncoding;
|
||||
int m_iRdpJpegQuality;
|
||||
int m_iServerPort;
|
||||
int m_iSmbPort;
|
||||
int m_iUsedShareGroups;
|
||||
int m_iVncDisplayNumber;
|
||||
int m_iVncImageEncoding;
|
||||
int m_iVncJpegQuality;
|
||||
int m_iXdmBroadcastPort;
|
||||
int m_iXdmListPort;
|
||||
int m_iXdmQueryPort;
|
||||
int m_iClipFilter;
|
||||
|
||||
wxString m_sCommandLine;
|
||||
wxString m_sCupsPath;
|
||||
wxString m_sFileName;
|
||||
wxString m_sGuestPassword;
|
||||
wxString m_sGuestUser;
|
||||
wxString m_sKbdLayoutLanguage;
|
||||
wxString m_sName;
|
||||
wxString m_sPassword;
|
||||
wxString m_sProxyCommand;
|
||||
wxString m_sProxyHost;
|
||||
wxString m_sProxyPass;
|
||||
wxString m_sProxyUser;
|
||||
wxString m_sRdpApplication;
|
||||
wxString m_sRdpDomain;
|
||||
wxString m_sRdpHostName;
|
||||
wxString m_sRdpPassword;
|
||||
wxString m_sRdpUsername;
|
||||
wxString m_sServerHost;
|
||||
wxString m_sSshKey;
|
||||
wxString m_sUsername;
|
||||
wxString m_sVncHostName;
|
||||
wxString m_sVncPassword;
|
||||
wxString m_sXdmListHost;
|
||||
wxString m_sXdmQueryHost;
|
||||
|
||||
ConnectionSpeed m_eConnectionSpeed;
|
||||
DesktopType m_eDesktopType;
|
||||
DisplayType m_eDisplayType;
|
||||
SessionType m_eSessionType;
|
||||
CacheMemory m_eCacheMemory;
|
||||
CacheDisk m_eCacheDisk;
|
||||
XdmMode m_eXdmMode;
|
||||
RatePA m_eRatePA;
|
||||
|
||||
ArrayOfShareGroups m_aShareGroups;
|
||||
wxArrayString m_aUsedShareGroups;
|
||||
ArrayOfUsbForwards m_aUsbForwards;
|
||||
|
||||
MyXmlConfig *saved;
|
||||
wxString *m_pMd5Password;
|
||||
wxString *m_pClrPassword;
|
||||
};
|
||||
|
||||
#endif
|
||||
// _MYXMLCONFIG_H_
|
||||
103
PAWrapperSimple.cpp
Normal file
103
PAWrapperSimple.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
class pawrapper {
|
||||
public:
|
||||
pawrapper()
|
||||
{
|
||||
wxConfigBase::Get()->Read(wxT("Config/SystemNxDir"), &pactlcmd);
|
||||
pactlcmd << wxFileName::GetPathSeparator() << wxT("bin")
|
||||
<< wxFileName::GetPathSeparator() << wxT("pactl.exe");
|
||||
m_bConnected=wxFileName::IsFileExecutable(pactlcmd);
|
||||
if (m_bConnected) {
|
||||
myLogTrace(MYTRACETAG, wxT("PAWrapper: executable \"%s\" found."),
|
||||
VMB(pactlcmd));
|
||||
pactlcmd << wxT(" -s 127.0.0.1");
|
||||
} else
|
||||
myLogTrace(MYTRACETAG, wxT("PAWrapper: executable \"%s\" not found!"),
|
||||
VMB(pactlcmd));
|
||||
}
|
||||
|
||||
|
||||
bool getdefaults(wxString &Sink, wxString &Source)
|
||||
{
|
||||
wxString cmd; wxArrayString outtxt; bool ret;
|
||||
Sink.Empty(); Source.Empty();
|
||||
cmd << pactlcmd << wxT(" info");
|
||||
int sterr = ::wxExecute(cmd, outtxt, wxEXEC_SYNC);
|
||||
ret = (sterr == 0);
|
||||
if (ret) {
|
||||
for (int i=0; i<outtxt.GetCount(); i++) {
|
||||
wxArrayString tks = ::wxStringTokenize(outtxt[i],wxT(":"));
|
||||
if (tks[0].IsSameAs(wxT("Default Sink")))
|
||||
Sink = tks[1].Trim(false);
|
||||
else if (tks[0].IsSameAs(wxT("Default Source")))
|
||||
Source = tks[1].Trim(false);
|
||||
}
|
||||
} else
|
||||
myLogTrace(MYTRACETAG, wxT("PAWrapper: couldn't get defaults sterr = %d"),
|
||||
sterr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool findmodules(const wxChar *name, wxArrayString &indexes, wxArrayString &args)
|
||||
{
|
||||
wxString cmd, ts; wxArrayString outtxt; bool ret;
|
||||
cmd << pactlcmd << wxT(" list short");
|
||||
int sterr = ::wxExecute(cmd, outtxt, wxEXEC_SYNC);
|
||||
ret = (sterr == 0);
|
||||
if (ret) {
|
||||
for (int i=0; i<outtxt.GetCount(); i++) {
|
||||
wxArrayString tks = ::wxStringTokenize(outtxt[i]);
|
||||
if (tks[1].IsSameAs(name)) {
|
||||
indexes.Add(tks[0]);
|
||||
ts.Empty();
|
||||
for (int j=2; j<tks.GetCount(); j++) {
|
||||
if (j!=2)
|
||||
ts << wxT(" ");
|
||||
ts << tks[j];
|
||||
}
|
||||
args.Add(ts);
|
||||
}
|
||||
}
|
||||
} else
|
||||
myLogTrace(MYTRACETAG, wxT("PAWrapper: couldn't list modules sterr = %d"),
|
||||
sterr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
bool loadmodule(const wxString name, const wxString args)
|
||||
{
|
||||
wxString cmd; wxArrayString outtxt; bool ret;
|
||||
cmd << pactlcmd << wxT(" load-module ")
|
||||
<< name << wxT(" ") << args;
|
||||
int sterr = ::wxExecute(cmd, outtxt, wxEXEC_SYNC);
|
||||
ret = (sterr == 0);
|
||||
if (!ret)
|
||||
myLogTrace(MYTRACETAG, wxT("PAWrapper: couldn't load module %s sterr = %d"),
|
||||
VMB(name), sterr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool unloadmodule(int index)
|
||||
{
|
||||
wxString cmd; wxArrayString outtxt; bool ret;
|
||||
cmd << pactlcmd << wxT(" unload-module ")
|
||||
<< wxString::Format(wxT("%u"),index);
|
||||
int sterr = ::wxExecute(cmd, outtxt, wxEXEC_SYNC);
|
||||
ret = (sterr == 0);
|
||||
if (!ret)
|
||||
myLogTrace(MYTRACETAG, wxT("PAWrapper: couldn't load module id %u; sterr = %d"),
|
||||
index, sterr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool isConnected()
|
||||
{
|
||||
return m_bConnected;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
bool m_bConnected;
|
||||
wxString pactlcmd;
|
||||
|
||||
};
|
||||
179
PanicDialog.cpp
Normal file
179
PanicDialog.cpp
Normal file
@@ -0,0 +1,179 @@
|
||||
// $Id: PanicDialog.cpp 148 2009-02-10 20:04:38Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
||||
#pragma implementation "PanicDialog.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
////@begin includes
|
||||
////@end includes
|
||||
|
||||
#include "PanicDialog.h"
|
||||
|
||||
////@begin XPM images
|
||||
////@end XPM images
|
||||
|
||||
#include <wx/artprov.h>
|
||||
#include "Icon.h"
|
||||
|
||||
/*!
|
||||
* PanicDialog type definition
|
||||
*/
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS( PanicDialog, wxDialog )
|
||||
|
||||
/*!
|
||||
* PanicDialog event table definition
|
||||
*/
|
||||
|
||||
BEGIN_EVENT_TABLE( PanicDialog, wxDialog )
|
||||
|
||||
////@begin PanicDialog event table entries
|
||||
////@end PanicDialog event table entries
|
||||
|
||||
END_EVENT_TABLE()
|
||||
|
||||
/*!
|
||||
* PanicDialog constructors
|
||||
*/
|
||||
|
||||
PanicDialog::PanicDialog( )
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
PanicDialog::PanicDialog( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
||||
{
|
||||
Init();
|
||||
Create(parent, id, caption, pos, size, style);
|
||||
}
|
||||
|
||||
/*!
|
||||
* PanicDialog creator
|
||||
*/
|
||||
|
||||
bool PanicDialog::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
||||
{
|
||||
////@begin PanicDialog creation
|
||||
SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS);
|
||||
SetParent(parent);
|
||||
CreateControls();
|
||||
SetIcon(GetIconResource(wxT("res/nx.png")));
|
||||
if (GetSizer())
|
||||
{
|
||||
GetSizer()->SetSizeHints(this);
|
||||
}
|
||||
Centre();
|
||||
////@end PanicDialog creation
|
||||
wxUnusedVar(style);
|
||||
wxUnusedVar(size);
|
||||
wxUnusedVar(pos);
|
||||
wxUnusedVar(caption);
|
||||
wxUnusedVar(id);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Member initialisation
|
||||
*/
|
||||
|
||||
void PanicDialog::Init()
|
||||
{
|
||||
////@begin PanicDialog member initialisation
|
||||
m_iDialogClass = wxICON_WARNING;
|
||||
m_sMessage = wxEmptyString;
|
||||
m_pCtrlBitmap = NULL;
|
||||
m_pCtrlMessage = NULL;
|
||||
////@end PanicDialog member initialisation
|
||||
}
|
||||
/*!
|
||||
* Control creation for PanicDialog
|
||||
*/
|
||||
|
||||
void PanicDialog::CreateControls()
|
||||
{
|
||||
////@begin PanicDialog content construction
|
||||
if (!wxXmlResource::Get()->LoadDialog(this, GetParent(), _T("ID_PANICDIALOG")))
|
||||
wxLogError(wxT("Missing wxXmlResource::Get()->Load() in OnInit()?"));
|
||||
m_pCtrlBitmap = XRCCTRL(*this, "wxID_STATIC_BITMAP", wxStaticBitmap);
|
||||
m_pCtrlMessage = XRCCTRL(*this, "wxID_STATIC", wxStaticText);
|
||||
////@end PanicDialog content construction
|
||||
|
||||
// Create custom windows not generated automatically here.
|
||||
////@begin PanicDialog content initialisation
|
||||
////@end PanicDialog content initialisation
|
||||
|
||||
wxArtID artid = wxART_WARNING;
|
||||
switch (m_iDialogClass) {
|
||||
case wxICON_INFORMATION:
|
||||
artid = wxART_INFORMATION;
|
||||
break;
|
||||
case wxICON_ERROR:
|
||||
artid = wxART_ERROR;
|
||||
break;
|
||||
}
|
||||
m_pCtrlBitmap->SetBitmap(wxArtProvider::GetBitmap(artid, wxART_MESSAGE_BOX));
|
||||
m_pCtrlMessage->SetLabel(m_sMessage);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Should we show tooltips?
|
||||
*/
|
||||
|
||||
bool PanicDialog::ShowToolTips()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get bitmap resources
|
||||
*/
|
||||
|
||||
wxBitmap PanicDialog::GetBitmapResource( const wxString& name )
|
||||
{
|
||||
// Bitmap retrieval
|
||||
return CreateBitmapFromFile(name);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get icon resources
|
||||
*/
|
||||
|
||||
wxIcon PanicDialog::GetIconResource( const wxString& name )
|
||||
{
|
||||
// Icon retrieval
|
||||
return CreateIconFromFile(name);
|
||||
}
|
||||
121
PanicDialog.h
Normal file
121
PanicDialog.h
Normal file
@@ -0,0 +1,121 @@
|
||||
// $Id: PanicDialog.h 683 2012-02-09 23:37:19Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _PANICDIALOG_H_
|
||||
#define _PANICDIALOG_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
||||
#pragma interface "PanicDialog.h"
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* Includes
|
||||
*/
|
||||
|
||||
////@begin includes
|
||||
#include "PanicDialog_symbols.h"
|
||||
#include "wx/xrc/xmlres.h"
|
||||
////@end includes
|
||||
|
||||
/*!
|
||||
* Forward declarations
|
||||
*/
|
||||
|
||||
////@begin forward declarations
|
||||
////@end forward declarations
|
||||
|
||||
/*!
|
||||
* Control identifiers
|
||||
*/
|
||||
|
||||
////@begin control identifiers
|
||||
#define ID_PANICDIALOG 10149
|
||||
#define SYMBOL_PANICDIALOG_STYLE wxCAPTION|wxSYSTEM_MENU|wxSTAY_ON_TOP|wxCLOSE_BOX
|
||||
#define SYMBOL_PANICDIALOG_TITLE _T("")
|
||||
#define SYMBOL_PANICDIALOG_IDNAME ID_PANICDIALOG
|
||||
#define SYMBOL_PANICDIALOG_SIZE wxSize(400, 300)
|
||||
#define SYMBOL_PANICDIALOG_POSITION wxDefaultPosition
|
||||
////@end control identifiers
|
||||
|
||||
/*!
|
||||
* Compatibility
|
||||
*/
|
||||
|
||||
#ifndef wxCLOSE_BOX
|
||||
#define wxCLOSE_BOX 0x1000
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* PanicDialog class declaration
|
||||
*/
|
||||
|
||||
class PanicDialog: public wxDialog
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS( PanicDialog )
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
public:
|
||||
/// Constructors
|
||||
PanicDialog( );
|
||||
PanicDialog( wxWindow* parent, wxWindowID id = SYMBOL_PANICDIALOG_IDNAME, const wxString& caption = SYMBOL_PANICDIALOG_TITLE, const wxPoint& pos = SYMBOL_PANICDIALOG_POSITION, const wxSize& size = SYMBOL_PANICDIALOG_SIZE, long style = SYMBOL_PANICDIALOG_STYLE );
|
||||
|
||||
/// Creation
|
||||
bool Create( wxWindow* parent, wxWindowID id = SYMBOL_PANICDIALOG_IDNAME, const wxString& caption = SYMBOL_PANICDIALOG_TITLE, const wxPoint& pos = SYMBOL_PANICDIALOG_POSITION, const wxSize& size = SYMBOL_PANICDIALOG_SIZE, long style = SYMBOL_PANICDIALOG_STYLE );
|
||||
|
||||
/// Initialises member variables
|
||||
void Init();
|
||||
|
||||
/// Creates the controls and sizers
|
||||
void CreateControls();
|
||||
|
||||
////@begin PanicDialog event handler declarations
|
||||
|
||||
////@end PanicDialog event handler declarations
|
||||
|
||||
////@begin PanicDialog member function declarations
|
||||
|
||||
int GetDialogClass() const { return m_iDialogClass ; }
|
||||
void SetDialogClass(int value) { m_iDialogClass = value ; }
|
||||
|
||||
wxString GetMessage() const { return m_sMessage ; }
|
||||
void SetMessage(wxString value) { m_sMessage = value ; }
|
||||
|
||||
/// Retrieves bitmap resources
|
||||
wxBitmap GetBitmapResource( const wxString& name );
|
||||
|
||||
/// Retrieves icon resources
|
||||
wxIcon GetIconResource( const wxString& name );
|
||||
////@end PanicDialog member function declarations
|
||||
|
||||
/// Should we show tooltips?
|
||||
static bool ShowToolTips();
|
||||
|
||||
////@begin PanicDialog member variables
|
||||
wxStaticBitmap* m_pCtrlBitmap;
|
||||
wxStaticText* m_pCtrlMessage;
|
||||
private:
|
||||
int m_iDialogClass;
|
||||
wxString m_sMessage;
|
||||
////@end PanicDialog member variables
|
||||
};
|
||||
|
||||
#endif
|
||||
// _PANICDIALOG_H_
|
||||
23
PanicDialog_symbols.h
Normal file
23
PanicDialog_symbols.h
Normal file
@@ -0,0 +1,23 @@
|
||||
// $Id: PanicDialog_symbols.h 216 2009-04-16 01:46:25Z felfert $
|
||||
//
|
||||
// Copyright (C) 2009 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#define ID_PANICDIALOG_SYMBOL_0 _("&Terminate")
|
||||
#define ID_PANICDIALOG_SYMBOL_1 _("&Cancel")
|
||||
181
ProxyPasswordDialog.cpp
Normal file
181
ProxyPasswordDialog.cpp
Normal file
@@ -0,0 +1,181 @@
|
||||
// $Id: ProxyPasswordDialog.cpp 455 2010-01-30 03:26:11Z felfert $
|
||||
//
|
||||
// Copyright (C) 2010 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
||||
#pragma implementation "ProxyPasswordDialog.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
////@begin includes
|
||||
////@end includes
|
||||
|
||||
#include "ProxyPasswordDialog.h"
|
||||
|
||||
////@begin XPM images
|
||||
////@end XPM images
|
||||
|
||||
|
||||
/*!
|
||||
* ProxyPasswordDialog type definition
|
||||
*/
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS( ProxyPasswordDialog, wxDialog )
|
||||
|
||||
|
||||
/*!
|
||||
* ProxyPasswordDialog event table definition
|
||||
*/
|
||||
|
||||
BEGIN_EVENT_TABLE( ProxyPasswordDialog, wxDialog )
|
||||
|
||||
////@begin ProxyPasswordDialog event table entries
|
||||
////@end ProxyPasswordDialog event table entries
|
||||
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
/*!
|
||||
* ProxyPasswordDialog constructors
|
||||
*/
|
||||
|
||||
ProxyPasswordDialog::ProxyPasswordDialog()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
ProxyPasswordDialog::ProxyPasswordDialog( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
||||
{
|
||||
Init();
|
||||
Create(parent, id, caption, pos, size, style);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* ProxyPasswordDialog creator
|
||||
*/
|
||||
|
||||
bool ProxyPasswordDialog::Create( wxWindow* parent, wxWindowID WXUNUSED(id), const wxString& WXUNUSED(caption), const wxPoint& WXUNUSED(pos), const wxSize& WXUNUSED(size), long WXUNUSED(style) )
|
||||
{
|
||||
////@begin ProxyPasswordDialog creation
|
||||
SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY|wxWS_EX_BLOCK_EVENTS);
|
||||
SetParent(parent);
|
||||
CreateControls();
|
||||
SetIcon(GetIconResource(wxT("res/nx.png")));
|
||||
if (GetSizer())
|
||||
{
|
||||
GetSizer()->SetSizeHints(this);
|
||||
}
|
||||
Centre();
|
||||
////@end ProxyPasswordDialog creation
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* ProxyPasswordDialog destructor
|
||||
*/
|
||||
|
||||
ProxyPasswordDialog::~ProxyPasswordDialog()
|
||||
{
|
||||
////@begin ProxyPasswordDialog destruction
|
||||
////@end ProxyPasswordDialog destruction
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* Member initialisation
|
||||
*/
|
||||
|
||||
void ProxyPasswordDialog::Init()
|
||||
{
|
||||
////@begin ProxyPasswordDialog member initialisation
|
||||
////@end ProxyPasswordDialog member initialisation
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* Control creation for ProxyPasswordDialog
|
||||
*/
|
||||
|
||||
void ProxyPasswordDialog::CreateControls()
|
||||
{
|
||||
////@begin ProxyPasswordDialog content construction
|
||||
if (!wxXmlResource::Get()->LoadDialog(this, GetParent(), _T("ID_PROXYPASSWORDDIALOG")))
|
||||
wxLogError(wxT("Missing wxXmlResource::Get()->Load() in OnInit()?"));
|
||||
// Set validators
|
||||
if (FindWindow(XRCID("ID_TEXTCTRL_PROXYPASS2")))
|
||||
FindWindow(XRCID("ID_TEXTCTRL_PROXYPASS2"))->SetValidator( wxTextValidator(wxFILTER_NONE, & m_sPassword) );
|
||||
////@end ProxyPasswordDialog content construction
|
||||
|
||||
// Create custom windows not generated automatically here.
|
||||
if (FindWindow(XRCID("ID_TEXTCTRL_PROXYPASS2")))
|
||||
FindWindow(XRCID("ID_TEXTCTRL_PROXYPASS2"))->SetFocus();
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* Should we show tooltips?
|
||||
*/
|
||||
|
||||
bool ProxyPasswordDialog::ShowToolTips()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get bitmap resources
|
||||
*/
|
||||
|
||||
wxBitmap ProxyPasswordDialog::GetBitmapResource( const wxString& name )
|
||||
{
|
||||
// Bitmap retrieval
|
||||
////@begin ProxyPasswordDialog bitmap retrieval
|
||||
wxUnusedVar(name);
|
||||
return wxNullBitmap;
|
||||
////@end ProxyPasswordDialog bitmap retrieval
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get icon resources
|
||||
*/
|
||||
|
||||
wxIcon ProxyPasswordDialog::GetIconResource( const wxString& name )
|
||||
{
|
||||
// Icon retrieval
|
||||
////@begin ProxyPasswordDialog icon retrieval
|
||||
wxUnusedVar(name);
|
||||
return wxNullIcon;
|
||||
////@end ProxyPasswordDialog icon retrieval
|
||||
}
|
||||
112
ProxyPasswordDialog.h
Normal file
112
ProxyPasswordDialog.h
Normal file
@@ -0,0 +1,112 @@
|
||||
// $Id: ProxyPasswordDialog.h 449 2010-01-24 21:43:59Z felfert $
|
||||
//
|
||||
// Copyright (C) 2010 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _PROXYPASSWORDDIALOG_H_
|
||||
#define _PROXYPASSWORDDIALOG_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
||||
#pragma interface "ProxyPasswordDialog.h"
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* Includes
|
||||
*/
|
||||
|
||||
////@begin includes
|
||||
#include "ProxyPasswordDialog_symbols.h"
|
||||
#include "wx/xrc/xmlres.h"
|
||||
#include "wx/valtext.h"
|
||||
////@end includes
|
||||
|
||||
/*!
|
||||
* Forward declarations
|
||||
*/
|
||||
|
||||
////@begin forward declarations
|
||||
////@end forward declarations
|
||||
|
||||
/*!
|
||||
* Control identifiers
|
||||
*/
|
||||
|
||||
////@begin control identifiers
|
||||
#define ID_PROXYPASSWORDDIALOG 10184
|
||||
#define SYMBOL_PROXYPASSWORDDIALOG_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxSTAY_ON_TOP|wxCLOSE_BOX|wxTAB_TRAVERSAL
|
||||
#define SYMBOL_PROXYPASSWORDDIALOG_TITLE _("HTTP proxy password - OpenNX")
|
||||
#define SYMBOL_PROXYPASSWORDDIALOG_IDNAME ID_PROXYPASSWORDDIALOG
|
||||
#define SYMBOL_PROXYPASSWORDDIALOG_SIZE wxSize(400, 300)
|
||||
#define SYMBOL_PROXYPASSWORDDIALOG_POSITION wxDefaultPosition
|
||||
////@end control identifiers
|
||||
|
||||
|
||||
/*!
|
||||
* ProxyPasswordDialog class declaration
|
||||
*/
|
||||
|
||||
class ProxyPasswordDialog: public wxDialog
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS( ProxyPasswordDialog )
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
public:
|
||||
/// Constructors
|
||||
ProxyPasswordDialog();
|
||||
ProxyPasswordDialog( wxWindow* parent, wxWindowID id = SYMBOL_PROXYPASSWORDDIALOG_IDNAME, const wxString& caption = SYMBOL_PROXYPASSWORDDIALOG_TITLE, const wxPoint& pos = SYMBOL_PROXYPASSWORDDIALOG_POSITION, const wxSize& size = SYMBOL_PROXYPASSWORDDIALOG_SIZE, long style = SYMBOL_PROXYPASSWORDDIALOG_STYLE );
|
||||
|
||||
/// Creation
|
||||
bool Create( wxWindow* parent, wxWindowID id = SYMBOL_PROXYPASSWORDDIALOG_IDNAME, const wxString& caption = SYMBOL_PROXYPASSWORDDIALOG_TITLE, const wxPoint& pos = SYMBOL_PROXYPASSWORDDIALOG_POSITION, const wxSize& size = SYMBOL_PROXYPASSWORDDIALOG_SIZE, long style = SYMBOL_PROXYPASSWORDDIALOG_STYLE );
|
||||
|
||||
/// Destructor
|
||||
~ProxyPasswordDialog();
|
||||
|
||||
/// Initialises member variables
|
||||
void Init();
|
||||
|
||||
/// Creates the controls and sizers
|
||||
void CreateControls();
|
||||
|
||||
////@begin ProxyPasswordDialog event handler declarations
|
||||
|
||||
////@end ProxyPasswordDialog event handler declarations
|
||||
|
||||
////@begin ProxyPasswordDialog member function declarations
|
||||
|
||||
wxString GetPassword() const { return m_sPassword ; }
|
||||
void SetPassword(wxString value) { m_sPassword = value ; }
|
||||
|
||||
/// Retrieves bitmap resources
|
||||
wxBitmap GetBitmapResource( const wxString& name );
|
||||
|
||||
/// Retrieves icon resources
|
||||
wxIcon GetIconResource( const wxString& name );
|
||||
////@end ProxyPasswordDialog member function declarations
|
||||
|
||||
/// Should we show tooltips?
|
||||
static bool ShowToolTips();
|
||||
|
||||
////@begin ProxyPasswordDialog member variables
|
||||
private:
|
||||
wxString m_sPassword;
|
||||
////@end ProxyPasswordDialog member variables
|
||||
};
|
||||
|
||||
#endif
|
||||
// _PROXYPASSWORDDIALOG_H_
|
||||
26
ProxyPasswordDialog_symbols.h
Normal file
26
ProxyPasswordDialog_symbols.h
Normal file
@@ -0,0 +1,26 @@
|
||||
// $Id: ProxyPasswordDialog_symbols.h 476 2010-02-10 00:06:14Z felfert $
|
||||
//
|
||||
// Copyright (C) 2010 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#define ID_PROXYPASSWORDDIALOG_SYMBOL_0 _("HTTP proxy password - OpenNX")
|
||||
#define ID_PROXYPASSWORDDIALOG_SYMBOL_1 _("Please enter your HTTP proxy password")
|
||||
#define ID_PROXYPASSWORDDIALOG_SYMBOL_2 _("Password")
|
||||
#define ID_PROXYPASSWORDDIALOG_SYMBOL_3 _("&OK")
|
||||
#define ID_PROXYPASSWORDDIALOG_SYMBOL_4 _("&Cancel")
|
||||
281
ProxyPropertyDialog.cpp
Normal file
281
ProxyPropertyDialog.cpp
Normal file
@@ -0,0 +1,281 @@
|
||||
// $Id: ProxyPropertyDialog.cpp 647 2011-06-23 17:52:29Z felfert $
|
||||
//
|
||||
// Copyright (C) 2010 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
||||
#pragma implementation "ProxyPropertyDialog.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#include <wx/cshelp.h>
|
||||
#include <wx/config.h>
|
||||
|
||||
////@begin includes
|
||||
////@end includes
|
||||
|
||||
#include "ProxyPropertyDialog.h"
|
||||
#include "MyValidator.h"
|
||||
#include "opennxApp.h"
|
||||
|
||||
////@begin XPM images
|
||||
////@end XPM images
|
||||
|
||||
|
||||
/*!
|
||||
* ProxyPropertyDialog type definition
|
||||
*/
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS( ProxyPropertyDialog, wxDialog )
|
||||
|
||||
|
||||
/*!
|
||||
* ProxyPropertyDialog event table definition
|
||||
*/
|
||||
|
||||
BEGIN_EVENT_TABLE( ProxyPropertyDialog, wxDialog )
|
||||
|
||||
////@begin ProxyPropertyDialog event table entries
|
||||
EVT_RADIOBUTTON( XRCID("ID_RADIOBUTTON_HTTPPROXY"), ProxyPropertyDialog::OnRadiobuttonHttpproxySelected )
|
||||
|
||||
EVT_RADIOBUTTON( XRCID("ID_RADIOBUTTON_EXTERNALPROXY"), ProxyPropertyDialog::OnRadiobuttonExternalproxySelected )
|
||||
|
||||
////@end ProxyPropertyDialog event table entries
|
||||
//
|
||||
EVT_MENU(wxID_CONTEXT_HELP, ProxyPropertyDialog::OnContextHelp)
|
||||
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
/*!
|
||||
* ProxyPropertyDialog constructors
|
||||
*/
|
||||
|
||||
ProxyPropertyDialog::ProxyPropertyDialog()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
ProxyPropertyDialog::ProxyPropertyDialog( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
||||
{
|
||||
Init();
|
||||
Create(parent, id, caption, pos, size, style);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* ProxyPropertyDialog creator
|
||||
*/
|
||||
|
||||
bool ProxyPropertyDialog::Create( wxWindow* parent, wxWindowID, const wxString&, const wxPoint&, const wxSize&, long )
|
||||
{
|
||||
////@begin ProxyPropertyDialog creation
|
||||
SetExtraStyle(wxWS_EX_BLOCK_EVENTS|wxDIALOG_EX_CONTEXTHELP);
|
||||
SetParent(parent);
|
||||
CreateControls();
|
||||
if (GetSizer())
|
||||
{
|
||||
GetSizer()->SetSizeHints(this);
|
||||
}
|
||||
Centre();
|
||||
////@end ProxyPropertyDialog creation
|
||||
::wxGetApp().EnableContextHelp(this);
|
||||
wxString d;
|
||||
wxConfigBase::Get()->Read(wxT("Config/SystemNxDir"), &d);
|
||||
wxFileName hfile(d, wxT("pconnect.html"));
|
||||
hfile.AppendDir(wxT("share"));
|
||||
hfile.MakeAbsolute();
|
||||
m_pProxyCmdHelp->SetURL(hfile.GetFullPath().Prepend(wxT("file://")));
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* ProxyPropertyDialog destructor
|
||||
*/
|
||||
|
||||
ProxyPropertyDialog::~ProxyPropertyDialog()
|
||||
{
|
||||
////@begin ProxyPropertyDialog destruction
|
||||
////@end ProxyPropertyDialog destruction
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* Member initialisation
|
||||
*/
|
||||
|
||||
void ProxyPropertyDialog::Init()
|
||||
{
|
||||
////@begin ProxyPropertyDialog member initialisation
|
||||
m_bUseProxy = true;
|
||||
m_iProxyPort = 3128;
|
||||
m_bProxyPassRemember = false;
|
||||
m_bExternalProxy = false;
|
||||
m_pCtrlProxyHost = NULL;
|
||||
m_pCtrlProxyPort = NULL;
|
||||
m_pCtrlProxyUser = NULL;
|
||||
m_pCtrlProxyPass = NULL;
|
||||
m_pCtrlProxyPassRemember = NULL;
|
||||
m_pCtrlProxyCommand = NULL;
|
||||
m_pProxyCmdHelp = NULL;
|
||||
////@end ProxyPropertyDialog member initialisation
|
||||
}
|
||||
|
||||
/*!
|
||||
* Control creation for ProxyPropertyDialog
|
||||
*/
|
||||
|
||||
void ProxyPropertyDialog::CreateControls()
|
||||
{
|
||||
////@begin ProxyPropertyDialog content construction
|
||||
if (!wxXmlResource::Get()->LoadDialog(this, GetParent(), _T("ID_PROXYPROPERTYDIALOG")))
|
||||
wxLogError(wxT("Missing wxXmlResource::Get()->Load() in OnInit()?"));
|
||||
m_pCtrlProxyHost = XRCCTRL(*this, "ID_TEXTCTRL_PROXYHOST", wxTextCtrl);
|
||||
m_pCtrlProxyPort = XRCCTRL(*this, "ID_SPINCTRL_PROXYPORT", wxSpinCtrl);
|
||||
m_pCtrlProxyUser = XRCCTRL(*this, "ID_TEXTCTRL_PROXYUSER", wxTextCtrl);
|
||||
m_pCtrlProxyPass = XRCCTRL(*this, "ID_TEXTCTRL_PROXYPASS", wxTextCtrl);
|
||||
m_pCtrlProxyPassRemember = XRCCTRL(*this, "ID_CHECKBOX_PROXYPASS_REMEMBER", wxCheckBox);
|
||||
m_pCtrlProxyCommand = XRCCTRL(*this, "ID_TEXTCTRL_PROXYCOMMAND", wxTextCtrl);
|
||||
m_pProxyCmdHelp = XRCCTRL(*this, "ID_HYPERLINKCTRL", wxHyperlinkCtrl);
|
||||
// Set validators
|
||||
if (FindWindow(XRCID("ID_RADIOBUTTON_HTTPPROXY")))
|
||||
FindWindow(XRCID("ID_RADIOBUTTON_HTTPPROXY"))->SetValidator( wxGenericValidator(& m_bUseProxy) );
|
||||
if (FindWindow(XRCID("ID_TEXTCTRL_PROXYHOST")))
|
||||
FindWindow(XRCID("ID_TEXTCTRL_PROXYHOST"))->SetValidator( MyValidator(MyValidator::MYVAL_HOST, & m_sProxyHost) );
|
||||
if (FindWindow(XRCID("ID_SPINCTRL_PROXYPORT")))
|
||||
FindWindow(XRCID("ID_SPINCTRL_PROXYPORT"))->SetValidator( wxGenericValidator(& m_iProxyPort) );
|
||||
if (FindWindow(XRCID("ID_TEXTCTRL_PROXYUSER")))
|
||||
FindWindow(XRCID("ID_TEXTCTRL_PROXYUSER"))->SetValidator( wxTextValidator(wxFILTER_NONE, & m_sProxyUser) );
|
||||
if (FindWindow(XRCID("ID_TEXTCTRL_PROXYPASS")))
|
||||
FindWindow(XRCID("ID_TEXTCTRL_PROXYPASS"))->SetValidator( wxTextValidator(wxFILTER_NONE, & m_sProxyPass) );
|
||||
if (FindWindow(XRCID("ID_CHECKBOX_PROXYPASS_REMEMBER")))
|
||||
FindWindow(XRCID("ID_CHECKBOX_PROXYPASS_REMEMBER"))->SetValidator( wxGenericValidator(& m_bProxyPassRemember) );
|
||||
if (FindWindow(XRCID("ID_RADIOBUTTON_EXTERNALPROXY")))
|
||||
FindWindow(XRCID("ID_RADIOBUTTON_EXTERNALPROXY"))->SetValidator( wxGenericValidator(& m_bExternalProxy) );
|
||||
if (FindWindow(XRCID("ID_TEXTCTRL_PROXYCOMMAND")))
|
||||
FindWindow(XRCID("ID_TEXTCTRL_PROXYCOMMAND"))->SetValidator( wxTextValidator(wxFILTER_NONE, & m_sProxyCommand) );
|
||||
////@end ProxyPropertyDialog content construction
|
||||
|
||||
// Create custom windows not generated automatically here.
|
||||
////@begin ProxyPropertyDialog content initialisation
|
||||
////@end ProxyPropertyDialog content initialisation
|
||||
}
|
||||
|
||||
void ProxyPropertyDialog::UpdateDialogConstraints()
|
||||
{
|
||||
if (m_pCtrlProxyHost)
|
||||
m_pCtrlProxyHost->Enable(m_bUseProxy);
|
||||
if (m_pCtrlProxyPort)
|
||||
m_pCtrlProxyPort->Enable(m_bUseProxy);
|
||||
if (m_pCtrlProxyUser)
|
||||
m_pCtrlProxyUser->Enable(m_bUseProxy);
|
||||
if (m_pCtrlProxyPass)
|
||||
m_pCtrlProxyPass->Enable(m_bUseProxy);
|
||||
if (m_pCtrlProxyPassRemember)
|
||||
m_pCtrlProxyPassRemember->Enable(m_bUseProxy);
|
||||
if (m_pCtrlProxyCommand)
|
||||
m_pCtrlProxyCommand->Enable(m_bExternalProxy);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Should we show tooltips?
|
||||
*/
|
||||
|
||||
bool ProxyPropertyDialog::ShowToolTips()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get bitmap resources
|
||||
*/
|
||||
|
||||
wxBitmap ProxyPropertyDialog::GetBitmapResource( const wxString& name )
|
||||
{
|
||||
// Bitmap retrieval
|
||||
////@begin ProxyPropertyDialog bitmap retrieval
|
||||
wxUnusedVar(name);
|
||||
return wxNullBitmap;
|
||||
////@end ProxyPropertyDialog bitmap retrieval
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get icon resources
|
||||
*/
|
||||
|
||||
wxIcon ProxyPropertyDialog::GetIconResource( const wxString& name )
|
||||
{
|
||||
// Icon retrieval
|
||||
////@begin ProxyPropertyDialog icon retrieval
|
||||
wxUnusedVar(name);
|
||||
return wxNullIcon;
|
||||
////@end ProxyPropertyDialog icon retrieval
|
||||
}
|
||||
|
||||
void ProxyPropertyDialog::OnContextHelp(wxCommandEvent &)
|
||||
{
|
||||
wxContextHelp contextHelp(this);
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RADIOBUTTON_HTTPPROXY
|
||||
*/
|
||||
|
||||
void ProxyPropertyDialog::OnRadiobuttonHttpproxySelected( wxCommandEvent& event )
|
||||
{
|
||||
m_pCtrlProxyHost->Enable(true);
|
||||
m_pCtrlProxyPort->Enable(true);
|
||||
m_pCtrlProxyUser->Enable(true);
|
||||
m_pCtrlProxyPass->Enable(true);
|
||||
m_pCtrlProxyPassRemember->Enable(true);
|
||||
m_pCtrlProxyCommand->Enable(false);
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RADIOBUTTON_EXTERNALPROXY
|
||||
*/
|
||||
|
||||
void ProxyPropertyDialog::OnRadiobuttonExternalproxySelected( wxCommandEvent& event )
|
||||
{
|
||||
m_pCtrlProxyHost->Enable(false);
|
||||
m_pCtrlProxyPort->Enable(false);
|
||||
m_pCtrlProxyUser->Enable(false);
|
||||
m_pCtrlProxyPass->Enable(false);
|
||||
m_pCtrlProxyPassRemember->Enable(false);
|
||||
m_pCtrlProxyCommand->Enable(true);
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
|
||||
|
||||
163
ProxyPropertyDialog.h
Normal file
163
ProxyPropertyDialog.h
Normal file
@@ -0,0 +1,163 @@
|
||||
// $Id: ProxyPropertyDialog.h 653 2011-12-07 15:39:54Z felfert $
|
||||
//
|
||||
// Copyright (C) 2010 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _PROXYPROPERTYDIALOG_H_
|
||||
#define _PROXYPROPERTYDIALOG_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
||||
#pragma interface "ProxyPropertyDialog.h"
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* Includes
|
||||
*/
|
||||
|
||||
////@begin includes
|
||||
#include "ProxyPropertyDialog_symbols.h"
|
||||
#include "wx/xrc/xmlres.h"
|
||||
#include "wx/valgen.h"
|
||||
#include "wx/spinctrl.h"
|
||||
#include "wx/valtext.h"
|
||||
#include "wx/hyperlink.h"
|
||||
#include "wx/statline.h"
|
||||
////@end includes
|
||||
|
||||
/*!
|
||||
* Forward declarations
|
||||
*/
|
||||
|
||||
////@begin forward declarations
|
||||
class wxSpinCtrl;
|
||||
class wxHyperlinkCtrl;
|
||||
////@end forward declarations
|
||||
|
||||
/*!
|
||||
* Control identifiers
|
||||
*/
|
||||
|
||||
////@begin control identifiers
|
||||
#define ID_PROXYPROPERTYDIALOG 10083
|
||||
#define SYMBOL_PROXYPROPERTYDIALOG_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL
|
||||
#define SYMBOL_PROXYPROPERTYDIALOG_TITLE _("Proxy settings - OpenNX")
|
||||
#define SYMBOL_PROXYPROPERTYDIALOG_IDNAME ID_PROXYPROPERTYDIALOG
|
||||
#define SYMBOL_PROXYPROPERTYDIALOG_SIZE wxSize(400, 300)
|
||||
#define SYMBOL_PROXYPROPERTYDIALOG_POSITION wxDefaultPosition
|
||||
////@end control identifiers
|
||||
|
||||
|
||||
/*!
|
||||
* ProxyPropertyDialog class declaration
|
||||
*/
|
||||
|
||||
class ProxyPropertyDialog: public wxDialog
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS( ProxyPropertyDialog )
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
public:
|
||||
/// Constructors
|
||||
ProxyPropertyDialog();
|
||||
ProxyPropertyDialog( wxWindow* parent, wxWindowID id = SYMBOL_PROXYPROPERTYDIALOG_IDNAME, const wxString& caption = SYMBOL_PROXYPROPERTYDIALOG_TITLE, const wxPoint& pos = SYMBOL_PROXYPROPERTYDIALOG_POSITION, const wxSize& size = SYMBOL_PROXYPROPERTYDIALOG_SIZE, long style = SYMBOL_PROXYPROPERTYDIALOG_STYLE );
|
||||
|
||||
/// Creation
|
||||
bool Create( wxWindow* parent, wxWindowID id = SYMBOL_PROXYPROPERTYDIALOG_IDNAME, const wxString& caption = SYMBOL_PROXYPROPERTYDIALOG_TITLE, const wxPoint& pos = SYMBOL_PROXYPROPERTYDIALOG_POSITION, const wxSize& size = SYMBOL_PROXYPROPERTYDIALOG_SIZE, long style = SYMBOL_PROXYPROPERTYDIALOG_STYLE );
|
||||
|
||||
/// Destructor
|
||||
~ProxyPropertyDialog();
|
||||
|
||||
/// Initialises member variables
|
||||
void Init();
|
||||
|
||||
/// Creates the controls and sizers
|
||||
void CreateControls();
|
||||
|
||||
void UpdateDialogConstraints();
|
||||
|
||||
void OnContextHelp(wxCommandEvent &);
|
||||
|
||||
////@begin ProxyPropertyDialog event handler declarations
|
||||
|
||||
/// wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RADIOBUTTON_HTTPPROXY
|
||||
void OnRadiobuttonHttpproxySelected( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RADIOBUTTON_EXTERNALPROXY
|
||||
void OnRadiobuttonExternalproxySelected( wxCommandEvent& event );
|
||||
|
||||
////@end ProxyPropertyDialog event handler declarations
|
||||
|
||||
////@begin ProxyPropertyDialog member function declarations
|
||||
|
||||
bool GetBUseProxy() const { return m_bUseProxy ; }
|
||||
void SetBUseProxy(bool value) { m_bUseProxy = value ; }
|
||||
|
||||
wxString GetSProxyHost() const { return m_sProxyHost ; }
|
||||
void SetSProxyHost(wxString value) { m_sProxyHost = value ; }
|
||||
|
||||
int GetIProxyPort() const { return m_iProxyPort ; }
|
||||
void SetIProxyPort(int value) { m_iProxyPort = value ; }
|
||||
|
||||
wxString GetSProxyUser() const { return m_sProxyUser ; }
|
||||
void SetSProxyUser(wxString value) { m_sProxyUser = value ; }
|
||||
|
||||
wxString GetSProxyPass() const { return m_sProxyPass ; }
|
||||
void SetSProxyPass(wxString value) { m_sProxyPass = value ; }
|
||||
|
||||
bool GetBProxyPassRemember() const { return m_bProxyPassRemember ; }
|
||||
void SetBProxyPassRemember(bool value) { m_bProxyPassRemember = value ; }
|
||||
|
||||
bool GetBExternalProxy() const { return m_bExternalProxy ; }
|
||||
void SetBExternalProxy(bool value) { m_bExternalProxy = value ; }
|
||||
|
||||
wxString GetSProxyCommand() const { return m_sProxyCommand ; }
|
||||
void SetSProxyCommand(wxString value) { m_sProxyCommand = value ; }
|
||||
|
||||
/// Retrieves bitmap resources
|
||||
wxBitmap GetBitmapResource( const wxString& name );
|
||||
|
||||
/// Retrieves icon resources
|
||||
wxIcon GetIconResource( const wxString& name );
|
||||
////@end ProxyPropertyDialog member function declarations
|
||||
|
||||
/// Should we show tooltips?
|
||||
static bool ShowToolTips();
|
||||
|
||||
////@begin ProxyPropertyDialog member variables
|
||||
wxTextCtrl* m_pCtrlProxyHost;
|
||||
wxSpinCtrl* m_pCtrlProxyPort;
|
||||
wxTextCtrl* m_pCtrlProxyUser;
|
||||
wxTextCtrl* m_pCtrlProxyPass;
|
||||
wxCheckBox* m_pCtrlProxyPassRemember;
|
||||
wxTextCtrl* m_pCtrlProxyCommand;
|
||||
wxHyperlinkCtrl* m_pProxyCmdHelp;
|
||||
private:
|
||||
bool m_bUseProxy;
|
||||
wxString m_sProxyHost;
|
||||
int m_iProxyPort;
|
||||
wxString m_sProxyUser;
|
||||
wxString m_sProxyPass;
|
||||
bool m_bProxyPassRemember;
|
||||
bool m_bExternalProxy;
|
||||
wxString m_sProxyCommand;
|
||||
////@end ProxyPropertyDialog member variables
|
||||
};
|
||||
|
||||
#endif
|
||||
// _PROXYPROPERTYDIALOG_H_
|
||||
33
ProxyPropertyDialog_symbols.h
Normal file
33
ProxyPropertyDialog_symbols.h
Normal file
@@ -0,0 +1,33 @@
|
||||
// $Id: ProxyPropertyDialog_symbols.h 653 2011-12-07 15:39:54Z felfert $
|
||||
//
|
||||
// Copyright (C) 2010 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#define ID_PROXYPROPERTYDIALOG_SYMBOL_0 _("Proxy settings - OpenNX")
|
||||
#define ID_PROXYPROPERTYDIALOG_SYMBOL_1 _("Connect through internal (NoMachine) HTTP proxy")
|
||||
#define ID_PROXYPROPERTYDIALOG_SYMBOL_2 _("Host")
|
||||
#define ID_PROXYPROPERTYDIALOG_SYMBOL_3 _("Port")
|
||||
#define ID_PROXYPROPERTYDIALOG_SYMBOL_4 _("User")
|
||||
#define ID_PROXYPROPERTYDIALOG_SYMBOL_5 _("Password")
|
||||
#define ID_PROXYPROPERTYDIALOG_SYMBOL_6 _("Remember proxy password")
|
||||
#define ID_PROXYPROPERTYDIALOG_SYMBOL_7 _("Connect through external proxy")
|
||||
#define ID_PROXYPROPERTYDIALOG_SYMBOL_8 _("Command")
|
||||
#define ID_PROXYPROPERTYDIALOG_SYMBOL_9 _("?")
|
||||
#define ID_PROXYPROPERTYDIALOG_SYMBOL_10 _("&OK")
|
||||
#define ID_PROXYPROPERTYDIALOG_SYMBOL_11 _("&Cancel")
|
||||
834
PulseAudio.cpp
Normal file
834
PulseAudio.cpp
Normal file
@@ -0,0 +1,834 @@
|
||||
// $Id: PulseAudio.cpp 688 2012-02-18 02:36:07Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
||||
#pragma implementation "PulseAudio.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#include "PulseAudio.h"
|
||||
#ifndef PA_NOLIB
|
||||
#include "MyDynlib.h"
|
||||
#endif
|
||||
|
||||
#include <wx/log.h>
|
||||
#include <wx/utils.h>
|
||||
#include <wx/regex.h>
|
||||
#include <wx/config.h>
|
||||
#include <wx/wfstream.h>
|
||||
#include <wx/txtstrm.h>
|
||||
#include <wx/process.h>
|
||||
#include <wx/tokenzr.h>
|
||||
|
||||
#ifdef APP_OPENNX
|
||||
# include "opennxApp.h"
|
||||
#endif
|
||||
#ifdef APP_PULSETEST
|
||||
# include "pulseTest.h"
|
||||
#endif
|
||||
#include "osdep.h"
|
||||
|
||||
#include "trace.h"
|
||||
ENABLE_TRACE;
|
||||
|
||||
#if defined(HAVE_PULSE_PULSEAUDIO_H) || defined(__WXMSW__) || defined(__WXMAC__)
|
||||
# define WITH_PULSEAUDIO
|
||||
#endif
|
||||
|
||||
#ifdef WITH_PULSEAUDIO
|
||||
#include <pulse/pulseaudio.h>
|
||||
|
||||
#undef PA_ADEBUG
|
||||
|
||||
#ifndef PA_NOLIB
|
||||
typedef pa_threaded_mainloop* (*Tpa_threaded_mainloop_new)(void);
|
||||
typedef pa_mainloop_api* (*Tpa_threaded_mainloop_get_api)(pa_threaded_mainloop*);
|
||||
typedef int (*Tpa_threaded_mainloop_start)(pa_threaded_mainloop *);
|
||||
typedef void (*Tpa_threaded_mainloop_stop)(pa_threaded_mainloop *);
|
||||
typedef void (*Tpa_threaded_mainloop_free)(pa_threaded_mainloop *);
|
||||
typedef pa_context* (*Tpa_context_new)(pa_mainloop_api *, const char *);
|
||||
typedef void (*Tpa_context_set_state_callback)(pa_context *, pa_context_notify_cb_t, void *);
|
||||
typedef int (*Tpa_context_connect)(pa_context *, const char *, pa_context_flags_t, const pa_spawn_api *);
|
||||
typedef void (*Tpa_context_disconnect)(pa_context *);
|
||||
typedef pa_operation* (*Tpa_context_drain)(pa_context *, pa_context_notify_cb_t, void *);
|
||||
typedef pa_context_state_t (*Tpa_context_get_state)(pa_context *);
|
||||
typedef pa_operation* (*Tpa_context_get_server_info)(pa_context *, pa_server_info_cb_t, void *);
|
||||
typedef pa_operation* (*Tpa_context_get_module_info_list)(pa_context *, pa_module_info_cb_t, void *);
|
||||
typedef pa_operation* (*Tpa_context_load_module)(pa_context *, const char*, const char *, pa_context_index_cb_t, void *);
|
||||
typedef pa_operation* (*Tpa_context_unload_module)(pa_context *, uint32_t, pa_context_success_cb_t, void *);
|
||||
typedef int (*Tpa_context_errno)(pa_context *);
|
||||
typedef void (*Tpa_context_unref)(pa_context *);
|
||||
typedef void (*Tpa_operation_unref)(pa_operation *);
|
||||
typedef const char* (*Tpa_strerror)(int);
|
||||
typedef void (*Tpa_xfree)(void *p);
|
||||
|
||||
|
||||
#define LOADPTR(name) p = dll->GetSymbol(wxT(#name)); if (NULL == p) return 0; P##name = (T##name)p
|
||||
#define FPTR(name) static T##name P##name = NULL
|
||||
|
||||
FPTR(pa_threaded_mainloop_new);
|
||||
FPTR(pa_threaded_mainloop_get_api);
|
||||
FPTR(pa_threaded_mainloop_start);
|
||||
FPTR(pa_threaded_mainloop_stop);
|
||||
FPTR(pa_threaded_mainloop_free);
|
||||
FPTR(pa_context_new);
|
||||
FPTR(pa_context_set_state_callback);
|
||||
FPTR(pa_context_connect);
|
||||
FPTR(pa_context_disconnect);
|
||||
FPTR(pa_context_drain);
|
||||
FPTR(pa_context_get_state);
|
||||
FPTR(pa_context_unref);
|
||||
FPTR(pa_operation_unref);
|
||||
FPTR(pa_context_get_server_info);
|
||||
FPTR(pa_context_get_module_info_list);
|
||||
FPTR(pa_context_load_module);
|
||||
FPTR(pa_context_unload_module);
|
||||
FPTR(pa_context_errno);
|
||||
FPTR(pa_strerror);
|
||||
FPTR(pa_xfree);
|
||||
|
||||
static int _set_pasyms(MyDynamicLibrary *dll) {
|
||||
void *p;
|
||||
LOADPTR(pa_threaded_mainloop_new);
|
||||
LOADPTR(pa_threaded_mainloop_get_api);
|
||||
LOADPTR(pa_threaded_mainloop_start);
|
||||
LOADPTR(pa_threaded_mainloop_stop);
|
||||
LOADPTR(pa_threaded_mainloop_free);
|
||||
LOADPTR(pa_context_new);
|
||||
LOADPTR(pa_context_set_state_callback);
|
||||
LOADPTR(pa_context_connect);
|
||||
LOADPTR(pa_context_disconnect);
|
||||
LOADPTR(pa_context_drain);
|
||||
LOADPTR(pa_context_get_state);
|
||||
LOADPTR(pa_context_unref);
|
||||
LOADPTR(pa_operation_unref);
|
||||
LOADPTR(pa_context_get_server_info);
|
||||
LOADPTR(pa_context_get_module_info_list);
|
||||
LOADPTR(pa_context_load_module);
|
||||
LOADPTR(pa_context_unload_module);
|
||||
LOADPTR(pa_context_errno);
|
||||
LOADPTR(pa_strerror);
|
||||
LOADPTR(pa_xfree);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
// On windows, calling myLogTrace() from within libpulse's
|
||||
// connection loop apparently crashes libpulse for some
|
||||
// unknown reason. Therefore, we use native OutputDebugStringA
|
||||
// in this case.
|
||||
#ifdef __WXMSW__
|
||||
# define STATE_TRACE(msg) OutputDebugStringA(msg)
|
||||
#else
|
||||
# define STATE_TRACE(msg) myLogTrace(MYTRACETAG, wxT(msg))
|
||||
#endif
|
||||
|
||||
#ifdef PA_NOLIB
|
||||
# include "PAWrapperSimple.cpp"
|
||||
#else
|
||||
class pawrapper {
|
||||
private:
|
||||
typedef enum {
|
||||
NONE,
|
||||
LIST,
|
||||
LOAD_MODULE,
|
||||
UNLOAD_MODULE,
|
||||
SET_SINK_VOLUME,
|
||||
SET_SOURCE_VOLUME,
|
||||
SET_SINK_INPUT_VOLUME,
|
||||
} eAction;
|
||||
|
||||
public:
|
||||
pawrapper()
|
||||
: m_bConnected(false), m_pLoop(NULL), m_pApi(NULL), m_pContext(NULL)
|
||||
{
|
||||
m_bError = false;
|
||||
m_bConnected = false;
|
||||
#ifdef __WXMSW__
|
||||
const char * server = "127.0.0.1";
|
||||
#else
|
||||
const char * server = NULL;
|
||||
#endif
|
||||
m_pLoop = Ppa_threaded_mainloop_new();
|
||||
m_pApi = Ppa_threaded_mainloop_get_api(m_pLoop);
|
||||
m_pContext = Ppa_context_new(m_pApi, "OpenNX");
|
||||
Ppa_context_set_state_callback(m_pContext, context_state_callback_if, this);
|
||||
int retry = 3;
|
||||
do {
|
||||
m_bError = false;
|
||||
myLogTrace(MYTRACETAG, wxT("pa_context_connect try %d"), 4 - retry);
|
||||
if (0 <= Ppa_context_connect(m_pContext, server, PA_CONTEXT_NOAUTOSPAWN, NULL)) {
|
||||
Ppa_threaded_mainloop_start(m_pLoop);
|
||||
while (!(m_bConnected || m_bError))
|
||||
::wxGetApp().Yield(true);
|
||||
}
|
||||
if (m_bConnected)
|
||||
break;
|
||||
} while (retry-- > 0);
|
||||
}
|
||||
|
||||
~pawrapper()
|
||||
{
|
||||
#ifndef __WXMSW__
|
||||
if (m_bConnected)
|
||||
Ppa_context_disconnect(m_pContext);
|
||||
#endif
|
||||
if (m_pLoop) {
|
||||
Ppa_threaded_mainloop_stop(m_pLoop);
|
||||
Ppa_threaded_mainloop_free(m_pLoop);
|
||||
}
|
||||
if (NULL != m_pContext)
|
||||
Ppa_context_unref(m_pContext);
|
||||
}
|
||||
|
||||
bool getdefaults(wxString &Sink, wxString &Source)
|
||||
{
|
||||
m_bComplete = false;
|
||||
Ppa_operation_unref(Ppa_context_get_server_info(m_pContext, get_server_info_callback_if, this));
|
||||
bool ret = waitcmd();
|
||||
if (ret && m_bComplete) {
|
||||
Sink = m_DefSink;
|
||||
Source = m_DefSource;
|
||||
}
|
||||
return ret && m_bComplete;
|
||||
}
|
||||
|
||||
bool findmodules(const wxChar *name, wxArrayString &indexes, wxArrayString &args)
|
||||
{
|
||||
m_sStr = name;
|
||||
m_bSearch = true;
|
||||
m_bFound = false;
|
||||
m_bComplete = false;
|
||||
m_bError = false;
|
||||
m_asIndexes.Empty(); m_asArgs.Empty();
|
||||
Ppa_operation_unref(Ppa_context_get_module_info_list(m_pContext, get_module_info_callback_if, this));
|
||||
bool ret = waitcmd();
|
||||
if (ret && m_bFound) {
|
||||
args = m_asArgs;
|
||||
indexes = m_asIndexes;
|
||||
}
|
||||
return ret && m_bFound;
|
||||
}
|
||||
|
||||
|
||||
bool loadmodule(const wxString name, const wxString args)
|
||||
{
|
||||
m_bComplete = false;
|
||||
m_bError = false;
|
||||
Ppa_operation_unref(Ppa_context_load_module(m_pContext, name.mb_str(), args.mb_str(), index_callback_if, this));
|
||||
return waitcmd();
|
||||
}
|
||||
|
||||
bool unloadmodule(int index)
|
||||
{
|
||||
m_bComplete = false;
|
||||
m_bError = false;
|
||||
Ppa_operation_unref(Ppa_context_unload_module(m_pContext, index, simple_callback_if, this));
|
||||
return waitcmd();
|
||||
}
|
||||
|
||||
bool isConnected()
|
||||
{
|
||||
return m_bConnected;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
bool waitcmd() {
|
||||
while (!(m_bError || m_bComplete)) {
|
||||
::wxGetApp().Yield(true);
|
||||
}
|
||||
return !m_bError;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void runcmd(eAction a)
|
||||
{
|
||||
m_bComplete = false;
|
||||
m_bError = false;
|
||||
switch (a) {
|
||||
case SET_SINK_VOLUME:
|
||||
{
|
||||
pa_cvolume v;
|
||||
|
||||
pa_cvolume_set(&v, 1, volume);
|
||||
Ppa_operation_unref(pa_context_set_sink_volume_by_name(m_pContext, sink_name, &v, simple_callback_if, NULL));
|
||||
break;
|
||||
}
|
||||
case SET_SOURCE_VOLUME:
|
||||
{
|
||||
pa_cvolume v;
|
||||
|
||||
pa_cvolume_set(&v, 1, volume);
|
||||
Ppa_operation_unref(pa_context_set_source_volume_by_name(m_pContext, source_name, &v, simple_callback_if, NULL));
|
||||
break;
|
||||
}
|
||||
case SET_SINK_INPUT_VOLUME:
|
||||
{
|
||||
pa_cvolume v;
|
||||
|
||||
pa_cvolume_set(&v, 1, volume);
|
||||
Ppa_operation_unref(pa_context_set_sink_input_volume(m_pContext, sink_input_idx, &v, simple_callback_if, NULL));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void drain(void) {
|
||||
pa_operation *o = Ppa_context_drain(m_pContext, context_drain_complete_if, this);
|
||||
if (NULL == o) {
|
||||
myLogTrace(MYTRACETAG, wxT("drain_complete"));
|
||||
m_bComplete = true;
|
||||
} else
|
||||
Ppa_operation_unref(o);
|
||||
}
|
||||
|
||||
void context_state_callback(pa_context *c)
|
||||
{
|
||||
if (NULL == c)
|
||||
return;
|
||||
switch (Ppa_context_get_state(c)) {
|
||||
case PA_CONTEXT_UNCONNECTED:
|
||||
STATE_TRACE("PA_CONTEXT_UNCONNECTED");
|
||||
break;
|
||||
case PA_CONTEXT_CONNECTING:
|
||||
STATE_TRACE("PA_CONTEXT_CONNECTING");
|
||||
break;
|
||||
case PA_CONTEXT_AUTHORIZING:
|
||||
STATE_TRACE("PA_CONTEXT_AUTHORIZING");
|
||||
break;
|
||||
case PA_CONTEXT_SETTING_NAME:
|
||||
STATE_TRACE("PA_CONTEXT_SETTING_NAME");
|
||||
break;
|
||||
case PA_CONTEXT_READY:
|
||||
STATE_TRACE("PA_CONTEXT_READY");
|
||||
m_bConnected = true;
|
||||
break;
|
||||
case PA_CONTEXT_TERMINATED:
|
||||
STATE_TRACE("PA_CONTEXT_TERMINATED");
|
||||
break;
|
||||
case PA_CONTEXT_FAILED:
|
||||
STATE_TRACE("PA_CONTEXT_FAILED");
|
||||
m_bError = true;
|
||||
break;
|
||||
default:
|
||||
STATE_TRACE("PA_CONTEXT_default");
|
||||
m_bError = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void get_server_info_callback(pa_context *c, const pa_server_info *i)
|
||||
{
|
||||
if (!i) {
|
||||
myLogTrace(MYTRACETAG, wxT("Failed to get server information: %s"), Ppa_strerror(Ppa_context_errno(c)));
|
||||
m_bError = true;
|
||||
m_pApi->quit(m_pApi, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
wxString dsink(i->default_sink_name ? i->default_sink_name : "", wxConvUTF8);
|
||||
wxString dsrc(i->default_source_name ? i->default_source_name : "", wxConvUTF8);
|
||||
m_DefSink = dsink; m_DefSource = dsrc; m_bComplete = true;
|
||||
}
|
||||
|
||||
void get_module_info_callback(pa_context *c, const pa_module_info *i, int is_last)
|
||||
{
|
||||
if (is_last < 0) {
|
||||
myLogTrace(MYTRACETAG, wxT("Failed to get module information: %s"), Ppa_strerror(Ppa_context_errno(c)));
|
||||
m_bError = true;
|
||||
m_pApi->quit(m_pApi, 0);
|
||||
return;
|
||||
}
|
||||
if (is_last) {
|
||||
drain();
|
||||
return;
|
||||
}
|
||||
if (NULL != i) {
|
||||
wxString name(i->name, wxConvUTF8);
|
||||
wxString args(i->argument ? i->argument : "", wxConvUTF8);
|
||||
if (name.IsSameAs(m_sStr)) {
|
||||
m_bFound = true;
|
||||
myLogTrace(MYTRACETAG, wxT("Found module[%u] %s %s"),
|
||||
i->index, VMB(name), VMB(args));
|
||||
m_asIndexes.Add(wxString::Format(wxT("%d"),i->index));
|
||||
m_asArgs.Add(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void index_callback(pa_context *c, uint32_t idx)
|
||||
{
|
||||
if (idx == PA_INVALID_INDEX) {
|
||||
myLogTrace(MYTRACETAG, wxT("Index failure: %s"), Ppa_strerror(Ppa_context_errno(c)));
|
||||
m_bError = true;
|
||||
m_pApi->quit(m_pApi, 0);
|
||||
return;
|
||||
}
|
||||
m_iIndex = idx;
|
||||
drain();
|
||||
}
|
||||
|
||||
void simple_callback(pa_context *c, int success)
|
||||
{
|
||||
if (!success) {
|
||||
m_bError = true;
|
||||
myLogTrace(MYTRACETAG, wxT("Simple failure: %s"), Ppa_strerror(Ppa_context_errno(c)));
|
||||
m_pApi->quit(m_pApi, 0);
|
||||
return;
|
||||
}
|
||||
drain();
|
||||
}
|
||||
|
||||
void context_drain_complete(pa_context *)
|
||||
{
|
||||
myLogTrace(MYTRACETAG, wxT("context_drain_complete"));
|
||||
m_bComplete = true;
|
||||
}
|
||||
|
||||
static void simple_callback_if(pa_context *c, int success, void *udata) {
|
||||
if (NULL == udata)
|
||||
return;
|
||||
static_cast<pawrapper *>(udata)->simple_callback(c, success);
|
||||
}
|
||||
|
||||
static void index_callback_if(pa_context *c, uint32_t idx, void *udata) {
|
||||
if (NULL == udata)
|
||||
return;
|
||||
static_cast<pawrapper *>(udata)->index_callback(c, idx);
|
||||
}
|
||||
|
||||
static void context_drain_complete_if(pa_context *c, void *udata) {
|
||||
if (NULL == udata)
|
||||
return;
|
||||
static_cast<pawrapper *>(udata)->context_drain_complete(c);
|
||||
}
|
||||
|
||||
static void get_module_info_callback_if(pa_context *c, const pa_module_info *i, int last, void *udata) {
|
||||
if (NULL == udata)
|
||||
return;
|
||||
static_cast<pawrapper *>(udata)->get_module_info_callback(c, i, last);
|
||||
}
|
||||
|
||||
static void get_server_info_callback_if(pa_context *c, const pa_server_info *i, void *udata) {
|
||||
if (NULL == udata)
|
||||
return;
|
||||
static_cast<pawrapper *>(udata)->get_server_info_callback(c, i);
|
||||
}
|
||||
|
||||
static void context_state_callback_if(pa_context *c, void *udata) {
|
||||
if (NULL == udata)
|
||||
return;
|
||||
static_cast<pawrapper *>(udata)->context_state_callback(c);
|
||||
}
|
||||
|
||||
volatile bool m_bConnected;
|
||||
volatile bool m_bComplete;
|
||||
volatile bool m_bError;
|
||||
volatile bool m_bSearch;
|
||||
volatile bool m_bFound;
|
||||
unsigned int m_iIndex;
|
||||
pa_threaded_mainloop *m_pLoop;
|
||||
pa_mainloop_api *m_pApi;
|
||||
pa_context *m_pContext;
|
||||
wxString m_sStr;
|
||||
|
||||
wxString m_DefSink;
|
||||
wxString m_DefSource;
|
||||
wxArrayString m_asIndexes;
|
||||
wxArrayString m_asArgs;
|
||||
};
|
||||
#endif
|
||||
|
||||
# if defined(__WXMSW__) || defined(__WXMAC__)
|
||||
# ifdef __WXMAC__
|
||||
extern "C" {
|
||||
extern const char *getMacMachineID();
|
||||
};
|
||||
# endif
|
||||
|
||||
static wxString MachineID() {
|
||||
# ifdef __WXMSW__
|
||||
return ::wxGetHostName().Lower();
|
||||
# else
|
||||
return wxString(getMacMachineID(), wxConvUTF8);
|
||||
# endif
|
||||
}
|
||||
# endif // defined(__WXMSW__) || defined(__WXMAC__)
|
||||
#endif // WITH_PULSEAUDIO
|
||||
|
||||
bool PulseAudio::AutoSpawn()
|
||||
{
|
||||
#ifdef WITH_PULSEAUDIO
|
||||
# if defined(__WXMSW__) || defined(__WXMAC__)
|
||||
int papid;
|
||||
int retry = 3;
|
||||
// On windows and mac, we do our own autospawn
|
||||
wxString piddir = ::wxGetHomeDir() + wxFileName::GetPathSeparator()
|
||||
+ wxT(".config") + wxFileName::GetPathSeparator()
|
||||
+ wxT("pulse") + wxFileName::GetPathSeparator()
|
||||
+ MachineID() + wxT("-runtime");
|
||||
wxString pidfile = piddir + wxFileName::GetPathSeparator() + wxT("pid");
|
||||
wxString pacmd;
|
||||
wxConfigBase::Get()->Read(wxT("Config/SystemNxDir"), &pacmd);
|
||||
pacmd << wxFileName::GetPathSeparator() << wxT("bin")
|
||||
<< wxFileName::GetPathSeparator() << wxT("pulseaudio");
|
||||
# ifdef __WXMSW__
|
||||
pacmd << wxT(".exe --exit-idle-time=-1 --log-target=file:\"")
|
||||
<< ::wxGetHomeDir() << wxFileName::GetPathSeparator()
|
||||
<< wxT(".config") << wxFileName::GetPathSeparator()
|
||||
<< wxT("pulse") << wxFileName::GetPathSeparator()
|
||||
<< wxT("pa.log\"");
|
||||
# endif
|
||||
do {
|
||||
# ifdef __WXMSW__
|
||||
myLogTrace(MYTRACETAG, wxT("PulseAudio::AutoSpawn: checking pulseaudio process"));
|
||||
papid = getpidof("pulseaudio.exe");
|
||||
if (papid != 0) {
|
||||
myLogTrace(MYTRACETAG, wxT("PulseAudio::AutoSpawn: process %d is running"), papid);
|
||||
return true;
|
||||
}
|
||||
# else
|
||||
myLogTrace(MYTRACETAG, wxT("PulseAudio::AutoSpawn: checking '%s'"), VMB(pidfile));
|
||||
wxFileInputStream sPid(pidfile);
|
||||
if (sPid.IsOk()) {
|
||||
myLogTrace(MYTRACETAG, wxT("PulseAudio::AutoSpawn: PID file exists"));
|
||||
wxTextInputStream tis(sPid);
|
||||
tis >> papid;
|
||||
myLogTrace(MYTRACETAG, wxT("PulseAudio::AutoSpawn: PID=%d"), papid);
|
||||
if ((papid != 0) && ::wxProcess::Exists(papid)) {
|
||||
myLogTrace(MYTRACETAG, wxT("PulseAudio::AutoSpawn: process %d is running"), papid);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
||||
myLogTrace(MYTRACETAG, wxT("PulseAudio::AutoSpawn: trying to start '%s'"), VMB(pacmd));
|
||||
# ifdef __WXMSW__
|
||||
wxProcess *nxpa = wxProcess::Open(pacmd,
|
||||
wxEXEC_ASYNC|wxEXEC_MAKE_GROUP_LEADER);
|
||||
wxThread::Sleep(100);
|
||||
if (nxpa) {
|
||||
nxpa->CloseOutput();
|
||||
nxpa->Detach();
|
||||
}
|
||||
# else
|
||||
::wxExecute(pacmd, wxEXEC_ASYNC|wxEXEC_MAKE_GROUP_LEADER);
|
||||
# endif
|
||||
wxThread::Sleep(1000);
|
||||
} while (retry-- > 0);
|
||||
myLogTrace(MYTRACETAG, wxT("PulseAudio::AutoSpawn: spawn failed"));
|
||||
return false;
|
||||
# else
|
||||
myLogTrace(MYTRACETAG, wxT("Not spawning pulseaudio on this platform"));
|
||||
return true;
|
||||
# endif // defined(__WXMSW__) || defined(__WXMAC__)
|
||||
#else
|
||||
return true;
|
||||
#endif // WITH_PULSEAUDIO
|
||||
}
|
||||
|
||||
#ifndef PA_NOLIB
|
||||
PulseAudio::PulseAudio()
|
||||
: pa(NULL), dll(NULL), m_bPulseAvailable(false)
|
||||
{
|
||||
m_iPortEsound = 0; m_iPortNative = 0;
|
||||
#ifdef WITH_PULSEAUDIO
|
||||
wxLogNull ignoreErrors;
|
||||
if (AutoSpawn()) {
|
||||
dll = new MyDynamicLibrary();
|
||||
# ifdef __WXMSW__
|
||||
wxString pdll = wxT("libpulse-0");
|
||||
# else
|
||||
wxString pdll = wxT("libpulse");
|
||||
# endif
|
||||
if (dll->Load(pdll)) {
|
||||
myLogTrace(MYTRACETAG, wxT("libpulse loaded"));
|
||||
if (0 != _set_pasyms(dll)) {
|
||||
myLogTrace(MYTRACETAG, wxT("libpulse functions loaded"));
|
||||
pa = new pawrapper();
|
||||
if (pa->isConnected()) {
|
||||
m_bPulseAvailable = true;
|
||||
myLogTrace(MYTRACETAG, wxT("connected to pulseaudio daemon"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
myLogTrace(MYTRACETAG, wxT("No pulseaudio support"));
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
PulseAudio::PulseAudio()
|
||||
: pa(NULL), m_bPulseAvailable(false)
|
||||
{
|
||||
m_iPortEsound = 0; m_iPortNative = 0;
|
||||
# ifdef WITH_PULSEAUDIO
|
||||
if (AutoSpawn()) {
|
||||
pa = new pawrapper();
|
||||
if (pa->isConnected()) {
|
||||
m_bPulseAvailable = true;
|
||||
myLogTrace(MYTRACETAG, wxT("connected to pulseaudio daemon"));
|
||||
}
|
||||
}
|
||||
# else
|
||||
myLogTrace(MYTRACETAG, wxT("No pulseaudio support"));
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
PulseAudio::~PulseAudio()
|
||||
{
|
||||
#ifdef WITH_PULSEAUDIO
|
||||
delete pa;
|
||||
# ifndef PA_NOLIB
|
||||
delete dll;
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
bool PulseAudio::IsAvailable()
|
||||
{
|
||||
myLogTrace(MYTRACETAG, wxT("IsAvailable:%s"),
|
||||
# ifdef __WXMSW__
|
||||
m_bPulseAvailable ? wxT("true") : wxT("false"));
|
||||
# else
|
||||
m_bPulseAvailable ? "true" : "false");
|
||||
# endif
|
||||
return m_bPulseAvailable;
|
||||
}
|
||||
|
||||
int PulseAudio::FoundModuleIDs(wxString modname, wxString s_argstpl,
|
||||
wxArrayString &a_indexes, wxArrayString &a_args,
|
||||
bool HardAccordance = false)
|
||||
{
|
||||
#ifdef WITH_PULSEAUDIO
|
||||
wxRegEx re;
|
||||
wxArrayString indexes, args_args; indexes.Empty(); args_args.Empty();
|
||||
if (!pa->findmodules(modname, indexes, args_args))
|
||||
return 0;
|
||||
wxArrayString argstpl = ::wxStringTokenize(s_argstpl);
|
||||
myLogTrace(MYTRACETAG, wxT("Found modules named %s (argstpl=%d): idx/args_args count = %d/%d"),
|
||||
VMB(modname),(int)argstpl.GetCount(),(int)indexes.GetCount(),
|
||||
(int)args_args.GetCount());
|
||||
a_indexes.Empty(); a_args.Empty(); int c = 0;
|
||||
for (int i = 0; i < indexes.GetCount(); i++)
|
||||
{
|
||||
if (argstpl.IsEmpty() && !HardAccordance) {
|
||||
a_indexes.Add(indexes[i]); a_args.Add(args_args[i]); c++;
|
||||
continue;
|
||||
}
|
||||
wxArrayString margs = ::wxStringTokenize(args_args[i]);
|
||||
#ifdef PA_ADEBUG
|
||||
myLogTrace(MYTRACETAG, wxT("Checking mod[%s], in args = '%s'; count = %d "),
|
||||
VMB(indexes[i]), VMB(args_args[i]),(int)margs.GetCount());
|
||||
#endif
|
||||
if (HardAccordance && (argstpl.GetCount() != margs.GetCount()))
|
||||
continue;
|
||||
bool Accordance = true;
|
||||
for (int j = 0; j < argstpl.GetCount(); j++) {
|
||||
#ifdef PA_ADEBUG
|
||||
myLogTrace(MYTRACETAG, wxT("Checking template '%s'"), VMB(argstpl[j]));
|
||||
#endif
|
||||
re.Compile(argstpl[j], wxRE_ADVANCED);
|
||||
bool rfound = false;
|
||||
for (int k = 0; k < margs.GetCount(); k++) {
|
||||
rfound = re.Matches(margs[k]);
|
||||
#ifdef PA_ADEBUG
|
||||
myLogTrace(MYTRACETAG, wxT("Checking arg '%s' -> res = %d"),
|
||||
VMB(margs[k]), rfound);
|
||||
#endif
|
||||
if (rfound)
|
||||
break;
|
||||
}
|
||||
if (!rfound) {
|
||||
Accordance = false; break;
|
||||
}
|
||||
}
|
||||
if (Accordance) {
|
||||
a_indexes.Add(indexes[i]); a_args.Add(args_args[i]); c++;
|
||||
}
|
||||
}
|
||||
myLogTrace(MYTRACETAG, wxT("Matches %d modules named %s: idxs/args = %d/%d"),
|
||||
c, VMB(modname), (int)a_indexes.GetCount(),(int)a_args.GetCount());
|
||||
return c;
|
||||
#else
|
||||
wxUnusedVar(modname,s_argstpl,HardAccordance);
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool PulseAudio::UnloadExistingModules(wxString modname, wxString s_argstpl,
|
||||
bool HardAccordance = false)
|
||||
{
|
||||
if (!m_bPulseAvailable)
|
||||
return false;
|
||||
#ifdef WITH_PULSEAUDIO
|
||||
wxArrayString mis,mas; mis.Empty(); mas.Empty();
|
||||
bool res = true; bool res0;
|
||||
if (FoundModuleIDs(modname,s_argstpl,mis,mas,HardAccordance) > 0) {
|
||||
for (int i = 0; i < mis.GetCount(); i++) {
|
||||
long mid; mis[i].ToLong(&mid);
|
||||
res0 = pa->unloadmodule(mid);
|
||||
myLogTrace(MYTRACETAG, wxT("unloading %s module[%d] -> res = %d"),
|
||||
VMB(modname), (int)mid, (int)res);
|
||||
res = res ? res0 : res;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
#else
|
||||
wxUnusedVar(modname,s_argstpl,HardAccordance);
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool PulseAudio::ActivateEsound(int port)
|
||||
{
|
||||
if (!m_bPulseAvailable)
|
||||
return false;
|
||||
#ifdef WITH_PULSEAUDIO
|
||||
wxString mname = wxT("module-esound-protocol-tcp");
|
||||
UnloadExistingModules(mname,wxT(""));
|
||||
wxString ma = wxString::Format(wxT("port=%d"), port);
|
||||
UnloadExistingModules(wxT("module-native-protocol-tcp"),ma);
|
||||
ma.Append(wxString::Format(wxT(" listen=127.0.0.1 auth-anonymous=1"), port));
|
||||
bool res = pa->loadmodule(mname,ma);
|
||||
myLogTrace(MYTRACETAG, wxT("loading %s module -> res = %d"),
|
||||
VMB(mname), res);
|
||||
return res;
|
||||
#else
|
||||
wxUnusedVar(port);
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool PulseAudio::ActivateNative(int port, int rrate, bool mono)
|
||||
{
|
||||
if (!m_bPulseAvailable)
|
||||
return false;
|
||||
#ifdef WITH_PULSEAUDIO
|
||||
UnloadExistingModules(wxT("module-esound-protocol-tcp"),wxT(""));
|
||||
wxString mname = wxT("module-native-protocol-tcp");
|
||||
wxString ma = wxString::Format(wxT("port=%d"), port);
|
||||
wxArrayString mis,mas; bool res;
|
||||
bool bNativeModulePort = (FoundModuleIDs(mname,ma,mis,mas) > 0);
|
||||
wxString mname_fake = wxT("module-null-sink");
|
||||
wxString mname_conn = wxT("module-loopback");
|
||||
if (!bNativeModulePort) {
|
||||
ma.Append(wxString::Format(wxT(" listen=127.0.0.1 auth-anonymous=1")));
|
||||
res = pa->loadmodule(mname,ma);
|
||||
myLogTrace(MYTRACETAG, wxT("loading %s module -> res = %d (args = '%s')"),
|
||||
VMB(mname), (int)res, VMB(ma));
|
||||
}
|
||||
if (!res)
|
||||
return res;
|
||||
wxString ma_fake = wxString::Format(wxT(" rate=%d channels=%s"),rrate,
|
||||
mono ?wxT("1"):wxT("2"));
|
||||
if ((rrate == 0) || (FoundModuleIDs(mname_fake,ma_fake,mis,mas) == 0)) {
|
||||
wxString deltpl = wxT("(sink|sink_name|source)=(ts_sender|ts_receiver)");
|
||||
UnloadExistingModules(mname_conn,deltpl);
|
||||
UnloadExistingModules(mname_fake,deltpl);
|
||||
if (rrate == 0)
|
||||
return res;
|
||||
}
|
||||
#ifndef __WXMSW__
|
||||
wxString dsi,dso; dsi.Empty(); dso.Empty();
|
||||
pa->getdefaults(dsi,dso);
|
||||
myLogTrace(MYTRACETAG, wxT("Get defaults: Sink ='%s'; Source ='%s'"),
|
||||
VMB(dsi), VMB(dso));
|
||||
if ((dsi.IsEmpty()) || (dso.IsEmpty()))
|
||||
return true; // modules for resample are optional now
|
||||
#else
|
||||
// on win we check availability of sink and source only
|
||||
// because old resample scheme not work
|
||||
// on systems >=w7 is necessary try to load sink and source
|
||||
// separately since audio devices are present according to
|
||||
// speakers/headset/microphone connect status
|
||||
// Also these modules always must be reloaded in case
|
||||
// recent jacks reconnection
|
||||
bool IsSink, IsSource;
|
||||
mname = wxT("module-waveout");
|
||||
ma = wxT("sink_name=output");
|
||||
UnloadExistingModules(mname,ma);
|
||||
ma.Append(wxT(" record=0"));
|
||||
IsSink = pa->loadmodule(mname,ma);
|
||||
myLogTrace(MYTRACETAG, wxT("loading %s module -> res = %d (args = '%s')"),
|
||||
VMB(mname), (int)IsSink, VMB(ma));
|
||||
ma = wxT("source_name=input");
|
||||
UnloadExistingModules(mname,ma);
|
||||
ma.Append(wxT(" playback=0"));
|
||||
IsSource = pa->loadmodule(mname,ma);
|
||||
myLogTrace(MYTRACETAG, wxT("loading %s module -> res = %d (args = '%s')"),
|
||||
VMB(mname), (int)IsSource, VMB(ma));
|
||||
res = (IsSink || IsSource);
|
||||
return res;
|
||||
#endif
|
||||
|
||||
#ifndef __WXMSW__
|
||||
ma = wxT("sink_name=ts_sender") + ma_fake;
|
||||
if (!FoundModuleIDs(mname_fake,wxT("sink_name=ts_sender"),mis,mas)) {
|
||||
res = pa->loadmodule(mname_fake,ma);
|
||||
myLogTrace(MYTRACETAG, wxT("loading %s module -> res = %d (args = '%s')"),
|
||||
VMB(mname_fake), (int)res, VMB(ma));
|
||||
}
|
||||
|
||||
ma = wxT("source=") + dso + wxT(" sink=ts_sender");
|
||||
if (!FoundModuleIDs(mname_conn,wxT("sink=ts_sender"),mis,mas)) {
|
||||
res = pa->loadmodule(mname_conn,ma);
|
||||
myLogTrace(MYTRACETAG, wxT("loading %s module -> res = %d (args = '%s')"),
|
||||
VMB(mname_conn), (int)res, VMB(ma));
|
||||
}
|
||||
|
||||
ma = wxT("sink_name=ts_receiver") + ma_fake;
|
||||
if (!FoundModuleIDs(mname_fake,wxT("sink_name=ts_receiver"),mis,mas)) {
|
||||
res = pa->loadmodule(mname_fake,ma);
|
||||
myLogTrace(MYTRACETAG, wxT("loading %s module -> res = %d (args = '%s')"),
|
||||
VMB(mname_fake), (int)res, VMB(ma));
|
||||
}
|
||||
|
||||
ma = wxT("source=ts_receiver.monitor sink=") + dsi;
|
||||
if (!FoundModuleIDs(mname_conn,wxT("source=ts_receiver.monitor"),mis,mas)) {
|
||||
res = pa->loadmodule(mname_conn,ma);
|
||||
myLogTrace(MYTRACETAG, wxT("loading %s module -> res = %d (args = '%s')"),
|
||||
VMB(mname_conn), (int)res, VMB(ma));
|
||||
}
|
||||
return true;
|
||||
#endif
|
||||
#else
|
||||
wxUnusedVar(port,rrate,mono);
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
76
PulseAudio.h
Normal file
76
PulseAudio.h
Normal file
@@ -0,0 +1,76 @@
|
||||
// $Id: PulseAudio.h 654 2011-12-09 18:07:38Z felfert $
|
||||
//
|
||||
// Copyright (C) 2009 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _PULSEAUDIO_H_
|
||||
#define _PULSEAUDIO_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
||||
#pragma interface "PulseAudio.h"
|
||||
#endif
|
||||
|
||||
#include "MyXmlConfig.h"
|
||||
|
||||
#ifdef __WXMSW__
|
||||
#define PA_NOLIB
|
||||
#endif
|
||||
|
||||
class pawrapper;
|
||||
#ifndef PA_NOLIB
|
||||
class MyDynamicLibrary;
|
||||
#endif
|
||||
|
||||
class PulseAudio {
|
||||
public:
|
||||
PulseAudio();
|
||||
virtual ~PulseAudio();
|
||||
|
||||
/**
|
||||
* Return true, if a pulseaudio server is running.
|
||||
*/
|
||||
bool IsAvailable();
|
||||
|
||||
bool ActivateEsound(int port);
|
||||
bool ActivateNative(int port, int rrate, bool mono);
|
||||
|
||||
const int GetEsoundPort() { return m_iPortEsound; }
|
||||
const int GetNativePort() { return m_iPortNative; }
|
||||
|
||||
int FoundModuleIDs(wxString modname, wxString s_argstpl,
|
||||
wxArrayString &a_indexes, wxArrayString &a_args,
|
||||
bool HardAccordance);
|
||||
bool UnloadExistingModules(wxString modname, wxString s_argstpl,
|
||||
bool HardAccordance);
|
||||
|
||||
private:
|
||||
bool AutoSpawn();
|
||||
|
||||
int m_iPortEsound;
|
||||
int m_iPortNative;
|
||||
|
||||
pawrapper *pa;
|
||||
#ifndef PA_NOLIB
|
||||
MyDynamicLibrary *dll;
|
||||
#endif
|
||||
bool m_bPulseAvailable;
|
||||
};
|
||||
|
||||
#endif
|
||||
// _PULSEAUDIO_H_
|
||||
177
QuitDialog.cpp
Normal file
177
QuitDialog.cpp
Normal file
@@ -0,0 +1,177 @@
|
||||
// $Id: QuitDialog.cpp 148 2009-02-10 20:04:38Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
||||
#pragma implementation "QuitDialog.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
////@begin includes
|
||||
////@end includes
|
||||
|
||||
#include "QuitDialog.h"
|
||||
#include "Icon.h"
|
||||
|
||||
////@begin XPM images
|
||||
////@end XPM images
|
||||
|
||||
/*!
|
||||
* QuitDialog type definition
|
||||
*/
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS( QuitDialog, wxDialog )
|
||||
|
||||
/*!
|
||||
* QuitDialog event table definition
|
||||
*/
|
||||
|
||||
BEGIN_EVENT_TABLE( QuitDialog, wxDialog )
|
||||
|
||||
////@begin QuitDialog event table entries
|
||||
////@end QuitDialog event table entries
|
||||
|
||||
END_EVENT_TABLE()
|
||||
|
||||
/*!
|
||||
* QuitDialog constructors
|
||||
*/
|
||||
|
||||
QuitDialog::QuitDialog( )
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
QuitDialog::QuitDialog( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
||||
{
|
||||
Init();
|
||||
Create(parent, id, caption, pos, size, style);
|
||||
}
|
||||
|
||||
/*!
|
||||
* QuitDialog creator
|
||||
*/
|
||||
|
||||
bool QuitDialog::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
||||
{
|
||||
////@begin QuitDialog creation
|
||||
SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS);
|
||||
SetParent(parent);
|
||||
CreateControls();
|
||||
SetIcon(GetIconResource(wxT("res/nx.png")));
|
||||
if (GetSizer())
|
||||
{
|
||||
GetSizer()->SetSizeHints(this);
|
||||
}
|
||||
Centre();
|
||||
////@end QuitDialog creation
|
||||
wxUnusedVar(style);
|
||||
wxUnusedVar(size);
|
||||
wxUnusedVar(pos);
|
||||
wxUnusedVar(caption);
|
||||
wxUnusedVar(id);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Member initialisation
|
||||
*/
|
||||
|
||||
void QuitDialog::Init()
|
||||
{
|
||||
////@begin QuitDialog member initialisation
|
||||
m_iDialogClass = wxICON_WARNING;
|
||||
m_sMessage = wxEmptyString;
|
||||
m_pCtrlBitmap = NULL;
|
||||
m_pCtrlMessage = NULL;
|
||||
////@end QuitDialog member initialisation
|
||||
}
|
||||
/*!
|
||||
* Control creation for QuitDialog
|
||||
*/
|
||||
|
||||
void QuitDialog::CreateControls()
|
||||
{
|
||||
////@begin QuitDialog content construction
|
||||
if (!wxXmlResource::Get()->LoadDialog(this, GetParent(), _T("ID_QUITDIALOG")))
|
||||
wxLogError(wxT("Missing wxXmlResource::Get()->Load() in OnInit()?"));
|
||||
m_pCtrlBitmap = XRCCTRL(*this, "ID_STATICBITMAP", wxStaticBitmap);
|
||||
m_pCtrlMessage = XRCCTRL(*this, "wxID_STATIC", wxStaticText);
|
||||
////@end QuitDialog content construction
|
||||
|
||||
// Create custom windows not generated automatically here.
|
||||
////@begin QuitDialog content initialisation
|
||||
////@end QuitDialog content initialisation
|
||||
|
||||
wxArtID artid = wxART_WARNING;
|
||||
switch (m_iDialogClass) {
|
||||
case wxICON_INFORMATION:
|
||||
artid = wxART_INFORMATION;
|
||||
break;
|
||||
case wxICON_ERROR:
|
||||
artid = wxART_ERROR;
|
||||
break;
|
||||
}
|
||||
m_pCtrlBitmap->SetBitmap(wxArtProvider::GetBitmap(artid, wxART_MESSAGE_BOX));
|
||||
m_pCtrlMessage->SetLabel(m_sMessage);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Should we show tooltips?
|
||||
*/
|
||||
|
||||
bool QuitDialog::ShowToolTips()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get bitmap resources
|
||||
*/
|
||||
|
||||
wxBitmap QuitDialog::GetBitmapResource( const wxString& name )
|
||||
{
|
||||
// Bitmap retrieval
|
||||
return CreateBitmapFromFile(name);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get icon resources
|
||||
*/
|
||||
|
||||
wxIcon QuitDialog::GetIconResource( const wxString& name )
|
||||
{
|
||||
// Icon retrieval
|
||||
return CreateIconFromFile(name);
|
||||
}
|
||||
121
QuitDialog.h
Normal file
121
QuitDialog.h
Normal file
@@ -0,0 +1,121 @@
|
||||
// $Id: QuitDialog.h 97 2006-12-21 09:18:48Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _QUITDIALOG_H_
|
||||
#define _QUITDIALOG_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
||||
#pragma interface "QuitDialog.h"
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* Includes
|
||||
*/
|
||||
|
||||
////@begin includes
|
||||
#include "QuitDialog_symbols.h"
|
||||
#include "wx/xrc/xmlres.h"
|
||||
////@end includes
|
||||
|
||||
/*!
|
||||
* Forward declarations
|
||||
*/
|
||||
|
||||
////@begin forward declarations
|
||||
////@end forward declarations
|
||||
|
||||
/*!
|
||||
* Control identifiers
|
||||
*/
|
||||
|
||||
////@begin control identifiers
|
||||
#define ID_QUITDIALOG 10151
|
||||
#define SYMBOL_QUITDIALOG_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxSTAY_ON_TOP|wxCLOSE_BOX
|
||||
#define SYMBOL_QUITDIALOG_TITLE _T("")
|
||||
#define SYMBOL_QUITDIALOG_IDNAME ID_QUITDIALOG
|
||||
#define SYMBOL_QUITDIALOG_SIZE wxSize(400, 300)
|
||||
#define SYMBOL_QUITDIALOG_POSITION wxDefaultPosition
|
||||
////@end control identifiers
|
||||
|
||||
/*!
|
||||
* Compatibility
|
||||
*/
|
||||
|
||||
#ifndef wxCLOSE_BOX
|
||||
#define wxCLOSE_BOX 0x1000
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* QuitDialog class declaration
|
||||
*/
|
||||
|
||||
class QuitDialog: public wxDialog
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS( QuitDialog )
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
public:
|
||||
/// Constructors
|
||||
QuitDialog( );
|
||||
QuitDialog( wxWindow* parent, wxWindowID id = SYMBOL_QUITDIALOG_IDNAME, const wxString& caption = SYMBOL_QUITDIALOG_TITLE, const wxPoint& pos = SYMBOL_QUITDIALOG_POSITION, const wxSize& size = SYMBOL_QUITDIALOG_SIZE, long style = SYMBOL_QUITDIALOG_STYLE );
|
||||
|
||||
/// Creation
|
||||
bool Create( wxWindow* parent, wxWindowID id = SYMBOL_QUITDIALOG_IDNAME, const wxString& caption = SYMBOL_QUITDIALOG_TITLE, const wxPoint& pos = SYMBOL_QUITDIALOG_POSITION, const wxSize& size = SYMBOL_QUITDIALOG_SIZE, long style = SYMBOL_QUITDIALOG_STYLE );
|
||||
|
||||
/// Initialises member variables
|
||||
void Init();
|
||||
|
||||
/// Creates the controls and sizers
|
||||
void CreateControls();
|
||||
|
||||
////@begin QuitDialog event handler declarations
|
||||
|
||||
////@end QuitDialog event handler declarations
|
||||
|
||||
////@begin QuitDialog member function declarations
|
||||
|
||||
int GetDialogClass() const { return m_iDialogClass ; }
|
||||
void SetDialogClass(int value) { m_iDialogClass = value ; }
|
||||
|
||||
wxString GetMessage() const { return m_sMessage ; }
|
||||
void SetMessage(wxString value) { m_sMessage = value ; }
|
||||
|
||||
/// Retrieves bitmap resources
|
||||
wxBitmap GetBitmapResource( const wxString& name );
|
||||
|
||||
/// Retrieves icon resources
|
||||
wxIcon GetIconResource( const wxString& name );
|
||||
////@end QuitDialog member function declarations
|
||||
|
||||
/// Should we show tooltips?
|
||||
static bool ShowToolTips();
|
||||
|
||||
////@begin QuitDialog member variables
|
||||
wxStaticBitmap* m_pCtrlBitmap;
|
||||
wxStaticText* m_pCtrlMessage;
|
||||
private:
|
||||
int m_iDialogClass;
|
||||
wxString m_sMessage;
|
||||
////@end QuitDialog member variables
|
||||
};
|
||||
|
||||
#endif
|
||||
// _QUITDIALOG_H_
|
||||
22
QuitDialog_symbols.h
Normal file
22
QuitDialog_symbols.h
Normal file
@@ -0,0 +1,22 @@
|
||||
// $Id: QuitDialog_symbols.h 216 2009-04-16 01:46:25Z felfert $
|
||||
//
|
||||
// Copyright (C) 2009 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#define ID_QUITDIALOG_SYMBOL_0 _("&Quit")
|
||||
39
README.md
Normal file
39
README.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# OSS evolution of classic nx technology - OpenNX CE
|
||||
|
||||
All these years, the classic nx was not as dead as it seemed ;)
|
||||
It is used in production and develops as fast as it can.
|
||||
|
||||
Continued development of the original code from http://opennx.net/
|
||||
|
||||
I am very grateful to the developers of the [ArcticaProject/nx-libs](https://github.com/ArcticaProject/nx-libs) for maintaining backward
|
||||
compatibility and the opportunity to use their libraries instead
|
||||
of self-assembly.
|
||||
|
||||
Compared to the original opennx new features added by community:
|
||||
|
||||
- Building with wxWidgets 3.0.4
|
||||
|
||||
- For win32 building with modified !M NX-libs uder cygwin. Xming not used.
|
||||
Sources of these libs may be found at [old git repo](http://git.etersoft.ru/people/dimbor/packages/?p=NXClient-W32.git)
|
||||
|
||||
- CUPS client mode: client's system CUPS used directlty
|
||||
This need to provide username/pass on each printer (like on win-resources);
|
||||
|
||||
- Pulseaudio sound: direct, tunnelled, with or without resampling.
|
||||
On Windows pulseaudio6 binarys are included;
|
||||
|
||||
- Localization of windows sharenames;
|
||||
|
||||
- On Windows original fonts from nxclient are included.
|
||||
|
||||
- ...
|
||||
|
||||
It worked with our own [freenx-server](https://github.com/dimbor-ru/freenx-server)
|
||||
And with classic nxserver 3.x.x compatibility remained.
|
||||
|
||||
Debian package home-maded for Devuan ASCII now. There is a suspicion that
|
||||
under Debian Stretch everything will be fine.
|
||||
|
||||
Windows installer can be downloaded at [unixforum.org](https://unixforum.org/up/nxman/OpenNXCE-1.0.1-r15.6.exe)
|
||||
|
||||
dimbor. 2021.
|
||||
366
RdpImageSettingsDialog.cpp
Normal file
366
RdpImageSettingsDialog.cpp
Normal file
@@ -0,0 +1,366 @@
|
||||
// $Id: RdpImageSettingsDialog.cpp 676 2012-02-05 16:18:21Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma implementation "RdpImageSettingsDialog.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
////@begin includes
|
||||
////@end includes
|
||||
|
||||
#include "RdpImageSettingsDialog.h"
|
||||
#include "MyXmlConfig.h"
|
||||
#include "Icon.h"
|
||||
#include "opennxApp.h"
|
||||
|
||||
#include <wx/cshelp.h>
|
||||
|
||||
////@begin XPM images
|
||||
////@end XPM images
|
||||
|
||||
/*!
|
||||
* RdpImageSettingsDialog type definition
|
||||
*/
|
||||
|
||||
IMPLEMENT_CLASS( RdpImageSettingsDialog, wxDialog )
|
||||
|
||||
/*!
|
||||
* RdpImageSettingsDialog event table definition
|
||||
*/
|
||||
|
||||
BEGIN_EVENT_TABLE( RdpImageSettingsDialog, wxDialog )
|
||||
|
||||
////@begin RdpImageSettingsDialog event table entries
|
||||
EVT_COMMAND_SCROLL_THUMBRELEASE( XRCID("ID_SLIDER_RDP_COLORS"), RdpImageSettingsDialog::OnSliderRdpColorsScrollThumbRelease )
|
||||
|
||||
EVT_RADIOBUTTON( XRCID("ID_RADIOBUTTON_RDP_JPEG_AND_RGB"), RdpImageSettingsDialog::OnRadiobuttonRdpJpegAndRgbSelected )
|
||||
|
||||
EVT_RADIOBUTTON( XRCID("ID_RADIOBUTTON_RDP_JPEG"), RdpImageSettingsDialog::OnRadiobuttonRdpJpegSelected )
|
||||
|
||||
EVT_RADIOBUTTON( XRCID("ID_RADIOBUTTON_RDP_PNG"), RdpImageSettingsDialog::OnRadiobuttonRdpPngSelected )
|
||||
|
||||
EVT_RADIOBUTTON( XRCID("ID_RADIOBUTTON_RDP_PLAIN"), RdpImageSettingsDialog::OnRadiobuttonRdpPlainSelected )
|
||||
|
||||
EVT_CHECKBOX( XRCID("ID_CHECKBOX_X11_JPEG_CUSTOMQUALITY"), RdpImageSettingsDialog::OnCheckboxX11JpegCustomqualityClick )
|
||||
|
||||
EVT_BUTTON( wxID_OK, RdpImageSettingsDialog::OnOkClick )
|
||||
|
||||
////@end RdpImageSettingsDialog event table entries
|
||||
|
||||
EVT_MENU(wxID_CONTEXT_HELP, RdpImageSettingsDialog::OnContextHelp)
|
||||
|
||||
END_EVENT_TABLE()
|
||||
|
||||
/*!
|
||||
* RdpImageSettingsDialog constructors
|
||||
*/
|
||||
|
||||
RdpImageSettingsDialog::RdpImageSettingsDialog( )
|
||||
: m_pCfg(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
RdpImageSettingsDialog::RdpImageSettingsDialog( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
||||
: m_pCfg(NULL)
|
||||
{
|
||||
Create(parent, id, caption, pos, size, style);
|
||||
}
|
||||
|
||||
void RdpImageSettingsDialog::SetConfig(MyXmlConfig *cfg)
|
||||
{
|
||||
m_pCfg = cfg;
|
||||
}
|
||||
|
||||
/*!
|
||||
* RdpImageSettingsDialog creator
|
||||
*/
|
||||
|
||||
bool RdpImageSettingsDialog::Create( wxWindow* parent, wxWindowID WXUNUSED(id), const wxString& WXUNUSED(caption), const wxPoint& WXUNUSED(pos), const wxSize& WXUNUSED(size), long WXUNUSED(style) )
|
||||
{
|
||||
////@begin RdpImageSettingsDialog member initialisation
|
||||
m_iRdpColors = 0;
|
||||
m_pCtrlUseJpegQuality = NULL;
|
||||
m_pCtrlJpegQuality = NULL;
|
||||
////@end RdpImageSettingsDialog member initialisation
|
||||
|
||||
wxASSERT_MSG(m_pCfg, _T("RdpImageSettingsDialog::Create: No configuration"));
|
||||
if (m_pCfg) {
|
||||
switch (m_pCfg->iGetRdpImageEncoding()) {
|
||||
case -1:
|
||||
m_bImageEncodingBoth = false;
|
||||
m_bImageEncodingJpeg = true;
|
||||
m_bImageEncodingPNG = false;
|
||||
m_bImageEncodingPlainX = false;
|
||||
m_bUseJpegQuality = true;
|
||||
break;
|
||||
case 0:
|
||||
m_bImageEncodingBoth = false;
|
||||
m_bImageEncodingJpeg = false;
|
||||
m_bImageEncodingPNG = false;
|
||||
m_bImageEncodingPlainX = true;
|
||||
m_bUseJpegQuality = false;
|
||||
break;
|
||||
case 1:
|
||||
m_bImageEncodingBoth = false;
|
||||
m_bImageEncodingJpeg = true;
|
||||
m_bImageEncodingPNG = false;
|
||||
m_bImageEncodingPlainX = false;
|
||||
m_bUseJpegQuality = false;
|
||||
break;
|
||||
case 2:
|
||||
m_bImageEncodingBoth = false;
|
||||
m_bImageEncodingJpeg = false;
|
||||
m_bImageEncodingPNG = true;
|
||||
m_bImageEncodingPlainX = false;
|
||||
m_bUseJpegQuality = false;
|
||||
break;
|
||||
case 3:
|
||||
m_bImageEncodingBoth = true;
|
||||
m_bImageEncodingJpeg = false;
|
||||
m_bImageEncodingPNG = false;
|
||||
m_bImageEncodingPlainX = false;
|
||||
m_bUseJpegQuality = false;
|
||||
break;
|
||||
case 4:
|
||||
m_bImageEncodingBoth = true;
|
||||
m_bImageEncodingJpeg = false;
|
||||
m_bImageEncodingPNG = false;
|
||||
m_bImageEncodingPlainX = false;
|
||||
m_bUseJpegQuality = true;
|
||||
break;
|
||||
}
|
||||
m_iJpegQuality = m_pCfg->iGetRdpJpegQuality();
|
||||
m_bRdpCache = m_pCfg->bGetRdpCache();
|
||||
m_iRdpColors = m_pCfg->iGetRdpColors();
|
||||
}
|
||||
|
||||
////@begin RdpImageSettingsDialog creation
|
||||
SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY|wxWS_EX_BLOCK_EVENTS|wxDIALOG_EX_CONTEXTHELP);
|
||||
SetParent(parent);
|
||||
CreateControls();
|
||||
SetIcon(GetIconResource(wxT("res/nx.png")));
|
||||
if (GetSizer())
|
||||
{
|
||||
GetSizer()->SetSizeHints(this);
|
||||
}
|
||||
Centre();
|
||||
////@end RdpImageSettingsDialog creation
|
||||
::wxGetApp().EnableContextHelp(this);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Control creation for RdpImageSettingsDialog
|
||||
*/
|
||||
|
||||
void RdpImageSettingsDialog::CreateControls()
|
||||
{
|
||||
////@begin RdpImageSettingsDialog content construction
|
||||
if (!wxXmlResource::Get()->LoadDialog(this, GetParent(), _T("ID_DIALOG_IMAGE_RDP")))
|
||||
wxLogError(wxT("Missing wxXmlResource::Get()->Load() in OnInit()?"));
|
||||
m_pCtrlUseJpegQuality = XRCCTRL(*this, "ID_CHECKBOX_X11_JPEG_CUSTOMQUALITY", wxCheckBox);
|
||||
m_pCtrlJpegQuality = XRCCTRL(*this, "ID_SLIDER_X11_JPEG_QALITY", wxSlider);
|
||||
// Set validators
|
||||
if (FindWindow(XRCID("ID_SLIDER_RDP_COLORS")))
|
||||
FindWindow(XRCID("ID_SLIDER_RDP_COLORS"))->SetValidator( wxGenericValidator(& m_iRdpColors) );
|
||||
if (FindWindow(XRCID("ID_RADIOBUTTON_RDP_JPEG_AND_RGB")))
|
||||
FindWindow(XRCID("ID_RADIOBUTTON_RDP_JPEG_AND_RGB"))->SetValidator( wxGenericValidator(& m_bImageEncodingBoth) );
|
||||
if (FindWindow(XRCID("ID_RADIOBUTTON_RDP_JPEG")))
|
||||
FindWindow(XRCID("ID_RADIOBUTTON_RDP_JPEG"))->SetValidator( wxGenericValidator(& m_bImageEncodingJpeg) );
|
||||
if (FindWindow(XRCID("ID_RADIOBUTTON_RDP_PNG")))
|
||||
FindWindow(XRCID("ID_RADIOBUTTON_RDP_PNG"))->SetValidator( wxGenericValidator(& m_bImageEncodingPNG) );
|
||||
if (FindWindow(XRCID("ID_RADIOBUTTON_RDP_PLAIN")))
|
||||
FindWindow(XRCID("ID_RADIOBUTTON_RDP_PLAIN"))->SetValidator( wxGenericValidator(& m_bImageEncodingPlainX) );
|
||||
if (FindWindow(XRCID("ID_CHECKBOX_X11_JPEG_CUSTOMQUALITY")))
|
||||
FindWindow(XRCID("ID_CHECKBOX_X11_JPEG_CUSTOMQUALITY"))->SetValidator( wxGenericValidator(& m_bUseJpegQuality) );
|
||||
if (FindWindow(XRCID("ID_SLIDER_X11_JPEG_QALITY")))
|
||||
FindWindow(XRCID("ID_SLIDER_X11_JPEG_QALITY"))->SetValidator( wxGenericValidator(& m_iJpegQuality) );
|
||||
if (FindWindow(XRCID("ID_CHECKBOX_RDP_IMGCACHE")))
|
||||
FindWindow(XRCID("ID_CHECKBOX_RDP_IMGCACHE"))->SetValidator( wxGenericValidator(& m_bRdpCache) );
|
||||
////@end RdpImageSettingsDialog content construction
|
||||
|
||||
// Create custom windows not generated automatically here.
|
||||
|
||||
////@begin RdpImageSettingsDialog content initialisation
|
||||
////@end RdpImageSettingsDialog content initialisation
|
||||
UpdateDialogConstraints(false);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Should we show tooltips?
|
||||
*/
|
||||
|
||||
bool RdpImageSettingsDialog::ShowToolTips()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get bitmap resources
|
||||
*/
|
||||
|
||||
wxBitmap RdpImageSettingsDialog::GetBitmapResource( const wxString& name )
|
||||
{
|
||||
// Bitmap retrieval
|
||||
return CreateBitmapFromFile(name);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get icon resources
|
||||
*/
|
||||
|
||||
wxIcon RdpImageSettingsDialog::GetIconResource( const wxString& name )
|
||||
{
|
||||
// Icon retrieval
|
||||
return CreateIconFromFile(name);
|
||||
}
|
||||
|
||||
void RdpImageSettingsDialog::OnContextHelp(wxCommandEvent &)
|
||||
{
|
||||
wxContextHelp contextHelp(this);
|
||||
}
|
||||
|
||||
void RdpImageSettingsDialog::UpdateDialogConstraints(bool fromWindow /* = true */)
|
||||
{
|
||||
if (fromWindow)
|
||||
TransferDataFromWindow();
|
||||
if (m_bImageEncodingBoth || m_bImageEncodingJpeg) {
|
||||
m_pCtrlUseJpegQuality->Enable();
|
||||
m_pCtrlJpegQuality->Enable(m_bUseJpegQuality);
|
||||
} else {
|
||||
m_pCtrlUseJpegQuality->Disable();
|
||||
m_pCtrlJpegQuality->Disable();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
|
||||
*/
|
||||
|
||||
void RdpImageSettingsDialog::OnOkClick( wxCommandEvent& event )
|
||||
{
|
||||
wxASSERT_MSG(m_pCfg, _T("RdpImageSettingsDialog::OnOkClick: No configuration"));
|
||||
if (m_pCfg) {
|
||||
TransferDataFromWindow();
|
||||
int ienc = 3;
|
||||
if (m_bImageEncodingBoth) {
|
||||
ienc = (m_bUseJpegQuality) ? 4 : 3;
|
||||
} else if (m_bImageEncodingJpeg) {
|
||||
ienc = (m_bUseJpegQuality) ? -1 : 1;
|
||||
} else if (m_bImageEncodingPNG) {
|
||||
ienc = 2;
|
||||
} else if (m_bImageEncodingPlainX) {
|
||||
ienc = 0;
|
||||
}
|
||||
m_pCfg->iSetRdpImageEncoding(ienc);
|
||||
m_pCfg->iSetRdpJpegQuality(m_iJpegQuality);
|
||||
m_pCfg->iSetRdpColors(m_iRdpColors);
|
||||
m_pCfg->bSetRdpCache(m_bRdpCache);
|
||||
}
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* wxEVT_SCROLL_THUMBRELEASE event handler for ID_SLIDER_RDP_COLORS
|
||||
*/
|
||||
|
||||
void RdpImageSettingsDialog::OnSliderRdpColorsScrollThumbRelease( wxScrollEvent& event )
|
||||
{
|
||||
wxSlider *sl = wxDynamicCast(event.GetEventObject(), wxSlider);
|
||||
// Stick slider to nearest integer position
|
||||
int p = event.GetPosition();
|
||||
sl->SetValue((p > 0) ? p - 1 : p + 1);
|
||||
sl->SetValue(p);
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RADIOBUTTON_RDP_JPEG_AND_RGB
|
||||
*/
|
||||
|
||||
void RdpImageSettingsDialog::OnRadiobuttonRdpJpegAndRgbSelected( wxCommandEvent& event )
|
||||
{
|
||||
UpdateDialogConstraints();
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RADIOBUTTON_RDP_JPEG
|
||||
*/
|
||||
|
||||
void RdpImageSettingsDialog::OnRadiobuttonRdpJpegSelected( wxCommandEvent& event )
|
||||
{
|
||||
UpdateDialogConstraints();
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RADIOBUTTON_RDP_PNG
|
||||
*/
|
||||
|
||||
void RdpImageSettingsDialog::OnRadiobuttonRdpPngSelected( wxCommandEvent& event )
|
||||
{
|
||||
UpdateDialogConstraints();
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RADIOBUTTON_RDP_PLAIN
|
||||
*/
|
||||
|
||||
void RdpImageSettingsDialog::OnRadiobuttonRdpPlainSelected( wxCommandEvent& event )
|
||||
{
|
||||
UpdateDialogConstraints();
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX_X11_JPEG_CUSTOMQUALITY
|
||||
*/
|
||||
|
||||
void RdpImageSettingsDialog::OnCheckboxX11JpegCustomqualityClick( wxCommandEvent& event )
|
||||
{
|
||||
UpdateDialogConstraints();
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
150
RdpImageSettingsDialog.h
Normal file
150
RdpImageSettingsDialog.h
Normal file
@@ -0,0 +1,150 @@
|
||||
// $Id: RdpImageSettingsDialog.h 676 2012-02-05 16:18:21Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _RDPIMAGESETTINGSDIALOG_H_
|
||||
#define _RDPIMAGESETTINGSDIALOG_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "RdpImageSettingsDialog.cpp"
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* Includes
|
||||
*/
|
||||
|
||||
////@begin includes
|
||||
#include "RdpImageSettingsDialog_symbols.h"
|
||||
#include "wx/xrc/xmlres.h"
|
||||
#include "wx/valgen.h"
|
||||
#include "wx/statline.h"
|
||||
////@end includes
|
||||
|
||||
/*!
|
||||
* Forward declarations
|
||||
*/
|
||||
|
||||
////@begin forward declarations
|
||||
////@end forward declarations
|
||||
class MyXmlConfig;
|
||||
|
||||
/*!
|
||||
* Control identifiers
|
||||
*/
|
||||
|
||||
////@begin control identifiers
|
||||
#define ID_DIALOG_IMAGE_RDP 10085
|
||||
#define SYMBOL_RDPIMAGESETTINGSDIALOG_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX
|
||||
#define SYMBOL_RDPIMAGESETTINGSDIALOG_TITLE _("RDP Image Settings - OpenNX")
|
||||
#define SYMBOL_RDPIMAGESETTINGSDIALOG_IDNAME ID_DIALOG_IMAGE_RDP
|
||||
#define SYMBOL_RDPIMAGESETTINGSDIALOG_SIZE wxDefaultSize
|
||||
#define SYMBOL_RDPIMAGESETTINGSDIALOG_POSITION wxDefaultPosition
|
||||
////@end control identifiers
|
||||
|
||||
/*!
|
||||
* Compatibility
|
||||
*/
|
||||
|
||||
#ifndef wxCLOSE_BOX
|
||||
#define wxCLOSE_BOX 0x1000
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* RdpImageSettingsDialog class declaration
|
||||
*/
|
||||
|
||||
class RdpImageSettingsDialog: public wxDialog
|
||||
{
|
||||
DECLARE_CLASS( RdpImageSettingsDialog )
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
public:
|
||||
/// Constructors
|
||||
RdpImageSettingsDialog( );
|
||||
RdpImageSettingsDialog( wxWindow* parent, wxWindowID id = SYMBOL_RDPIMAGESETTINGSDIALOG_IDNAME, const wxString& caption = SYMBOL_RDPIMAGESETTINGSDIALOG_TITLE, const wxPoint& pos = SYMBOL_RDPIMAGESETTINGSDIALOG_POSITION, const wxSize& size = SYMBOL_RDPIMAGESETTINGSDIALOG_SIZE, long style = SYMBOL_RDPIMAGESETTINGSDIALOG_STYLE );
|
||||
|
||||
/// Creation
|
||||
bool Create( wxWindow* parent, wxWindowID id = SYMBOL_RDPIMAGESETTINGSDIALOG_IDNAME, const wxString& caption = SYMBOL_RDPIMAGESETTINGSDIALOG_TITLE, const wxPoint& pos = SYMBOL_RDPIMAGESETTINGSDIALOG_POSITION, const wxSize& size = SYMBOL_RDPIMAGESETTINGSDIALOG_SIZE, long style = SYMBOL_RDPIMAGESETTINGSDIALOG_STYLE );
|
||||
void SetConfig(MyXmlConfig *);
|
||||
|
||||
private:
|
||||
/// Creates the controls and sizers
|
||||
void CreateControls();
|
||||
|
||||
void OnContextHelp(wxCommandEvent &);
|
||||
|
||||
////@begin RdpImageSettingsDialog event handler declarations
|
||||
|
||||
/// wxEVT_SCROLL_THUMBRELEASE event handler for ID_SLIDER_RDP_COLORS
|
||||
void OnSliderRdpColorsScrollThumbRelease( wxScrollEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RADIOBUTTON_RDP_JPEG_AND_RGB
|
||||
void OnRadiobuttonRdpJpegAndRgbSelected( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RADIOBUTTON_RDP_JPEG
|
||||
void OnRadiobuttonRdpJpegSelected( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RADIOBUTTON_RDP_PNG
|
||||
void OnRadiobuttonRdpPngSelected( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RADIOBUTTON_RDP_PLAIN
|
||||
void OnRadiobuttonRdpPlainSelected( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX_X11_JPEG_CUSTOMQUALITY
|
||||
void OnCheckboxX11JpegCustomqualityClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
|
||||
void OnOkClick( wxCommandEvent& event );
|
||||
|
||||
////@end RdpImageSettingsDialog event handler declarations
|
||||
|
||||
////@begin RdpImageSettingsDialog member function declarations
|
||||
|
||||
/// Retrieves bitmap resources
|
||||
wxBitmap GetBitmapResource( const wxString& name );
|
||||
|
||||
/// Retrieves icon resources
|
||||
wxIcon GetIconResource( const wxString& name );
|
||||
////@end RdpImageSettingsDialog member function declarations
|
||||
|
||||
/// Should we show tooltips?
|
||||
static bool ShowToolTips();
|
||||
|
||||
void UpdateDialogConstraints(bool fromWindow = true);
|
||||
|
||||
////@begin RdpImageSettingsDialog member variables
|
||||
wxCheckBox* m_pCtrlUseJpegQuality;
|
||||
wxSlider* m_pCtrlJpegQuality;
|
||||
private:
|
||||
bool m_bRdpCache;
|
||||
int m_iRdpColors;
|
||||
bool m_bImageEncodingBoth;
|
||||
bool m_bImageEncodingJpeg;
|
||||
bool m_bImageEncodingPNG;
|
||||
bool m_bImageEncodingPlainX;
|
||||
bool m_bUseJpegQuality;
|
||||
int m_iJpegQuality;
|
||||
////@end RdpImageSettingsDialog member variables
|
||||
|
||||
MyXmlConfig *m_pCfg;
|
||||
};
|
||||
|
||||
#endif
|
||||
// _RDPIMAGESETTINGSDIALOG_H_
|
||||
37
RdpImageSettingsDialog_symbols.h
Normal file
37
RdpImageSettingsDialog_symbols.h
Normal file
@@ -0,0 +1,37 @@
|
||||
// $Id: RdpImageSettingsDialog_symbols.h 674 2012-02-05 05:55:40Z felfert $
|
||||
//
|
||||
// Copyright (C) 2011 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#define ID_DIALOG_IMAGE_RDP_SYMBOL_0 _("RDP Image Settings - OpenNX")
|
||||
#define ID_DIALOG_IMAGE_RDP_SYMBOL_1 _("Allowed colors")
|
||||
#define ID_DIALOG_IMAGE_RDP_SYMBOL_2 _("256")
|
||||
#define ID_DIALOG_IMAGE_RDP_SYMBOL_3 _("32K")
|
||||
#define ID_DIALOG_IMAGE_RDP_SYMBOL_4 _("64K")
|
||||
#define ID_DIALOG_IMAGE_RDP_SYMBOL_5 _("16M")
|
||||
#define ID_DIALOG_IMAGE_RDP_SYMBOL_6 _("Encoding")
|
||||
#define ID_DIALOG_IMAGE_RDP_SYMBOL_7 _("Use JPEG and RGB image compression")
|
||||
#define ID_DIALOG_IMAGE_RDP_SYMBOL_8 _("Use JPEG image compression only")
|
||||
#define ID_DIALOG_IMAGE_RDP_SYMBOL_9 _("Use RGB image compression only")
|
||||
#define ID_DIALOG_IMAGE_RDP_SYMBOL_10 _("Use plain X bitmaps")
|
||||
#define ID_DIALOG_IMAGE_RDP_SYMBOL_11 _("Use custom image quality")
|
||||
#define ID_DIALOG_IMAGE_RDP_SYMBOL_12 _("Cache")
|
||||
#define ID_DIALOG_IMAGE_RDP_SYMBOL_13 _("Enable RDP image cache")
|
||||
#define ID_DIALOG_IMAGE_RDP_SYMBOL_14 _("&OK")
|
||||
#define ID_DIALOG_IMAGE_RDP_SYMBOL_15 _("&Cancel")
|
||||
405
RdpPropertyDialog.cpp
Normal file
405
RdpPropertyDialog.cpp
Normal file
@@ -0,0 +1,405 @@
|
||||
// $Id: RdpPropertyDialog.cpp 590 2010-10-23 22:42:11Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma implementation "RdpPropertyDialog.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
////@begin includes
|
||||
////@end includes
|
||||
|
||||
#include "RdpPropertyDialog.h"
|
||||
#include "Icon.h"
|
||||
#include "MyXmlConfig.h"
|
||||
#include "MyValidator.h"
|
||||
#include "opennxApp.h"
|
||||
|
||||
#include <wx/config.h>
|
||||
#include <wx/cshelp.h>
|
||||
|
||||
////@begin XPM images
|
||||
////@end XPM images
|
||||
|
||||
/*!
|
||||
* RdpPropertyDialog type definition
|
||||
*/
|
||||
|
||||
IMPLEMENT_CLASS( RdpPropertyDialog, wxDialog )
|
||||
|
||||
/*!
|
||||
* RdpPropertyDialog event table definition
|
||||
*/
|
||||
|
||||
BEGIN_EVENT_TABLE( RdpPropertyDialog, wxDialog )
|
||||
|
||||
////@begin RdpPropertyDialog event table entries
|
||||
EVT_RADIOBUTTON( XRCID("ID_RADIOBUTTON_RDP_WINLOGON"), RdpPropertyDialog::OnRadiobuttonRdpWinlogonSelected )
|
||||
|
||||
EVT_RADIOBUTTON( XRCID("ID_RADIOBUTTON_RDP_NXAUTH"), RdpPropertyDialog::OnRadiobuttonRdpNxauthSelected )
|
||||
|
||||
EVT_RADIOBUTTON( XRCID("ID_RADIOBUTTON_RDP_AUTOLOGIN"), RdpPropertyDialog::OnRadiobuttonRdpAutologinSelected )
|
||||
|
||||
EVT_RADIOBUTTON( XRCID("ID_RADIOBUTTON_RDP_DESKTOP"), RdpPropertyDialog::OnRadiobuttonRdpDesktopSelected )
|
||||
|
||||
EVT_RADIOBUTTON( XRCID("ID_RADIOBUTTON_RDP_RUNAPP"), RdpPropertyDialog::OnRadiobuttonRdpRunappSelected )
|
||||
|
||||
EVT_BUTTON( wxID_OK, RdpPropertyDialog::OnOkClick )
|
||||
|
||||
////@end RdpPropertyDialog event table entries
|
||||
|
||||
EVT_MENU(wxID_CONTEXT_HELP, RdpPropertyDialog::OnContextHelp)
|
||||
|
||||
END_EVENT_TABLE()
|
||||
|
||||
/*!
|
||||
* RdpPropertyDialog constructors
|
||||
*/
|
||||
|
||||
RdpPropertyDialog::RdpPropertyDialog( )
|
||||
: m_pCfg(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
RdpPropertyDialog::RdpPropertyDialog( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
||||
: m_pCfg(NULL)
|
||||
{
|
||||
Create(parent, id, caption, pos, size, style);
|
||||
}
|
||||
|
||||
void RdpPropertyDialog::SetConfig(MyXmlConfig *cfg)
|
||||
{
|
||||
m_pCfg = cfg;
|
||||
}
|
||||
|
||||
/*!
|
||||
* RdpPropertyDialog creator
|
||||
*/
|
||||
|
||||
bool RdpPropertyDialog::Create( wxWindow* parent, wxWindowID WXUNUSED(id), const wxString& WXUNUSED(caption), const wxPoint& WXUNUSED(pos), const wxSize& WXUNUSED(size), long WXUNUSED(style) )
|
||||
{
|
||||
////@begin RdpPropertyDialog member initialisation
|
||||
m_bAutoLogin = false;
|
||||
m_bShowWinLogon = false;
|
||||
m_bUseNxAuth = false;
|
||||
m_pCtrlAutologin = NULL;
|
||||
m_pCtrlUsername = NULL;
|
||||
m_pCtrlPassword = NULL;
|
||||
m_pCtrlRememberPassword = NULL;
|
||||
m_pCtrlRootless = NULL;
|
||||
m_pCtrlRunApplication = NULL;
|
||||
m_pCtrlApplicationString = NULL;
|
||||
////@end RdpPropertyDialog member initialisation
|
||||
wxASSERT_MSG(m_pCfg, _T("RdpPropertyDialog::Create: No configuration"));
|
||||
if (m_pCfg) {
|
||||
m_bRememberPassword = m_pCfg->bGetRdpRememberPassword();
|
||||
m_bRootless = m_pCfg->bGetRdpRootless();
|
||||
m_bRunApplication = m_pCfg->bGetRdpRunApplication();
|
||||
m_bRunDesktop = !m_bRunApplication;
|
||||
m_sHostname = m_pCfg->sGetRdpHostName();
|
||||
m_sUsername = m_pCfg->sGetRdpUsername();
|
||||
m_sPassword = m_pCfg->sGetRdpPassword();
|
||||
m_sRunCommand = m_pCfg->sGetRdpApplication();
|
||||
m_sRdpDomain = m_pCfg->sGetRdpDomain();
|
||||
int atype = m_pCfg->iGetRdpAuthType();
|
||||
switch (atype) {
|
||||
case 0:
|
||||
m_bAutoLogin = true;
|
||||
break;
|
||||
case 1:
|
||||
m_bShowWinLogon = true;
|
||||
break;
|
||||
case 2:
|
||||
m_bUseNxAuth = true;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
wxConfigBase::Get()->Read(wxT("Config/StorePasswords"), &m_bStorePasswords, true);
|
||||
if (!m_bStorePasswords)
|
||||
m_bRememberPassword = false;
|
||||
|
||||
////@begin RdpPropertyDialog creation
|
||||
SetExtraStyle(wxWS_EX_BLOCK_EVENTS|wxDIALOG_EX_CONTEXTHELP);
|
||||
SetParent(parent);
|
||||
CreateControls();
|
||||
SetIcon(GetIconResource(wxT("res/nx.png")));
|
||||
if (GetSizer())
|
||||
{
|
||||
GetSizer()->SetSizeHints(this);
|
||||
}
|
||||
Centre();
|
||||
////@end RdpPropertyDialog creation
|
||||
::wxGetApp().EnableContextHelp(this);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Control creation for RdpPropertyDialog
|
||||
*/
|
||||
|
||||
void RdpPropertyDialog::CreateControls()
|
||||
{
|
||||
////@begin RdpPropertyDialog content construction
|
||||
if (!wxXmlResource::Get()->LoadDialog(this, GetParent(), _T("ID_DIALOG_SETTINGS_RDP")))
|
||||
wxLogError(wxT("Missing wxXmlResource::Get()->Load() in OnInit()?"));
|
||||
m_pCtrlAutologin = XRCCTRL(*this, "ID_RADIOBUTTON_RDP_AUTOLOGIN", wxRadioButton);
|
||||
m_pCtrlUsername = XRCCTRL(*this, "ID_TEXTCTRL_RDP_USERNAME", wxTextCtrl);
|
||||
m_pCtrlPassword = XRCCTRL(*this, "ID_TEXTCTRL_RDP_PASSWORD", wxTextCtrl);
|
||||
m_pCtrlRememberPassword = XRCCTRL(*this, "ID_CHECKBOX_RDP_REMEMBER_PWD", wxCheckBox);
|
||||
m_pCtrlRootless = XRCCTRL(*this, "ID_CHECKBOX_RDP_ROOTLESS", wxCheckBox);
|
||||
m_pCtrlRunApplication = XRCCTRL(*this, "ID_RADIOBUTTON_RDP_RUNAPP", wxRadioButton);
|
||||
m_pCtrlApplicationString = XRCCTRL(*this, "ID_TEXTCTRL_RDP_APPLICATION", wxTextCtrl);
|
||||
// Set validators
|
||||
if (FindWindow(XRCID("ID_TEXTCTRL_RDP_HOST")))
|
||||
FindWindow(XRCID("ID_TEXTCTRL_RDP_HOST"))->SetValidator( wxGenericValidator(& m_sHostname) );
|
||||
if (FindWindow(XRCID("ID_TEXTCTRL_RDP_DOMAIN")))
|
||||
FindWindow(XRCID("ID_TEXTCTRL_RDP_DOMAIN"))->SetValidator( wxTextValidator(wxFILTER_NONE, & m_sRdpDomain) );
|
||||
if (FindWindow(XRCID("ID_RADIOBUTTON_RDP_WINLOGON")))
|
||||
FindWindow(XRCID("ID_RADIOBUTTON_RDP_WINLOGON"))->SetValidator( wxGenericValidator(& m_bShowWinLogon) );
|
||||
if (FindWindow(XRCID("ID_RADIOBUTTON_RDP_NXAUTH")))
|
||||
FindWindow(XRCID("ID_RADIOBUTTON_RDP_NXAUTH"))->SetValidator( wxGenericValidator(& m_bUseNxAuth) );
|
||||
if (FindWindow(XRCID("ID_RADIOBUTTON_RDP_AUTOLOGIN")))
|
||||
FindWindow(XRCID("ID_RADIOBUTTON_RDP_AUTOLOGIN"))->SetValidator( wxGenericValidator(& m_bAutoLogin) );
|
||||
if (FindWindow(XRCID("ID_TEXTCTRL_RDP_USERNAME")))
|
||||
FindWindow(XRCID("ID_TEXTCTRL_RDP_USERNAME"))->SetValidator( wxGenericValidator(& m_sUsername) );
|
||||
if (FindWindow(XRCID("ID_TEXTCTRL_RDP_PASSWORD")))
|
||||
FindWindow(XRCID("ID_TEXTCTRL_RDP_PASSWORD"))->SetValidator( wxGenericValidator(& m_sPassword) );
|
||||
if (FindWindow(XRCID("ID_CHECKBOX_RDP_REMEMBER_PWD")))
|
||||
FindWindow(XRCID("ID_CHECKBOX_RDP_REMEMBER_PWD"))->SetValidator( wxGenericValidator(& m_bRememberPassword) );
|
||||
if (FindWindow(XRCID("ID_CHECKBOX_RDP_ROOTLESS")))
|
||||
FindWindow(XRCID("ID_CHECKBOX_RDP_ROOTLESS"))->SetValidator( wxGenericValidator(& m_bRootless) );
|
||||
if (FindWindow(XRCID("ID_RADIOBUTTON_RDP_DESKTOP")))
|
||||
FindWindow(XRCID("ID_RADIOBUTTON_RDP_DESKTOP"))->SetValidator( wxGenericValidator(& m_bRunDesktop) );
|
||||
if (FindWindow(XRCID("ID_RADIOBUTTON_RDP_RUNAPP")))
|
||||
FindWindow(XRCID("ID_RADIOBUTTON_RDP_RUNAPP"))->SetValidator( wxGenericValidator(& m_bRunApplication) );
|
||||
if (FindWindow(XRCID("ID_TEXTCTRL_RDP_APPLICATION")))
|
||||
FindWindow(XRCID("ID_TEXTCTRL_RDP_APPLICATION"))->SetValidator( wxGenericValidator(& m_sRunCommand) );
|
||||
////@end RdpPropertyDialog content construction
|
||||
|
||||
if (!m_bStorePasswords)
|
||||
m_pCtrlRememberPassword->Enable(false);
|
||||
|
||||
////@begin RdpPropertyDialog content initialisation
|
||||
////@end RdpPropertyDialog content initialisation
|
||||
UpdateDialogConstraints();
|
||||
}
|
||||
|
||||
/*!
|
||||
* Should we show tooltips?
|
||||
*/
|
||||
|
||||
bool RdpPropertyDialog::ShowToolTips()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get bitmap resources
|
||||
*/
|
||||
|
||||
wxBitmap RdpPropertyDialog::GetBitmapResource( const wxString& name )
|
||||
{
|
||||
// Bitmap retrieval
|
||||
return CreateBitmapFromFile(name);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get icon resources
|
||||
*/
|
||||
|
||||
wxIcon RdpPropertyDialog::GetIconResource( const wxString& name )
|
||||
{
|
||||
// Icon retrieval
|
||||
return CreateIconFromFile(name);
|
||||
}
|
||||
|
||||
void RdpPropertyDialog::OnContextHelp(wxCommandEvent &)
|
||||
{
|
||||
wxContextHelp contextHelp(this);
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RADIOBUTTON_RDP_AUTOLOGIN
|
||||
*/
|
||||
|
||||
void RdpPropertyDialog::OnRadiobuttonRdpAutologinSelected( wxCommandEvent& event )
|
||||
{
|
||||
m_bAutoLogin = true;
|
||||
UpdateDialogConstraints();
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RADIOBUTTON_RDP_NXAUTH
|
||||
*/
|
||||
|
||||
void RdpPropertyDialog::OnRadiobuttonRdpNxauthSelected( wxCommandEvent& event )
|
||||
{
|
||||
m_bAutoLogin = false;
|
||||
UpdateDialogConstraints();
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RADIOBUTTON_RDP_WINLOGON
|
||||
*/
|
||||
|
||||
void RdpPropertyDialog::OnRadiobuttonRdpWinlogonSelected( wxCommandEvent& event )
|
||||
{
|
||||
m_bAutoLogin = false;
|
||||
UpdateDialogConstraints();
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RADIOBUTTON_RDP_DESKTOP
|
||||
*/
|
||||
|
||||
void RdpPropertyDialog::OnRadiobuttonRdpDesktopSelected( wxCommandEvent& event )
|
||||
{
|
||||
m_bRunApplication = false;
|
||||
UpdateDialogConstraints();
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RADIOBUTTON_RDP_RUNAPP
|
||||
*/
|
||||
|
||||
void RdpPropertyDialog::OnRadiobuttonRdpRunappSelected( wxCommandEvent& event )
|
||||
{
|
||||
m_bRunApplication = true;
|
||||
UpdateDialogConstraints();
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void RdpPropertyDialog::UpdateDialogConstraints()
|
||||
{
|
||||
m_pCtrlUsername->Enable(m_bAutoLogin);
|
||||
m_pCtrlPassword->Enable(m_bAutoLogin);
|
||||
m_pCtrlRememberPassword->Enable(m_bStorePasswords && m_bAutoLogin);
|
||||
m_pCtrlApplicationString->Enable(m_bRunApplication);
|
||||
}
|
||||
/*!
|
||||
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
|
||||
*/
|
||||
|
||||
void RdpPropertyDialog::OnOkClick( wxCommandEvent& event )
|
||||
{
|
||||
wxASSERT_MSG(m_pCfg, _T("RdpPropertyDialog::OnOkClick: No configuration"));
|
||||
if (m_pCfg) {
|
||||
TransferDataFromWindow();
|
||||
m_pCfg->bSetRdpRememberPassword(m_bRememberPassword);
|
||||
m_pCfg->bSetRdpRootless(m_bRootless);
|
||||
m_pCfg->bSetRdpRunApplication(m_bRunApplication);
|
||||
m_pCfg->sSetRdpHostName(m_sHostname);
|
||||
m_pCfg->sSetRdpUsername(m_sUsername);
|
||||
m_pCfg->sSetRdpPassword(m_sPassword);
|
||||
m_pCfg->sSetRdpApplication(m_sRunCommand);
|
||||
m_pCfg->sSetRdpDomain(m_sRdpDomain);
|
||||
int atype = 2;
|
||||
if (m_bShowWinLogon)
|
||||
atype = 1;
|
||||
if (m_bAutoLogin)
|
||||
atype = 0;
|
||||
m_pCfg->iSetRdpAuthType(atype);
|
||||
}
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
#ifdef __WXMSW__
|
||||
/* dimbor: on wxWindows 3.0.2 we need to make a sunset by hand
|
||||
for some reason */
|
||||
bool RdpPropertyDialog::TransferDataToWindow()
|
||||
{
|
||||
wxDialog::TransferDataToWindow();
|
||||
if (FindWindow(XRCID("ID_TEXTCTRL_RDP_HOST")))
|
||||
FindWindow(XRCID("ID_TEXTCTRL_RDP_HOST"))->GetValidator()->TransferToWindow();
|
||||
if (FindWindow(XRCID("ID_TEXTCTRL_RDP_DOMAIN")))
|
||||
FindWindow(XRCID("ID_TEXTCTRL_RDP_DOMAIN"))->GetValidator()->TransferToWindow();
|
||||
if (FindWindow(XRCID("ID_RADIOBUTTON_RDP_WINLOGON")))
|
||||
FindWindow(XRCID("ID_RADIOBUTTON_RDP_WINLOGON"))->GetValidator()->TransferToWindow();
|
||||
if (FindWindow(XRCID("ID_RADIOBUTTON_RDP_NXAUTH")))
|
||||
FindWindow(XRCID("ID_RADIOBUTTON_RDP_NXAUTH"))->GetValidator()->TransferToWindow();
|
||||
if (FindWindow(XRCID("ID_RADIOBUTTON_RDP_AUTOLOGIN")))
|
||||
FindWindow(XRCID("ID_RADIOBUTTON_RDP_AUTOLOGIN"))->GetValidator()->TransferToWindow();
|
||||
if (FindWindow(XRCID("ID_TEXTCTRL_RDP_USERNAME")))
|
||||
FindWindow(XRCID("ID_TEXTCTRL_RDP_USERNAME"))->GetValidator()->TransferToWindow();
|
||||
if (FindWindow(XRCID("ID_TEXTCTRL_RDP_PASSWORD")))
|
||||
FindWindow(XRCID("ID_TEXTCTRL_RDP_PASSWORD"))->GetValidator()->TransferToWindow();
|
||||
if (FindWindow(XRCID("ID_CHECKBOX_RDP_REMEMBER_PWD")))
|
||||
FindWindow(XRCID("ID_CHECKBOX_RDP_REMEMBER_PWD"))->GetValidator()->TransferToWindow();
|
||||
if (FindWindow(XRCID("ID_CHECKBOX_RDP_ROOTLESS")))
|
||||
FindWindow(XRCID("ID_CHECKBOX_RDP_ROOTLESS"))->GetValidator()->TransferToWindow();
|
||||
if (FindWindow(XRCID("ID_RADIOBUTTON_RDP_DESKTOP")))
|
||||
FindWindow(XRCID("ID_RADIOBUTTON_RDP_DESKTOP"))->GetValidator()->TransferToWindow();
|
||||
if (FindWindow(XRCID("ID_RADIOBUTTON_RDP_RUNAPP")))
|
||||
FindWindow(XRCID("ID_RADIOBUTTON_RDP_RUNAPP"))->GetValidator()->TransferToWindow();
|
||||
if (FindWindow(XRCID("ID_TEXTCTRL_RDP_APPLICATION")))
|
||||
FindWindow(XRCID("ID_TEXTCTRL_RDP_APPLICATION"))->GetValidator()->TransferToWindow();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RdpPropertyDialog::TransferDataFromWindow()
|
||||
{
|
||||
wxDialog::TransferDataFromWindow();
|
||||
if (FindWindow(XRCID("ID_TEXTCTRL_RDP_HOST")))
|
||||
FindWindow(XRCID("ID_TEXTCTRL_RDP_HOST"))->GetValidator()->TransferFromWindow();
|
||||
if (FindWindow(XRCID("ID_TEXTCTRL_RDP_DOMAIN")))
|
||||
FindWindow(XRCID("ID_TEXTCTRL_RDP_DOMAIN"))->GetValidator()->TransferFromWindow();
|
||||
if (FindWindow(XRCID("ID_RADIOBUTTON_RDP_WINLOGON")))
|
||||
FindWindow(XRCID("ID_RADIOBUTTON_RDP_WINLOGON"))->GetValidator()->TransferFromWindow();
|
||||
if (FindWindow(XRCID("ID_RADIOBUTTON_RDP_NXAUTH")))
|
||||
FindWindow(XRCID("ID_RADIOBUTTON_RDP_NXAUTH"))->GetValidator()->TransferFromWindow();
|
||||
if (FindWindow(XRCID("ID_RADIOBUTTON_RDP_AUTOLOGIN")))
|
||||
FindWindow(XRCID("ID_RADIOBUTTON_RDP_AUTOLOGIN"))->GetValidator()->TransferFromWindow();
|
||||
if (FindWindow(XRCID("ID_TEXTCTRL_RDP_USERNAME")))
|
||||
FindWindow(XRCID("ID_TEXTCTRL_RDP_USERNAME"))->GetValidator()->TransferFromWindow();
|
||||
if (FindWindow(XRCID("ID_TEXTCTRL_RDP_PASSWORD")))
|
||||
FindWindow(XRCID("ID_TEXTCTRL_RDP_PASSWORD"))->GetValidator()->TransferFromWindow();
|
||||
if (FindWindow(XRCID("ID_CHECKBOX_RDP_REMEMBER_PWD")))
|
||||
FindWindow(XRCID("ID_CHECKBOX_RDP_REMEMBER_PWD"))->GetValidator()->TransferFromWindow();
|
||||
if (FindWindow(XRCID("ID_CHECKBOX_RDP_ROOTLESS")))
|
||||
FindWindow(XRCID("ID_CHECKBOX_RDP_ROOTLESS"))->GetValidator()->TransferFromWindow();
|
||||
if (FindWindow(XRCID("ID_RADIOBUTTON_RDP_DESKTOP")))
|
||||
FindWindow(XRCID("ID_RADIOBUTTON_RDP_DESKTOP"))->GetValidator()->TransferFromWindow();
|
||||
if (FindWindow(XRCID("ID_RADIOBUTTON_RDP_RUNAPP")))
|
||||
FindWindow(XRCID("ID_RADIOBUTTON_RDP_RUNAPP"))->GetValidator()->TransferFromWindow();
|
||||
if (FindWindow(XRCID("ID_TEXTCTRL_RDP_APPLICATION")))
|
||||
FindWindow(XRCID("ID_TEXTCTRL_RDP_APPLICATION"))->GetValidator()->TransferFromWindow();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
166
RdpPropertyDialog.h
Normal file
166
RdpPropertyDialog.h
Normal file
@@ -0,0 +1,166 @@
|
||||
// $Id: RdpPropertyDialog.h 590 2010-10-23 22:42:11Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _RDPPROPERTYDIALOG_H_
|
||||
#define _RDPPROPERTYDIALOG_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "RdpPropertyDialog.cpp"
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* Includes
|
||||
*/
|
||||
|
||||
////@begin includes
|
||||
#include "RdpPropertyDialog_symbols.h"
|
||||
#include "wx/xrc/xmlres.h"
|
||||
#include "wx/valgen.h"
|
||||
#include "wx/valtext.h"
|
||||
#include "wx/statline.h"
|
||||
////@end includes
|
||||
|
||||
/*!
|
||||
* Forward declarations
|
||||
*/
|
||||
|
||||
class MyXmlConfig;
|
||||
|
||||
////@begin forward declarations
|
||||
////@end forward declarations
|
||||
|
||||
/*!
|
||||
* Control identifiers
|
||||
*/
|
||||
|
||||
////@begin control identifiers
|
||||
#define ID_DIALOG_SETTINGS_RDP 10065
|
||||
#define SYMBOL_RDPPROPERTYDIALOG_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX
|
||||
#define SYMBOL_RDPPROPERTYDIALOG_TITLE _("RDP Session Settings - OpenNX")
|
||||
#define SYMBOL_RDPPROPERTYDIALOG_IDNAME ID_DIALOG_SETTINGS_RDP
|
||||
#define SYMBOL_RDPPROPERTYDIALOG_SIZE wxSize(200, 150)
|
||||
#define SYMBOL_RDPPROPERTYDIALOG_POSITION wxDefaultPosition
|
||||
////@end control identifiers
|
||||
|
||||
/*!
|
||||
* Compatibility
|
||||
*/
|
||||
|
||||
#ifndef wxCLOSE_BOX
|
||||
#define wxCLOSE_BOX 0x1000
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* RdpPropertyDialog class declaration
|
||||
*/
|
||||
|
||||
class RdpPropertyDialog: public wxDialog
|
||||
{
|
||||
DECLARE_CLASS( RdpPropertyDialog )
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
public:
|
||||
/// Constructors
|
||||
RdpPropertyDialog( );
|
||||
RdpPropertyDialog( wxWindow* parent, wxWindowID id = SYMBOL_RDPPROPERTYDIALOG_IDNAME, const wxString& caption = SYMBOL_RDPPROPERTYDIALOG_TITLE, const wxPoint& pos = SYMBOL_RDPPROPERTYDIALOG_POSITION, const wxSize& size = SYMBOL_RDPPROPERTYDIALOG_SIZE, long style = SYMBOL_RDPPROPERTYDIALOG_STYLE );
|
||||
|
||||
/// Creation
|
||||
bool Create( wxWindow* parent, wxWindowID id = SYMBOL_RDPPROPERTYDIALOG_IDNAME, const wxString& caption = SYMBOL_RDPPROPERTYDIALOG_TITLE, const wxPoint& pos = SYMBOL_RDPPROPERTYDIALOG_POSITION, const wxSize& size = SYMBOL_RDPPROPERTYDIALOG_SIZE, long style = SYMBOL_RDPPROPERTYDIALOG_STYLE );
|
||||
|
||||
void SetConfig(MyXmlConfig *);
|
||||
void UpdateDialogConstraints();
|
||||
|
||||
|
||||
#ifdef __WXMSW__
|
||||
bool TransferDataToWindow();
|
||||
bool TransferDataFromWindow();
|
||||
#endif
|
||||
private:
|
||||
/// Creates the controls and sizers
|
||||
void CreateControls();
|
||||
|
||||
void OnContextHelp(wxCommandEvent &);
|
||||
|
||||
////@begin RdpPropertyDialog event handler declarations
|
||||
|
||||
/// wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RADIOBUTTON_RDP_WINLOGON
|
||||
void OnRadiobuttonRdpWinlogonSelected( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RADIOBUTTON_RDP_NXAUTH
|
||||
void OnRadiobuttonRdpNxauthSelected( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RADIOBUTTON_RDP_AUTOLOGIN
|
||||
void OnRadiobuttonRdpAutologinSelected( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RADIOBUTTON_RDP_DESKTOP
|
||||
void OnRadiobuttonRdpDesktopSelected( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RADIOBUTTON_RDP_RUNAPP
|
||||
void OnRadiobuttonRdpRunappSelected( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
|
||||
void OnOkClick( wxCommandEvent& event );
|
||||
|
||||
////@end RdpPropertyDialog event handler declarations
|
||||
|
||||
public:
|
||||
////@begin RdpPropertyDialog member function declarations
|
||||
|
||||
/// Retrieves bitmap resources
|
||||
wxBitmap GetBitmapResource( const wxString& name );
|
||||
|
||||
/// Retrieves icon resources
|
||||
wxIcon GetIconResource( const wxString& name );
|
||||
////@end RdpPropertyDialog member function declarations
|
||||
|
||||
/// Should we show tooltips?
|
||||
static bool ShowToolTips();
|
||||
|
||||
private:
|
||||
////@begin RdpPropertyDialog member variables
|
||||
wxRadioButton* m_pCtrlAutologin;
|
||||
wxTextCtrl* m_pCtrlUsername;
|
||||
wxTextCtrl* m_pCtrlPassword;
|
||||
wxCheckBox* m_pCtrlRememberPassword;
|
||||
wxCheckBox* m_pCtrlRootless;
|
||||
wxRadioButton* m_pCtrlRunApplication;
|
||||
wxTextCtrl* m_pCtrlApplicationString;
|
||||
private:
|
||||
wxString m_sHostname;
|
||||
wxString m_sUsername;
|
||||
wxString m_sPassword;
|
||||
wxString m_sRunCommand;
|
||||
bool m_bAutoLogin;
|
||||
bool m_bRememberPassword;
|
||||
bool m_bRootless;
|
||||
bool m_bShowWinLogon;
|
||||
bool m_bUseNxAuth;
|
||||
bool m_bRunDesktop;
|
||||
bool m_bRunApplication;
|
||||
wxString m_sRdpDomain;
|
||||
////@end RdpPropertyDialog member variables
|
||||
|
||||
MyXmlConfig *m_pCfg;
|
||||
bool m_bStorePasswords;
|
||||
};
|
||||
|
||||
#endif
|
||||
// _RDPPROPERTYDIALOG_H_
|
||||
36
RdpPropertyDialog_symbols.h
Normal file
36
RdpPropertyDialog_symbols.h
Normal file
@@ -0,0 +1,36 @@
|
||||
// $Id: RdpPropertyDialog_symbols.h 674 2012-02-05 05:55:40Z felfert $
|
||||
//
|
||||
// Copyright (C) 2011 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#define ID_DIALOG_SETTINGS_RDP_SYMBOL_0 _("RDP Session Settings - OpenNX")
|
||||
#define ID_DIALOG_SETTINGS_RDP_SYMBOL_1 _("Server")
|
||||
#define ID_DIALOG_SETTINGS_RDP_SYMBOL_2 _("Domain")
|
||||
#define ID_DIALOG_SETTINGS_RDP_SYMBOL_3 _("Authentication")
|
||||
#define ID_DIALOG_SETTINGS_RDP_SYMBOL_4 _("Show the Windows logon")
|
||||
#define ID_DIALOG_SETTINGS_RDP_SYMBOL_5 _("Use NX credentials")
|
||||
#define ID_DIALOG_SETTINGS_RDP_SYMBOL_6 _("Use the following credentials")
|
||||
#define ID_DIALOG_SETTINGS_RDP_SYMBOL_7 _("Username")
|
||||
#define ID_DIALOG_SETTINGS_RDP_SYMBOL_8 _("Password")
|
||||
#define ID_DIALOG_SETTINGS_RDP_SYMBOL_9 _("Remember my password")
|
||||
#define ID_DIALOG_SETTINGS_RDP_SYMBOL_10 _("Session Type")
|
||||
#define ID_DIALOG_SETTINGS_RDP_SYMBOL_11 _("Run desktop")
|
||||
#define ID_DIALOG_SETTINGS_RDP_SYMBOL_12 _("Run application")
|
||||
#define ID_DIALOG_SETTINGS_RDP_SYMBOL_13 _("&OK")
|
||||
#define ID_DIALOG_SETTINGS_RDP_SYMBOL_14 _("&Cancel")
|
||||
346
ResumeDialog.cpp
Normal file
346
ResumeDialog.cpp
Normal file
@@ -0,0 +1,346 @@
|
||||
// $Id: ResumeDialog.cpp 685 2012-02-15 17:09:07Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
||||
#pragma implementation "ResumeDialog.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
////@begin includes
|
||||
#include "wx/imaglist.h"
|
||||
////@end includes
|
||||
|
||||
#include "ResumeDialog.h"
|
||||
#include "Icon.h"
|
||||
|
||||
#include "opennxApp.h"
|
||||
|
||||
#include "trace.h"
|
||||
ENABLE_TRACE;
|
||||
|
||||
////@begin XPM images
|
||||
////@end XPM images
|
||||
|
||||
/*!
|
||||
* ResumeDialog type definition
|
||||
*/
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS( ResumeDialog, wxDialog )
|
||||
|
||||
/*!
|
||||
* ResumeDialog event table definition
|
||||
*/
|
||||
|
||||
BEGIN_EVENT_TABLE( ResumeDialog, wxDialog )
|
||||
|
||||
////@begin ResumeDialog event table entries
|
||||
EVT_LIST_ITEM_SELECTED( XRCID("ID_LISTCTRL_SESSIONS"), ResumeDialog::OnListctrlSessionsSelected )
|
||||
|
||||
EVT_BUTTON( wxID_REFRESH, ResumeDialog::OnRefreshClick )
|
||||
|
||||
EVT_BUTTON( XRCID("ID_BUTTON_TERMINATE"), ResumeDialog::OnButtonTerminateClick )
|
||||
|
||||
EVT_BUTTON( XRCID("ID_BUTTON_TAKEOVER"), ResumeDialog::OnButtonTakeoverClick )
|
||||
|
||||
EVT_BUTTON( XRCID("ID_BUTTON_RESUME"), ResumeDialog::OnButtonResumeClick )
|
||||
|
||||
////@end ResumeDialog event table entries
|
||||
|
||||
END_EVENT_TABLE()
|
||||
|
||||
/*!
|
||||
* ResumeDialog constructors
|
||||
*/
|
||||
|
||||
ResumeDialog::ResumeDialog( )
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
ResumeDialog::ResumeDialog( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
||||
{
|
||||
Init();
|
||||
Create(parent, id, caption, pos, size, style);
|
||||
}
|
||||
|
||||
/*!
|
||||
* ResumeDialog creator
|
||||
*/
|
||||
|
||||
bool ResumeDialog::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
||||
{
|
||||
////@begin ResumeDialog creation
|
||||
SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
|
||||
SetParent(parent);
|
||||
CreateControls();
|
||||
if (GetSizer())
|
||||
{
|
||||
GetSizer()->SetSizeHints(this);
|
||||
}
|
||||
Centre();
|
||||
////@end ResumeDialog creation
|
||||
wxUnusedVar(style);
|
||||
wxUnusedVar(size);
|
||||
wxUnusedVar(pos);
|
||||
wxUnusedVar(caption);
|
||||
wxUnusedVar(id);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Member initialisation
|
||||
*/
|
||||
|
||||
void ResumeDialog::Init()
|
||||
{
|
||||
////@begin ResumeDialog member initialisation
|
||||
m_lActiveSession = -1;
|
||||
m_eMode = New;
|
||||
m_bShadow = false;
|
||||
m_pCtrlSessions = NULL;
|
||||
m_pCtrlTerminate = NULL;
|
||||
m_pCtrlTakeover = NULL;
|
||||
m_pCtrlResume = NULL;
|
||||
m_pCtrlNew = NULL;
|
||||
////@end ResumeDialog member initialisation
|
||||
}
|
||||
/*!
|
||||
* Control creation for ResumeDialog
|
||||
*/
|
||||
|
||||
void ResumeDialog::CreateControls()
|
||||
{
|
||||
////@begin ResumeDialog content construction
|
||||
if (!wxXmlResource::Get()->LoadDialog(this, GetParent(), _T("ID_RESUMEDIALOG")))
|
||||
wxLogError(wxT("Missing wxXmlResource::Get()->Load() in OnInit()?"));
|
||||
m_pCtrlSessions = XRCCTRL(*this, "ID_LISTCTRL_SESSIONS", wxListCtrl);
|
||||
m_pCtrlTerminate = XRCCTRL(*this, "ID_BUTTON_TERMINATE", wxButton);
|
||||
m_pCtrlTakeover = XRCCTRL(*this, "ID_BUTTON_TAKEOVER", wxButton);
|
||||
m_pCtrlResume = XRCCTRL(*this, "ID_BUTTON_RESUME", wxButton);
|
||||
m_pCtrlNew = XRCCTRL(*this, "wxID_OK", wxButton);
|
||||
////@end ResumeDialog content construction
|
||||
|
||||
// Create custom windows not generated automatically here.
|
||||
////@begin ResumeDialog content initialisation
|
||||
////@end ResumeDialog content initialisation
|
||||
//
|
||||
m_pCtrlSessions->InsertColumn(0, _("Name"));
|
||||
m_pCtrlSessions->InsertColumn(1, _("User"));
|
||||
m_pCtrlSessions->InsertColumn(2, _("State"));
|
||||
m_pCtrlSessions->InsertColumn(3, _("Type"));
|
||||
m_pCtrlSessions->InsertColumn(4, _("Screen"));
|
||||
m_pCtrlSessions->InsertColumn(5, _("Port"));
|
||||
m_pCtrlSessions->InsertColumn(6, _("Options"));
|
||||
m_pCtrlSessions->InsertColumn(7, _("Session ID"));
|
||||
for (int i = 0; i < m_pCtrlSessions->GetColumnCount(); i++)
|
||||
m_pCtrlSessions->SetColumnWidth(i, wxLIST_AUTOSIZE);
|
||||
}
|
||||
|
||||
void
|
||||
ResumeDialog::AddSession(const wxString& name, const wxString& state, const wxString& type,
|
||||
const wxString& size, const wxString& colors,
|
||||
const wxString& port, const wxString& opts, const wxString& id, const wxString& user /* = wxT("") */)
|
||||
{
|
||||
long idx = m_pCtrlSessions->InsertItem(m_pCtrlSessions->GetItemCount(), name, 0);
|
||||
if (0 <= idx) {
|
||||
m_pCtrlSessions->SetItem(idx, 1, user);
|
||||
m_pCtrlSessions->SetItem(idx, 2, state);
|
||||
m_pCtrlSessions->SetItem(idx, 3, type);
|
||||
if (size.IsSameAs(wxT("N/A")) && colors.IsSameAs(wxT("N/A")))
|
||||
m_pCtrlSessions->SetItem(idx, 4, colors);
|
||||
else
|
||||
m_pCtrlSessions->SetItem(idx, 4, size + wxT("x") + colors);
|
||||
m_pCtrlSessions->SetItem(idx, 5, port);
|
||||
m_pCtrlSessions->SetItem(idx, 6, opts);
|
||||
m_pCtrlSessions->SetItem(idx, 7, id);
|
||||
//long lPort;
|
||||
//port.ToLong(&lPort);
|
||||
//m_pCtrlSessions->SetItemData(idx, lPort);
|
||||
for (int i = 0; i < m_pCtrlSessions->GetColumnCount(); i++)
|
||||
m_pCtrlSessions->SetColumnWidth(i, wxLIST_AUTOSIZE);
|
||||
if ((m_lActiveSession < 0) || (name == m_sPreferredSession)) {
|
||||
myLogTrace(MYTRACETAG, wxT("autoselect preferred=%d"), (int)idx);
|
||||
wxListItem info;
|
||||
info.m_itemId = idx;
|
||||
info.m_mask = wxLIST_MASK_STATE;
|
||||
info.m_state = wxLIST_STATE_FOCUSED|wxLIST_STATE_SELECTED;
|
||||
info.m_stateMask = wxLIST_STATE_FOCUSED|wxLIST_STATE_SELECTED;
|
||||
m_pCtrlSessions->SetItem(info);
|
||||
m_sSelectedPort = port;
|
||||
m_sSelectedName = name;
|
||||
m_sSelectedType = type;
|
||||
m_sSelectedId = id;
|
||||
}
|
||||
} else {
|
||||
wxLogError(_("Could not add session list item"));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ResumeDialog::EnableNew(bool b)
|
||||
{
|
||||
m_pCtrlNew->Enable(b);
|
||||
}
|
||||
|
||||
void
|
||||
ResumeDialog::SetAttachMode(bool b)
|
||||
{
|
||||
m_bShadow = b;
|
||||
m_pCtrlResume->SetLabel(b ? _("&Attach") : _("&Resume"));
|
||||
m_pCtrlTakeover->SetLabel(b ? _("&View") : _("&Takeover"));
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_LIST_ITEM_SELECTED event handler for ID_LISTCTRL_SESSIONS
|
||||
*/
|
||||
|
||||
void ResumeDialog::OnListctrlSessionsSelected( wxListEvent& event )
|
||||
{
|
||||
m_lActiveSession = event.GetIndex();
|
||||
myLogTrace(MYTRACETAG, wxT("clickselect=%d"), (int)m_lActiveSession);
|
||||
wxListItem info;
|
||||
info.SetId(m_lActiveSession);
|
||||
info.SetMask(wxLIST_MASK_TEXT);
|
||||
info.SetColumn(2);
|
||||
m_pCtrlSessions->GetItem(info);
|
||||
if (m_bShadow) {
|
||||
if (info.GetText() == wxT("Suspended")) {
|
||||
m_pCtrlResume->Enable(false);
|
||||
m_pCtrlTakeover->Enable(false);
|
||||
m_pCtrlTerminate->Enable(true);
|
||||
} else {
|
||||
m_pCtrlResume->Enable(true);
|
||||
m_pCtrlTakeover->Enable(true);
|
||||
m_pCtrlTerminate->Enable(false);
|
||||
}
|
||||
} else {
|
||||
if (info.GetText() == wxT("Suspended")) {
|
||||
m_pCtrlResume->Enable(true);
|
||||
m_pCtrlTakeover->Enable(false);
|
||||
m_pCtrlTerminate->Enable(true);
|
||||
} else {
|
||||
m_pCtrlResume->Enable(false);
|
||||
m_pCtrlTakeover->Enable(true);
|
||||
m_pCtrlTerminate->Enable(false);
|
||||
}
|
||||
}
|
||||
info.SetColumn(0);
|
||||
m_pCtrlSessions->GetItem(info);
|
||||
m_sSelectedName = info.GetText();
|
||||
info.SetColumn(3);
|
||||
m_pCtrlSessions->GetItem(info);
|
||||
m_sSelectedType = info.GetText();
|
||||
info.SetColumn(5);
|
||||
m_pCtrlSessions->GetItem(info);
|
||||
m_sSelectedPort = info.GetText();
|
||||
info.SetColumn(7);
|
||||
m_pCtrlSessions->GetItem(info);
|
||||
m_sSelectedId = info.GetText();
|
||||
myLogTrace(MYTRACETAG, wxT("Selected session ID=%s"), VMB(m_sSelectedId));
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_REFRESH
|
||||
*/
|
||||
|
||||
void ResumeDialog::OnRefreshClick( wxCommandEvent& event )
|
||||
{
|
||||
wxUnusedVar(event);
|
||||
m_eMode = Refresh;
|
||||
EndModal(wxID_OK);
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_TAKEOVER
|
||||
*/
|
||||
|
||||
void ResumeDialog::OnButtonTakeoverClick( wxCommandEvent& )
|
||||
{
|
||||
m_eMode = Takeover;
|
||||
EndModal(wxID_OK);
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_RESUME
|
||||
*/
|
||||
|
||||
void ResumeDialog::OnButtonResumeClick( wxCommandEvent& )
|
||||
{
|
||||
m_eMode = Resume;
|
||||
EndModal(wxID_OK);
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_TERMINATE
|
||||
*/
|
||||
|
||||
void ResumeDialog::OnButtonTerminateClick( wxCommandEvent& )
|
||||
{
|
||||
if (wxYES != ::wxMessageBox(_("Do you really want to terminate the selected session?"),
|
||||
_("Terminate session - OpenNX"), wxYES_NO|wxICON_QUESTION, this))
|
||||
return;
|
||||
m_eMode = Terminate;
|
||||
EndModal(wxID_OK);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Should we show tooltips?
|
||||
*/
|
||||
|
||||
bool ResumeDialog::ShowToolTips()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get bitmap resources
|
||||
*/
|
||||
|
||||
wxBitmap ResumeDialog::GetBitmapResource( const wxString& name )
|
||||
{
|
||||
// Bitmap retrieval
|
||||
return CreateBitmapFromFile(name);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get icon resources
|
||||
*/
|
||||
|
||||
wxIcon ResumeDialog::GetIconResource( const wxString& name )
|
||||
{
|
||||
// Icon retrieval
|
||||
return CreateIconFromFile(name);
|
||||
}
|
||||
176
ResumeDialog.h
Normal file
176
ResumeDialog.h
Normal file
@@ -0,0 +1,176 @@
|
||||
// $Id: ResumeDialog.h 674 2012-02-05 05:55:40Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _RESUMEDIALOG_H_
|
||||
#define _RESUMEDIALOG_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
||||
#pragma interface "ResumeDialog.h"
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* Includes
|
||||
*/
|
||||
|
||||
////@begin includes
|
||||
#include "ResumeDialog_symbols.h"
|
||||
#include "wx/xrc/xmlres.h"
|
||||
#include "wx/listctrl.h"
|
||||
#include "wx/statline.h"
|
||||
////@end includes
|
||||
|
||||
/*!
|
||||
* Forward declarations
|
||||
*/
|
||||
|
||||
////@begin forward declarations
|
||||
class wxListCtrl;
|
||||
////@end forward declarations
|
||||
|
||||
/*!
|
||||
* Control identifiers
|
||||
*/
|
||||
|
||||
////@begin control identifiers
|
||||
#define ID_RESUMEDIALOG 10050
|
||||
#define SYMBOL_RESUMEDIALOG_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX
|
||||
#define SYMBOL_RESUMEDIALOG_TITLE _("Select session - OpenNX")
|
||||
#define SYMBOL_RESUMEDIALOG_IDNAME ID_RESUMEDIALOG
|
||||
#define SYMBOL_RESUMEDIALOG_SIZE wxSize(400, 300)
|
||||
#define SYMBOL_RESUMEDIALOG_POSITION wxDefaultPosition
|
||||
////@end control identifiers
|
||||
|
||||
/*!
|
||||
* Compatibility
|
||||
*/
|
||||
|
||||
#ifndef wxCLOSE_BOX
|
||||
#define wxCLOSE_BOX 0x1000
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* ResumeDialog class declaration
|
||||
*/
|
||||
|
||||
class ResumeDialog: public wxDialog
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS( ResumeDialog )
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
public:
|
||||
typedef enum {
|
||||
Refresh,
|
||||
New,
|
||||
Resume,
|
||||
Takeover,
|
||||
Terminate,
|
||||
} Mode;
|
||||
|
||||
/// Constructors
|
||||
ResumeDialog( );
|
||||
ResumeDialog( wxWindow* parent, wxWindowID id = SYMBOL_RESUMEDIALOG_IDNAME, const wxString& caption = SYMBOL_RESUMEDIALOG_TITLE, const wxPoint& pos = SYMBOL_RESUMEDIALOG_POSITION, const wxSize& size = SYMBOL_RESUMEDIALOG_SIZE, long style = SYMBOL_RESUMEDIALOG_STYLE );
|
||||
|
||||
/// Creation
|
||||
bool Create( wxWindow* parent, wxWindowID id = SYMBOL_RESUMEDIALOG_IDNAME, const wxString& caption = SYMBOL_RESUMEDIALOG_TITLE, const wxPoint& pos = SYMBOL_RESUMEDIALOG_POSITION, const wxSize& size = SYMBOL_RESUMEDIALOG_SIZE, long style = SYMBOL_RESUMEDIALOG_STYLE );
|
||||
|
||||
/// Initialises member variables
|
||||
void Init();
|
||||
|
||||
/// Creates the controls and sizers
|
||||
void CreateControls();
|
||||
|
||||
void EnableNew(bool);
|
||||
void SetPreferredSession(const wxString &name) { m_sPreferredSession = name; };
|
||||
void AddSession(const wxString&, const wxString&, const wxString&, const wxString&,
|
||||
const wxString&, const wxString&, const wxString&, const wxString&, const wxString& user = wxT(""));
|
||||
void SetAttachMode(bool);
|
||||
|
||||
private:
|
||||
|
||||
////@begin ResumeDialog event handler declarations
|
||||
|
||||
/// wxEVT_COMMAND_LIST_ITEM_SELECTED event handler for ID_LISTCTRL_SESSIONS
|
||||
void OnListctrlSessionsSelected( wxListEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_REFRESH
|
||||
void OnRefreshClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_TERMINATE
|
||||
void OnButtonTerminateClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_TAKEOVER
|
||||
void OnButtonTakeoverClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_RESUME
|
||||
void OnButtonResumeClick( wxCommandEvent& event );
|
||||
|
||||
////@end ResumeDialog event handler declarations
|
||||
|
||||
public:
|
||||
////@begin ResumeDialog member function declarations
|
||||
|
||||
Mode GetMode() const { return m_eMode ; }
|
||||
void SetMode(Mode value) { m_eMode = value ; }
|
||||
|
||||
wxString GetSelectedId() const { return m_sSelectedId ; }
|
||||
void SetSelectedId(wxString value) { m_sSelectedId = value ; }
|
||||
|
||||
wxString GetSelectedName() const { return m_sSelectedName ; }
|
||||
void SetSelectedName(wxString value) { m_sSelectedName = value ; }
|
||||
|
||||
wxString GetSelectedType() const { return m_sSelectedType ; }
|
||||
void SetSelectedType(wxString value) { m_sSelectedType = value ; }
|
||||
|
||||
wxString GetSelectedPort() const { return m_sSelectedPort ; }
|
||||
void SetSelectedPort(wxString value) { m_sSelectedPort = value ; }
|
||||
|
||||
/// Retrieves bitmap resources
|
||||
wxBitmap GetBitmapResource( const wxString& name );
|
||||
|
||||
/// Retrieves icon resources
|
||||
wxIcon GetIconResource( const wxString& name );
|
||||
////@end ResumeDialog member function declarations
|
||||
|
||||
private:
|
||||
/// Should we show tooltips?
|
||||
static bool ShowToolTips();
|
||||
|
||||
////@begin ResumeDialog member variables
|
||||
wxListCtrl* m_pCtrlSessions;
|
||||
wxButton* m_pCtrlTerminate;
|
||||
wxButton* m_pCtrlTakeover;
|
||||
wxButton* m_pCtrlResume;
|
||||
wxButton* m_pCtrlNew;
|
||||
private:
|
||||
long m_lActiveSession;
|
||||
Mode m_eMode;
|
||||
wxString m_sSelectedId;
|
||||
wxString m_sSelectedName;
|
||||
wxString m_sSelectedType;
|
||||
wxString m_sSelectedPort;
|
||||
bool m_bShadow;
|
||||
////@end ResumeDialog member variables
|
||||
|
||||
wxString m_sPreferredSession;
|
||||
};
|
||||
|
||||
#endif
|
||||
// _RESUMEDIALOG_H_
|
||||
29
ResumeDialog_symbols.h
Normal file
29
ResumeDialog_symbols.h
Normal file
@@ -0,0 +1,29 @@
|
||||
// $Id: ResumeDialog_symbols.h 674 2012-02-05 05:55:40Z felfert $
|
||||
//
|
||||
// Copyright (C) 2011 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#define ID_RESUMEDIALOG_SYMBOL_0 _("Select session - OpenNX")
|
||||
#define ID_RESUMEDIALOG_SYMBOL_1 _("There are multiple sessions available, please select one or click New to create a session.")
|
||||
#define ID_RESUMEDIALOG_SYMBOL_2 _("Refresh")
|
||||
#define ID_RESUMEDIALOG_SYMBOL_3 _("Ter&minate")
|
||||
#define ID_RESUMEDIALOG_SYMBOL_4 _("&Takeover")
|
||||
#define ID_RESUMEDIALOG_SYMBOL_5 _("&Resume")
|
||||
#define ID_RESUMEDIALOG_SYMBOL_6 _("&New")
|
||||
#define ID_RESUMEDIALOG_SYMBOL_7 _("&Cancel")
|
||||
592
SessionAdmin.cpp
Normal file
592
SessionAdmin.cpp
Normal file
@@ -0,0 +1,592 @@
|
||||
// $Id: SessionAdmin.cpp 688 2012-02-18 02:36:07Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma implementation "SessionAdmin.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
////@begin includes
|
||||
////@end includes
|
||||
|
||||
#include <wx/filename.h>
|
||||
#include <wx/config.h>
|
||||
#include <wx/process.h>
|
||||
|
||||
#include "LogDialog.h"
|
||||
#include "opennxApp.h"
|
||||
#include "pwcrypt.h"
|
||||
#include "MySession.h"
|
||||
#include "SessionAdmin.h"
|
||||
#include "SessionList.h"
|
||||
#include "LoginDialog.h"
|
||||
#include "AboutDialog.h"
|
||||
#include "Icon.h"
|
||||
|
||||
#ifdef __UNIX__
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
#include "osdep.h"
|
||||
|
||||
#include "trace.h"
|
||||
ENABLE_TRACE;
|
||||
|
||||
////@begin XPM images
|
||||
////@end XPM images
|
||||
|
||||
/*!
|
||||
* SessionAdmin type definition
|
||||
*/
|
||||
|
||||
IMPLEMENT_CLASS( SessionAdmin, wxFrame )
|
||||
|
||||
/*!
|
||||
* SessionAdmin event table definition
|
||||
*/
|
||||
|
||||
BEGIN_EVENT_TABLE( SessionAdmin, wxFrame )
|
||||
|
||||
////@begin SessionAdmin event table entries
|
||||
EVT_MENU( XRCID("ID_MENU_SESSION_NEW"), SessionAdmin::OnMenuSessionNewClick )
|
||||
|
||||
EVT_MENU( wxID_PREFERENCES, SessionAdmin::OnPREFERENCESClick )
|
||||
|
||||
EVT_MENU( wxID_EXIT, SessionAdmin::OnEXITClick )
|
||||
|
||||
EVT_MENU( XRCID("ID_MENU_SESSION_TERMINATE"), SessionAdmin::OnMenuSessionTerminateClick )
|
||||
|
||||
EVT_MENU( XRCID("ID_MENU_SESSION_PSTATS"), SessionAdmin::OnMenuSessionPstatsClick )
|
||||
|
||||
EVT_MENU( XRCID("ID_MENU_SESSION_FSTATS"), SessionAdmin::OnMenuSessionFstatsClick )
|
||||
|
||||
EVT_MENU( XRCID("ID_MENU_SESSION_LOG"), SessionAdmin::OnMenuSessionLogClick )
|
||||
|
||||
EVT_MENU( XRCID("ID_MENU_SESSION_REMOVE"), SessionAdmin::OnMenuSessionRemoveClick )
|
||||
|
||||
EVT_MENU( XRCID("ID_MENU_SESSION_KILL"), SessionAdmin::OnMenuSessionKillClick )
|
||||
|
||||
EVT_MENU( XRCID("ID_MENU_REFRESH"), SessionAdmin::OnMenuRefreshClick )
|
||||
|
||||
EVT_MENU( wxID_ABOUT, SessionAdmin::OnABOUTClick )
|
||||
|
||||
EVT_MENU( XRCID("ID_TOOL_SESSION_NEW"), SessionAdmin::OnToolSessionNewClick )
|
||||
|
||||
EVT_MENU( XRCID("ID_TOOL_SESSION_TERMINATE"), SessionAdmin::OnToolSessionTerminateClick )
|
||||
|
||||
EVT_MENU( XRCID("ID_TOOL_SESSION_PSTATS"), SessionAdmin::OnToolSessionPstatsClick )
|
||||
|
||||
EVT_MENU( XRCID("ID_TOOL_SESSION_FSTATS"), SessionAdmin::OnToolSessionFstatsClick )
|
||||
|
||||
EVT_MENU( XRCID("ID_TOOL_SESSION_LOG"), SessionAdmin::OnToolSessionLogClick )
|
||||
|
||||
EVT_MENU( XRCID("ID_TOOL_REFRESH"), SessionAdmin::OnToolRefreshClick )
|
||||
|
||||
EVT_MENU( XRCID("ID_TOOL_SESSION_REMOVE"), SessionAdmin::OnToolSessionRemoveClick )
|
||||
|
||||
EVT_MENU( XRCID("ID_TOOL_SESSION_KILL"), SessionAdmin::OnToolSessionKillClick )
|
||||
|
||||
EVT_LIST_ITEM_SELECTED( XRCID("ID_LISTCTRL"), SessionAdmin::OnListctrlSelected )
|
||||
EVT_LIST_ITEM_DESELECTED( XRCID("ID_LISTCTRL"), SessionAdmin::OnListctrlDeselected )
|
||||
|
||||
////@end SessionAdmin event table entries
|
||||
|
||||
EVT_COMMAND(wxID_ANY, wxEVT_SESSIONLIST_ACTION, SessionAdmin::OnSessionList )
|
||||
|
||||
END_EVENT_TABLE()
|
||||
|
||||
/*!
|
||||
* SessionAdmin constructors
|
||||
*/
|
||||
|
||||
SessionAdmin::SessionAdmin()
|
||||
{
|
||||
}
|
||||
|
||||
SessionAdmin::SessionAdmin( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
||||
{
|
||||
Create( parent, id, caption, pos, size, style );
|
||||
}
|
||||
|
||||
SessionAdmin::~SessionAdmin()
|
||||
{
|
||||
delete m_sessions;
|
||||
}
|
||||
|
||||
/*!
|
||||
* SessionAdmin creator
|
||||
*/
|
||||
|
||||
bool SessionAdmin::Create( wxWindow* parent, wxWindowID WXUNUSED(id), const wxString& WXUNUSED(caption), const wxPoint& WXUNUSED(pos), const wxSize& WXUNUSED(size), long WXUNUSED(style) )
|
||||
{
|
||||
////@begin SessionAdmin member initialisation
|
||||
m_SessionListCtrl = NULL;
|
||||
////@end SessionAdmin member initialisation
|
||||
|
||||
wxConfigBase::Get()->Read(_T("Config/UserNxDir"), &m_NxDirectory);
|
||||
|
||||
////@begin SessionAdmin creation
|
||||
SetParent(parent);
|
||||
CreateControls();
|
||||
SetIcon(GetIconResource(wxT("res/opennx-admin.png")));
|
||||
if (GetSizer())
|
||||
{
|
||||
GetSizer()->SetSizeHints(this);
|
||||
}
|
||||
Centre();
|
||||
////@end SessionAdmin creation
|
||||
|
||||
m_sessions = new SessionList(m_NxDirectory, this);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Control creation for SessionAdmin
|
||||
*/
|
||||
|
||||
void SessionAdmin::CreateControls()
|
||||
{
|
||||
////@begin SessionAdmin content construction
|
||||
if (!wxXmlResource::Get()->LoadFrame(this, GetParent(), wxT("ID_FRAME_ADMIN")))
|
||||
wxLogError(wxT("Missing wxXmlResource::Get()->Load() in OnInit()?"));
|
||||
m_SessionListCtrl = XRCCTRL(*this, "ID_LISTCTRL", wxListCtrl);
|
||||
////@end SessionAdmin content construction
|
||||
|
||||
// Create custom windows not generated automatically here.
|
||||
|
||||
////@begin SessionAdmin content initialisation
|
||||
////@end SessionAdmin content initialisation
|
||||
|
||||
SessionToolsEnable(false);
|
||||
m_SessionListCtrl->InsertColumn(0, _("Server"));
|
||||
m_SessionListCtrl->InsertColumn(1, _("Port"));
|
||||
m_SessionListCtrl->InsertColumn(2, _("Session ID"));
|
||||
m_SessionListCtrl->InsertColumn(3, _("Creation Date"));
|
||||
m_SessionListCtrl->InsertColumn(4, _("PID"));
|
||||
m_SessionListCtrl->InsertColumn(5, _("Status"));
|
||||
m_SessionListCtrl->InsertColumn(6, _("Type"));
|
||||
for (int i = 0; i < m_SessionListCtrl->GetColumnCount(); i++)
|
||||
m_SessionListCtrl->SetColumnWidth(i, wxLIST_AUTOSIZE_USEHEADER);
|
||||
}
|
||||
|
||||
|
||||
void SessionAdmin::SessionToolsEnable(bool enable, bool running /* = false */)
|
||||
{
|
||||
GetToolBar()->EnableTool(XRCID("ID_TOOL_SESSION_TERMINATE"), enable && running);
|
||||
GetToolBar()->EnableTool(XRCID("ID_TOOL_SESSION_PSTATS"), enable && running);
|
||||
GetToolBar()->EnableTool(XRCID("ID_TOOL_SESSION_FSTATS"), enable && running);
|
||||
GetToolBar()->EnableTool(XRCID("ID_TOOL_SESSION_LOG"), enable);
|
||||
GetToolBar()->EnableTool(XRCID("ID_TOOL_SESSION_REMOVE"), enable && !running);
|
||||
GetToolBar()->EnableTool(XRCID("ID_TOOL_SESSION_KILL"), enable && running);
|
||||
GetMenuBar()->FindItem(XRCID("ID_MENU_SESSION_TERMINATE"))->Enable(enable && running);
|
||||
GetMenuBar()->FindItem(XRCID("ID_MENU_SESSION_PSTATS"))->Enable(enable && running);
|
||||
GetMenuBar()->FindItem(XRCID("ID_MENU_SESSION_FSTATS"))->Enable(enable && running);
|
||||
GetMenuBar()->FindItem(XRCID("ID_MENU_SESSION_LOG"))->Enable(enable);
|
||||
GetMenuBar()->FindItem(XRCID("ID_MENU_SESSION_REMOVE"))->Enable(enable && !running);
|
||||
GetMenuBar()->FindItem(XRCID("ID_MENU_SESSION_KILL"))->Enable(enable && running);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Should we show tooltips?
|
||||
*/
|
||||
|
||||
bool SessionAdmin::ShowToolTips()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get bitmap resources
|
||||
*/
|
||||
|
||||
wxBitmap SessionAdmin::GetBitmapResource( const wxString& name )
|
||||
{
|
||||
// Bitmap retrieval
|
||||
return CreateBitmapFromFile(name);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get icon resources
|
||||
*/
|
||||
|
||||
wxIcon SessionAdmin::GetIconResource( const wxString& name )
|
||||
{
|
||||
// Icon retrieval
|
||||
return CreateIconFromFile(name);
|
||||
}
|
||||
|
||||
void SessionAdmin::ShowSessionStats(long item, bool full)
|
||||
{
|
||||
MySession *s =
|
||||
wxDynamicCast((void *)m_SessionListCtrl->GetItemData(item), MySession);
|
||||
if (s) {
|
||||
wxFileName fn(s->sGetDir(), wxT("stats"));
|
||||
wxString md5stats1 = Md5OfFile(fn.GetFullPath());
|
||||
wxString md5stats2 = md5stats1;
|
||||
bool ok = false;
|
||||
#ifdef __UNIX__
|
||||
ok = (kill((pid_t)s->lGetPID(), full ? SIGUSR1 : SIGUSR2) == 0);
|
||||
#else
|
||||
#endif
|
||||
if (ok) {
|
||||
// Wait until file starts changing
|
||||
myLogTrace(MYTRACETAG, wxT("wait for change of stats"));
|
||||
while (ok) {
|
||||
md5stats2 = Md5OfFile(fn.GetFullPath());
|
||||
if (md5stats1 != md5stats2)
|
||||
break;
|
||||
::wxGetApp().Yield(true);
|
||||
wxThread::Sleep(100);
|
||||
}
|
||||
// Wait until file stopped changing
|
||||
wxThread::Sleep(100);
|
||||
myLogTrace(MYTRACETAG, wxT("wait for settling stats"));
|
||||
while (ok) {
|
||||
md5stats1 = Md5OfFile(fn.GetFullPath());
|
||||
if (md5stats1 == md5stats2)
|
||||
break;
|
||||
md5stats2 = md5stats1;
|
||||
::wxGetApp().Yield(true);
|
||||
wxThread::Sleep(100);
|
||||
}
|
||||
if (ok) {
|
||||
LogDialog d(NULL);
|
||||
d.SetTitle(full ?
|
||||
_("Full session statistics - OpenNX") :
|
||||
_("Partial session statistics - OpenNX"));
|
||||
d.ReadLogFile(s->sGetDir() + wxFileName::GetPathSeparator() + wxT("stats"));
|
||||
d.ShowModal();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* Handle events from SessionList
|
||||
*/
|
||||
void SessionAdmin::OnSessionList(wxCommandEvent& event)
|
||||
{
|
||||
long idx;
|
||||
MySession *s;
|
||||
switch (event.GetInt()) {
|
||||
case SessionList::SessionAdded:
|
||||
s = wxDynamicCast((void *)event.GetClientData(), MySession);
|
||||
// Hostname
|
||||
idx = m_SessionListCtrl->InsertItem(0, s->sGetHost(), 0);
|
||||
m_SessionListCtrl->SetItemData(idx, (long)s);
|
||||
// Port
|
||||
m_SessionListCtrl->SetItem(idx, 1, s->sGetPort());
|
||||
// Session ID
|
||||
m_SessionListCtrl->SetItem(idx, 2, s->sGetMd5());
|
||||
// Creation Time
|
||||
m_SessionListCtrl->SetItem(idx, 3, s->sGetCreationTime());
|
||||
// PID
|
||||
m_SessionListCtrl->SetItem(idx, 4, s->sGetPID());
|
||||
// Status
|
||||
m_SessionListCtrl->SetItem(idx, 5, s->sGetSessionStatus());
|
||||
// Type
|
||||
m_SessionListCtrl->SetItem(idx, 6, s->sGetSessionType());
|
||||
break;
|
||||
case SessionList::SessionChanged:
|
||||
s = wxDynamicCast((void *)event.GetClientData(), MySession);
|
||||
idx = m_SessionListCtrl->FindItem(-1, (long)s);
|
||||
myLogTrace(MYTRACETAG, wxT("state changed: %d"), (int)idx);
|
||||
if (idx != -1) {
|
||||
m_SessionListCtrl->SetItem(idx, 3, s->sGetCreationTime());
|
||||
m_SessionListCtrl->SetItem(idx, 4, s->sGetPID());
|
||||
m_SessionListCtrl->SetItem(idx, 5, s->sGetSessionStatus());
|
||||
if (m_SessionListCtrl->GetItemState(idx, wxLIST_STATE_SELECTED)) {
|
||||
bool running = (s->eGetSessionStatus() == MySession::Running);
|
||||
SessionToolsEnable(true, running);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SessionList::SessionRemoved:
|
||||
idx = m_SessionListCtrl->FindItem(-1, (long)event.GetClientData());
|
||||
if (idx != -1) {
|
||||
m_SessionListCtrl->DeleteItem(idx);
|
||||
}
|
||||
break;
|
||||
case SessionList::UpdateList:
|
||||
#ifndef __WXMAC__ // On OSX, this messes up column headers
|
||||
{
|
||||
int width = m_SessionListCtrl->GetItemCount() ?
|
||||
wxLIST_AUTOSIZE : wxLIST_AUTOSIZE_USEHEADER;
|
||||
for (int i = 0; i < m_SessionListCtrl->GetColumnCount(); i++)
|
||||
m_SessionListCtrl->SetColumnWidth(i, width);
|
||||
}
|
||||
#endif
|
||||
m_SessionListCtrl->Update();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_TOOL_SESSION_NEW
|
||||
*/
|
||||
|
||||
void SessionAdmin::OnToolSessionNewClick( wxCommandEvent& event )
|
||||
{
|
||||
OnMenuSessionNewClick(event);
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_FILE_CHDIR
|
||||
*/
|
||||
|
||||
void SessionAdmin::OnPREFERENCESClick( wxCommandEvent& )
|
||||
{
|
||||
const wxString& dir = wxDirSelector(_("Choose new NX session directory."),
|
||||
m_NxDirectory, wxDD_DEFAULT_STYLE, wxDefaultPosition, this);
|
||||
if (!dir.IsEmpty()) {
|
||||
m_NxDirectory = dir;
|
||||
m_sessions->SetDir(dir);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_FILE_EXIT
|
||||
*/
|
||||
|
||||
void SessionAdmin::OnEXITClick( wxCommandEvent& )
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_SESSION_TERMINATE
|
||||
*/
|
||||
|
||||
void SessionAdmin::OnToolSessionTerminateClick( wxCommandEvent& event )
|
||||
{
|
||||
OnMenuSessionTerminateClick(event);
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_SESSION_PSTATS
|
||||
*/
|
||||
|
||||
void SessionAdmin::OnToolSessionPstatsClick( wxCommandEvent& event )
|
||||
{
|
||||
OnMenuSessionPstatsClick(event);
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_SESSION_FSTATS
|
||||
*/
|
||||
|
||||
void SessionAdmin::OnToolSessionFstatsClick( wxCommandEvent& event )
|
||||
{
|
||||
OnMenuSessionFstatsClick(event);
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_SESSION_LOG
|
||||
*/
|
||||
|
||||
void SessionAdmin::OnToolSessionLogClick( wxCommandEvent& event )
|
||||
{
|
||||
OnMenuSessionLogClick(event);
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_SESSION_REMOVE
|
||||
*/
|
||||
|
||||
void SessionAdmin::OnToolSessionRemoveClick( wxCommandEvent& event )
|
||||
{
|
||||
OnMenuSessionRemoveClick(event);
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_SESSION_KILL
|
||||
*/
|
||||
|
||||
void SessionAdmin::OnToolSessionKillClick( wxCommandEvent& event )
|
||||
{
|
||||
OnMenuSessionKillClick(event);
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_OPTIONS_REFRESH
|
||||
*/
|
||||
|
||||
void SessionAdmin::OnToolRefreshClick( wxCommandEvent& event )
|
||||
{
|
||||
OnMenuRefreshClick(event);
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_HELP_ABOUT
|
||||
*/
|
||||
|
||||
void SessionAdmin::OnABOUTClick( wxCommandEvent& )
|
||||
{
|
||||
AboutDialog d(this);
|
||||
d.ShowModal();
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_LIST_ITEM_SELECTED event handler for ID_LISTCTRL
|
||||
*/
|
||||
|
||||
void SessionAdmin::OnListctrlSelected( wxListEvent& event )
|
||||
{
|
||||
MySession *s =
|
||||
wxDynamicCast((void *)m_SessionListCtrl->GetItemData(event.GetIndex()), MySession);
|
||||
bool running = ((NULL != s) && (s->eGetSessionStatus() == MySession::Running));
|
||||
SessionToolsEnable(true, running);
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_LIST_ITEM_DESELECTED event handler for ID_LISTCTRL
|
||||
*/
|
||||
|
||||
void SessionAdmin::OnListctrlDeselected( wxListEvent& )
|
||||
{
|
||||
SessionToolsEnable(false);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_SESSION_NEW
|
||||
*/
|
||||
|
||||
void SessionAdmin::OnMenuSessionNewClick( wxCommandEvent& )
|
||||
{
|
||||
LoginDialog d(this);
|
||||
d.ShowModal();
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_SESSION_TERMINATE
|
||||
*/
|
||||
|
||||
void SessionAdmin::OnMenuSessionTerminateClick( wxCommandEvent& )
|
||||
{
|
||||
#ifndef __WXMSW__
|
||||
long item = m_SessionListCtrl->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
||||
if (item != -1) {
|
||||
MySession *s =
|
||||
wxDynamicCast((void *)m_SessionListCtrl->GetItemData(item), MySession);
|
||||
if (s)
|
||||
close_sid(s->sGetMd5().mb_str());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_SESSION_PSTATS
|
||||
*/
|
||||
|
||||
void SessionAdmin::OnMenuSessionPstatsClick( wxCommandEvent& )
|
||||
{
|
||||
long item = m_SessionListCtrl->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
||||
if (item != -1)
|
||||
ShowSessionStats(item, false);
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_SESSION_FSTATS
|
||||
*/
|
||||
|
||||
void SessionAdmin::OnMenuSessionFstatsClick( wxCommandEvent& )
|
||||
{
|
||||
long item = m_SessionListCtrl->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
||||
if (item != -1)
|
||||
ShowSessionStats(item, true);
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_SESSION_LOG
|
||||
*/
|
||||
|
||||
void SessionAdmin::OnMenuSessionLogClick( wxCommandEvent& )
|
||||
{
|
||||
long item = m_SessionListCtrl->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
||||
if (item != -1) {
|
||||
MySession *s =
|
||||
wxDynamicCast((void *)m_SessionListCtrl->GetItemData(item), MySession);
|
||||
if (s) {
|
||||
LogDialog d(NULL);
|
||||
d.ReadLogFile(s->sGetDir() + wxFileName::GetPathSeparator() + wxT("session"));
|
||||
d.ShowModal();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_SESSION_REMOVE
|
||||
*/
|
||||
|
||||
void SessionAdmin::OnMenuSessionRemoveClick( wxCommandEvent& )
|
||||
{
|
||||
long item = m_SessionListCtrl->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
||||
if (item != -1) {
|
||||
MySession *s =
|
||||
wxDynamicCast((void *)m_SessionListCtrl->GetItemData(item), MySession);
|
||||
if (s) {
|
||||
m_SessionListCtrl->DeleteItem(item);
|
||||
wxString dir = s->sGetDir();
|
||||
m_sessions->CleanupDir(dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_SESSION_KILL
|
||||
*/
|
||||
|
||||
void SessionAdmin::OnMenuSessionKillClick( wxCommandEvent& )
|
||||
{
|
||||
long item = m_SessionListCtrl->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
||||
if (item != -1) {
|
||||
MySession *s =
|
||||
wxDynamicCast((void *)m_SessionListCtrl->GetItemData(item), MySession);
|
||||
wxProcess::Kill(s->lGetPID());
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_REFRESH
|
||||
*/
|
||||
|
||||
void SessionAdmin::OnMenuRefreshClick( wxCommandEvent& )
|
||||
{
|
||||
m_sessions->ScanDir();
|
||||
}
|
||||
|
||||
|
||||
191
SessionAdmin.h
Normal file
191
SessionAdmin.h
Normal file
@@ -0,0 +1,191 @@
|
||||
// $Id: SessionAdmin.h 399 2009-09-09 19:35:12Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _SESSIONADMIN_H_
|
||||
#define _SESSIONADMIN_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "SessionAdmin.cpp"
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* Includes
|
||||
*/
|
||||
|
||||
////@begin includes
|
||||
#include "SessionAdmin_symbols.h"
|
||||
#include "wx/xrc/xmlres.h"
|
||||
#include "wx/frame.h"
|
||||
#include "wx/toolbar.h"
|
||||
#include "wx/listctrl.h"
|
||||
////@end includes
|
||||
|
||||
/*!
|
||||
* Forward declarations
|
||||
*/
|
||||
|
||||
class SessionList;
|
||||
////@begin forward declarations
|
||||
class wxListCtrl;
|
||||
////@end forward declarations
|
||||
|
||||
/*!
|
||||
* Control identifiers
|
||||
*/
|
||||
|
||||
////@begin control identifiers
|
||||
#define ID_FRAME_ADMIN 10103
|
||||
#define SYMBOL_SESSIONADMIN_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxMINIMIZE_BOX|wxMAXIMIZE_BOX|wxCLOSE_BOX
|
||||
#define SYMBOL_SESSIONADMIN_TITLE _("Session Administrator - OpenNX")
|
||||
#define SYMBOL_SESSIONADMIN_IDNAME ID_FRAME_ADMIN
|
||||
#define SYMBOL_SESSIONADMIN_SIZE wxDefaultSize
|
||||
#define SYMBOL_SESSIONADMIN_POSITION wxDefaultPosition
|
||||
////@end control identifiers
|
||||
|
||||
/*!
|
||||
* Compatibility
|
||||
*/
|
||||
|
||||
#ifndef wxCLOSE_BOX
|
||||
#define wxCLOSE_BOX 0x1000
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* SessionAdmin class declaration
|
||||
*/
|
||||
|
||||
class SessionAdmin: public wxFrame
|
||||
{
|
||||
DECLARE_CLASS( SessionAdmin )
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
public:
|
||||
|
||||
void SessionToolsEnable(bool enable, bool running = false);
|
||||
/// Constructors
|
||||
SessionAdmin( );
|
||||
SessionAdmin( wxWindow* parent, wxWindowID id = SYMBOL_SESSIONADMIN_IDNAME, const wxString& caption = SYMBOL_SESSIONADMIN_TITLE, const wxPoint& pos = SYMBOL_SESSIONADMIN_POSITION, const wxSize& size = SYMBOL_SESSIONADMIN_SIZE, long style = SYMBOL_SESSIONADMIN_STYLE );
|
||||
virtual ~SessionAdmin();
|
||||
|
||||
bool Create( wxWindow* parent, wxWindowID id = SYMBOL_SESSIONADMIN_IDNAME, const wxString& caption = SYMBOL_SESSIONADMIN_TITLE, const wxPoint& pos = SYMBOL_SESSIONADMIN_POSITION, const wxSize& size = SYMBOL_SESSIONADMIN_SIZE, long style = SYMBOL_SESSIONADMIN_STYLE );
|
||||
|
||||
/// Creates the controls and sizers
|
||||
void CreateControls();
|
||||
|
||||
// Event handler for events from SessionList
|
||||
void OnSessionList(wxCommandEvent& event);
|
||||
|
||||
////@begin SessionAdmin event handler declarations
|
||||
|
||||
/// wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_SESSION_NEW
|
||||
void OnMenuSessionNewClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_MENU_SELECTED event handler for wxID_PREFERENCES
|
||||
void OnPREFERENCESClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_MENU_SELECTED event handler for wxID_EXIT
|
||||
void OnEXITClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_SESSION_TERMINATE
|
||||
void OnMenuSessionTerminateClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_SESSION_PSTATS
|
||||
void OnMenuSessionPstatsClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_SESSION_FSTATS
|
||||
void OnMenuSessionFstatsClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_SESSION_LOG
|
||||
void OnMenuSessionLogClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_SESSION_REMOVE
|
||||
void OnMenuSessionRemoveClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_SESSION_KILL
|
||||
void OnMenuSessionKillClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_REFRESH
|
||||
void OnMenuRefreshClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT
|
||||
void OnABOUTClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_MENU_SELECTED event handler for ID_TOOL_SESSION_NEW
|
||||
void OnToolSessionNewClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_MENU_SELECTED event handler for ID_TOOL_SESSION_TERMINATE
|
||||
void OnToolSessionTerminateClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_MENU_SELECTED event handler for ID_TOOL_SESSION_PSTATS
|
||||
void OnToolSessionPstatsClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_MENU_SELECTED event handler for ID_TOOL_SESSION_FSTATS
|
||||
void OnToolSessionFstatsClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_MENU_SELECTED event handler for ID_TOOL_SESSION_LOG
|
||||
void OnToolSessionLogClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_MENU_SELECTED event handler for ID_TOOL_REFRESH
|
||||
void OnToolRefreshClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_MENU_SELECTED event handler for ID_TOOL_SESSION_REMOVE
|
||||
void OnToolSessionRemoveClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_MENU_SELECTED event handler for ID_TOOL_SESSION_KILL
|
||||
void OnToolSessionKillClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_LIST_ITEM_SELECTED event handler for ID_LISTCTRL
|
||||
void OnListctrlSelected( wxListEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_LIST_ITEM_DESELECTED event handler for ID_LISTCTRL
|
||||
void OnListctrlDeselected( wxListEvent& event );
|
||||
|
||||
////@end SessionAdmin event handler declarations
|
||||
|
||||
////@begin SessionAdmin member function declarations
|
||||
|
||||
wxString GetNxDirectory() const { return m_NxDirectory ; }
|
||||
void SetNxDirectory(wxString value) { m_NxDirectory = value ; }
|
||||
|
||||
/// Retrieves bitmap resources
|
||||
wxBitmap GetBitmapResource( const wxString& name );
|
||||
|
||||
/// Retrieves icon resources
|
||||
wxIcon GetIconResource( const wxString& name );
|
||||
////@end SessionAdmin member function declarations
|
||||
|
||||
/// Should we show tooltips?
|
||||
static bool ShowToolTips();
|
||||
|
||||
private:
|
||||
void ShowSessionStats(long, bool);
|
||||
|
||||
|
||||
////@begin SessionAdmin member variables
|
||||
wxListCtrl* m_SessionListCtrl;
|
||||
wxString m_NxDirectory;
|
||||
////@end SessionAdmin member variables
|
||||
|
||||
SessionList *m_sessions;
|
||||
};
|
||||
|
||||
#endif
|
||||
// _SESSIONADMIN_H_
|
||||
38
SessionAdmin_symbols.h
Normal file
38
SessionAdmin_symbols.h
Normal file
@@ -0,0 +1,38 @@
|
||||
// $Id: SessionAdmin_symbols.h 151 2009-02-10 22:30:59Z felfert $
|
||||
//
|
||||
// Copyright (C) 2008 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#define ID_FRAME_ADMIN_SYMBOL_0 _("Session Administrator - OpenNX")
|
||||
#define ID_FRAME_ADMIN_SYMBOL_1 _("&File")
|
||||
#define ID_FRAME_ADMIN_SYMBOL_2 _("New NX Session...")
|
||||
#define ID_FRAME_ADMIN_SYMBOL_3 _("Change NX directory...")
|
||||
#define ID_FRAME_ADMIN_SYMBOL_4 _("Exit")
|
||||
#define ID_FRAME_ADMIN_SYMBOL_5 _("&Session")
|
||||
#define ID_FRAME_ADMIN_SYMBOL_6 _("Terminate session")
|
||||
#define ID_FRAME_ADMIN_SYMBOL_7 _("View partial statistics")
|
||||
#define ID_FRAME_ADMIN_SYMBOL_8 _("View full statistics")
|
||||
#define ID_FRAME_ADMIN_SYMBOL_9 _("View session log")
|
||||
#define ID_FRAME_ADMIN_SYMBOL_10 _("Remove session")
|
||||
#define ID_FRAME_ADMIN_SYMBOL_11 _("Kill application")
|
||||
#define ID_FRAME_ADMIN_SYMBOL_12 _("Options")
|
||||
#define ID_FRAME_ADMIN_SYMBOL_13 _("Refresh session list")
|
||||
#define ID_FRAME_ADMIN_SYMBOL_14 _("Help")
|
||||
#define ID_FRAME_ADMIN_SYMBOL_15 _("About OpenNX client...")
|
||||
#define ID_FRAME_ADMIN_SYMBOL_16 _("New NX session")
|
||||
311
SessionList.cpp
Normal file
311
SessionList.cpp
Normal file
@@ -0,0 +1,311 @@
|
||||
// $Id: SessionList.cpp 687 2012-02-18 00:00:24Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma implementation "SessionList.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#include "SessionList.h"
|
||||
#include "MySession.h"
|
||||
|
||||
#include <wx/dir.h>
|
||||
#include <wx/filename.h>
|
||||
|
||||
#include "trace.h"
|
||||
ENABLE_TRACE;
|
||||
|
||||
DEFINE_LOCAL_EVENT_TYPE(wxEVT_SESSIONLIST_ACTION);
|
||||
|
||||
class SessionTraverser : public wxDirTraverser
|
||||
{
|
||||
public:
|
||||
SessionTraverser(wxArrayString& dirs) : m_dirs(dirs) { }
|
||||
|
||||
virtual wxDirTraverseResult OnFile(const wxString& WXUNUSED(filename))
|
||||
{
|
||||
return wxDIR_CONTINUE;
|
||||
}
|
||||
|
||||
virtual wxDirTraverseResult OnDir(const wxString& dirpath)
|
||||
{
|
||||
wxString name = wxFileName::FileName(dirpath).GetFullName();
|
||||
m_dirs.Add(name);
|
||||
return wxDIR_IGNORE;
|
||||
}
|
||||
|
||||
private:
|
||||
wxArrayString& m_dirs;
|
||||
};
|
||||
|
||||
class RmRfTraverser : public wxDirTraverser
|
||||
{
|
||||
public:
|
||||
RmRfTraverser() { }
|
||||
|
||||
~RmRfTraverser()
|
||||
{
|
||||
int n = m_aFiles.GetCount() - 1;
|
||||
while (n >= 0) {
|
||||
myLogTrace(MYTRACETAG, wxT("Removing file %s"), VMB(m_aFiles[n]));
|
||||
::wxRemoveFile(m_aFiles[n--]);
|
||||
}
|
||||
n = m_aDirs.GetCount() - 1;
|
||||
while (n >= 0) {
|
||||
myLogTrace(MYTRACETAG, wxT("Removing dir %s"), VMB(m_aDirs[n]));
|
||||
::wxRmdir(m_aDirs[n--]);
|
||||
}
|
||||
}
|
||||
|
||||
virtual wxDirTraverseResult OnFile(const wxString& filename)
|
||||
{
|
||||
myLogTrace(MYTRACETAG, wxT("going to delete file %s"), VMB(filename));
|
||||
m_aFiles.Add(filename);
|
||||
return wxDIR_CONTINUE;
|
||||
}
|
||||
|
||||
virtual wxDirTraverseResult OnDir(const wxString& dirpath)
|
||||
{
|
||||
myLogTrace(MYTRACETAG, wxT("going to delete dir %s"), VMB(dirpath));
|
||||
m_aDirs.Add(dirpath);
|
||||
return wxDIR_CONTINUE;
|
||||
}
|
||||
|
||||
private:
|
||||
wxArrayString m_aDirs;
|
||||
wxArrayString m_aFiles;
|
||||
};
|
||||
|
||||
WX_DECLARE_STRING_HASH_MAP(MySession, SessionHash);
|
||||
|
||||
SessionList::SessionList(wxString dir, wxEvtHandler* h)
|
||||
: wxThreadHelper()
|
||||
, m_dirName(dir)
|
||||
, m_pAdminHandler(h)
|
||||
, m_dir(NULL)
|
||||
, m_reValid(false)
|
||||
{
|
||||
m_sessions = new SessionHash();
|
||||
m_re = new wxRegEx();
|
||||
if (m_re->Compile(wxT("(([TF])-)?([SC])-(.*)-([[:digit:]]+)-([[:xdigit:]]{32})$"), wxRE_ADVANCED))
|
||||
m_reValid = true;
|
||||
if (m_reValid && (!m_dirName.IsEmpty())) {
|
||||
CreateThread();
|
||||
m_thread->Run();
|
||||
}
|
||||
}
|
||||
|
||||
SessionList::~SessionList()
|
||||
{
|
||||
m_thread->Delete();
|
||||
while (m_thread->IsRunning())
|
||||
wxThread::Sleep(100);
|
||||
if (m_dir != NULL)
|
||||
delete m_dir;
|
||||
delete m_re;
|
||||
m_sessions->clear();
|
||||
delete m_sessions;
|
||||
}
|
||||
|
||||
void SessionList::SetDir(wxString dir)
|
||||
{
|
||||
m_dirName = dir;
|
||||
if (m_reValid && (!m_dirName.IsEmpty())) {
|
||||
if (m_thread == NULL) {
|
||||
CreateThread();
|
||||
m_thread->Run();
|
||||
} else {
|
||||
m_csDir.Enter();
|
||||
if (m_dir)
|
||||
delete m_dir;
|
||||
m_dir = NULL;
|
||||
m_csDir.Leave();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SessionList::ScanDir()
|
||||
{
|
||||
wxCriticalSectionLocker dlocker(m_csDir);
|
||||
|
||||
if (m_dir == NULL) {
|
||||
if (m_dirName.IsEmpty())
|
||||
return;
|
||||
if (!wxDir::Exists(m_dirName)) {
|
||||
m_dirName = wxEmptyString;
|
||||
return;
|
||||
}
|
||||
m_dir = new wxDir(m_dirName);
|
||||
}
|
||||
|
||||
// get the names of all session directories
|
||||
wxArrayString sdirs;
|
||||
SessionTraverser traverser(sdirs);
|
||||
m_dir->Traverse(traverser);
|
||||
size_t cnt = sdirs.GetCount();
|
||||
size_t i;
|
||||
|
||||
// Format of session dir name:
|
||||
//
|
||||
// ([TF]-)?[SC]-(.*)-[:digit:]+-[:xdigit:]{32}
|
||||
//
|
||||
// 1. element is session status
|
||||
// "T-" resp. "F-" stands for terminated or failed respectively.
|
||||
// If it is missing, the session is undefined (probably running).
|
||||
//
|
||||
// 2. element is session type
|
||||
// S- resp. C- stands for server resp. client session type
|
||||
//
|
||||
// 3. element is host name of the NX server
|
||||
// 4. element is port name
|
||||
// 5. element is an md5sum. (//FE: For what data?)
|
||||
//
|
||||
|
||||
bool changed = false;
|
||||
SessionHash::iterator it;
|
||||
size_t oldcount = m_sessions->size();
|
||||
for (it = m_sessions->begin(); it != m_sessions->end(); ++it)
|
||||
it->second.bSetTouched(false);
|
||||
|
||||
for (i = 0; i < cnt; i++) {
|
||||
wxString tmp = sdirs[i];
|
||||
if (m_re->Matches(tmp)) {
|
||||
wxString md5 = m_re->GetMatch(tmp, 6);
|
||||
|
||||
it = m_sessions->find(md5);
|
||||
if (it == m_sessions->end()) {
|
||||
// New session found
|
||||
long port;
|
||||
|
||||
m_re->GetMatch(tmp,5).ToLong(&port);
|
||||
myLogTrace(MYTRACETAG,
|
||||
wxT("State='%s', Type='%s', Host='%s', Port=%d, MD5='%s'"),
|
||||
VMB(m_re->GetMatch(tmp,2)),
|
||||
VMB(m_re->GetMatch(tmp,3)),
|
||||
VMB(m_re->GetMatch(tmp,4)),
|
||||
(int)port, VMB(md5));
|
||||
// Create new hash entry
|
||||
MySession s(m_dirName + wxFileName::GetPathSeparator() + tmp,
|
||||
m_re->GetMatch(tmp,2), m_re->GetMatch(tmp,3),
|
||||
m_re->GetMatch(tmp,4), port, md5);
|
||||
(*m_sessions)[md5] = s;
|
||||
if (m_pAdminHandler) {
|
||||
wxCommandEvent ev(wxEVT_SESSIONLIST_ACTION, wxID_ANY);
|
||||
ev.SetInt(SessionAdded);
|
||||
ev.SetClientData(&(m_sessions->find(md5)->second));
|
||||
m_pAdminHandler->AddPendingEvent(ev);
|
||||
changed = true;
|
||||
}
|
||||
} else {
|
||||
// Existing session found, mark it
|
||||
it->second.bSetTouched(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
bool finished = false;
|
||||
|
||||
while (!finished) {
|
||||
finished = true;
|
||||
for (it = m_sessions->begin(); it != m_sessions->end(); ++it) {
|
||||
if (it->second.bGetTouched()) {
|
||||
MySession::tSessionStatus st = it->second.eGetSessionStatus();
|
||||
it->second.CheckState();
|
||||
if (it->second.eGetSessionStatus() != st) {
|
||||
if (m_pAdminHandler) {
|
||||
wxCommandEvent ev(wxEVT_SESSIONLIST_ACTION, wxID_ANY);
|
||||
ev.SetInt(SessionChanged);
|
||||
ev.SetClientData(&it->second);
|
||||
m_pAdminHandler->AddPendingEvent(ev);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
wxString md5 = it->second.sGetMd5();
|
||||
myLogTrace(MYTRACETAG, wxT("Session '%s' disappeared"), VMB(md5));
|
||||
finished = false;
|
||||
if (m_pAdminHandler) {
|
||||
wxCommandEvent ev(wxEVT_SESSIONLIST_ACTION, wxID_ANY);
|
||||
ev.SetInt(SessionRemoved);
|
||||
ev.SetClientData(&it->second);
|
||||
m_pAdminHandler->AddPendingEvent(ev);
|
||||
changed = true;
|
||||
}
|
||||
RemoveFromList(md5);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (changed && (m_pAdminHandler != NULL)) {
|
||||
wxCommandEvent ev(wxEVT_SESSIONLIST_ACTION, wxID_ANY);
|
||||
ev.SetInt(UpdateList);
|
||||
m_pAdminHandler->AddPendingEvent(ev);
|
||||
}
|
||||
if (m_sessions->size() != oldcount)
|
||||
myLogTrace(MYTRACETAG, wxT("SessionList: Now %d sessions"), (int)m_sessions->size());
|
||||
}
|
||||
|
||||
void
|
||||
SessionList::RemoveFromList(wxString md5)
|
||||
{
|
||||
m_sessions->erase(md5);
|
||||
}
|
||||
|
||||
void
|
||||
SessionList::CleanupDir(wxString &dir)
|
||||
{
|
||||
if (!dir.IsEmpty()) {
|
||||
{
|
||||
myLogTrace(MYTRACETAG, wxT("CleanupDir '%s'"), VMB(dir));
|
||||
wxDir d(dir);
|
||||
RmRfTraverser t;
|
||||
d.Traverse(t);
|
||||
}
|
||||
::wxRmdir(dir);
|
||||
}
|
||||
}
|
||||
|
||||
wxThread::ExitCode
|
||||
SessionList::Entry()
|
||||
{
|
||||
int cnt = 0;
|
||||
while (!m_thread->TestDestroy()) {
|
||||
if (cnt-- == 0) {
|
||||
ScanDir();
|
||||
cnt = 20;
|
||||
}
|
||||
wxThread::Sleep(100);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
69
SessionList.h
Normal file
69
SessionList.h
Normal file
@@ -0,0 +1,69 @@
|
||||
// $Id: SessionList.h 399 2009-09-09 19:35:12Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _SESSIONLIST_H_
|
||||
#define _SESSIONLIST_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "SessionList.cpp"
|
||||
#endif
|
||||
|
||||
#include <wx/thread.h>
|
||||
|
||||
class wxDir;
|
||||
class wxRegEx;
|
||||
class SessionHash;
|
||||
|
||||
DECLARE_LOCAL_EVENT_TYPE(wxEVT_SESSIONLIST_ACTION, -1)
|
||||
|
||||
class SessionList : public wxThreadHelper
|
||||
{
|
||||
public:
|
||||
enum {
|
||||
SessionAdded,
|
||||
SessionChanged,
|
||||
SessionRemoved,
|
||||
UpdateList
|
||||
};
|
||||
|
||||
SessionList(wxString dir = _T(""), wxEvtHandler *h = NULL);
|
||||
virtual ~SessionList();
|
||||
|
||||
virtual wxThread::ExitCode Entry();
|
||||
|
||||
void SetDir(wxString dir);
|
||||
void SetAdminHandler(wxEvtHandler *h) { m_pAdminHandler = h; }
|
||||
|
||||
void ScanDir();
|
||||
void CleanupDir(wxString &);
|
||||
void RemoveFromList(wxString md5);
|
||||
|
||||
private:
|
||||
wxCriticalSection m_csDir;
|
||||
wxString m_dirName;
|
||||
wxEvtHandler *m_pAdminHandler;
|
||||
SessionHash *m_sessions;
|
||||
wxDir *m_dir;
|
||||
wxRegEx *m_re;
|
||||
bool m_reValid;
|
||||
};
|
||||
|
||||
#endif // _SESSIONLIST_H_
|
||||
2591
SessionProperties.cpp
Normal file
2591
SessionProperties.cpp
Normal file
File diff suppressed because it is too large
Load Diff
508
SessionProperties.h
Normal file
508
SessionProperties.h
Normal file
@@ -0,0 +1,508 @@
|
||||
// $Id: SessionProperties.h 705 2012-03-16 13:01:13Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU LibroxyCommary General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _SESSIONPROPERTIES_H_
|
||||
#define _SESSIONPROPERTIES_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "SessionProperties.cpp"
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* Includes
|
||||
*/
|
||||
|
||||
////@begin includes
|
||||
#include "SessionProperties_symbols.h"
|
||||
#include "wx/xrc/xmlres.h"
|
||||
#include "wx/notebook.h"
|
||||
#include "wx/spinctrl.h"
|
||||
#include "wx/valgen.h"
|
||||
#include "wx/listctrl.h"
|
||||
#include "wx/html/htmlwin.h"
|
||||
////@end includes
|
||||
#include "wx/sizer.h"
|
||||
|
||||
/*!
|
||||
* Forward declarations
|
||||
*/
|
||||
|
||||
////@begin forward declarations
|
||||
class wxNotebook;
|
||||
class wxSpinCtrl;
|
||||
class wxListCtrl;
|
||||
class extHtmlWindow;
|
||||
////@end forward declarations
|
||||
|
||||
#include "MyValidator.h"
|
||||
#include "MyXmlConfig.h"
|
||||
|
||||
/*!
|
||||
* Control identifiers
|
||||
*/
|
||||
|
||||
////@begin control identifiers
|
||||
#define ID_DIALOG_PROPERTIES 10006
|
||||
#define SYMBOL_SESSIONPROPERTIES_STYLE wxCAPTION|wxSYSTEM_MENU|wxCLOSE_BOX
|
||||
#define SYMBOL_SESSIONPROPERTIES_TITLE _("Session properties - OpenNX")
|
||||
#define SYMBOL_SESSIONPROPERTIES_IDNAME ID_DIALOG_PROPERTIES
|
||||
#define SYMBOL_SESSIONPROPERTIES_SIZE wxDefaultSize
|
||||
#define SYMBOL_SESSIONPROPERTIES_POSITION wxDefaultPosition
|
||||
////@end control identifiers
|
||||
|
||||
/*!
|
||||
* Compatibility
|
||||
*/
|
||||
|
||||
#ifndef wxCLOSE_BOX
|
||||
#define wxCLOSE_BOX 0x1000
|
||||
#endif
|
||||
|
||||
class KbdLayout;
|
||||
WX_DECLARE_OBJARRAY(KbdLayout, KbdLayoutTable);
|
||||
|
||||
/*!
|
||||
* SessionProperties class declaration
|
||||
*/
|
||||
|
||||
class SessionProperties: public wxDialog, KeyTypeCallback
|
||||
{
|
||||
DECLARE_CLASS( SessionProperties )
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
public:
|
||||
/// Constructors
|
||||
SessionProperties( );
|
||||
SessionProperties( wxWindow* parent, wxWindowID id = SYMBOL_SESSIONPROPERTIES_IDNAME, const wxString& caption = SYMBOL_SESSIONPROPERTIES_TITLE, const wxPoint& pos = SYMBOL_SESSIONPROPERTIES_POSITION, const wxSize& size = SYMBOL_SESSIONPROPERTIES_SIZE, long style = SYMBOL_SESSIONPROPERTIES_STYLE );
|
||||
|
||||
/// Creation
|
||||
bool Create( wxWindow* parent, wxWindowID id = SYMBOL_SESSIONPROPERTIES_IDNAME, const wxString& caption = SYMBOL_SESSIONPROPERTIES_TITLE, const wxPoint& pos = SYMBOL_SESSIONPROPERTIES_POSITION, const wxSize& size = SYMBOL_SESSIONPROPERTIES_SIZE, long style = SYMBOL_SESSIONPROPERTIES_STYLE );
|
||||
|
||||
void UpdateDialogConstraints(bool);
|
||||
void SetConfig(MyXmlConfig *config);
|
||||
|
||||
private:
|
||||
/// Creates the controls and sizers
|
||||
void CreateControls();
|
||||
/**
|
||||
* Checks for any changes in the dialog and Enables/Disables the Apply-Button
|
||||
*/
|
||||
void CheckChanged();
|
||||
/**
|
||||
* Checks for any changes in the config and Enables/Disables the Apply-Button
|
||||
*/
|
||||
void CheckCfgChanges(bool prevchanges);
|
||||
/**
|
||||
* Handler for OnChar events.
|
||||
*/
|
||||
virtual void KeyTyped();
|
||||
/**
|
||||
* Installs event handler for OnChar event in all wxTextCtrl and wxSpinCtrl
|
||||
* childs.
|
||||
*/
|
||||
void InstallOnCharHandlers(wxWindow *w = NULL);
|
||||
|
||||
void SaveState();
|
||||
|
||||
public:
|
||||
|
||||
void OnContextHelp(wxCommandEvent &);
|
||||
|
||||
////@begin SessionProperties event handler declarations
|
||||
|
||||
/// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_TEXTCTRL_HOST
|
||||
void OnTextctrlHostUpdated( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_SPINCTRL_UPDATED event handler for ID_SPINCTRL_PORT
|
||||
void OnSpinctrlPortUpdated( wxSpinEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_SPINCTRL_PORT
|
||||
void OnTextctrlPortUpdated( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX_PWSAVE
|
||||
void OnCheckboxPwsaveClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_KEYMANAGE
|
||||
void OnButtonKeymanageClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX_SMARTCARD
|
||||
void OnCheckboxSmartcardClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_COMBOBOX_DPROTO
|
||||
void OnComboboxDprotoSelected( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_COMBOBOX_DTYPE
|
||||
void OnComboboxDtypeSelected( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_DSETTINGS
|
||||
void OnButtonDsettingsClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_SLIDER_UPDATED event handler for ID_SLIDER_SPEED
|
||||
void OnSliderSpeedUpdated( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_COMBOBOX_DISPTYPE
|
||||
void OnComboboxDisptypeSelected( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_SPINCTRL_UPDATED event handler for ID_SPINCTRL_WIDTH
|
||||
void OnSpinctrlWidthUpdated( wxSpinEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_SPINCTRL_WIDTH
|
||||
void OnSpinctrlWidthTextUpdated( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_SPINCTRL_UPDATED event handler for ID_SPINCTRL_HEIGHT
|
||||
void OnSpinctrlHeightUpdated( wxSpinEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_SPINCTRL_HEIGHT
|
||||
void OnSpinctrlHeightTextUpdated( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX_IMG_CUSTOM
|
||||
void OnCheckboxImgCustomClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_IMG_CUSTOM
|
||||
void OnButtonImgCustomClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX_KBDOTHER
|
||||
void OnCheckboxKbdotherClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_COMBOBOX_KBDLAYOUT
|
||||
void OnComboboxKbdlayoutSelected( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX_DISABLETCPNODEL
|
||||
void OnCheckboxDisabletcpnodelClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX_DISABLEZCOMP
|
||||
void OnCheckboxDisablezcompClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX_ENABLESSL
|
||||
void OnCheckboxEnablesslClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX_PROXY
|
||||
void OnCheckboxProxyClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_PROXYSETTINGS
|
||||
void OnButtonProxysettingsClick( wxCommandEvent& event );
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
/// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX_DISABLEDX
|
||||
void OnCheckboxDisabledxClick( wxCommandEvent& event );
|
||||
|
||||
#endif
|
||||
#if defined(__WXMSW__)
|
||||
/// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX_GRABKB
|
||||
void OnCheckboxGrabkbClick( wxCommandEvent& event );
|
||||
|
||||
#endif
|
||||
/// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX_NODEFERRED
|
||||
void OnCheckboxNodeferredClick( wxCommandEvent& event );
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
/// wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_COMBOBOX_CLIPFILTER
|
||||
void OnComboboxClipfilterSelected( wxCommandEvent& event );
|
||||
|
||||
#endif
|
||||
/// wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_COMBOBOX_CACHEMEM
|
||||
void OnComboboxCachememSelected( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_COMBOBOX_CACHEDISK
|
||||
void OnComboboxCachediskSelected( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_CACHECLEAN
|
||||
void OnButtonCachecleanClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX_SMB
|
||||
void OnCheckboxSmbClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_SPINCTRL_UPDATED event handler for ID_SPINCTRL_SMBPORT
|
||||
void OnSpinctrlSmbportUpdated( wxSpinEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_SPINCTRL_SMBPORT
|
||||
void OnSpinctrlSmbportTextUpdated( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX_CUPSENABLE
|
||||
void OnCheckboxCupsenableClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_SPINCTRL_UPDATED event handler for ID_SPINCTRL_CUPSPORT
|
||||
void OnSpinctrlCupsportUpdated( wxSpinEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_SPINCTRL_CUPSPORT
|
||||
void OnSpinctrlCupsportTextUpdated( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_LIST_ITEM_SELECTED event handler for ID_LISTCTRL_SMB_SHARES
|
||||
void OnListctrlSmbSharesSelected( wxListEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_LIST_ITEM_ACTIVATED event handler for ID_LISTCTRL_SMB_SHARES
|
||||
void OnListctrlSmbSharesItemActivated( wxListEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_SMB_ADD
|
||||
void OnButtonSmbAddClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_SMB_MODIFY
|
||||
void OnButtonSmbModifyClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_SMB_DELETE
|
||||
void OnButtonSmbDeleteClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX_MMEDIA
|
||||
void OnCheckboxMmediaClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX_NATIVEPA
|
||||
void OnCheckboxNativePAClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_COMBOBOX_RATEPA
|
||||
void OnComboboxRatePASelected( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX_MONOPA
|
||||
void OnCheckboxMonoPAClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX_USBENABLE
|
||||
void OnCHECKBOXUSBENABLEClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_LIST_ITEM_SELECTED event handler for ID_LISTCTRL_USBFILTER
|
||||
void OnListctrlUsbfilterSelected( wxListEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_LIST_ITEM_ACTIVATED event handler for ID_LISTCTRL_USBFILTER
|
||||
void OnListctrlUsbfilterItemActivated( wxListEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_USBADD
|
||||
void OnButtonUsbaddClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_USBMODIFY
|
||||
void OnButtonUsbmodifyClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_USBDELETE
|
||||
void OnButtonUsbdeleteClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_TEXTCTRL_USERDIR
|
||||
void OnTextctrlUserdirUpdated( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_BROWSE_USERDIR
|
||||
void OnButtonBrowseUserdirClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX_REMOVEOLDSF
|
||||
void OnCheckboxRemoveoldsfClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_TEXTCTRL_SYSDIR
|
||||
void OnTextctrlSysdirUpdated( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_BROWSE_SYSDIR
|
||||
void OnButtonBrowseSysdirClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_TEXTCTRL_CUPSPATH
|
||||
void OnTextctrlCupspathUpdated( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_BROWSE_CUPSPATH
|
||||
void OnButtonBrowseCupspathClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_TEXTCTRL_USBIPD_SOCKET
|
||||
void OnTextctrlUsbipdSocketTextUpdated( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_BROWSE_USBIPD_SOCKET
|
||||
void OnButtonBrowseUsbipdSocketClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_SPINCTRL_UPDATED event handler for ID_SPINCTRL_USB_LOCALPORT
|
||||
void OnSpinctrlUsbLocalportUpdated( wxSpinEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_SPINCTRL_USB_LOCALPORT
|
||||
void OnSpinctrlUsbLocalportTextUpdated( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX_CREATEICON
|
||||
void OnCheckboxCreateiconClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX_RESETMSGBOXES
|
||||
void OnCheckboxResetmsgboxesClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX_LOWERCASE_LOGIN
|
||||
void OnCheckboxLowercaseLoginClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX_CLEAR_PASSONABORT
|
||||
void OnCheckboxClearPassonabortClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX_NOMAGICPIXEL
|
||||
void OnCheckboxNomagicpixelClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_DELETE
|
||||
void OnDeleteClick( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_APPLY
|
||||
void OnApplyClick( wxCommandEvent& event );
|
||||
|
||||
////@end SessionProperties event handler declarations
|
||||
|
||||
////@begin SessionProperties member function declarations
|
||||
|
||||
bool GetbCreateDesktopIcon() const { return m_bCreateDesktopIcon ; }
|
||||
void SetbCreateDesktopIcon(bool value) { m_bCreateDesktopIcon = value ; }
|
||||
|
||||
int GetUsbLocalPort() const { return m_iUsbLocalPort ; }
|
||||
void SetUsbLocalPort(int value) { m_iUsbLocalPort = value ; }
|
||||
|
||||
wxString GetsSystemNxDir() const { return m_sSystemNxDir ; }
|
||||
void SetsSystemNxDir(wxString value) { m_sSystemNxDir = value ; }
|
||||
|
||||
wxString GetUsbipdSocket() const { return m_sUsbipdSocket ; }
|
||||
void SetUsbipdSocket(wxString value) { m_sUsbipdSocket = value ; }
|
||||
|
||||
wxString GetsUserNxDir() const { return m_sUserNxDir ; }
|
||||
void SetsUserNxDir(wxString value) { m_sUserNxDir = value ; }
|
||||
|
||||
/// Retrieves bitmap resources
|
||||
wxBitmap GetBitmapResource( const wxString& name );
|
||||
|
||||
/// Retrieves icon resources
|
||||
wxIcon GetIconResource( const wxString& name );
|
||||
////@end SessionProperties member function declarations
|
||||
|
||||
/// Should we show tooltips?
|
||||
static bool ShowToolTips();
|
||||
|
||||
private:
|
||||
////@begin SessionProperties member variables
|
||||
wxNotebook* m_pNoteBook;
|
||||
wxTextCtrl* m_pCtrlHostname;
|
||||
wxSpinCtrl* m_pCtrlPort;
|
||||
wxCheckBox* m_pCtrlUseSmartCard;
|
||||
wxComboBox* m_pCtrlSessionType;
|
||||
wxComboBox* m_pCtrlDesktopType;
|
||||
wxButton* m_pCtrlDesktopSettings;
|
||||
wxComboBox* m_pCtrlDisplayType;
|
||||
wxSpinCtrl* m_pCtrlDisplayWidth;
|
||||
wxSpinCtrl* m_pCtrlDisplayHeight;
|
||||
wxCheckBox* m_pCtrlImageEncCustom;
|
||||
wxButton* m_pCtrlImageSettings;
|
||||
wxCheckBox* m_pCtrlKeyboardOther;
|
||||
wxComboBox* m_pCtrlKeyboardLayout;
|
||||
wxCheckBox* m_pCtrlEnableSSL;
|
||||
wxButton* m_pCtrlProxySettings;
|
||||
wxCheckBox* m_pCtrlSmbEnable;
|
||||
wxSpinCtrl* m_pCtrlSmbPort;
|
||||
wxCheckBox* m_pCtrlCupsEnable;
|
||||
wxSpinCtrl* m_pCtrlCupsPort;
|
||||
wxListCtrl* m_pCtrlSmbShares;
|
||||
wxButton* m_pCtrlShareAdd;
|
||||
wxButton* m_pCtrlShareModify;
|
||||
wxButton* m_pCtrlShareDelete;
|
||||
wxCheckBox* m_pCtrlEnableMultimedia;
|
||||
wxCheckBox* m_pCtrlEnableNativePA;
|
||||
wxComboBox* m_pCtrlRatePA;
|
||||
wxCheckBox* m_pCtrlEnableMonoPA;
|
||||
wxCheckBox* m_pCtrlUsbEnable;
|
||||
wxListCtrl* m_pCtrlUsbFilter;
|
||||
wxButton* m_pCtrlUsbAdd;
|
||||
wxButton* m_pCtrlUsbModify;
|
||||
wxButton* m_pCtrlUsbDelete;
|
||||
wxTextCtrl* m_pCtrlUserNxDir;
|
||||
wxTextCtrl* m_pCtrlSystemNxDir;
|
||||
wxTextCtrl* m_pCtrlCupsPath;
|
||||
wxButton* m_pCtrlCupsBrowse;
|
||||
wxPanel* m_pCtrlUsbipdDaemon;
|
||||
wxTextCtrl* m_pCtrlUsbIpdSocket;
|
||||
wxButton* m_pCtrlUsbipdSocketBrowse;
|
||||
wxSpinCtrl* m_pCtrlUsbLocalPort;
|
||||
wxCheckBox* m_pCtrlResetMessageBoxes;
|
||||
wxPanel* m_pCtrlPanelAbout;
|
||||
extHtmlWindow* m_pHtmlWindow;
|
||||
wxButton* m_pCtrlApplyButton;
|
||||
private:
|
||||
bool m_bClearPassOnAbort;
|
||||
bool m_bCreateDesktopIcon;
|
||||
bool m_bDisableDeferredUpdates;
|
||||
bool m_bDisableDirectDraw;
|
||||
bool m_bDisableMagicPixel;
|
||||
bool m_bDisableTcpNoDelay;
|
||||
bool m_bDisableZlibCompression;
|
||||
bool m_bEnableMultimedia;
|
||||
bool m_bEnableNativePA;
|
||||
bool m_bEnableMonoPA;
|
||||
bool m_bEnableSSL;
|
||||
bool m_bEnableSmbSharing;
|
||||
bool m_bEnableUSBIP;
|
||||
bool m_bExternalProxy;
|
||||
bool m_bGrabKeyboard;
|
||||
bool m_bKbdLayoutOther;
|
||||
bool m_bLowercaseLogin;
|
||||
bool m_bProxyPassRemember;
|
||||
bool m_bRememberPassword;
|
||||
bool m_bRemoveOldSessionFiles;
|
||||
bool m_bResetMessageBoxes;
|
||||
bool m_bSavedClearPassOnAbort;
|
||||
bool m_bSavedCreateDesktopIcon;
|
||||
bool m_bSavedDisableMagicPixel;
|
||||
bool m_bSavedLowercaseLogin;
|
||||
bool m_bSavedResetMessageBoxes;
|
||||
bool m_bUseCups;
|
||||
bool m_bUseCustomImageEncoding;
|
||||
bool m_bUseDefaultImageEncoding;
|
||||
bool m_bUseProxy;
|
||||
bool m_bUseSmartCard;
|
||||
int m_iCacheDisk;
|
||||
int m_iCacheMem;
|
||||
int m_iClipFilter;
|
||||
int m_iConnectionSpeed;
|
||||
int m_iCupsPort;
|
||||
int m_iDesktopType;
|
||||
int m_iDesktopTypeDialog;
|
||||
int m_iDisplayHeight;
|
||||
int m_iDisplayType;
|
||||
int m_iDisplayWidth;
|
||||
int m_iPort;
|
||||
int m_iProxyPort;
|
||||
int m_iPseudoDesktopTypeIndex;
|
||||
int m_iPseudoDisplayTypeIndex;
|
||||
int m_iSavedUsbLocalPort;
|
||||
int m_iSessionType;
|
||||
int m_iSmbPort;
|
||||
int m_iRatePA;
|
||||
int m_iUsbLocalPort;
|
||||
wxString m_sCupsPath;
|
||||
wxString m_sHostName;
|
||||
wxString m_sKbdLayoutLanguage;
|
||||
wxString m_sProxyCommand;
|
||||
wxString m_sProxyHost;
|
||||
wxString m_sProxyPass;
|
||||
wxString m_sProxyUser;
|
||||
wxString m_sSystemNxDir;
|
||||
wxString m_sUsbipdSocket; // Local control socket for usbipd2
|
||||
wxString m_sUserNxDir;
|
||||
////@end SessionProperties member variables
|
||||
|
||||
bool readKbdLayouts();
|
||||
int findSelectedShare();
|
||||
#ifdef SUPPORT_USBIP
|
||||
int findSelectedUsbDevice();
|
||||
void appendUsbDevice(SharedUsbDevice &, int);
|
||||
#endif
|
||||
void updateListCtrlColumnWidth(wxListCtrl *);
|
||||
void removePage(const wxString &);
|
||||
|
||||
wxString m_sSavedUserNxDir;
|
||||
wxString m_sSavedSystemNxDir;
|
||||
wxString m_sSavedUsbipdSocket;
|
||||
bool m_bKeyTyped;
|
||||
bool m_bStorePasswords;
|
||||
int m_iUnixDesktopType;
|
||||
|
||||
MyXmlConfig *m_pCfg;
|
||||
KbdLayoutTable m_aKbdLayoutTable;
|
||||
ArrayOfUsbForwards m_aUsbForwards;
|
||||
};
|
||||
|
||||
#endif
|
||||
// _SESSIONPROPERTIES_H_
|
||||
120
SessionProperties_symbols.h
Normal file
120
SessionProperties_symbols.h
Normal file
@@ -0,0 +1,120 @@
|
||||
// $Id: SessionProperties_symbols.h 705 2012-03-16 13:01:13Z felfert $
|
||||
//
|
||||
// Copyright (C) 2011 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_0 _("Session properties - OpenNX")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_1 _("General")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_2 _("Server")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_3 _("Host")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_4 _("Port")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_5 _("Remember my password")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_6 _("Key...")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_7 _("Use SmartCard")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_8 _("Desktop")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_9 _("Unix")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_10 _("Windows")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_11 _("VNC")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_12 _("Shadow")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_13 _("KDE")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_14 _("GNOME")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_15 _("CDE")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_16 _("XFCE")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_17 _("XDMCP")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_18 _("Custom")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_19 _("Settings...")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_20 _("MODEM")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_21 _("ISDN")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_22 _("ADSL")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_23 _("WAN")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_24 _("LAN")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_25 _("Display and Keyboard")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_26 _("640x480")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_27 _("800x600")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_28 _("1024x768")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_29 _("Available Area")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_30 _("Fullscreen")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_31 _("W")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_32 _("H")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_33 _("Use custom settings")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_34 _("Modify...")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_35 _("Use custom layout")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_36 _("Advanced")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_37 _("Network")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_38 _("Disable no-delay on TCP connection")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_39 _("Disable ZLIB stream compression")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_40 _("Enable SSL encryption of all traffic")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_41 _("Connect through proxy")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_42 _("System")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_43 _("Disable DirectDraw rendering")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_44 _("Grab keyboard when client has focus")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_45 _("Disable deferred screen updates")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_46 _("Clipboard filter")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_47 _("Use PRIMARY selection")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_48 _("Use CLIPBOARD selection")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_49 _("Use both")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_50 _("Cache")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_51 _("In memory")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_52 _("0 Mb")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_53 _("1 Mb")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_54 _("2 Mb")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_55 _("4 Mb")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_56 _("8 Mb")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_57 _("16 Mb")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_58 _("32 Mb")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_59 _("64 Mb")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_60 _("128 Mb")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_61 _("On disk")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_62 _("256 Mb")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_63 _("512 Mb")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_64 _("Clean all cache files")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_65 _("Services")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_66 _("Enable SMB sharing")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_67 _("Default port")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_68 _("Enable CUPS printing")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_69 _("Add")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_70 _("Modify")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_71 _("Delete")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_72 _("Enable multimedia support")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_73 _("USB")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_74 _("Enable USB forwarding")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_75 _("Environment")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_76 _("User NX directory")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_77 _("...")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_78 _("Remove old session files")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_79 _("System NX directory")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_80 _("System CUPS daemon")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_81 _("System USBIP daemon")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_82 _("Local command socket path")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_83 _("Local port")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_84 _("Create a desktop icon for this session")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_85 _("Reset hidden messages")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_86 _("Always use lowercase login name")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_87 _("Clear password entry on abort")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_88 _("Disable magic pixel in fullscreen mode")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_89 _("About")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_90 _("&Delete")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_91 _("&Apply")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_92 _("&OK")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_93 _("&Cancel")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_94 _("1280x1024")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_95 _("1400x1050")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_96 _("1440x900")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_97 _("1680x1050")
|
||||
#define ID_DIALOG_PROPERTIES_SYMBOL_98 _("1920x1080")
|
||||
588
ShareProperties.cpp
Normal file
588
ShareProperties.cpp
Normal file
@@ -0,0 +1,588 @@
|
||||
// $Id: ShareProperties.cpp 707 2012-03-22 13:53:19Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma implementation "ShareProperties.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
////@begin includes
|
||||
////@end includes
|
||||
|
||||
#include "MyValidator.h"
|
||||
#include "MyXmlConfig.h"
|
||||
#include "WinShare.h"
|
||||
#include "ShareProperties.h"
|
||||
#include "Icon.h"
|
||||
#include "opennxApp.h"
|
||||
|
||||
#include <wx/bmpcbox.h>
|
||||
#include <wx/cshelp.h>
|
||||
|
||||
////@begin XPM images
|
||||
////@end XPM images
|
||||
|
||||
#include "trace.h"
|
||||
ENABLE_TRACE;
|
||||
|
||||
/*!
|
||||
* ShareProperties type definition
|
||||
*/
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS( ShareProperties, wxDialog )
|
||||
|
||||
/*!
|
||||
* ShareProperties event table definition
|
||||
*/
|
||||
|
||||
BEGIN_EVENT_TABLE( ShareProperties, wxDialog )
|
||||
|
||||
////@begin ShareProperties event table entries
|
||||
EVT_COMBOBOX( XRCID("ID_COMBOBOX_SHARE_LOCALNAME"), ShareProperties::OnComboboxShareLocalnameSelected )
|
||||
|
||||
EVT_BUTTON( wxID_OK, ShareProperties::OnOkClick )
|
||||
|
||||
////@end ShareProperties event table entries
|
||||
|
||||
EVT_MENU(wxID_CONTEXT_HELP, ShareProperties::OnContextHelp)
|
||||
|
||||
END_EVENT_TABLE()
|
||||
|
||||
/*!
|
||||
* ShareProperties constructors
|
||||
*/
|
||||
|
||||
ShareProperties::ShareProperties( )
|
||||
: m_iCurrentShare(-1)
|
||||
, m_bUseSmb(false)
|
||||
, m_bUseCups(false)
|
||||
{
|
||||
}
|
||||
|
||||
ShareProperties::ShareProperties( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
||||
: m_iCurrentShare(-1)
|
||||
, m_bUseSmb(false)
|
||||
, m_bUseCups(false)
|
||||
{
|
||||
Create(parent, id, caption, pos, size, style);
|
||||
}
|
||||
|
||||
void ShareProperties::SetConfig(MyXmlConfig *cfg)
|
||||
{
|
||||
m_pCfg = cfg;
|
||||
}
|
||||
|
||||
void ShareProperties::SetCurrentShare(int cs)
|
||||
{
|
||||
m_iCurrentShare = cs;
|
||||
}
|
||||
|
||||
void ShareProperties::SetUse(bool useSmb, bool useCups)
|
||||
{
|
||||
m_bUseSmb = useSmb;
|
||||
m_bUseCups = useCups;
|
||||
}
|
||||
|
||||
/*!
|
||||
* ShareProperties creator
|
||||
*/
|
||||
|
||||
bool ShareProperties::Create( wxWindow* parent, wxWindowID WXUNUSED(id), const wxString& WXUNUSED(caption), const wxPoint& WXUNUSED(pos), const wxSize& WXUNUSED(size), long WXUNUSED(style) )
|
||||
{
|
||||
////@begin ShareProperties member initialisation
|
||||
m_bCupsPublic = false;
|
||||
m_bSmbPublic = false;
|
||||
m_sCupsDriver = wxT("cups driver");
|
||||
m_sSmbDiskUsername = ::wxGetUserId();
|
||||
m_sSmbPrintUsername = ::wxGetUserId();
|
||||
m_pCtrlLocalShares = NULL;
|
||||
m_pCtrlSmbPrintOptions = NULL;
|
||||
m_pCtrlSmbDriver = NULL;
|
||||
m_pCtrlSmbPrivate = NULL;
|
||||
m_pCtrlSmbPublic = NULL;
|
||||
m_pCtrlSmbPrintUsername = NULL;
|
||||
m_pCtrlSmbPrintPassword = NULL;
|
||||
m_pCtrlCupsOptions = NULL;
|
||||
m_pCtrlCupsPrivate = NULL;
|
||||
m_pCtrlCupsPublic = NULL;
|
||||
m_pCtrlCupsPrintUsername = NULL;
|
||||
m_pCtrlCupsPrintPassword = NULL;
|
||||
m_pCtrlUsbOptions = NULL;
|
||||
m_pCtrlSmbDiskOptions = NULL;
|
||||
m_pCtrlMountPoint = NULL;
|
||||
m_pCtrlUsername = NULL;
|
||||
m_pCtrlPassword = NULL;
|
||||
////@end ShareProperties member initialisation
|
||||
|
||||
////@begin ShareProperties creation
|
||||
SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY|wxWS_EX_BLOCK_EVENTS|wxDIALOG_EX_CONTEXTHELP);
|
||||
SetParent(parent);
|
||||
CreateControls();
|
||||
SetIcon(GetIconResource(wxT("res/nx.png")));
|
||||
if (GetSizer())
|
||||
{
|
||||
GetSizer()->SetSizeHints(this);
|
||||
}
|
||||
Centre();
|
||||
////@end ShareProperties creation
|
||||
::wxGetApp().EnableContextHelp(this);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if wxCHECK_VERSION(3,1,0)
|
||||
static int cmpshares(SharedResource **a, SharedResource **b)
|
||||
#else
|
||||
static int cmpshares(_wxObjArrayArrayOfShares **a, _wxObjArrayArrayOfShares **b)
|
||||
#endif
|
||||
{
|
||||
return (*a)->name.Cmp((*b)->name);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Control creation for ShareProperties
|
||||
*/
|
||||
|
||||
void ShareProperties::CreateControls()
|
||||
{
|
||||
////@begin ShareProperties content construction
|
||||
if (!wxXmlResource::Get()->LoadDialog(this, GetParent(), _T("ID_DIALOG_SHARE_ADD")))
|
||||
wxLogError(wxT("Missing wxXmlResource::Get()->Load() in OnInit()?"));
|
||||
m_pCtrlLocalShares = XRCCTRL(*this, "ID_COMBOBOX_SHARE_LOCALNAME", wxBitmapComboBox);
|
||||
m_pCtrlSmbPrintOptions = XRCCTRL(*this, "ID_PANEL_SMB_PRINTER", wxPanel);
|
||||
m_pCtrlSmbDriver = XRCCTRL(*this, "ID_COMBOBOX_SMBDRIVER", wxComboBox);
|
||||
m_pCtrlSmbPrivate = XRCCTRL(*this, "ID_RADIOBUTTON_SMB_PRIVATE", wxRadioButton);
|
||||
m_pCtrlSmbPublic = XRCCTRL(*this, "ID_RADIOBUTTON_SMB_PUBLIC", wxRadioButton);
|
||||
m_pCtrlSmbPrintUsername = XRCCTRL(*this, "ID_TEXTCTRL_SMBPRINT_USERNAME", wxTextCtrl);
|
||||
m_pCtrlSmbPrintPassword = XRCCTRL(*this, "ID_TEXTCTRL_SMBPRINT_PASSWORD", wxTextCtrl);
|
||||
m_pCtrlCupsOptions = XRCCTRL(*this, "ID_PANEL_CUPSOPTIONS", wxPanel);
|
||||
m_pCtrlCupsPrivate = XRCCTRL(*this, "ID_RADIOBUTTON_CUPS_PRIVATE", wxRadioButton);
|
||||
m_pCtrlCupsPublic = XRCCTRL(*this, "ID_RADIOBUTTON_CUPS_PUBLIC", wxRadioButton);
|
||||
m_pCtrlCupsPrintUsername = XRCCTRL(*this, "ID_TEXTCTRL_CUPSPRINT_USERNAME", wxTextCtrl);
|
||||
m_pCtrlCupsPrintPassword = XRCCTRL(*this, "ID_TEXTCTRL_CUPSPRINT_PASSWORD", wxTextCtrl);
|
||||
m_pCtrlUsbOptions = XRCCTRL(*this, "ID_PANEL_USBIP", wxPanel);
|
||||
m_pCtrlSmbDiskOptions = XRCCTRL(*this, "ID_PANEL_SMBOPTIONS", wxPanel);
|
||||
m_pCtrlMountPoint = XRCCTRL(*this, "ID_TEXTCTRL_SHARE_MOUNTPOINT", wxTextCtrl);
|
||||
m_pCtrlUsername = XRCCTRL(*this, "ID_TEXTCTRL_SHARE_USERNAME", wxTextCtrl);
|
||||
m_pCtrlPassword = XRCCTRL(*this, "ID_TEXTCTRL_SHARE_PASSWORD", wxTextCtrl);
|
||||
// Set validators
|
||||
if (FindWindow(XRCID("ID_COMBOBOX_SMBDRIVER")))
|
||||
FindWindow(XRCID("ID_COMBOBOX_SMBDRIVER"))->SetValidator( wxGenericValidator(& m_sSmbDriver) );
|
||||
if (FindWindow(XRCID("ID_RADIOBUTTON_SMB_PUBLIC")))
|
||||
FindWindow(XRCID("ID_RADIOBUTTON_SMB_PUBLIC"))->SetValidator( wxGenericValidator(& m_bSmbPublic) );
|
||||
if (FindWindow(XRCID("ID_TEXTCTRL_SMBPRINT_USERNAME")))
|
||||
FindWindow(XRCID("ID_TEXTCTRL_SMBPRINT_USERNAME"))->SetValidator( MyValidator(& m_sSmbPrintUsername) );
|
||||
if (FindWindow(XRCID("ID_TEXTCTRL_SMBPRINT_PASSWORD")))
|
||||
FindWindow(XRCID("ID_TEXTCTRL_SMBPRINT_PASSWORD"))->SetValidator( MyValidator(& m_sSmbPrintPassword) );
|
||||
if (FindWindow(XRCID("ID_COMBOBOX_CUPSDRIVER")))
|
||||
FindWindow(XRCID("ID_COMBOBOX_CUPSDRIVER"))->SetValidator( wxGenericValidator(& m_sCupsDriver) );
|
||||
if (FindWindow(XRCID("ID_RADIOBUTTON_CUPS_PUBLIC")))
|
||||
FindWindow(XRCID("ID_RADIOBUTTON_CUPS_PUBLIC"))->SetValidator( wxGenericValidator(& m_bCupsPublic) );
|
||||
if (FindWindow(XRCID("ID_TEXTCTRL_CUPSPRINT_USERNAME")))
|
||||
FindWindow(XRCID("ID_TEXTCTRL_CUPSPRINT_USERNAME"))->SetValidator( MyValidator(& m_sCupsPrintUsername) );
|
||||
if (FindWindow(XRCID("ID_TEXTCTRL_CUPSPRINT_PASSWORD")))
|
||||
FindWindow(XRCID("ID_TEXTCTRL_CUPSPRINT_PASSWORD"))->SetValidator( MyValidator(& m_sCupsPrintPassword) );
|
||||
if (FindWindow(XRCID("ID_TEXTCTRL_SHARE_MOUNTPOINT")))
|
||||
FindWindow(XRCID("ID_TEXTCTRL_SHARE_MOUNTPOINT"))->SetValidator( MyValidator(& m_sMountPoint) );
|
||||
if (FindWindow(XRCID("ID_TEXTCTRL_SHARE_USERNAME")))
|
||||
FindWindow(XRCID("ID_TEXTCTRL_SHARE_USERNAME"))->SetValidator( MyValidator(& m_sSmbDiskUsername) );
|
||||
if (FindWindow(XRCID("ID_TEXTCTRL_SHARE_PASSWORD")))
|
||||
FindWindow(XRCID("ID_TEXTCTRL_SHARE_PASSWORD"))->SetValidator( MyValidator(& m_sSmbDiskPassword) );
|
||||
////@end ShareProperties content construction
|
||||
|
||||
// Create custom windows not generated automatically here.
|
||||
|
||||
////@begin ShareProperties content initialisation
|
||||
////@end ShareProperties content initialisation
|
||||
|
||||
int minw = 0;
|
||||
int minh = 0;
|
||||
int w, h;
|
||||
m_pCtrlSmbDiskOptions->Show(false);
|
||||
m_pCtrlSmbPrintOptions->Show(true);
|
||||
m_pCtrlCupsOptions->Show(false);
|
||||
InvalidateBestSize();
|
||||
Layout();
|
||||
m_pCtrlSmbPrintOptions->SetMinSize(m_pCtrlSmbPrintOptions->GetBestSize());
|
||||
GetBestSize(&minw, &minh);
|
||||
|
||||
m_pCtrlSmbDiskOptions->Show(false);
|
||||
m_pCtrlSmbPrintOptions->Show(false);
|
||||
m_pCtrlCupsOptions->Show(true);
|
||||
InvalidateBestSize();
|
||||
Layout();
|
||||
m_pCtrlCupsOptions->SetMinSize(m_pCtrlCupsOptions->GetBestSize());
|
||||
GetBestSize(&w, &h);
|
||||
if (w > minw)
|
||||
minw = w;
|
||||
if (h > minh)
|
||||
minh = h;
|
||||
|
||||
m_pCtrlCupsOptions->Show(false);
|
||||
m_pCtrlSmbDiskOptions->Show(true);
|
||||
m_pCtrlSmbPrintOptions->Show(false);
|
||||
InvalidateBestSize();
|
||||
Layout();
|
||||
m_pCtrlSmbDiskOptions->SetMinSize(m_pCtrlSmbDiskOptions->GetBestSize());
|
||||
GetBestSize(&w, &h);
|
||||
if (w > minw)
|
||||
minw = w;
|
||||
if (h > minh)
|
||||
minh = h;
|
||||
SetMinSize(wxSize(minw, minh));
|
||||
|
||||
if (m_iCurrentShare != -1) {
|
||||
ShareGroup sg = m_pCfg->aGetShareGroups().Item(m_iCurrentShare);
|
||||
wxBitmap bm = wxNullBitmap;
|
||||
m_pCtrlLocalShares->Append(sg.m_sShareName, bm, &sg);
|
||||
m_pCtrlLocalShares->SetSelection(0);
|
||||
m_pCtrlLocalShares->Enable(false);
|
||||
SetTitle(_("Modify shared resource - OpenNX"));
|
||||
switch (sg.m_eType) {
|
||||
case SharedResource::SHARE_UNKNOWN:
|
||||
break;
|
||||
case SharedResource::SHARE_SMB_DISK:
|
||||
m_pCtrlCupsOptions->Show(false);
|
||||
m_pCtrlSmbPrintOptions->Show(false);
|
||||
m_pCtrlSmbDiskOptions->Show(true);
|
||||
m_sMountPoint = sg.m_sAlias;
|
||||
m_sSmbDiskUsername = sg.m_sUsername;
|
||||
if (m_sSmbDiskUsername.IsEmpty())
|
||||
m_sSmbDiskUsername = ::wxGetUserId();
|
||||
m_sSmbDiskPassword = sg.m_sPassword;
|
||||
Layout();
|
||||
break;
|
||||
case SharedResource::SHARE_SMB_PRINTER:
|
||||
m_pCtrlCupsOptions->Show(false);
|
||||
m_pCtrlSmbDiskOptions->Show(false);
|
||||
m_pCtrlSmbPrintOptions->Show(true);
|
||||
m_sSmbDriver = sg.m_sDriver;
|
||||
m_sSmbPrintUsername = sg.m_sUsername;
|
||||
if (m_sSmbPrintUsername.IsEmpty())
|
||||
m_sSmbPrintUsername = ::wxGetUserId();
|
||||
m_sSmbPrintPassword = sg.m_sPassword;
|
||||
if (sg.m_bPublic)
|
||||
m_pCtrlSmbPublic->SetValue(true);
|
||||
else
|
||||
m_pCtrlSmbPrivate->SetValue(true);
|
||||
Layout();
|
||||
break;
|
||||
case SharedResource::SHARE_CUPS_PRINTER:
|
||||
m_pCtrlSmbPrintOptions->Show(false);
|
||||
m_pCtrlSmbDiskOptions->Show(false);
|
||||
m_pCtrlCupsOptions->GetSizer()->Layout();
|
||||
m_pCtrlCupsOptions->Show(true);
|
||||
m_sCupsPrintUsername = sg.m_sUsername;
|
||||
if (m_sCupsPrintUsername.IsEmpty())
|
||||
m_sCupsPrintUsername = ::wxGetUserId();
|
||||
m_sCupsPrintPassword = sg.m_sPassword;
|
||||
if (sg.m_bPublic)
|
||||
m_pCtrlCupsPublic->SetValue(true);
|
||||
else
|
||||
m_pCtrlCupsPrivate->SetValue(true);
|
||||
Layout();
|
||||
break;
|
||||
}
|
||||
m_pCtrlMountPoint->SetValue(m_sMountPoint);
|
||||
} else {
|
||||
// Fetch list of shares
|
||||
if (m_bUseSmb) {
|
||||
SmbClient sc;
|
||||
m_aShares = sc.GetShares();
|
||||
}
|
||||
if (m_bUseCups) {
|
||||
CupsClient cc;
|
||||
ArrayOfShares cupsShares = cc.GetShares();
|
||||
WX_APPEND_ARRAY(m_aShares, cupsShares);
|
||||
}
|
||||
// Apparently, wxGTK (perhaps GTK itself) has a bug which
|
||||
// results in data pointers not being associated properly to the
|
||||
// ComboBox, if that ComboBox is sorted (wxCB_SORT attribute).
|
||||
// As a woraround, we use an *unsorted* ComboBox and sort the
|
||||
// shares before adding them to the ComboBox.
|
||||
m_aShares.Sort(cmpshares);
|
||||
|
||||
// Build ComboBox content
|
||||
for (size_t i = 0; i < m_aShares.GetCount(); i++) {
|
||||
wxBitmap bm;
|
||||
switch (m_aShares[i].sharetype) {
|
||||
case SharedResource::SHARE_SMB_DISK:
|
||||
bm = GetBitmapResource(wxT("res/smbfolder.png"));
|
||||
break;
|
||||
case SharedResource::SHARE_SMB_PRINTER:
|
||||
bm = GetBitmapResource(wxT("res/smbprinter.png"));
|
||||
break;
|
||||
case SharedResource::SHARE_CUPS_PRINTER:
|
||||
bm = GetBitmapResource(wxT("res/cupsprinter.png"));
|
||||
break;
|
||||
default:
|
||||
bm = wxNullBitmap;
|
||||
break;
|
||||
}
|
||||
m_pCtrlLocalShares->Append(m_aShares[i].name, bm, m_aShares[i].GetThisVoid());
|
||||
}
|
||||
|
||||
if (m_aShares.GetCount() > 0) {
|
||||
// Select first element of ComboBox
|
||||
m_pCtrlLocalShares->SetSelection(0);
|
||||
SharedResource *res = wxDynamicCast(m_pCtrlLocalShares->GetClientData(0), SharedResource);
|
||||
wxASSERT(res);
|
||||
switch (res->sharetype) {
|
||||
case SharedResource::SHARE_UNKNOWN:
|
||||
break;
|
||||
case SharedResource::SHARE_SMB_DISK:
|
||||
m_pCtrlSmbPrintOptions->Show(false);
|
||||
m_pCtrlCupsOptions->Show(false);
|
||||
m_pCtrlSmbDiskOptions->Show(true);
|
||||
m_sMountPoint = res->name;
|
||||
Layout();
|
||||
break;
|
||||
case SharedResource::SHARE_SMB_PRINTER:
|
||||
m_pCtrlSmbDiskOptions->Show(false);
|
||||
m_pCtrlCupsOptions->Show(false);
|
||||
m_pCtrlSmbPrintOptions->Show(true);
|
||||
m_sSmbDriver = wxT("HP LaserJet ?");
|
||||
Layout();
|
||||
break;
|
||||
case SharedResource::SHARE_CUPS_PRINTER:
|
||||
m_pCtrlSmbDiskOptions->Show(false);
|
||||
m_pCtrlSmbPrintOptions->Show(false);
|
||||
m_pCtrlCupsOptions->Show(true);
|
||||
Layout();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
wxLogMessage(_("No shares found"));
|
||||
m_pCtrlLocalShares->Enable(false);
|
||||
m_pCtrlMountPoint->Enable(false);
|
||||
m_pCtrlUsername->Enable(false);
|
||||
m_pCtrlPassword->Enable(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ShareProperties::OnContextHelp(wxCommandEvent &)
|
||||
{
|
||||
wxContextHelp contextHelp(this);
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_COMBOBOX_SHARE_LOCALNAME
|
||||
*/
|
||||
|
||||
void ShareProperties::OnComboboxShareLocalnameSelected( wxCommandEvent& event )
|
||||
{
|
||||
SharedResource *res = wxDynamicCast(m_pCtrlLocalShares->GetClientData(event.GetInt()), SharedResource);
|
||||
wxASSERT(res);
|
||||
switch (res->sharetype) {
|
||||
case SharedResource::SHARE_UNKNOWN:
|
||||
break;
|
||||
case SharedResource::SHARE_SMB_DISK:
|
||||
m_pCtrlCupsOptions->Show(false);
|
||||
m_pCtrlSmbPrintOptions->Show(false);
|
||||
m_pCtrlSmbDiskOptions->Show(true);
|
||||
m_sMountPoint = res->name;
|
||||
m_pCtrlMountPoint->SetValue(m_sMountPoint);
|
||||
Layout();
|
||||
break;
|
||||
case SharedResource::SHARE_SMB_PRINTER:
|
||||
m_sSmbDriver = wxT("HP LaserJet ?");
|
||||
m_pCtrlSmbDriver->SetValue(m_sSmbDriver);
|
||||
m_pCtrlCupsOptions->Show(false);
|
||||
m_pCtrlSmbDiskOptions->Show(false);
|
||||
m_pCtrlCupsOptions->Show(false);
|
||||
m_pCtrlCupsOptions->GetSizer()->Layout();
|
||||
m_pCtrlSmbPrintOptions->Show(true);
|
||||
Layout();
|
||||
break;
|
||||
case SharedResource::SHARE_CUPS_PRINTER:
|
||||
m_sCupsDriver = wxT("HP LaserJet ?");
|
||||
m_pCtrlSmbPrintOptions->Show(false);
|
||||
m_pCtrlSmbDiskOptions->Show(false);
|
||||
m_pCtrlCupsOptions->GetSizer()->Layout();
|
||||
m_pCtrlCupsOptions->Show(true);
|
||||
Layout();
|
||||
break;
|
||||
}
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void ShareProperties::askForDefault(ArrayOfShareGroups &sg, ShareGroup &g)
|
||||
{
|
||||
if (g.m_bDefault)
|
||||
return;
|
||||
wxString msg =
|
||||
wxString::Format(_("Do you want to make\n%s\nthe default printer?"), VMB(g.m_sShareName));
|
||||
wxMessageDialog d(this, msg, _("Default printer"), wxYES_NO|wxICON_QUESTION);
|
||||
if (d.ShowModal() == wxID_YES) {
|
||||
for (size_t i = 0; i < sg.GetCount(); i++)
|
||||
sg[i].m_bDefault = false;
|
||||
g.m_bDefault = true;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
|
||||
*/
|
||||
|
||||
void ShareProperties::OnOkClick( wxCommandEvent& event )
|
||||
{
|
||||
ArrayOfShareGroups sg = m_pCfg->aGetShareGroups();
|
||||
int nPrinters = 0;
|
||||
TransferDataFromWindow();
|
||||
for (size_t i = 0; i < sg.GetCount(); i++) {
|
||||
switch (sg[i].m_eType) {
|
||||
case SharedResource::SHARE_UNKNOWN:
|
||||
break;
|
||||
case SharedResource::SHARE_CUPS_PRINTER:
|
||||
nPrinters++;
|
||||
break;
|
||||
case SharedResource::SHARE_SMB_PRINTER:
|
||||
nPrinters++;
|
||||
break;
|
||||
case SharedResource::SHARE_SMB_DISK:
|
||||
if ((sg[i].m_sAlias == m_sMountPoint) && ((int)i != m_iCurrentShare)) {
|
||||
wxMessageBox(_("Mountpoint is already used. Please chose another mountpoint"),
|
||||
_("Invalid mountpoint"), wxICON_ERROR|wxOK);
|
||||
if (m_iCurrentShare != -1)
|
||||
m_pCtrlMountPoint->SetValue(sg[m_iCurrentShare].m_sAlias);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (m_iCurrentShare != -1) {
|
||||
switch (sg[m_iCurrentShare].m_eType) {
|
||||
case SharedResource::SHARE_UNKNOWN:
|
||||
break;
|
||||
case SharedResource::SHARE_SMB_DISK:
|
||||
sg[m_iCurrentShare].m_sAlias = m_sMountPoint;
|
||||
sg[m_iCurrentShare].m_sUsername = m_sSmbDiskUsername;
|
||||
sg[m_iCurrentShare].m_sPassword = m_sSmbDiskPassword;
|
||||
break;
|
||||
case SharedResource::SHARE_SMB_PRINTER:
|
||||
sg[m_iCurrentShare].m_sDriver = m_sSmbDriver;
|
||||
sg[m_iCurrentShare].m_bPublic = m_bSmbPublic;
|
||||
sg[m_iCurrentShare].m_sUsername = m_sSmbPrintUsername;
|
||||
sg[m_iCurrentShare].m_sPassword = m_sSmbPrintPassword;
|
||||
if (nPrinters > 0)
|
||||
askForDefault(sg, sg[m_iCurrentShare]);
|
||||
break;
|
||||
case SharedResource::SHARE_CUPS_PRINTER:
|
||||
sg[m_iCurrentShare].m_sUsername = ::wxGetUserId();
|
||||
sg[m_iCurrentShare].m_sDriver = m_sCupsDriver;
|
||||
sg[m_iCurrentShare].m_bPublic = m_bCupsPublic;
|
||||
sg[m_iCurrentShare].m_sUsername = m_sCupsPrintUsername;
|
||||
sg[m_iCurrentShare].m_sPassword = m_sCupsPrintPassword;
|
||||
if (nPrinters > 0)
|
||||
askForDefault(sg, sg[m_iCurrentShare]);
|
||||
break;
|
||||
}
|
||||
m_pCfg->aSetShareGroups(sg);
|
||||
} else {
|
||||
ShareGroup g;
|
||||
SharedResource *res = wxDynamicCast(m_pCtrlLocalShares->GetClientData(m_pCtrlLocalShares->GetSelection()), SharedResource);
|
||||
wxASSERT(res);
|
||||
myLogTrace(MYTRACETAG, wxT("selected: %d %p"), (int)event.GetInt(), res);
|
||||
|
||||
g.m_eType = res->sharetype;
|
||||
g.m_sShareName = res->name;
|
||||
g.m_sGroupName = wxString::Format(wxT("Share%d"), (int)sg.GetCount());
|
||||
g.m_bDefault = false;
|
||||
switch (res->sharetype) {
|
||||
case SharedResource::SHARE_UNKNOWN:
|
||||
break;
|
||||
case SharedResource::SHARE_SMB_DISK:
|
||||
g.m_sAlias = m_sMountPoint;
|
||||
g.m_sUsername = m_sSmbDiskUsername;
|
||||
g.m_sPassword = m_sSmbDiskPassword;
|
||||
break;
|
||||
case SharedResource::SHARE_SMB_PRINTER:
|
||||
g.m_sDriver = m_sSmbDriver;
|
||||
g.m_bPublic = m_bSmbPublic;
|
||||
g.m_sUsername = m_sSmbPrintUsername;
|
||||
g.m_sPassword = m_sSmbPrintPassword;
|
||||
if (nPrinters > 0)
|
||||
askForDefault(sg, g);
|
||||
break;
|
||||
case SharedResource::SHARE_CUPS_PRINTER:
|
||||
g.m_sDriver = wxT("cups driver");
|
||||
g.m_bPublic = m_bCupsPublic;
|
||||
g.m_sUsername = m_sCupsPrintUsername;
|
||||
g.m_sPassword = m_sCupsPrintPassword;
|
||||
if (nPrinters > 0)
|
||||
askForDefault(sg, g);
|
||||
break;
|
||||
}
|
||||
sg.Add(g);
|
||||
m_pCfg->aSetShareGroups(sg);
|
||||
wxArrayString as = m_pCfg->aGetUsedShareGroups();
|
||||
as.Add(g.m_sGroupName);
|
||||
m_pCfg->aSetUsedShareGroups(as);
|
||||
m_pCfg->iSetUsedShareGroups(m_pCfg->iGetUsedShareGroups() + 1);
|
||||
}
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
/*!
|
||||
* Should we show tooltips?
|
||||
*/
|
||||
|
||||
bool ShareProperties::ShowToolTips()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get bitmap resources
|
||||
*/
|
||||
|
||||
wxBitmap ShareProperties::GetBitmapResource( const wxString& name )
|
||||
{
|
||||
// Bitmap retrieval
|
||||
return CreateBitmapFromFile(name);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get icon resources
|
||||
*/
|
||||
|
||||
wxIcon ShareProperties::GetIconResource( const wxString& name )
|
||||
{
|
||||
// Icon retrieval
|
||||
return CreateIconFromFile(name);
|
||||
}
|
||||
168
ShareProperties.h
Normal file
168
ShareProperties.h
Normal file
@@ -0,0 +1,168 @@
|
||||
// $Id: ShareProperties.h 707 2012-03-22 13:53:19Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _SHAREPROPERTIES_H_
|
||||
#define _SHAREPROPERTIES_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "ShareProperties.cpp"
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* Includes
|
||||
*/
|
||||
|
||||
////@begin includes
|
||||
#include "ShareProperties_symbols.h"
|
||||
#include "wx/xrc/xmlres.h"
|
||||
#include "wx/bmpcbox.h"
|
||||
#include "wx/valgen.h"
|
||||
#include "wx/statline.h"
|
||||
////@end includes
|
||||
|
||||
#include "WinShare.h"
|
||||
#include "MyXmlConfig.h"
|
||||
|
||||
/*!
|
||||
* Forward declarations
|
||||
*/
|
||||
|
||||
////@begin forward declarations
|
||||
class wxBitmapComboBox;
|
||||
////@end forward declarations
|
||||
class MyXmlConfig;
|
||||
class SharedResource;
|
||||
|
||||
/*!
|
||||
* Control identifiers
|
||||
*/
|
||||
|
||||
////@begin control identifiers
|
||||
#define ID_DIALOG_SHARE_ADD 10098
|
||||
#define SYMBOL_SHAREPROPERTIES_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX
|
||||
#define SYMBOL_SHAREPROPERTIES_TITLE _("New shared resource - OpenNX")
|
||||
#define SYMBOL_SHAREPROPERTIES_IDNAME ID_DIALOG_SHARE_ADD
|
||||
#define SYMBOL_SHAREPROPERTIES_SIZE wxSize(114, 75)
|
||||
#define SYMBOL_SHAREPROPERTIES_POSITION wxDefaultPosition
|
||||
////@end control identifiers
|
||||
|
||||
/*!
|
||||
* Compatibility
|
||||
*/
|
||||
|
||||
#ifndef wxCLOSE_BOX
|
||||
#define wxCLOSE_BOX 0x1000
|
||||
#endif
|
||||
#ifndef wxFIXED_MINSIZE
|
||||
#define wxFIXED_MINSIZE 0
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* ShareProperties class declaration
|
||||
*/
|
||||
|
||||
class ShareProperties: public wxDialog
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS( ShareProperties )
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
public:
|
||||
/// Constructors
|
||||
ShareProperties( );
|
||||
ShareProperties( wxWindow* parent, wxWindowID id = SYMBOL_SHAREPROPERTIES_IDNAME, const wxString& caption = SYMBOL_SHAREPROPERTIES_TITLE, const wxPoint& pos = SYMBOL_SHAREPROPERTIES_POSITION, const wxSize& size = SYMBOL_SHAREPROPERTIES_SIZE, long style = SYMBOL_SHAREPROPERTIES_STYLE );
|
||||
void SetConfig(MyXmlConfig *);
|
||||
void SetCurrentShare(int);
|
||||
void SetUse(bool, bool);
|
||||
|
||||
/// Creation
|
||||
bool Create( wxWindow* parent, wxWindowID id = SYMBOL_SHAREPROPERTIES_IDNAME, const wxString& caption = SYMBOL_SHAREPROPERTIES_TITLE, const wxPoint& pos = SYMBOL_SHAREPROPERTIES_POSITION, const wxSize& size = SYMBOL_SHAREPROPERTIES_SIZE, long style = SYMBOL_SHAREPROPERTIES_STYLE );
|
||||
|
||||
private:
|
||||
void askForDefault(ArrayOfShareGroups &, ShareGroup &);
|
||||
|
||||
/// Creates the controls and sizers
|
||||
void CreateControls();
|
||||
|
||||
void OnContextHelp(wxCommandEvent &);
|
||||
|
||||
////@begin ShareProperties event handler declarations
|
||||
|
||||
/// wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_COMBOBOX_SHARE_LOCALNAME
|
||||
void OnComboboxShareLocalnameSelected( wxCommandEvent& event );
|
||||
|
||||
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
|
||||
void OnOkClick( wxCommandEvent& event );
|
||||
|
||||
////@end ShareProperties event handler declarations
|
||||
|
||||
////@begin ShareProperties member function declarations
|
||||
|
||||
/// Retrieves bitmap resources
|
||||
wxBitmap GetBitmapResource( const wxString& name );
|
||||
|
||||
/// Retrieves icon resources
|
||||
wxIcon GetIconResource( const wxString& name );
|
||||
////@end ShareProperties member function declarations
|
||||
|
||||
/// Should we show tooltips?
|
||||
static bool ShowToolTips();
|
||||
|
||||
////@begin ShareProperties member variables
|
||||
wxBitmapComboBox* m_pCtrlLocalShares;
|
||||
wxPanel* m_pCtrlSmbPrintOptions;
|
||||
wxComboBox* m_pCtrlSmbDriver;
|
||||
wxRadioButton* m_pCtrlSmbPrivate;
|
||||
wxRadioButton* m_pCtrlSmbPublic;
|
||||
wxTextCtrl* m_pCtrlSmbPrintUsername;
|
||||
wxTextCtrl* m_pCtrlSmbPrintPassword;
|
||||
wxPanel* m_pCtrlCupsOptions;
|
||||
wxRadioButton* m_pCtrlCupsPrivate;
|
||||
wxRadioButton* m_pCtrlCupsPublic;
|
||||
wxTextCtrl* m_pCtrlCupsPrintUsername;
|
||||
wxTextCtrl* m_pCtrlCupsPrintPassword;
|
||||
wxPanel* m_pCtrlUsbOptions;
|
||||
wxPanel* m_pCtrlSmbDiskOptions;
|
||||
wxTextCtrl* m_pCtrlMountPoint;
|
||||
wxTextCtrl* m_pCtrlUsername;
|
||||
wxTextCtrl* m_pCtrlPassword;
|
||||
private:
|
||||
bool m_bCupsPublic;
|
||||
bool m_bSmbPublic;
|
||||
wxString m_sCupsDriver;
|
||||
wxString m_sMountPoint;
|
||||
wxString m_sSmbDiskPassword;
|
||||
wxString m_sSmbDiskUsername;
|
||||
wxString m_sSmbDriver;
|
||||
wxString m_sSmbPrintPassword;
|
||||
wxString m_sSmbPrintUsername;
|
||||
wxString m_sCupsPrintPassword;
|
||||
wxString m_sCupsPrintUsername;
|
||||
////@end ShareProperties member variables
|
||||
|
||||
int m_iCurrentShare;
|
||||
ArrayOfShares m_aShares;
|
||||
MyXmlConfig *m_pCfg;
|
||||
bool m_bUseSmb;
|
||||
bool m_bUseCups;
|
||||
};
|
||||
|
||||
#endif
|
||||
// _SHAREPROPERTIES_H_
|
||||
52
ShareProperties_symbols.h
Normal file
52
ShareProperties_symbols.h
Normal file
@@ -0,0 +1,52 @@
|
||||
// $Id: ShareProperties_symbols.h 707 2012-03-22 13:53:19Z felfert $
|
||||
//
|
||||
// Copyright (C) 2011 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#define ID_DIALOG_SHARE_ADD_SYMBOL_0 _("New shared resource - OpenNX")
|
||||
#define ID_DIALOG_SHARE_ADD_SYMBOL_1 _("Please select the name of the shared resource on the\nlocal computer.")
|
||||
#define ID_DIALOG_SHARE_ADD_SYMBOL_2 _("Share")
|
||||
#define ID_DIALOG_SHARE_ADD_SYMBOL_3 _("SMB printer options")
|
||||
#define ID_DIALOG_SHARE_ADD_SYMBOL_4 _("Please choose a printer driver:")
|
||||
#define ID_DIALOG_SHARE_ADD_SYMBOL_5 _("deskjet")
|
||||
#define ID_DIALOG_SHARE_ADD_SYMBOL_6 _("deskjet2")
|
||||
#define ID_DIALOG_SHARE_ADD_SYMBOL_7 _("dymo")
|
||||
#define ID_DIALOG_SHARE_ADD_SYMBOL_8 _("epson24")
|
||||
#define ID_DIALOG_SHARE_ADD_SYMBOL_9 _("epson9")
|
||||
#define ID_DIALOG_SHARE_ADD_SYMBOL_10 _("laserjet")
|
||||
#define ID_DIALOG_SHARE_ADD_SYMBOL_11 _("okidata24")
|
||||
#define ID_DIALOG_SHARE_ADD_SYMBOL_12 _("okidata9")
|
||||
#define ID_DIALOG_SHARE_ADD_SYMBOL_13 _("stcolor")
|
||||
#define ID_DIALOG_SHARE_ADD_SYMBOL_14 _("stcolor2")
|
||||
#define ID_DIALOG_SHARE_ADD_SYMBOL_15 _("stphoto")
|
||||
#define ID_DIALOG_SHARE_ADD_SYMBOL_16 _("stphoto2")
|
||||
#define ID_DIALOG_SHARE_ADD_SYMBOL_17 _("Access control:")
|
||||
#define ID_DIALOG_SHARE_ADD_SYMBOL_18 _("Private printer")
|
||||
#define ID_DIALOG_SHARE_ADD_SYMBOL_19 _("Public printer")
|
||||
#define ID_DIALOG_SHARE_ADD_SYMBOL_20 _("The remote system will need to provide security\ncredentials to your local client. Please specify\nusername and password with which you configured\nthis share.")
|
||||
#define ID_DIALOG_SHARE_ADD_SYMBOL_21 _("Username")
|
||||
#define ID_DIALOG_SHARE_ADD_SYMBOL_22 _("Password")
|
||||
#define ID_DIALOG_SHARE_ADD_SYMBOL_23 _("CUPS options")
|
||||
#define ID_DIALOG_SHARE_ADD_SYMBOL_24 _("cups driver")
|
||||
#define ID_DIALOG_SHARE_ADD_SYMBOL_25 _("USB Filter Details")
|
||||
#define ID_DIALOG_SHARE_ADD_SYMBOL_26 _("SMB options")
|
||||
#define ID_DIALOG_SHARE_ADD_SYMBOL_27 _("Please specify the resource name on the remote\nmachine with which this share will be made available.")
|
||||
#define ID_DIALOG_SHARE_ADD_SYMBOL_28 _("Mount on")
|
||||
#define ID_DIALOG_SHARE_ADD_SYMBOL_29 _("&OK")
|
||||
#define ID_DIALOG_SHARE_ADD_SYMBOL_30 _("&Cancel")
|
||||
452
SimpleXauth.cpp
Normal file
452
SimpleXauth.cpp
Normal file
@@ -0,0 +1,452 @@
|
||||
// $Id: SimpleXauth.cpp 501 2010-03-01 08:10:39Z felfert $
|
||||
//
|
||||
// Copyright (C) 2010 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma implementation "SimpleXauth.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
# if defined(__WXMSW__) || defined(APP_TESTXAUTH)
|
||||
|
||||
#include "SimpleXauth.h"
|
||||
#include "pwcrypt.h"
|
||||
#include <wx/socket.h>
|
||||
#include <wx/tokenzr.h>
|
||||
#include <wx/hashset.h>
|
||||
#include <wx/wfstream.h>
|
||||
|
||||
# define XauthFamilyInternet 0 /* IPv4 */
|
||||
# define XauthFamilyDECnet 1
|
||||
# define XauthFamilyChaos 2
|
||||
# define XauthFamilyInternet6 6 /* IPv6 */
|
||||
# define XauthFamilyServerInterpreted 5
|
||||
# define XauthFamilyLocal 256 /* not part of X standard (i.e. X.h) */
|
||||
# define XauthFamilyWild 65535
|
||||
# define XauthFamilyNetname 254 /* not part of X standard */
|
||||
# define XauthFamilyKrb5Principal 253 /* Kerberos 5 principal name */
|
||||
# define XauthFamilyLocalHost 252 /* for local non-net authentication */
|
||||
|
||||
typedef struct xauth {
|
||||
unsigned short family;
|
||||
unsigned short address_length;
|
||||
char *address;
|
||||
unsigned short number_length;
|
||||
char *number;
|
||||
unsigned short name_length;
|
||||
char *name;
|
||||
unsigned short data_length;
|
||||
char *data;
|
||||
} Xauth;
|
||||
|
||||
class SimpleXauthEntry
|
||||
{
|
||||
public:
|
||||
SimpleXauthEntry();
|
||||
SimpleXauthEntry(wxString cookie);
|
||||
SimpleXauthEntry(const SimpleXauthEntry &);
|
||||
~SimpleXauthEntry();
|
||||
bool Read(wxInputStream &);
|
||||
bool Write(wxOutputStream &);
|
||||
void SetUnix(wxString name, int display);
|
||||
void SetInternet(wxIPV4address addr, int display);
|
||||
wxString GetKey() const;
|
||||
wxString Dump() const;
|
||||
private:
|
||||
Xauth au;
|
||||
wxIPV4address iaddr;
|
||||
wxString naddr;
|
||||
wxString dpystr;
|
||||
void init();
|
||||
bool readShort(wxInputStream &, unsigned short &);
|
||||
bool readString(wxInputStream &, unsigned short &, char *&);
|
||||
bool writeShort(wxOutputStream &, unsigned short);
|
||||
bool writeString(wxOutputStream &, unsigned short, char *);
|
||||
|
||||
friend class SimpleXauthEntryHash;
|
||||
friend class SimpleXauthEntryEqual;
|
||||
};
|
||||
|
||||
SimpleXauthEntry::SimpleXauthEntry()
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
SimpleXauthEntry::SimpleXauthEntry(wxString cookie)
|
||||
{
|
||||
init();
|
||||
unsigned long l;
|
||||
unsigned int idx = 0;
|
||||
for (idx = 0; idx < cookie.Length(); idx += 2) {
|
||||
if (!cookie.Mid(idx, 2).ToULong(&l, 16))
|
||||
break;
|
||||
au.data_length++;
|
||||
}
|
||||
au.data = new char[au.data_length];
|
||||
for (idx = 0; idx < cookie.Length(); idx += 2) {
|
||||
if (!cookie.Mid(idx, 2).ToULong(&l, 16))
|
||||
break;
|
||||
au.data[idx / 2] = l;
|
||||
}
|
||||
}
|
||||
|
||||
SimpleXauthEntry::SimpleXauthEntry(const SimpleXauthEntry &other)
|
||||
{
|
||||
memcpy(&au, &other.au, sizeof(au));
|
||||
if (au.address_length && au.address) {
|
||||
au.address = new char [au.address_length];
|
||||
if (au.address)
|
||||
memcpy(au.address, other.au.address, au.address_length);
|
||||
}
|
||||
if (au.number_length && au.number) {
|
||||
au.number = new char [au.number_length];
|
||||
if (au.number)
|
||||
memcpy(au.number, other.au.number, au.number_length);
|
||||
}
|
||||
if (au.name_length && au.name) {
|
||||
au.name = new char [au.name_length];
|
||||
if (au.name)
|
||||
memcpy(au.name, other.au.name, au.name_length);
|
||||
}
|
||||
if (au.data_length && au.data) {
|
||||
au.data = new char [au.data_length];
|
||||
if (au.data)
|
||||
memcpy(au.data, other.au.data, au.data_length);
|
||||
}
|
||||
dpystr = other.dpystr;
|
||||
naddr = other.naddr;
|
||||
iaddr = other.iaddr;
|
||||
}
|
||||
|
||||
SimpleXauthEntry::~SimpleXauthEntry()
|
||||
{
|
||||
if (au.address)
|
||||
delete au.address;
|
||||
if (au.number)
|
||||
delete au.number;
|
||||
if (au.name)
|
||||
delete au.name;
|
||||
if (au.data)
|
||||
delete au.data;
|
||||
}
|
||||
|
||||
void SimpleXauthEntry::init()
|
||||
{
|
||||
memset(&au, 0, sizeof(au));
|
||||
// set our defaults
|
||||
au.name = strdup("MIT-MAGIC-COOKIE-1");
|
||||
au.name_length = 18;
|
||||
}
|
||||
|
||||
wxString SimpleXauthEntry::Dump() const
|
||||
{
|
||||
wxString tmp;
|
||||
tmp << wxT("family: ") << au.family << wxT(", addr: ");
|
||||
if (au.family == XauthFamilyInternet)
|
||||
tmp << iaddr.IPAddress();
|
||||
else
|
||||
tmp << naddr;
|
||||
tmp << wxT(", dpy: ") << dpystr;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
wxString SimpleXauthEntry::GetKey() const
|
||||
{
|
||||
wxString key;
|
||||
key << au.family << wxT(":");
|
||||
switch (au.family) {
|
||||
case XauthFamilyInternet:
|
||||
key << iaddr.IPAddress();
|
||||
break;
|
||||
default:
|
||||
key << naddr.Upper();
|
||||
break;
|
||||
}
|
||||
key << wxT(":") << dpystr;
|
||||
return key;
|
||||
}
|
||||
|
||||
bool SimpleXauthEntry::readShort(wxInputStream &s, unsigned short &val)
|
||||
{
|
||||
unsigned char buf[2];
|
||||
if (s.Read(&buf, sizeof(buf)).LastRead() == sizeof(buf)) {
|
||||
val = buf[0] * 256 + buf[1];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SimpleXauthEntry::readString(wxInputStream &s, unsigned short &len, char * &buf)
|
||||
{
|
||||
if (readShort(s, len)) {
|
||||
if (buf) {
|
||||
delete buf;
|
||||
buf = NULL;
|
||||
}
|
||||
if (len > 0) {
|
||||
buf = new char[len];
|
||||
if (!buf)
|
||||
return false;
|
||||
return (s.Read(buf, len).LastRead() == len);
|
||||
} else
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SimpleXauthEntry::Read(wxInputStream &s)
|
||||
{
|
||||
char *tmp;
|
||||
if (!readShort(s, au.family))
|
||||
return false;
|
||||
if (!readString(s, au.address_length, au.address))
|
||||
return false;
|
||||
if (!readString(s, au.number_length, au.number))
|
||||
return false;
|
||||
if (!readString(s, au.name_length, au.name))
|
||||
return false;
|
||||
if (!readString(s, au.data_length, au.data))
|
||||
return false;
|
||||
switch (au.family) {
|
||||
case XauthFamilyLocal:
|
||||
if (au.address_length > 0) {
|
||||
tmp = new char[au.address_length + 1];
|
||||
if (tmp) {
|
||||
memcpy(tmp, au.address, au.address_length);
|
||||
tmp[au.address_length] = '\0';
|
||||
naddr = wxString(wxConvUTF8.cMB2WC(tmp));
|
||||
delete tmp;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case XauthFamilyInternet:
|
||||
if (au.address_length == 4) {
|
||||
iaddr.Hostname(wxString::Format(wxT("%d.%d.%d.%d"),
|
||||
au.address[0] & 255, au.address[1] & 255,
|
||||
au.address[2] & 255, au.address[3] & 255));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
naddr = wxEmptyString;
|
||||
for (int i = 0; i < au.address_length; i++) {
|
||||
int ia = au.address[i];
|
||||
naddr.Append(wxString::Format(wxT("%02x"), ia));
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (au.number_length > 0) {
|
||||
tmp = new char[au.number_length + 1];
|
||||
if (tmp) {
|
||||
memcpy(tmp, au.number, au.number_length);
|
||||
tmp[au.number_length] = '\0';
|
||||
dpystr = wxString(wxConvUTF8.cMB2WC(tmp));
|
||||
delete tmp;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SimpleXauthEntry::writeShort(wxOutputStream &s, unsigned short val)
|
||||
{
|
||||
unsigned char buf[2];
|
||||
|
||||
buf[0] = (val & (unsigned)0xff00) >> 8;
|
||||
buf[1] = val & 0xff;
|
||||
return (s.Write(&buf, sizeof(buf)).LastWrite() == sizeof(buf));
|
||||
}
|
||||
|
||||
bool SimpleXauthEntry::writeString(wxOutputStream &s, unsigned short len, char *buf)
|
||||
{
|
||||
if (!writeShort(s, len))
|
||||
return false;
|
||||
if (len > 0)
|
||||
return (s.Write(buf, len).LastWrite() == len);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SimpleXauthEntry::Write(wxOutputStream &s)
|
||||
{
|
||||
if (!writeShort(s, au.family))
|
||||
return false;
|
||||
if (!writeString(s, au.address_length, au.address))
|
||||
return false;
|
||||
if (!writeString(s, au.number_length, au.number))
|
||||
return false;
|
||||
if (!writeString(s, au.name_length, au.name))
|
||||
return false;
|
||||
return writeString(s, au.data_length, au.data);
|
||||
}
|
||||
|
||||
void SimpleXauthEntry::SetUnix(wxString addr, int display)
|
||||
{
|
||||
au.family = XauthFamilyLocal;
|
||||
dpystr = wxString::Format(wxT("%d"), display);
|
||||
au.number_length = dpystr.Length();
|
||||
au.number = strdup((const char *)dpystr.mb_str());
|
||||
naddr = addr;
|
||||
if (au.address)
|
||||
delete au.address;
|
||||
au.address_length = naddr.Length();
|
||||
au.address = strdup((const char *)naddr.To8BitData());
|
||||
}
|
||||
|
||||
void SimpleXauthEntry::SetInternet(wxIPV4address addr, int display)
|
||||
{
|
||||
au.family = XauthFamilyInternet;
|
||||
dpystr = wxString::Format(wxT("%d"), display);
|
||||
au.number_length = dpystr.Length();
|
||||
au.number = strdup((const char *)dpystr.mb_str());
|
||||
iaddr = addr;
|
||||
au.address_length = 4;
|
||||
if (au.address)
|
||||
delete au.address;
|
||||
au.address = new char[4];
|
||||
if (au.address) {
|
||||
int i = 0;
|
||||
wxStringTokenizer t(iaddr.IPAddress(), wxT("."));
|
||||
while (t.HasMoreTokens() && (i < 4)) {
|
||||
unsigned long l;
|
||||
if (t.GetNextToken().ToULong(&l))
|
||||
au.address[i++] = l;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SimpleXauthEntryHash
|
||||
{
|
||||
public:
|
||||
SimpleXauthEntryHash() { }
|
||||
|
||||
unsigned long operator()(const SimpleXauthEntry & k) const
|
||||
{
|
||||
return wxStringHash::wxCharStringHash(k.GetKey());
|
||||
}
|
||||
|
||||
SimpleXauthEntryHash& operator=(const SimpleXauthEntryHash&) { return *this; }
|
||||
};
|
||||
|
||||
class SimpleXauthEntryEqual
|
||||
{
|
||||
public:
|
||||
SimpleXauthEntryEqual() { }
|
||||
|
||||
bool operator()(const SimpleXauthEntry& a, const SimpleXauthEntry& b) const
|
||||
{
|
||||
return a.GetKey().IsSameAs(b.GetKey());
|
||||
}
|
||||
|
||||
SimpleXauthEntryEqual& operator=(const SimpleXauthEntryEqual&) { return *this; }
|
||||
};
|
||||
|
||||
WX_DECLARE_HASH_SET(
|
||||
SimpleXauthEntry, SimpleXauthEntryHash, SimpleXauthEntryEqual, SimpleXauthEntrySet
|
||||
);
|
||||
|
||||
class SimpleXauthPrivate
|
||||
{
|
||||
public:
|
||||
SimpleXauthPrivate() {
|
||||
cookie = md5sum(::wxGetUserId() + wxDateTime::Now().Format());
|
||||
};
|
||||
wxString filename;
|
||||
wxString cookie;
|
||||
SimpleXauthEntrySet entries;
|
||||
};
|
||||
|
||||
SimpleXauth::SimpleXauth(wxString filename)
|
||||
{
|
||||
m_pPrivate = new SimpleXauthPrivate();
|
||||
m_pPrivate->filename = filename;
|
||||
readFile();
|
||||
}
|
||||
|
||||
SimpleXauth::~SimpleXauth()
|
||||
{
|
||||
writeFile();
|
||||
delete m_pPrivate;
|
||||
}
|
||||
|
||||
bool SimpleXauth::readFile()
|
||||
{
|
||||
wxLogNull nolog;
|
||||
wxFileInputStream s(m_pPrivate->filename);
|
||||
while (s.IsOk()) {
|
||||
SimpleXauthEntry e;
|
||||
if (!e.Read(s))
|
||||
return (m_pPrivate->entries.size() > 0);
|
||||
m_pPrivate->entries.insert(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SimpleXauth::writeFile()
|
||||
{
|
||||
wxFileOutputStream s(m_pPrivate->filename);
|
||||
if (s.IsOk()) {
|
||||
SimpleXauthEntrySet::iterator it = m_pPrivate->entries.begin();
|
||||
for (; it != m_pPrivate->entries.end(); ++it) {
|
||||
if (!it->Write(s))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
wxString SimpleXauth::GetCookie()
|
||||
{
|
||||
return m_pPrivate->cookie;
|
||||
}
|
||||
|
||||
void SimpleXauth::AddDisplay(int displayNum)
|
||||
{
|
||||
// We always add the following 3 variants (suitable
|
||||
// for both Xming and NXWin):
|
||||
// localhost:X
|
||||
// ipaddress:X
|
||||
// localname/unix:X
|
||||
|
||||
wxString host = ::wxGetFullHostName();
|
||||
wxIPV4address a;
|
||||
a.Hostname(host);
|
||||
SimpleXauthEntry e(m_pPrivate->cookie);
|
||||
e.SetInternet(a, displayNum);
|
||||
m_pPrivate->entries.insert(e);
|
||||
a.LocalHost();
|
||||
e.SetInternet(a, displayNum);
|
||||
m_pPrivate->entries.insert(e);
|
||||
e.SetUnix(host.BeforeFirst(wxT('.')), displayNum);
|
||||
m_pPrivate->entries.insert(e);
|
||||
}
|
||||
#endif
|
||||
50
SimpleXauth.h
Normal file
50
SimpleXauth.h
Normal file
@@ -0,0 +1,50 @@
|
||||
// $Id: SimpleXauth.h 494 2010-02-28 05:36:15Z felfert $
|
||||
//
|
||||
// Copyright (C) 2010 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _SimpleXauth_H_
|
||||
#define _SimpleXauth_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "SimpleXauth.cpp"
|
||||
#endif
|
||||
|
||||
// Defines canonicalized platform names (e.g. __WXMSW__)
|
||||
#include <wx/platform.h>
|
||||
|
||||
# if defined(__WXMSW__) || defined(APP_TESTXAUTH)
|
||||
class SimpleXauthPrivate;
|
||||
|
||||
class SimpleXauth
|
||||
{
|
||||
public:
|
||||
SimpleXauth(wxString filename);
|
||||
~SimpleXauth();
|
||||
void AddDisplay(int);
|
||||
wxString GetCookie();
|
||||
|
||||
private:
|
||||
bool writeFile();
|
||||
bool readFile();
|
||||
SimpleXauthPrivate *m_pPrivate;
|
||||
};
|
||||
|
||||
# endif
|
||||
#endif
|
||||
247
SupressibleMessageDialog.cpp
Normal file
247
SupressibleMessageDialog.cpp
Normal file
@@ -0,0 +1,247 @@
|
||||
// $Id: SupressibleMessageDialog.cpp 587 2010-10-21 22:35:37Z felfert $
|
||||
//
|
||||
// Copyright (C) 2010 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
||||
#pragma implementation "SupessibleMessageDialog.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#include <wx/config.h>
|
||||
////@begin includes
|
||||
////@end includes
|
||||
|
||||
#include "SupressibleMessageDialog.h"
|
||||
#include "Icon.h"
|
||||
|
||||
////@begin XPM images
|
||||
////@end XPM images
|
||||
|
||||
|
||||
/*!
|
||||
* SupressibleMessageDialog type definition
|
||||
*/
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS( SupressibleMessageDialog, wxDialog )
|
||||
|
||||
|
||||
/*!
|
||||
* SupressibleMessageDialog event table definition
|
||||
*/
|
||||
|
||||
BEGIN_EVENT_TABLE( SupressibleMessageDialog, wxDialog )
|
||||
|
||||
////@begin SupressibleMessageDialog event table entries
|
||||
////@end SupressibleMessageDialog event table entries
|
||||
|
||||
END_EVENT_TABLE()
|
||||
|
||||
int SupressibleMessageDialog::ShowConditional(const wxString &msgid, int defaultResult)
|
||||
{
|
||||
wxString cfgname(wxT("SupressedDialogs/"));
|
||||
cfgname.Append(msgid);
|
||||
bool hide = false;
|
||||
wxConfigBase::Get()->Read(cfgname, &hide, false);
|
||||
if (hide)
|
||||
return defaultResult;
|
||||
int ret = wxDialog::ShowModal();
|
||||
if ((wxID_CANCEL == ret) && (wxYES_NO == (m_lButtonStyle & (wxCANCEL|wxYES_NO)))) {
|
||||
// No cancel button: Closing dialog => defaultResult
|
||||
ret = defaultResult;
|
||||
}
|
||||
if (m_bHide)
|
||||
wxConfigBase::Get()->Write(cfgname, true);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*!
|
||||
* SupressibleMessageDialog constructors
|
||||
*/
|
||||
|
||||
SupressibleMessageDialog::SupressibleMessageDialog()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
SupressibleMessageDialog::SupressibleMessageDialog( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
||||
{
|
||||
Init();
|
||||
Create(parent, id, caption, pos, size, style);
|
||||
}
|
||||
|
||||
|
||||
SupressibleMessageDialog::SupressibleMessageDialog(wxWindow *parent, const wxString &message, const wxString &caption, long style /* = wxICON_EXCLAMATION|wxOK */)
|
||||
{
|
||||
Init();
|
||||
Create(parent, SYMBOL_SUPRESSIBLEMESSAGEDIALOG_IDNAME, caption,
|
||||
SYMBOL_SUPRESSIBLEMESSAGEDIALOG_POSITION, SYMBOL_SUPRESSIBLEMESSAGEDIALOG_SIZE,
|
||||
SYMBOL_SUPRESSIBLEMESSAGEDIALOG_STYLE);
|
||||
m_lIconStyle = style & wxICON_MASK;
|
||||
m_lButtonStyle = style & ~wxICON_MASK;
|
||||
switch (m_lIconStyle) {
|
||||
case wxICON_EXCLAMATION:
|
||||
m_pDialogIcon->SetBitmap(wxArtProvider::GetBitmap(wxART_WARNING, wxART_MESSAGE_BOX));
|
||||
break;
|
||||
case wxICON_ERROR:
|
||||
m_pDialogIcon->SetBitmap(wxArtProvider::GetBitmap(wxART_ERROR, wxART_MESSAGE_BOX));
|
||||
break;
|
||||
case wxICON_QUESTION:
|
||||
m_pDialogIcon->SetBitmap(wxArtProvider::GetBitmap(wxART_QUESTION, wxART_MESSAGE_BOX));
|
||||
break;
|
||||
case wxICON_INFORMATION:
|
||||
m_pDialogIcon->SetBitmap(wxArtProvider::GetBitmap(wxART_INFORMATION, wxART_MESSAGE_BOX));
|
||||
break;
|
||||
}
|
||||
wxSizer *sz = GetSizer();
|
||||
if (sz) {
|
||||
wxSizer *bs = CreateSeparatedButtonSizer(m_lButtonStyle);
|
||||
if (bs) {
|
||||
sz->Add(bs, wxSizerFlags().Expand().Border(wxALL, 5));
|
||||
}
|
||||
if (m_lButtonStyle & wxYES_NO) {
|
||||
// Add missing event handler for "No" button.
|
||||
Connect(XRCID("wxID_NO"), wxEVT_COMMAND_BUTTON_CLICKED,
|
||||
wxCommandEventHandler(SupressibleMessageDialog::OnNoClick));
|
||||
}
|
||||
}
|
||||
SetTitle(caption);
|
||||
m_pMessage->SetLabel(message);
|
||||
Fit();
|
||||
}
|
||||
|
||||
/*!
|
||||
* SupessibleMessageDialog creator
|
||||
*/
|
||||
|
||||
bool SupressibleMessageDialog::Create( wxWindow* parent, wxWindowID, const wxString&, const wxPoint&, const wxSize&, long)
|
||||
{
|
||||
////@begin SupressibleMessageDialog creation
|
||||
SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
|
||||
SetParent(parent);
|
||||
CreateControls();
|
||||
SetIcon(GetIconResource(wxT("res/nx.png")));
|
||||
if (GetSizer())
|
||||
{
|
||||
GetSizer()->SetSizeHints(this);
|
||||
}
|
||||
Centre();
|
||||
////@end SupressibleMessageDialog creation
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* SupressibleMessageDialog destructor
|
||||
*/
|
||||
|
||||
SupressibleMessageDialog::~SupressibleMessageDialog()
|
||||
{
|
||||
////@begin SupressibleMessageDialog destruction
|
||||
////@end SupressibleMessageDialog destruction
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* Member initialisation
|
||||
*/
|
||||
|
||||
void SupressibleMessageDialog::Init()
|
||||
{
|
||||
////@begin SupressibleMessageDialog member initialisation
|
||||
m_bHide = false;
|
||||
m_lButtonStyle = 0;
|
||||
m_lIconStyle = 0;
|
||||
m_pDialogIcon = NULL;
|
||||
m_pMessage = NULL;
|
||||
////@end SupressibleMessageDialog member initialisation
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* Control creation for SupessibleMessageDialog
|
||||
*/
|
||||
|
||||
void SupressibleMessageDialog::CreateControls()
|
||||
{
|
||||
////@begin SupressibleMessageDialog content construction
|
||||
if (!wxXmlResource::Get()->LoadDialog(this, GetParent(), _T("ID_SUPRESSIBLEMESSAGEDIALOG")))
|
||||
wxLogError(wxT("Missing wxXmlResource::Get()->Load() in OnInit()?"));
|
||||
m_pDialogIcon = XRCCTRL(*this, "wxID_STATIC", wxStaticBitmap);
|
||||
m_pMessage = XRCCTRL(*this, "wxID_DLGMESSAGE", wxStaticText);
|
||||
// Set validators
|
||||
if (FindWindow(XRCID("ID_CHECKBOX")))
|
||||
FindWindow(XRCID("ID_CHECKBOX"))->SetValidator( wxGenericValidator(& m_bHide) );
|
||||
////@end SupressibleMessageDialog content construction
|
||||
|
||||
// Create custom windows not generated automatically here.
|
||||
////@begin SupressibleMessageDialog content initialisation
|
||||
////@end SupressibleMessageDialog content initialisation
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* Should we show tooltips?
|
||||
*/
|
||||
|
||||
bool SupressibleMessageDialog::ShowToolTips()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get bitmap resources
|
||||
*/
|
||||
|
||||
wxBitmap SupressibleMessageDialog::GetBitmapResource( const wxString& name )
|
||||
{
|
||||
// Bitmap retrieval
|
||||
return CreateBitmapFromFile(name);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get icon resources
|
||||
*/
|
||||
|
||||
wxIcon SupressibleMessageDialog::GetIconResource( const wxString& name )
|
||||
{
|
||||
// Icon retrieval
|
||||
return CreateIconFromFile(name);
|
||||
}
|
||||
|
||||
|
||||
void SupressibleMessageDialog::OnNoClick( wxCommandEvent& )
|
||||
{
|
||||
EndModal(wxID_NO);
|
||||
}
|
||||
|
||||
119
SupressibleMessageDialog.h
Normal file
119
SupressibleMessageDialog.h
Normal file
@@ -0,0 +1,119 @@
|
||||
// $Id: SupressibleMessageDialog.h 587 2010-10-21 22:35:37Z felfert $
|
||||
//
|
||||
// Copyright (C) 2010 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _SUPESSIBLEMESSAGEDIALOG_H_
|
||||
#define _SUPESSIBLEMESSAGEDIALOG_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
||||
#pragma interface "SupessibleMessageDialog.h"
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* Includes
|
||||
*/
|
||||
|
||||
////@begin includes
|
||||
#include "SupressibleMessageDialog_symbols.h"
|
||||
#include "wx/xrc/xmlres.h"
|
||||
#include "wx/valgen.h"
|
||||
////@end includes
|
||||
|
||||
/*!
|
||||
* Forward declarations
|
||||
*/
|
||||
|
||||
////@begin forward declarations
|
||||
////@end forward declarations
|
||||
|
||||
/*!
|
||||
* Control identifiers
|
||||
*/
|
||||
|
||||
////@begin control identifiers
|
||||
#define ID_SUPRESSIBLEMESSAGEDIALOG 10142
|
||||
#define SYMBOL_SUPRESSIBLEMESSAGEDIALOG_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL
|
||||
#define SYMBOL_SUPRESSIBLEMESSAGEDIALOG_TITLE _("SupressibleMessageDialog")
|
||||
#define SYMBOL_SUPRESSIBLEMESSAGEDIALOG_IDNAME ID_SUPRESSIBLEMESSAGEDIALOG
|
||||
#define SYMBOL_SUPRESSIBLEMESSAGEDIALOG_SIZE wxSize(400, 300)
|
||||
#define SYMBOL_SUPRESSIBLEMESSAGEDIALOG_POSITION wxDefaultPosition
|
||||
////@end control identifiers
|
||||
|
||||
|
||||
/*!
|
||||
* SupressibleMessageDialog class declaration
|
||||
*/
|
||||
|
||||
class SupressibleMessageDialog: public wxDialog
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS( SupressibleMessageDialog )
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
public:
|
||||
/// Constructors
|
||||
SupressibleMessageDialog();
|
||||
SupressibleMessageDialog( wxWindow* parent, wxWindowID id = SYMBOL_SUPRESSIBLEMESSAGEDIALOG_IDNAME, const wxString& caption = SYMBOL_SUPRESSIBLEMESSAGEDIALOG_TITLE, const wxPoint& pos = SYMBOL_SUPRESSIBLEMESSAGEDIALOG_POSITION, const wxSize& size = SYMBOL_SUPRESSIBLEMESSAGEDIALOG_SIZE, long style = SYMBOL_SUPRESSIBLEMESSAGEDIALOG_STYLE );
|
||||
|
||||
SupressibleMessageDialog(wxWindow *parent, const wxString &message, const wxString &caption, long style = wxICON_EXCLAMATION|wxOK);
|
||||
|
||||
/// Creation
|
||||
bool Create( wxWindow* parent, wxWindowID id = SYMBOL_SUPRESSIBLEMESSAGEDIALOG_IDNAME, const wxString& caption = SYMBOL_SUPRESSIBLEMESSAGEDIALOG_TITLE, const wxPoint& pos = SYMBOL_SUPRESSIBLEMESSAGEDIALOG_POSITION, const wxSize& size = SYMBOL_SUPRESSIBLEMESSAGEDIALOG_SIZE, long style = SYMBOL_SUPRESSIBLEMESSAGEDIALOG_STYLE );
|
||||
|
||||
/// Destructor
|
||||
~SupressibleMessageDialog();
|
||||
|
||||
/// Initialises member variables
|
||||
void Init();
|
||||
|
||||
/// Creates the controls and sizers
|
||||
void CreateControls();
|
||||
|
||||
int ShowConditional(const wxString &msgid, int defaultResult);
|
||||
|
||||
void OnNoClick( wxCommandEvent& event );
|
||||
|
||||
////@begin SupressibleMessageDialog event handler declarations
|
||||
|
||||
////@end SupressibleMessageDialog event handler declarations
|
||||
|
||||
////@begin SupressibleMessageDialog member function declarations
|
||||
|
||||
/// Retrieves bitmap resources
|
||||
wxBitmap GetBitmapResource( const wxString& name );
|
||||
|
||||
/// Retrieves icon resources
|
||||
wxIcon GetIconResource( const wxString& name );
|
||||
////@end SupressibleMessageDialog member function declarations
|
||||
|
||||
/// Should we show tooltips?
|
||||
static bool ShowToolTips();
|
||||
|
||||
////@begin SupressibleMessageDialog member variables
|
||||
wxStaticBitmap* m_pDialogIcon;
|
||||
wxStaticText* m_pMessage;
|
||||
private:
|
||||
bool m_bHide;
|
||||
long m_lButtonStyle;
|
||||
long m_lIconStyle;
|
||||
////@end SupressibleMessageDialog member variables
|
||||
};
|
||||
|
||||
#endif
|
||||
// _SUPESSIBLEMESSAGEDIALOG_H_
|
||||
23
SupressibleMessageDialog_symbols.h
Normal file
23
SupressibleMessageDialog_symbols.h
Normal file
@@ -0,0 +1,23 @@
|
||||
// $Id: SupressibleMessageDialog_symbols.h 549 2010-08-20 21:38:00Z felfert $
|
||||
//
|
||||
// Copyright (C) 2010 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#define ID_SUPRESSIBLEMESSAGEDIALOG_SYMBOL_0 _("SupressibleMessageDialog")
|
||||
#define ID_SUPRESSIBLEMESSAGEDIALOG_SYMBOL_1 _("Do not show this message again")
|
||||
222
TextViewer.cpp
Normal file
222
TextViewer.cpp
Normal file
@@ -0,0 +1,222 @@
|
||||
// $Id: TextViewer.cpp 451 2010-01-27 12:24:56Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
||||
#pragma implementation "TextViewer.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#include <wx/wfstream.h>
|
||||
#include <wx/txtstrm.h>
|
||||
#include <wx/mstream.h>
|
||||
#include <wx/richtext/richtextxml.h>
|
||||
|
||||
#include "debugleak.h"
|
||||
|
||||
////@begin includes
|
||||
////@end includes
|
||||
|
||||
#include "TextViewer.h"
|
||||
#include "opennxApp.h"
|
||||
#include "Icon.h"
|
||||
|
||||
////@begin XPM images
|
||||
////@end XPM images
|
||||
|
||||
class myRichTextCtrl : public wxRichTextCtrl {
|
||||
DECLARE_DYNAMIC_CLASS(myRichTextCtrl);
|
||||
|
||||
public:
|
||||
|
||||
bool DoLoadFile(const wxString& filename, wxRichTextFileType fileType = wxRICHTEXT_TYPE_XML)
|
||||
{
|
||||
bool success = false;
|
||||
wxFileSystem fs;
|
||||
wxFSFile *f = fs.OpenFile(filename);
|
||||
if (f) {
|
||||
wxInputStream *is = f->GetStream();
|
||||
if (is->IsOk()) {
|
||||
success = GetBuffer().LoadFile(*is, (wxRichTextFileType)fileType);
|
||||
if (success)
|
||||
m_filename = filename;
|
||||
}
|
||||
}
|
||||
|
||||
DiscardEdits();
|
||||
SetInsertionPoint(0);
|
||||
LayoutContent();
|
||||
PositionCaret();
|
||||
SetupScrollbars(true);
|
||||
Refresh(false);
|
||||
SendTextUpdatedEvent();
|
||||
|
||||
if (success)
|
||||
return true;
|
||||
wxLogError(_("File couldn't be loaded."));
|
||||
return false;
|
||||
}
|
||||
};
|
||||
IMPLEMENT_DYNAMIC_CLASS(myRichTextCtrl, wxRichTextCtrl);
|
||||
|
||||
/*!
|
||||
* TextViewer type definition
|
||||
*/
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS( TextViewer, wxDialog )
|
||||
|
||||
/*!
|
||||
* TextViewer event table definition
|
||||
*/
|
||||
|
||||
BEGIN_EVENT_TABLE( TextViewer, wxDialog )
|
||||
|
||||
////@begin TextViewer event table entries
|
||||
EVT_BUTTON( wxID_CLOSE, TextViewer::OnCloseClick )
|
||||
|
||||
////@end TextViewer event table entries
|
||||
|
||||
END_EVENT_TABLE()
|
||||
|
||||
/*!
|
||||
* TextViewer constructors
|
||||
*/
|
||||
|
||||
TextViewer::TextViewer( )
|
||||
{
|
||||
}
|
||||
|
||||
TextViewer::TextViewer( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
||||
{
|
||||
Create(parent, id, caption, pos, size, style);
|
||||
}
|
||||
|
||||
/*!
|
||||
* TextViewer creator
|
||||
*/
|
||||
|
||||
bool TextViewer::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
||||
{
|
||||
////@begin TextViewer member initialisation
|
||||
m_sFileName = wxT("");
|
||||
m_pRichTextCtrl = NULL;
|
||||
////@end TextViewer member initialisation
|
||||
|
||||
////@begin TextViewer creation
|
||||
SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
|
||||
SetParent(parent);
|
||||
CreateControls();
|
||||
SetIcon(GetIconResource(wxT("res/nx.png")));
|
||||
if (GetSizer())
|
||||
{
|
||||
GetSizer()->SetSizeHints(this);
|
||||
}
|
||||
Centre();
|
||||
////@end TextViewer creation
|
||||
wxUnusedVar(style);
|
||||
wxUnusedVar(size);
|
||||
wxUnusedVar(pos);
|
||||
wxUnusedVar(caption);
|
||||
wxUnusedVar(id);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Control creation for TextViewer
|
||||
*/
|
||||
|
||||
void TextViewer::CreateControls()
|
||||
{
|
||||
////@begin TextViewer content construction
|
||||
if (!wxXmlResource::Get()->LoadDialog(this, GetParent(), _T("ID_TEXTVIEWER")))
|
||||
wxLogError(wxT("Missing wxXmlResource::Get()->Load() in OnInit()?"));
|
||||
m_pRichTextCtrl = XRCCTRL(*this, "ID_RICHTEXTCTRL", myRichTextCtrl);
|
||||
////@end TextViewer content construction
|
||||
|
||||
m_pRichTextCtrl->GetBuffer().AddHandler(new wxRichTextXMLHandler());
|
||||
m_pRichTextCtrl->SetHandlerFlags(wxRICHTEXT_HANDLER_CONVERT_FACENAMES);
|
||||
|
||||
////@begin TextViewer content initialisation
|
||||
////@end TextViewer content initialisation
|
||||
}
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CLOSE
|
||||
*/
|
||||
|
||||
void TextViewer::OnCloseClick( wxCommandEvent& event )
|
||||
{
|
||||
Destroy();
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
/*!
|
||||
* Should we show tooltips?
|
||||
*/
|
||||
|
||||
bool TextViewer::ShowToolTips()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get bitmap resources
|
||||
*/
|
||||
|
||||
wxBitmap TextViewer::GetBitmapResource( const wxString& name )
|
||||
{
|
||||
// Bitmap retrieval
|
||||
return CreateBitmapFromFile(name);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get icon resources
|
||||
*/
|
||||
|
||||
wxIcon TextViewer::GetIconResource( const wxString& name )
|
||||
{
|
||||
// Icon retrieval
|
||||
return CreateIconFromFile(name);
|
||||
}
|
||||
|
||||
bool
|
||||
TextViewer::LoadFile(const wxString &sFileName)
|
||||
{
|
||||
bool ret = false;
|
||||
m_sFileName = sFileName;
|
||||
wxFileName fn(sFileName);
|
||||
{
|
||||
wxLogNull l;
|
||||
ret = m_pRichTextCtrl->LoadFile(m_sFileName, wxRICHTEXT_TYPE_XML);
|
||||
}
|
||||
if (ret)
|
||||
SetTitle(fn.GetName());
|
||||
return ret;
|
||||
}
|
||||
118
TextViewer.h
Normal file
118
TextViewer.h
Normal file
@@ -0,0 +1,118 @@
|
||||
// $Id: TextViewer.h 186 2009-02-24 13:01:39Z felfert $
|
||||
//
|
||||
// Copyright (C) 2006 The OpenNX Team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef _TEXTVIEWER_H_
|
||||
#define _TEXTVIEWER_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
||||
#pragma interface "TextViewer.h"
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* Includes
|
||||
*/
|
||||
|
||||
////@begin includes
|
||||
#include "TextViewer_symbols.h"
|
||||
#include "wx/xrc/xmlres.h"
|
||||
#include "wx/richtext/richtextctrl.h"
|
||||
#include "wx/statline.h"
|
||||
////@end includes
|
||||
|
||||
/*!
|
||||
* Forward declarations
|
||||
*/
|
||||
|
||||
////@begin forward declarations
|
||||
class myRichTextCtrl;
|
||||
////@end forward declarations
|
||||
|
||||
/*!
|
||||
* Control identifiers
|
||||
*/
|
||||
|
||||
////@begin control identifiers
|
||||
#define ID_TEXTVIEWER 10020
|
||||
#define SYMBOL_TEXTVIEWER_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxDIALOG_NO_PARENT|wxCLOSE_BOX|wxMAXIMIZE_BOX|wxMINIMIZE_BOX
|
||||
#define SYMBOL_TEXTVIEWER_TITLE _("Text Viewer - OpenNX")
|
||||
#define SYMBOL_TEXTVIEWER_IDNAME ID_TEXTVIEWER
|
||||
#define SYMBOL_TEXTVIEWER_SIZE wxDefaultSize
|
||||
#define SYMBOL_TEXTVIEWER_POSITION wxDefaultPosition
|
||||
////@end control identifiers
|
||||
|
||||
/*!
|
||||
* Compatibility
|
||||
*/
|
||||
|
||||
#ifndef wxCLOSE_BOX
|
||||
#define wxCLOSE_BOX 0x1000
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* TextViewer class declaration
|
||||
*/
|
||||
|
||||
class TextViewer: public wxDialog
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS( TextViewer )
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
public:
|
||||
/// Constructors
|
||||
TextViewer( );
|
||||
TextViewer( wxWindow* parent, wxWindowID id = SYMBOL_TEXTVIEWER_IDNAME, const wxString& caption = SYMBOL_TEXTVIEWER_TITLE, const wxPoint& pos = SYMBOL_TEXTVIEWER_POSITION, const wxSize& size = SYMBOL_TEXTVIEWER_SIZE, long style = SYMBOL_TEXTVIEWER_STYLE );
|
||||
|
||||
/// Creation
|
||||
bool Create( wxWindow* parent, wxWindowID id = SYMBOL_TEXTVIEWER_IDNAME, const wxString& caption = SYMBOL_TEXTVIEWER_TITLE, const wxPoint& pos = SYMBOL_TEXTVIEWER_POSITION, const wxSize& size = SYMBOL_TEXTVIEWER_SIZE, long style = SYMBOL_TEXTVIEWER_STYLE );
|
||||
|
||||
/// Creates the controls and sizers
|
||||
void CreateControls();
|
||||
|
||||
bool LoadFile(const wxString &file);
|
||||
|
||||
private:
|
||||
////@begin TextViewer event handler declarations
|
||||
|
||||
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CLOSE
|
||||
void OnCloseClick( wxCommandEvent& event );
|
||||
|
||||
////@end TextViewer event handler declarations
|
||||
|
||||
////@begin TextViewer member function declarations
|
||||
|
||||
/// Retrieves bitmap resources
|
||||
wxBitmap GetBitmapResource( const wxString& name );
|
||||
|
||||
/// Retrieves icon resources
|
||||
wxIcon GetIconResource( const wxString& name );
|
||||
////@end TextViewer member function declarations
|
||||
|
||||
/// Should we show tooltips?
|
||||
static bool ShowToolTips();
|
||||
|
||||
////@begin TextViewer member variables
|
||||
myRichTextCtrl* m_pRichTextCtrl;
|
||||
wxString m_sFileName;
|
||||
////@end TextViewer member variables
|
||||
};
|
||||
|
||||
#endif
|
||||
// _TEXTVIEWER_H_
|
||||
23
TextViewer_symbols.h
Normal file
23
TextViewer_symbols.h
Normal file
@@ -0,0 +1,23 @@
|
||||
// $Id: TextViewer_symbols.h 186 2009-02-24 13:01:39Z felfert $
|
||||
//
|
||||
// Copyright (C) 2009 The OpenNX team
|
||||
// Author: Fritz Elfert
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc.,
|
||||
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#define ID_TEXTVIEWER_SYMBOL_0 _("Text Viewer - OpenNX")
|
||||
#define ID_TEXTVIEWER_SYMBOL_1 _("&Close")
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user