form_MMIDataDownload.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:39k
源码类别:
MTK
开发平台:
C++ Builder
- /*****************************************************************************
- * Copyright Statement:
- * --------------------
- * This software is protected by Copyright and the information contained
- * herein is confidential. The software may not be copied and the information
- * contained herein may not be used or disclosed except with the written
- * permission of MediaTek Inc. (C) 2005
- *
- * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
- * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
- * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
- * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
- * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
- * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
- * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
- * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
- * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
- * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
- *
- * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
- * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
- * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
- * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
- * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
- *
- * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
- * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
- * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
- * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
- * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
- *
- *****************************************************************************/
- /*****************************************************************************
- *
- * Filename:
- * ---------
- * form_MMIDataDownload.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * MMI data download form source
- *
- * Author:
- * -------
- * Andy Ueng (mtk00490)
- *
- *============================================================================
- * HISTORY
- * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *------------------------------------------------------------------------------
- * $Revision$
- * $Modtime$
- * $Log$
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *============================================================================
- ****************************************************************************/
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include <IniFiles.hpp>
- #pragma hdrstop
- #include "form_MMIDataDownload.h"
- #include "meta_utils.h"
- #include "man_active.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- AnsiString as_default_FAT_name;
- AnsiString as_default_FAT_path;
- AnsiString as_MMIDataStr;
- extern META_RESULT MetaResult_MMIData;
- TfrmMMIDataDownload *frmMMIDataDownload;
- int Index_MMIData;
- //---------------------------------------------------------------------------
- void REQ_Write_To_FAT(void)
- {
- frmMMIDataDownload->REQ_Write_To_FAT();
- }
- //---------------------------------------------------------------------------
- void REQ_Read_From_FAT(void)
- {
- frmMMIDataDownload->MMI_FILE_Object.REQ_Read_From_FAT((as_default_FAT_path + as_default_FAT_name).c_str(), as_MMIDataStr.c_str());
- }
- //---------------------------------------------------------------------------
- void TfrmMMIDataDownload::set_DEFAULT_PATH(void)
- {
- if(rbFullScreen->Checked)
- {
- as_default_FAT_path = as_default_FAT_fullscreen_path;
- }
- else if(RadioButtonAssociate->Checked)
- {
- as_default_FAT_path = as_default_FAT_associate_path;
- }
- else if(RadioButtonEMS->Checked)
- {
- as_default_FAT_path = as_default_FAT_EMS_path;
- }
- else if(rbMidi->Checked)
- {
- as_default_FAT_path = as_default_FAT_midi_path;
- }
- else if(rbiMelody->Checked)
- {
- as_default_FAT_path = as_default_FAT_imelody_path;
- }
- }
- //---------------------------------------------------------------------------
- __fastcall TfrmMMIDataDownload::TfrmMMIDataDownload(TComponent* Owner)
- : TForm(Owner)
- {
- DirectoryListBoxMMIData->Drive = DriveComboBoxMMIData->Drive;
- FileListBoxMMIData->Directory = DirectoryListBoxMMIData->Directory;
- FileListBoxMMIData->Mask = FilterComboBoxMMIData->Mask;
- read_MAX_FILE_COUNT();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmMMIDataDownload::FilterComboBoxMMIDataChange(
- TObject *Sender)
- {
- FileListBoxMMIData->Mask = FilterComboBoxMMIData->Mask;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmMMIDataDownload::DirectoryListBoxMMIDataChange(
- TObject *Sender)
- {
- FileListBoxMMIData->Directory = DirectoryListBoxMMIData->Directory;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmMMIDataDownload::DriveComboBoxMMIDataChange(
- TObject *Sender)
- {
- DirectoryListBoxMMIData->Drive = DriveComboBoxMMIData->Drive;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmMMIDataDownload::FileListBoxMMIDataChange(
- TObject *Sender)
- {
- //if(FileListBoxMMIData->FileName != "")
- // {
- // ImageMMIData->Picture->LoadFromFile(FileListBoxMMIData->FileName);
- // ImageMMIData->Height = ImageMMIData->Picture->Height;
- // ImageMMIData->Width = ImageMMIData->Picture->Width;
- // }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmMMIDataDownload::btnAddToListClick(
- TObject *Sender)
- {
- btnRemoveFromList->Enabled = true;
- if(rbFullScreen->Checked == true)
- {
- if(lbLocalMMIData->Items->Count < as_MAX_FULLSCREEN_FILE_COUNT.ToInt())
- {
- //lbLocalMMIData->Items->Add(FileListBoxMMIData->FileName);
- //FileListBoxMMIData->CopySelection( lbLocalMMIData );
- for(int i=0; i<FileListBoxMMIData->Count && i<as_MAX_FULLSCREEN_FILE_COUNT.ToInt(); i++)
- {
- if( FileListBoxMMIData->Selected[i] )
- {
- lbLocalMMIData->Items->Add( DirectoryListBoxMMIData->Directory + "\" + FileListBoxMMIData->Items->Strings[i] );
- }
- }
- write_local_default_fullscreen_file_setting();
- }
- else
- {
- Application->MessageBox( "Max full screen file reached", "ERROR!", MB_OK );
- }
- }
- else if(RadioButtonAssociate->Checked == true)
- {
- if(lbLocalMMIData->Items->Count < as_MAX_ASSOCIATE_FILE_COUNT.ToInt())
- {
- lbLocalMMIData->Items->Add(FileListBoxMMIData->FileName);
- write_local_default_associate_file_setting();
- }
- else
- {
- Application->MessageBox( "Max full associate file reached", "ERROR!", MB_OK );
- }
- }
- else if(RadioButtonEMS->Checked == true)
- {
- if(lbLocalMMIData->Items->Count < as_MAX_EMS_FILE_COUNT.ToInt())
- {
- lbLocalMMIData->Items->Add(FileListBoxMMIData->FileName);
- write_local_default_EMS_file_setting();
- }
- else
- {
- Application->MessageBox( "Max full EMS file reached", "ERROR!", MB_OK );
- }
- }
- else if(rbMidi->Checked == true)
- {
- if(lbLocalMMIData->Items->Count < as_MAX_MIDI_FILE_COUNT.ToInt())
- {
- lbLocalMMIData->Items->Add(FileListBoxMMIData->FileName);
- write_local_default_midi_file_setting();
- }
- else
- {
- Application->MessageBox( "Max full midi file reached", "ERROR!", MB_OK );
- }
- }
- else if(rbiMelody->Checked == true)
- {
- if(lbLocalMMIData->Items->Count < as_MAX_IMELODY_FILE_COUNT.ToInt())
- {
- lbLocalMMIData->Items->Add(FileListBoxMMIData->FileName);
- write_local_default_imelody_file_setting();
- }
- else
- {
- Application->MessageBox( "Max iMelody file reached", "ERROR!", MB_OK );
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmMMIDataDownload::FormShow(TObject *Sender)
- {
- show_download_type();
- ShowFileSelected();
- ModifyLastRadioButtonChecked();
- }
- //////////////////////////////////////////////////////////////////////////////////////////
- //---------------------------------------------------------------------------
- void __fastcall TfrmMMIDataDownload::FormClose(TObject *Sender,
- TCloseAction &Action)
- {
- // save graph setting
- if(rbFullScreen->Checked == true)
- {
- write_local_default_fullscreen_file_setting();
- as_download_type = "fullscreen";
- }
- else if(RadioButtonAssociate->Checked == true)
- {
- write_local_default_associate_file_setting();
- as_download_type = "associate";
- }
- else if(RadioButtonEMS->Checked == true)
- {
- write_local_default_EMS_file_setting();
- as_download_type = "ems";
- }
- else if(rbMidi->Checked == true)
- {
- write_local_default_midi_file_setting();
- as_download_type = "midi";
- }
- else if(rbiMelody->Checked == true)
- {
- write_local_default_imelody_file_setting();
- as_download_type = "imelody";
- }
- write_download_type("MF_setup.txt",
- Application->ExeName,
- as_download_type);
- // ---------------- write local file setting to file ------------------------------------
- }
- //////////////////////////////////////////////////////////////////////////////////////////////
- //---------------------------------------------------------------------------
- void __fastcall TfrmMMIDataDownload::btnRemoveFromListClick(
- TObject *Sender)
- {
- if(lbLocalMMIData->ItemIndex < 0)
- {
- return;
- }
- else
- {
- int LocalMMIDataCount = lbLocalMMIData->Count;
- int i, SelectedNum = 0, deletedNum = 0;
- for(i=0; i<LocalMMIDataCount; i++)
- {
- if( lbLocalMMIData->Selected[i] )
- {
- SelectedNum++;
- }
- }
- while( SelectedNum != 0)
- {
- for(i=lbLocalMMIData->Count-1; i>=0; i--)
- {
- if( lbLocalMMIData->Selected[i] )
- {
- lbLocalMMIData->Items->Delete(i );
- SelectedNum--;
- deletedNum++;
- }
- }
- }
- if(rbFullScreen->Checked == true)
- {
- write_local_default_fullscreen_file_setting();
- local_default_fullscreen_file_count = local_default_fullscreen_file_count - lbLocalMMIData->SelCount;
- }
- else if(RadioButtonAssociate->Checked == true)
- {
- write_local_default_associate_file_setting();
- local_default_associate_file_count = local_default_associate_file_count - lbLocalMMIData->SelCount;
- }
- else if(RadioButtonEMS->Checked == true)
- {
- write_local_default_EMS_file_setting();
- local_default_EMS_file_count = local_default_EMS_file_count - lbLocalMMIData->SelCount;
- }
- else if(rbMidi->Checked == true)
- {
- write_local_default_midi_file_setting();
- local_default_midi_file_count = local_default_midi_file_count - lbLocalMMIData->SelCount;
- }
- else if(rbiMelody->Checked == true)
- {
- write_local_default_imelody_file_setting();
- local_default_imelody_file_count = local_default_imelody_file_count - lbLocalMMIData->SelCount;
- }
- }
- }
- //---------------------------------------------------------------------------
- void TfrmMMIDataDownload::write_local_default_fullscreen_file_setting(void)
- {
- // erase local graph file section
- int i;
- for(i=0; i< local_default_fullscreen_file_count; i++)
- {
- delete_local_default_fullscreen_file_key("MF_setup.txt", Application->ExeName, IntToStr(i+1));
- }
- // write local graph file name
- for(i=0; i<lbLocalMMIData->Items->Count; i++)
- {
- write_local_default_fullscreen_file_name("MF_setup.txt", Application->ExeName, i+1, lbLocalMMIData->Items->Strings[i].c_str());
- }
- // write local graph file count
- write_local_default_fullscreen_file_count("MF_setup.txt", Application->ExeName, IntToStr(lbLocalMMIData->Items->Count));
- }
- //---------------------------------------------------------------------------
- void TfrmMMIDataDownload::write_local_default_associate_file_setting(void)
- {
- // erase local graph file section
- int i;
- for(i=0; i< local_default_associate_file_count; i++)
- {
- delete_local_default_associate_file_key("MF_setup.txt", Application->ExeName, IntToStr(i+1));
- }
- // write local graph file name
- for(i=0; i<lbLocalMMIData->Items->Count; i++)
- {
- write_local_default_associate_file_name("MF_setup.txt", Application->ExeName, i+1, lbLocalMMIData->Items->Strings[i].c_str());
- }
- // write local graph file count
- write_local_default_associate_file_count("MF_setup.txt", Application->ExeName, IntToStr(lbLocalMMIData->Items->Count));
- }
- //---------------------------------------------------------------------------
- void TfrmMMIDataDownload::write_local_default_EMS_file_setting(void)
- {
- // erase local graph file section
- int i;
- for(i=0; i< local_default_EMS_file_count; i++)
- {
- delete_local_default_EMS_file_key("MF_setup.txt", Application->ExeName, IntToStr(i+1));
- }
- // write local graph file name
- for(i=0; i<lbLocalMMIData->Items->Count; i++)
- {
- write_local_default_EMS_file_name("MF_setup.txt", Application->ExeName, i+1, lbLocalMMIData->Items->Strings[i].c_str());
- }
- // write local graph file count
- write_local_default_EMS_file_count("MF_setup.txt", Application->ExeName, IntToStr(lbLocalMMIData->Items->Count));
- }
- //---------------------------------------------------------------------------
- void TfrmMMIDataDownload::write_local_default_midi_file_setting(void)
- {
- // erase local file section
- int i;
- for(i=0; i< local_default_midi_file_count; i++)
- {
- delete_local_default_midi_file_key("MF_setup.txt", Application->ExeName, IntToStr(i+1));
- }
- // write local file name
- for(i=0; i<lbLocalMMIData->Items->Count; i++)
- {
- write_local_default_midi_file_name("MF_setup.txt", Application->ExeName, i+1, lbLocalMMIData->Items->Strings[i].c_str());
- }
- // write local file count
- write_local_default_midi_file_count("MF_setup.txt", Application->ExeName, IntToStr(lbLocalMMIData->Items->Count));
- }
- //---------------------------------------------------------------------------
- void TfrmMMIDataDownload::write_local_default_imelody_file_setting(void)
- {
- // erase local file section
- int i;
- for(i=0; i< local_default_imelody_file_count; i++)
- {
- delete_local_default_imelody_file_key("MF_setup.txt", Application->ExeName, IntToStr(i+1));
- }
- // write local file name
- for(i=0; i<lbLocalMMIData->Items->Count; i++)
- {
- write_local_default_imelody_file_name("MF_setup.txt", Application->ExeName, i+1, lbLocalMMIData->Items->Strings[i].c_str());
- }
- // write local file count
- write_local_default_imelody_file_count("MF_setup.txt", Application->ExeName, IntToStr(lbLocalMMIData->Items->Count));
- }
- ///////////////////////////////////////////////////////////////////////////////
- // read FAT path from file
- void TfrmMMIDataDownload::read_DEFAULT_PATH(void)
- {
- as_default_FAT_fullscreen_path = read_DEFAULT_FULLSCREEN_PATH ( "MF_setup.txt",
- Application->ExeName
- );
- as_default_FAT_associate_path = read_DEFAULT_ASSOCIATE_PATH ("MF_setup.txt",
- Application->ExeName
- );
- as_default_FAT_EMS_path = read_DEFAULT_EMS_PATH ("MF_setup.txt",
- Application->ExeName
- );
- as_default_FAT_midi_path = read_DEFAULT_MIDI_PATH ("MF_setup.txt",
- Application->ExeName
- );
- as_default_FAT_imelody_path = read_DEFAULT_IMELODY_PATH ("MF_setup.txt",
- Application->ExeName
- );
- }
- /////////////////////////////////////////////////////////////////////////////////////////////
- void TfrmMMIDataDownload::ConfirmCallback_MMIDataDownload( void )
- {
- int state = MMI_FILE_Object.ConfirmState;
- if( state==STATE_MMI_GRAPH_FILE_DOWNLOAD_OK )
- {
- }
- else if( state==STATE_MMI_GRAPH_FILE_DOWNLOAD_FAIL )
- {
- Application->MessageBox( "Execution Failure : MMI data download", "FAILURE", MB_OK );
- }
- else if( state==STATE_MMI_GRAPH_FILE_DOWNLOAD_TIMEOUT )
- {
- Application->MessageBox( "Execution Timeout : MMI data download", "TIMEOUT", MB_OK );
- }
- else if( state==STATE_MMI_GRAPH_FILE_DOWNLOAD_STOP )
- {
- }
- }
- //////////////////////////////////////////////////////////////////////////////////////////////
- void TfrmMMIDataDownload::ShowFileSelected(void)
- {
- lbLocalMMIData->Clear();
- //*********************************** Full screen *********************************************
- if(rbFullScreen->Checked)
- {
- AnsiString as_temp_local_default_fullscreen_file_count;
- LabelListBoxMMIData->Caption = "Full screen file selected";
- as_temp_local_default_fullscreen_file_count = read_local_default_fullscreen_file_count(
- "MF_setup.txt",
- Application->ExeName
- );
- if( as_temp_local_default_fullscreen_file_count != "")
- {
- local_default_fullscreen_file_count = as_temp_local_default_fullscreen_file_count.ToInt();
- if(local_default_fullscreen_file_count != 0)
- {
- btnRemoveFromList->Enabled = true;
- }
- }
- else
- {
- local_default_fullscreen_file_count = 0;
- }
- int i;
- AnsiString as_temp_local_default_fullscreen_file_name;
- for (i=0; i< local_default_fullscreen_file_count; i++)
- {
- as_temp_local_default_fullscreen_file_name = read_local_default_fullscreen_file_name(
- "MF_setup.txt",
- Application->ExeName,
- IntToStr(i+1)
- );
- lbLocalMMIData->Items->Strings[i] = as_temp_local_default_fullscreen_file_name;
- }
- }
- //*********************************** Assocaite *********************************************
- else if(RadioButtonAssociate->Checked)
- {
- AnsiString as_temp_local_default_associate_file_count;
- LabelListBoxMMIData->Caption = "Associate file selected";
- as_temp_local_default_associate_file_count = read_local_default_associate_file_count(
- "MF_setup.txt",
- Application->ExeName
- );
- if( as_temp_local_default_associate_file_count != "")
- {
- local_default_associate_file_count = as_temp_local_default_associate_file_count.ToInt();
- if(local_default_associate_file_count != 0)
- {
- btnRemoveFromList->Enabled = true;
- }
- }
- else
- {
- local_default_associate_file_count = 0;
- }
- int i;
- AnsiString as_temp_local_default_associate_file_name;
- for (i=0; i< local_default_associate_file_count; i++)
- {
- as_temp_local_default_associate_file_name = read_local_default_associate_file_name(
- "MF_setup.txt",
- Application->ExeName,
- IntToStr(i+1)
- );
- lbLocalMMIData->Items->Strings[i] = as_temp_local_default_associate_file_name;
- }
- }
- //*********************************** EMS *********************************************
- else if(RadioButtonEMS->Checked)
- {
- AnsiString as_temp_local_default_EMS_file_count;
- LabelListBoxMMIData->Caption = "EMS file selected";
- as_temp_local_default_EMS_file_count = read_local_default_EMS_file_count(
- "MF_setup.txt",
- Application->ExeName
- );
- if( as_temp_local_default_EMS_file_count != "")
- {
- local_default_EMS_file_count = as_temp_local_default_EMS_file_count.ToInt();
- if(local_default_EMS_file_count != 0)
- {
- btnRemoveFromList->Enabled = true;
- }
- }
- else
- {
- local_default_EMS_file_count = 0;
- }
- int i;
- AnsiString as_temp_local_default_EMS_file_name;
- for (i=0; i< local_default_EMS_file_count; i++)
- {
- as_temp_local_default_EMS_file_name = read_local_default_EMS_file_name(
- "MF_setup.txt",
- Application->ExeName,
- IntToStr(i+1)
- );
- lbLocalMMIData->Items->Strings[i] = as_temp_local_default_EMS_file_name;
- }
- }
- //*********************************** Midi *********************************************
- else if(rbMidi->Checked)
- {
- AnsiString as_temp_local_default_midi_file_count;
- LabelListBoxMMIData->Caption = "Midi file selected";
- as_temp_local_default_midi_file_count = read_local_default_midi_file_count(
- "MF_setup.txt",
- Application->ExeName
- );
- if( as_temp_local_default_midi_file_count != "")
- {
- local_default_midi_file_count = as_temp_local_default_midi_file_count.ToInt();
- if(local_default_midi_file_count != 0)
- {
- btnRemoveFromList->Enabled = true;
- }
- }
- else
- {
- local_default_midi_file_count = 0;
- }
- int i;
- AnsiString as_temp_local_default_midi_file_name;
- for (i=0; i< local_default_midi_file_count; i++)
- {
- as_temp_local_default_midi_file_name = read_local_default_midi_file_name(
- "MF_setup.txt",
- Application->ExeName,
- IntToStr(i+1)
- );
- lbLocalMMIData->Items->Strings[i] = as_temp_local_default_midi_file_name;
- }
- } // rbMIdi checked
- //*********************************** iMelody *********************************************
- else if(rbiMelody->Checked)
- {
- AnsiString as_temp_local_default_imelody_file_count;
- LabelListBoxMMIData->Caption = "iMelody file selected";
- as_temp_local_default_imelody_file_count = read_local_default_imelody_file_count(
- "MF_setup.txt",
- Application->ExeName
- );
- if( as_temp_local_default_imelody_file_count != "")
- {
- local_default_imelody_file_count = as_temp_local_default_imelody_file_count.ToInt();
- if(local_default_imelody_file_count != 0)
- {
- btnRemoveFromList->Enabled = true;
- }
- }
- else
- {
- local_default_imelody_file_count = 0;
- }
- int i;
- AnsiString as_temp_local_default_imelody_file_name;
- for (i=0; i< local_default_imelody_file_count; i++)
- {
- as_temp_local_default_imelody_file_name = read_local_default_imelody_file_name(
- "MF_setup.txt",
- Application->ExeName,
- IntToStr(i+1)
- );
- lbLocalMMIData->Items->Strings[i] = as_temp_local_default_imelody_file_name;
- }
- }
- }
- ///////////////////////////////////////////////////////////////////////////////////////////
- void TfrmMMIDataDownload::ModifyLastRadioButtonChecked(void)
- {
- if(rbFullScreen->Checked)
- {
- lastRadioButtonFullscreenChecked = true;
- lastRadioButtonAssociateChecked = false;
- lastRadioButtonEMSChecked = false;
- lastRadioButtonMidiChecked = false;
- lastRadioButtoniMelodyChecked = false;
- }
- else if(RadioButtonAssociate->Checked)
- {
- lastRadioButtonFullscreenChecked = false;
- lastRadioButtonAssociateChecked = true;
- lastRadioButtonEMSChecked = false;
- lastRadioButtonMidiChecked = false;
- lastRadioButtoniMelodyChecked = false;
- }
- else if(RadioButtonEMS->Checked)
- {
- lastRadioButtonFullscreenChecked = false;
- lastRadioButtonAssociateChecked = false;
- lastRadioButtonEMSChecked = true;
- lastRadioButtonMidiChecked = false;
- lastRadioButtoniMelodyChecked = false;
- }
- else if(rbMidi->Checked)
- {
- lastRadioButtonFullscreenChecked = false;
- lastRadioButtonAssociateChecked = false;
- lastRadioButtonEMSChecked = false;
- lastRadioButtonMidiChecked = true;
- lastRadioButtoniMelodyChecked = false;
- }
- else if(rbiMelody->Checked)
- {
- lastRadioButtonFullscreenChecked = false;
- lastRadioButtonAssociateChecked = false;
- lastRadioButtonEMSChecked = false;
- lastRadioButtonMidiChecked = false;
- lastRadioButtoniMelodyChecked = true;
- }
- }
- //-----------------------------------------------------------------------------
- void __fastcall TfrmMMIDataDownload::rbFullScreenClick(
- TObject *Sender)
- {
- if(lastRadioButtonFullscreenChecked == false)
- {
- SaveLastFileShow();
- ShowFileSelected();
- ModifyLastRadioButtonChecked();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmMMIDataDownload::RadioButtonAssociateClick(
- TObject *Sender)
- {
- if(lastRadioButtonAssociateChecked == false)
- {
- SaveLastFileShow();
- ShowFileSelected();
- ModifyLastRadioButtonChecked();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmMMIDataDownload::RadioButtonEMSClick(TObject *Sender)
- {
- if(lastRadioButtonEMSChecked == false)
- {
- SaveLastFileShow();
- ShowFileSelected();
- ModifyLastRadioButtonChecked();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmMMIDataDownload::rbMidiClick(TObject *Sender)
- {
- if(lastRadioButtonMidiChecked == false)
- {
- SaveLastFileShow();
- ShowFileSelected();
- ModifyLastRadioButtonChecked();
- }
- }
- //---------------------------------------------------------------------------
- void TfrmMMIDataDownload::read_MAX_FILE_COUNT(void)
- {
- as_MAX_FULLSCREEN_FILE_COUNT = read_MAX_FULLSCREEN_FILE_COUNT(
- "MF_setup.txt",
- Application->ExeName
- );
- as_MAX_ASSOCIATE_FILE_COUNT = read_MAX_ASSOCIATE_FILE_COUNT(
- "MF_setup.txt",
- Application->ExeName
- );
- as_MAX_EMS_FILE_COUNT = read_MAX_EMS_FILE_COUNT(
- "MF_setup.txt",
- Application->ExeName
- );
- as_MAX_MIDI_FILE_COUNT = read_MAX_MIDI_FILE_COUNT(
- "MF_setup.txt",
- Application->ExeName
- );
- as_MAX_IMELODY_FILE_COUNT = read_MAX_IMELODY_FILE_COUNT(
- "MF_setup.txt",
- Application->ExeName
- );
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- void TfrmMMIDataDownload::show_download_type(void)
- {
- AnsiString as_temp_download_type;
- as_temp_download_type = read_download_type("MF_setup.txt", Application->ExeName);
- as_temp_download_type = LowerCase(as_temp_download_type);
- if(as_temp_download_type.AnsiCompare("fullscreen") == 0)
- {
- rbFullScreen->Checked = true;
- }
- else if(as_temp_download_type.AnsiCompare("associate") == 0)
- {
- RadioButtonAssociate->Checked = true;
- }
- else if(as_temp_download_type.AnsiCompare("ems") == 0)
- {
- RadioButtonEMS->Checked = true;
- }
- else if(as_temp_download_type.AnsiCompare("midi") == 0)
- {
- rbMidi->Checked = true;
- }
- else if(as_temp_download_type.AnsiCompare("imelody") == 0)
- {
- rbiMelody->Checked = true;
- }
- }
- //------------------------------------------------------------------------------
- void __fastcall TfrmMMIDataDownload::TimerMMIDataDownloadTimer(
- TObject *Sender)
- {
- if( IsRunning_MMIData == false)
- {
- TimerMMIDataDownload->Enabled = false;
- // enable button
- btnDownloadToFAT->Enabled = true;
- if (MetaResult_MMIData == META_RESULT_SUCCESSFUL)
- {
- sbMMIData->Panels->Items[0]->Text = (AnsiString) " Write to FAT successful";
- }
- else
- {
- sbMMIData->Panels->Items[0]->Text = (AnsiString) " Write to FAT fail";
- Application->MessageBox( "Execution Failure : Write to FAT", "FAILURE", MB_OK );
- }
- } // if( IsRunning_MMIData == false)
- }
- //------------------------------------------------------------------------------
- void TfrmMMIDataDownload::SaveLastFileShow(void)
- {
- if(lastRadioButtonFullscreenChecked == true)
- {
- write_local_default_fullscreen_file_setting();
- }
- else if(lastRadioButtonAssociateChecked == true)
- {
- write_local_default_associate_file_setting();
- }
- else if(lastRadioButtonEMSChecked == true)
- {
- write_local_default_EMS_file_setting();
- }
- else if(lastRadioButtonMidiChecked == true)
- {
- write_local_default_midi_file_setting();
- }
- else if(lastRadioButtoniMelodyChecked == true)
- {
- write_local_default_imelody_file_setting();
- }
- }
- //=================================================================================================
- //---------------------------------------------------------------------------
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- void __fastcall TfrmMMIDataDownload::btnDownloadToFATClick(
- TObject *Sender)
- {
- // disable button
- btnDownloadToFAT->Enabled = false;
- read_DEFAULT_PATH();
- set_DEFAULT_PATH();
- for(int i=0; i< lbLocalMMIData->Items->Count; i++)
- {
- getFilenameFromStr(lbLocalMMIData->Items->Strings[i].c_str(), as_default_FAT_name);
- strcpy(MMI_FILE_Object.FAT_filepath[i], (as_default_FAT_path + as_default_FAT_name).c_str());
- strcpy(MMI_FILE_Object.local_filepath[i], lbLocalMMIData->Items->Strings[i].c_str());
- }
- TimerMMIDataDownload->Interval = 1000;
- TimerMMIDataDownload->Enabled = true;
- sbMMIData->Panels->Items[0]->Text = (AnsiString) " Write to FAT Progressing";
- ActiveMan->SetActiveFunction( ::REQ_Write_To_FAT );
- }
- ////////////////////////////// Upload //////////////////////////////////////////
- //---------------------------------------------------------------------------
- //---------------------------------------------------------------------------
- void __fastcall TfrmMMIDataDownload::BitBtnUploadFromFATClick(
- TObject *Sender)
- {
- // disable BitBtnDownloadToFAT, BitBtnUploadFromFAT
- btnDownloadToFAT->Enabled = false;
- //BitBtnUploadFromFAT->Enabled = false;
- read_DEFAULT_PATH();
- set_DEFAULT_PATH();
- Index_MMIData = 0;
- as_default_FAT_name = "spring" + IntToStr(Index_MMIData);
- as_MMIDataStr = "spring" + IntToStr(Index_MMIData);
- TimerMMIDataUpload->Interval = 1000;
- TimerMMIDataUpload->Enabled = true;
- ActiveMan->SetActiveFunction( ::REQ_Read_From_FAT );
- }
- ////////////////////////////////////////////////////////////////////////////////
- void __fastcall TfrmMMIDataDownload::TimerMMIDataUploadTimer(
- TObject *Sender)
- {
- if( IsRunning_MMIData == false)
- {
- if( Index_MMIData == 10)
- {
- TimerMMIDataUpload->Enabled = false;
- // enable BitBtnDownloadToFAT, BitBtnUploadFromFAT
- btnDownloadToFAT->Enabled = true;
- // BitBtnUploadFromFAT->Enabled = true;
- if (MetaResult_MMIData == META_RESULT_SUCCESSFUL)
- {
- sbMMIData->Panels->Items[0]->Text = (AnsiString) " Read from FAT successful";
- }
- else
- {
- sbMMIData->Panels->Items[0]->Text = (AnsiString) " Read from FAT fail";
- Application->MessageBox( "Execution Failure : Read from FAT", "FAILURE", MB_OK );
- }
- }
- else
- {
- if (MetaResult_MMIData == META_RESULT_SUCCESSFUL)
- {
- Index_MMIData++;
- sbMMIData->Panels->Items[0]->Text = (AnsiString) " Read from FAT Progressing";
- }
- else
- {
- TimerMMIDataUpload->Enabled = false;
- // enable BitBtnDownloadToFAT, BitBtnUploadFromFAT
- btnDownloadToFAT->Enabled = true;
- // BitBtnUploadFromFAT->Enabled = true;
- sbMMIData->Panels->Items[0]->Text = (AnsiString) " Read from FAT fail";
- Application->MessageBox( "Execution Failure : Read from FAT", "FAILURE", MB_OK );
- }
- }
- } // if( IsRunning_MMIData == false)
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmMMIDataDownload::rbiMelodyClick(TObject *Sender)
- {
- if(lastRadioButtoniMelodyChecked == false)
- {
- SaveLastFileShow();
- ShowFileSelected();
- ModifyLastRadioButtonChecked();
- }
- }
- //---------------------------------------------------------------------------
- void TfrmMMIDataDownload::REQ_Write_To_FAT(void)
- {
- MMI_FILE_Object.REQ_Write_To_FAT(lbLocalMMIData->Items->Count);
- }
- //---------------------------------------------------------------------------------------------
- //---------------------------------------------------------------------------
- void TfrmMMIDataDownload::write_download_type(
- AnsiString asSetupFile,
- AnsiString asExeName,
- AnsiString as_download_type
- )
- {
- AnsiString asPath;
- if ( getPathFromStr(asExeName, asPath) &&
- withPath( asPath) &&
- !withPath( asSetupFile)
- )
- {
- asSetupFile = asPath + asSetupFile;
- }
- TIniFile *ini;
- try
- {
- ini = new TIniFile( asSetupFile );
- if(ini != NULL)
- {
- ini->WriteString("MMI data download table", "download_type", as_download_type );
- delete ini;
- ini = NULL;
- }
- }
- catch (...)
- {
- ShowMessage( " META factory : write setup file : " + asSetupFile + " error ");
- }
- }