messagingfw/biomsgfw/BIFUTSRC/TBIFVIEW.CPP
changeset 22 bde600d88860
parent 0 8e480a14352b
equal deleted inserted replaced
21:08008ce8a6df 22:bde600d88860
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // TBIFVIEW.CPP
       
    15 //
       
    16 #include <bif.h>
       
    17 
       
    18 #include <barsc.h>
       
    19 #include <barsread.h>
       
    20 
       
    21 #include <e32cons.h>
       
    22 #include <e32std.h>
       
    23 
       
    24 #pragma warning(disable:4238)  // nonstandard extension used : class rvalue used as lvalue
       
    25 
       
    26 LOCAL_D CConsoleBase* console;
       
    27 const TInt KTestCleanupStack=0x40;
       
    28 LOCAL_D CTrapCleanup* TheTrapCleanup;
       
    29 LOCAL_D RFs Fs;
       
    30 const TInt KMaxBioCommandLine=256;
       
    31 TBuf<KMaxBioCommandLine> Arg;
       
    32 
       
    33 LOCAL_C void setupCleanup()
       
    34 //
       
    35 // Initialise the cleanup stack.
       
    36 //
       
    37     {
       
    38 	TheTrapCleanup=CTrapCleanup::New();
       
    39 	TRAPD(r,\
       
    40 		{\
       
    41 		for (TInt i=KTestCleanupStack;i>0;i--)\
       
    42 			CleanupStack::PushL((TAny*)1);\
       
    43 		CleanupStack::Pop(KTestCleanupStack);\
       
    44 		});
       
    45 	}
       
    46 
       
    47 
       
    48 LOCAL_D void ReadBIFL()
       
    49 	{
       
    50 	//
       
    51 	// Open BIF file
       
    52 	CBioInfoFileReader* bifFile=CBioInfoFileReader::NewLC(Fs,Arg);
       
    53 
       
    54 	//
       
    55 	// Read data from BIF file
       
    56 	console->Printf(_L("message_type_uid: %x(hex)\n"),bifFile->MessageTypeUid());
       
    57 	console->Printf(_L("message_parser_name: %S\n"),bifFile->MessageParserName());
       
    58 	console->Printf(_L("message_app_uid: %x(hex)\n"),bifFile->MessageAppUid());
       
    59 	console->Printf(_L("message_appctrl_name: %s\n"), bifFile->MessageAppCtrlName());
       
    60 	console->Printf(_L("general_data: {%x, %x, %x} (hex)\n"),bifFile->GeneralData1(),bifFile->GeneralData2(),bifFile->GeneralData3());
       
    61 	TBuf<80> buf = bifFile->Description();
       
    62 	console->Printf(_L("description: %S\n"), &buf);
       
    63 	buf = bifFile->IconsFilename();
       
    64 	console->Printf(_L("icons_filename: %S\n"), &buf);
       
    65 	buf = bifFile->FileExtension();
       
    66 	console->Printf(_L("file_extension: %S\n"), &buf);
       
    67 
       
    68 	const CArrayFixFlat<TInt16>* zoomlevels=bifFile->ZoomLevelsLC();
       
    69 	const TInt count=zoomlevels->Count();
       
    70 	console->Printf(_L("zoom_levels_count: %d\n"),count);
       
    71 	console->Printf(_L("zoom_levels: {"));
       
    72 	for(TInt cc=0;cc<count;++cc)
       
    73 		console->Printf(_L("%d "),zoomlevels->At(cc));
       
    74 	console->Printf(_L("}\n"));
       
    75 	CleanupStack::PopAndDestroy();		// zoomlevels
       
    76 	
       
    77 	const CArrayFixFlat<TBioMsgId>* ids=bifFile->IdsLC();
       
    78 	const TInt idCount=ids->Count();
       
    79 	console->Printf(_L("ids_count: %d\n"),idCount);
       
    80 	
       
    81 	for(TInt dd=0;dd<idCount;dd++)
       
    82 		{
       
    83 		console->Printf(_L("*** id#%d ***\n"),dd);
       
    84 
       
    85 		switch(ids->At(dd).iType)
       
    86 			{
       
    87 		case EBioMsgIdUnknown:
       
    88 			console->Printf(_L("type: EBioMsgIdUnknown\n"));
       
    89 			break;
       
    90 		case EBioMsgIdIana:
       
    91 			console->Printf(_L("type: Iana\n"));
       
    92 			break;
       
    93 		case EBioMsgIdNbs:
       
    94 			console->Printf(_L("type: Nbs\n"));
       
    95 			break;
       
    96 		case EBioMsgIdWap:
       
    97 			console->Printf(_L("type: Wap\n"));
       
    98 			break;
       
    99 		case EBioMsgIdWapSecure:
       
   100 			console->Printf(_L("type: WapSecure\n"));
       
   101 			break;
       
   102 		default:
       
   103 			console->Printf(_L("type: UNKNOWN (%d)\n"),ids->At(dd).iType);
       
   104 			};
       
   105 
       
   106 
       
   107 		switch(ids->At(dd).iConfidence)
       
   108 			{
       
   109 		case CApaDataRecognizerType::ECertain:
       
   110 			console->Printf(_L("confidence: Certain\n"));
       
   111 			break;
       
   112 		case CApaDataRecognizerType::EProbable:
       
   113 			console->Printf(_L("confidence: Probable\n"));
       
   114 			break;
       
   115 		case CApaDataRecognizerType::EPossible:
       
   116 			console->Printf(_L("confidence: Possible\n"));
       
   117 			break;
       
   118 		case CApaDataRecognizerType::EUnlikely:
       
   119 			console->Printf(_L("confidence: Unlikely\n"));
       
   120 			break;
       
   121 		case CApaDataRecognizerType::ENotRecognized:
       
   122 			console->Printf(_L("confidence: NotRecognized\n"));
       
   123 			break;
       
   124 	
       
   125 		default:
       
   126 			console->Printf(_L("confidence: UNKNOWN (%d)\n"),ids->At(dd).iConfidence);
       
   127 			};
       
   128 		
       
   129 		buf = ids->At(dd).iText;
       
   130 		console->Printf(_L("text: %S\n"), &buf);
       
   131 		console->Printf(_L("port: %d\n"),ids->At(dd).iPort);
       
   132 		console->Printf(_L("character_set: %x(hex)\n"),ids->At(dd).iCharacterSet);
       
   133 		console->Printf(_L("general_data: %x(hex)\n"),ids->At(dd).iGeneralIdData);
       
   134 		}
       
   135 
       
   136 	CleanupStack::PopAndDestroy();		// ids
       
   137 	
       
   138 	CleanupStack::PopAndDestroy();	// bifFile
       
   139 	}
       
   140 
       
   141 void DoConsole()
       
   142 	{
       
   143 	console=Console::NewL(_L("EPOC32 - BIF Viewer"),TSize(KConsFullScreen,KConsFullScreen));
       
   144 	CleanupStack::PushL(console);
       
   145 
       
   146 	Fs.Connect();
       
   147 
       
   148 	User::CommandLine(Arg);
       
   149 
       
   150 	console->Printf(_L("Reading from bif %S\n"),&Arg);
       
   151 	TRAPD(err,ReadBIFL());
       
   152 	if (err!=KErrNone)
       
   153 		console->Printf(_L("Leave code: %d\n"),err);
       
   154 	else
       
   155 		console->Printf(_L("BIF read success\n"));
       
   156 
       
   157 	Fs.Close();
       
   158 
       
   159 	console->Getch();
       
   160 
       
   161 	CleanupStack::PopAndDestroy(); // console
       
   162 	}
       
   163 
       
   164 GLDEF_C TInt E32Main()
       
   165 	{
       
   166 	__UHEAP_MARK;
       
   167 	setupCleanup();
       
   168 	TRAPD(err,DoConsole());
       
   169 	delete TheTrapCleanup;
       
   170 	__UHEAP_MARKEND;
       
   171 	return KErrNone;
       
   172 	}