File: FileChooserDlg.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 (154 lines) | stat: -rw-r--r-- 3,912 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
// FileChooserDlg.cpp : implementation file
//

#include "stdafx.h"
#include "XPIPackager.h"
#include "FileChooserDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CFileChooserDlg dialog


CFileChooserDlg::CFileChooserDlg(int a_FileType, CString& a_PLID, CString& a_FileName, const CString& a_Domain_Name,
                  const CString& a_Product_Name, const CString& a_Version,
                  CWnd* pParent /*=NULL*/)
	: CDialog(CFileChooserDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CFileChooserDlg)
	m_PLID_Value = _T("");
	m_FileName_Value = _T("");
	//}}AFX_DATA_INIT

  // set members
  m_PLID = a_PLID;
  m_FileName = a_FileName;
  m_Domain_Name = a_Domain_Name;
  m_Product_Name = a_Product_Name;
  m_Version = a_Version;

  m_FileType = a_FileType;
}


void CFileChooserDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CFileChooserDlg)
	DDX_Text(pDX, IDC_PLID, m_PLID_Value);
	DDX_Text(pDX, IDC_FILENAME, m_FileName_Value);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CFileChooserDlg, CDialog)
	//{{AFX_MSG_MAP(CFileChooserDlg)
	ON_BN_CLICKED(IDC_PLID_HELP, OnPLIDHelp)
	ON_BN_CLICKED(IDC_FILENAME_BROWSE, OnFilenameBrowse)
	ON_BN_CLICKED(IDC_AUTO_PLID, OnAutoPLID)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFileChooserDlg message handlers

void CFileChooserDlg::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);
}


static char BASED_CODE szFilter[] = "DLL Files (*.dll)|*.dll|Executeable Files (*.exe)|*.exe|XPT Files (*.xpt)|*.xpt|";
static char BASED_CODE szFilter2[] = "XPT Files (*.xpt)|*.xpt|DLL Files (*.dll)|*.dll|Executeable Files (*.exe)|*.exe|";

void CFileChooserDlg::OnFilenameBrowse() 
{
	// TODO: Add your control notification handler code here
	// TODO: Add your control notification handler code here
  UpdateData(true);
  CString temp;
  if(m_FileType == CXPIPackagerApp::XPT_TYPE)
    temp = szFilter2;
  else
    temp = szFilter;

  CFileDialog dlg(true, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, temp);
  
  if(IDOK == dlg.DoModal())
  {
    CFile t_File;
    CString t_PluginFileName = dlg.GetPathName();
    if(t_File.Open(t_PluginFileName, CFile::modeRead))
    {
      CFileStatus t_FileStatus;
      if(t_File.GetStatus(t_FileStatus))
      {
        m_FileName_Value = t_PluginFileName;
        m_FileName = t_PluginFileName;// set the member
        t_File.Close();
      }
    }
    UpdateData(false);
  }	
}

void CFileChooserDlg::OnAutoPLID() 
{
	// TODO: Add your control notification handler code here
  UpdateData(true);
  CString temp;
  temp = "@";
  temp += m_Domain_Name;
  temp += "/";
  temp += m_Product_Name;
  temp += ",version=";
  temp += m_Version;
  
  m_PLID_Value = temp;
  m_PLID = temp;// set the member

  UpdateData(false);	
}

BOOL CFileChooserDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
  UpdateData(true);
  
  m_PLID_Value = m_PLID;
  m_FileName_Value = m_FileName;

  UpdateData(false);	
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CFileChooserDlg::OnOK() 
{
	// TODO: Add extra validation here
  UpdateData(true);
	m_PLID = m_PLID_Value;
	m_FileName = m_FileName_Value;

  CFile t_File;
  if(! t_File.Open(m_FileName, CFile::modeRead))
  {
    CString tMessage = m_FileName;
    tMessage += " is not a valid File or File Name";
    MessageBox(tMessage, "Not a valid File!", MB_OK + MB_ICONEXCLAMATION);
    return;
  }
  t_File.Close();

	CDialog::OnOK();
}