📄 commdbclass.cpp
字号:
#include "commdbClass.h"
#include "f32file.h"
#include <COMMDB.H>
/*****************************************************************************
COPYRIGHT All rights reserved Sony Ericsson Mobile Communications AB 2006.
The software is the copyrighted work of Sony Ericsson Mobile Communications AB.
The use of the software is subject to the terms of use or of the end-user license
agreement which accompanies or is included with the software. The software is
provided "as is" and Sony Ericsson specifically disclaim any warranty or
condition whatsoever regarding merchantability or fitness for a specific
purpose, title or non-infringement. No warranty of any kind is made in
relation to the condition, suitability, availability, accuracy, reliability,
merchantability and/or non-infringement of the software provided herein.
*****************************************************************************/
CcommdbClass* CcommdbClass::NewLC()
{
CcommdbClass* self = new (ELeave) CcommdbClass();
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
CcommdbClass* CcommdbClass::NewL()
{
CcommdbClass* self = CcommdbClass::NewLC();
CleanupStack::Pop(self);
return self;
}
CcommdbClass::CcommdbClass()
{
}
CcommdbClass::~CcommdbClass()
{
}
void CcommdbClass::ConstructL()
{
}
void CcommdbClass::CreteOutputFileL()
{
_LIT8(KSign,"############################################################");
_LIT(KFileName, "C:\\media files\\other\\cedout.cfg");
_LIT8(KTableName, "\r\nTable name: %S \r\n\r\n");
_LIT8(KNewLine,"\r\n");
//ERROR MESSAGE
_LIT8(KErrorMessage, "\r\n Table %S was not found \r\n");
//FOR GENERAL
_LIT8(KRecordName, " Record name: %S \r\n");
_LIT8(KCommDbId, " CommDb id: %d\r\n");
///FOR IAP TABLE
_LIT8(KIAPServiceType," IAPServiceType: %S \r\n");
_LIT8(KIAPBearerType," IAPBearerType: %S \r\n");
_LIT8(KIAPService, " IAPService: %d\r\n");
_LIT8(KIAPBearer, " IAPBearer: %d\r\n");
_LIT8(KIAPNetwork, " IAPNetwork %d\r\n");
_LIT8(KIAPNetworkweighting, " IAPNetworkwighting: %d\r\n");
_LIT8(KIAPLocation, " IAPLocation: %d\r\n\r\n");
//////
TBuf8<100>outputbuffer;
TBuf8<KCommsDbSvrMaxColumnNameLength> mybuffer8;
TBuf<KCommsDbSvrMaxColumnNameLength> mybuffer;
TUint32 CommDbId;
TInt error;
RFile file;
RFs fsSession;
//connects to the fileserver
User::LeaveIfError(fsSession.Connect());
CleanupClosePushL(fsSession);
//creates a new file replacing any existing file with the same name
User::LeaveIfError(file.Replace(fsSession,KFileName,EFileStreamText|EFileWrite|EFileShareAny));
User::LeaveIfError(file.Write(KSign));
TInt MoreRecords;
//instance to the CommDb
CCommsDatabase* commDb = CCommsDatabase::NewL();
CleanupStack::PushL(commDb);
CCommsDbTableView* myView;
//////////////////////NETWORK TABLE/////////////////////////////////
//gets a new CCommsDbTableView FOR NETWORK TABLE
TRAP(error,myView = commDb->OpenTableLC(TPtrC(NETWORK));CleanupStack::Pop(myView));
CleanupStack::PushL(myView);
if(error == KErrNone)
{
myView->GetTableName(mybuffer);
mybuffer8.Copy(mybuffer);
//writes the table name to the file
outputbuffer.Format(KTableName(),&mybuffer8);
User::LeaveIfError(file.Write(outputbuffer));
//access the first record of the table;
MoreRecords = myView->GotoFirstRecord();
while(MoreRecords == KErrNone)
{
myView->ReadUintL(TPtrC(COMMDB_ID),CommDbId);
outputbuffer.Format(KCommDbId,CommDbId);
User::LeaveIfError(file.Write(outputbuffer));
myView->ReadTextL(TPtrC(COMMDB_NAME),mybuffer8);
outputbuffer.Format(KRecordName(),&mybuffer8);
outputbuffer.Append(KNewLine);
User::LeaveIfError(file.Write(outputbuffer));
MoreRecords = myView->GotoNextRecord();
}
}
else
{
mybuffer.Copy(TPtrC(NETWORK));
mybuffer8.Copy(mybuffer);
outputbuffer.Format(KErrorMessage(),&mybuffer8);
outputbuffer.Append(KNewLine);
User::LeaveIfError(file.Write(outputbuffer));
}
CleanupStack::PopAndDestroy(); //CCommsDbTableView
myView = NULL;
User::LeaveIfError(file.Write(KSign));
////////////////////////////////////////////////
//////////////IAP TABLE/////////////////////////
TRAP(error,myView = commDb->OpenTableLC(TPtrC(IAP));CleanupStack::Pop(myView));
CleanupStack::PushL(myView);
if(KErrNone == error)
{
myView->GetTableName(mybuffer);
mybuffer8.Copy(mybuffer);
//writes the table name to the file
outputbuffer.Format(KTableName(),&mybuffer8);
User::LeaveIfError(file.Write(outputbuffer));
//access the first record of the table;
MoreRecords = myView->GotoFirstRecord();
while(MoreRecords == KErrNone)
{
myView->ReadUintL(TPtrC(COMMDB_ID),CommDbId);
outputbuffer.Format(KCommDbId,CommDbId);
User::LeaveIfError(file.Write(outputbuffer));
myView->ReadTextL(TPtrC(COMMDB_NAME),mybuffer8);
outputbuffer.Format(KRecordName(),&mybuffer8);
User::LeaveIfError(file.Write(outputbuffer));
myView->ReadUintL(TPtrC(IAP_SERVICE),CommDbId);
outputbuffer.Format(KIAPService,CommDbId);
User::LeaveIfError(file.Write(outputbuffer));
myView->ReadTextL(TPtrC(IAP_SERVICE_TYPE),mybuffer8);
outputbuffer.Format(KIAPServiceType(),&mybuffer8);
User::LeaveIfError(file.Write(outputbuffer));
myView->ReadUintL(TPtrC(IAP_BEARER),CommDbId);
outputbuffer.Format(KIAPBearer,CommDbId);
User::LeaveIfError(file.Write(outputbuffer));
myView->ReadTextL(TPtrC(IAP_BEARER_TYPE),mybuffer8);
outputbuffer.Format(KIAPBearerType(),&mybuffer8);
User::LeaveIfError(file.Write(outputbuffer));
myView->ReadUintL(TPtrC(IAP_NETWORK),CommDbId);
outputbuffer.Format(KIAPNetwork,CommDbId);
User::LeaveIfError(file.Write(outputbuffer));
myView->ReadUintL(TPtrC(IAP_NETWORK_WEIGHTING),CommDbId);
outputbuffer.Format(KIAPNetworkweighting,CommDbId);
User::LeaveIfError(file.Write(outputbuffer));
myView->ReadUintL(TPtrC(IAP_LOCATION),CommDbId);
outputbuffer.Format(KIAPLocation,CommDbId);
User::LeaveIfError(file.Write(outputbuffer));
MoreRecords = myView->GotoNextRecord();
}
}
else
{
mybuffer.Copy(TPtrC(IAP));
mybuffer8.Copy(mybuffer);
outputbuffer.Format(KErrorMessage(),&mybuffer8);
outputbuffer.Append(KNewLine);
User::LeaveIfError(file.Write(outputbuffer));
}
User::LeaveIfError(file.Write(KSign));
CleanupStack::PopAndDestroy(); //CCommsDbTableView
myView = NULL;
//////////////////////////////////////
////////////////////////////////////////////////
CleanupStack::PopAndDestroy(); //CCommsDB
CleanupStack::PopAndDestroy(&fsSession);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -