File: XPIPackagerDlg.cpp

package info (click to toggle)
mozilla-firefox 1.0.4-2sarge17
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 255,356 kB
  • ctags: 267,207
  • sloc: cpp: 1,623,961; ansic: 792,828; xml: 85,380; makefile: 41,934; perl: 27,802; asm: 14,884; sh: 14,807; cs: 4,507; python: 4,398; java: 4,004; yacc: 1,380; lex: 409; pascal: 354; php: 244; csh: 132; objc: 73; ada: 44; sql: 4
file content (810 lines) | stat: -rw-r--r-- 25,220 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
// XPIPackagerDlg.cpp : implementation file
//

#include "stdafx.h"
#include "XPIPackager.h"
#include "XPIPackagerDlg.h"
#include "FileChooserDlg.h"
#include "MIMETypeChooseDlg.h"
#include "ZipArchive.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#define COMPANY_DEFAULT_VALUE "My Plugin Company"
#define PLUGIN_DESC_DEFAULT_VALUE "My Exemplary Plugin Mine All Mine"
#define DOMAIN_DEFAULT_VALUE "www.MyPluginCompany.com"

#define ZIP_COMMAND "Y:\\workspace\\XPIinstaller\\Debug\\zip.exe -q "
#define QUOTE "\""
#define SPACE " "
#define INSTALL_JS_FILE "install.js"

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CXPIPackagerDlg dialog

CXPIPackagerDlg::CXPIPackagerDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CXPIPackagerDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CXPIPackagerDlg)
	m_Domain_Name_Value = _T("");
	m_PLID_Value = _T("");
	m_Plugin_Version_Value = _T("");
	m_Product_Name_Value = _T("");
	m_Archive_Name_Value = _T("");
	m_Component_Size_Value = 0;
	m_Company_Name_Value = _T("");
	m_Plugin_Size_Value = 0;
	m_Plugin_Description_Value = _T("");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CXPIPackagerDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CXPIPackagerDlg)
	DDX_Control(pDX, IDC_MIME_LIST, m_MIME_List_Control);
	DDX_Control(pDX, IDC_COMPONENT_LIST, m_Component_List_Control);
	DDX_Control(pDX, IDC_PLUGIN_LIST, m_Plugin_List_Control);
	DDX_Text(pDX, IDC_DOMAIN_NAME, m_Domain_Name_Value);
	DDX_Text(pDX, IDC_PLID, m_PLID_Value);
	DDX_Text(pDX, IDC_PLUGIN_VERSION, m_Plugin_Version_Value);
	DDX_Text(pDX, IDC_PRODUCT_NAME, m_Product_Name_Value);
	DDX_Text(pDX, IDC_ARCHIVE_NAME, m_Archive_Name_Value);
	DDX_Text(pDX, IDC_COMPONENT_SIZE, m_Component_Size_Value);
	DDX_Text(pDX, IDC_COMPANY_NAME, m_Company_Name_Value);
	DDX_Text(pDX, IDC_PLUGIN_SIZE, m_Plugin_Size_Value);
	DDX_Text(pDX, IDC_PLUGIN_DESCRIPTION, m_Plugin_Description_Value);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CXPIPackagerDlg, CDialog)
	//{{AFX_MSG_MAP(CXPIPackagerDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDOK, OnCreate)
	ON_BN_CLICKED(IDC_AUTO_PLID, OnAutoPLID)
	ON_BN_CLICKED(IDC_BIG_HELP, OnBigHelp)
	ON_BN_CLICKED(IDC_PLID_HELP, OnPLIDHelp)
	ON_BN_CLICKED(IDC_COMPONENT_BROWSE, OnComponentBrowse)
	ON_BN_CLICKED(IDC_COMPONENT_REMOVE, OnComponentRemove)
	ON_BN_CLICKED(IDC_PLUGIN_BROWSE, OnPluginBrowse)
	ON_BN_CLICKED(IDC_PLUGIN_REMOVE, OnPluginRemove)
	ON_BN_CLICKED(IDC_MIMETYPE_ADD, OnMIMETypeAdd)
	ON_BN_CLICKED(IDC_MIMETYPE_REMOVE, OnMIMETypeRemove)
	ON_NOTIFY(NM_DBLCLK, IDC_PLUGIN_LIST, OnDblclkPluginList)
	ON_NOTIFY(NM_DBLCLK, IDC_COMPONENT_LIST, OnDblclkComponentList)
	ON_NOTIFY(NM_DBLCLK, IDC_MIME_LIST, OnDblclkMimeList)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CXPIPackagerDlg message handlers

