TUint CTupleStoreImpl::PutL(TTupleType aTupleType, const TTupleName& aTupleName, const TDesC& aSubName, 
		const TComponentName& aComponent,
		const TDesC8& aSerializedData, TBBPriority aPriority, TBool aReplace,
		const TTime& aLeaseExpires, TBool aKeepExisting)
{
	CALLSTACKITEM_N(_CL("CTupleStoreImpl"), _CL("PutL"));

	if (aTupleName.iModule.iUid == KBBAnyUidValue ||
		aTupleName.iId == KBBAnyId ||
		aComponent.iModule.iUid == KBBAnyUidValue ||
		aComponent.iId == KBBAnyId) User::Leave(KErrArgument);

	TUint ret;
	{
		TAutomaticTransactionHolder ath(*this);

		TBool exists=SeekNameL(aTupleType, aTupleName, aSubName);
		if (exists && aKeepExisting) {
			UpdateL();
			iTable.SetColL(ELeaseExpires, aLeaseExpires);
			MDBStore::PutL();
			return 0;
		} else if (exists && aReplace) {
			UpdateL();
		} else {
			InsertL();
			iTable.SetColL(ETupleType, aTupleType);
			iTable.SetColL(ENameModule, aTupleName.iModule.iUid);
			iTable.SetColL(ENameId, aTupleName.iId);
			iTable.SetColL(ENameSubName1, aSubName);
			iTable.SetColL(ENameSubName2, aSubName.Left(iSubNameIndexLength));
			iTable.SetColL(EPriority, aPriority);
			iTable.SetColL(EComponentModule, aComponent.iModule.iUid);
			iTable.SetColL(EComponentId, aComponent.iId);
		}
		ret=iTable.ColUint(ETupleId);

		if (aSerializedData.Length() > 0) {
			RADbColWriteStream w; w.OpenLA(iTable, EData);
			w.WriteUint32L(aSerializedData.Length());
			w.WriteL(aSerializedData);
			w.CommitL();
		} else {
			iTable.SetColNullL(EData);
		}
		iTable.SetColL(ELeaseExpires, aLeaseExpires);
		MDBStore::PutL();
	}

	if (aLeaseExpires < iNextExpiry) {
		TTime now=GetTime();
		TTimeIntervalSeconds s;
		aLeaseExpires.SecondsFrom(now, s);
		TInt wait=s.Int();
		iTimer->Wait(wait);
	}
	return ret;
}
// -----------------------------------------------------------------------------
// CDRMHelperServer::UpdateL().
// This function update items with a URI
// -----------------------------------------------------------------------------
//
void CDRMHelperServer::UpdateL( const TDesC8& aUri )
    {
#ifdef _DRM_TESTING
    WriteL(_L8("UpdateL(aUri)"));
    WriteL(aUri);
#endif

    UpdateL( aUri , ContentAccess::EView);
    UpdateL( aUri , ContentAccess::EPlay);
    UpdateL( aUri , ContentAccess::EExecute);
    UpdateL( aUri , ContentAccess::EPrint);

    }
// -----------------------------------------------------------------------------
// CDRMHelperServer::UpdateL().
// This function update items with a URI and a permission type
// -----------------------------------------------------------------------------
//
void CDRMHelperServer::UpdateL(
            const TDesC8& aUri ,
            const TUint8& aPermType )
    {
#ifdef _DRM_TESTING
    WriteL(_L8("UpdateL(aUri,aPerm)"));
    WriteL(aUri);
#endif

    UpdateL( aUri , aPermType , CDRMHelperServer::EActive );
    UpdateL( aUri , aPermType , CDRMHelperServer::EPassive );

    }
