commsfwtools/preparedefaultcommsdatabase/Tools/ced/src/ced.cpp
branchRCL_3
changeset 25 9d7ce34704c8
parent 21 07656293a99c
child 26 b564fb5fd78b
equal deleted inserted replaced
24:00c6709d25aa 25:9d7ce34704c8
    96 /** Flag to indicate whether the '-V' arg was passed in */
    96 /** Flag to indicate whether the '-V' arg was passed in */
    97 TBool gValidityChecking = EFalse;
    97 TBool gValidityChecking = EFalse;
    98 /** flag to indicate whether the execution format is .dll or .exe*/
    98 /** flag to indicate whether the execution format is .dll or .exe*/
    99 TBool gIsExeDLL = EFalse;
    99 TBool gIsExeDLL = EFalse;
   100 /** flag to indicate whether the configuration file is in XML format */
   100 /** flag to indicate whether the configuration file is in XML format */
   101 TBool gIsXML = ETrue; 
   101 TBool gIsXML = ETrue;
       
   102 /** flag to keep generic records */
       
   103 TBool gKeepGenerics = ETrue;
   102 
   104 
   103 #ifdef SYMBIAN_NETWORKING_3GPPDEFAULTQOS
   105 #ifdef SYMBIAN_NETWORKING_3GPPDEFAULTQOS
   104 TBool gDeprecatedFields = EFalse;
   106 TBool gDeprecatedFields = EFalse;
   105 #endif
   107 #endif
   106 //SYMBIAN_NETWORKING_3GPPDEFAULTQOS
   108 //SYMBIAN_NETWORKING_3GPPDEFAULTQOS
   291 		{
   293 		{
   292 		User::LeaveIfError(err);
   294 		User::LeaveIfError(err);
   293 		}
   295 		}
   294 	
   296 	
   295 	// delete everything in the database
   297 	// delete everything in the database
       
   298 	TInt keptElements = 0; 
   296 	if (ids.Count())
   299 	if (ids.Count())
   297 		{
   300 		{
   298 		for ( TInt i = ids.Count()-1; i >=0 ; i--)
   301 		for ( TInt i = ids.Count()-1; i >=0 ; i--)
   299 			{
   302 			{
   300 			if( i == ids.Count()-1 || i>=10000 && i%10000==0 || i<10000 && i>= 1000 && i%1000==0 ||
   303 			if( i == ids.Count()-1 || i>=10000 && i%10000==0 || i<10000 && i>= 1000 && i%1000==0 ||
   301 				i<1000 && i>=100 && i%100==0 || i<100 && i>=10 && i%10==0 || i<10)
   304 				i<1000 && i>=100 && i%100==0 || i<100 && i>=10 && i%10==0 || i<10)
   302 				{
   305 				{
   303 				gMsg->Msg(_L("%d"),i);
   306 				gMsg->Msg(_L("%d"),i);
   304 				}
   307 				}
   305 			User::LeaveIfError(storage->Delete(ids[i]));
   308 			if(!gKeepGenerics || ids[i] < KCDInitialUDefRecordType || ids[i] > KCDLastUDefRecordType)
   306 			}
   309 			    {
   307 		}
   310                 User::LeaveIfError(storage->Delete(ids[i]));
   308 	
   311 			    }
       
   312 			else
       
   313 			    {
       
   314 			    ++keptElements;
       
   315 			    }
       
   316 			}
       
   317 		}
       
   318 	
       
   319     gMsg->Msg(_L("Kept %d elements intact (KeepGenerics option == %d"), keptElements, gKeepGenerics);
   309 	TUint32 aErrorId;
   320 	TUint32 aErrorId;
   310 	err = storage->CommitTransaction(aErrorId);
   321 	err = storage->CommitTransaction(aErrorId);
   311 
   322 
   312 	CleanupStack::PopAndDestroy(2);
   323 	CleanupStack::PopAndDestroy(2);
   313 	
   324 	
   688 	// provided, so the caller should only look for process exit != 0 to mean failure, and then examine the
   699 	// provided, so the caller should only look for process exit != 0 to mean failure, and then examine the
   689 	// log to see what failed.
   700 	// log to see what failed.
   690 	return !gProcessingSuccessful;
   701 	return !gProcessingSuccessful;
   691 	}
   702 	}
   692 
   703 
       
   704 TBool MatchArg(const TDesC& aArg, const TDesC& aOpt)
       
   705     {
       
   706     return aArg.Left(aOpt.Length()).CompareF(aOpt) == 0;
       
   707     }
   693 
   708 
   694 TInt ParseCommandLineL(TBool &aDebugOn, TBool &aOverWrite, TBool &aForceXMLProcessing, TDes &aIn, TDes &aOut, TDes &aInPref)
   709 TInt ParseCommandLineL(TBool &aDebugOn, TBool &aOverWrite, TBool &aForceXMLProcessing, TDes &aIn, TDes &aOut, TDes &aInPref)
   695 /** Parse the command line for any overriding settings from exe command line 
   710 /** Parse the command line for any overriding settings from exe command line 
   696 
   711 
   697 @param bDebugOn Wether to output debug messages to the log file using CFileDump::Dbg(TPtrC text, ...)
   712 @param bDebugOn Wether to output debug messages to the log file using CFileDump::Dbg(TPtrC text, ...)
   732 			arg = pCmd->Arg(i);
   747 			arg = pCmd->Arg(i);
   733 			arg.UpperCase();
   748 			arg.UpperCase();
   734 			
   749 			
   735 			// CED will report all the failures on the end, unlike success in all the cases except missing cfg file
   750 			// CED will report all the failures on the end, unlike success in all the cases except missing cfg file
   736 			// Switch introduced because of high impact on test results and to avoid BC break
   751 			// Switch introduced because of high impact on test results and to avoid BC break
   737 			if ( arg.FindF(_L("-V")) != KErrNotFound )
   752 			if ( MatchArg(arg, _L("-V")) )
   738 				{
   753 				{
   739 				gValidityChecking = ETrue;
   754 				gValidityChecking = ETrue;
   740 				continue;
   755 				continue;
   741 				}
   756 				}
   742 
   757 
   743 			//Display help
   758 			//Display help
   744 			if ( arg.FindF(_L("-H")) != KErrNotFound )
   759 			if ( MatchArg(arg, _L("-H")) )
   745 				{
   760 				{
   746 				HelpDump();
   761 				HelpDump();
   747 				CleanupStack::Pop(pCmd);
   762 				CleanupStack::Pop(pCmd);
   748 				delete pCmd;
   763 				delete pCmd;
   749 				return valid;
   764 				return valid;
   750 				}
   765 				}
   751 			
   766 			
   752 			// Append database switch
   767 			// Append database switch
   753 			if ( arg.FindF(_L("-A")) != KErrNotFound )
   768 			if ( MatchArg(arg, _L("-A")) )
   754 				{
   769 				{
   755 				aOverWrite = EFalse;
   770 				aOverWrite = EFalse;
   756 				continue;
   771 				continue;
   757 				}
   772 				}
   758 			
   773 			
   759 			// Debug switch
   774 			// Debug switch
   760 			if ( arg.FindF(_L("-D")) != KErrNotFound )
   775 			if ( MatchArg(arg, _L("-D")) )
   761 				{
   776 				{
   762 				aDebugOn = ETrue;
   777 				aDebugOn = ETrue;
   763 				continue;
   778 				continue;
   764 				}
   779 				}
   765 
   780 
   766 			// Debug switch
   781 			// Debug switch
   767 			if ( arg.FindF(_L("-M")) != KErrNotFound )
   782 			if ( MatchArg(arg, _L("-M")) )
   768 				{
   783 				{
   769 				aInPref = pCmd->Arg(++i);
   784 				aInPref = pCmd->Arg(++i);
   770 				continue;
   785 				continue;
   771 				}
   786 				}
   772 			
   787 			
       
   788             // Keep generics switch
       
   789             if ( MatchArg(arg, _L("-KG")) )
       
   790                 {
       
   791                 gKeepGenerics = ETrue;
       
   792                 continue;
       
   793                 }
       
   794 			
       
   795             // Zap generics switch
       
   796             if ( MatchArg(arg, _L("-ZG")) )
       
   797                 {
       
   798                 gKeepGenerics = EFalse;
       
   799                 continue;
       
   800                 }
       
   801 
   773 			// Presence of invalid table entry links
   802 			// Presence of invalid table entry links
   774 			// will not cause an error
   803 			// will not cause an error
   775 			if ( arg.FindF(_L("-F")) != KErrNotFound )
   804 			if ( MatchArg(arg, _L("-F")) )
   776 				{
   805 				{
   777 				aForceXMLProcessing = ETrue;
   806 				aForceXMLProcessing = ETrue;
   778 				continue;
   807 				continue;
   779 				}
   808 				}
   780 			
   809 			
   781 			// Specification of an input file
   810 			// Specification of an input file
   782 			if ( arg.FindF(_L("-I")) != KErrNotFound )
   811 			if ( MatchArg(arg, _L("-I")) )
   783 				{
   812 				{
   784 				if( i != pCmd->Count()-1 )
   813 				if( i != pCmd->Count()-1 )
   785 					{
   814 					{
   786 					aIn = pCmd->Arg(++i);
   815 					aIn = pCmd->Arg(++i);
   787 					bInFound = ETrue;
   816 					bInFound = ETrue;
   798 					delete pCmd;
   827 					delete pCmd;
   799 					return valid;
   828 					return valid;
   800 					}
   829 					}
   801 				}
   830 				}
   802 			// Specification of an output file
   831 			// Specification of an output file
   803 			if ( arg.FindF(_L("-O")) != KErrNotFound )
   832 			if ( MatchArg(arg, _L("-O")) )
   804 				{
   833 				{
   805 				if( i != pCmd->Count()-1 )
   834 				if( i != pCmd->Count()-1 )
   806 					{
   835 					{
   807 					aOut = pCmd->Arg(++i);
   836 					aOut = pCmd->Arg(++i);
   808 					bOutFound = ETrue;
   837 					bOutFound = ETrue;
   821 #ifdef __TOOLS2__
   850 #ifdef __TOOLS2__
   822 			// Specification of the database binary version
   851 			// Specification of the database binary version
   823 			// This must be specified on the tools2 platform.
   852 			// This must be specified on the tools2 platform.
   824 			TBuf<16> databaseVersion;
   853 			TBuf<16> databaseVersion;
   825 			
   854 			
   826 			if ( arg.FindF(_L("-B")) != KErrNotFound )
   855 			if ( MatchArg(arg, _L("-B")) )
   827 				{
   856 				{
   828 				if( i != pCmd->Count()-1 )
   857 				if( i != pCmd->Count()-1 )
   829 					{
   858 					{
   830 					databaseVersion = pCmd->Arg(++i);
   859 					databaseVersion = pCmd->Arg(++i);
   831 					if(databaseVersion.Compare(SUPPORTED_OS) == 0)
   860 					if(databaseVersion.Compare(SUPPORTED_OS) == 0)
   927 	gConsole->Printf(_L("\n-m  Specifies the default mesh configuration file to CED. Defaults to reading '%S'."), &KMeshPrefaceFile);
   956 	gConsole->Printf(_L("\n-m  Specifies the default mesh configuration file to CED. Defaults to reading '%S'."), &KMeshPrefaceFile);
   928 #endif
   957 #endif
   929 	gConsole->Printf(_L("\n-v  Enables validation of the configuration data while writing to the database."));
   958 	gConsole->Printf(_L("\n-v  Enables validation of the configuration data while writing to the database."));
   930 	gConsole->Printf(_L("\n-i  Specifies an input file to CED. Must be either *.xml or *.cfg. Defaults to reading '%S' or '%S'."), &CFG_TARGET, &XML_TARGET);
   959 	gConsole->Printf(_L("\n-i  Specifies an input file to CED. Must be either *.xml or *.cfg. Defaults to reading '%S' or '%S'."), &CFG_TARGET, &XML_TARGET);
   931 	gConsole->Printf(_L("\n-o  Specifies an output file for CED to log to. Defaults to '%S'."), &LOG_TARGET);
   960 	gConsole->Printf(_L("\n-o  Specifies an output file for CED to log to. Defaults to '%S'."), &LOG_TARGET);
       
   961     gConsole->Printf(_L("\n-kg Keep existing generic-record elements (default)"));
       
   962     gConsole->Printf(_L("\n-zg Zap all existing elements including generics (unless appending)"));
   932 #ifdef __TOOLS2__
   963 #ifdef __TOOLS2__
   933 	gConsole->Printf(_L("\n-b  Specifies the binary output should be compatible with this Symbian OS version.\n"));
   964 	gConsole->Printf(_L("\n-b  Specifies the binary output should be compatible with this Symbian OS version.\n"));
   934 #endif
   965 #endif
   935 #ifndef __TOOLS2__
   966 #ifndef __TOOLS2__
   936 	gConsole->Printf(_L("\nPress any key to finish"));
   967 	gConsole->Printf(_L("\nPress any key to finish"));