BOOL CXPIPackagerDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here
  // Initialize the CListControl Columns
  m_Plugin_List_Control.InsertColumn( 0, "Plugin File", LVCFMT_LEFT, 200, -1 );
  m_Plugin_List_Control.InsertColumn( 1, "PLID", LVCFMT_LEFT, 125, -1 );

  m_Component_List_Control.InsertColumn( 0, "Component File", LVCFMT_LEFT, 200, -1 );
  m_Component_List_Control.InsertColumn( 1, "PLID", LVCFMT_LEFT, 125, -1 );

  m_MIME_List_Control.InsertColumn( 0, "Mime Type", LVCFMT_LEFT, 150, -1 );
  m_MIME_List_Control.InsertColumn( 1, "Suffix", LVCFMT_LEFT, 100, -1 );
  m_MIME_List_Control.InsertColumn( 2, "Suffix Description", LVCFMT_LEFT, 150, -1 );
  m_MIME_List_Control.InsertColumn( 3, "Plugin File", LVCFMT_LEFT, 250, -1 );

  // fill with starter information
  m_Company_Name_Value = COMPANY_DEFAULT_VALUE;
  m_Plugin_Description_Value = PLUGIN_DESC_DEFAULT_VALUE;
  m_Domain_Name_Value = DOMAIN_DEFAULT_VALUE;

  UpdateData(false);
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CXPIPackagerDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CXPIPackagerDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CXPIPackagerDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}



void CXPIPackagerDlg::OnCreate() 
{
	// TODO: Add your control notification handler code here
  UpdateData(true);

  if(!m_Archive_Name_Value.GetLength())
  {
    MessageBox("Need a valid name for the final XPI Installer file.", "Invalid File", MB_OK + MB_ICONEXCLAMATION);
    return;
  }

  if(!m_PluginFileList.GetSize())
  {
    MessageBox("You must have at least one PLUGIN file in a XPI Archive.", "Plugin File Missing", MB_OK + MB_ICONEXCLAMATION);
    return;
  }
  
  CString tempFileName = m_PluginFileList.ElementAt(0);
  CString tempArchiveName = m_Archive_Name_Value.Left(tempFileName.ReverseFind('.') + 1);

  CString temp = tempFileName.Left(tempFileName.ReverseFind('\\') + 1);
  temp += m_Archive_Name_Value;

  m_Archive_Name_Value = temp;

  //create new archive *.xpi
  CZipArchive archive;
  archive.Open(m_Archive_Name_Value, CZipArchive::create);

  //add plugin dlls
  int FileCount = m_PluginFileList.GetSize();
  for(int i = 0; i < FileCount; i++)
  {
    tempFileName = m_PluginFileList.GetAt(i);
    archive.AddNewFile(tempFileName, -1, false);
  }

  //add components
  FileCount = m_ComponentFileList.GetSize();
  if( FileCount != 0 )
  {
    for( i = 0; i < FileCount; i++)
    {
      tempFileName = m_ComponentFileList.GetAt(i);
      archive.AddNewFile(tempFileName, -1, false);
    }
  }

  //add install .js
  HRSRC info = ::FindResource(NULL,MAKEINTRESOURCE(IDR_HEADER), "JSCRIPT");
  HGLOBAL resource = ::LoadResource(NULL, info);
  DWORD fileSize = SizeofResource(NULL, info);
  BYTE *mempointer = (BYTE *) GlobalLock(resource);
  CString header;
  memcpy(header.GetBuffer(fileSize), mempointer, fileSize);
  header.ReleaseBuffer();
  int foo = header.GetLength();

  info = ::FindResource(NULL,MAKEINTRESOURCE(IDR_BODY), "JSCRIPT");
  resource = ::LoadResource(NULL, info);
  fileSize = SizeofResource(NULL, info);
  mempointer = (BYTE *) GlobalLock(resource);
  CString body;
  memcpy(body.GetBuffer(fileSize), mempointer, fileSize);
  body.ReleaseBuffer();
  int foo2 = body.GetLength();
  
  CString finalFile;
  GetGuts(header, body, finalFile);

  if (finalFile.GetLength())
  {
    CZipFileHeader header;
    header.m_uMethod = Z_DEFLATED;
    header.SetFileName("install.js");
    header.SetComment("install.js: install script");
    archive.OpenNewFile(header, Z_DEFAULT_COMPRESSION, m_Archive_Name_Value);
    archive.WriteNewFile(finalFile.GetBuffer(0), finalFile.GetLength());
    archive.CloseNewFile();
  }
  //close archive
  archive.Close();
  GlobalUnlock(resource);

  CString tMessage = "The following XPI Archive:\n\n";
  tMessage += m_Archive_Name_Value;
  tMessage += "\n\nwas created successfully!";
  MessageBox(tMessage, "XPI Archive Created!", MB_OK + MB_ICONEXCLAMATION);
  return;
}