/**
Updates the listtype and favouritename. Only, these 2 properties can be modified.

@param aUriPropsId Property ID which uniquely identifies the row in the URIPropertiesTbl
@param aListType New Listtype 
@param aFavouriteName New favourite name for the URI
*/
void CUriListInterface::UpdateUriL ( TInt aUriPropsId, InetUriList::TListType aListType, const TDesC8& aFavouriteName )
	{	
	iDbAccessor->BeginTransactionL ();
	// This is not to delete the object rather to do a rollback operation incase of a failure
	CleanupStack::PushL ( TCleanupItem ( CUriListInterface::RollbackTrans, iDbAccessor ) );

	// Only update List Type & Favourite Name. Other properties are not allowed to update.
	if ( UpdateL ( KUriPropsTblName(), aUriPropsId, aListType, aFavouriteName ) == 0 )
		User::Leave ( InetUriList::KErrUriNotFound );

	User::LeaveIfError ( UpdateL ( KViewName(), aUriPropsId, aListType, aFavouriteName ) );
	
	iDbAccessor->CommitTransactionL ();
	CleanupStack::Pop (); // iDbAccessor	
	}
Example #5
0
void CMyLEDAgendaNotifierSubject::UpdateL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage)
	{
	RDebug::Print(_L("Plugin: LED Agenda notifier updated (asynch. call) \n"));
	UpdateL(aBuffer);
	TRAPD(err,aMessage.WriteL(aReplySlot,KUpdateAgendaLEDResponseAsync));
	__ASSERT_ALWAYS(!err,User::Panic(_L("WriteL(aReplySlot,KUpdateAgendaLEDResponseAsync)"),err));
	}
// -----------------------------------------------------------------------------
// CUpdateManager::RunL
//
// Handles an active object's timer event.
// -----------------------------------------------------------------------------  
void CUpdateManager::RunL()
    {
    TTime   currentTime;
    currentTime.HomeTime();
    TTimeIntervalMinutes diff;
    currentTime.MinutesFrom(iLastAutoUpdate,diff);

    if (diff.Int() < 0)
        {
        for(TInt i =0 ; i < iQueueArray.Count(); i++)
            {
            iQueueArray[i]->ResetTimers(); 
            }
        }
    iLastAutoUpdate.HomeTime();

    if (iStatus.Int() == KErrNone || iStatus.Int() == KErrAbort)
        {      
        StartTimer();
        if(iAutoUpdateWhileRoaming)
            {
            UpdateL();
            }
        else
            {
            iRoamingInfo->CheckForRoaming();
            }
        }      
    }
// --------------------------------------------------------------------------
// CHomeMediaContainer::ConstructL
// --------------------------------------------------------------------------
//
void CHomeMediaContainer::ConstructL(const TRect& aRect)
    {
    CAknDoubleLargeStyleListBox* listBoxModel
                                   = new (ELeave)CAknDoubleLargeStyleListBox;
    BaseConstructL( aRect , listBoxModel );
    UpdateL();
    }
// -----------------------------------------------------------------------------
// CLandmarksInfoContainer::EditLandmarkL
// 
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CLandmarksInfoContainer::EditLandmarkL()
    {
    // Create editor
    TBool isEdited = EFalse;

    TInt selectedLine = iListBox->View()->CurrentItemIndex();
    TInt activeField = 0;
    if (selectedLine >= 0 && selectedLine < iFields.Count())
        {
        activeField = iFields[selectedLine];
        }
    
    CLandmarksEditDialog* editDialog = CLandmarksEditDialog::NewLC(
        *iLandmark, EFalse, isEdited, iEngine, activeField);

    TInt err = editDialog->ExecuteLD(R_LMREFAPP_EDIT_DIALOG);
    CleanupStack::Pop(editDialog);
    User::LeaveIfError(err);

    // Commit if edited
    if (isEdited)
        {
        iEngine.CommitLandmarkL(*iLandmark);
        UpdateL();
    
        // move to first field
        iListBox->View()->SetCurrentItemIndex(0);
        }
    }
