OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [host/] [tools/] [configtool/] [standalone/] [wxwin/] [admindlg.cpp] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
// ####ECOSHOSTGPLCOPYRIGHTBEGIN####                                        
2
// -------------------------------------------                              
3
// This file is part of the eCos host tools.                                
4
// Copyright (C) 1998, 1999, 2000, 2003 Free Software Foundation, Inc.      
5
//
6
// This program is free software; you can redistribute it and/or modify     
7
// it under the terms of the GNU General Public License as published by     
8
// the Free Software Foundation; either version 2 or (at your option) any   
9
// later version.                                                           
10
//
11
// This program is distributed in the hope that it will be useful, but      
12
// WITHOUT ANY WARRANTY; without even the implied warranty of               
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU        
14
// General Public License for more details.                                 
15
//
16
// You should have received a copy of the GNU General Public License        
17
// along with this program; if not, write to the                            
18
// Free Software Foundation, Inc., 51 Franklin Street,                      
19
// Fifth Floor, Boston, MA  02110-1301, USA.                                
20
// -------------------------------------------                              
21
// ####ECOSHOSTGPLCOPYRIGHTEND####                                          
22
// admindlg.cpp :
23
//
24
//===========================================================================
25
//#####DESCRIPTIONBEGIN####
26
//
27
// Author(s):   julians,jld
28
// Contact(s):  julians
29
// Date:        2000/09/28
30
// Version:     $Id: admindlg.cpp,v 1.6 2001/08/22 16:50:32 julians Exp $
31
// Purpose:
32
// Description: Implementation file for ecAdminDialog
33
// Requires:
34
// Provides:
35
// See also:
36
// Known bugs:
37
// Usage:
38
//
39
//####DESCRIPTIONEND####
40
//
41
//===========================================================================
42
 
43
// ============================================================================
44
// declarations
45
// ============================================================================
46
 
47
// ----------------------------------------------------------------------------
48
// headers
49
// ----------------------------------------------------------------------------
50
#ifdef __GNUG__
51
#pragma implementation "admindlg.h"
52
#endif
53
 
54
// Includes other headers for precompiled compilation
55
#include "ecpch.h"
56
 
57
#ifdef __BORLANDC__
58
#pragma hdrstop
59
#endif
60
 
61
// For registry access functions in GetUserToolsPath
62
#ifdef __WXMSW__
63
#include <windows.h>
64
#include "wx/msw/winundef.h"
65
#endif
66
 
67
#include "wx/cshelp.h"
68
#include "wx/filedlg.h"
69
#include "wx/file.h"
70
#include "wx/filefn.h"
71
#include "wx/progdlg.h"
72
 
73
#include "configtool.h"
74
#include "admindlg.h"
75
#include "configtooldoc.h"
76
#include "licensedlg.h"
77
#include "ecutils.h"
78
 
79
#ifdef __WXGTK__
80
#include "bitmaps/package_open.xpm"
81
#include "bitmaps/package_version.xpm"
82
#endif
83
 
84
BEGIN_EVENT_TABLE(ecAdminDialog, ecDialog)
85
    EVT_BUTTON(wxID_OK, ecAdminDialog::OnClose)
86
    EVT_BUTTON(ecID_ADMIN_DIALOG_ADD, ecAdminDialog::OnAdd)
87
    EVT_BUTTON(ecID_ADMIN_DIALOG_REMOVE, ecAdminDialog::OnRemove)
88
    EVT_INIT_DIALOG(ecAdminDialog::OnInitDialog)
89
END_EVENT_TABLE()
90
 
91
// ----------------------------------------------------------------------------
92
// main frame
93
// ----------------------------------------------------------------------------
94
 
95
// Frame constructor
96
ecAdminDialog::ecAdminDialog(wxWindow* parent, const wxString& repository, const wxString& userTools):
97
    m_imageList(16, 16, 1)
98
{
99
    m_strRepository = repository;
100
    m_strUserTools = userTools;
101
        m_CdlPkgData = NULL;
102
 
103
    SetExtraStyle(wxDIALOG_EX_CONTEXTHELP);
104
 
105
    ecDialog::Create(parent, ecID_ADMIN_DIALOG, _("Administration"),
106
        wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER);
107
 
108
    CreateControls(this);
109
 
110
    m_imageList.Add(wxICON(package_open));
111
    m_imageList.Add(wxICON(package_version));
112
    m_treeCtrl->SetImageList(& m_imageList);
113
 
114
    Centre(wxBOTH);
115
}
116
 