/* --- FILLER.JS ---
var PLUGIN_FILE         = [%s];
var PLUGIN_FILE_PLID    = [%s];
var COMPONENT_FILE      = [%s];
var COMPONENT_FILE_PLID = [%s];
// (DLL files)
var PLUGIN_SIZE         = %d;
// (XPI files)
var COMPONENT_SIZE      = %d;
var SOFTWARE_NAME       = "%s";
var PLID    = "%s";
var VERSION = "%s";
var MIMETYPE           = [%s];
var SUFFIX             = [%s];
var SUFFIX_DESCRIPTION = [%s];
var COMPANY_NAME       = "%s";
var PLUGIN_DESCRIPTION = "%s";
*/

#define BUFFER_SIZE 5000

void
CXPIPackagerDlg::GetGuts(const CString &header, const CString &body, CString &result)
{
  CString filler;

  HRSRC info = ::FindResource(NULL,MAKEINTRESOURCE(IDR_FILLER), "JSCRIPT");
  HGLOBAL resource = ::LoadResource(NULL, info);
  DWORD fileSize = SizeofResource(NULL, info);
  BYTE *mempointer = (BYTE *) GlobalLock(resource);
  memcpy(filler.GetBuffer(fileSize), mempointer, fileSize);
  filler.ReleaseBuffer();


  CFile t_File;
  CString t_FileName;
  CString t_FullFileName;

  // build the plugin parameter
  CString t_PluginParameter;
  CString t_PluginPLIDParameter;
  int FileCount = m_PluginFileList.GetSize();
  for(int i = 0; i < FileCount; i++)
  {
    t_FullFileName = m_PluginFileList.GetAt(i);
    if(t_File.Open(t_FullFileName, CFile::modeRead))
    {
      t_FileName = t_File.GetFileName();
    }
    t_File.Close();
    t_PluginParameter += "\"" + t_FileName + "\"";
    t_PluginPLIDParameter += "\"" + m_PluginPLIDList.ElementAt(i) + "\"";
    if(i != (FileCount - 1))
    {
      t_PluginParameter += ", ";
      t_PluginPLIDParameter += ", ";
    }
  }

  // build the component parameter
  CString t_ComponentParameter;
  CString t_ComponentPLIDParameter;
  FileCount = m_ComponentFileList.GetSize();
  for( i = 0; i < FileCount; i++)
  {
    t_FullFileName = m_ComponentFileList.GetAt(i);
    if(t_File.Open(t_FullFileName, CFile::modeRead))
    {
      t_FileName = t_File.GetFileName();
    }
    t_File.Close();
    t_ComponentParameter += "\"" + t_FileName + "\"";
    t_ComponentPLIDParameter += "\"" + m_ComponentPLIDList.ElementAt(i) + "\"";
    if(i != (FileCount - 1))
    {
      t_ComponentParameter += ", ";
      t_ComponentPLIDParameter += ", ";
    }
  }
  if(!t_ComponentParameter.GetLength())
    t_ComponentParameter = "\"\"";
  if(!t_ComponentPLIDParameter.GetLength())
    t_ComponentPLIDParameter = "\"\"";

  // build the MIME parameters
  CString t_MIMETypeParameter;
  CString t_SuffixParameter;
  CString t_SuffixDescriptionParameter;
  FileCount = m_MIMETypeList.GetSize();
  for( i = 0; i < FileCount; i++)
  {
    t_MIMETypeParameter          += "\"" + m_MIMETypeList.ElementAt(i) + "\"";
    t_SuffixParameter            += "\"" + m_SuffixList.ElementAt(i) + "\"";
    t_SuffixDescriptionParameter += "\"" + m_SuffixDescriptionList.ElementAt(i) + "\"";
    if(i != (FileCount - 1))
    {
      t_MIMETypeParameter          += ", ";;
      t_SuffixParameter            += ", ";;
      t_SuffixDescriptionParameter += ", ";;
    }
  }
  if(!t_MIMETypeParameter.GetLength())
    t_MIMETypeParameter = "\"\"";
  if(!t_SuffixParameter.GetLength())
    t_SuffixParameter = "\"\"";
  if(!t_SuffixDescriptionParameter.GetLength())
    t_SuffixDescriptionParameter = "\"\"";
  
  CString buffer;

  sprintf(buffer.GetBuffer(filler.GetLength() + BUFFER_SIZE), filler, t_PluginParameter, t_PluginPLIDParameter,
    t_ComponentParameter, t_ComponentPLIDParameter, m_Plugin_Size_Value, m_Component_Size_Value, 
    m_Product_Name_Value, m_PLID_Value, m_Plugin_Version_Value, t_MIMETypeParameter, t_SuffixParameter,
    t_SuffixDescriptionParameter, m_Company_Name_Value, m_Plugin_Description_Value);

  buffer.ReleaseBuffer();
  result += header;
  result += buffer;
  result += body;
}

