|
1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // t_usb_win.cpp : Defines the class behaviors for the application. |
|
15 // |
|
16 |
|
17 #include "stdafx.h" |
|
18 #include "atlbase.h" |
|
19 #include "t_usb_win.h" |
|
20 #include "t_usb_winDlg.h" |
|
21 #include "global.h" |
|
22 |
|
23 #ifdef _DEBUG |
|
24 #define new DEBUG_NEW |
|
25 #undef THIS_FILE |
|
26 static char THIS_FILE[] = __FILE__; |
|
27 #endif |
|
28 |
|
29 |
|
30 |
|
31 // === Global Defines === |
|
32 |
|
33 char gScriptFileName[100]; |
|
34 char gManufacturerName[100]; |
|
35 char gProductName[100]; |
|
36 char gSerialNumber[100]; |
|
37 char gLogfileName[100]; |
|
38 |
|
39 BOOL gVerboseMode = FALSE; |
|
40 BOOL gKeepOpen = FALSE; |
|
41 BOOL gAbort = FALSE; |
|
42 |
|
43 FILE *logStream = NULL; |
|
44 int gTransferMode = 0; |
|
45 CT_usb_winDlg* gMainWindow; |
|
46 int gReadWriteTimeOut = READWRITE_TIMEOUT; |
|
47 |
|
48 ///////////////////////////////////////////////////////////////////////////// |
|
49 // CT_usb_winApp |
|
50 |
|
51 BEGIN_MESSAGE_MAP(CT_usb_winApp, CWinApp) |
|
52 //{{AFX_MSG_MAP(CT_usb_winApp) |
|
53 // NOTE - the ClassWizard will add and remove mapping macros here. |
|
54 // DO NOT EDIT what you see in these blocks of generated code! |
|
55 //}}AFX_MSG |
|
56 ON_COMMAND(ID_HELP, CWinApp::OnHelp) |
|
57 END_MESSAGE_MAP() |
|
58 |
|
59 ///////////////////////////////////////////////////////////////////////////// |
|
60 // CT_usb_winApp construction |
|
61 |
|
62 CT_usb_winApp::CT_usb_winApp() |
|
63 { |
|
64 // TODO: add construction code here, |
|
65 // Place all significant initialization in InitInstance |
|
66 } |
|
67 |
|
68 ///////////////////////////////////////////////////////////////////////////// |
|
69 // The one and only CT_usb_winApp object |
|
70 |
|
71 CT_usb_winApp theApp; |
|
72 |
|
73 |
|
74 // |
|
75 // Process the command line arguments, printing a helpful message |
|
76 // if none are supplied. |
|
77 // |
|
78 static int ProcessCmdLine() |
|
79 { |
|
80 USES_CONVERSION; |
|
81 |
|
82 LPWSTR cmdLine = GetCommandLineW(); |
|
83 |
|
84 gScriptFileName[0] = '\0'; |
|
85 gManufacturerName[0] = '\0'; |
|
86 gProductName[0] = '\0'; |
|
87 gSerialNumber[0] = '\0'; |
|
88 gLogfileName[0] = '\0'; |
|
89 |
|
90 int argc; |
|
91 LPWSTR * argv = CommandLineToArgvW(cmdLine, & argc); |
|
92 |
|
93 for (int i = 1; i < argc; i++) |
|
94 { |
|
95 if ((argv[i][0] == '-') || (argv[i][0] == '/')) |
|
96 { |
|
97 switch (argv[i][1]) |
|
98 { |
|
99 case 'A': |
|
100 case 'a': |
|
101 case 'L': |
|
102 case 'l': |
|
103 if (argv[i][2] != '=') |
|
104 return -1; |
|
105 strcpy (gLogfileName,W2A (&argv[i][3])); |
|
106 if (argv[i][1] == 'L' || argv[i][1] == 'l') |
|
107 logStream = fopen (gLogfileName, "w"); |
|
108 else |
|
109 logStream = fopen (gLogfileName, "a+"); |
|
110 if (logStream == NULL) |
|
111 return -1; |
|
112 break; |
|
113 |
|
114 case 'M': |
|
115 case 'm': |
|
116 if (argv[i][2] != '=') |
|
117 return -1; |
|
118 strcpy (gManufacturerName,W2A (&argv[i][3])); |
|
119 break; |
|
120 |
|
121 case 'P': |
|
122 case 'p': |
|
123 if (argv[i][2] != '=') |
|
124 return -1; |
|
125 strcpy (gProductName,W2A (&argv[i][3])); |
|
126 break; |
|
127 |
|
128 case 'S': |
|
129 case 's': |
|
130 if (argv[i][2] != '=') |
|
131 return -1; |
|
132 strcpy (gSerialNumber,W2A (&argv[i][3])); |
|
133 break; |
|
134 |
|
135 case 'T': |
|
136 case 't': |
|
137 if (argv[i][2] != '=') |
|
138 return -1; |
|
139 gReadWriteTimeOut = atoi(W2A (&argv[i][3])); |
|
140 if (gReadWriteTimeOut <= 0) |
|
141 return -1; |
|
142 break; |
|
143 |
|
144 case 'K': |
|
145 case 'k': |
|
146 gKeepOpen = true; |
|
147 break; |
|
148 |
|
149 case 'V': |
|
150 case 'v': |
|
151 gVerboseMode = true; |
|
152 break; |
|
153 |
|
154 default: |
|
155 return -1; |
|
156 } |
|
157 } |
|
158 else |
|
159 { |
|
160 strcpy (gScriptFileName,W2A (argv[i])); |
|
161 } |
|
162 } |
|
163 return 0; |
|
164 } |
|
165 |
|
166 ///////////////////////////////////////////////////////////////////////////// |
|
167 // CT_usb_winApp initialization |
|
168 |
|
169 BOOL CT_usb_winApp::InitInstance() |
|
170 { |
|
171 BOOL retCode = FALSE; |
|
172 |
|
173 // Standard initialization |
|
174 // If you are not using these features and wish to reduce the size |
|
175 // of your final executable, you should remove from the following |
|
176 // the specific initialization routines you do not need. |
|
177 |
|
178 #ifdef _AFXDLL |
|
179 Enable3dControls(); // Call this when using MFC in a shared DLL |
|
180 #else |
|
181 Enable3dControlsStatic(); // Call this when linking to MFC statically |
|
182 #endif |
|
183 |
|
184 SetDialogBkColor( RGB(255,255,255),RGB(0, 0, 0)); // Set dialog background color to white |
|
185 |
|
186 if (ProcessCmdLine() < 0) |
|
187 { |
|
188 TRACE0("Invalid Command Line Parameter\n"); |
|
189 return -1; |
|
190 |
|
191 } |
|
192 |
|
193 CT_usb_winDlg dlg; |
|
194 m_pMainWnd = &dlg; |
|
195 gMainWindow = &dlg; |
|
196 int nResponse = dlg.DoModal(); |
|
197 |
|
198 return retCode; |
|
199 } |