smsprotocols/smsstack/common/src/smsstacklog.cpp
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
child 42 3adadc800673
child 65 630d2f34d719
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2002-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 // Logging macros code specific structures in SMSStack.
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent
       
    21 */
       
    22  
       
    23 #include "gsmupdu.h"
       
    24 #include "smsstacklog.h"
       
    25 
       
    26 
       
    27 //
       
    28 // All functions in this file are available only if logging is enabled.
       
    29 //
       
    30 #ifdef _SMS_LOGGING_ENABLED
       
    31 
       
    32 
       
    33 /**
       
    34  *  Number of characters per line during hex dump logging.
       
    35  */
       
    36 const TInt  KHexDumpCharsPerLine = 32;
       
    37 
       
    38 
       
    39 /**
       
    40  *  Converts a PDU from a buffer into a ASCII string and decodes it.
       
    41  *
       
    42  *  @param aPDU         PDU to log.
       
    43  *  @param aCommandPdu  Flag to say if this is a command PDU.
       
    44  */
       
    45 void LogSmsIfPDU(const TDesC8& aText, const TDesC8& aPDU, TBool aCommandPdu)
       
    46 	{
       
    47 	TBuf8<128>  tmpBuf;
       
    48 
       
    49 	//
       
    50 	// Log the PDU as raw hex...
       
    51 	//
       
    52 	tmpBuf.Copy(aText);
       
    53 	tmpBuf.Append(_L8("RAW:  "));
       
    54 
       
    55 	LOGSMSIFHEXBUF(tmpBuf, aPDU);
       
    56 
       
    57 	//
       
    58 	// Log the first octet...
       
    59 	//
       
    60 	// bit	   7	6	 5	  4    3	2	 1	  0
       
    61 	// submit  rp	udhi srr  vpf  vpf	rd	 0	  1  mti, rd,  vpf, rp, udhi, srr,
       
    62 	// deliver rp	udhi sri			mms  0	  0  mti, mms, rp, udhi, sri
       
    63 	// status		udhi srq			mms  1	  0  mti, udhi, mms, srq
       
    64 	// command		udhi srr				 1    0  mti, udhi, srr
       
    65 	//
       
    66 	enum TSmsVp
       
    67 		{
       
    68 		EVpAbs,
       
    69 		EVpEnh,
       
    70 		EVpRel,
       
    71 		EVpNone,
       
    72 		};
       
    73 	
       
    74 	CSmsPDU::TSmsPDUType  pduType = (CSmsPDU::TSmsPDUType) -1;
       
    75 	TInt  octetOffset = 0;
       
    76 	TText8  firstOctet = aPDU[octetOffset++];
       
    77 	TBool  udhiPresent = EFalse;
       
    78 	TSmsVp  vpf = EVpRel;
       
    79 
       
    80 	tmpBuf.Zero();
       
    81 	
       
    82 	if ((firstOctet & 0x03) == 0x00)
       
    83 		{
       
    84 		pduType = CSmsPDU::ESmsDeliver;
       
    85 		tmpBuf.Append(_L8("DELIVER "));
       
    86 		}
       
    87 	else if ((firstOctet & 0x03) == 0x01)
       
    88 		{
       
    89 		pduType = CSmsPDU::ESmsSubmit;
       
    90 		tmpBuf.Append(_L8("SUBMIT  "));
       
    91 		}
       
    92 	else if((firstOctet & 0x03) == 0x02)
       
    93 		{
       
    94 		if (aCommandPdu)
       
    95 			{
       
    96 			pduType = CSmsPDU::ESmsCommand;
       
    97 			tmpBuf.Append(_L8("COMMAND "));
       
    98 			}
       
    99 		else
       
   100 			{
       
   101 			pduType = CSmsPDU::ESmsStatusReport;
       
   102 			tmpBuf.Append(_L8("STATUS  "));
       
   103 			}
       
   104 		}
       
   105 	else
       
   106 		{
       
   107 		tmpBuf.Append(_L8("UNKNOWN "));
       
   108 		}
       
   109 
       
   110 	if (pduType == CSmsPDU::ESmsSubmit  ||  pduType == CSmsPDU::ESmsDeliver)
       
   111 		{
       
   112 		if (firstOctet & 0x80)
       
   113 			{
       
   114 			tmpBuf.Append(_L8("    1"));
       
   115 			}
       
   116 		else
       
   117 			{
       
   118 			tmpBuf.Append(_L8("    0"));
       
   119 			}
       
   120 		}
       
   121 	else
       
   122 		{
       
   123 		tmpBuf.Append(_L8("    -"));
       
   124 		}
       
   125 
       
   126 	if (firstOctet & 0x40)
       
   127 		{
       
   128 		tmpBuf.Append(_L8("    1"));
       
   129 		udhiPresent = ETrue;
       
   130 		}
       
   131 	else
       
   132 		{
       
   133 		tmpBuf.Append(_L8("    0"));
       
   134 		}
       
   135 
       
   136 	if (firstOctet & 0x20)
       
   137 		{
       
   138 		tmpBuf.Append(_L8("    1"));
       
   139 		}
       
   140 	else
       
   141 		{
       
   142 		tmpBuf.Append(_L8("    0"));
       
   143 		}
       
   144 
       
   145 	if (pduType == CSmsPDU::ESmsDeliver  ||  pduType == CSmsPDU::ESmsStatusReport)
       
   146 		{
       
   147 		// MMS is Deliver or Status Report PDUs only...
       
   148 		if (firstOctet & 0x04)
       
   149 			{
       
   150 			tmpBuf.Append(_L8("    1"));
       
   151 			}
       
   152 		else
       
   153 			{
       
   154 			tmpBuf.Append(_L8("    0"));
       
   155 			}
       
   156 		}
       
   157 	else
       
   158 		{
       
   159 		tmpBuf.Append(_L8("    -"));
       
   160 		}
       
   161 
       
   162 	if (pduType == CSmsPDU::ESmsSubmit)
       
   163 		{
       
   164 		// Reject Duplicates and VP is for Sumbit PDUs only.
       
   165 		if (firstOctet & 0x04)
       
   166 			{
       
   167 			tmpBuf.Append(_L8("    1"));
       
   168 			}
       
   169 		else
       
   170 			{
       
   171 			tmpBuf.Append(_L8("    0"));
       
   172 			}
       
   173 
       
   174 		if ((firstOctet & 0x18) == 0x18)
       
   175 			{
       
   176 			tmpBuf.Append(_L8("    ABS"));
       
   177 			vpf = EVpAbs;
       
   178 			}
       
   179 		else if ((firstOctet & 0x18) == 0x10)
       
   180 			{
       
   181 			tmpBuf.Append(_L8("    REL"));
       
   182 			vpf = EVpRel;
       
   183 			}
       
   184 		else if ((firstOctet & 0x18) == 0x08)
       
   185 			{
       
   186 			tmpBuf.Append(_L8("    ENH"));
       
   187 			vpf = EVpEnh;
       
   188 			}
       
   189 		else
       
   190 			{
       
   191 			tmpBuf.Append(_L8("    NO "));
       
   192 			vpf = EVpNone;
       
   193 			}
       
   194 		}
       
   195 	else
       
   196 		{
       
   197 		tmpBuf.Append(_L8("    -      -"));
       
   198 		}
       
   199 
       
   200 	LOGSMSIF2("%S      HEX   MTI        RP UDHI  SRX  MMS   RD     VP", &aText);
       
   201 	LOGSMSIF4("%SFO:   0x%02X  %S", &aText, firstOctet, &tmpBuf);
       
   202 
       
   203 	if (pduType == -1)
       
   204 		{
       
   205 		// Not supported!
       
   206 		return;
       
   207 		}
       
   208 
       
   209 	//
       
   210 	//
       
   211 	// Message reference (submit, status report and command only)...
       
   212 	//
       
   213 	if (pduType == CSmsPDU::ESmsSubmit  ||
       
   214 	    pduType == CSmsPDU::ESmsStatusReport  ||
       
   215 	    pduType == CSmsPDU::ESmsCommand)
       
   216 		{
       
   217         LOGSMSIF3("%SMR:   0x%02X", &aText, aPDU[octetOffset]);
       
   218         octetOffset++;
       
   219 		}
       
   220 
       
   221 	//
       
   222 	// Command's PID, CT and MN...
       
   223 	//
       
   224 	if (pduType == CSmsPDU::ESmsCommand)
       
   225 		{
       
   226 		LOGSMSIF3("%SPID:  0x%02X", &aText, aPDU[octetOffset]);
       
   227         octetOffset++;
       
   228 
       
   229 		LOGSMSIF3("%SCT:   0x%02X", &aText, aPDU[octetOffset]);
       
   230         octetOffset++;
       
   231 
       
   232 		LOGSMSIF3("%SMN:   0x%02X", &aText, aPDU[octetOffset]);
       
   233         octetOffset++;
       
   234 		}
       
   235 
       
   236 	//
       
   237 	// Log the telephone number...
       
   238 	//
       
   239 	TInt  telLength = (TInt) aPDU[octetOffset];
       
   240 	TInt  typeOfNumber = aPDU[octetOffset+1];
       
   241 	
       
   242 	octetOffset += 2;
       
   243 		
       
   244 	if (telLength >= 0  &&  telLength <= 20)
       
   245 		{
       
   246 		// Convert the number to ascii...
       
   247 		tmpBuf.Zero();
       
   248 		
       
   249 		for (TInt  count = 0;  count < (telLength + 1) / 2;  count++)
       
   250 			{
       
   251 			tmpBuf.AppendFormat(_L8("%1X%1X"), aPDU[octetOffset] & 0x0f,
       
   252 								(aPDU[octetOffset] >> 4) & 0x0f);
       
   253 			octetOffset++;
       
   254 			}
       
   255 		
       
   256 		tmpBuf.SetLength(telLength);
       
   257 
       
   258 		LOGSMSIF4("%STEL:  0x%02X  %S", &aText, typeOfNumber, &tmpBuf);
       
   259 		}
       
   260 	else
       
   261 		{
       
   262 		LOGSMSIF3("%STEL:  Illegal length value (%d)!", &aText, telLength);
       
   263 		return;
       
   264 		}
       
   265 
       
   266 	//
       
   267 	// PID and the DCS (submit and deliver only)...
       
   268 	//
       
   269 	if (pduType == CSmsPDU::ESmsSubmit  ||  pduType == CSmsPDU::ESmsDeliver)
       
   270 		{
       
   271 		LOGSMSIF3("%SPID:  0x%02X", &aText, aPDU[octetOffset]);
       
   272 		octetOffset++;
       
   273 
       
   274 		tmpBuf.Zero();
       
   275 
       
   276 		TInt  dcs = aPDU[octetOffset];
       
   277 		octetOffset++;
       
   278 
       
   279 		if ((dcs & 0xF0 != 0xF0)  &&
       
   280 		    ((dcs & 0xD0) == 0x00  ||  (dcs & 0xC0) == 0xC0  ||
       
   281 		     (dcs & 0xD0) == 0xD0  ||  (dcs & 0xE0) == 0xE0))
       
   282 			{
       
   283 			//
       
   284 			// Classless messages:
       
   285 			// 00x0xxxx GSM 7 bit default alphabet with no message class
       
   286 			// 1100xxxx Message Waiting Indication Group: Discard Message
       
   287 			// 1101xxxx Message Waiting Indication Group: Store Message
       
   288 			// 1110xxxx Message Waiting Indication Group: Store Message (UCS2 character set)
       
   289 			//
       
   290 			tmpBuf.Append(_L8("NO        "));
       
   291 			}
       
   292 		else if ((dcs & 0xC0) == 0x00  ||  (dcs & 0x40) == 0x40  ||  (dcs & 0xF0) == 0xF0)
       
   293 			{
       
   294 			//
       
   295 			// Message has a class:
       
   296 			// 00xxxxxx General Data Coding indication
       
   297 			// 01xxxxxx Message Marked for Automatic Deletion Group
       
   298 			// 1111xxxx Data coding/message class
       
   299 			//
       
   300 			if ((dcs & 0x03) == 0x00)		//class 0 sms
       
   301 				{
       
   302 				tmpBuf.Append(_L8("0         "));
       
   303 				}
       
   304 			else if((dcs & 0x03) == 0x03)	//class 3 sms
       
   305 				{
       
   306 				tmpBuf.Append(_L8("3         "));
       
   307 				}
       
   308 			else if((dcs & 0x01) == 0x01)	//class 1 sms
       
   309 				{
       
   310 				tmpBuf.Append(_L8("1         "));
       
   311 				}
       
   312 			else if((dcs & 0x02) == 0x02)	//class 2 sms
       
   313 				{
       
   314 				tmpBuf.Append(_L8("2         "));
       
   315 				}
       
   316 			}
       
   317 		else
       
   318 			{
       
   319 			//
       
   320 			// 1000xxxx...1011xxxx Reserved coding groups
       
   321 			//
       
   322 			tmpBuf.Append(_L8("NO        "));
       
   323 			}
       
   324 
       
   325 		if ((dcs & 0xF0) == 0xF0)
       
   326 			{
       
   327 			// Data coding/message class
       
   328 			if ((dcs & 0x04) == 0x00)
       
   329 				{
       
   330 				tmpBuf.Append(_L8(" 7 BIT   "));
       
   331 				}
       
   332 			else if ((dcs & 0x04) == 0x04)
       
   333 				{
       
   334 				tmpBuf.Append(_L8(" 8 BIT   "));
       
   335 				}
       
   336 			}
       
   337 		else if ((dcs & 0xC0) == 0xC0  ||  (dcs & 0xD0) == 0xD0)
       
   338 			{
       
   339 			//Message Waiting Indication: Discard Message or Store Message
       
   340 			tmpBuf.Append(_L8(" 7 BIT   "));
       
   341 			}
       
   342 		else if ((dcs & 0xE0) == 0xE0)
       
   343 			{
       
   344 			//Message Waiting Indication: Store Message (UCS2 character set)
       
   345 			tmpBuf.Append(_L8("16 BIT   "));
       
   346 			}
       
   347 		else if ((dcs & 0xC0) == 0x00 ||  (dcs & 0x40) == 0x40)
       
   348 			{
       
   349 			// General Data Coding indication or Automatic Deletion Group
       
   350 			if ((dcs & 0x0C) == 0x00)
       
   351 				{
       
   352 				tmpBuf.Append(_L8(" 7 BIT   "));
       
   353 				}
       
   354 			else if ((dcs & 0x0C) == 0x0C)
       
   355 				{
       
   356 				tmpBuf.Append(_L8("Reserved "));
       
   357 				}
       
   358 			else if ((dcs & 0x04) == 0x04)
       
   359 				{
       
   360 				tmpBuf.Append(_L8(" 8 BIT   "));
       
   361 				}
       
   362 			else if ((dcs & 0x08) == 0x08)
       
   363 				{
       
   364 				tmpBuf.Append(_L8("16 BIT   "));
       
   365 				}
       
   366 			}
       
   367 		else
       
   368 			{
       
   369 			// Reserved coding groups
       
   370 			tmpBuf.Append(_L("Reserved "));
       
   371 			}
       
   372 
       
   373 		if ((dcs & 0xF0 != 0xF0)  &&
       
   374 		    ((dcs & 0xC0) == 0xC0  ||  (dcs & 0xD0) == 0xD0  ||  (dcs & 0xE0) == 0xE0))
       
   375 			{
       
   376 			if ((dcs & 0x03) == 0x00)
       
   377 				{
       
   378 				// Voicemail Message Waiting
       
   379 				tmpBuf.Append(_L8("Voicemail Message Waiting"));
       
   380 				}
       
   381 			else if ((dcs & 0x03) == 0x03)
       
   382 				{
       
   383 				// Other Message Waiting
       
   384 				tmpBuf.Append(_L8("Other Message Waiting"));
       
   385 				}
       
   386 			else if ((dcs & 0x01) == 0x01)
       
   387 				{
       
   388 				// Fax Message Waiting
       
   389 				tmpBuf.Append(_L8("Fax Message Waiting"));
       
   390 				}
       
   391 			else if ((dcs & 0x02) == 0x02)
       
   392 				{
       
   393 				// Electronic Mail Message Waiting
       
   394 				tmpBuf.Append(_L8("Electronic Mail Message Waiting"));
       
   395 				}
       
   396 			else
       
   397 				{
       
   398 				tmpBuf.Append(_L8("-"));
       
   399 				}
       
   400 			}
       
   401 		else
       
   402 			{
       
   403 			tmpBuf.Append(_L8("-"));
       
   404 			}
       
   405 
       
   406 		LOGSMSIF2("%SDCS:  HEX   CLASS      DCS     INDICATION TYPE", &aText);
       
   407 		LOGSMSIF4("%S      0x%02X  %S", &aText, dcs, &tmpBuf);
       
   408 		}
       
   409 
       
   410 	//
       
   411 	// VP (submit only)...
       
   412 	//
       
   413 	if (pduType == CSmsPDU::ESmsSubmit)
       
   414 		{
       
   415 		if (vpf == EVpRel)
       
   416 			{
       
   417 			LOGSMSIF3("%SVP:   %d (Relative)", &aText, aPDU[octetOffset++]);
       
   418 			}
       
   419 		else if (vpf == EVpAbs)
       
   420 			{
       
   421 			// absolute format	  -  TODO to look for the right format
       
   422 			tmpBuf.Zero();
       
   423 			
       
   424 			for (TInt index = 0;  index < 7;  index++)
       
   425 				{
       
   426 				tmpBuf.AppendFormat(_L8("%02X"), aPDU[octetOffset + index]);
       
   427 				}
       
   428 			
       
   429 			LOGSMSIF3("%SVP:   %S (Absolute)", &aText, &tmpBuf);
       
   430 			octetOffset += 7;
       
   431 			}
       
   432 		else if (vpf == EVpEnh)
       
   433 			{
       
   434 			// enhanced validity period   -  TODO to look for the right format
       
   435 			tmpBuf.Zero();
       
   436 			
       
   437 			for (TInt index = 0;  index < 7;  index++)
       
   438 				{
       
   439 				tmpBuf.AppendFormat(_L8("%02X"), aPDU[octetOffset + index]);
       
   440 				}
       
   441 			
       
   442 			LOGSMSIF3("%SVP:   %S (Enhanced)", &aText, &tmpBuf);
       
   443 			octetOffset += 7;
       
   444 			}
       
   445 		}
       
   446 
       
   447 	//
       
   448 	// SCTS (deliver and status)  -  TODO to look for the right format
       
   449 	//
       
   450 	if (pduType == CSmsPDU::ESmsDeliver  ||  pduType == CSmsPDU::ESmsStatusReport)
       
   451 		{
       
   452 		tmpBuf.Zero();
       
   453 		
       
   454 		for (TInt index = 0;  index < 7;  index++)
       
   455 			{
       
   456 			tmpBuf.AppendFormat(_L8("%02X"), aPDU[octetOffset + index]);
       
   457 			}
       
   458 			
       
   459 		LOGSMSIF3("%SSCTS: %S", &aText, &tmpBuf);
       
   460 		octetOffset += 7;
       
   461 		}
       
   462 	
       
   463 	//
       
   464 	// Getting the DT and the status of the SR (SR only)
       
   465 	// TODO	to look for some appended octet after the status, eg. carried ud
       
   466 	//      and to analise the status
       
   467 	//
       
   468 	if (pduType == CSmsPDU::ESmsStatusReport)
       
   469 		{
       
   470 		tmpBuf.Zero();
       
   471 		
       
   472 		for (TInt index = 0;  index < 7;  index++)
       
   473 			{
       
   474 			tmpBuf.AppendFormat(_L8("%02X"), aPDU[octetOffset + index]);
       
   475 			}
       
   476 			
       
   477 		LOGSMSIF3("%SDT:   %S", &aText, &tmpBuf);
       
   478 		octetOffset += 7;
       
   479 
       
   480 		LOGSMSIF3("%SST:   %02X", &aText, aPDU[octetOffset]);
       
   481 		octetOffset++;
       
   482 		}
       
   483 
       
   484 	//
       
   485 	// Getting the UDL   -    TODO to add UD later and to decode the UDH
       
   486 	//
       
   487 	if (pduType == CSmsPDU::ESmsDeliver  ||  pduType == CSmsPDU::ESmsSubmit)
       
   488 		{
       
   489 		if (udhiPresent)
       
   490 			{
       
   491 			TInt  udl  = aPDU[octetOffset++];
       
   492 			TInt  udhl = aPDU[octetOffset++];
       
   493 			
       
   494 			if (udhl > 1)
       
   495 				{
       
   496 				tmpBuf.Zero();
       
   497 			
       
   498 				// getting iei_a
       
   499 				TInt  iei_a = aPDU[octetOffset++];
       
   500 	
       
   501 				// getting ieidl_a
       
   502 				TInt  ieidl_a = aPDU[octetOffset++];
       
   503 	
       
   504 				if (ieidl_a < udhl)
       
   505 					{
       
   506 					//
       
   507 					// With EDS, IEIDL can  be almost the whole payload; need to limit
       
   508 					// length of debug or increase udlbuf2 to around 300 bytes (which would
       
   509 					// make stack frame around 700 bytes out of allowed 2kB; seems too much)
       
   510 					// TODO: think whether we should explicitly show this truncation, eg with "..."
       
   511 					//
       
   512 					for (TInt index = 0;  index < ieidl_a;  index++)
       
   513 						{
       
   514 						tmpBuf.AppendFormat(_L8("%02X"), aPDU[octetOffset + index]);
       
   515 						if (tmpBuf.Length() > tmpBuf.MaxLength() - 2  ||
       
   516 							octetOffset + index == aPDU.Length() - 1)
       
   517 							{
       
   518 							break;
       
   519 							}
       
   520 						}
       
   521 					}
       
   522 				else
       
   523 					{
       
   524 					LOGSMSIF3("%SUDL:  Problems with the ieidl_a %d being less that UDHL",
       
   525 							  &aText, ieidl_a);
       
   526 					}
       
   527 	
       
   528 				if ((ieidl_a + 1) > udhl)
       
   529 					{
       
   530 					LOGSMSIF2("%SUDL:  Corrupted or implement decoding for second iei_b, iei_n!",
       
   531 							  &aText);
       
   532 					}
       
   533 	
       
   534 				LOGSMSIF2("%SUDL:  HEX    UDHL   IEI_A  IEIDL_A   ", &aText);
       
   535 				LOGSMSIF7("%S      0x%02X   0x%02X   0x%02X   0x%02X  %S", &aText,
       
   536 						  udl, udhl, iei_a, ieidl_a, &tmpBuf);
       
   537 				}
       
   538 			else
       
   539 				{
       
   540 				LOGSMSIF2("%SUDL:  Corrupted because TP-UDHP is TRUE and TP-UDHL is less than 1!", &aText);
       
   541 				LOGSMSIF2("%SUDL:  HEX   UDHL   IEI_A", &aText);
       
   542 				LOGSMSIF4("%S      0x%02X    0x%02X", &aText, udl, udhl);
       
   543 				}
       
   544 			}
       
   545 		else
       
   546 			{
       
   547 			TInt  udl  = aPDU[octetOffset++];
       
   548 			
       
   549 			LOGSMSIF2("%SUDL:  HEX    UDHL", &aText);
       
   550 			LOGSMSIF3("%S      0x%02X   -", &aText, udl);
       
   551 			}
       
   552 		}
       
   553 	} // LogSmsIfPDU
       
   554 
       
   555 
       
   556 void LogSmsIfHexBuf(const TDesC8& aText, const TDesC8& aHexBuf)
       
   557     {
       
   558 	//
       
   559 	// Print the PDU in hex in rows of upto KHexDumpCharsPerLine bytes...
       
   560 	//
       
   561 	TBuf8<KHexDumpCharsPerLine * 2>  hexLine;
       
   562     TInt  length = aHexBuf.Length();
       
   563 	TInt  position;
       
   564 
       
   565 	for (position = 0;  position < length;  position += KHexDumpCharsPerLine)
       
   566 		{
       
   567 		TInt  bytesToLog = length - position;
       
   568 		TInt  byteIndex;
       
   569 		
       
   570 		if (bytesToLog > KHexDumpCharsPerLine)
       
   571 			{
       
   572 			bytesToLog = KHexDumpCharsPerLine;
       
   573 			}
       
   574 
       
   575 		hexLine.Zero();
       
   576 
       
   577 		for (byteIndex = 0;  byteIndex < bytesToLog;  byteIndex++)
       
   578 			{
       
   579 			hexLine.AppendFormat(_L8("%02X"), aHexBuf[position + byteIndex]);
       
   580 			}
       
   581 
       
   582 		LOGSMSIF3("%S%S", &aText, &hexLine);
       
   583 		}
       
   584     } // LogSmsIfHexBuf
       
   585 
       
   586 
       
   587 /**
       
   588  *	Logs a Type of Number enum.
       
   589  *
       
   590  *  @param aTON  Enum to log.
       
   591  */
       
   592 void LogSmsIfTypeOfNumber(const TDesC8& aText, RMobilePhone::TMobileTON aTON)
       
   593 	{
       
   594 	switch (aTON)
       
   595 		{
       
   596 		case RMobilePhone::EUnknownNumber:
       
   597 			{
       
   598 			LOGSMSIF2("%SEUnknownNumber", &aText);
       
   599 			}
       
   600 			break;
       
   601 
       
   602 		case RMobilePhone::EInternationalNumber:
       
   603 			{
       
   604 			LOGSMSIF2("%SEInternationalNumber", &aText);
       
   605 			}
       
   606 			break;
       
   607 
       
   608 		case RMobilePhone::ENationalNumber:
       
   609 			{
       
   610 			LOGSMSIF2("%SENationalNumber", &aText);
       
   611 			}
       
   612 			break;
       
   613 
       
   614 		case RMobilePhone::ENetworkSpecificNumber:
       
   615 			{
       
   616 			LOGSMSIF2("%SENetworkSpecificNumber", &aText);
       
   617 			}
       
   618 			break;
       
   619 
       
   620 		case RMobilePhone::ESubscriberNumber:
       
   621 			{
       
   622 			LOGSMSIF2("%SESubscriberNumber", &aText);
       
   623 			}
       
   624 			break;
       
   625 
       
   626 		case RMobilePhone::EAlphanumericNumber:
       
   627 			{
       
   628 			LOGSMSIF2("%SEAlphanumericNumber", &aText);
       
   629 			}
       
   630 			break;
       
   631 
       
   632 		case RMobilePhone::EAbbreviatedNumber:
       
   633 			{
       
   634 			LOGSMSIF2("%SEAbbreviatedNumber", &aText);
       
   635 			}
       
   636 			break;
       
   637 
       
   638 		default:
       
   639 			{
       
   640 			LOGSMSIF3("%S<unknown enum %d>", &aText, aTON);
       
   641 			}
       
   642 			break;
       
   643 		}
       
   644 	} // LogSmsIfTypeOfNumber
       
   645 
       
   646 
       
   647 /**
       
   648  *	Logs a Numbering Plan enum.
       
   649  *
       
   650  *  @param aNPI  Enum to log.
       
   651  */
       
   652 void LogSmsIfNumberingPlan(const TDesC8& aText, RMobilePhone::TMobileNPI aNPI)
       
   653 	{
       
   654 	switch (aNPI)
       
   655 		{
       
   656 		case RMobilePhone::EUnknownNumberingPlan:
       
   657 			{
       
   658 			LOGSMSIF2("%SEUnknownNumberingPlan", &aText);
       
   659 			}
       
   660 			break;
       
   661 
       
   662 		case RMobilePhone::EIsdnNumberPlan:
       
   663 			{
       
   664 			LOGSMSIF2("%SEIsdnNumberPlan", &aText);
       
   665 			}
       
   666 			break;
       
   667 
       
   668 		case RMobilePhone::EDataNumberPlan:
       
   669 			{
       
   670 			LOGSMSIF2("%SEDataNumberPlan", &aText);
       
   671 			}
       
   672 			break;
       
   673 
       
   674 		case RMobilePhone::ETelexNumberPlan:
       
   675 			{
       
   676 			LOGSMSIF2("%SETelexNumberPlan", &aText);
       
   677 			}
       
   678 			break;
       
   679 
       
   680 		case RMobilePhone::EServiceCentreSpecificPlan1:
       
   681 			{
       
   682 			LOGSMSIF2("%SEServiceCentreSpecificPlan1", &aText);
       
   683 			}
       
   684 			break;
       
   685 
       
   686 		case RMobilePhone::EServiceCentreSpecificPlan2:
       
   687 			{
       
   688 			LOGSMSIF2("%SEServiceCentreSpecificPlan2", &aText);
       
   689 			}
       
   690 			break;
       
   691 
       
   692 		case RMobilePhone::ENationalNumberPlan:
       
   693 			{
       
   694 			LOGSMSIF2("%SENationalNumberPlan", &aText);
       
   695 			}
       
   696 			break;
       
   697 
       
   698 		case RMobilePhone::EPrivateNumberPlan:
       
   699 			{
       
   700 			LOGSMSIF2("%SEPrivateNumberPlan", &aText);
       
   701 			}
       
   702 			break;
       
   703 
       
   704 		case RMobilePhone::EERMESNumberPlan:
       
   705 			{
       
   706 			LOGSMSIF2("%SEERMESNumberPlan", &aText);
       
   707 			}
       
   708 			break;
       
   709 
       
   710 		default:
       
   711 			{
       
   712 			LOGSMSIF3("%S<unknown enum %d>", &aText, aNPI);
       
   713 			}
       
   714 			break;
       
   715 		}
       
   716 	} // LogSmsIfNumberingPlan
       
   717 
       
   718 
       
   719 /**
       
   720  *	Logs contents of TMobileGsmSmsEntryV1 object.
       
   721  *
       
   722  *  @param aSmsGsmEntryV1  Entry to log.
       
   723  */
       
   724 void LogSmsIfSmsEntry(const TDesC8& aText,
       
   725 					  const RMobileSmsStore::TMobileGsmSmsEntryV1& aSmsGsmEntryV1)
       
   726 	{
       
   727 	//
       
   728 	// Header and index...
       
   729 	//
       
   730 	LOGSMSIF2("%SRMobileSmsStore::TMobileGsmSmsEntryV1:", &aText);
       
   731 	LOGSMSIF4("%S  iIndex=%d (0x%08x)", &aText, aSmsGsmEntryV1.iIndex,
       
   732 			  aSmsGsmEntryV1.iIndex);
       
   733 	
       
   734 	//
       
   735 	// Message status...
       
   736 	//
       
   737 	switch (aSmsGsmEntryV1.iMsgStatus)
       
   738 		{
       
   739 		case RMobileSmsStore::EStoredMessageUnknownStatus:
       
   740 			{
       
   741 			LOGSMSIF2("%S  iStoreStats=EStoredMessageUnknownStatus", &aText);
       
   742 			}
       
   743 			break;
       
   744 
       
   745 		case RMobileSmsStore::EStoredMessageUnread:
       
   746 			{
       
   747 			LOGSMSIF2("%S  iStoreStats=EStoredMessageUnread", &aText);
       
   748 			}
       
   749 			break;
       
   750 
       
   751 		case RMobileSmsStore::EStoredMessageRead:
       
   752 			{
       
   753 			LOGSMSIF2("%S  iStoreStats=EStoredMessageRead", &aText);
       
   754 			}
       
   755 			break;
       
   756 
       
   757 		case RMobileSmsStore::EStoredMessageUnsent:
       
   758 			{
       
   759 			LOGSMSIF2("%S  iStoreStats=EStoredMessageUnsent", &aText);
       
   760 			}
       
   761 			break;
       
   762 
       
   763 		case RMobileSmsStore::EStoredMessageSent:
       
   764 			{
       
   765 			LOGSMSIF2("%S  iStoreStats=EStoredMessageSent", &aText);
       
   766 			}
       
   767 			break;
       
   768 
       
   769 		case RMobileSmsStore::EStoredMessageDelivered:
       
   770 			{
       
   771 			LOGSMSIF2("%S  iStoreStats=EStoredMessageDelivered", &aText);
       
   772 			}
       
   773 			break;
       
   774 
       
   775 		default:
       
   776 			{
       
   777 			LOGSMSIF3("%S  iStoreStats=<unknown enum %d>", &aText,
       
   778 					  aSmsGsmEntryV1.iMsgStatus);
       
   779 			}
       
   780 			break;
       
   781 		}
       
   782 
       
   783 	//
       
   784 	// Service centre number...
       
   785 	//
       
   786 	TBuf8<RMobilePhone::KMaxMobileTelNumberSize>  numberIn8bit;
       
   787 
       
   788 	numberIn8bit.Copy(aSmsGsmEntryV1.iServiceCentre.iTelNumber);
       
   789 	LOGSMSIF3("%S  SRC Address=\"%S\"", &aText, &numberIn8bit);
       
   790 
       
   791 	//
       
   792 	// Service Centre Type Of Number...
       
   793 	//
       
   794 	TBuf8<128>  tmpBuf;
       
   795 	
       
   796 	tmpBuf.Copy(aText);
       
   797 	tmpBuf.Append(_L8("  SRC AddrTON="));
       
   798 
       
   799 	LOGSMSIFTYPEOFNUMBER(tmpBuf, aSmsGsmEntryV1.iServiceCentre.iTypeOfNumber);
       
   800 
       
   801 	//
       
   802 	// Number Plan...
       
   803 	//
       
   804 	tmpBuf.Copy(aText);
       
   805 	tmpBuf.Append(_L8("  SRC AddrNPI="));
       
   806 
       
   807 	LOGSMSIFNUMBERINGPLAN(tmpBuf, aSmsGsmEntryV1.iServiceCentre.iNumberPlan);
       
   808 
       
   809 	//
       
   810 	// PDU...
       
   811 	//
       
   812 	tmpBuf.Copy(aText);
       
   813 	tmpBuf.Append(_L8("  PDU: "));
       
   814 
       
   815 	LOGSMSIFPDU(tmpBuf, aSmsGsmEntryV1.iMsgData, EFalse);
       
   816 	} // LogSmsIfSmsEntry
       
   817 
       
   818 
       
   819 /**
       
   820  *	Logs contents of TMobileSmsSendAttributesV1 object.
       
   821  *
       
   822  *  @param aAttrib  Attributes to log.
       
   823  */
       
   824 void LogSmsIfSendAttributes(const TDesC8& aText,
       
   825 							const RMobileSmsMessaging::TMobileSmsSendAttributesV1& aAttrib)
       
   826 	{
       
   827 	LOGSMSIF2("%SRMobileSmsMessaging::TMobileSmsSendAttributesV1:", &aText);
       
   828 	LOGSMSIF3("%S  iFlags=0x%08x", &aText, (TInt)(aAttrib.iFlags));
       
   829 
       
   830 	if (aAttrib.iFlags & RMobileSmsMessaging::KGsmServiceCentre)
       
   831 		{
       
   832 		TBuf8<128 + RMobilePhone::KMaxMobileTelNumberSize>  tmpBuf;
       
   833 		
       
   834 		tmpBuf.Copy(aAttrib.iGsmServiceCentre.iTelNumber);
       
   835 		LOGSMSIF3("%S  SRC Address=%S", &aText, &tmpBuf);
       
   836 
       
   837 		tmpBuf.Copy(aText);
       
   838 		tmpBuf.Append(_L8("  SRC AddrTON="));
       
   839 
       
   840 		LOGSMSIFTYPEOFNUMBER(tmpBuf, aAttrib.iGsmServiceCentre.iTypeOfNumber);
       
   841 
       
   842 		tmpBuf.Copy(aText);
       
   843 		tmpBuf.Append(_L8("  SRC AddrNPI="));
       
   844 
       
   845 		LOGSMSIFNUMBERINGPLAN(tmpBuf, aAttrib.iGsmServiceCentre.iNumberPlan);
       
   846 		}
       
   847 
       
   848 	if (aAttrib.iFlags & RMobileSmsMessaging::KSmsDataFormat)
       
   849 		{
       
   850 		switch (aAttrib.iDataFormat)
       
   851 			{
       
   852 			case RMobileSmsMessaging::EFormatUnspecified:
       
   853 				{
       
   854 				LOGSMSIF2("%S  iDataFormat=EFormatUnspecified", &aText);
       
   855 				}
       
   856 				break;
       
   857 
       
   858 			case RMobileSmsMessaging::EFormatGsmTpdu:
       
   859 				{
       
   860 				LOGSMSIF2("%S  iDataFormat=EFormatGsmTpdu", &aText);
       
   861 				}
       
   862 				break;
       
   863 
       
   864 			case RMobileSmsMessaging::EFormatCdmaTpdu:
       
   865 				{
       
   866 				LOGSMSIF2("%S  iDataFormat=EFormatCdmaTpdu", &aText);
       
   867 				}
       
   868 				break;
       
   869 
       
   870 			default:
       
   871 				{
       
   872 				LOGSMSIF3("%S  iDataFormat=<unknown enum %d>", &aText,
       
   873 						  aAttrib.iDataFormat);
       
   874 				}
       
   875 				break;
       
   876 			}
       
   877 		}
       
   878 
       
   879 	if (aAttrib.iFlags & RMobileSmsMessaging::KCdmaTeleservice)
       
   880 		{
       
   881 		LOGSMSIF3("%S  iCdmaTeles=0x08X", &aText, aAttrib.iCdmaTeleservice);
       
   882 		}
       
   883 
       
   884 	if (aAttrib.iFlags & RMobileSmsMessaging::KCdmaServiceCategory)
       
   885 		{
       
   886 		LOGSMSIF3("%S  iCdmaServ=0x08X", &aText, aAttrib.iCdmaServiceCategory);
       
   887 		}
       
   888 
       
   889 	if (aAttrib.iFlags & RMobileSmsMessaging::KRemotePartyInfo)
       
   890 		{
       
   891 		TBuf8<RMobilePhone::KMaxMobileTelNumberSize>  tmpBuf;
       
   892 		
       
   893 		tmpBuf.Copy(aAttrib.iDestination.iTelNumber);
       
   894 		LOGSMSIF3("%S  DST Address=%S", &aText, &tmpBuf);
       
   895 
       
   896 		tmpBuf.Copy(aText);
       
   897 		tmpBuf.Append(_L8("  DST AddrTON="));
       
   898 
       
   899 		LOGSMSIFTYPEOFNUMBER(tmpBuf, aAttrib.iDestination.iTypeOfNumber);
       
   900 
       
   901 		tmpBuf.Copy(aText);
       
   902 		tmpBuf.Append(_L8("  DST AddrNPI="));
       
   903 
       
   904 		LOGSMSIFNUMBERINGPLAN(tmpBuf, aAttrib.iDestination.iNumberPlan);
       
   905 		}
       
   906 
       
   907 	if (aAttrib.iFlags & RMobileSmsMessaging::KMoreToSend)
       
   908 		{
       
   909 		if (aAttrib.iMore)
       
   910 			{
       
   911 			LOGSMSIF2("%S  iMore=ETrue", &aText);
       
   912 			}
       
   913 		else
       
   914 			{
       
   915 			LOGSMSIF2("%S  iMore=EFalse", &aText);
       
   916 			}
       
   917 		}
       
   918 
       
   919 	if (aAttrib.iFlags & RMobileSmsMessaging::KMessageReference)
       
   920 		{
       
   921 		LOGSMSIF3("%S  iMsgRef=0x08X", &aText, aAttrib.iMsgRef);
       
   922 		}
       
   923 
       
   924 	if(aAttrib.iFlags & RMobileSmsMessaging::KGsmSubmitReport)
       
   925 		{
       
   926 		TBuf8<RMobilePhone::KMaxMobileTelNumberSize>  tmpBuf;
       
   927 		
       
   928 		tmpBuf.Copy(aText);
       
   929 		tmpBuf.Append(_L8("  iSubmitReport PDU: "));
       
   930 
       
   931 		LOGSMSIFPDU(tmpBuf, aAttrib.iSubmitReport, EFalse);
       
   932 		}
       
   933 	} // LogSmsIfSendAttributes
       
   934 
       
   935 #endif // _SMS_LOGGING_ENABLED