void CXPIPackagerDlg::OnAutoPLID() 
{
  // TODO: Add your control notification handler code here
  UpdateData(true);
  CString temp;
  temp = "@";
  temp += m_Domain_Name_Value;
  temp += "/";
  temp += m_Product_Name_Value;
  temp += ",version=";
  temp += m_Plugin_Version_Value;
  
  m_PLID_Value = temp;

  UpdateData(false);	
}

void CXPIPackagerDlg::OnBigHelp() 
{
	// TODO: Add your control notification handler code here
  CString tempString = "http://devedge.netscape.com/viewsource/2002/xpinstall-guidelines/";
  ShellExecute(NULL,"open",tempString,"","",SW_SHOWDEFAULT);
}

void CXPIPackagerDlg::OnPLIDHelp() 
{
	// TODO: Add your control notification handler code here
  CString tempString = "http://www.mozilla.org/projects/plugins/plugin-identifier.html";
  ShellExecute(NULL,"open",tempString,"","",SW_SHOWDEFAULT);
}


long CXPIPackagerDlg::CalculateTotalFileSize(const CStringArray* t_Array) 
{
	// TODO: Add your control notification handler code here
  CFile t_File;
  CString t_FileName;
	int t_NumFiles = t_Array->GetSize();

  long t_Size = 0;

  for(int i = 0; i < t_NumFiles; i++)
  {
    t_FileName = t_Array->GetAt(i);
    if(t_File.Open(t_FileName, CFile::modeRead))
    {
      CFileStatus t_FileStatus;
      if(t_File.GetStatus(t_FileStatus))
        t_Size += t_FileStatus.m_size;
    }
    t_File.Close();
  }
  return t_Size;
}

