30 ON_BN_CLICKED( IDOK, OnBnClickedOk )
42 #if( FMI_SUPPORT_A614 ) 64 #if( FMI_SUPPORT_A614 ) 65 mOldListItem.setValid(
FALSE );
82 CDataExchange * aDataExchange
85 CDialog::DoDataExchange( aDataExchange );
104 CDialog::OnInitDialog();
129 if( mFilePath ==
"" || mVersion ==
"" )
134 if( mVersion.Left( 2 ) ==
"0x" )
136 if( mVersion.GetLength() > 34 )
141 if( mVersion.GetLength() > 16 )
147 GetDlgItem( IDOK )->EnableWindow(
TRUE );
151 GetDlgItem( IDOK )->EnableWindow(
FALSE );
164 TCHAR workingDirectory[200];
170 DWORD result = GetCurrentDirectory( 200, workingDirectory );
171 if( result == 0 || result > 200 )
173 MessageBox( _T(
"Unable to get current directory"), _T(
"Severe Error") );
182 OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
185 if( dlg.DoModal() == IDOK )
187 mFilePath = dlg.GetPathName();
188 #if( FMI_SUPPORT_A614 ) 197 if( !SetCurrentDirectory( workingDirectory ) )
199 MessageBox( _T(
"Unable to set current directory"), _T(
"Severe Error") );
219 char versionString[35];
223 memset( version, 0,
sizeof( version ) );
224 WideCharToMultiByte( mCom.mClientCodepage, 0, mVersion, -1, versionString, 34, NULL, NULL );
225 versionString[34] =
'\0';
227 if( strncmp( versionString,
"0x", 2 ) == 0 )
233 versionLength = (
uint8)
minval( 16, strlen( versionString ) );
234 memmove( version, versionString, versionLength );
237 WideCharToMultiByte( CP_ACP, 0, mFilePath.GetBuffer(), -1, file, 200, NULL, NULL );
239 fstream open_file( file, ios_base::binary | ios_base::in );
240 if( open_file.good() )
244 mCom.sendFile( file, versionLength, version, (
uint8)mFileType );
246 #if( FMI_SUPPORT_A614 ) 253 AddPSRtoStopList( file, itemId );
258 UINT sendResult = sending_dlg.DoModal();
260 #if( FMI_SUPPORT_A614 ) 263 if( IDOK != sendResult )
265 if( mOldListItem.isValid() )
266 mCom.mA603Stops.put( mOldListItem );
268 mCom.mA603Stops.remove( itemId );
274 mFilePath += _T(
" could not be opened ");
275 MessageBox( mFilePath, _T(
"Error!") );
281 #if( FMI_SUPPORT_A614 ) 288 ifstream open_file( file, ios_base::binary | ios_base::in | ios_base::ate );
289 if( open_file.good() )
291 const short buffSize = 200;
292 char buffer[buffSize];
293 memset( buffer, 0, buffSize );
296 int fSize = open_file.tellg();
307 open_file.seekg( 0, ios::beg );
308 open_file.seekg( 10 );
309 open_file.read( reinterpret_cast<char*>(&itemId),
sizeof(
uint32) );
310 open_file.read( buffer, buffSize );
312 for(
int i = 0; i < buffSize; i++ )
314 if( buffer[i] == NULL )
316 TCHAR tcharName[200];
317 MultiByteToWideChar( CP_UTF8, 0, buffer, -1, tcharName, 200 );
318 stopText.SetString( tcharName );
325 StopListItem& stopListItem = mCom.mA603Stops.get( itemId );
328 mOldListItem = stopListItem;
334 mCom.mA603Stops.put( stopListItem );
BOOL isValid() const
Check whether this item is valid.
Modal dialog displaying the status of the file transfer.
#define IDD_FILE_TRANSFER
CFileTransferDlg(CWnd *aParent, FmiApplicationLayer &aCom)
Constructor.
#define IDC_FILE_XFER_BTN_FIND
afx_msg void OnEnChangeFile()
Edit Change handler for all text boxes.
afx_msg void OnBnClickedFind()
Click handler for Find (file to send) button.
virtual void DoDataExchange(CDataExchange *aDataExchange)
Perform dialog data exchange and validation.
#define cnt_of_array(_a)
The number of elements in _a.
void setValid(BOOL aValid=TRUE)
Set this item as valid.
Data structure to hold details of an A603 stop that the server needs to keep.
#define INVALID32
Placeholder for an invalid 32-bit value.
void setCurrentName(CString aName)
Set the current name of the stop.
#define minval(_x, _y)
The smaller of _x and _y.
uint16 UTIL_hex_to_uint8(const char *aHexString, uint8 *aBinaryData, uint16 aMaxBytes)
Convert a hexadecimal ASCII string to an array of uint8.
Serial communication controller for Garmin and FMI packets.
#define IDC_FILE_XFER_EDIT_FILE_VERSION
BOOL OnInitDialog()
Initialize the dialog.
#define IDC_FILE_XFER_EDIT_FILENAME
Modal dialog allowing the user to select a file to transfer to the client.
void setStopStatus(stop_status_status_type aStatus)
Set the stop status.
unsigned char uint8
8-bit unsigned integer
#define IDC_FILE_XFER_CBO_FILE_TYPE
virtual ~CFileTransferDlg()
Destructor.
unsigned long int uint32
32-bit unsigned integer
void AddPSRtoStopList(char *file, uint32 &itemId)
Adds the transferred PSR to the stop list.
afx_msg void OnBnClickedOk()
Click handler for OK button.
static CFileTransferDlg::file_type file_types[]
File types that the client accepts.