--- a/phoneengine/phonemodel/src/cpeparsermanufacturerhandler.cpp Tue Aug 31 15:14:29 2010 +0300
+++ b/phoneengine/phonemodel/src/cpeparsermanufacturerhandler.cpp Wed Sep 01 12:30:10 2010 +0100
@@ -17,11 +17,19 @@
// ==================== INCLUDE FILES ====================
+#include "cpeparsermanufacturerhandler.h"
+#include "mpephonemodelinternal.h"
#include <mpecallhandling.h>
#include <mpedatastore.h>
+#include <sysutil.h>
#include <talogger.h>
-#include "cpeparsermanufacturerhandler.h"
-#include "mpephonemodelinternal.h"
+
+
+// CONSTANTS
+const TInt KPESwVersionLineCount = 3;
+const TInt KPEVersionLineFeed = '\n';
+const TInt KPESalesModelNameMaxLength = 20;
+_LIT( KPESalesModelFileName, "Z:\\resource\\versions\\model.txt");
// ================= MEMBER FUNCTIONS =======================
@@ -36,13 +44,13 @@
iCallHandling( aCallHandling ),
iFsSession( aFsSession )
{
- TEFLOGSTRING( KTAOBJECT, "PE CPEParserManufacturerHandler::CPEParserManufacturerHandler()" );
+ TEFLOGSTRING( KTAOBJECT, "PE CPEParserManufacturerHandler::CPEParserManufacturerHandler()" );
}
// Destructor
CPEParserManufacturerHandler::~CPEParserManufacturerHandler()
{
- TEFLOGSTRING( KTAOBJECT, "PE CPEParserManufacturerHandler::~CPEParserManufacturerHandler()" );
+ TEFLOGSTRING( KTAOBJECT, "PE CPEParserManufacturerHandler::~CPEParserManufacturerHandler()" );
}
// -----------------------------------------------------------------------------
@@ -52,10 +60,29 @@
void CPEParserManufacturerHandler::ProcessCommandL(
TUint aCommand ) // aCommand command enumeration.
{
- TEFLOGSTRING( KTAINT, "PE CPEParserManufacturerHandler::ProcessCommandL" );
+ TEFLOGSTRING( KTAINT, "PE CPEParserManufacturerHandler::ProcessCommandL" );
switch ( aCommand )
{
+ case EShowVersion: // *#0000#
+ {
+ TEFLOGSTRING( KTAINT, "PE CPEParserManufacturerHandler::ProcessCommandL, EShowVersion" );
+
+ TPEPhoneIdentityParameters phoneIdentity;
+ phoneIdentity = iModel.DataStore()->PhoneIdentityParameters();
+ if ( GetSwVersionAndPhoneModelL( phoneIdentity.iRevision ) == KErrNone )
+ {
+ iModel.DataStore()->SetPhoneIdentityParameters( phoneIdentity );
+ iModel.SendMessage( MEngineMonitor::EPEMessageShowVersion );
+ }
+ else
+ {
+ iModel.SendMessage( MEngineMonitor::EPEMessageError );
+ TEFLOGSTRING( KTAERROR,
+ "PE CPEGSMPARSERMANUFACTURERHANDLER::PROCESSCOMMANDL: FAILED TO RETRIEVE SW VERSION" );
+ }
+ break;
+ }
case EBadPinChange:
{
iModel.SendMessage( MEngineMonitor::EPEMessageBadPin1Change );
@@ -86,6 +113,13 @@
iModel.SendMessage( MEngineMonitor::EPEMessageActivateRfsDeep );
break;
}
+ case EActivateWarranty:
+ //lint -fallthrough
+ case ELifeTimer:
+ {
+ iModel.SendMessage( MEngineMonitor::EPEMessageActivateWarrantyMode );
+ break;
+ }
case EShowBtAddress: // *#2820#
{
iModel.SendMessage( MEngineMonitor::EPEMessageShowBTDeviceAddress );
@@ -101,6 +135,11 @@
iModel.SendMessage( MEngineMonitor::EPEMessageShowWlanMacAddress );
break;
}
+ case EBTDebugMode: // *#2873#
+ {
+ iModel.SendMessage( MEngineMonitor::EPEMessageBTDebugMode );
+ break;
+ }
default:
{
TEFLOGSTRING( KTAERROR, "PE CPEGSMPARSERMANUFACTURERHANDLER::PROCESSCOMMANDL: UNEXPECTED COMMAND" );
@@ -165,4 +204,91 @@
}
}
+// -----------------------------------------------------------------------------
+// CPEParserManufacturerHandler::GetSwVersionAndPhoneModelL
+// Gets sw version from SysUtil::GetSwVersion and loads phone model information
+// from file. This information is set to aSwVersion.
+// -----------------------------------------------------------------------------
+//
+TInt CPEParserManufacturerHandler::GetSwVersionAndPhoneModelL(
+ TDes& aSwVersion )
+ {
+ TEFLOGSTRING( KTAINT, "PE CPEParserManufacturerHandler::GetSwVersionAndPhoneModelL" );
+
+ TInt errorCode = SysUtil::GetSWVersion( aSwVersion ) ;
+
+ TEFLOGSTRING2( KTAINT,
+ "PE CPEParserManufacturerHandler::GetSwVersionAndPhoneModelL > SysUtil::GetSWVersion, error code: %d",
+ errorCode );
+
+ if ( errorCode == KErrNone )
+ {
+ // Remove needless lines
+ RemoveLinesAfterThreeLines( aSwVersion );
+ // Add phone model
+ AppendPhoneModelL( aSwVersion );
+ }
+
+ return errorCode;
+ }
+
+// -----------------------------------------------------------------------------
+// CPEParserManufacturerHandler::RemoveNeedlessLinesL
+// Removes lines after 3 end-of-line (\n) chars.
+// -----------------------------------------------------------------------------
+//
+void CPEParserManufacturerHandler::RemoveLinesAfterThreeLines(
+ TDes& aSwVersion )
+ {
+ TEFLOGSTRING( KTAINT, "PE CPEParserManufacturerHandler::RemoveLinesAfterThreeLines" );
+
+ TInt lineFeedCount = 0;
+
+ const TInt swVersionLength( aSwVersion.Length() );
+ for( TInt i = 0; i < swVersionLength ; i++ )
+ {
+ if( aSwVersion[i] == KPEVersionLineFeed )
+ {
+ lineFeedCount++;
+ if( lineFeedCount == KPESwVersionLineCount )
+ {
+ const TInt charsToDelete( aSwVersion.Length() - i );
+
+ // Dont delete the last line feed characted, thats why
+ // i + 1.
+ aSwVersion.Delete( i + 1, charsToDelete );
+ return;
+ }
+ }
+ }
+ }
+
+// -----------------------------------------------------------------------------
+// CPEParserManufacturerHandler::AppendPhoneModelL
+// Reads phone model info from disk and appends it to aSwVersion.
+// -----------------------------------------------------------------------------
+//
+void CPEParserManufacturerHandler::AppendPhoneModelL(
+ TDes& aSwVersion )
+ {
+ RFile file;
+ User::LeaveIfError( file.Open( iFsSession,
+ KPESalesModelFileName,
+ EFileShareReadersOnly | EFileRead ) );
+ CleanupClosePushL( file );
+
+ HBufC* model = HBufC::NewLC( KPESalesModelNameMaxLength );
+ TPtr ptr = model->Des();
+
+ // Read the data from file.
+ TFileText reader;
+ reader.Set( file );
+ User::LeaveIfError( reader.Read( ptr ) );
+
+ // Append the phone model to aSwVersion
+ aSwVersion.Append( *model );
+
+ CleanupStack::PopAndDestroy( 2 ); // model, file
+ }
+
// End of File