void CXPIPackagerDlg::OnComponentBrowse() 
{
	// TODO: Add your control notification handler code here
  UpdateData(true);
  CString t_PLID;
  CString t_ComponentName;
  CString t_ComponentFileName;
  CFileChooserDlg dlg(CXPIPackagerApp::XPT_TYPE, m_PLID_Value, t_ComponentFileName, m_Domain_Name_Value, m_Product_Name_Value, m_Plugin_Version_Value, NULL);

  if(IDOK == dlg.DoModal())
  {
    t_ComponentFileName = dlg.GetFileName();
    t_PLID = dlg.GetPLIDForFileName();

    CFile t_File;
    if(t_File.Open(t_ComponentFileName, CFile::modeRead))
    {
      CFileStatus t_FileStatus;
      if(t_File.GetStatus(t_FileStatus))
      {
        t_ComponentName = t_File.GetFileName();

        m_ComponentList.InsertAt(0, t_ComponentName);
        m_ComponentFileList.InsertAt(0, t_ComponentFileName);
        m_ComponentPLIDList.InsertAt(0, t_PLID);

        m_Component_List_Control.InsertItem( 0, "", -1);
        m_Component_List_Control.SetItemText( 0, 0, t_ComponentFileName);
        m_Component_List_Control.SetItemText( 0, 1, t_PLID);

        // re-adjust plugin total size
        t_File.Close();
        m_ComponentTotalSize = CalculateTotalFileSize(&m_ComponentFileList);
        m_Component_Size_Value = m_ComponentTotalSize;
      }
    }
  }
  UpdateData(false);
}

void CXPIPackagerDlg::OnComponentRemove() 
{
	// TODO: Add your control notification handler code here
  UpdateData(true);
	int t_CurrentSelection = m_Component_List_Control.GetSelectionMark( );
	if(t_CurrentSelection == -1)
	  return;

	m_Component_List_Control.DeleteItem(t_CurrentSelection);
  m_ComponentList.RemoveAt(t_CurrentSelection);
  m_ComponentFileList.RemoveAt(t_CurrentSelection);
  m_ComponentPLIDList.RemoveAt(t_CurrentSelection);
  // re-adjust size
  m_Component_Size_Value = CalculateTotalFileSize(&m_ComponentFileList);
  UpdateData(false);
}

void CXPIPackagerDlg::OnPluginBrowse() 
{
	// TODO: Add your control notification handler code here
  UpdateData(true);

  CString t_PLID;
  CString t_PluginName;
  CString t_PluginFileName;

  CFileChooserDlg dlg(CXPIPackagerApp::DLL_TYPE, m_PLID_Value, t_PluginFileName, m_Domain_Name_Value, m_Product_Name_Value, m_Plugin_Version_Value, NULL);

  if(IDOK == dlg.DoModal())
  {
    t_PluginFileName = dlg.GetFileName();
    t_PLID = dlg.GetPLIDForFileName();

    CFile t_File;
    if(t_File.Open(t_PluginFileName, CFile::modeRead))
    {
      CFileStatus t_FileStatus;
      if(t_File.GetStatus(t_FileStatus))
      {
        t_PluginName = t_File.GetFileName();

        m_PluginList.InsertAt(0, t_PluginName);
        m_PluginFileList.InsertAt(0, t_PluginFileName);
        m_PluginPLIDList.InsertAt(0, t_PLID);

        m_Plugin_List_Control.InsertItem( 0, "", -1);
        m_Plugin_List_Control.SetItemText( 0, 0, t_PluginFileName);
        m_Plugin_List_Control.SetItemText( 0, 1, t_PLID);

        // re-adjust plugin total size
        t_File.Close();
        m_PluginTotalSize = CalculateTotalFileSize(&m_PluginFileList);
        m_Plugin_Size_Value = m_PluginTotalSize;
      }
    }
  }
  UpdateData(false);
}

void CXPIPackagerDlg::OnPluginRemove() 
{
	// TODO: Add your control notification handler code here
  UpdateData(true);
	int t_CurrentSelection = m_Plugin_List_Control.GetSelectionMark( );
	if(t_CurrentSelection == -1)
	  return;

	m_Plugin_List_Control.DeleteItem(t_CurrentSelection);
  m_PluginList.RemoveAt(t_CurrentSelection);
  m_PluginFileList.RemoveAt(t_CurrentSelection);
  m_PluginPLIDList.RemoveAt(t_CurrentSelection);
  // re-adjust size
  m_Plugin_Size_Value = CalculateTotalFileSize(&m_PluginFileList);
  UpdateData(false);
}


