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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [host/] [tools/] [pkgadmin/] [win32/] [PkgAdminDlg.cpp] - Blame information for rev 790

Go to most recent revision | 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 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
// PkgAdminDlg.cpp : implementation file
23
//
24
 
25
#include "stdafx.h"
26
 
27
#include "PkgAdmin.h"
28
#include "PkgAdminDlg.h"
29
#include "PkgAdminLicenseDlg.h"
30
#include "PkgAdminTclWaitDlg.h"
31
 
32
#ifdef _DEBUG
33
#define new DEBUG_NEW
34
#undef THIS_FILE
35
static char THIS_FILE[] = __FILE__;
36
#endif
37
 
38
/////////////////////////////////////////////////////////////////////////////
39
// CPkgadminAboutDlg dialog used for App About
40
 
41
class CPkgadminAboutDlg : public CDialog
42
{
43
public:
44
        CPkgadminAboutDlg();
45
 
46
// Dialog Data
47
        //{{AFX_DATA(CPkgadminAboutDlg)
48
        enum { IDD = IDD_PKGADMIN_ABOUTBOX };
49
        //}}AFX_DATA
50
 
51
        // ClassWizard generated virtual function overrides
52
        //{{AFX_VIRTUAL(CPkgadminAboutDlg)
53
        protected:
54
        virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
55
        //}}AFX_VIRTUAL
56
 
57
// Implementation
58
protected:
59
        //{{AFX_MSG(CPkgadminAboutDlg)
60
        //}}AFX_MSG
61
        DECLARE_MESSAGE_MAP()
62
};
63
 
64
CPkgadminAboutDlg::CPkgadminAboutDlg() : CDialog(CPkgadminAboutDlg::IDD)
65
{
66
        //{{AFX_DATA_INIT(CPkgadminAboutDlg)
67
        //}}AFX_DATA_INIT
68
}
69
 
70
void CPkgadminAboutDlg::DoDataExchange(CDataExchange* pDX)
71
{
72
        CDialog::DoDataExchange(pDX);
73
        //{{AFX_DATA_MAP(CPkgadminAboutDlg)
74
        //}}AFX_DATA_MAP
75
}
76
 
77
BEGIN_MESSAGE_MAP(CPkgadminAboutDlg, CDialog)
78
        //{{AFX_MSG_MAP(CPkgadminAboutDlg)
79
                // No message handlers
80
        //}}AFX_MSG_MAP
81
END_MESSAGE_MAP()
82
 
83
/////////////////////////////////////////////////////////////////////////////
84
// CPkgAdminDlg dialog
85
 
86
CPkgAdminDlg::CPkgAdminDlg(LPCTSTR pszRepository,LPCTSTR pszUserTools)
87
        : CeCosDialog(CPkgAdminDlg::IDD, NULL)
88
{
89
        //{{AFX_DATA_INIT(CPkgAdminDlg)
90
                // NOTE: the ClassWizard will add member initialization here
91
        //}}AFX_DATA_INIT
92
        // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
93
  if(pszRepository){
94
          m_strRepository=pszRepository;
95
  }
96
  if(pszUserTools){
97
          m_strUserTools=pszUserTools;
98
  }
99
        m_CdlPkgData = NULL;
100
}
101
 
102
void CPkgAdminDlg::DoDataExchange(CDataExchange* pDX)
103
{
104
        CeCosDialog::DoDataExchange(pDX);
105
        //{{AFX_DATA_MAP(CPkgAdminDlg)
106
        DDX_Control(pDX, IDC_PKGADMIN_REMOVE, m_btnRemove);
107
        DDX_Control(pDX, IDC_PKGADMIN_TREE, m_ctrlPackageTree);
108
        //}}AFX_DATA_MAP
109
}
110
 
111
BEGIN_MESSAGE_MAP(CPkgAdminDlg, CeCosDialog)
112
        //{{AFX_MSG_MAP(CPkgAdminDlg)
113
        ON_WM_SYSCOMMAND()
114
        ON_WM_PAINT()
115
        ON_WM_QUERYDRAGICON()
116
        ON_BN_CLICKED(IDC_PKGADMIN_REMOVE, OnPkgadminRemove)
117
        ON_WM_DESTROY()
118
        ON_BN_CLICKED(IDC_PKGADMIN_ADD, OnPkgadminAdd)
