LOCAL_C void writeRomImage() // // Write the ROM image. // { test.Start(_L("Write rom file header")); // TPckgBuf<TRomFileHeader> fileHeadB; fileHeadB.FillZ(fileHeadB.MaxLength()); TRomFileHeader& fileHead=fileHeadB(); Mem::Copy(&fileHead.iName[0],"EPOC468 ROM ",KRomFileHeaderNameSize); Mem::Copy(&fileHead.iVersionStr[0],"0.01",4); Mem::Copy(&fileHead.iBuildNumStr[0]," 1",4); fileHead.iRomSize=TheRomHeader.iRomSize; fileHead.iHeaderSize=KRomFileHeaderSize; test(TheFile.Write(fileHeadB)==KErrNone); // test.Next(_L("Write rom header")); TheFiller.FillZ(TheFiller.MaxLength()); TPckgC<TRomHeader> head(TheRomHeader); test(TheFile.Write(head)==KErrNone); TheCurrentBase=UserSvr::RomHeaderAddress()+sizeof(TheRomHeader); // test.Next(_L("Write directories")); TheLevel=(-1); TheRootDir->WriteDirs(); test(TheLevel==(-1)); // test.Next(_L("Write files")); TheLevel=(-1); TheRootDir->WriteFiles(); test(TheLevel==(-1)); // test.End(); }
// ----------------------------------------------------------------------------- // CNSmlDsProvisioningAdapter::SaveL // ----------------------------------------------------------------------------- void CNSmlDsProvisioningAdapter::SaveL(TInt aItem) { _DBG_FILE("CNSmlDsProvisioningAdapter::SaveL(): begin"); TPckgBuf<TUint32> uid; RSyncMLDataSyncProfile profile; TBool ret = EFalse; if(iProfiles[aItem]->iServerId != NULL) { RSyncMLDataSyncProfile ProfileToSearch; RArray<TSmlProfileId> arr; iSession.ListProfilesL( arr, ESmlDataSync ); TInt ProfileId = KErrNotFound; CleanupClosePushL(arr); for ( TInt index = 0; index < arr.Count(); index++ ) { TRAPD( error, ProfileToSearch.OpenL(iSession, arr[index], ESmlOpenRead ) ); if ( error == KErrNone ) { if ( ( iProfiles[aItem]->iServerId->Des()).Compare(ProfileToSearch.ServerId() ) == 0 ) { ret = ETrue; ProfileId = (TInt)arr[index]; ProfileToSearch.Close(); break; } } ProfileToSearch.Close(); } CleanupStack::PopAndDestroy( &arr ); if( ret ) { profile.OpenL(iSession, ProfileId , ESmlOpenReadWrite ); } else { profile.CreateL( iSession ); } CleanupClosePushL( profile ); } else { profile.CreateL( iSession ); CleanupClosePushL( profile ); } // ui needs this to be set 0 profile.SetCreatorId(0);//iProfiles[aItem]->iProfile.SetCreatorId(0); profile.SetSanUserInteractionL( iProfiles[aItem]->iServerAlertedAction ); if ( iProfiles[aItem]->iDisplayName ) { profile.SetDisplayNameL( iProfiles[aItem]->iDisplayName->Des() ); } if ( iProfiles[aItem]->iServerId ) { profile.SetServerIdL( iProfiles[aItem]->iServerId->Des() ); } if ( iProfiles[aItem]->iUsername ) { profile.SetUserNameL( iProfiles[aItem]->iUsername->Des() ); } if ( iProfiles[aItem]->iPassword ) { profile.SetPasswordL( iProfiles[aItem]->iPassword->Des() ); } // creates profile -> must be done before opening the connection profile.UpdateL(); RSyncMLConnection connection; connection.OpenL( profile, KUidNSmlMediumTypeInternet.iUid ); CleanupClosePushL( connection ); if ( (iProfiles[aItem]->iVisitParameter && iProfiles[aItem]->iVisitParameter->Data().Length() == uid.MaxLength() ) || iToNapIDInternetIndicator) { TUint apId = 0; TInt ERROR = KErrNone; TInt err1 = KErrNone; if (iToNapIDInternetIndicator) { //Get Access Point from DB or SNAP TRAP(err1, apId = WPAdapterUtil::GetAPIDL()); } else { uid.Copy(iProfiles[aItem]->iVisitParameter->Data() ); RCmManagerExt cmmanagerExt; cmmanagerExt.OpenL(); CleanupClosePushL(cmmanagerExt); RCmConnectionMethodExt cm; cm = cmmanagerExt.ConnectionMethodL( uid()); CleanupClosePushL( cm ); TRAP( ERROR, apId = cm.GetIntAttributeL(CMManager::ECmIapId) ); CleanupStack::PopAndDestroy(2); //cmmanager,cm } //Get default access point in failure of getting AP if (ERROR != KErrNone || err1 != KErrNone) { apId = GetDefaultIAPL(); } HBufC8* iapBuf = HBufC8::NewLC( 8 ); TPtr8 ptrBuf = iapBuf->Des(); ptrBuf.Num( apId ); connection.SetPropertyL( KNSmlIAPId, *iapBuf ); CleanupStack::PopAndDestroy(); //iapBuf } if( iProfiles[aItem]->iHostAddress ) { // see if address contains also port TBool portFound = EFalse; TInt startPos(0); if(iProfiles[aItem]->iHostAddress->Find(KNSmlDsProvisioningHTTP)==0) { startPos=KNSmlDsProvisioningHTTP().Length(); } else if(iProfiles[aItem]->iHostAddress->Find(KNSmlDsProvisioningHTTPS)==0) { startPos=KNSmlDsProvisioningHTTPS().Length(); } TPtrC uriPtr = iProfiles[aItem]->iHostAddress->Mid(startPos); if(uriPtr.Locate(KNSmlDMColon)!=KErrNotFound) { portFound = ETrue; } if( portFound == EFalse ) { HBufC *uri = 0; // port not found from URI -> see if it is given separately if( iProfiles[aItem]->iPort ) { // parse address and port into URI if( CombineURILC( iProfiles[aItem]->iHostAddress->Des(), iProfiles[aItem]->iPort->Des(), uri ) == KErrNone ) { if(iProfiles[aItem]->iHostAddress) { delete iProfiles[aItem]->iHostAddress; iProfiles[aItem]->iHostAddress = NULL; } iProfiles[aItem]->iHostAddress = uri->Des().AllocL(); } CleanupStack::PopAndDestroy(); // uri } else { // use default port if( CombineURILC( iProfiles[aItem]->iHostAddress->Des(), KNSmlDsDefaultPort(), uri ) == KErrNone ) { if(iProfiles[aItem]->iHostAddress) { delete iProfiles[aItem]->iHostAddress; iProfiles[aItem]->iHostAddress = NULL; } iProfiles[aItem]->iHostAddress = uri->Des().AllocL(); } CleanupStack::PopAndDestroy(); // uri } } connection.SetServerURIL( ConvertTo8LC( iProfiles[aItem]->iHostAddress->Des() ) ); CleanupStack::PopAndDestroy(); // ConvertTo8LC } // set authtype, HTTPUserName, HTTPPassword if( iProfiles[aItem]->iHTTPUserName || iProfiles[aItem]->iHTTPPassword ) { connection.SetPropertyL( KNSmlHTTPAuth, KNSmlTrueVal ); if( iProfiles[aItem]->iHTTPUserName ) { connection.SetPropertyL( KNSmlHTTPUsername, iProfiles[aItem]->iHTTPUserName->Des() ); } if( iProfiles[aItem]->iHTTPPassword ) { connection.SetPropertyL( KNSmlHTTPPassword, iProfiles[aItem]->iHTTPPassword->Des() ); } } else { connection.SetPropertyL( KNSmlHTTPAuth, KNSmlFalseVal ); } connection.UpdateL(); CleanupStack::PopAndDestroy(); // connection if(iProfiles[aItem]->iProtocolVersion == ESmlVersion1_1_2 || iProfiles[aItem]->iProtocolVersion == ESmlVersion1_2 ) { profile.SetProtocolVersionL(iProfiles[aItem]->iProtocolVersion); } TInt iDataProvElementCount = iProfiles[aItem]->iDataProvElement.Count(); _DBG_FILE("CNSmlDsProvisioningAdapter::SaveL(): Resource For loop: before Start"); for ( TInt i = 0; i < iDataProvElementCount; i++ ) { _DBG_FILE( "CNSmlDsProvisioningAdapter::SaveL(): Resource For loop: In"); RSyncMLDataProvider dataProvider; TRAPD(error, dataProvider.OpenL(iSession, iProfiles[aItem]->iDataProvElement[i]->iUid)); if (!error) { CleanupClosePushL(dataProvider); if (ret) { RArray<TSmlTaskId> providers; profile.ListTasksL(providers); TInt dataprovcount = providers.Count(); for (TInt i = 0; i < dataprovcount; i++) { TSmlTaskId taskID = providers[i]; RSyncMLTask task; task.OpenL(profile, taskID); CleanupClosePushL(task); if (dataProvider.Identifier() == task.DataProvider()) { profile.DeleteTaskL(taskID); CleanupStack::PopAndDestroy(); break; } CleanupStack::PopAndDestroy(); } providers.Reset(); providers.Close(); } HBufC* localDB = dataProvider.DefaultDataStoreName().AllocLC(); _DBG_FILE("CNSmlDsProvisioningAdapter::SaveL(): DB value"); DBG_ARGS( iProfiles[aItem]->iDataProvElement[i]->iRemoteDBUri->Des().Ptr()); RSyncMLTask task; task.CreateL( profile, iProfiles[aItem]->iDataProvElement[i]->iUid, iProfiles[aItem]->iDataProvElement[i]->iRemoteDBUri->Des(), localDB->Des()); CleanupClosePushL(task); TRAPD(err, task.UpdateL()); if (err != KErrAlreadyExists && err != KErrNone) { User::Leave(err); } CleanupStack::PopAndDestroy(3); // task, localDB, dataProvider } } _DBG_FILE("CNSmlDsProvisioningAdapter::SaveL(): Resource For loop: after End"); profile.UpdateL(); iProfiles[aItem]->iProfileId = profile.Identifier(); CleanupStack::PopAndDestroy( &profile ); _DBG_FILE("CNSmlDsProvisioningAdapter::SaveL(): end"); }