Example #9
0
EXPORT_C void CCnaConverterList::ConvToListL(const TDataType& aMimeType,CArrayFix<SConverterInfo>* aSConverterInfoArray)
/** Gets a list of converters that convert to a specified data type.

@param aMimeType Target data type
@param aSConverterInfoArray On return, an array of converter information objects
for all suitable converters */
{
    ASSERT(aSConverterInfoArray->Count()==0);
    if (!iDoneScan)
        UpdateL();
    TInt i;
    TInt count = iConverters->Count();
    for (i = 0; i < count; i++)
    {
        CCnaConverter* conv = iConverters->At(i);
        //does converter support this type
        if (conv->MimeTo(aMimeType) )
        {
            const TInt countFrom=conv->CountFrom();
            for( TInt j=0; j<countFrom; j++)
            {
                SConverterInfo info;
                info.iTranslation=conv->MimeFromText(j);
                info.iUid=conv->Uid();
                info.iIndex=j;
                aSConverterInfoArray->AppendL(info);
            }
        }
    }
}
// -----------------------------------------------------------------------------
// CAMMSLocationControlGroup::SetCartesianL
// Moves the object to the new location
// (other items were commented in a header).
// -----------------------------------------------------------------------------
void CAMMSLocationControlGroup::SetCartesianL(TInt aX, TInt aY, TInt aZ)
{
    iUncommited.iLocation[ EComponentX ] = aX;
    iUncommited.iLocation[ EComponentY ] = aY;
    iUncommited.iLocation[ EComponentZ ] = aZ;

    UpdateL(ELocation);
}
Example #11
0
void CMyLEDPhoneNotifierSubject::UpdateL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage)
	{
	RDebug::Print(_L("Plugin: LED Phone notifier updated (asynch. call) \n"));
	UpdateL(aBuffer);
	TRAPD(err,aMessage.WriteL(aReplySlot,KUpdatePhoneLEDResponseAsync));
	__ASSERT_ALWAYS(!err,User::Panic(_L("WriteL(aReplySlot,KUpdatePhoneLEDResponseAsync)"),err));
	aMessage.Complete(EEikNotExtRequestCompleted);
	}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//
void CPosLmNameIndex::UpdateL( TPosLmItemId aId, const TDesC& aName )
    {
    HBufC* name = aName.AllocLC();
	CleanupStack::Pop( name );//ownership of name is transferred in the call to UpdateL
//coverity[freed_arg : FALSE]
    UpdateL( aId, name );
//coverity[pass_freed_arg : FALSE]
    }
// -----------------------------------------------------------------------------
// CAMMSDopplerControlGroup::SetVelocityCartesianL
// Sets the velocity, used in calculations for the Doppler effect.
// (other items were commented in a header).
// -----------------------------------------------------------------------------
void CAMMSDopplerControlGroup::SetVelocityCartesianL(
    TInt aX,
    TInt aY,
    TInt aZ)
{
    iUncommited.iVelocity[ EComponentX ] = aX;
    iUncommited.iVelocity[ EComponentY ] = aY;
    iUncommited.iVelocity[ EComponentZ ] = aZ;

    UpdateL(EVelocity);
}
// -----------------------------------------------------------------------------
// CAMMSDopplerControlGroup::SetEnabledL
// Specifies if this Doppler effect is active or ignored.
// (other items were commented in a header).
// -----------------------------------------------------------------------------
void CAMMSDopplerControlGroup::SetEnabledL(TBool aEnabled)
{
    // If the DopplerControl was fetched from the Spectator,
    // this method has no effect. So only disable the value for SoundSource3D.
    if (aEnabled ||
            (!aEnabled && iControlType == EAMMSSoundSource3DControl))
    {
        iUncommited.iEnabled = aEnabled;
        UpdateL(EEnabled);
    }
}
// -----------------------------------------------------------------------------
// CLandmarksInfoContainer::LoadLandmarkL
// 
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CLandmarksInfoContainer::LoadLandmarkL(TPosLmItemId aLandmarkId)
    {
	delete iLandmark;
	iLandmark = NULL;

    iLandmark = iEngine.LandmarkLC(aLandmarkId);
    CleanupStack::Pop(iLandmark);

    UpdateL();
    iListBox->View()->SetCurrentItemIndex(0);
    }