119
        ON_BN_CLICKED(IDCLOSE, OnClose)
120
        ON_BN_CLICKED(IDC_PKGADMIN_REPOSITORY, OnPkgadminRepository)
121
        ON_NOTIFY(TVN_SELCHANGED, IDC_PKGADMIN_TREE, OnSelchangedPkgadminTree)
122
        //}}AFX_MSG_MAP
123
END_MESSAGE_MAP()
124
 
125
/////////////////////////////////////////////////////////////////////////////
126
// CPkgAdminDlg message handlers
127
 
128
BOOL CPkgAdminDlg::OnInitDialog()
129
{
130
        CeCosDialog::OnInitDialog();
131
 
132
  if(this==AfxGetApp()->m_pMainWnd){ // only if the dialog is the application
133
          // Add "About..." menu item to system menu.
134
 
135
          // IDM_ABOUTBOX must be in the system command range.
136
          ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
137
          ASSERT(IDM_ABOUTBOX < 0xF000);
138
 
139
          CMenu* pSysMenu = GetSystemMenu(FALSE);
140
          if (pSysMenu != NULL)
141
          {
142
                  CString strAboutMenu;
143
                  strAboutMenu.LoadString(IDS_ABOUTBOX);
144
                  if (!strAboutMenu.IsEmpty())
145
                  {
146
                          pSysMenu->AppendMenu(MF_SEPARATOR);
147
                          pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
148
                  }
149
          }
150
 
151
        // Set the icon for this dialog.  The framework does this automatically
152
        //  when the application's main window is not a dialog
153
          SetIcon(m_hIcon, TRUE);                       // Set big icon
154
 
155
  // The following AppWizard-generated call was causing the 32x32 icon to
156
        //  be resized for use as a 16x16 icon. Removing the call causes the
157
        //  correct 16x16 icon to be displayed.
158
//      SetIcon(m_hIcon, FALSE);                // Set small icon
159
 
160
        // TODO: Add extra initialization here
161
 
162
        // setup the repsoitory location
163
 
164
          if (m_strRepository.IsEmpty()) // if the repository cannot be located
165
          {
166
                  OnPkgadminRepository (); // prompt the user for the repository location
167
                  if (m_strRepository.IsEmpty ())
168
                  {
169
                          PostMessage (WM_COMMAND,IDCANCEL);
170
                          return TRUE;
171
                  }
172
          }
173
  } else {
174
    GetDlgItem(IDC_PKGADMIN_REPOSITORY)->ShowWindow(SW_HIDE);
175
  }
176
 
177
        // setup the path to the user tools (tar and gunzip)
178
 
179
        if ((! m_strUserTools.IsEmpty()) || FindUserToolsPath ()) // if the user tools can be located
180
        {
181
                // add the user tools to the PATH environment variable
182
                const DWORD nLength = GetEnvironmentVariable (_T("PATH"), NULL, 0) + 1;
183
                TCHAR * pszOldPath  = new TCHAR [nLength];
184
                GetEnvironmentVariable (_T("PATH"), pszOldPath, nLength);
185
                SetEnvironmentVariable (_T("PATH"), CString (pszOldPath) + _T(";") + m_strUserTools);
186
                delete [] pszOldPath;
187
        }
188
 
189
        // setup the package tree image list
190
 
191
        m_ilTreeIcons.Create (IDB_PKGADMIN_TREEICONS, 16, 1, RGB (0,128,128));
192
        m_ctrlPackageTree.SetImageList (&m_ilTreeIcons, TVSIL_NORMAL);
193
 
194
        // populate the package tree
195
 
196
        while (! PopulatePackageTree (m_strRepository))
197
        {
198
                m_strRepository = _T("");
199
                OnPkgadminRepository (); // prompt the user for the repository location
200
                if (m_strRepository.IsEmpty ()) // if dialog was cancelled
201
                {
202
                        PostQuitMessage (1);
203
                        return TRUE;
204
                }
205
        }
206
 
207
        return TRUE;  // return TRUE  unless you set the focus to a control
208
}
209
 
210
void CPkgAdminDlg::OnSysCommand(UINT nID, LPARAM lParam)
211
{
212
        if ((nID & 0xFFF0) == IDM_ABOUTBOX)
213
        {
214
                CPkgadminAboutDlg dlgAbout;
215
                dlgAbout.DoModal();
216
        }
217
        else
218
        {
219
                CeCosDialog::OnSysCommand(nID, lParam);
220
        }
221
}
222
 
