mediasettings/mediasettingsengine/src/MPSettingsRopConfigParser.cpp
changeset 0 96612d01cf9f
child 20 2d690156cf8f
equal deleted inserted replaced
-1:000000000000 0:96612d01cf9f
       
     1 /*
       
     2 * Copyright (c) 2002 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 the License "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:   Config descriptor parser for ROP specific settings.*
       
    15 */
       
    16 
       
    17 
       
    18 // Version : %version: 3 %
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 // INCLUDE FILES
       
    24 #include    <utf.h>
       
    25 #include    "MPSettingsRopConfigParser.h"
       
    26 #include	"mpxlog.h"
       
    27 
       
    28 // CONSTANTS
       
    29 const TInt KMPRopEntryArrayGranularity = 16;
       
    30 
       
    31 _LIT8(KMPRopTypeInteger, "Integer");
       
    32 _LIT8(KMPRopTypeString, "String");
       
    33 _LIT8(KMPRopEntrySeparator, ";");
       
    34 _LIT8(KMPRopKeySeparator, ":");
       
    35 _LIT8(KMPRopValueSeparator, "=");
       
    36 _LIT8(KMPRopStringConstrainer, "\"");
       
    37 _LIT8(KMPRopArrayOpeningMarker, "{");
       
    38 _LIT8(KMPRopArrayClosingMarker, "}");
       
    39 _LIT8(KMPRopArraySeparator, ",");
       
    40 _LIT8(KMPRopIntegerEntryPrototype, "%S:Integer = %d;");
       
    41 _LIT8(KMPRopStringEntryPrototype, "%S:String = \"%S\";");
       
    42 
       
    43 const TInt KMPRopIntegerEntryPrototypeStaticLength = 23; // static length + 11 chars for the (32bit) TInt
       
    44 const TInt KMPRopStringEntryPrototypeStaticLength = 13;
       
    45 
       
    46 
       
    47 // ============================ MEMBER FUNCTIONS ===============================
       
    48 
       
    49 // *******************************
       
    50 // *** class CMPRopSettingItem ***
       
    51 // *******************************
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CMPRopSettingItem::CMPRopSettingItem
       
    55 // C++ default constructor can NOT contain any code, that
       
    56 // might leave.
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 CMPRopSettingItem::CMPRopSettingItem(TInt aId) : iId(aId),
       
    60     iValueChanged(EFalse)
       
    61     {
       
    62     MPX_DEBUG1(_L("#MS# CMPRopSettingItem::CMPRopSettingItem()"));
       
    63     }
       
    64 
       
    65 // -----------------------------------------------------------------------------
       
    66 // CMPRopSettingItem::ConstructL
       
    67 // Symbian 2nd phase constructor can leave.
       
    68 // -----------------------------------------------------------------------------
       
    69 //
       
    70 void CMPRopSettingItem::ConstructL(const TDesC& aKey)
       
    71     {
       
    72     MPX_DEBUG2(_L("#MS# CMPRopSettingItem::ConstructL(%S)"),&aKey);
       
    73     iKey = HBufC8::NewL(aKey.Length());
       
    74     TPtr8 ptr = iKey->Des();
       
    75     CnvUtfConverter::ConvertFromUnicodeToUtf8(ptr, aKey);
       
    76     }
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CMPRopSettingItem::NewLC
       
    80 // Two-phased constructor.
       
    81 // -----------------------------------------------------------------------------
       
    82 //
       
    83 CMPRopSettingItem* CMPRopSettingItem::NewLC(TInt aId, const TDesC& aKey)
       
    84     {
       
    85     MPX_DEBUG3(_L("#MS# CMPRopSettingItem::NewLC(%d,%S)"),aId,&aKey);
       
    86     CMPRopSettingItem* self = new(ELeave) CMPRopSettingItem(aId);
       
    87     
       
    88     CleanupStack::PushL(self);
       
    89     self->ConstructL(aKey);
       
    90 
       
    91     return self;
       
    92     }
       
    93    
       
    94 // -----------------------------------------------------------------------------
       
    95 // CMPRopSettingItem::~CMPRopSettingItem
       
    96 // Destructor
       
    97 // -----------------------------------------------------------------------------
       
    98 //
       
    99 CMPRopSettingItem::~CMPRopSettingItem()
       
   100     {
       
   101     MPX_DEBUG1(_L("#MS# CMPRopSettingItem::~CMPRopSettingItem()"));
       
   102     if (iKey) 
       
   103 		{
       
   104 		delete iKey;
       
   105 		}
       
   106     delete iStringValue;
       
   107     iIntArray.Close();
       
   108     }
       
   109 
       
   110 
       
   111 // ****************************************
       
   112 // *** class CMPSettingsRopConfigParser ***
       
   113 // ****************************************
       
   114 
       
   115 // -----------------------------------------------------------------------------
       
   116 // CMPSettingsRopConfigParser::CMPSettingsRopConfigParser
       
   117 // C++ default constructor can NOT contain any code, that
       
   118 // might leave.
       
   119 // -----------------------------------------------------------------------------
       
   120 //
       
   121 CMPSettingsRopConfigParser::CMPSettingsRopConfigParser()
       
   122     {
       
   123     MPX_DEBUG1(_L("#MS# CMPSettingsRopConfigParser::CMPSettingsRopConfigParser()"));
       
   124     }
       
   125    
       
   126 // -----------------------------------------------------------------------------
       
   127 // CMPSettingsRopConfigParser::~CMPSettingsRopConfigParser
       
   128 // Destructor
       
   129 // -----------------------------------------------------------------------------
       
   130 //
       
   131 CMPSettingsRopConfigParser::~CMPSettingsRopConfigParser()
       
   132     {
       
   133     MPX_DEBUG1(_L("#MS# CMPSettingsRopConfigParser::~CMPSettingsRopConfigParser()"));
       
   134 	if (iEntries)
       
   135       iEntries->ResetAndDestroy();
       
   136     delete iEntries;
       
   137     delete iTmpBuf;
       
   138     delete iConfigHeader;
       
   139     }
       
   140 
       
   141 // -----------------------------------------------------------------------------
       
   142 // CMPSettingsRopConfigParser::ConstructL
       
   143 // Symbian 2nd phase constructor can leave.
       
   144 // -----------------------------------------------------------------------------
       
   145 //
       
   146 void CMPSettingsRopConfigParser::ConstructL()
       
   147     {
       
   148     MPX_DEBUG1(_L("#MS# CMPSettingsRopConfigParser::ConstructL()"));
       
   149     iEntries = new(ELeave) CArrayPtrFlat<HBufC8>(KMPRopEntryArrayGranularity);
       
   150     }
       
   151 
       
   152 // -----------------------------------------------------------------------------
       
   153 // CMPSettingsRopConfigParser::NewL
       
   154 // Two-phased constructor.
       
   155 // -----------------------------------------------------------------------------
       
   156 //
       
   157 CMPSettingsRopConfigParser* CMPSettingsRopConfigParser::NewL()
       
   158     {
       
   159     MPX_DEBUG1(_L("#MS# CMPSettingsRopConfigParser::NewL()"));
       
   160     CMPSettingsRopConfigParser* self = new(ELeave) CMPSettingsRopConfigParser;
       
   161     
       
   162     CleanupStack::PushL(self);
       
   163     self->ConstructL();
       
   164     CleanupStack::Pop();
       
   165 
       
   166     return self;
       
   167     }
       
   168 
       
   169 // -----------------------------------------------------------------------------
       
   170 // CMPSettingsRopConfigParser::ParseConfigStringL
       
   171 // -----------------------------------------------------------------------------
       
   172 //
       
   173 HBufC8* CMPSettingsRopConfigParser::ParseConfigStringL(const TDesC8& aConfigString, const CArrayPtr<CMPRopSettingItem>* aItemArray)
       
   174     {
       
   175     MPX_DEBUG1(_L("#MS# CMPSettingsRopConfigParser::ParseConfigStringL()"));
       
   176     iBufferPtr.Set(aConfigString);
       
   177     iItemArray = aItemArray;
       
   178     
       
   179     // Parse header
       
   180     HBufC8* header = ParseConfigHeaderL();
       
   181     CleanupStack::PushL(header);
       
   182 
       
   183     // Read all config entries to an array
       
   184     PopulateEntryArrayFromConfigStringL();
       
   185 
       
   186     // Parse config entries from the array, delete items from the entry array
       
   187     ParseSettingsBufferL();
       
   188     iEntries->ResetAndDestroy();
       
   189 
       
   190     CleanupStack::Pop(); // header
       
   191 
       
   192     return header;
       
   193     }
       
   194 
       
   195 // -----------------------------------------------------------------------------
       
   196 // CMPSettingsRopConfigParser::CreateConfigStringL
       
   197 // -----------------------------------------------------------------------------
       
   198 //
       
   199 HBufC8* CMPSettingsRopConfigParser::CreateConfigStringL(const CArrayPtr<CMPRopSettingItem>* aItemArray, const TDesC8& aConfigHeader)
       
   200     {
       
   201     MPX_DEBUG1(_L("#MS# CMPSettingsRopConfigParser::CreateConfigStringL()"));
       
   202     HBufC8* configString = NULL;
       
   203     iItemArray = aItemArray;
       
   204 
       
   205     delete iConfigHeader;
       
   206     iConfigHeader = NULL;
       
   207     iConfigHeader = HBufC8::NewL(aConfigHeader.Length() + 1); // magic, leave room for line separator (';')
       
   208     TPtr8 tmp = iConfigHeader->Des();
       
   209 
       
   210     tmp.Append(aConfigHeader);
       
   211     tmp.Append(KMPRopEntrySeparator);
       
   212 
       
   213     PopulateEntryArrayFromItemArrayL();
       
   214     
       
   215     // If iEntries->Count() == 1 -> iEntries contains only config header ->
       
   216     // none of the setting values has change => no need to create config string
       
   217     if (iEntries->Count() > 1)
       
   218         {
       
   219         configString = CreateConfigStringFromEntryArrayL();
       
   220         }
       
   221 
       
   222     iEntries->ResetAndDestroy();
       
   223 
       
   224     return configString;
       
   225     }
       
   226 
       
   227 // -----------------------------------------------------------------------------
       
   228 // CMPSettingsRopConfigParser::ParseConfigHeaderL
       
   229 // -----------------------------------------------------------------------------
       
   230 //
       
   231 HBufC8* CMPSettingsRopConfigParser::ParseConfigHeaderL()
       
   232     {
       
   233     MPX_DEBUG1(_L("#MS# CMPSettingsRopConfigParser::ParseConfigHeaderL()"));
       
   234     HBufC8* buf = NULL;
       
   235     TPtrC8 ptr;
       
   236     TInt error = GetNextEntry(ptr);
       
   237     if (error)
       
   238         {
       
   239         // If header line cannot be found, the string is corrupted => Leave
       
   240         User::Leave(KErrCorrupt);
       
   241         }
       
   242 
       
   243     buf = ptr.AllocL();
       
   244     return buf;
       
   245     }
       
   246 
       
   247 // -----------------------------------------------------------------------------
       
   248 // CMPSettingsRopConfigParser::NextConfigEntryL
       
   249 // -----------------------------------------------------------------------------
       
   250 //
       
   251 HBufC8* CMPSettingsRopConfigParser::NextConfigEntryL(TInt& aError)
       
   252     {
       
   253     MPX_DEBUG1(_L("#MS# CMPSettingsRopConfigParser::NextConfigEntryL()"));
       
   254     HBufC8* buf = NULL;
       
   255 
       
   256     TPtrC8 ptr;
       
   257     aError = GetNextEntry(ptr);
       
   258 
       
   259     if (!aError)
       
   260         {
       
   261         buf = ptr.AllocL();
       
   262         buf->Des().Trim();
       
   263         }
       
   264 
       
   265     return buf;
       
   266     }
       
   267 
       
   268 // -----------------------------------------------------------------------------
       
   269 // CMPSettingsRopConfigParser::PopulateEntryArrayFromConfigStringL
       
   270 // -----------------------------------------------------------------------------
       
   271 //
       
   272 void CMPSettingsRopConfigParser::PopulateEntryArrayFromConfigStringL()
       
   273     {
       
   274     MPX_DEBUG1(_L("#MS# CMPSettingsRopConfigParser::PopulateEntryArrayFromConfigStringL()"));
       
   275     TInt error(KErrNone);
       
   276     iEntries->ResetAndDestroy();
       
   277 
       
   278     do
       
   279         {
       
   280         HBufC8* buf = NextConfigEntryL(error);
       
   281 
       
   282         if (!error)
       
   283             {
       
   284             iEntries->AppendL(buf);
       
   285             }
       
   286         }
       
   287     while (!error);
       
   288 
       
   289     if (error != KErrNotFound)
       
   290         {
       
   291         User::Leave(error);
       
   292         }
       
   293     }
       
   294 
       
   295 // -----------------------------------------------------------------------------
       
   296 // CMPSettingsRopConfigParser::PopulateEntryArrayFromItemArrayL
       
   297 // -----------------------------------------------------------------------------
       
   298 //
       
   299 void CMPSettingsRopConfigParser::PopulateEntryArrayFromItemArrayL()
       
   300     {
       
   301     MPX_DEBUG1(_L("#MS# CMPSettingsRopConfigParser::PopulateEntryArrayFromItemArrayL()"));
       
   302     CMPRopSettingItem* item = NULL;
       
   303     HBufC8* buf = NULL;
       
   304     iEntries->ResetAndDestroy();
       
   305 
       
   306     // Append config string header to array
       
   307     iEntries->AppendL(iConfigHeader);
       
   308     iConfigHeader = NULL;
       
   309 
       
   310     TInt count = iItemArray->Count();
       
   311     for (TInt i = 0; i < count; ++i)
       
   312         {
       
   313         item = iItemArray->At(i);
       
   314 
       
   315         if (item->iValueChanged)
       
   316             {
       
   317             buf = CreateConfigEntryL(item);
       
   318 
       
   319             if (buf)
       
   320                 {
       
   321                 CleanupStack::PushL(buf);
       
   322                 iEntries->AppendL(buf);
       
   323                 CleanupStack::Pop(); // buf
       
   324                 }
       
   325             }
       
   326         }
       
   327     }
       
   328 
       
   329 // -----------------------------------------------------------------------------
       
   330 // CMPSettingsRopConfigParser::CreateConfigEntryL
       
   331 // -----------------------------------------------------------------------------
       
   332 //
       
   333 HBufC8* CMPSettingsRopConfigParser::CreateConfigEntryL(CMPRopSettingItem* aItem)
       
   334     {
       
   335     MPX_DEBUG1(_L("#MS# CMPSettingsRopConfigParser::CreateConfigEntryL()"));
       
   336     HBufC8* buf = NULL;
       
   337 
       
   338     switch (aItem->iType)
       
   339         {
       
   340         case EMPRopConfTypeInteger:
       
   341             {
       
   342             buf = HBufC8::NewL(aItem->iKey->Length() + KMPRopIntegerEntryPrototypeStaticLength);
       
   343             TPtr8 ptr = buf->Des();
       
   344             ptr.Format(KMPRopIntegerEntryPrototype, aItem->iKey, aItem->iIntValue);
       
   345             break;
       
   346             }
       
   347         case EMPRopConfTypeString:
       
   348             {
       
   349             HBufC* str = aItem->iStringValue;
       
   350             TInt strLength = str->Length();
       
   351             HBufC8* str8 = HBufC8::NewLC(strLength);
       
   352             TPtr8 str8Ptr = str8->Des();
       
   353             CnvUtfConverter::ConvertFromUnicodeToUtf8(str8Ptr, *str);
       
   354             
       
   355             buf = HBufC8::NewL(aItem->iKey->Length() + strLength + KMPRopStringEntryPrototypeStaticLength);
       
   356             TPtr8 ptr = buf->Des();
       
   357             ptr.Format(KMPRopStringEntryPrototype, aItem->iKey, &(*str8));
       
   358             CleanupStack::PopAndDestroy(); //str8
       
   359             break;
       
   360             }
       
   361         default:
       
   362             break;
       
   363         }
       
   364 
       
   365     return buf;
       
   366     }
       
   367 
       
   368 
       
   369 // -----------------------------------------------------------------------------
       
   370 // CMPSettingsRopConfigParser::GetNextEntry
       
   371 // -----------------------------------------------------------------------------
       
   372 //
       
   373 TInt CMPSettingsRopConfigParser::GetNextEntry(TPtrC8& aEntry)
       
   374     {
       
   375     MPX_DEBUG1(_L("#MS# CMPSettingsRopConfigParser::GetNextEntry()"));
       
   376     TInt error(KErrNone);
       
   377 
       
   378     TInt offset = iBufferPtr.Find(KMPRopEntrySeparator);
       
   379     if (offset != KErrNotFound)
       
   380         {
       
   381         aEntry.Set(iBufferPtr.Left(offset));
       
   382         iBufferPtr.Set(iBufferPtr.Mid(++offset)); // don't include ';'
       
   383         }
       
   384     else
       
   385         {
       
   386         error = KErrNotFound;
       
   387         }
       
   388 
       
   389     return error;
       
   390     }
       
   391 
       
   392 // -----------------------------------------------------------------------------
       
   393 // CMPSettingsRopConfigParser::ParseSettingsBufferL
       
   394 // -----------------------------------------------------------------------------
       
   395 //
       
   396 void CMPSettingsRopConfigParser::ParseSettingsBufferL()
       
   397     {
       
   398     MPX_DEBUG1(_L("#MS# CMPSettingsRopConfigParser::ParseSettingsBufferL()"));
       
   399     CMPRopSettingItem* item;
       
   400     TPtrC8 value;
       
   401 
       
   402     TInt count = iItemArray->Count();
       
   403     for (TInt i = 0; i < count; ++i)
       
   404         {
       
   405         item = iItemArray->At(i);
       
   406 
       
   407         item->iError = GetConfigDataL(*item->iKey, value, item->iType);
       
   408         
       
   409         if (!item->iError)
       
   410             {
       
   411             switch (item->iType)
       
   412                 {
       
   413                 case EMPRopConfTypeInteger:
       
   414                     {
       
   415                     // Parse integer value
       
   416                     TLex8 lex(value);
       
   417                     item->iError = lex.Val(item->iIntValue);
       
   418                     break;
       
   419                     }
       
   420                 case EMPRopConfTypeIntArray:
       
   421                     {
       
   422                     HBufC8* tmp = NULL;
       
   423                     TInt offset = 0; // Magic: should not be KErrNotFound initially
       
   424                     TInt error = KErrNone;
       
   425                     TInt intVal = 0;
       
   426                     item->iIntArray.Reset();
       
   427                     
       
   428                     while (offset != KErrNotFound && !error)
       
   429                         {
       
   430                         offset = value.Find(KMPRopArraySeparator);
       
   431 
       
   432                         if (offset != KErrNotFound)
       
   433                             {
       
   434                             tmp = value.Left(offset).AllocLC();
       
   435                             }
       
   436                         else
       
   437                             {
       
   438                             tmp = value.AllocLC();
       
   439                             }
       
   440 
       
   441                         tmp->Des().Trim();
       
   442                         TLex8 lex(*tmp);
       
   443                         error = lex.Val(intVal);
       
   444 
       
   445                         if (!error)
       
   446                             {
       
   447                             User::LeaveIfError(item->iIntArray.Append(intVal));
       
   448 
       
   449                             if (offset != KErrNotFound)
       
   450                                 {
       
   451                                 value.Set(value.Mid(offset + 1));
       
   452                                 }
       
   453                             }
       
   454 
       
   455                         CleanupStack::PopAndDestroy(); // tmp
       
   456                         tmp = NULL;
       
   457                         }
       
   458                     
       
   459                     item->iError = error;
       
   460                     break;
       
   461                     }
       
   462                 case EMPRopConfTypeString:
       
   463                     // Parse string value
       
   464                     value.Set(ValueStringPtr(value, item->iError));
       
   465 
       
   466                     if (!item->iError)
       
   467                         {
       
   468                         delete item->iStringValue;
       
   469                         item->iStringValue = NULL;
       
   470                         item->iStringValue = HBufC::NewL(value.Length());
       
   471     
       
   472                         TPtr tmp = item->iStringValue->Des();
       
   473                         CnvUtfConverter::ConvertToUnicodeFromUtf8(tmp, value);
       
   474                         }
       
   475                     break;
       
   476                 default:
       
   477                     item->iError = KErrNotSupported;
       
   478                     break;
       
   479                 }
       
   480             }
       
   481         }
       
   482     }
       
   483 
       
   484 // -----------------------------------------------------------------------------
       
   485 // CMPSettingsRopConfigParser::GetConfigDataL
       
   486 // -----------------------------------------------------------------------------
       
   487 //
       
   488 TInt CMPSettingsRopConfigParser::GetConfigDataL(const TDesC8& aKey, TPtrC8& aValue, TMPRopConfType& aType)
       
   489     {
       
   490     MPX_DEBUG1(_L("#MS# CMPSettingsRopConfigParser::GetConfigDataL()"));
       
   491     TInt ret = KErrNotFound;
       
   492     TInt offset = KErrNotFound;
       
   493     HBufC8* buf = NULL;
       
   494 
       
   495     // Try to find aConfigKey from the beginning of each entry untill one is found
       
   496     // (offset has to be 0, as there can be several different config keys that
       
   497     // include some other config key, e.g. "Timeout" vs. "ConnTimeout").
       
   498     for (TInt i = 0; offset != 0 && i < iEntries->Count(); i++)
       
   499         {
       
   500         buf = iEntries->At(i);
       
   501         offset = buf->Find(aKey);
       
   502         }
       
   503 
       
   504     // Parse type and value if correct key was found
       
   505     if (offset == 0)
       
   506         {
       
   507         offset = buf->Find(KMPRopKeySeparator);
       
   508         TInt offset2 = buf->Find(KMPRopValueSeparator);
       
   509         TInt arrayOffset = buf->Find(KMPRopArrayOpeningMarker);
       
   510 
       
   511         if (offset != KErrNotFound && offset2 != KErrNotFound && offset < offset2)
       
   512             {
       
   513             ++offset; // Move past the key separator
       
   514 
       
   515             delete iTmpBuf;
       
   516             iTmpBuf = NULL;
       
   517             iTmpBuf = buf->Mid(offset, offset2 - offset).AllocL();
       
   518             iTmpBuf->Des().Trim();
       
   519             
       
   520             // Parse type
       
   521             if (*iTmpBuf == TPtrC8(KMPRopTypeInteger))
       
   522                 {
       
   523                 if (arrayOffset == KErrNotFound)
       
   524                     {
       
   525                     aType = EMPRopConfTypeInteger;
       
   526                     }
       
   527                 else
       
   528                     {
       
   529                     aType = EMPRopConfTypeIntArray;
       
   530                     }
       
   531                 }
       
   532             else if (*iTmpBuf == TPtrC8(KMPRopTypeString))
       
   533                 {
       
   534                 aType = EMPRopConfTypeString;
       
   535                 }
       
   536             else
       
   537                 {
       
   538                 ret = KErrNotSupported;
       
   539                 }
       
   540  
       
   541             if (ret != KErrNotSupported)
       
   542                 {
       
   543                 // Parse value
       
   544                 delete iTmpBuf;
       
   545                 iTmpBuf = NULL;
       
   546 
       
   547                 if (aType == EMPRopConfTypeIntArray)
       
   548                     {
       
   549                     TInt arrayOffset2 = buf->Find(KMPRopArrayClosingMarker);
       
   550 
       
   551                     if (arrayOffset2 != KErrNotFound && arrayOffset < arrayOffset2)
       
   552                         {
       
   553                         // Copy, but do not include markers
       
   554                         iTmpBuf = buf->Mid(arrayOffset + 1, arrayOffset2 - arrayOffset - 1).AllocL();
       
   555                         ret = KErrNone;
       
   556                         }
       
   557                     else
       
   558                         {
       
   559                         return KErrCorrupt;
       
   560                         }
       
   561                     }
       
   562                 else
       
   563                     {
       
   564                     iTmpBuf = buf->Mid(++offset2).AllocL(); // Move past the value separator
       
   565                     ret = KErrNone;
       
   566                     }
       
   567 
       
   568                 iTmpBuf->Des().Trim();
       
   569 
       
   570                 aValue.Set(*iTmpBuf);
       
   571                 }
       
   572             }
       
   573         }
       
   574 
       
   575     return ret;
       
   576     }
       
   577 
       
   578 // -----------------------------------------------------------------------------
       
   579 // CMPSettingsRopConfigParser::ValueStringPtr
       
   580 // -----------------------------------------------------------------------------
       
   581 //
       
   582 TPtrC8 CMPSettingsRopConfigParser::ValueStringPtr(const TDesC8& aValue, TInt& aError)
       
   583     {
       
   584     MPX_DEBUG1(_L("#MS# CMPSettingsRopConfigParser::ValueStringPtr()"));
       
   585     TPtrC8 ptr;
       
   586     aError = KErrNotFound;
       
   587     // Find first string constrainer
       
   588     TInt offset = aValue.Find(KMPRopStringConstrainer);
       
   589     
       
   590     if (offset != KErrNotFound)
       
   591         {
       
   592         TPtrC8 tmp;
       
   593         // 1.) Set offset1 to point the first character of the config string
       
   594         // 2.) Set characters after the first string constrainer to tmp
       
   595         tmp.Set(aValue.Mid(++offset));
       
   596         // Find second string constrainer
       
   597         offset = tmp.Find(KMPRopStringConstrainer);
       
   598 
       
   599         if (offset != KErrNotFound)
       
   600             {
       
   601             // Set characters between the string constrainers to aString
       
   602             ptr.Set(tmp.Left(offset));
       
   603             aError = KErrNone;
       
   604             }
       
   605         }
       
   606 
       
   607     return ptr;
       
   608     }
       
   609 
       
   610 // -----------------------------------------------------------------------------
       
   611 // CMPSettingsRopConfigParser::CreateConfigStringFromEntryArrayL
       
   612 // -----------------------------------------------------------------------------
       
   613 //
       
   614 HBufC8* CMPSettingsRopConfigParser::CreateConfigStringFromEntryArrayL()
       
   615     {
       
   616     MPX_DEBUG1(_L("#MS# CMPSettingsRopConfigParser::CreateConfigStringFromEntryArrayL()"));
       
   617     TInt length(0);
       
   618     TInt count = iEntries->Count();
       
   619     for (TInt i = 0; i < count; ++i)
       
   620         {
       
   621         length += iEntries->At(i)->Length();
       
   622         }
       
   623 
       
   624     HBufC8* configString = HBufC8::NewL(length);
       
   625     TPtr8 ptr = configString->Des();
       
   626 
       
   627     for (TInt j = 0; j < count; ++j)
       
   628         {
       
   629         ptr.Append(*iEntries->At(j));
       
   630         }
       
   631 
       
   632     return configString;
       
   633     }
       
   634 
       
   635 //  End of File