void CTupleStoreImpl::CleanOldTuplesL()
{
	CALLSTACKITEM_N(_CL("CTupleStoreImpl"), _CL("CleanOldTuplesL"));

	SwitchIndexL(EIndexLeaseExpires);
	iTable.FirstL();
	iTable.GetL();

	TTupleName name; TBuf<KMaxTupleSubNameLength> subname;
	TTime expires;
	
	if (iTable.IsColNull(ELeaseExpires)) {
		expires=TTime(0);
	} else {
		expires=iTable.ColTime(ELeaseExpires);
	}
	TTime now=GetTime();
	TInt tupletype=-1;
	while (now > expires) {
		if ( iTable.IsColNull(ELeaseExpires) ) {
			UpdateL();
			iTable.SetColL( ELeaseExpires, Time::MaxTTime() );
			MDBStore::PutL();
		} else {
			tupletype=iTable.ColInt(ETupleType);
			if (tupletype == ETupleDataOrRequest) {
				name.iModule.iUid=iTable.ColInt(ENameModule);
				name.iId=iTable.ColInt(ENameId);
				subname=iTable.ColDes16(ENameSubName1);
			}
			MDBStore::DeleteL();
			if (tupletype == ETupleDataOrRequest) {
				iDeleteNotification.NotifyDeleted(name, subname);
			}
		}
		if (! iTable.NextL() ) return;
		iTable.GetL();
		if (iTable.IsColNull(ELeaseExpires)) {
			expires=TTime(0);
		} else {
			expires=iTable.ColTime(ELeaseExpires);
		}
	}
	if ( expires == TTime(0) || expires == Time::MaxTTime() ) return;

	TTimeIntervalSeconds s;
	TInt err=expires.SecondsFrom(now, s);
	if (err==KErrOverflow) return;

	iNextExpiry=expires;
	TInt wait=s.Int();
	iTimer->Wait(wait);
}
// -----------------------------------------------------------------------------
// CAMMSDopplerControlGroup::SetVelocitySphericalL
// Sets the velocity, used in calculations for the Doppler effect.
// (other items were commented in a header).
// -----------------------------------------------------------------------------
void CAMMSDopplerControlGroup::SetVelocitySphericalL(
    TInt aAzimuth,
    TInt aElevation,
    TInt aRadius)
{
    TInt sphericalVector[] = { aAzimuth, aElevation, aRadius };

    // Convert to cartesian.
    AMMSUtil::FromSphericalToCartesianL(sphericalVector,
                                        iUncommited.iVelocity);

    UpdateL(EVelocity);
}
Example #18
0
EXPORT_C TInt CCnaConverterList::CountL()
/** Gets the total number of converters.

It can leave because it needs to rescan the disk to refresh
the list of converters.

@return Total number of converters */
{
    if (!iDoneScan)
        UpdateL();
    TInt count=0;
    return count+iImplementationArray.Count();
}
// -----------------------------------------------------------------------------
// CAMMSLocationControlGroup::SetSphericalL
// Moves the object to the new location
// (other items were commented in a header).
// -----------------------------------------------------------------------------
void CAMMSLocationControlGroup::SetSphericalL(
    TInt aAzimuth,
    TInt aElevation,
    TInt aRadius)
{
    __ASSERT_DEBUG(aRadius >= 0, User::Invariant());

    TInt sphericalVector[] = { aAzimuth, aElevation, aRadius };

    // Convert to cartesian.
    AMMSUtil::FromSphericalToCartesianL(sphericalVector,
                                        iUncommited.iLocation);

    UpdateL(ELocation);
}
Example #20
0
void CSpecialLog::SpecialLogL(TInt aKey, TInt aValue)
{
	RLogSpecial & entry = iLogSpecial[aKey];
	if (ESpecialLogInt == entry.iType && aValue == entry.iInt)
		return; 	// Same, ignore.

	if (ESpecialLogText == entry.iType)
	{
		delete entry.iText;
		entry.iText = NULL;
		entry.iType = ESpecialLogInt;
	}
	entry.iInt = aValue;
	UpdateL(EFalse);
}
Example #21
0
void CSpecialLog::SpecialLogL(TInt aKey, const TDesC & aValue)
{
	RLogSpecial & entry = iLogSpecial[aKey];
	if (ESpecialLogText == entry.iType && entry.iText)
	{
		if (entry.iText->Length() == aValue.Length() && 0 == entry.iText->Compare(aValue))
			return; // Same, ignore.
		// Reallocate for the value descriptor.
		delete entry.iText;
		entry.iText = NULL;
	}
	else
	{
		entry.iType = ESpecialLogText;
	}
	entry.iText = aValue.AllocL();
	UpdateL(EFalse);
}
Example #22
0
EXPORT_C TUid CCnaConverterList::ConverterL(const TDataType& aFrom,const TDataType& aTo)
/** Gets the UID of the converter that converts to and from the specified data types.

@param aFrom Source data type
@param aTo Target data type
@return Converter UID */
{
    if (!iDoneScan)
        UpdateL();
    TInt ii;
    TInt count=iConverters->Count();
    for (ii=0; ii<count; ii++)
    {
        const CCnaConverter* conv=iConverters->At(ii);
        if (conv->MimeFrom(aFrom) && conv->MimeTo(aTo))
        {
            return conv->Uid();
        }
    }
    return KNullUid;
}
Example #23
0
EXPORT_C CConverterBase* CCnaConverterList::NewConverterL(TUid aUid)
/** Locates the converter with the specified UID, loads its associated DLL
and returns a pointer to it.

@param aUid Converter UID
@return Converter with the specified UID, or NULL if there is no suitable converter */
{
    CConverterBase* base=ConverterListUtil::UtilityConverterL(aUid);
    if (base)
        return base;
    if (!iDoneScan)
        UpdateL();
    TInt i;
    TInt count;
    count = iImplementationArray.Count();
    for (i = 0; i < count; i++)
    {
        if (iImplementationArray[i]->ImplementationUid()==aUid)
        {
            return LoadConverterL(iImplementationArray[i]->ImplementationUid());
        }
    }
    return NULL;
}
// -----------------------------------------------------------------------------
// CDRMHelperServer::HandleEventL().
// This function handle event from DRM notifier
// -----------------------------------------------------------------------------
//
void CDRMHelperServer::HandleEventL( MDRMEvent* aEvent )
    {
#ifdef _DRM_TESTING
    WriteL(_L8("HandleEventL"));
#endif

    HBufC8* contentID = 0;
    TDRMEventType event;

    aEvent->GetEventType(event);

#ifdef _DRM_TESTING
            WriteL(_L8("Notifier:"),event);
#endif
    switch(event)
        {
        case KEventAddRemove:
            {
#ifdef _DRM_TESTING
            WriteL(_L8("Notifier: EventAddRemove"));
#endif
            contentID = REINTERPRET_CAST( CDRMEventAddRemove* , aEvent )->GetContentIDL();
            CleanupStack::PushL( contentID );
#ifdef _DRM_TESTING
            WriteL(contentID->Des());
#endif
            switch( REINTERPRET_CAST( CDRMEventAddRemove* , aEvent )->Status() )
                {
                case ERightsObjectRecieved:
                    {
#ifdef _DRM_TESTING
                    WriteL(_L8("Notifier: RightsObjectRecieved"));
#endif
                    UpdateL( contentID->Des() );
                    }
                    break;
                case ERightsObjectDeleted:
                    {
#ifdef _DRM_TESTING
                    WriteL(_L8("Notifier: RightsObjectDeleted"));
#endif
                    UpdateL( contentID->Des() );
                    }
                    break;
                case ERightsObjectDeletedAll:
                    {
#ifdef _DRM_TESTING
                    WriteL(_L8("Notifier: RightsObjectDeletedAll"));
#endif
                    UpdateL( contentID->Des() );
                    }
                    break;
                default:
                    {
#ifdef _DRM_TESTING
                    WriteL(_L8("Notifier: Unknown event"));
#endif
                    }
                    break;
                }
            CleanupStack::PopAndDestroy( contentID );
            }
            break;
        case KEventModify:
            {
#ifdef _DRM_TESTING
            WriteL(_L8("Notifier: EventModify"));
#endif
            contentID = REINTERPRET_CAST( CDRMEventModify* , aEvent )->GetContentIDL();
            CleanupStack::PushL( contentID );
#ifdef _DRM_TESTING
            WriteL(contentID->Des());
#endif
            UpdateL( contentID->Des() );
            CleanupStack::PopAndDestroy( contentID );
            }
            break;
        case KEventTimeChange:
            {
#ifdef _DRM_TESTING
            WriteL(_L8("Notifier: EventTimeChange"));
#endif
            UpdateL();
            }
            break;
        default:
            {
#ifdef _DRM_TESTING
            WriteL(_L8("Notifier: Unknown event"));
#endif
            }
            break;

        }
    return;
    }