223
// If you add a minimize button to your dialog, you will need the code below
224
//  to draw the icon.  For MFC applications using the document/view model,
225
//  this is automatically done for you by the framework.
226
 
227
void CPkgAdminDlg::OnPaint()
228
{
229
        if (IsIconic())
230
        {
231
                CPaintDC dc(this); // device context for painting
232
 
233
                SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
234
 
235
                // Center icon in client rectangle
236
                int cxIcon = GetSystemMetrics(SM_CXICON);
237
                int cyIcon = GetSystemMetrics(SM_CYICON);
238
                CRect rect;
239
                GetClientRect(&rect);
240
                int x = (rect.Width() - cxIcon + 1) / 2;
241
                int y = (rect.Height() - cyIcon + 1) / 2;
242
 
243
                // Draw the icon
244
                dc.DrawIcon(x, y, m_hIcon);
245
        }
246
        else
247
        {
248
                CeCosDialog::OnPaint();
249
        }
250
}
251
 
252
// The system calls this to obtain the cursor to display while the user drags
253
//  the minimized window.
254
HCURSOR CPkgAdminDlg::OnQueryDragIcon()
255
{
256
        return (HCURSOR) m_hIcon;
257
}
258
 
259
// Trivial handlers; otherwise CdlPackagesDatabaseBody::make asserts.
260
void CdlErrorHandler (std::string message)
261
{
262
};
263
 
264
void CdlWarningHandler (std::string message)
265
{
266
};
267
 
268
 
269
bool CPkgAdminDlg::PopulatePackageTree(LPCTSTR pszPackagesPath)
270
{
271
        // delete any existing CDL database
272
 
273
        if (m_CdlPkgData)
274
        {
275
                delete m_CdlPkgData;
276
                m_CdlPkgData = NULL;
277
        }
278
 
279
        // load the package database
280
 
281
        try
282
        {
283
        // Cdl asserts unless the handlers are present.
284
#if 1
285
        m_CdlPkgData = CdlPackagesDatabaseBody::make (UnicodeToStdStr (pszPackagesPath), &CdlErrorHandler, &CdlWarningHandler);
286
#else
287
        m_CdlPkgData = CdlPackagesDatabaseBody::make (UnicodeToStdStr (pszPackagesPath));
288
#endif
289
        }
290
        catch (CdlStringException exception)
291
        {
292
                CString strMessage;
293
                strMessage.Format (_T("Error loading database:\n\n%s"), CString (exception.get_message ().c_str ()));
294
                AfxMessageBox (strMessage);
295
                return false;
296
        }
297
        catch (...)
298
        {
299
                AfxMessageBox (_T("Error loading database"));
300
                return false;
301
        }
302
 
303
        // clear the old package tree
304
 
305
        ClearPackageTree ();
306
 
307
        // populate the new package tree
308
 
309
        const std::vector<std::string>& packages = m_CdlPkgData->get_packages ();
310
        for (std::vector<std::string>::const_iterator package = packages.begin (); package != packages.end (); package++)
311
        {
312
                // add a package node
313
 
314
                TRACE (_T("Adding package %s:"), CString (package->c_str ()));
315
                HTREEITEM hPackage = m_ctrlPackageTree.InsertItem (CString (m_CdlPkgData->get_package_aliases (*package) [0].c_str ()));
316
                m_ctrlPackageTree.SetItemData (hPackage, (DWORD) new CString (package->c_str ()));
317
                m_ctrlPackageTree.SetItemImage (hPackage, 0, 0);
318
 
319
                const std::vector<std::string>& versions = m_CdlPkgData->get_package_versions (* package);
320
                for (std::vector<std::string>::const_iterator version = versions.begin (); version != versions.end (); version++)
321
                {
322
                        // add a version node
323
 
324
                        TRACE (_T(" %s"), CString (version->c_str ()));
325
                        const HTREEITEM hVersion = m_ctrlPackageTree.InsertItem (CString (version->c_str ()), hPackage);
326
                        m_ctrlPackageTree.SetItemImage (hVersion, 1, 1);
327
                }
328
                TRACE (_T("\n"));
329
                m_ctrlPackageTree.SortChildren (hPackage); // sort the version nodes
330
        }
331
 
332
        m_ctrlPackageTree.SortChildren (NULL); // sort the package nodes
333
 
334
  if(this==AfxGetApp()->m_pMainWnd){ // if the dialog is the application
335
          // update the caption bar
336
          CString strCaption (m_strRepository);
337
          strCaption.Replace (_TCHAR('/'), _TCHAR('\\'));
338
          strCaption += _T(" - eCos Package Administration Tool");
339
          SetWindowText (strCaption);
340
  }
341
 
342
        return true;
343
}
344
 
