// ---------------------------------------------------------------------------
// CLAPILandmarkStoreManager::LandmarkStoresL
// ---------------------------------------------------------------------------
//
CDesCArray* CLAPILandmarkStoreManager::LandmarkStoresL()
{
    JELOG2(EJavaLocation);
    // List landmark databases but remove the default store from the array
    CDesCArray* stores = iLmDbManager->ListDatabasesLC();
    HBufC* defaultDbName = iLmDbManager->DefaultDatabaseUriLC();

    // Remove the default database from the store names array. External stores
    // are also removed because this API does not support other than stores
    // which are located in the file system of the device
    TInt count = stores->Count();
    for (TInt i = 0; i < count; i++)
    {
        TPtrC storeUri = stores->MdcaPoint(i);
        if (defaultDbName->CompareF(storeUri) == 0 || storeUri.FindF(
                    KLAPIDefaultProtocol) == KErrNotFound)
        {
            stores->Delete(i);
            break;
        }
    }

    CleanupStack::PopAndDestroy(defaultDbName);
    CleanupStack::Pop(stores);
    return stores;
}
TInt TPkgParser::ParseDataLineL(class CFileObjectHolder* &aFileList,  
                                char* line)
{
   char*  localName    = NULL;
   char*  url          = NULL;
   uint32 fileSize     = 0;
   char*  checksum     = NULL;
   uint32 action       = 0;
   char*  version      = NULL;
   char*  versionFile  = NULL;
   char*  versionCheck = NULL;
   char*  isoLang      = NULL;

   TBool ok = ETrue;
   ok = ok && ParseString(localName,    line);
   ok = ok && ParseString(url,          line);
   ok = ok && ParseUint32(fileSize,     line);
   ok = ok && ParseString(checksum,     line);
   ok = ok && ParseUint32(action,       line);
   ok = ok && ParseString(version,      line); //last mandatory field
   TBool lineCorrect = ok;
   ok = ok && ParseString(versionFile,  line); //may return EFalse if
                                               //there is no ending ';'
   ok = ok && ParseString(versionCheck, line); 
   ok = ok && ParseString(isoLang,      line);
   if(!lineCorrect){
      return 0;
   }

   //ignore lines that are language tagged but doesn't match the
   //selected language.
   if(isoLang && strlen(isoLang) > 0 && iSelectedLang != KNullDesC){
      HBufC* lang = WFTextUtil::AllocL(isoLang);
      if(0 != lang->CompareF(iSelectedLang)){
         action = 3; //Delete file.
      }
      delete lang;
   }


   class CFileObject *a = CFileObject::NewLC(localName, url, fileSize, 
                                             checksum, action, version,
                                             versionFile, versionCheck, 
                                             isoLang);

   if (!aFileList) {
      aFileList = new (ELeave) CFileObjectHolder();
   }
   CleanupStack::Pop(a);
   aFileList->unshift(a);
   return 1;
}
// -----------------------------------------------------------------------------
// CAtomFeedParser::ElementHandlerLinkL
//
// A ElementHandler function that handles the link element.
// -----------------------------------------------------------------------------
//
void CAtomFeedParser::ElementHandlerLinkL(const CFeedParser& /*aParser*/, CXmlUtils& aXmlUtils, 
        TXmlEngElement aNode, TInt aValueId, MFeedParserObserver& aObserver)
    {
    HBufC*  rel = NULL;
    HBufC*  href = NULL;
    
    // Get the link's relationship.
    rel = aXmlUtils.AttributeL(aNode, KRel);
    CleanupStack::PushL(rel);
        
    // Get the link's url.
    // TODO: Resolve the href using the base element or feed url.
    href = aXmlUtils.AttributeL(aNode, KHref);
    CleanupStack::PushL(href);

    if ((href == NULL) || (href->Length() == 0))
        {
        CleanupStack::PopAndDestroy(href);
        CleanupStack::PopAndDestroy(rel);
        
        return;
        }

    // The link points to an item's full story or feed's main web page.
    if ((rel == NULL) || (rel->CompareF(KAlternate) == 0))
        {
        aObserver.AddAttributeL(aValueId, *href);
        }
                
    // The link points to an enclsoure.
    else if (rel->CompareF(KEnclosure) == 0)
        {
        HBufC*  type = NULL;
        HBufC*  title = NULL;
        HBufC*  length = NULL;
            
        type = aXmlUtils.AttributeL(aNode, KType);
        CleanupStack::PushL(type);
        title = aXmlUtils.AttributeL(aNode, KTitle);
        CleanupStack::PushL(title);
        length = aXmlUtils.AttributeL(aNode, KLength);
        CleanupStack::PushL(length);

        aObserver.EnclosureBeginsL();

        if (type != NULL)
            {                    
            aObserver.AddAttributeL(EEnclosureAttributeContentType, *type);
            }
        if (length != NULL)
            {                    
            aObserver.AddAttributeL(EEnclosureAttributeSize, *length);
            }
        if (href != NULL)
            {                    
            aObserver.AddAttributeL(EEnclosureAttributeLink, *href);
            }
        if (title != NULL)
            {                    
            aObserver.AddAttributeL(EEnclosureAttributeTitle, *title);
            }

        aObserver.EnclosureEndsL();

        CleanupStack::PopAndDestroy(length);
        CleanupStack::PopAndDestroy(title);
        CleanupStack::PopAndDestroy(type);
        }
    
    CleanupStack::PopAndDestroy(href);
    CleanupStack::PopAndDestroy(rel);
    }