Example #25
0
/**
Add the given contact item to the database. Forward the call to CPplTableBase
based classes representing the tables in the contact database.

@param 	aItem The contact item to be added to the database. 
@param 	aSessionId The ID of the session that issued the request.  Used to
		prevent Phonebook Synchroniser deadlock.

@return Contact item ID of the contact added to the database.
*/
TContactItemId CPplContactItemManager::CreateL(CContactItem& aItem, TUint aSessionId)
	{
	TBool controlTransaction = !(iTransactionManager.IsTransactionActive());
	
	TBool compressedGuid=EFalse;

	// If needed generate a gui for the current contact item
	if (aItem.Guid() == TPtrC(KNullDesC))
		{
		iPreferencePersistor->SetGuidL(aItem, compressedGuid);
		}

	if (compressedGuid)
		{
		aItem.SetHasCompressedGuid(compressedGuid);
		}

	if (aItem.Type() == KUidContactICCEntry) 
		{
		const TInt ret = iContactProperties.ContactSynchroniserL(aSessionId).ValidateWriteContact(static_cast<CContactICCEntry&>(aItem));
		User::LeaveIfError(ret);	
		}
	
	if(controlTransaction)
		{
		StartTransactionL(aSessionId);
		}
		
	iContactTable->CreateInDbL(aItem);	
	iGroupTable->CreateInDbL(aItem);	
	iCommAddrTable->CreateInDbL(aItem);

   	TContactItemId groupId = iIccContactStore.CreateInDbL(aItem, aSessionId);
   	if(groupId != KNullContactId)
   	    {
   	    //Every ICC entry is added to a special group, created by the Phonebook
        //Synchroniser server during the initial synchronisation with the Contacts Model.
		CContactItemViewDef* itemDef = CContactItemViewDef::NewLC(CContactItemViewDef::EIncludeFields,CContactItemViewDef::EMaskHiddenFields);
		itemDef->AddL(KUidContactFieldMatchAll);

		// Add ICC entry to the group.
		CContactGroup* grp = static_cast<CContactGroup*>(ReadLC(groupId, *itemDef, EPlAllInfo, aSessionId));
		
		grp->AddContactL(aItem.Id());
		UpdateL(*grp, aSessionId);

		CleanupStack::PopAndDestroy(2, itemDef); // grp
   	    }

	if(controlTransaction)
		{
		CommitTransactionL();
		}
	
	// Assuming success if no leaves at this point, so update
	// the metadata search store for this entry
	//CCntMetadataOperation* op = CCntMetadataOperation::NewLC(iColSession);
	//TRAP_IGNORE(op->SaveContactLD(aItem));
	//CleanupStack::Pop(op); // Do not destroy - called LD function
	
	return aItem.Id();	
	}