345
void CPkgAdminDlg::OnPkgadminRemove()
346
{
347
        const HTREEITEM hTreeItem = m_ctrlPackageTree.GetSelectedItem ();
348
        if (! hTreeItem)
349
                return;
350
 
351
        if (IDYES != CWnd::MessageBox (_T("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?"),
352
                _T("Remove Package"), MB_YESNO | MB_ICONEXCLAMATION))
353
                return;
354
 
355
        const CString * pstrPackage = (const CString *) m_ctrlPackageTree.GetItemData (hTreeItem);
356
        if (pstrPackage) // if a package node is selected
357
        {
358
                // remove all package version nodes
359
 
360
                bool bStatus = true;
361
                HTREEITEM hChildItem = m_ctrlPackageTree.GetChildItem (hTreeItem);
362
                while (hChildItem && bStatus)
363
                {
364
                        const HTREEITEM hNextChildItem = m_ctrlPackageTree.GetNextSiblingItem (hChildItem);
365
                        bStatus = RemovePackageVersion (hChildItem);
366
                        hChildItem = hNextChildItem;
367
                }
368
 
369
                // remove the package node
370
 
371
                if (bStatus)
372
                {
373
                        delete pstrPackage;
374
                        m_ctrlPackageTree.DeleteItem (hTreeItem);
375
                }
376
        }
377
        else // a version node is selected
378
        {
379
                // remove the version node
380
 
381
                const HTREEITEM hParentItem = m_ctrlPackageTree.GetParentItem (hTreeItem);
382
                ASSERT (hParentItem);
383
                if (RemovePackageVersion (hTreeItem) && ! m_ctrlPackageTree.ItemHasChildren (hParentItem)) // if the only version was deleted
384
                {
385
                        // remove the package node
386
 
387
                        delete pstrPackage;
388
                        m_ctrlPackageTree.DeleteItem (hParentItem);
389
                }
390
        }
391
}
392
 
393
void CPkgAdminDlg::ClearPackageTree()
394
{
395
        HTREEITEM hPackage = m_ctrlPackageTree.GetRootItem ();
396
        if (! hPackage) // if no packages in the tree...
397
                return;     // ...nothing to do
398
 
399
        while (hPackage)
400
        {
401
                const HTREEITEM hNextPackage = m_ctrlPackageTree.GetNextSiblingItem (hPackage);
402
                TRACE (_T("Deleting package %s\n"), * ((CString *) m_ctrlPackageTree.GetItemData (hPackage)));
403
                delete (CString *) m_ctrlPackageTree.GetItemData (hPackage);
404
                m_ctrlPackageTree.DeleteItem (hPackage);
405
                hPackage = hNextPackage;
406
        }
407
}
408
 
409
void CPkgAdminDlg::OnDestroy()
410
{
411
        CeCosDialog::OnDestroy();
412
 
413
        // free memory allocated to the tree item data CStrings
414
 
415
        ClearPackageTree ();
416
 
417
        // free memory allocated to the CDL database
418
 
419
        if (m_CdlPkgData)
420
                delete m_CdlPkgData;
421
 
422
}
423
 
