237 TServerResources::CreateRepositoryFileNameLC(fileName, aRepository->Uid(), aLocation, EIni); |
237 TServerResources::CreateRepositoryFileNameLC(fileName, aRepository->Uid(), aLocation, EIni); |
238 r = CIniFileIn::NewLC(TServerResources::iFs,inifile,*fileName); |
238 r = CIniFileIn::NewLC(TServerResources::iFs,inifile,*fileName); |
239 if(r==KErrNone) |
239 if(r==KErrNone) |
240 { |
240 { |
241 r=ReadSettingsL(inifile, aRepository); |
241 r=ReadSettingsL(inifile, aRepository); |
242 if(r==KErrCorrupt) |
242 #ifdef SYMBIAN_INCLUDE_APP_CENTRIC |
|
243 // PMA repositories are not allowed to be installed/updated via SWI. |
|
244 // Any repository marked as protected in the install directory will be |
|
245 // deleted, when opened. |
|
246 if ( aLocation == EInstall && (aRepository->iSimRep->KeyspaceType() == EPMAKeyspace) ) |
|
247 { |
|
248 r = KErrNotSupported; |
|
249 } |
|
250 |
|
251 if(r == KErrCorrupt || r == KErrNotSupported) |
|
252 #else |
|
253 if(r == KErrCorrupt) |
|
254 #endif |
243 { |
255 { |
244 // File is corrupt, if it's not the ROM file, delete it |
256 // File is corrupt, if it's not the ROM file, delete it |
245 if(fileName && aLocation != ERom) |
257 if(fileName && aLocation != ERom) |
|
258 { |
246 User::LeaveIfError(TServerResources::iFs.Delete(*fileName)); |
259 User::LeaveIfError(TServerResources::iFs.Delete(*fileName)); |
|
260 } |
247 // Delete any repository settings that may have been read in |
261 // Delete any repository settings that may have been read in |
248 aRepository->GetSettings().Reset(); |
262 aRepository->GetSettings().Reset(); |
249 } |
263 } |
250 } |
264 } |
251 |
265 |
568 #ifndef PDS_TEST_MULTIROFS |
582 #ifndef PDS_TEST_MULTIROFS |
569 User::Leave(KErrMultiRofsOldCreUsed); |
583 User::Leave(KErrMultiRofsOldCreUsed); |
570 #endif |
584 #endif |
571 } |
585 } |
572 } |
586 } |
|
587 #ifdef SYMBIAN_INCLUDE_APP_CENTRIC |
|
588 // Need to ensure both keyspaces are of the same type (either both protected or |
|
589 // both non-protected). |
|
590 if ( aCoreRepository->iSimRep->KeyspaceType() != repos->KeyspaceType() ) |
|
591 { |
|
592 User::Leave(KErrCorrupt); |
|
593 } |
|
594 #endif |
|
595 |
573 //Now that the repository is initialized and at this stage the repository file has been |
596 //Now that the repository is initialized and at this stage the repository file has been |
574 //checked whether they are corrupt |
597 //checked whether they are corrupt |
575 repos->SettingsArray().SetIsDefault(ETrue); |
598 repos->SettingsArray().SetIsDefault(ETrue); |
|
599 |
576 MergeRepositoryL(aCoreRepository,repos); |
600 MergeRepositoryL(aCoreRepository,repos); |
577 |
601 |
578 CleanupStack::PopAndDestroy(repos); //repos |
602 CleanupStack::PopAndDestroy(repos); //repos |
579 } |
603 } |
580 } |
604 } |
587 TInt err(KErrNotFound); |
611 TInt err(KErrNotFound); |
588 |
612 |
589 err = aRepository->CreateRepositoryFromCreFileL(aLocation); |
613 err = aRepository->CreateRepositoryFromCreFileL(aLocation); |
590 if(err==KErrNotFound) |
614 if(err==KErrNotFound) |
591 { |
615 { |
|
616 #ifdef SYMBIAN_INCLUDE_APP_CENTRIC |
|
617 // Persists and Protected directories are internal and do not support .txt repository files. |
|
618 if ( (aLocation!=EPersists) && (aLocation!=EPma) ) |
|
619 #else |
592 if (aLocation!=EPersists) |
620 if (aLocation!=EPersists) |
593 err = ReadIniFileL(aRepository,aLocation); |
621 #endif |
594 } |
622 { |
595 //for ROM might want to consider the possibility of multi rofs file |
623 err = ReadIniFileL(aRepository,aLocation); |
|
624 } |
|
625 } |
|
626 // For ROM need to consider the possibility of multi rofs file. |
596 #ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS |
627 #ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS |
597 if (aLocation==ERom && iMultiRofsUidList.Count()!=0) |
628 if (aLocation==ERom && iMultiRofsUidList.Count()!=0) |
598 { |
629 { |
599 //if there is error and not because of non-existant we should return error immediately |
630 //if there is error and not because of non-existant we should return error immediately |
600 //and if it is fine but the uid does not match one of the multirofsuidlsit this means that |
631 //and if it is fine but the uid does not match one of the multirofsuidlsit this means that |
639 |
670 |
640 switch (aIniFileOpenMode) |
671 switch (aIniFileOpenMode) |
641 { |
672 { |
642 case CIniFileIn::EAuto: |
673 case CIniFileIn::EAuto: |
643 { |
674 { |
|
675 #ifdef SYMBIAN_INCLUDE_APP_CENTRIC |
|
676 // If the repository is in the list of protected repositories, it must be in the protected directory. |
|
677 if ( TServerResources::iPMADriveRepositories.FindInOrder( aRepository->Uid(), TLinearOrder<TUid>(TServerResources::CompareUids) ) != KErrNotFound ) |
|
678 { |
|
679 // File must now exist on the protected drive. |
|
680 err = CreateRepositoryL(aRepository, EPma); |
|
681 // We will either successfully load (err==None) the repository or there will be an |
|
682 // error loading it, in which case we must return the error. |
|
683 return err; |
|
684 } |
|
685 #endif |
644 // Look in persists dir |
686 // Look in persists dir |
645 err=CreateRepositoryL(aRepository, EPersists); |
687 err=CreateRepositoryL(aRepository, EPersists); |
646 |
688 |
647 if(err==KErrNone) |
689 if(err==KErrNone) |
648 { |
690 { |
811 AddOpenRepositoryL(rep); |
853 AddOpenRepositoryL(rep); |
812 |
854 |
813 // We pop the rep here because if later call of TServerResources::AddOwnerIdLookupMapping fails of OOM |
855 // We pop the rep here because if later call of TServerResources::AddOwnerIdLookupMapping fails of OOM |
814 // the call of RemoveOpenRepository() will delete the repository before leave. |
856 // the call of RemoveOpenRepository() will delete the repository before leave. |
815 CleanupStack::Pop(rep); |
857 CleanupStack::Pop(rep); |
816 |
858 #ifdef SYMBIAN_INCLUDE_APP_CENTRIC |
817 // Add owner mapping to list - Will fail if an entry already exists |
859 // We don't want to add protected Keyspaces to iOwnerIdLookUpTable, as this is used for BUR and |
818 // with this Repository UID but this doesn't matter |
860 // protected keyspaces are excluded from BUR. |
819 TUid owner = rep->Owner() ; |
861 if (rep->iSimRep->KeyspaceType() != EPMAKeyspace) |
820 TInt err = TServerResources::AddOwnerIdLookupMapping(aUid.iUid, owner.iUid); |
862 { |
821 if (err == KErrNoMemory) |
863 #endif |
822 { |
864 // Add owner mapping to list - Will fail if an entry already exists |
823 RemoveOpenRepository(rep); |
865 // with this Repository UID but this doesn't matter |
824 User::Leave(err); |
866 TUid owner = rep->Owner() ; |
825 } |
867 TInt err = TServerResources::AddOwnerIdLookupMapping(aUid.iUid, owner.iUid); |
|
868 if (err == KErrNoMemory) |
|
869 { |
|
870 RemoveOpenRepository(rep); |
|
871 User::Leave(err); |
|
872 } |
|
873 #ifdef SYMBIAN_INCLUDE_APP_CENTRIC |
|
874 } |
|
875 #endif |
826 |
876 |
827 //Find the location of the current transaction for this repository |
877 //Find the location of the current transaction for this repository |
828 const TInt offset (FindRepositoryInfo(aUid)); |
878 const TInt offset (FindRepositoryInfo(aUid)); |
829 if (offset >=0) //If there are no outstanding transactions |
879 if (offset >=0) //If there are no outstanding transactions |
830 { |
880 { |