117
ecAdminDialog::~ecAdminDialog()
118
{
119
        ClearPackageTree ();
120
 
121
        // free memory allocated to the CDL database
122
 
123
        if (m_CdlPkgData)
124
                delete m_CdlPkgData;
125
 
126
    m_treeCtrl->SetImageList(NULL);
127
}
128
 
129
void ecAdminDialog::OnInitDialog(wxInitDialogEvent& event)
130
{
131
    // setup the path to the user tools (tar and gunzip)
132
 
133
    if ((! m_strUserTools.IsEmpty()) || FindUserToolsPath ()) // if the user tools can be located
134
    {
135
        wxString path;
136
        wxGetEnv(wxT("PATH"), & path);
137
 
138
        // TODO: this may not work on all platforms
139
        path = path + wxString(wxPATH_SEP) + m_strUserTools;
140
        wxSetEnv(wxT("PATH"), path);
141
    }
142
 
143
    // populate the package tree
144
 
145
    if (!PopulatePackageTree (m_strRepository))
146
    {
147
        m_strRepository = wxT("");
148
        // TODO
149
        // OnPkgadminRepository (); // prompt the user for the repository location
150
    }
151
}
152
 
153
void ecAdminDialog::CreateControls(wxWindow* parent)
154
{
155
    m_treeCtrl = new wxTreeCtrl(parent, ecID_ADMIN_DIALOG_TREE,
156
        wxDefaultPosition, wxSize(380, 290), wxTR_HAS_BUTTONS | wxSUNKEN_BORDER);
157
 
158
    wxSizer *item0 = new wxBoxSizer( wxHORIZONTAL );
159
 
160
    wxSizer *item1 = new wxBoxSizer( wxVERTICAL );
161
 
162
    wxStaticText *item2 = new wxStaticText( parent, wxID_STATIC, _("&Installed packages:"), wxDefaultPosition, wxDefaultSize, 0 );
163
    item1->Add( item2, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
164
 
165
    wxWindow *item3 = parent->FindWindow( ecID_ADMIN_DIALOG_TREE );
166
    wxASSERT( item3 );
167
    item1->Add( item3, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
168
 
169
    item0->Add( item1, 1, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
170
 
171
    wxSizer *item4 = new wxBoxSizer( wxVERTICAL );
172
 
173
    wxButton *item5 = new wxButton( parent, ecID_ADMIN_DIALOG_ADD, _("&Add..."), wxDefaultPosition, wxDefaultSize, 0 );
174
    item4->Add( item5, 0, wxALIGN_CENTRE|wxALL, 5 );
175
 
176
    wxButton *item6 = new wxButton( parent, ecID_ADMIN_DIALOG_REMOVE, _("&Remove"), wxDefaultPosition, wxDefaultSize, 0 );
177
    item4->Add( item6, 0, wxALIGN_CENTRE|wxALL, 5 );
178
 
179
    item4->Add( 20, 20, 1, wxALIGN_CENTRE|wxALL, 5 );
180
 
181
    wxButton *item7 = new wxButton( parent, wxID_OK, _("&Close"), wxDefaultPosition, wxDefaultSize, 0 );
182
    item4->Add( item7, 0, wxALIGN_CENTRE|wxALL, 5 );
183
 
184
#ifdef __WXGTK__
185
    wxButton *contextButton = new wxContextHelpButton( parent );
186
    item4->Add( contextButton, 0, wxALIGN_CENTRE|wxALL, 5 );
187
#endif
188
 
189
    item0->Add( item4, 0, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxTOP|wxBOTTOM, 5 );
190
 
191
    item7->SetDefault(); // Make Close the default button
192
 
193
    parent->SetAutoLayout( TRUE );
194
    parent->SetSizer( item0 );
195
    parent->Layout();
196
    item0->Fit( parent );
197
    //item0->SetSizeHints( parent );
198
 
199
    // Add context-sensitive help text
200
    parent->FindWindow( ecID_ADMIN_DIALOG_TREE)->SetHelpText(_("Displays the set of packages currently in the eCos component repository."));
201
    parent->FindWindow( ecID_ADMIN_DIALOG_ADD)->SetHelpText(_("Adds the contents of an eCos package file to the eCos component repository."));
202
    parent->FindWindow( ecID_ADMIN_DIALOG_REMOVE)->SetHelpText(_("Removes the currently selected package from the eCos component repository."));
203
    parent->FindWindow( wxID_OK )->SetHelpText(_("Closes the dialog and saves any changes you have made."));
204
 
205
#if __WXGTK__
206
    parent->FindWindow( wxID_CONTEXT_HELP )->SetHelpText(_("Invokes context-sensitive help for the clicked-on window."));
207
#endif
208
 
209
}
210
 
211
void ecAdminDialog::OnAdd(wxCommandEvent& event)
212
{
213
    wxString defaultDir; // TODO
214
    wxString defaultFile;
215
    wxString wildcard = wxT("eCos Package Files (*.epk)|*.epk");
216
    wxFileDialog dlg(this, _("Open eCos Package Files"), defaultDir, defaultFile, wildcard, wxOPEN|wxMULTIPLE);
217
 
218
    if (wxID_OK == dlg.ShowModal ())
219
    {
220
        bool bRepositoryChanged = FALSE;
221
        //POSITION posPathName = dlg.GetStartPosition ();
222
        wxArrayString filenames;
223
        dlg.GetPaths(filenames);
224
        size_t i;
225
        for (i = (size_t) 0; i < filenames.GetCount(); i++)
226
        {
227
            wxString strPathName(filenames[i]);
228
 
229
            if (!wxFileExists(strPathName))
230
            {
231
                wxString msg;
232
                msg.Printf(_("Cannot open %s"), (const wxChar*) strPathName);
233
                wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK);
234
            }
235
            else
236
            {
237
 
238
                // get an eCos package distribution file
239
 
240
                // extract the licence file
241
 
242
                wxString strCommand;
243
                strCommand.Printf(wxT("add %s --extract_license"), (const wxChar*) strPathName);
244
                strCommand.Replace(wxT("\\"), wxT("/")); // backslashes -> forward slashes for Tcl_EvalFile
245
                EvalTclFile (3, strCommand, _("Adding package"));
246
 
247
                wxString strLicenseFile = m_strRepository + wxString(wxFILE_SEP_PATH) + wxT("pkgadd.txt");
248
#ifdef __WXMSW__
249
                strLicenseFile.Replace (wxT("/"), wxT("\\")); // forward slashes -> backslashes for Win32
250
#endif
251
                // read the license file
252
 
253
                wxFile fileLicenseFile;
254
                if (fileLicenseFile.Exists (strLicenseFile) && fileLicenseFile.Open (strLicenseFile, wxFile::read))
255
                {
256
                    //TRACE (_T("License file found at %s\n"), strLicenseFile);
257
                    const off_t dwLicenseLength = fileLicenseFile.Length ();
258
                    char* pszBuffer = new char [dwLicenseLength + 1]; // allocate a buffer
259
                    fileLicenseFile.Read ((void*) pszBuffer, dwLicenseLength);
260
                    fileLicenseFile.Close ();
261
                    wxRemoveFile (strLicenseFile); // delete the license file when read
262
                    pszBuffer [dwLicenseLength] = 0; // terminate the string in the buffer
263
                    wxString strLicenseText (pszBuffer); // copy into a wxString to convert to Unicode
264
                    delete [] pszBuffer;
265
#ifdef __WXMSW__
266
                    if (-1 == strLicenseText.Find (wxT("\r\n"))) // if the file has LF line endings...
267
                        strLicenseText.Replace (_T("\n"), _T("\r\n")); // ... replace with CRLF line endings
268
#else
269
                    strLicenseText.Replace (_T("\r"), wxEmptyString); // remove CR characters
270
#endif
271
                    // display the license text
272
 
273
                    ecLicenseDialog dlgLicense (strLicenseText, this, ecID_LICENSE_DIALOG, strPathName + _(" - Add Packages"));
274
                    if (wxID_OK != dlgLicense.ShowModal ()) // if license not accepted by user
275
                        continue; // try the next file
276
                }
277
 
278
                // add the contents of the package distribution file
279
 
280
                strCommand.Printf (wxT("add %s --accept_license"), (const wxChar*) strPathName);
281
                strCommand.Replace (wxT("\\"), wxT("/")); // backslashes -> forward slashes for Tcl_EvalFile
282
                if (! EvalTclFile (3, strCommand, _("Adding package")))  // if not successful
283
                {
284
                    // try the next file
285
                }
286
                else
287
                {
288
                    bRepositoryChanged = TRUE;
289
                }
290
            }
291
        }
292
 
293
        // refresh the package tree only if necessary
294
 
295
        if (bRepositoryChanged && ! PopulatePackageTree (m_strRepository))
296
        {
297
        }
298
    }
299
}
300
 
301
void ecAdminDialog::OnRemove(wxCommandEvent& event)
302
{
303
    wxTreeCtrl* treeCtrl = (wxTreeCtrl*) FindWindow( ecID_ADMIN_DIALOG_TREE) ;
304
 
305
    const wxTreeItemId hTreeItem = treeCtrl->GetSelection ();
306
    if (! hTreeItem || !hTreeItem.IsOk())
307
        return;
308
 
309
    if (wxYES != wxMessageBox (_("The selected package will be deleted from the repository. Core eCos packages may be restored only by reinstalling eCos.\n\nDo you wish to continue?"),
310
        _("Remove Package"), wxYES_NO | wxICON_EXCLAMATION))
311
        return;
312
 
313
    ecAdminItemData* data = (ecAdminItemData*) treeCtrl->GetItemData (hTreeItem);
314
 
315
    if (data) // if a package node is selected
316
    {
317
        // remove all package version nodes
318
 
319
        wxString pstrPackage(data->m_string);
320
 
321
        bool bStatus = TRUE;
322
#if wxCHECK_VERSION(2, 6, 0)
323
                wxTreeItemIdValue cookie;
324
#else
325
        long cookie;
326
#endif
327
 
328
        wxTreeItemId hChildItem = treeCtrl->GetFirstChild (hTreeItem, cookie);
329
        while (hChildItem && bStatus)
330
        {
331
            const wxTreeItemId hNextChildItem = treeCtrl->GetNextSibling (hChildItem);
332
            bStatus = RemovePackageVersion (hChildItem);
333
            hChildItem = hNextChildItem;
334
        }
335
 
336
        // remove the package node
337
 
338
        if (bStatus)
339
        {
340
            treeCtrl->Delete (hTreeItem);
341
        }
342
    }
343
    else // a version node is selected
344
    {
345
        // remove the version node
346
 
347
        const wxTreeItemId hParentItem = treeCtrl->GetItemParent (hTreeItem);
348
        wxASSERT (hParentItem && hParentItem.IsOk() );
349
        if (RemovePackageVersion (hTreeItem) && ! treeCtrl->ItemHasChildren (hParentItem)) // if the only version was deleted
350
        {
351
            // remove the package node
352
 
353
            treeCtrl->Delete (hParentItem);
354
        }
355
    }
356
}
357
 
358
void ecAdminDialog::OnClose(wxCommandEvent& event)
359
{
360
    event.Skip();
361
}
362
 
363
bool ecAdminDialog::FindUserToolsPath()
364
{
365
#ifdef __WXMSW__
366
    HKEY hKey;
367
    if (ERROR_SUCCESS != RegOpenKeyEx (HKEY_CURRENT_USER, _T("Software\\eCos Configuration Tool\\Paths\\UserToolsDir"), 0, KEY_READ, &hKey))
368
        return FALSE;
369
 
370
    TCHAR szBuffer [MAX_PATH + 1];
371
    DWORD dwBufferLength = MAX_PATH + 1;
372
    LONG lStatus = RegQueryValueEx (hKey, _T("Folder"), NULL, NULL, (LPBYTE) szBuffer, &dwBufferLength);
373
    RegCloseKey (hKey);
374
    if (ERROR_SUCCESS != lStatus)
375
        return FALSE;
376
 
377
    m_strUserTools = szBuffer;
378
    // TRACE (_T("User tools found at %s\n"), m_strUserTools);
379
    return ! m_strUserTools.IsEmpty ();
380
#else
381
    // wxMessageBox("Sorry, ecAdminDialog::FindUserToolsPath not implemented for this platform.");
382
    return FALSE;
383
#endif
384
}
385
 
386
bool ecAdminDialog::RemovePackageVersion (wxTreeItemId hTreeItem)
387
{
388
    wxTreeCtrl* treeCtrl = (wxTreeCtrl*) FindWindow( ecID_ADMIN_DIALOG_TREE) ;
389
 
390
    const wxTreeItemId hParentItem = treeCtrl->GetItemParent (hTreeItem);
391
    wxASSERT (hParentItem);
392
 
393
    ecAdminItemData* data = (ecAdminItemData*) treeCtrl->GetItemData (hParentItem);
394
 
395
    wxASSERT( data );
396
 
397
    if (!data)
398
        return FALSE;
399
 
400
    wxString pstrPackage = data->m_string ;
401
 
402
    wxString strCommand;
403
    wxString itemText(treeCtrl->GetItemText (hTreeItem));
404
    strCommand.Printf (wxT("remove %s --version %s"), (const wxChar*) pstrPackage, (const wxChar*) itemText);
405
    if (! EvalTclFile (3, strCommand, wxT("Removing package"))) // if not successful
406
        return false;
407
 
408
    treeCtrl->Delete (hTreeItem); // remove the selected item from the tree
409
 
410
    return TRUE;
411
}
412
 
413
void ecAdminDialog::ClearPackageTree ()
414
{
415
    wxTreeCtrl* treeCtrl = (wxTreeCtrl*) FindWindow( ecID_ADMIN_DIALOG_TREE) ;
416
 
417
    wxTreeItemId hPackage = treeCtrl->GetRootItem ();
418
    if (! hPackage.IsOk()) // if no packages in the tree...
419
        return;     // ...nothing to do
420
 
421
    while (hPackage.IsOk())
422
    {
423
        const wxTreeItemId hNextPackage = treeCtrl->GetNextSibling(hPackage);
424
        treeCtrl->Delete (hPackage);
425
        hPackage = hNextPackage;
426
    }
427
}
428
 
429
// Trivial handlers; otherwise CdlPackagesDatabaseBody::make asserts.
430
static void CdlErrorHandler (std::string message)
431
{
432
};
433
 
434
static void CdlWarningHandler (std::string message)
435
{
436
};
437
 
438
 
439
bool ecAdminDialog::PopulatePackageTree (const wxString& packageDatabase)
440
{
441
    wxTreeCtrl* treeCtrl = (wxTreeCtrl*) FindWindow( ecID_ADMIN_DIALOG_TREE) ;
442
 
443
    // delete any existing CDL database
444
 
445
    if (m_CdlPkgData)
446
    {
447
        delete m_CdlPkgData;
448
        m_CdlPkgData = NULL;
449
    }
450
 
451
    // load the package database
452
 
453
    try
454
    {
455
        // Cdl asserts unless the handlers are present.
456
        m_CdlPkgData = CdlPackagesDatabaseBody::make (ecUtils::UnicodeToStdStr (ecUtils::NativeToPosixPath (packageDatabase)), &CdlErrorHandler, &CdlWarningHandler);
457
    }
458
    catch (CdlStringException exception)
459
    {
460
        wxString strMessage;
461
        strMessage.Printf (_("Error loading database:\n\n%s"), (const wxChar*) wxString (exception.get_message ().c_str ()));
462
        wxMessageBox(strMessage, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK);
463
        return FALSE;
464
    }
465
    catch (...)
466
    {
467
        wxMessageBox(_("Error loading database"), (const wxChar*) wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK);
468
        return FALSE;
469
    }
470
 
471
    // clear the old package tree
472
 
473
    ClearPackageTree ();
474
 
475
    // Add a root item
476
    wxTreeItemId rootId = m_treeCtrl->AddRoot(_("Packages"), 0, -1);
477
 
478
    // populate the new package tree
479
 
480
    const std::vector<std::string>& packages = m_CdlPkgData->get_packages ();
481
    for (std::vector<std::string>::const_iterator package = packages.begin (); package != packages.end (); package++)
482
    {
483
        // add a package node
484
 
485
        wxTreeItemId hPackage = treeCtrl->AppendItem (treeCtrl->GetRootItem(), wxString (m_CdlPkgData->get_package_aliases (*package) [0].c_str ()));
486
        treeCtrl->SetItemData (hPackage, new ecAdminItemData(wxString (package->c_str ())));
487
        treeCtrl->SetItemImage (hPackage, 0, wxTreeItemIcon_Normal);
488
        treeCtrl->SetItemImage (hPackage, 0, wxTreeItemIcon_Selected);
489
        treeCtrl->SetItemImage (hPackage, 0, wxTreeItemIcon_Expanded);
490
        treeCtrl->SetItemImage (hPackage, 0, wxTreeItemIcon_SelectedExpanded);
491
 
492
        const std::vector<std::string>& versions = m_CdlPkgData->get_package_versions (* package);
493
        for (std::vector<std::string>::const_iterator version = versions.begin (); version != versions.end (); version++)
494
        {
495
            // add a version node
496
            const wxTreeItemId hVersion = treeCtrl->AppendItem ( hPackage, wxString (version->c_str ()));
497
            treeCtrl->SetItemImage (hVersion, 1, wxTreeItemIcon_Normal);
498
            treeCtrl->SetItemImage (hVersion, 1, wxTreeItemIcon_Selected);
499
            treeCtrl->SetItemImage (hVersion, 1, wxTreeItemIcon_Expanded);
500
            treeCtrl->SetItemImage (hVersion, 1, wxTreeItemIcon_SelectedExpanded);
501
        }
502
        treeCtrl->SortChildren (hPackage); // sort the version nodes
503
    }
504
 
505
    treeCtrl->SortChildren (treeCtrl->GetRootItem()); // sort the package nodes
506
    treeCtrl->Expand(treeCtrl->GetRootItem());
507
 
508
    return TRUE;
509
}
510
 
511
 
512
bool ecAdminDialog::EvalTclFile(int nargc, const wxString& Argv, const wxString& msg)
513
{
514
    wxProgressDialog dlgWait(msg, _("Please wait..."), 100, this);
515
 
516
    dlgWait.Update(50);
517
 
518
//TRACE (_T("Evaluating ecosadmin.tcl %s\n"), pszArgv);
519
 
520
    // set up the data structure which is passed to the Tcl thread
521
 
522
    wxString strArgc;
523
    strArgc.Printf (wxT("%d"), nargc);
524
    std::string argv0 = ecUtils::UnicodeToStdStr (m_strRepository) + "/ecosadmin.tcl";
525
    std::string argv = ecUtils::UnicodeToStdStr (Argv);
526
    std::string argc = ecUtils::UnicodeToStdStr (strArgc);
527
 
528
    Tcl_Interp * interp = Tcl_CreateInterp ();
529
 
530
#ifdef __WXMSW__
531
    Tcl_Channel outchan = Tcl_OpenFileChannel (interp, "nul", "a+", 777);
532
    Tcl_SetStdChannel (outchan, TCL_STDOUT); // direct standard output to NUL:
533
#endif
534
 
535
    const char * pszStatus = Tcl_SetVar (interp, "argv0", (char*) argv0.c_str(), 0);
536
    pszStatus = Tcl_SetVar (interp, "argv", (char*) argv.c_str(), 0);
537
    pszStatus = Tcl_SetVar (interp, "argc", (char*) argc.c_str(), 0);
538
    pszStatus = Tcl_SetVar (interp, "gui_mode", "1", 0); // return errors in result string
539
    int nStatus = Tcl_EvalFile (interp, (char*) argv0.c_str());
540
    const char* result = Tcl_GetStringResult (interp);
541
 
542
#ifdef __WXMSW__
543
    Tcl_SetStdChannel (NULL, TCL_STDOUT);
544
    Tcl_UnregisterChannel (interp, outchan);
545
#endif
546
 
547
    Tcl_DeleteInterp (interp);
548
 
549
    wxString strErrorMessage (result);
550
 
551
    // report any error
552
    if (! strErrorMessage.IsEmpty ())
553
    {
554
        wxString msg (_("Command execution error:\n\n") + strErrorMessage);
555
        wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK);
556
        return FALSE;
557
    }
558
    else if (TCL_OK != nStatus)
559
    {
560
        wxString msg (_("Command execution error"));
561
        wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK);
562
    return FALSE;
563
    }
564
 
565
    return TRUE;
566
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.