424
void CPkgAdminDlg::OnPkgadminAdd()
425
{
426
        CFileDialog dlg (TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT, _T("eCos Package Files (*.epk)|*.epk||"), GetParent ());
427
        TCHAR szBuffer [MAX_PATH * 16] = _T("");
428
        dlg.m_ofn.lpstrFile = szBuffer;
429
        dlg.m_ofn.nMaxFile = MAX_PATH * 16;
430
        dlg.m_ofn.lpstrTitle = _T("Open eCos Package Files");
431
        if (IDOK == dlg.DoModal ())
432
        {
433
                bool bRepositoryChanged = false;
434
                POSITION posPathName = dlg.GetStartPosition ();
435
                while (posPathName)
436
                {
437
                        // get an eCos package distribution file
438
 
439
                        CString strPathName = dlg.GetNextPathName (posPathName);
440
 
441
                        // extract the licence file
442
 
443
                        CString strCommand;
444
                        strCommand.Format (_T("add %s --extract_license"), strPathName);
445
                        strCommand.Replace (_TCHAR('\\'), _TCHAR('/')); // backslashes -> forward slashes for Tcl_EvalFile
446
                        EvalTclFile (3, strCommand);
447
                        CString strLicenseFile = m_strRepository + _T("/pkgadd.txt");
448
                        strLicenseFile.Replace (_TCHAR('/'), _TCHAR('\\')); // forward slashes -> backslashes for Win32
449
 
450
                        // read the license file
451
 
452
                        CFile fileLicenseFile;
453
                        if (fileLicenseFile.Open (strLicenseFile, CFile::modeRead))
454
                        {
455
                                TRACE (_T("License file found at %s\n"), strLicenseFile);
456
                                const DWORD dwLicenseLength = fileLicenseFile.GetLength ();
457
                                char * pszBuffer = new char [dwLicenseLength + 1]; // allocate a buffer
458
                                fileLicenseFile.Read (pszBuffer, dwLicenseLength);
459
                                fileLicenseFile.Close ();
460
                                CFile::Remove (strLicenseFile); // delete the license file when read
461
                                pszBuffer [dwLicenseLength] = NULL; // terminate the string in the buffer
462
                                CString strLicenseText (pszBuffer); // copy into a CString to convert to Unicode
463
                                delete [] pszBuffer;
464
                                if (-1 == strLicenseText.Find (_T("\r\n"))) // if the file has LF line endings...
465
                                        strLicenseText.Replace (_T("\n"), _T("\r\n")); // ... replace with CRLF line endings
466
 
467
                                // display the license text
468
 
469
                                CPkgAdminLicenseDlg dlgLicense (this);
470
                                dlgLicense.m_strLicense = strLicenseText;
471
                                dlgLicense.SetCaption (strPathName + _T(" - Add Packages"));
472
                                if (IDOK != dlgLicense.DoModal ()) // if license not accepted by user
473
                                        continue; // try the next file
474
                        }
475
 
476
                        // add the contents of the package distribution file
477
 
478
                        strCommand.Format (_T("add %s --accept_license"), strPathName);
479
                        strCommand.Replace (_TCHAR('\\'), _TCHAR('/')); // backslashes -> forward slashes for Tcl_EvalFile
480
                        if (! EvalTclFile (3, strCommand))  // if not successful
481
                                continue; // try the next file
482
 
483
                        bRepositoryChanged = true;
484
                }
485
 
486
                // refresh the package tree only if necessary
487
 
488
                if (bRepositoryChanged && ! PopulatePackageTree (m_strRepository))
489
                        DestroyWindow ();
490
        }
491
}
492
 
493
bool CPkgAdminDlg::EvalTclFile(int nArgc, LPCTSTR pszArgv)
494
{
495
        CPkgAdminTclWaitDlg dlgWait;
496
 
497
        TRACE (_T("Evaluating ecosadmin.tcl %s\n"), pszArgv);
498
 
499
        // set up the data structure which is passed to the Tcl thread
500
 
501
        CString strArgc;
502
        strArgc.Format (_T("%d"), nArgc);
503
        std::string argv0 = UnicodeToStdStr (m_strRepository) + "/ecosadmin.tcl";
504
        std::string argv = UnicodeToStdStr (pszArgv);
505
        std::string argc = UnicodeToStdStr (strArgc);
506
        dlgWait.etsInfo.argv0 = (char *) argv0.c_str ();
507
        dlgWait.etsInfo.argv = (char *) argv.c_str ();
508
        dlgWait.etsInfo.argc = (char *) argc.c_str ();
509
 
510
        // display the 'please wait' dialog
511
        // the Tcl command is invoked from CPkgAdminTclWaitDlg::OnCreate()
512
 
513
        CWaitCursor curWait;
514
        dlgWait.DoModal ();
515
        curWait.Restore ();
516
 
517
        // retrieve status information from the data structure
518
 
519
        int nStatus = dlgWait.etsInfo.status;
520
        CString strErrorMessage (dlgWait.etsInfo.result);
521
 
522
        // report any error
523
 
524
        if (! strErrorMessage.IsEmpty ())
525
        {
526
                AfxMessageBox (_T("Command execution error:\n\n") + strErrorMessage);
527
                return false;
528
        }
529
        else if (TCL_OK != nStatus)
530
        {
531
                AfxMessageBox (_T("Command execution error"));
532
                return false;
533
        }
534
 
535
        return true;
536
}
537
 
