javacommons/connectionmanager/src.s60/connectionmanager.cpp
branchRCL_3
changeset 19 04becd199f91
child 47 f40128debb5d
child 50 023eef975703
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "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 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Connection Manager
       
    15 *                Provides Native conection management for all Java Connections:
       
    16                  - Network Access selection
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #include <memory>
       
    22 #include <agentdialog.h>                    // RGenConAgentDialogServer
       
    23 #include <commsdattypesv1_1.h>              // TMDBElementId
       
    24 #include <logger.h>
       
    25 #include <commdb.h>
       
    26 #include <cmmanager.h>
       
    27 #include <cmdefconnvalues.h>
       
    28 #include <cmmanagerdef.h>
       
    29 #include <javastorageentry.h>
       
    30 #include <javastorage.h>
       
    31 #include <javastoragenames.h>
       
    32 #include <javasymbianoslayer.h>
       
    33 #include <cmdestination.h>
       
    34 #include "connectionmanager.h"
       
    35 #include "javacommonutils.h"
       
    36 #include "s60commonutils.h"
       
    37 
       
    38 using namespace java::storage;
       
    39 using namespace CMManager;
       
    40 
       
    41 _LIT8(KAskAlwaysId, "A");
       
    42 _LIT8(KAskOnceId, "O");
       
    43 _LIT8(KDefaultConn, "F");
       
    44 _LIT8(KSnapId, "D");
       
    45 _LIT8(KIapId, "I");
       
    46 
       
    47 
       
    48 enum JavaNetworkAccessPointType
       
    49 {
       
    50     ENapNone = 0,               ///< Not defined
       
    51     ENapAskAlways,              ///< Always ask
       
    52     ENapDefault,                ///< Default Conn
       
    53     ENapSnap,                   ///< SNAP ID is selected
       
    54     ENapIap,                    ///< IAP ID is selected
       
    55 };
       
    56 
       
    57 
       
    58 // Byte shift
       
    59 const TInt KShift8 = 8;
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 // ConnectionManager::isIapDefault
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 
       
    66 EXPORT_C bool ConnectionManager::isIapDefault(TUint32 aMatchIapId, TUint32 aDestId, bool aDefault)
       
    67 {
       
    68     LOG(ESOCKET,EInfo,"+ConnectionManager::getDefualtId");
       
    69     TUint32 id = aDestId;
       
    70     TUint32 tmpapId;
       
    71     TCmDefConnType type;
       
    72 
       
    73     RCmManager * mgr = new(ELeave) RCmManager();
       
    74     mgr->OpenL();
       
    75 
       
    76     if (aDefault)
       
    77     {
       
    78         TCmDefConnValue obj;
       
    79         mgr->ReadDefConnL(obj);
       
    80         id = obj.iId;
       
    81         type = obj.iType;
       
    82         if ((type ==ECmDefConnConnectionMethod) && (type == aMatchIapId))
       
    83         {
       
    84             return true;
       
    85         }
       
    86         else if (type != ECmDefConnDestination)
       
    87         {
       
    88             return false;
       
    89         }
       
    90     }
       
    91 
       
    92     RCmDestination tmpdst =     mgr->DestinationL(id);
       
    93     ILOG1(ESOCKET,"Is connected return value = %d ", tmpdst.IsConnectedL());
       
    94     if (!(tmpdst.IsConnectedL()))
       
    95     {
       
    96         return false;   // no access point within this destination are active
       
    97     }
       
    98     for (TInt j = 0; j < tmpdst.ConnectionMethodCount(); j++)
       
    99     {
       
   100         tmpapId = tmpdst.ConnectionMethodL(j).GetIntAttributeL(ECmIapId);
       
   101         ILOG1(ESOCKET,"tmpai id = %d   ",tmpapId);
       
   102         if (tmpapId == aMatchIapId)
       
   103         {
       
   104             return true;
       
   105         }
       
   106     }
       
   107     return false;
       
   108 
       
   109 }
       
   110 
       
   111 // ---------------------------------------------------------------------------
       
   112 // JavaNetworkAccessRepository::GetDeviceDefaultAccessPointL
       
   113 // ---------------------------------------------------------------------------
       
   114 //
       
   115 void ConnectionManager
       
   116 ::GetDeviceDefaultAccessPointL(char * access)
       
   117 {
       
   118     int id;
       
   119     TCmDefConnType type;
       
   120     LOG(ESOCKET,EInfo,"+GetDeviceDefaultAccessPointL");
       
   121 
       
   122     RCmManager * mgr = new(ELeave) RCmManager();
       
   123     mgr->OpenLC();
       
   124     TCmDefConnValue obj;
       
   125     HBufC8 * des;
       
   126 
       
   127 
       
   128     mgr->ReadDefConnL(obj);
       
   129     id = obj.iId;
       
   130     type = obj.iType;
       
   131     LOG1(ESOCKET,EInfo,"readDefConnL returned %d",id);
       
   132     LOG1(ESOCKET,EInfo,"type is %d",type);
       
   133     CleanupStack::PopAndDestroy();
       
   134 
       
   135 
       
   136     if (type == ECmDefConnAskOnce || type == ECmDefConnConnectionMethod || type == ECmDefConnDestination)
       
   137     {
       
   138         des = CreateDescriptorL(type,id);
       
   139     }
       
   140     else
       
   141     {
       
   142         des = PromptUserSelectNetworkAccessPointL();
       
   143         LOG(ESOCKET,EInfo," after PromptUserSelectNetworkAccessPointL ");
       
   144     }
       
   145     TInt len = des->Length();
       
   146     LOG1(ESOCKET,EInfo,"+des length =  %d",len);
       
   147     LOG(ESOCKET,EInfo,"after lenght");
       
   148     memcpy(access, des->Des().PtrZ(),len+1);
       
   149     LOG(ESOCKET,EInfo,"after memcpy");
       
   150     LOG1(ESOCKET,EInfo,"+apnInfo =  %s",access);
       
   151     LOG1(ESOCKET,EInfo,"+apnInfo =  %s",access);
       
   152     CleanupStack::PopAndDestroy(des);
       
   153 }
       
   154 
       
   155 void ConnectionManager
       
   156 ::PromptUserL(char * access)
       
   157 {
       
   158     HBufC8 * des;
       
   159     des = PromptUserSelectNetworkAccessPointL();
       
   160     TInt len = des->Length();
       
   161     memcpy(access, des->Des().PtrZ(),len+1);
       
   162     CleanupStack::PopAndDestroy(des);
       
   163 }
       
   164 
       
   165 // ---------------------------------------------------------------------------
       
   166 // JavaNetworkAccessRepository::PromptUserSelectNetworkAccessL
       
   167 // ---------------------------------------------------------------------------
       
   168 //
       
   169 HBufC8 *ConnectionManager
       
   170 ::PromptUserSelectNetworkAccessPointL()
       
   171 {
       
   172     LOG(ESOCKET,EInfo,"+PromptUserSelectNetworkAccessPointL");
       
   173     TUint32 id((TUint32)KJavaNetworkAccessNotSpecified);
       
   174     TUint32 snapOrIapId(0);
       
   175 
       
   176     TConnectionPrefs prefs;
       
   177     prefs.iRank = 1;
       
   178     prefs.iDirection = ECommDbConnectionDirectionOutgoing;
       
   179     prefs.iBearerSet = ECommDbBearerCSD | ECommDbBearerWcdma
       
   180                        | ECommDbBearerLAN | ECommDbBearerVirtual
       
   181 #ifdef RD_JAVA_SUPPORT_CDMA
       
   182                        | ECommDbBearerCdma2000
       
   183 #endif
       
   184                        | ECommDbBearerPSD
       
   185                        | ECommDbBearerPAN | ECommDbBearerWLAN;
       
   186 
       
   187     TUint32 dummy(0);
       
   188 
       
   189     RGenConAgentDialogServer dlgSv;
       
   190     CleanupClosePushL(dlgSv);
       
   191     User::LeaveIfError(dlgSv.Connect());
       
   192 
       
   193 
       
   194     TRequestStatus status(KRequestPending);
       
   195     LOG(ESOCKET,EInfo,"prompting by regenconagent ");
       
   196     dlgSv.AccessPointConnection(dummy, dummy, snapOrIapId, prefs.iBearerSet, status);
       
   197     User::WaitForRequest(status);
       
   198     CleanupStack::PopAndDestroy(&dlgSv);
       
   199     User::LeaveIfError(status.Int());
       
   200 
       
   201 
       
   202     TMDBElementId tableId = snapOrIapId & KCDMaskShowRecordType;
       
   203     if (tableId == KCDTIdNetworkRecord)
       
   204     {
       
   205         // User selects SNAP
       
   206         LOG(ESOCKET,EInfo,"user selected SNAP");
       
   207         id = (snapOrIapId & KCDMaskShowRecordId) >> KShift8;
       
   208         return CreateDescriptorL(2, id);
       
   209     }
       
   210     else if (tableId == KCDTIdIAPRecord)
       
   211     {
       
   212         // User selects IAP
       
   213         LOG(ESOCKET,EInfo,"user selected IAP");
       
   214         id = (snapOrIapId & KCDMaskShowRecordId) >> KShift8;
       
   215         return CreateDescriptorL(3, id);
       
   216     }
       
   217     else
       
   218     {
       
   219         // Uknown selection
       
   220     }
       
   221     return 0;
       
   222 }
       
   223 
       
   224 // ---------------------------------------------------------------------------
       
   225 // NetworkAccessRepository::DescriptorLC
       
   226 // ---------------------------------------------------------------------------
       
   227 //
       
   228 HBufC8 * ConnectionManager::CreateDescriptorL(const int aType, const int id)
       
   229 {
       
   230     LOG(ESOCKET,EInfo,"+ConnectionManager::CreateDescriptorL");
       
   231     HBufC8* des = HBufC8::NewLC(256);
       
   232     TPtr8 ptr(des->Des());
       
   233     switch (aType)
       
   234     {
       
   235     case ECmDefConnAlwaysAsk :
       
   236         ptr = KAskAlwaysId();
       
   237         break;
       
   238     case ECmDefConnAskOnce :
       
   239         ptr = KAskOnceId();
       
   240         break;
       
   241 
       
   242     case ECmDefConnDestination :
       
   243         if (id == KDefaultConnection)
       
   244         {
       
   245             // case of defaultconnection set in app settings
       
   246             // store 'F' into java storage
       
   247             ptr = KDefaultConn();
       
   248         }
       
   249         else
       
   250         {
       
   251             ptr = KSnapId();
       
   252             ptr.AppendNum(id);
       
   253         }
       
   254         break;
       
   255     case ECmDefConnConnectionMethod :
       
   256         LOG(ESOCKET,EInfo,"ECmDefConnConnectionMethod case");
       
   257         ptr = KIapId();
       
   258         ptr.AppendNum(id);
       
   259         break;
       
   260     default :
       
   261         User::Leave(KErrNotSupported);
       
   262         break;
       
   263     }
       
   264     // CleanupStack::PopAndDestroy();
       
   265     LOG(ESOCKET,EInfo,"-ConnectionManager::CreateDescriptorL");
       
   266     return des;
       
   267 }
       
   268 
       
   269 EXPORT_C unsigned int ConnectionManager::getDestinationNetworkIdL(Uid aAppSuiteUid)
       
   270 {
       
   271     JavaStorageApplicationEntry_t entries;
       
   272     std::wstring temp;
       
   273     JavaStorageEntry attribute;
       
   274     int snapid = KJavaNetworkAccessNotSpecified;
       
   275     std::auto_ptr<JavaStorage> js(JavaStorage::createInstance());
       
   276 
       
   277     js->open(JAVA_DATABASE_NAME);
       
   278 
       
   279 
       
   280     // Read all attributes of one application specified by UID.
       
   281     js->read(APPLICATION_PACKAGE_TABLE, aAppSuiteUid, entries);
       
   282     js->close();
       
   283 
       
   284     // set the entry as ACCESS_POINT
       
   285     attribute.setEntry(ACCESS_POINT, L"");
       
   286 
       
   287     // Get value of the attribute from read attributes.
       
   288     while (!entries.empty())
       
   289     {
       
   290         JavaStorageApplicationEntry_t::const_iterator findIterator = entries.find(attribute);
       
   291 
       
   292         if (findIterator != entries.end())
       
   293         {
       
   294             JavaStorageEntry sourceEntry = (*findIterator);
       
   295             temp.append(sourceEntry.entryValue().c_str());
       
   296             HBufC * value = S60CommonUtils::wstringToDes(temp.c_str());
       
   297             HBufC8 * temp1 = HBufC8::NewL(value->Des().Length());
       
   298             temp1->Des().Copy(value->Des());
       
   299             TRAP_IGNORE(snapid = ParseNetworkAccessPointL(*temp1));
       
   300         }
       
   301         else
       
   302         {
       
   303             LOG(ESOCKET,EInfo,"Name attribute does not exists.");
       
   304         }
       
   305         entries.clear();
       
   306     }
       
   307     return snapid;
       
   308 }
       
   309 
       
   310 EXPORT_C unsigned int ConnectionManager::getApnIdL(Uid aAppSuiteUid)
       
   311 {
       
   312     int apnid = KJavaNetworkAccessNotSpecified;
       
   313     JavaStorageApplicationEntry_t entries;
       
   314     std::auto_ptr<JavaStorage> js(JavaStorage::createInstance());
       
   315 
       
   316     try
       
   317     {
       
   318         js->open();
       
   319         js->read(APPLICATION_PACKAGE_TABLE, aAppSuiteUid, entries);
       
   320         js->close();
       
   321     }
       
   322     catch (JavaStorageException& aJse)
       
   323     {
       
   324         LOG1(ESOCKET, EInfo,"APN read error: %s", aJse.toString().c_str());
       
   325         return apnid;
       
   326     }
       
   327 
       
   328     JavaStorageEntry attribute;
       
   329     attribute.setEntry(ACCESS_POINT, L"");
       
   330 
       
   331     JavaStorageApplicationEntry_t::const_iterator findIterator
       
   332     = entries.find(attribute);
       
   333 
       
   334     if (findIterator != entries.end())
       
   335     {
       
   336         std::auto_ptr<HBufC>value(S60CommonUtils::wstringToDes(
       
   337                                       (*findIterator).entryValue().c_str()));
       
   338         std::auto_ptr<HBufC8> temp1(HBufC8::NewL(value->Des().Length()));
       
   339         temp1->Des().Copy(value->Des());
       
   340         TRAP_IGNORE(apnid = ParseNetworkAccessPointL(*temp1));
       
   341     }
       
   342     else
       
   343     {
       
   344         WLOG1WSTR(ESOCKET, "APN ID not found for the Application: %s",
       
   345                   aAppSuiteUid.toString());
       
   346     }
       
   347     return apnid;
       
   348 }
       
   349 
       
   350 
       
   351 EXPORT_C void ConnectionManager::setApnIdL(Uid aAppSuiteUid,int aApnId)
       
   352 {
       
   353     // only IAP ids supported
       
   354     std::auto_ptr<HBufC8>des(CreateDescriptorL(ECmDefConnConnectionMethod, aApnId));
       
   355     CleanupStack::Pop(); // Pop CreateDescriptorL added HBufC from cleanupstack.
       
   356 
       
   357     std::auto_ptr<HBufC> temp1(HBufC::NewL(des->Des().Length() + 1));
       
   358     temp1->Des().Copy(des->Des());
       
   359 
       
   360     TPtr ptr = temp1->Des();
       
   361     std::wstring apnString(desToWstring(ptr));
       
   362 
       
   363     LOG1(ESOCKET,EInfo,"ConnectionManager::setApnIdL() - len of apnString = %d",
       
   364          apnString.size());
       
   365 
       
   366     LOG1WSTR(ESOCKET,
       
   367              EInfo,
       
   368              "COnnectionManager::setApnIdL() - storing %s into javastorage",
       
   369              apnString);
       
   370 
       
   371     JavaStorageApplicationEntry_t matchEntries;
       
   372     std::auto_ptr<JavaStorage> js(JavaStorage::createInstance());
       
   373 
       
   374     try
       
   375     {
       
   376         js->open();
       
   377         // Check application really exists there. Otherwise orphaned column is
       
   378         // written to storage.
       
   379         js->read(APPLICATION_PACKAGE_TABLE, aAppSuiteUid, matchEntries);
       
   380         if (matchEntries.size() > 0)
       
   381         {
       
   382             JavaStorageApplicationEntry_t updateEntries;
       
   383             JavaStorageEntry attribute;
       
   384 
       
   385             attribute.setEntry(ACCESS_POINT, apnString);
       
   386             updateEntries.insert(attribute);
       
   387 
       
   388             matchEntries.clear();
       
   389             attribute.setEntry(ID, aAppSuiteUid.toString());
       
   390             matchEntries.insert(attribute);
       
   391 
       
   392             js->update(APPLICATION_PACKAGE_TABLE, updateEntries, matchEntries);
       
   393         }
       
   394     }
       
   395     catch (JavaStorageException& aJse)
       
   396     {
       
   397         WLOG1(ESOCKET, "Connection manager failed to store access point: %s", aJse.toString().c_str());
       
   398     }
       
   399 
       
   400     js->close();
       
   401 }
       
   402 EXPORT_C void ConnectionManager::setDestinationNetworkIdL(Uid aAppSuiteUid,int aSnapId)
       
   403 {
       
   404     std::auto_ptr<JavaStorage> js(JavaStorage::createInstance());
       
   405     JavaStorageApplicationEntry_t updateEntries;
       
   406     JavaStorageApplicationEntry_t matchEntries;
       
   407     JavaStorageEntry attribute;
       
   408     HBufC8* des = 0;
       
   409     try
       
   410     {
       
   411         js->open(JAVA_DATABASE_NAME);
       
   412     }
       
   413     catch (JavaStorageException jse)
       
   414     {
       
   415         LOG(ESOCKET,EInfo,"opening javastorage db failed");
       
   416     }
       
   417 
       
   418     // only SNAP ids supported
       
   419     if (aSnapId == KAlwaysAskId)
       
   420     {
       
   421         des = CreateDescriptorL(ECmDefConnAlwaysAsk,KAlwaysAskId);
       
   422     }
       
   423     else
       
   424     {
       
   425         if (aSnapId == KDefaultConnection)
       
   426         {
       
   427             des = CreateDescriptorL(ECmDefConnDestination,KDefaultConnection);
       
   428         }
       
   429         else
       
   430         {
       
   431             des = CreateDescriptorL(ECmDefConnDestination,aSnapId);
       
   432         }
       
   433     }
       
   434 
       
   435     HBufC* temp1 = HBufC::NewL(des->Des().Length()+1);
       
   436     temp1->Des().Copy(des->Des());
       
   437 
       
   438     int len1 = des->Length();
       
   439     int len2 = temp1->Length();
       
   440     LOG2(ESOCKET,EInfo,"ConnectionManager::setApnIdL() - len1= %d, len2 = %d",len1, len2);
       
   441     wchar_t* apnString = new wchar_t[len2+1];
       
   442 
       
   443     TPtr ptr = temp1->Des();
       
   444     TPtr ptr16((TUint16*)apnString,len2+1);
       
   445 
       
   446     ptr16.Copy(ptr);
       
   447     ptr16.SetLength(len2);
       
   448     ptr16.ZeroTerminate();
       
   449 
       
   450     LOG1(ESOCKET,EInfo,"ConnectionManager::setApnIdL() - len of apnString = %d", wcslen(apnString));
       
   451 
       
   452     std::wstring tmpstring(apnString);
       
   453     char *dirName = JavaCommonUtils::wstringToUtf8(tmpstring);
       
   454     LOG1(ESOCKET,EInfo,"COnnectionManager::setApnIdL() - storing %s into javastorage",dirName);
       
   455 
       
   456 
       
   457     js->startTransaction();
       
   458 
       
   459     attribute.setEntry(ACCESS_POINT, apnString);
       
   460     updateEntries.insert(attribute);
       
   461 
       
   462     attribute.setEntry(ID, aAppSuiteUid.toString());
       
   463     matchEntries.insert(attribute);
       
   464 
       
   465 
       
   466     LOG(ESOCKET,EInfo,"ConnectionManager::setApnIdL() - before js update");
       
   467     try
       
   468     {
       
   469         js->update(APPLICATION_PACKAGE_TABLE, updateEntries, matchEntries);
       
   470     }
       
   471     catch (JavaStorageException jse)
       
   472     {
       
   473         ELOG1(ESOCKET,"Updating the javastorage db failed %S",jse.toString().c_str());
       
   474         js->close();
       
   475         CleanupStack::PopAndDestroy(des);
       
   476         return;
       
   477     }
       
   478 
       
   479     try
       
   480     {
       
   481         js->commitTransaction();
       
   482     }
       
   483     catch (JavaStorageException jse)
       
   484     {
       
   485         ELOG(ESOCKET,"Commit transaction in javastorage db failed");
       
   486         js->close();
       
   487         CleanupStack::PopAndDestroy(des);
       
   488         return;
       
   489     }
       
   490 
       
   491     js->close();
       
   492     updateEntries.clear();
       
   493     matchEntries.clear();
       
   494     CleanupStack::PopAndDestroy(des);
       
   495 }
       
   496 
       
   497 unsigned int ConnectionManager::ParseNetworkAccessPointL(const TDesC8& aDes)
       
   498 {
       
   499     JavaNetworkAccessPointType type(ENapNone);
       
   500     TUint32 id = (TUint32)KJavaNetworkAccessNotSpecified;
       
   501 
       
   502     TLex8 charLexer(aDes);
       
   503     charLexer.Mark();
       
   504     // First character in descriptor MUST indicates Network Access type <(A)|(D|I)ID>
       
   505     if (!(charLexer.Peek()).IsAlpha())
       
   506     {
       
   507         // First character in descriptor IS NOT alpha
       
   508         User::Leave(KErrCorrupt);
       
   509     }
       
   510 
       
   511     // First character in descriptor IS alpha
       
   512     charLexer.Inc();
       
   513     TPtrC8 parsedText(charLexer.MarkedToken());
       
   514 
       
   515     // Parse what Network Access type is indicated
       
   516     if (parsedText.Compare(KAskAlwaysId) == 0)
       
   517     {
       
   518         type = ENapAskAlways;
       
   519         id = (TUint32) KAlwaysAskId;
       
   520     }
       
   521     // In case of default connection, equal to'F' case
       
   522     // return KDefaultConnection to app mgr
       
   523     else if (parsedText.Compare(KDefaultConn) == 0)
       
   524     {
       
   525         type = ENapDefault;
       
   526         id = (TUint32) KDefaultConnection;
       
   527     }
       
   528     else if (parsedText.Compare(KSnapId) == 0)
       
   529     {
       
   530         type = ENapSnap;
       
   531     }
       
   532     else if (parsedText.Compare(KIapId) == 0)
       
   533     {
       
   534         type = ENapIap;
       
   535     }
       
   536     else
       
   537     {
       
   538         // First character IS NOT pre-defined indicator
       
   539         User::Leave(KErrCorrupt);
       
   540     }
       
   541 
       
   542     if (type == ENapAskAlways || type == ENapDefault)
       
   543     {
       
   544         // Descriptor MUST contain only indicator
       
   545         if (!charLexer.Eos())
       
   546         {
       
   547             // Descriptor contains more than indicator
       
   548             User::Leave(KErrArgument);
       
   549         }
       
   550         // Success go to end
       
   551     }
       
   552     else
       
   553     {
       
   554         // Descriptor MUST contain only indicator and Network Access Point ID
       
   555         if (charLexer.Eos())
       
   556         {
       
   557             // Descriptor contains only indicator
       
   558             User::Leave(KErrCorrupt);
       
   559         }
       
   560 
       
   561         charLexer.Mark();
       
   562         charLexer.Inc();
       
   563         // Parse Network Access Point ID
       
   564         while ((charLexer.Peek()).IsDigit())
       
   565         {
       
   566             charLexer.Inc();    // move to next char
       
   567         }
       
   568 
       
   569         // get token
       
   570         TPtrC8 parsedNumber = charLexer.MarkedToken();
       
   571         TLex8 numLexer(parsedNumber);
       
   572         // try to convert token to number
       
   573         if (numLexer.Val(id, EDecimal) != KErrNone)
       
   574         {
       
   575             // Converting fails
       
   576             User::Leave(KErrCorrupt);
       
   577         }
       
   578 
       
   579         // Descriptor MUST contain only indicator and Network Access Point ID
       
   580         if (!charLexer.Eos())
       
   581         {
       
   582             // Descriptor contains more than indicator and Network Access ID
       
   583             User::Leave(KErrCorrupt);
       
   584         }
       
   585         // Success go to end
       
   586     }
       
   587     return id;
       
   588 }