// ---------------------------------------------------------------------------
// FileNamesEqual()
// ---------------------------------------------------------------------------
//
TBool FileNamesEqual( const HBufC& aFile1, const HBufC& aFile2 )
    {
    return ( aFile1.CompareF( aFile2 ) == 0 );
    }
TBool CConfigureCDSDialog::OkToExitL(TInt aButtonId)
	{
	LOG_MSG( "-> CConfigureCDSDialog::OkToExitL" );
	TBool ret = ETrue;
	TInt err;

	RPointerArray<CEikEdwin> edwins;
	CEikEdwin *edwin = static_cast<CEikEdwin*>(Control(EEdwin1));
	edwins.Append(edwin);
	edwin = static_cast<CEikEdwin*>(Control(EEdwin2));
	edwins.Append(edwin);
	edwin = static_cast<CEikEdwin*>(Control(EEdwin3));
	edwins.Append(edwin);
	edwin = static_cast<CEikEdwin*>(Control(EEdwin4));
	edwins.Append(edwin);
	edwin = static_cast<CEikEdwin*>(Control(EEdwin5));
	edwins.Append(edwin);
	edwin = static_cast<CEikEdwin*>(Control(EEdwin6));
	edwins.Append(edwin);
	edwin = static_cast<CEikEdwin*>(Control(EEdwin7));
	edwins.Append(edwin);

	switch (aButtonId)
		{
		case EEikBidCancel:
			{
			//RDebug::Print(_L("CConfigureCDSDialog::OkToExitL: Cancel pressed"));
			}
			break;
		case EBidCDSConfigure:
			{
			//RDebug::Print(_L("CConfigureCDSDialog::OkToExitL: iConfs.Count() == %d"), iConfs.Count());
			for (TInt i = 0; ( i < iConfs.Count() ) && ret; i++)
				{
				err = KErrNone;

				HBufC *input = NULL;
				if (edwins[i]->TextLength() > 0)
					{
					input = edwins[i]->GetTextInHBufL();
					}
				if ( ! input )
					{
					LOG_MSG2( "  NULL input for param %d" , i );
					continue;
					}

				//RDebug::Print(_L("CConfigureCDSDialog::OkToExitL: iConfs[i]->Type() == %d"), iConfs[i]->Type());

				switch (iConfs[i]->Type())
					{
					case COptionConfig::ETInt:
					case COptionConfig::ETUInt:
						{
						TLex opts(*input);
						TInt32 conf;
						err = opts.Val(conf);
						if ( err )
							{
							LOG_MSG("  error from opts.Val(conf) -> CConfigureCDSDialog::CEikonEnv::Static()->InfoMsg;" );
							CEikonEnv::Static()->InfoMsg(_L("Value must be an integer"));
							break;
							}

						//RDebug::Print(_L("CConfigureCDSDialog::OkToExitL: conf == %d"), conf);
						iConfs[i]->Value(conf);
						TRAP( err, iCoreDumpSession.SetConfigParameterL( *iConfs[i]) );
						}
						break;

					case COptionConfig::ETFileName:
					case COptionConfig::ETString:
					case COptionConfig::ETSingleEntryEnum:
					case COptionConfig::ETMultiEntryEnum:
						{						
						TRAP( err, iConfs[i]->ValueL(*input) );
						if ( KErrNone == err )
							{
							TRAP( err, iCoreDumpSession.SetConfigParameterL( *iConfs[i]) );
							}
						}
						break;

					case COptionConfig::ETBool:
						if (input->CompareF(_L("True"))== 0)
							{
							iConfs[i]->Value(ETrue);
							iConfs[i]->ValueL(_L("True"));
							}
						else if (input->CompareF(_L("False"))== 0)
							{
							iConfs[i]->Value(EFalse);
							iConfs[i]->ValueL(_L("False"));
							}
						else
							{
							err = KErrCorrupt;
							}

						if ( KErrNone == err )
							{
							TRAP( err, iCoreDumpSession.SetConfigParameterL( *iConfs[i]) );
							}

						break;

					default:
						CEikonEnv::Static()->InfoMsg(_L("Error with parameter type"));
						LOG_MSG( "CConfigureCDSDialog::OkToExitL: none of the above" );
						err = KErrCorrupt;
						break;

					}//switch

				if ( err )
					{
					RBuf errorString;
					CleanupClosePushL( errorString );
					errorString.CreateL( 128 );
					errorString.Append( _L("CDS Error ") ); 
					errorString.AppendNum( err );
					errorString.Append( _L(" setting parameter number ") );
					errorString.AppendNum( i );
					CEikonEnv::InfoWinL( errorString, KNullDesC );
					CleanupStack::PopAndDestroy( &errorString );
					ret = EFalse;
					}
                if(input)
                    {
                    delete input;
                    input = NULL;
                    }
				}
			}
			break;
		default:
			break;
		}

    edwins.Close();
	return ret;
	}