538
bool CPkgAdminDlg::RemovePackageVersion(HTREEITEM hTreeItem)
539
{
540
        const HTREEITEM hParentItem = m_ctrlPackageTree.GetParentItem (hTreeItem);
541
        ASSERT (hParentItem);
542
        CString * pstrPackage = (CString *) m_ctrlPackageTree.GetItemData (hParentItem);
543
        ASSERT (pstrPackage);
544
        CString strCommand;
545
        strCommand.Format (_T("remove %s --version %s"), * pstrPackage, m_ctrlPackageTree.GetItemText (hTreeItem));
546
        if (! EvalTclFile (3, strCommand)) // if not successful
547
                return false;
548
 
549
        m_ctrlPackageTree.DeleteItem (hTreeItem); // remove the selected item from the tree
550
        return true;
551
}
552
 
553
void CPkgAdminDlg::OnPkgadminRepository()
554
{
555
        CFileDialog dlg (TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST, _T("eCos Package Database Files (ecos.db)|ecos.db||"), GetParent ());
556
        dlg.m_ofn.lpstrTitle = _T("Open eCos Package Database File");
557
 
558
        int nStatus;
559
        do
560
        {
561
                nStatus = dlg.DoModal ();
562
                if (IDOK == nStatus)
563
                {
564
                        const CString strPathName = dlg.GetPathName ();
565
                        const int nPathNameIndex = strPathName.ReverseFind (_TCHAR('\\'));
566
                        ASSERT (nPathNameIndex != -1);
567
                        m_strRepository = strPathName.Mid (0, nPathNameIndex);
568
                        m_strRepository.Replace (_TCHAR('\\'), _TCHAR('/'));
569
                }
570
        }
571
        while ((IDOK == nStatus) && ! PopulatePackageTree (m_strRepository));
572
}
573
 
574
void CPkgAdminDlg::OnSelchangedPkgadminTree(NMHDR*, LRESULT* pResult)
575
{
576
        //NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
577
 
578
        // enable the remove button only if a node is selected
579
        m_btnRemove.EnableWindow (NULL != m_ctrlPackageTree.GetSelectedItem ());
580
 
581
        *pResult = 0;
582
}
583
 
584
std::string CPkgAdminDlg::UnicodeToStdStr(LPCTSTR str)
585
{
586
        int nLength = 1 + _tcslen (str);
587
        char * pszString = new char [nLength];
588
 
589
        #ifdef _UNICODE
590
        WideCharToMultiByte (CP_ACP, 0, str, -1, pszString, nLength, NULL, NULL);
591
        #else
592
        strcpy (pszString, str);
593
        #endif
594
 
595
        std::string stdstr = std::string (pszString);
596
        delete [] pszString;
597
        return stdstr;
598
}
599
 
600
bool CPkgAdminDlg::FindUserToolsPath()
601
{
602
        HKEY hKey;
603
        if (ERROR_SUCCESS != RegOpenKeyEx (HKEY_CURRENT_USER, _T("Software\\Red Hat\\eCos\\Configuration Tool\\User Tools"), 0, KEY_READ, &hKey))
604
                return false;
605
 
606
        TCHAR szBuffer [MAX_PATH + 1];
607
        DWORD dwBufferLength = MAX_PATH + 1;
608
        LONG lStatus = RegQueryValueEx (hKey, _T("Folder"), NULL, NULL, (LPBYTE) szBuffer, &dwBufferLength);
609
        RegCloseKey (hKey);
610
        if (ERROR_SUCCESS != lStatus)
611
                return false;
612
 
613
        m_strUserTools = szBuffer;
614
        TRACE (_T("User tools found at %s\n"), m_strUserTools);
615
        return ! m_strUserTools.IsEmpty ();
616
}

powered by: WebSVN 2.1.0

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