void CXPIPackagerDlg::OnMIMETypeAdd() 
{
	// TODO: Add your control notification handler code here
  UpdateData(true);
  if(!m_PluginList.GetSize())
  {
    CString tMessage = "No Plugin File is present in the archive yet.  A Plugin File is required to a MIME Type for the Plugin.";
    MessageBox(tMessage, "Error: No Plugin File!", MB_OK + MB_ICONEXCLAMATION);
    return;
  }
  CString temp;
  CMIMETypeChooseDlg dlg(temp, temp, temp, temp, &m_PluginList, NULL);

  if(IDOK == dlg.DoModal())
  {
    m_MIMETypeList.InsertAt(0, dlg.GetMIMEType());
    m_SuffixList.InsertAt(0, dlg.GetSuffix());
    m_SuffixDescriptionList.InsertAt(0, dlg.GetSuffixDescription());
    m_MIMEPluginList.InsertAt(0, dlg.GetPlugin());

    m_MIME_List_Control.InsertItem( 0, "", -1);
    m_MIME_List_Control.SetItemText( 0, 0, dlg.GetMIMEType());
    m_MIME_List_Control.SetItemText( 0, 1, dlg.GetSuffix());
    m_MIME_List_Control.SetItemText( 0, 2, dlg.GetSuffixDescription());
    m_MIME_List_Control.SetItemText( 0, 3, dlg.GetPlugin());
  }
  UpdateData(false);
}

void CXPIPackagerDlg::OnMIMETypeRemove() 
{
	// TODO: Add your control notification handler code here
  UpdateData(true);
	int t_CurrentSelection = m_MIME_List_Control.GetSelectionMark( );
	if(t_CurrentSelection == -1)
	  return;

	m_MIME_List_Control.DeleteItem(t_CurrentSelection);

  m_MIMETypeList.RemoveAt(t_CurrentSelection);
  m_SuffixList.RemoveAt(t_CurrentSelection);
  m_SuffixDescriptionList.RemoveAt(t_CurrentSelection);
  m_MIMEPluginList.RemoveAt(t_CurrentSelection);

  UpdateData(false);
}

void CXPIPackagerDlg::OnDblclkPluginList(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
  UpdateData(true);
	int t_CurrentSelection = m_Plugin_List_Control.GetSelectionMark( );
	if(t_CurrentSelection == -1)
	  return;

  CString t_PLID = m_PluginPLIDList.ElementAt(t_CurrentSelection);
  CString t_PluginName;
  CString t_PluginFileName = m_PluginFileList.ElementAt(t_CurrentSelection);

  CFileChooserDlg dlg(CXPIPackagerApp::DLL_TYPE, t_PLID, t_PluginFileName, m_Domain_Name_Value, m_Product_Name_Value, m_Plugin_Version_Value, NULL);

  if(IDOK == dlg.DoModal())
  {
    t_PluginFileName = dlg.GetFileName();
    t_PLID = dlg.GetPLIDForFileName();

    CFile t_File;
    if(t_File.Open(t_PluginFileName, CFile::modeRead))
    {
      CFileStatus t_FileStatus;
      if(t_File.GetStatus(t_FileStatus))
      {
        t_PluginName = t_File.GetFileName();

        m_PluginList.RemoveAt(t_CurrentSelection);
        m_PluginList.InsertAt(t_CurrentSelection, t_PluginName);
        m_PluginFileList.RemoveAt(t_CurrentSelection);
        m_PluginFileList.InsertAt(t_CurrentSelection, t_PluginFileName);
        m_PluginPLIDList.RemoveAt(t_CurrentSelection);
        m_PluginPLIDList.InsertAt(t_CurrentSelection, t_PLID);

        //m_Plugin_List_Control.InsertItem( 0, "", -1);
        m_Plugin_List_Control.SetItemText( t_CurrentSelection, 0, t_PluginFileName);
        m_Plugin_List_Control.SetItemText( t_CurrentSelection, 1, t_PLID);

        // re-adjust plugin total size
        t_File.Close();
        m_PluginTotalSize = CalculateTotalFileSize(&m_PluginFileList);
        m_Plugin_Size_Value = m_PluginTotalSize;
      }
    }
  }
  UpdateData(false);
	
	*pResult = 0;
}

