codhandler/codeng/src/CodParser.cpp
changeset 10 a359256acfc6
parent 0 dd21522fd290
child 26 cb62a4f66ebe
equal deleted inserted replaced
5:10e98eab6f85 10:a359256acfc6
    65     iError = KErrNone;
    65     iError = KErrNone;
    66     iData = &aData;
    66     iData = &aData;
    67     iBuf = &aBuf;
    67     iBuf = &aBuf;
    68     iCurP = iBuf->Ptr();
    68     iCurP = iBuf->Ptr();
    69     iEndP = iCurP + iBuf->Length();
    69     iEndP = iCurP + iBuf->Length();
       
    70     CMediaObjectData *mediaObject = CMediaObjectData::NewL();
    70     // Processing lines (attribute and value) until there is more lines to read.
    71     // Processing lines (attribute and value) until there is more lines to read.
    71     while ( AttrLineL() )
    72     while ( AttrLineL(mediaObject) )
    72         {
    73         {
    73         // Some compilers require empty controlled statement block instead of
    74         // Some compilers require empty controlled statement block instead of
    74         // just a semicolon.
    75         // just a semicolon.
    75         }
    76         }
    76 
    77     iData->AppendMediaObjectL( mediaObject );   
    77 #ifdef __TEST_COD_LOG
    78 #ifdef __TEST_COD_LOG
    78     TPtrC ptr16;
    79     TPtrC ptr16;
    79     TPtrC8 ptr8;
    80     TPtrC8 ptr8;
    80     CLOG(( EParse, 3, _L("TCodParser::ParseL data:") ));
    81     CLOG(( EParse, 3, _L("TCodParser::ParseL data:") ));
    81     ptr16.Set( aData.Name() );
    82     ptr16.Set( aData.Name() );
   111 
   112 
   112 // ---------------------------------------------------------
   113 // ---------------------------------------------------------
   113 // TCodParser::AttrLineL()
   114 // TCodParser::AttrLineL()
   114 // ---------------------------------------------------------
   115 // ---------------------------------------------------------
   115 //
   116 //
   116 TBool TCodParser::AttrLineL()
   117 TBool TCodParser::AttrLineL(CMediaObjectData *& aMediaObject)
   117     {
   118     {
   118     SkipWhiteSpace();  // Skip lines which contain only WS and LF at the end.
   119     SkipWhiteSpace();  // Skip lines which contain only WS and LF at the end.
   119     while ( IsEndOfLine() )
   120     while ( IsEndOfLine() )
   120         {
   121         {
   121         NextLine();
   122         NextLine();
   129             {
   130             {
   130             case ECodName:
   131             case ECodName:
   131                 {
   132                 {
   132                 if ( Colon() )
   133                 if ( Colon() )
   133                     {
   134                     {
   134                     ok = iData->SetNameL( AttrValue() );
   135                     ok = aMediaObject->SetNameL( AttrValue() );
   135                     EndOfLine();
   136                     EndOfLine();
   136                     }
   137                     }
   137                 break;
   138                 break;
   138                 }
   139                 }
   139 
   140 
   149 
   150 
   150             case ECodDescription:
   151             case ECodDescription:
   151                 {
   152                 {
   152                 if ( Colon() )
   153                 if ( Colon() )
   153                     {
   154                     {
   154                     ok = iData->SetDescriptionL( AttrValue() );
   155                     ok = aMediaObject->SetDescriptionL( AttrValue() );
   155                     EndOfLine();
   156                     EndOfLine();
   156                     }
   157                     }
   157                 break;
   158                 break;
   158                 }
   159                 }
   159 
   160 
   164                     // Parse as TUint - negative not allowed.
   165                     // Parse as TUint - negative not allowed.
   165                     TUint size;
   166                     TUint size;
   166                     TLex lex( AttrValue() );
   167                     TLex lex( AttrValue() );
   167                     if ( !lex.Val( size ) )
   168                     if ( !lex.Val( size ) )
   168                         {
   169                         {
   169                         iData->SetSize( size );
   170                         aMediaObject->SetSize( size );
   170                         }
   171                         }
   171                     else
   172                     else
   172                         {
   173                         {
   173                         ok = EFalse;
   174                         ok = EFalse;
   174                         }
   175                         }
   179 
   180 
   180             case ECodInstallNotify:
   181             case ECodInstallNotify:
   181                 {
   182                 {
   182                 if ( Colon() )
   183                 if ( Colon() )
   183                     {
   184                     {
   184                     ok = iData->SetInstallNotifyL( AttrValue() );
   185                     ok = aMediaObject->SetInstallNotifyL( AttrValue() );
   185                     EndOfLine();
   186                     EndOfLine();
   186                     }
   187                     }
   187                 break;
   188                 break;
   188                 }
   189                 }
   189 
   190 
   209 
   210 
   210             case ECodInfoUrl:
   211             case ECodInfoUrl:
   211                 {
   212                 {
   212                 if ( Colon() )
   213                 if ( Colon() )
   213                     {
   214                     {
   214                     ok = iData->SetInfoUrlL( AttrValue() );
   215                     ok = aMediaObject->SetInfoUrlL( AttrValue() );
   215                     EndOfLine();
   216                     EndOfLine();
   216                     }
   217                     }
   217                 break;
   218                 break;
   218                 }
   219                 }
   219 
   220 
   220             case ECodPrice:
   221             case ECodPrice:
   221                 {
   222                 {
   222                 if ( Colon() )
   223                 if ( Colon() )
   223                     {
   224                     {
   224                     ok = iData->SetPriceL( AttrValue() );
   225                     ok = aMediaObject->SetPriceL( AttrValue() );
   225                     EndOfLine();
   226                     EndOfLine();
   226                     }
   227                     }
   227                 break;
   228                 break;
   228                 }
   229                 }
   229 
   230 
   230             case ECodIcon:
   231             case ECodIcon:
   231                 {
   232                 {
   232                 if ( Colon() )
   233                 if ( Colon() )
   233                     {
   234                     {
   234                     ok = iData->SetIconL( AttrValue() );
   235                     ok = aMediaObject->SetIconL( AttrValue() );
       
   236                     EndOfLine();
       
   237                     }
       
   238                 break;
       
   239                 }
       
   240             case ECodType:
       
   241                 {
       
   242                 if ( Colon() )
       
   243                     {
       
   244                     ok = aMediaObject->SetTypeL( AttrValue() );
       
   245                     EndOfLine();
       
   246                     }
       
   247                 break;
       
   248                 }
       
   249             case ECodUrl:
       
   250                 {
       
   251                 if ( Colon() )
       
   252                     {
       
   253                     ok = aMediaObject->SetUrlL( AttrValue() );
   235                     EndOfLine();
   254                     EndOfLine();
   236                     }
   255                     }
   237                 break;
   256                 break;
   238                 }
   257                 }
   239 
   258