commands/icc/icc.cpp
changeset 0 7f656887cf89
equal deleted inserted replaced
-1:000000000000 0:7f656887cf89
       
     1 // icc.cpp
       
     2 // 
       
     3 // Copyright (c) 2009 - 2010 Accenture. All rights reserved.
       
     4 // This component and the accompanying materials are made available
       
     5 // under the terms of the "Eclipse Public License v1.0"
       
     6 // which accompanies this distribution, and is available
       
     7 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 // 
       
     9 // Initial Contributors:
       
    10 // Accenture - Initial contribution
       
    11 //
       
    12 
       
    13 #include <fshell/ioutils.h>
       
    14 #include <etelmm.h>
       
    15 #include <commsdattypesv1_1.h>
       
    16 #include <fshell/ltkutils.h>
       
    17 #include <cdblen.h>
       
    18 
       
    19 
       
    20 #define SERVICE_ENTRY(XXX) { XXX, #XXX }
       
    21 
       
    22 struct SEnumFlag
       
    23 	{
       
    24 	TInt iValue;
       
    25 	const char* iIndentifer;
       
    26 	};
       
    27 
       
    28 SEnumFlag KSstServices1to8[] =
       
    29 	{
       
    30 	SERVICE_ENTRY(RMobilePhone::KSstPin1Disable),
       
    31 	SERVICE_ENTRY(RMobilePhone::KSstADN),
       
    32 	SERVICE_ENTRY(RMobilePhone::KSstFDN),
       
    33 	SERVICE_ENTRY(RMobilePhone::KSstSMS),
       
    34 	SERVICE_ENTRY(RMobilePhone::KSstAoC),
       
    35 	SERVICE_ENTRY(RMobilePhone::KSstCCP),
       
    36 	SERVICE_ENTRY(RMobilePhone::KSstPLMNSelector)
       
    37 	};
       
    38 
       
    39 SEnumFlag KSstServices9to16[] =
       
    40 	{
       
    41 	SERVICE_ENTRY(RMobilePhone::KSstMSISDN),
       
    42 	SERVICE_ENTRY(RMobilePhone::KSstExt1),
       
    43 	SERVICE_ENTRY(RMobilePhone::KSstExt2),
       
    44 	SERVICE_ENTRY(RMobilePhone::KSstSMSP),
       
    45 	SERVICE_ENTRY(RMobilePhone::KSstLND),
       
    46 	SERVICE_ENTRY(RMobilePhone::KSstCBMI),
       
    47 	SERVICE_ENTRY(RMobilePhone::KSstGID1),
       
    48 	SERVICE_ENTRY(RMobilePhone::KSstGID2)
       
    49 	};
       
    50 
       
    51 SEnumFlag KSstServices17to24[] =
       
    52 	{
       
    53 	SERVICE_ENTRY(RMobilePhone::KSstSPName),
       
    54 	SERVICE_ENTRY(RMobilePhone::KSstSDN),
       
    55 	SERVICE_ENTRY(RMobilePhone::KSstExt3),
       
    56 	SERVICE_ENTRY(RMobilePhone::KSstVGCSList),
       
    57 	SERVICE_ENTRY(RMobilePhone::KSstVBSList),
       
    58 	SERVICE_ENTRY(RMobilePhone::KSsteMLPP),
       
    59 	SERVICE_ENTRY(RMobilePhone::KSstAnswereMLPP)
       
    60 	};
       
    61 
       
    62 SEnumFlag KSstServices25to32[] =
       
    63 	{
       
    64 	SERVICE_ENTRY(RMobilePhone::KSstSmsCbDataDownload),
       
    65 	SERVICE_ENTRY(RMobilePhone::KSstSmsPpDataDownload),
       
    66 	SERVICE_ENTRY(RMobilePhone::KSstMenuSelection),
       
    67 	SERVICE_ENTRY(RMobilePhone::KSstCallControl),
       
    68 	SERVICE_ENTRY(RMobilePhone::KSstProactiveSim),
       
    69 	SERVICE_ENTRY(RMobilePhone::KSstCBMIRanges),
       
    70 	SERVICE_ENTRY(RMobilePhone::KSstBDN),
       
    71 	SERVICE_ENTRY(RMobilePhone::KSstExt4)
       
    72 	};
       
    73 
       
    74 SEnumFlag KSstServices33to40[] =
       
    75 	{
       
    76 	SERVICE_ENTRY(RMobilePhone::KSstDepersonalisationKeys),
       
    77 	SERVICE_ENTRY(RMobilePhone::KSstCooperativeNetworks),
       
    78 	SERVICE_ENTRY(RMobilePhone::KSstSMStatusReports),
       
    79 	SERVICE_ENTRY(RMobilePhone::KSstNetworkIndAlerting),
       
    80 	SERVICE_ENTRY(RMobilePhone::KSstMoSmControlBySim),
       
    81 	SERVICE_ENTRY(RMobilePhone::KSstGprs),
       
    82 	SERVICE_ENTRY(RMobilePhone::KSstImage),
       
    83 	SERVICE_ENTRY(RMobilePhone::KSstSoLSA)
       
    84 	};
       
    85 
       
    86 SEnumFlag KSstServices41to48[] =
       
    87 	{
       
    88 	SERVICE_ENTRY(RMobilePhone::KSstUssdStringInCallControl),
       
    89 	SERVICE_ENTRY(RMobilePhone::KSstRunATCommand),
       
    90 	SERVICE_ENTRY(RMobilePhone::KSstPlmnSelectorListWithAccessTechnology),
       
    91 	SERVICE_ENTRY(RMobilePhone::KSstOplmnSelectorListWithAccessTechnology),
       
    92 	SERVICE_ENTRY(RMobilePhone::KSstHplmnAccessTechnology),
       
    93 	SERVICE_ENTRY(RMobilePhone::KSstCpbcchInformation),
       
    94 	SERVICE_ENTRY(RMobilePhone::KSstInvestigationScan),
       
    95 	SERVICE_ENTRY(RMobilePhone::KSstExtendedCcp)
       
    96 	};
       
    97 
       
    98 SEnumFlag KSstServices49to56[] =
       
    99 	{
       
   100 	SERVICE_ENTRY(RMobilePhone::KSstMExE),
       
   101 	SERVICE_ENTRY(RMobilePhone::KSstRplmnLastUsedAccessTechnology)
       
   102 	};
       
   103 
       
   104 SEnumFlag KUstServices1to8[] =
       
   105 	{
       
   106 	SERVICE_ENTRY(RMobilePhone::KUstLocalPhBk),
       
   107 	SERVICE_ENTRY(RMobilePhone::KUstFDN),
       
   108 	SERVICE_ENTRY(RMobilePhone::KUstExt2),
       
   109 	SERVICE_ENTRY(RMobilePhone::KUstSDN),
       
   110 	SERVICE_ENTRY(RMobilePhone::KUstExt3),
       
   111 	SERVICE_ENTRY(RMobilePhone::KUstBDN),
       
   112 	SERVICE_ENTRY(RMobilePhone::KUstExt4),
       
   113 	SERVICE_ENTRY(RMobilePhone::KUstOugoingCallInfo)
       
   114 	};
       
   115 
       
   116 SEnumFlag KUstServices9to16[] =
       
   117 	{
       
   118 	SERVICE_ENTRY(RMobilePhone::KUstIncomingCallInfo),
       
   119 	SERVICE_ENTRY(RMobilePhone::KUstSMS),
       
   120 	SERVICE_ENTRY(RMobilePhone::KUstSMSR),
       
   121 	SERVICE_ENTRY(RMobilePhone::KUstSMSP),
       
   122 	SERVICE_ENTRY(RMobilePhone::KUstAoC),
       
   123 	SERVICE_ENTRY(RMobilePhone::KUstCCP),
       
   124 	SERVICE_ENTRY(RMobilePhone::KUstCBMI),
       
   125 	SERVICE_ENTRY(RMobilePhone::KUstCBMIRanges)
       
   126 	};
       
   127 
       
   128 SEnumFlag KUstServices17to24[] =
       
   129 	{
       
   130 	SERVICE_ENTRY(RMobilePhone::KUstGID1),
       
   131 	SERVICE_ENTRY(RMobilePhone::KUstGID2),
       
   132 	SERVICE_ENTRY(RMobilePhone::KUstSPN),
       
   133 	SERVICE_ENTRY(RMobilePhone::KUstPLMNSelAccessTech),
       
   134 	SERVICE_ENTRY(RMobilePhone::KUstMSISDN),
       
   135 	SERVICE_ENTRY(RMobilePhone::KUstIMG),
       
   136 	SERVICE_ENTRY(RMobilePhone::KUsteMLPP)
       
   137 	};
       
   138 
       
   139 SEnumFlag KUstServices25to32[] =
       
   140 	{
       
   141 	SERVICE_ENTRY(RMobilePhone::KUstAnswereMLPP),
       
   142 	SERVICE_ENTRY(RMobilePhone::KUstGSMAccess),
       
   143 	SERVICE_ENTRY(RMobilePhone::KUstSMSPpDataDownload),
       
   144 	SERVICE_ENTRY(RMobilePhone::KUstSMSCbDataDownload),
       
   145 	SERVICE_ENTRY(RMobilePhone::KUstCallControl),
       
   146 	SERVICE_ENTRY(RMobilePhone::KUstMoSmControl),
       
   147 	SERVICE_ENTRY(RMobilePhone::KUstPCmdRunAtCommand)
       
   148 	};
       
   149 
       
   150 SEnumFlag KUstServices33to40[] =
       
   151 	{
       
   152 	SERVICE_ENTRY(RMobilePhone::KUstAlways),
       
   153 	SERVICE_ENTRY(RMobilePhone::KUstEST),
       
   154 	SERVICE_ENTRY(RMobilePhone::KUstACL),
       
   155 	SERVICE_ENTRY(RMobilePhone::KIstDepersonalisationKeys),
       
   156 	SERVICE_ENTRY(RMobilePhone::KUstCooperativeNetwork),
       
   157 	SERVICE_ENTRY(RMobilePhone::KUstGSMSecurityContext),
       
   158 	SERVICE_ENTRY(RMobilePhone::KUstCPBCCHInfo),
       
   159 	SERVICE_ENTRY(RMobilePhone::KUstInvestigationScan)
       
   160 	};
       
   161 
       
   162 SEnumFlag KUstServices41to48[] =
       
   163 	{
       
   164 	SERVICE_ENTRY(RMobilePhone::KUstMExE),
       
   165 	SERVICE_ENTRY(RMobilePhone::KUstOperatorPLMNSelector),
       
   166 	SERVICE_ENTRY(RMobilePhone::KUstHPLMNSelAccessTech),
       
   167 	SERVICE_ENTRY(RMobilePhone::KUstExt5),
       
   168 	SERVICE_ENTRY(RMobilePhone::KUstPLMNNetworkName),
       
   169 	SERVICE_ENTRY(RMobilePhone::KUstOperatorPLMNList),
       
   170 	SERVICE_ENTRY(RMobilePhone::KUstMDN),
       
   171 	SERVICE_ENTRY(RMobilePhone::KUstMWISo)
       
   172 	};
       
   173 
       
   174 SEnumFlag KUstServices49to56[] =
       
   175 	{
       
   176 	SERVICE_ENTRY(RMobilePhone::KUstCFIS),
       
   177 	SERVICE_ENTRY(RMobilePhone::KUstRPLMN),
       
   178 	SERVICE_ENTRY(RMobilePhone::KUstSPDI),
       
   179 	SERVICE_ENTRY(RMobilePhone::KUstMMS),
       
   180 	SERVICE_ENTRY(RMobilePhone::KUstExt8),
       
   181 	SERVICE_ENTRY(RMobilePhone::KUstCConGPRS),
       
   182 	SERVICE_ENTRY(RMobilePhone::KUstMMSUCP)
       
   183 	};
       
   184 
       
   185 #if defined (FSHELL_PLATFORM_S60) && FSHELL_PLATFORM_S60 >= 5
       
   186 SEnumFlag KUstServices57to64[] =
       
   187 	{
       
   188 	SERVICE_ENTRY(RMobilePhone::KUstVGCSGroupIdList),
       
   189 	SERVICE_ENTRY(RMobilePhone::KUstVBSGroupIdList),
       
   190 	SERVICE_ENTRY(RMobilePhone::KUstPseudonym),
       
   191 	SERVICE_ENTRY(RMobilePhone::KUstUserPLMNSelectorWLAN),
       
   192 	SERVICE_ENTRY(RMobilePhone::KUstOperatorPLMNSelectorWLAN),
       
   193 	SERVICE_ENTRY(RMobilePhone::KUstUserWSIDList),
       
   194 	SERVICE_ENTRY(RMobilePhone::KUstOperatorWSIDList),
       
   195 	SERVICE_ENTRY(RMobilePhone::KUstVGCSSecurity)
       
   196 	};
       
   197 #endif
       
   198 
       
   199 SEnumFlag KEstServices1to8[] =
       
   200 	{
       
   201 	SERVICE_ENTRY(RMobilePhone::KEstFDN),
       
   202 	SERVICE_ENTRY(RMobilePhone::KEstBDN),
       
   203 	SERVICE_ENTRY(RMobilePhone::KEstACL)
       
   204 	};
       
   205 
       
   206 #if defined (FSHELL_PLATFORM_S60) && FSHELL_PLATFORM_S60 >= 5
       
   207 SEnumFlag KIstServices1to8[] =
       
   208 	{
       
   209 	SERVICE_ENTRY(RMobilePhone::KIstPCSCF),
       
   210 	SERVICE_ENTRY(RMobilePhone::KIstGBA),
       
   211 	SERVICE_ENTRY(RMobilePhone::KIstHTTPDigest)
       
   212 	};
       
   213 #endif
       
   214 
       
   215 
       
   216 using namespace IoUtils;
       
   217 
       
   218 class CCmdIcc : public CCommandBase
       
   219 	{
       
   220 public:
       
   221 	static CCommandBase* NewLC();
       
   222 	~CCmdIcc();
       
   223 private:
       
   224 	CCmdIcc();
       
   225 	void OpenPhoneL();
       
   226 	void GetPhoneBookInfoL();
       
   227 	void ApiSupported(TInt aApi, TBool& aIsSupported);
       
   228 	void DisplayAccessCapsL();
       
   229 	void DisplayServiceTablesL();
       
   230 	void DisplayFdnStatusL();
       
   231 	void DisplayPhoneBookInfoL();
       
   232 	void DumpPhoneBookL();
       
   233 	void EditPhoneBookL();
       
   234 	void PrintServices(const TDesC& iTableName, TUint aServices, SEnumFlag aServiceTableDefinitions[], TInt aNumServiceTableDefinitions);
       
   235 private: // From CCommandBase.
       
   236 	virtual const TDesC& Name() const;
       
   237 	virtual void DoRunL();
       
   238 	virtual void ArgumentsL(RCommandArgumentList& aArguments);
       
   239 	virtual void OptionsL(RCommandOptionList& aOptions);
       
   240 private:
       
   241 	enum TOperation
       
   242 		{
       
   243 		EAccessCaps,
       
   244 		EServiceTables,
       
   245 		EFdnStatus,
       
   246 		EPhoneBookInfo,
       
   247 		EDumpPhoneBook,
       
   248 		EEditPhoneBook
       
   249 		};
       
   250 private:
       
   251 	RTelServer iEtelServer;
       
   252 	RMobilePhone iPhone;
       
   253 	RMobilePhoneBookStore iPhoneBookStore;
       
   254 	TBool iVerbose;
       
   255 	HBufC* iTsyName;
       
   256 	TUint iServiceTable;
       
   257 	HBufC* iStoreName;
       
   258 	HBufC* iMode;
       
   259 	TInt iSlot;
       
   260 	HBufC* iData;
       
   261 	TOperation iOperation;
       
   262 	TBool iV5Tsy;
       
   263 	TBool iV2Tsy;
       
   264 	TBool iUsimTsy;
       
   265 	RMobilePhoneBookStore::TMobilePhoneBookInfoV5 iStoreInfo;
       
   266 	};
       
   267 
       
   268 
       
   269 CCommandBase* CCmdIcc::NewLC()
       
   270 	{
       
   271 	CCmdIcc* self = new(ELeave) CCmdIcc();
       
   272 	CleanupStack::PushL(self);
       
   273 	self->BaseConstructL();
       
   274 	return self;
       
   275 	}
       
   276 
       
   277 CCmdIcc::~CCmdIcc()
       
   278 	{
       
   279 	iPhoneBookStore.Close();
       
   280 	iPhone.Close();
       
   281 	iEtelServer.Close();
       
   282 	delete iTsyName;
       
   283 	delete iStoreName;
       
   284 	delete iMode;
       
   285 	delete iData;
       
   286 	}
       
   287 
       
   288 CCmdIcc::CCmdIcc()
       
   289 	{
       
   290 	}
       
   291 
       
   292 const TDesC& CCmdIcc::Name() const
       
   293 	{
       
   294 	_LIT(KName, "icc");	
       
   295 	return KName;
       
   296 	}
       
   297 
       
   298 void CCmdIcc::DoRunL()
       
   299 	{
       
   300 	OpenPhoneL();
       
   301 
       
   302 	switch (iOperation)
       
   303 		{
       
   304 		case EAccessCaps:
       
   305 			DisplayAccessCapsL();
       
   306 			break;
       
   307 		case EServiceTables:
       
   308 			DisplayServiceTablesL();
       
   309 			break;
       
   310 		case EFdnStatus:
       
   311 			DisplayFdnStatusL();
       
   312 			break;
       
   313 		case EPhoneBookInfo:
       
   314 			DisplayPhoneBookInfoL();
       
   315 			break;
       
   316 		case EDumpPhoneBook:
       
   317 			DumpPhoneBookL();
       
   318 			break;
       
   319 		case EEditPhoneBook:
       
   320 			EditPhoneBookL();
       
   321 			break;
       
   322 		default:
       
   323 			User::Leave(KErrArgument);
       
   324 		}
       
   325 	}
       
   326 
       
   327 void CCmdIcc::DisplayAccessCapsL()
       
   328 	{
       
   329 	TUint32 iccCaps;
       
   330 	LeaveIfErr(iPhone.GetIccAccessCaps(iccCaps), _L("Couldn't get ICC access capabilities"));
       
   331 
       
   332 	TBool first(ETrue);
       
   333 	if (iccCaps & RMobilePhone::KCapsSimAccessSupported)
       
   334 		{
       
   335 		if (first)
       
   336 			{
       
   337 			first = EFalse;
       
   338 			}
       
   339 		else
       
   340 			{
       
   341 			Write(_L(" | "));
       
   342 			}
       
   343 		Write(_L("KCapsSimAccessSupported"));
       
   344 		}
       
   345 	if (iccCaps & RMobilePhone::KCapsRUimAccessSupported)
       
   346 		{
       
   347 		if (first)
       
   348 			{
       
   349 			first = EFalse;
       
   350 			}
       
   351 		else
       
   352 			{
       
   353 			Write(_L(" | "));
       
   354 			}
       
   355 		Write(_L("KCapsRUimAccessSupported"));
       
   356 		}
       
   357 	if (iccCaps & RMobilePhone::KCapsUSimAccessSupported)
       
   358 		{
       
   359 		if (first)
       
   360 			{
       
   361 			first = EFalse;
       
   362 			}
       
   363 		else
       
   364 			{
       
   365 			Write(_L(" | "));
       
   366 			}
       
   367 		Write(_L("KCapsUSimAccessSupported"));
       
   368 		}
       
   369 	if (!first)
       
   370 		{
       
   371 		Write(_L("\r\n"));
       
   372 		}
       
   373 	}
       
   374 	
       
   375 void CCmdIcc::PrintServices(const TDesC& iTableName, TUint aServices, SEnumFlag aServiceTableDefinitions[], TInt aNumServiceTableDefinitions)
       
   376 	{
       
   377 	Printf(_L("%S "), &iTableName);
       
   378 	TBool first(ETrue);
       
   379 	for (TInt i = 0; i < aNumServiceTableDefinitions; ++i)
       
   380 		{
       
   381 		if (aServices & aServiceTableDefinitions[i].iValue)
       
   382 			{
       
   383 			if (first)
       
   384 				{
       
   385 				first = EFalse;
       
   386 				}
       
   387 			else
       
   388 				{
       
   389 				Printf(_L(" | "));
       
   390 				}
       
   391 			TPtrC8 identifier((const TUint8*)aServiceTableDefinitions[i].iIndentifer);
       
   392 			identifier.Set(identifier.Mid(identifier.Find(_L8("::")) + 2));
       
   393 			Printf(identifier);
       
   394 			}
       
   395 		}
       
   396 	Write(_L("\r\n"));
       
   397 	}
       
   398 
       
   399 void CCmdIcc::DisplayServiceTablesL()
       
   400 	{
       
   401 	RMobilePhone::TMobilePhoneServiceTableV2 serviceTable;
       
   402 	TRequestStatus status;
       
   403 
       
   404 	if (iV2Tsy)
       
   405 		{
       
   406 		RMobilePhone::TMobilePhoneServiceTableV2Pckg serviceTablePckg(serviceTable);
       
   407 		iPhone.GetServiceTable(status, (RMobilePhone::TMobilePhoneServiceTable)iServiceTable, serviceTablePckg);
       
   408 		}
       
   409 	else
       
   410 		{
       
   411 		RMobilePhone::TMobilePhoneServiceTableV1Pckg serviceTablePckg(serviceTable);
       
   412 		iPhone.GetServiceTable(status, (RMobilePhone::TMobilePhoneServiceTable)iServiceTable, serviceTablePckg);
       
   413 		}
       
   414 	
       
   415 	User::WaitForRequest(status);
       
   416 	LeaveIfErr(status.Int(), _L("Unable to get service table %d"), iServiceTable);
       
   417 
       
   418 	switch (iServiceTable)
       
   419 		{
       
   420 		case RMobilePhone::ESIMServiceTable:
       
   421 			PrintServices(_L("1 to 8:  "), serviceTable.iServices1To8, KSstServices1to8, sizeof(KSstServices1to8) / sizeof(SEnumFlag));
       
   422 			PrintServices(_L("9 to 16: "), serviceTable.iServices9To16, KSstServices9to16, sizeof(KSstServices9to16) / sizeof(SEnumFlag));
       
   423 			PrintServices(_L("17 to 24:"), serviceTable.iServices17To24, KSstServices17to24, sizeof(KSstServices17to24) / sizeof(SEnumFlag));
       
   424 			PrintServices(_L("25 to 32:"), serviceTable.iServices25To32, KSstServices25to32, sizeof(KSstServices25to32) / sizeof(SEnumFlag));
       
   425 			PrintServices(_L("33 to 40:"), serviceTable.iServices33To40, KSstServices33to40, sizeof(KSstServices33to40) / sizeof(SEnumFlag));
       
   426 			PrintServices(_L("41 to 48:"), serviceTable.iServices41To48, KSstServices41to48, sizeof(KSstServices41to48) / sizeof(SEnumFlag));
       
   427 			PrintServices(_L("49 to 56:"), serviceTable.iServices49To56, KSstServices49to56, sizeof(KSstServices49to56) / sizeof(SEnumFlag));
       
   428 			break;
       
   429 		case RMobilePhone::EUSIMServiceTable:
       
   430 			PrintServices(_L("1 to 8:  "), serviceTable.iServices1To8, KUstServices1to8, sizeof(KUstServices1to8) / sizeof(SEnumFlag));
       
   431 			PrintServices(_L("9 to 16: "), serviceTable.iServices9To16, KUstServices9to16, sizeof(KUstServices9to16) / sizeof(SEnumFlag));
       
   432 			PrintServices(_L("17 to 24:"), serviceTable.iServices17To24, KUstServices17to24, sizeof(KUstServices17to24) / sizeof(SEnumFlag));
       
   433 			PrintServices(_L("25 to 32:"), serviceTable.iServices25To32, KUstServices25to32, sizeof(KUstServices25to32) / sizeof(SEnumFlag));
       
   434 			PrintServices(_L("33 to 40:"), serviceTable.iServices33To40, KUstServices33to40, sizeof(KUstServices33to40) / sizeof(SEnumFlag));
       
   435 			PrintServices(_L("41 to 48:"), serviceTable.iServices41To48, KUstServices41to48, sizeof(KUstServices41to48) / sizeof(SEnumFlag));
       
   436 			PrintServices(_L("49 to 56:"), serviceTable.iServices49To56, KUstServices49to56, sizeof(KUstServices49to56) / sizeof(SEnumFlag));
       
   437 			break;
       
   438 		case RMobilePhone::ECDMAServiceTable:
       
   439 			break;
       
   440 		case RMobilePhone::EUSIMEnabledServiceTable:
       
   441 			PrintServices(_L("1 to 8:  "), serviceTable.iServices1To8, KEstServices1to8, sizeof(KEstServices1to8) / sizeof(SEnumFlag));
       
   442 			break;
       
   443 #if defined (FSHELL_PLATFORM_S60) && FSHELL_PLATFORM_S60 >= 5
       
   444 		case RMobilePhone::EISIMServiceTable:
       
   445 			PrintServices(_L("1 to 8:  "), serviceTable.iServices1To8, KIstServices1to8, sizeof(KIstServices1to8) / sizeof(SEnumFlag));
       
   446 			break;
       
   447 #endif
       
   448 		}
       
   449 
       
   450 	if (iV2Tsy)
       
   451 		{
       
   452 		Write(_L("AID:\r\n"));
       
   453 		LtkUtils::HexDumpToOutput(serviceTable.iAID, Stdout());
       
   454 		}
       
   455 	}
       
   456 
       
   457 void CCmdIcc::DisplayFdnStatusL()
       
   458 	{
       
   459 	RMobilePhone::TMobilePhoneFdnStatus fdnStatus;
       
   460 	LeaveIfErr(iPhone.GetFdnStatus(fdnStatus), _L("Unable to get FDN status"));
       
   461 	switch (fdnStatus)
       
   462 		{
       
   463 		case RMobilePhone::EFdnNotActive:
       
   464 			Write(_L("EFdnNotActive\r\n"));
       
   465 			break;
       
   466 		case RMobilePhone::EFdnActive:
       
   467 			Write(_L("EFdnActive\r\n"));
       
   468 			break;
       
   469 		case RMobilePhone::EFdnPermanentlyActive:
       
   470 			Write(_L("EFdnPermanentlyActive\r\n"));
       
   471 			break;
       
   472 		case RMobilePhone::EFdnNotSupported:
       
   473 			Write(_L("EFdnNotSupported\r\n"));
       
   474 			break;
       
   475 		case RMobilePhone::EFdnUnknown:
       
   476 		default:
       
   477 			Write(_L("EFdnUnknown\r\n"));
       
   478 			break;
       
   479 		}
       
   480 	}
       
   481 
       
   482 void CCmdIcc::DisplayPhoneBookInfoL()
       
   483 	{
       
   484 	if (iStoreName == NULL)
       
   485 		{
       
   486 		LeaveIfErr(KErrArgument, _L("The name of the phone store must be specified using -s"));
       
   487 		}
       
   488 
       
   489 	if (iVerbose)
       
   490 		{
       
   491 		Printf(_L("Getting phone store info for phone book \"%S\"...\r\n"), iStoreName);
       
   492 		}
       
   493 
       
   494 	GetPhoneBookInfoL();
       
   495 
       
   496 	Printf(_L("Total number of entries:                 %d\r\n"), iStoreInfo.iTotalEntries);
       
   497 	Printf(_L("Used number of entries:                  %d\r\n"), iStoreInfo.iUsedEntries);
       
   498 	Printf(_L("Capabilities:                            0x%08x\r\n"), iStoreInfo.iCaps);
       
   499 	Printf(_L("Phone name:                              %S\r\n"), &iStoreInfo.iName);
       
   500 	Printf(_L("Maximum number length:                   %d\r\n"), iStoreInfo.iMaxNumLength);
       
   501 	Printf(_L("Maximum text length:                     %d\r\n"), iStoreInfo.iMaxTextLength);
       
   502 	Write( _L("Store location:                          "));
       
   503 	switch (iStoreInfo.iLocation)
       
   504 		{
       
   505 		default:
       
   506 		case RMobilePhoneBookStore::ELocationUnknown:
       
   507 			Write(_L("ELocationUnknown"));
       
   508 			break;
       
   509 		case RMobilePhoneBookStore::ELocationIccMemory:
       
   510 			Write(_L("ELocationIccMemory"));
       
   511 			break;
       
   512 		case RMobilePhoneBookStore::ELocationPhoneMemory:
       
   513 			Write(_L("ELocationPhoneMemory"));
       
   514 			break;
       
   515 		case RMobilePhoneBookStore::ELocationExternalMemory:
       
   516 			Write(_L("ELocationExternalMemory"));
       
   517 			break;
       
   518 		case RMobilePhoneBookStore::ELocationCombinedMemory:
       
   519 			Write(_L("ELocationCombinedMemory"));
       
   520 			break;
       
   521 		}
       
   522 	Write(_L("\r\n"));
       
   523 	Printf(_L("Change counter:                          %d\r\n"), iStoreInfo.iChangeCounter);
       
   524 	Printf(_L8("Phone book identity:                     %S\r\n"), &iStoreInfo.iIdentity);
       
   525 
       
   526 	if (iV2Tsy)
       
   527 		{
       
   528 		Printf(_L("Mode:                                    %S\r\n"), &iStoreInfo.iPhBkMode);
       
   529 		}
       
   530 
       
   531 	if (iV5Tsy)
       
   532 		{
       
   533 		Printf(_L("Maximum second names:                    %d\r\n"), iStoreInfo.iMaxSecondNames);
       
   534 		Printf(_L("Maximum text length second names:        %d\r\n"), iStoreInfo.iMaxTextLengthSecondName);
       
   535 		Printf(_L("Maximum additional numbers:              %d\r\n"), iStoreInfo.iMaxAdditionalNumbers);
       
   536 		Printf(_L("Maximum number length additional number: %d\r\n"), iStoreInfo.iMaxNumLengthAdditionalNumber);
       
   537 		Printf(_L("Maximum text length additional number:   %d\r\n"), iStoreInfo.iMaxTextLengthAdditionalNumber);
       
   538 		Printf(_L("Maximum group names:                     %d\r\n"), iStoreInfo.iMaxGroupNames);
       
   539 		Printf(_L("Maximum text length group name:          %d\r\n"), iStoreInfo.iMaxTextLengthGroupName);
       
   540 		Printf(_L("Maximum email address:                   %d\r\n"), iStoreInfo.iMaxEmailAddr);
       
   541 		Printf(_L("Maximum text length email address:       %d\r\n"), iStoreInfo.iMaxTextLengthEmailAddr);
       
   542 		}
       
   543 	}
       
   544 
       
   545 void CCmdIcc::DumpPhoneBookL()
       
   546 	{
       
   547 	if (iStoreName == NULL)
       
   548 		{
       
   549 		LeaveIfErr(KErrArgument, _L("The name of the phone store must be specified using -s"));
       
   550 		}
       
   551 
       
   552 	if (iVerbose)
       
   553 		{
       
   554 		Printf(_L("Dumping phone book store \"%S\"...\r\n"), iStoreName);
       
   555 		}
       
   556 
       
   557 	GetPhoneBookInfoL();
       
   558 
       
   559 	if (iVerbose)
       
   560 		{
       
   561 		Printf(_L("Phone book store has %d slots\r\n"), iStoreInfo.iTotalEntries);
       
   562 		}
       
   563 
       
   564 	for (TInt slotIndex = 0; slotIndex < iStoreInfo.iTotalEntries; ++slotIndex)
       
   565 		{
       
   566 		if (iVerbose)
       
   567 			{
       
   568 			Printf(_L("Reading slot %d...\r\n"), slotIndex);
       
   569 			}
       
   570 
       
   571 		TBuf8<1024> buf;
       
   572 		TRequestStatus status;
       
   573 		iPhoneBookStore.Read(status, slotIndex, 1, buf);
       
   574 		User::WaitForRequest(status);
       
   575 		if (status.Int() != KErrNone)
       
   576 			{
       
   577 			Printf(_L8("%d: %d\r\n"), slotIndex, status.Int());
       
   578 			}
       
   579 		else
       
   580 			{
       
   581 			Printf(_L8("%d:\r\n"), slotIndex);
       
   582 			LtkUtils::HexDumpToOutput(buf, Stdout());
       
   583 			Write(_L("\r\n"));
       
   584 			}
       
   585 		}
       
   586 	}
       
   587 
       
   588 void CCmdIcc::EditPhoneBookL()
       
   589 	{
       
   590 	if (iStoreName == NULL)
       
   591 		{
       
   592 		LeaveIfErr(KErrArgument, _L("The name of the phone store must be specified using -s"));
       
   593 		}
       
   594 
       
   595 	if (iData == NULL)
       
   596 		{
       
   597 		LeaveIfErr(KErrArgument, _L("The data to be entered must be specified using -d"));
       
   598 		}
       
   599 
       
   600 	if (!iOptions.IsPresent(&iSlot))
       
   601 		{
       
   602 		LeaveIfErr(KErrArgument, _L("The slot to be edited must be specified using -l"));
       
   603 		}
       
   604 
       
   605 	GetPhoneBookInfoL();
       
   606 	TRequestStatus status;
       
   607 	TPtrC8 data((const TUint8*)iData->Ptr(), iData->Size());
       
   608 
       
   609 	if (iVerbose)
       
   610 		{
       
   611 		Printf(_L("Writing the following to slot %d:\r\n"), iSlot);
       
   612 		LtkUtils::HexDumpToOutput(data, Stdout());
       
   613 		}
       
   614 
       
   615 	iPhoneBookStore.Write(status, data, iSlot);
       
   616 	User::WaitForRequest(status);
       
   617 	LeaveIfErr(status.Int(), _L("Unable to write to phone book store \"%S\""), iStoreName);
       
   618 	Printf(_L("Slot %d edited\r\n"), iSlot);
       
   619 	}
       
   620 
       
   621 void CCmdIcc::ApiSupported(TInt aApi, TBool& aIsSupported)
       
   622 	{
       
   623 	TInt err = iEtelServer.IsSupportedByModule(*iTsyName, aApi, aIsSupported);
       
   624 	if (err != KErrNone)
       
   625 		{
       
   626 		aIsSupported = EFalse;
       
   627 		}
       
   628 	}
       
   629 
       
   630 void CCmdIcc::GetPhoneBookInfoL()
       
   631 	{
       
   632 	if (iMode)
       
   633 		{
       
   634 		LeaveIfErr(iPhoneBookStore.Open(iPhone, *iStoreName, *iMode), _L("Unable to open phone book store \"%S\" in mode \"%S\""), iStoreName, iMode);
       
   635 		}
       
   636 	else
       
   637 		{
       
   638 		LeaveIfErr(iPhoneBookStore.Open(iPhone, *iStoreName), _L("Unable to open phone book store \"%S\""), iStoreName);
       
   639 		}
       
   640 
       
   641 	TRequestStatus status;
       
   642 	if (iV5Tsy)
       
   643 		{
       
   644 		TPckg<RMobilePhoneBookStore::TMobilePhoneBookInfoV5> pckg(iStoreInfo);
       
   645 		iPhoneBookStore.GetInfo(status, pckg);
       
   646 		}
       
   647 	else if (iV2Tsy)
       
   648 		{
       
   649 		TPckg<RMobilePhoneBookStore::TMobilePhoneBookInfoV2> pckg(iStoreInfo);
       
   650 		iPhoneBookStore.GetInfo(status, pckg);
       
   651 		}
       
   652 	else
       
   653 		{
       
   654 		TPckg<RMobilePhoneBookStore::TMobilePhoneBookInfoV1> pckg(iStoreInfo);
       
   655 		iPhoneBookStore.GetInfo(status, pckg);
       
   656 		}
       
   657 	User::WaitForRequest(status);
       
   658 	LeaveIfErr(status.Int(), _L("Couldn't get phone book store info"));
       
   659 	}
       
   660 
       
   661 void CCmdIcc::OpenPhoneL()
       
   662 	{
       
   663 	if (iTsyName == NULL)
       
   664 		{
       
   665 		CommsDat::CMDBSession* db = CommsDat::CMDBSession::NewLC(KCDLatestVersion);
       
   666 		CommsDat::CMDBField<TUint32>* globalSettingField = new(ELeave) CommsDat::CMDBField<TUint32>(CommsDat::KCDTIdModemPhoneServicesSMS);
       
   667 		CleanupStack::PushL(globalSettingField);
       
   668 		globalSettingField->SetRecordId(1);
       
   669 		globalSettingField->LoadL(*db);
       
   670 		TUint32 modemId = *globalSettingField;
       
   671 		CommsDat::CMDBField<TDesC>* tsyField = new(ELeave) CommsDat::CMDBField<TDesC>(CommsDat::KCDTIdTsyName);
       
   672 		CleanupStack::PushL(tsyField);
       
   673 		tsyField->SetRecordId(modemId);
       
   674 		TRAPL(tsyField->LoadL(*db), _L("Unable to read default TSY name"));
       
   675 		TBuf<KCommsDbSvrMaxFieldLength> tsyName;
       
   676 		tsyName = *tsyField;
       
   677 		iTsyName = tsyName.AllocL();
       
   678 		CleanupStack::PopAndDestroy(3, db); // db, tsyField & globalSettingField
       
   679 		}
       
   680 	
       
   681 	LeaveIfErr(iEtelServer.Connect(), _L("Unable to connect to the ETel server"));
       
   682 	LeaveIfErr(iEtelServer.LoadPhoneModule(*iTsyName), _L("Unable to load TSY module \"%S\""), iTsyName);
       
   683 	TInt numPhones = 0;
       
   684 	LeaveIfErr(iEtelServer.EnumeratePhones(numPhones), _L("Couldn't enumerate phones"));
       
   685 	TBool matchFound(EFalse);
       
   686 	TInt phoneIndex;
       
   687 	for (phoneIndex = 0; phoneIndex < numPhones; ++phoneIndex)
       
   688 		{
       
   689 		TName thisTsyName;
       
   690 		if ((iEtelServer.GetTsyName(phoneIndex, thisTsyName) == KErrNone) && (iTsyName->CompareF(thisTsyName) == KErrNone))
       
   691 			{
       
   692 			matchFound = ETrue;
       
   693 			break;
       
   694 			}
       
   695 		}
       
   696 	if (!matchFound)
       
   697 		{
       
   698 		LeaveIfErr(KErrNotFound, _L("Couldn't find phone using TSY \"%S\""), iTsyName);
       
   699 		}
       
   700 	RTelServer::TPhoneInfo phoneInfo;
       
   701 	LeaveIfErr(iEtelServer.GetPhoneInfo(phoneIndex, phoneInfo), _L("Couldn't get phone info"));
       
   702 	LeaveIfErr(iPhone.Open(iEtelServer, phoneInfo.iName), _L("Couldn't open phone"));
       
   703 
       
   704 	ApiSupported(KEtelExtMultimodeV5, iV5Tsy);
       
   705 	ApiSupported(KETelExtMultimodeV2, iV2Tsy);
       
   706 	ApiSupported(KEtelFuncMobileUSIMApplications, iUsimTsy);
       
   707 
       
   708 	if (iVerbose)
       
   709 		{
       
   710 		if (iUsimTsy)
       
   711 			{
       
   712 			Write(_L("TSY supports USIM API\r\n"));
       
   713 			}
       
   714 		if (iV2Tsy)
       
   715 			{
       
   716 			Write(_L("TSY supports V2 API\r\n"));
       
   717 			}
       
   718 		if (iV5Tsy)
       
   719 			{
       
   720 			Write(_L("TSY supports V5 API\r\n"));
       
   721 			}
       
   722 		}
       
   723 	}
       
   724 
       
   725 void CCmdIcc::ArgumentsL(RCommandArgumentList& aArguments)
       
   726 	{
       
   727 	_LIT(KOperationName, "operation");
       
   728 	aArguments.AppendEnumL((TInt&)iOperation, KOperationName);
       
   729 	}
       
   730 
       
   731 void CCmdIcc::OptionsL(RCommandOptionList& aOptions)
       
   732 	{
       
   733 	_LIT(KOptVerbose, "verbose");
       
   734 	aOptions.AppendBoolL(iVerbose, KOptVerbose);
       
   735 
       
   736 	_LIT(KOptTsyName, "tsy-name");
       
   737 	aOptions.AppendStringL(iTsyName, KOptTsyName);
       
   738 
       
   739 	_LIT(KArgServiceTable, "service-table");
       
   740 	aOptions.AppendUintL(iServiceTable, KArgServiceTable);
       
   741 
       
   742 	_LIT(KArgStoreName, "store-name");
       
   743 	aOptions.AppendStringL(iStoreName, KArgStoreName);
       
   744 
       
   745 	_LIT(KArgMode, "mode");
       
   746 	aOptions.AppendStringL(iMode, KArgMode);
       
   747 
       
   748 	_LIT(KArgSlot, "slot");
       
   749 	aOptions.AppendIntL(iSlot, KArgSlot);
       
   750 
       
   751 	_LIT(KArgData, "data");
       
   752 	aOptions.AppendStringL(iData, KArgData);
       
   753 	}
       
   754 
       
   755 
       
   756 EXE_BOILER_PLATE(CCmdIcc)
       
   757