void CTupleStoreImpl::ConstructL()
{
	CALLSTACKITEM_N(_CL("CTupleStoreImpl"), _CL("ConstructL"));

	iSubNameIndexLength=40;

	// name:      id,           tupletype,   
	TInt cols[]={ EDbColUint32, EDbColInt32, 
	//{     Uid,         Id,          subname1 }, 
		EDbColInt32, EDbColInt32, EDbColText, 
	//      priority,   
		EDbColInt8,
	// {	Uid,         Id},
		EDbColInt32, EDbColInt32, 
	//      data              LeaseExpires
		EDbColLongBinary, EDbColDateTime, 
	//		subname2
		EDbColText, -1 };

	TInt col_flags[]={ TDbCol::EAutoIncrement, 0, 0, 0, 0, 0,
		0, 0, 
		0, 0,
		0, 0 };
	// the tuple id is added to indices so that data is read in
	// the order it arrives
	TInt idxs[]={ 
		ETupleType, ENameModule, ENameId, ENameSubName2, ETupleId, -2, 
		ETupleId, -2,
		ETupleType, EComponentModule, EComponentId, 
			EPriority, ETupleId, -2,
		ELeaseExpires, 
		-1 };

	MDBStore::ConstructL(cols, idxs, false, 
		_L("TUPLES"), EFalse, col_flags);

	iTimer=CTimeOut::NewL(*this, CActive::EPriorityIdle);
	if (SeekIdL(0)) {
		TInt version=0;
		iTable.GetL();
		// check version and migrate if necessary
		version=iTable.ColInt32(ENameId);

		if (version<KVersion) {
			SwitchIndexL(-1); // no index
			TBool found=iTable.FirstL();
			while (found) {
				iTable.GetL();
				TUint uid_in_table, new_uid;
				new_uid=uid_in_table=iTable.ColInt(ENameModule);
				GetBackwardsCompatibleUid(new_uid);
				if (new_uid != uid_in_table) {
					UpdateL();
					iTable.SetColL(ENameModule, new_uid);
					MDBStore::PutL();
				}
				found=iTable.NextL();
			}
		}
		if (version<=KVersionBeforeExpires) {
			SwitchIndexL(-1); // no index
			TBool found=iTable.FirstL();
			while (found) {
				iTable.GetL();
				TInt tupletype;
				TTupleName tn;

				tn.iModule.iUid=iTable.ColInt(ENameModule);
				tn.iId=iTable.ColInt(ENameId);
				tupletype=iTable.ColInt(ETupleType);

				if ( (!(tn == KCLSettingsTuple)) && tupletype!=ETupleSpaceInternal ) {
					MDBStore::DeleteL();
				}
				found=iTable.NextL();
			}
		}

		if (version<KVersionBeforeNewUids) {
			TInt no_idxs[]={ -1 };
			iTable.Close();
			DeleteIndices(_L("TUPLES"));
			CC_TRAPD(err, MDBStore::ConstructL(cols, no_idxs, 
				false, _L("TUPLES"), ETrue, col_flags));
			iDb.BeginL();
			TTransactionHolder th(*this);
			TBool found=iTable.FirstL();
			while (found) {
				iTable.GetL();
				if ( iTable.ColUint(ETupleId) == 0 ) {
					UpdateL();
					iTable.SetColL(ENameId, KVersion);
					MDBStore::PutL();
				} else if (! iTable.IsColNull(ENameSubName1)) {
					UpdateL();
					iTable.SetColL(ENameSubName2,
						iTable.ColDes(ENameSubName1).Left(iSubNameIndexLength));
					MDBStore::PutL();
				}
				found=iTable.NextL();
			}
			iDb.CommitL();
			MDBStore::ConstructL(cols, idxs, 
				false, _L("TUPLES"), ETrue, col_flags);
		}

		if (version>=KVersionBeforeNewUids) {
			CleanOldTuplesL();
		}
		SeekIdL(0);
		UpdateL();
		iTable.SetColL(ENameId, KVersion);
		MDBStore::PutL();
		
	} else {
		InsertL();
		iTable.SetColL(ETupleType, ETupleSpaceInternal);
		iTable.SetColL(ENameId, KVersion);
		iTable.SetColL( ELeaseExpires, Time::MaxTTime() );
		MDBStore::PutL();
	}
}