form_DatabaseChange.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:10k
- /*****************************************************************************
- * 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_DatabaseChange.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * Database change 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>
- #pragma hdrstop
- #include "form_DatabaseChange.h"
- #include "form_main.h"
- #include "man_fdm.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TfrmDatabaseChange *frmDatabaseChange;
- extern CNVRAMMan *NVRAMMan;
- //---------------------------------------------------------------------------
- static void CNF_NVRAM_Get_Disk_Info( void )
- { frmDatabaseChange->CNF_NVRAM_Get_Disk_Info();
- }
- //---------------------------------------------------------------------------
- __fastcall TfrmDatabaseChange::TfrmDatabaseChange(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmDatabaseChange::btnCompareDatabaseClick(
- TObject *Sender)
- {
- bool ok;
- char str[512];
- if( ! NVRAMMan->Get_IsInit() )
- {
- frmMainSel->mnuFDMDatabaseClick(Sender);
- }
- if( ! NVRAMMan->Get_IsInit() )
- {
- sbDBChange->Panels->Items[0]->Text = (AnsiString) " NVRAM database file initialization fail";
- Application->MessageBox( "Execution Failure : NVRAM database file initialization", "FAILURE", MB_OK );
- return;
- }
- ok = OpenDialog->Execute();
- if( !ok ) return;
- strcpy( str, OpenDialog->FileName.c_str() );
- MetaResult = DATABASE_COMPARE_Object.Req_NVRAM_SWC_Database_Compare(str, &NumOfNewAddLID, &NumOfModifiedLID, &NumOfDeletedLID);
- if( MetaResult == META_SUCCESS)
- {
- stNumOfNewAddedLID->Caption = IntToStr(NumOfNewAddLID);
- stNumOfModifiedLID->Caption = IntToStr(NumOfModifiedLID);
- stNumOfDeletedLID->Caption = IntToStr(NumOfDeletedLID);
- if(NewAddLIDBuf==0)
- {
- NewAddLIDBuf = new LID_Info[NumOfNewAddLID];
- }
- if(ModifiedLIDBuf==0)
- {
- ModifiedLIDBuf = new LID_Info[NumOfModifiedLID];
- }
- if(DeletedLIDBuf==0)
- {
- DeletedLIDBuf = new LID_Info[NumOfDeletedLID];
- }
- MetaResult = DATABASE_COMPARE_Object.Req_NVRAM_SWC_Get_Database_Compare_Result(NewAddLIDBuf, NumOfNewAddLID, ModifiedLIDBuf, NumOfModifiedLID, DeletedLIDBuf, NumOfDeletedLID);
- if( MetaResult == META_SUCCESS)
- {
- int i;
- lbNewAddedLID->Clear();
- lbModifiedLID->Clear();
- lbDeletedLID->Clear();
- for (i=0; i< NumOfNewAddLID; i++)
- {
- lbNewAddedLID->Items->Add( (AnsiString) NewAddLIDBuf[i].LID);
- }
- for (i=0; i< NumOfModifiedLID; i++)
- {
- lbModifiedLID->Items->Add( (AnsiString) ModifiedLIDBuf[i].LID);
- }
- for (i=0; i< NumOfDeletedLID; i++)
- {
- lbDeletedLID->Items->Add( (AnsiString) DeletedLIDBuf[i].LID);
- }
- }
- delete NewAddLIDBuf;
- NewAddLIDBuf = 0;
- delete ModifiedLIDBuf;
- ModifiedLIDBuf = 0;
- delete DeletedLIDBuf;
- DeletedLIDBuf = 0;
- DATABASE_COMPARE_Object.ConfirmCallback = ::CNF_NVRAM_Get_Disk_Info;
- DATABASE_COMPARE_Object.Req_NVRAM_SWC_Check_FAT_FreeSpace();
- }
- if ( MetaResult != META_SUCCESS )
- {
- sbDBChange->Panels->Items[0]->Text = (AnsiString) " Get database compare result fail";
- Application->MessageBox( "Execution Fail : get database compare result", "FAIL", MB_OK );
- }
- }
- //---------------------------------------------------------------------------
- void TfrmDatabaseChange::CNF_NVRAM_Get_Disk_Info( void )
- {
- int state = DATABASE_COMPARE_Object.Get_ConfirmState();
- if( state == STATE_DATABASECOMPARE_OK )
- {
- stNVRAMSize->Caption = IntToStr(DATABASE_COMPARE_Object.CNF_NVRAM_GetDiskInfo.target_nvramsize);
- stFATFreeSpace->Caption = IntToStr(DATABASE_COMPARE_Object.CNF_NVRAM_GetDiskInfo.target_freespace);
- stOverhead->Caption = IntToStr(DATABASE_COMPARE_Object.CNF_NVRAM_GetDiskInfo.target_overhead);
- stNewDatabaseNVRAMSize->Caption = IntToStr(DATABASE_COMPARE_Object.CNF_NVRAM_GetDiskInfo.newdb_nvramsize);
- }
- else if( state == STATE_DATABASECOMPARE_FAIL )
- { if( DATABASE_COMPARE_Object.Get_MetaResult() != META_SUCCESS)
- {
- sbDBChange->Panels->Items[0]->Text = (AnsiString) " Can't retrieve info from target fail";
- Application->MessageBox( "Execution Fail : can't retrieve info from target", "FAIL", MB_OK );
- }
- else if( DATABASE_COMPARE_Object.CNF_NVRAM_GetDiskInfo.status == 1) // [ERROR] can't retrieve info from target
- {
- sbDBChange->Panels->Items[0]->Text = (AnsiString) " Can't retrieve info from target error";
- Application->MessageBox( "Execution Error : can't retrieve info from target", "ERROR", MB_OK );
- }
- else // [ERROR] freespace is not enough to upgrade to new NVRAM
- {
- stNVRAMSize->Caption = IntToStr(DATABASE_COMPARE_Object.CNF_NVRAM_GetDiskInfo.target_nvramsize);
- stFATFreeSpace->Caption = IntToStr(DATABASE_COMPARE_Object.CNF_NVRAM_GetDiskInfo.target_freespace);
- stOverhead->Caption = IntToStr(DATABASE_COMPARE_Object.CNF_NVRAM_GetDiskInfo.target_overhead);
- stNewDatabaseNVRAMSize->Caption = IntToStr(DATABASE_COMPARE_Object.CNF_NVRAM_GetDiskInfo.newdb_nvramsize);
- sbDBChange->Panels->Items[0]->Text = (AnsiString) " Freespace is not enough to upgrade to new NVRAM error";
- Application->MessageBox( "Execution Error : freespace is not enough to upgrade to new NVRAM", "ERROR", MB_OK );
- }
- }
- else if( state == STATE_DATABASECOMPARE_TIMEOUT )
- {
- sbDBChange->Panels->Items[0]->Text = (AnsiString) " Database compare timeout";
- Application->MessageBox( "Execution Timeout : Database compare", "TIMEOUT", MB_OK );
- }
- else if( state == STATE_DATABASECOMPARE_STOP )
- {
- sbDBChange->Panels->Items[0]->Text = (AnsiString) " Database compare stop";
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmDatabaseChange::btnDisableForceUpgradeClick(
- TObject *Sender)
- {
- DATABASE_COMPARE_Object.Req_NVRAM_SWC_Disable_ForceUpgrade();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmDatabaseChange::btnEnableForceUpgradeClick(
- TObject *Sender)
- {
- DATABASE_COMPARE_Object.Req_NVRAM_SWC_Enable_ForceUpgrade();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmDatabaseChange::btnGetFATFreeSpaceClick(
- TObject *Sender)
- {
- DATABASE_COMPARE_Object.ConfirmCallback = ::CNF_NVRAM_Get_Disk_Info;
- DATABASE_COMPARE_Object.Req_NVRAM_SWC_Check_FAT_FreeSpace();
- }
- //---------------------------------------------------------------------------