void CXPIPackagerDlg::OnDblclkComponentList(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
  UpdateData(true);
	int t_CurrentSelection = m_Component_List_Control.GetSelectionMark( );
	if(t_CurrentSelection == -1)
	  return;

  CString t_PLID = m_ComponentPLIDList.ElementAt(t_CurrentSelection);
  CString t_ComponentName;
  CString t_ComponentFileName = m_ComponentFileList.ElementAt(t_CurrentSelection);

  CFileChooserDlg dlg(CXPIPackagerApp::XPT_TYPE, t_PLID, t_ComponentFileName, m_Domain_Name_Value, m_Product_Name_Value, m_Plugin_Version_Value, NULL);

  if(IDOK == dlg.DoModal())
  {
    t_ComponentFileName = dlg.GetFileName();
    t_PLID = dlg.GetPLIDForFileName();

    CFile t_File;
    if(t_File.Open(t_ComponentFileName, CFile::modeRead))
    {
      CFileStatus t_FileStatus;
      if(t_File.GetStatus(t_FileStatus))
      {
        t_ComponentName = t_File.GetFileName();

        m_ComponentList.RemoveAt(t_CurrentSelection);
        m_ComponentList.InsertAt(t_CurrentSelection, t_ComponentName);
        m_ComponentFileList.RemoveAt(t_CurrentSelection);
        m_ComponentFileList.InsertAt(t_CurrentSelection, t_ComponentFileName);
        m_ComponentPLIDList.RemoveAt(t_CurrentSelection);
        m_ComponentPLIDList.InsertAt(t_CurrentSelection, t_PLID);

        //m_Plugin_List_Control.InsertItem( 0, "", -1);
        m_Component_List_Control.SetItemText( t_CurrentSelection, 0, t_ComponentFileName);
        m_Component_List_Control.SetItemText( t_CurrentSelection, 1, t_PLID);

        // re-adjust plugin total size
        t_File.Close();
        m_ComponentTotalSize = CalculateTotalFileSize(&m_ComponentFileList);
        m_Component_Size_Value = m_ComponentTotalSize;
      }
    }
  }
  UpdateData(false);
	
	*pResult = 0;
}

void CXPIPackagerDlg::OnDblclkMimeList(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
  UpdateData(true);
	int t_CurrentSelection = m_MIME_List_Control.GetSelectionMark( );
	if(t_CurrentSelection == -1)
	  return;

  if(!m_PluginList.GetSize())
  {
    CString tMessage = "No Plugin File is present in the archive yet.  A Plugin File is required to a MIME Type for the Plugin.";
    MessageBox(tMessage, "Error: No Plugin File!", MB_OK + MB_ICONEXCLAMATION);
    return;
  }

  CString t_MIMEType = m_MIMETypeList.ElementAt(t_CurrentSelection);
  CString t_Suffix = m_SuffixList.ElementAt(t_CurrentSelection);
  CString t_SuffixDescription = m_SuffixDescriptionList.ElementAt(t_CurrentSelection);
  CString t_Plugin = m_MIMEPluginList.ElementAt(t_CurrentSelection);

  CMIMETypeChooseDlg dlg(t_MIMEType, t_Suffix, t_SuffixDescription, t_Plugin, &m_PluginList, NULL);

  if(IDOK == dlg.DoModal())
  {
    m_MIMETypeList.RemoveAt(t_CurrentSelection);
    m_SuffixList.RemoveAt(t_CurrentSelection);
    m_SuffixDescriptionList.RemoveAt(t_CurrentSelection);
    m_MIMEPluginList.RemoveAt(t_CurrentSelection);

    m_MIMETypeList.InsertAt(t_CurrentSelection, dlg.GetMIMEType());
    m_SuffixList.InsertAt(t_CurrentSelection, dlg.GetSuffix());
    m_SuffixDescriptionList.InsertAt(t_CurrentSelection, dlg.GetSuffixDescription());
    m_MIMEPluginList.InsertAt(t_CurrentSelection, dlg.GetPlugin());

    //m_MIME_List_Control.InsertItem( t_CurrentSelection, "", -1);
    m_MIME_List_Control.SetItemText( t_CurrentSelection, 0, dlg.GetMIMEType());
    m_MIME_List_Control.SetItemText( t_CurrentSelection, 1, dlg.GetSuffix());
    m_MIME_List_Control.SetItemText( t_CurrentSelection, 2, dlg.GetSuffixDescription());
    m_MIME_List_Control.SetItemText( t_CurrentSelection, 3, dlg.GetPlugin());
  }
  UpdateData(false);

	*pResult = 0;
}