/**
Creates a New Service
If a Service Exists it doesnot create a new one

@param aSession		Current Session reference
@param aDescription	Entry Description Descriptor
@param aDetail		Entry Details Descriptor
@internalTechnology
*/
void CentralRepoUtils::CreateServiceL(CMsvSession* aSession, const TDesC& aDescription, const TDesC& aDetail)
	{
	TMsvId serviceId=0;
	TRAPD(err,TSmsUtilities::ServiceIdL(*aSession,serviceId));

		if(err == KErrNotFound) // If Service Already Exists Do not create new One
			{
			TInt priority = EMsvMediumPriority;
			TInt readOnlyFlag = EFalse;
			TInt visibleFlag = ETrue;

			TMsvEntry indexEntry;
			indexEntry.iType = KUidMsvServiceEntry;
			indexEntry.iMtm = KUidMsgTypeSMS;
			indexEntry.SetReadOnly(readOnlyFlag);
			indexEntry.SetVisible(visibleFlag);	
			indexEntry.SetPriority(TMsvPriority(priority));
			indexEntry.iDescription.Set(aDescription);
			indexEntry.iDetails.Set(aDetail);
			indexEntry.iDate.HomeTime();
			
			CMsvEntry* entry = CMsvEntry::NewL(*aSession,KMsvRootIndexEntryId,TMsvSelectionOrdering());
			CleanupStack::PushL(entry);
			entry->CreateL(indexEntry);
		    CleanupStack::PopAndDestroy(entry);
			}
	}
Esempio n. 2
0
/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
void CSMSSender::CreateNewMessageL()
{
	Cancel();
	iMessageMade = iMessageSent = iMessageReceived = EFalse;
	
	delete iMtm;
	iMtm = NULL;

    TMsvEntry newEntry;              // This represents an entry in the Message Server index
    newEntry.iMtm = KUidMsgTypeSMS;                         // message type is SMS
	newEntry.iType = KUidMsvMessageEntry;                   // this defines the type of the entry: message 
	newEntry.iServiceId = KMsvLocalServiceIndexEntryId;     // ID of local service (containing the standard folders)
	newEntry.iDate.UniversalTime();                              // set the date of the entry to home time
	newEntry.SetInPreparation(ETrue);                       // a flag that this message is in preparation
   	newEntry.SetReadOnly(EFalse);
   	
    // - CMsvEntry accesses and acts upon a particular Message Server entry.
    // - NewL() does not create a new entry, but simply a new object to access an existing entry.
    // - It takes in as parameters the client's message server session,
    //   ID of the entry to access and initial sorting order of the children of the entry. 
    CMsvEntry* entry = CMsvEntry::NewL(*iSession, KMsvDraftEntryIdValue, TMsvSelectionOrdering());
    CleanupStack::PushL(entry);

    delete iOperation;
    iOperation = NULL;
    iOperation = entry->CreateL(newEntry, iStatus);
    CleanupStack::PopAndDestroy(entry);

    iPhase = EWaitingForCreate;
    SetActive();    
}
Esempio n. 3
0
TMsvId CFakeSMSSender::CreateNewMessageL(TTime aMsgTime)
{
    CMsvEntry* Draftentry = CMsvEntry::NewL(*iMsvSession, KMsvDraftEntryIdValue ,TMsvSelectionOrdering());
  	CleanupStack::PushL(Draftentry);

    CMsvOperationWait* wait = CMsvOperationWait::NewLC();
    wait->Start();
    
	TMsvEntry newEntry;              // This represents an entry in the Message Server index
    newEntry.iMtm = KUidMsgTypeSMS;                         // message type is SMS
 	newEntry.iType = KUidMsvMessageEntry; //KUidMsvServiceEntry                  // this defines the type of the entry: message 
 	newEntry.iServiceId = KMsvLocalServiceIndexEntryId; //    // ID of local service (containing the standard folders)
   	newEntry.iDate = aMsgTime;                              // set the date of the entry to home time
	newEntry.SetInPreparation(ETrue);                       // a flag that this message is in preparation
	newEntry.SetReadOnly(EFalse);					
		
	CMsvOperation* oper = Draftentry->CreateL(newEntry,wait->iStatus);
    CleanupStack::PushL(oper);
    CActiveScheduler::Start();

    while( wait->iStatus.Int() == KRequestPending )
    {
        CActiveScheduler::Start();
    }

    
    // ...and keep track of the progress of the create operation.
    TMsvLocalOperationProgress progress = McliUtils::GetLocalProgressL(*oper);
    User::LeaveIfError(progress.iError);
//	Draftentry->MoveL(progress.iId,KMsvGlobalInBoxIndexEntryId);

	CleanupStack::PopAndDestroy(3);//Draftentry,wait,oper
	
    return progress.iId;
 }
Esempio n. 4
0
// -----------------------------------------------------------------------------
// CWPMessage::PostprocessEntryL
// -----------------------------------------------------------------------------
//
void CWPMessage::PostprocessEntryL( CMsvEntry& aCEntry, TMsvEntry& aTEntry )
    {
    FLOG( _L( "CWPMessage::PostprocessEntryL" ) );
    
    aTEntry.SetReadOnly(EFalse);
    aTEntry.SetVisible(ETrue);
    aTEntry.SetInPreparation(EFalse);
    aCEntry.ChangeL(aTEntry);
    }
Esempio n. 5
0
// -----------------------------------------------------------------------------
// CWPMessage::PrepareEntry
// -----------------------------------------------------------------------------
//
void CWPMessage::PrepareEntryLC( TMsvEntry& aEntry )
    {
    FLOG( _L( "CWPMessage::PrepareEntryLC" ) );
    
    // Current time
    TTime time;

	// Get Universal time
	time.UniversalTime();

	FLOG( _L( "CWPMessage::PrepareEntryLC create an invisible blank entry" ) );	
    // create an invisible blank entry 
    aEntry.iType = KUidMsvMessageEntry;
    aEntry.SetVisible(EFalse);
    aEntry.SetInPreparation(ETrue);
    aEntry.SetReadOnly(EFalse);
    aEntry.SetUnread(ETrue);
    aEntry.iDate = time;
    aEntry.iServiceId = KMsvLocalServiceIndexEntryId;
    aEntry.iError = KErrNone;
    // iMtmData1 is been used/reserved for count, please don't use for any other purpose.
    aEntry.SetMtmData1(3);
    FLOG( _L( "CWPMessage::PrepareEntryLC create an invisible blank entry done" ) );
    // Look up the details
    HBufC* details = NULL;
    if( iMessage->Authenticated() )
        {
        FLOG( _L( "CWPMessage::PrepareEntryLC iMessage->Authenticated() true" ) );
        details = LoadStringLC( R_FROM_SERVICEPROVIDER );
        FLOG( _L( "CWPMessage::PrepareEntryLC LoadString done" ) );
        }
    else
        {
        FLOG( _L( "CWPMessage::PrepareEntryLC iMessage->Authenticated() false" ) );
        if( iSender )
            {
            FLOG( _L( "CWPMessage::PrepareEntryLC iSender true" ) );
            details = HBufC::NewLC( iSender->Length() );
            details->Des().Copy( *iSender );
            }
        else
            {
            FLOG( _L( "CWPMessage::PrepareEntryLC iSender false" ) );
            details = KNullDesC().AllocLC();
            }
        }
    FLOG( _L( "CWPMessage::PrepareEntryLC iDetails.Set" ) );
    aEntry.iDetails.Set( *details );
    FLOG( _L( "CWPMessage::PrepareEntryLC Done" ) );
    }
Esempio n. 6
0
EXPORT_C TMsvId CMsvTestUtils::CreateServiceL(const TUid aMtm, TBool aReadOnly, TBool aVisible)
	{
	TMsvId id = 0;
	TMsvEntry entry;
	entry.iMtm = aMtm;
	entry.iType = KUidMsvServiceEntry;
	entry.SetReadOnly(aReadOnly);
	entry.SetVisible(aVisible);
	
	SetEntryL(KMsvRootIndexEntryId);
	CreateEntryL(entry);
	id = entry.Id();
	SetEntryL(id);
	return id;
	}
void CBulkCommitServerMtm::CreateBulkEntries(TUint aEntryCount, TMsvId aServiceId)
	{	
	TMsvEntry newEntry;
	for (TInt i = 0; i < aEntryCount; ++i)
		{
		newEntry.iType = KUidMsvMessageEntry;
		newEntry.iMtm = KUidBulkCommitTestMtm;
		newEntry.iServiceId = aServiceId;		
		newEntry.SetVisible(ETrue);
		newEntry.SetReadOnly(EFalse);
		newEntry.SetUnread(ETrue);
		newEntry.iDescription.Set(_L("Bulk Entry"));
		newEntry.SetSendingState(KMsvSendStateNotApplicable);
		
		iServerEntry->CreateEntryBulk(newEntry);	
		}
	}
/*
Creates two folders and then creates bulk entries under each folder.
After bulk commit, creates an entry to let the client know about 
bulk commit is done.
@param aEntryCount - Bulk entries to be created under each root entry
*/
void CBulkCommitServerMtm::CreateBulkEntryWithMultipleParentsL(TUint aEntryCount)
	{	
	iServerEntry->SetEntry(iServiceId);
	
	TMsvEntry folderEntry1, folderEntry2;
	//create the first folder
	folderEntry1.iType=KUidMsvFolderEntry;
	folderEntry1.iMtm = KUidBulkCommitTestMtm;
	folderEntry1.iServiceId = iServiceId;	
	iServerEntry->CreateEntry(folderEntry1);
	
	//create the second folder entry
	folderEntry2.iType=KUidMsvFolderEntry;
	folderEntry2.iMtm = KUidBulkCommitTestMtm;
	folderEntry2.iServiceId = iServiceId;	
	iServerEntry->CreateEntry(folderEntry2);
	
	iServerEntry->SetEntry(folderEntry1.Id());
	//Create a series of entries using the bulk API under the first folder
	CreateBulkEntries(aEntryCount, folderEntry1.Id());
	
	iServerEntry->SetEntry(folderEntry2.Id());
	//Create a series of entries using the bulk API under the second folder
	CreateBulkEntries(aEntryCount, folderEntry2.Id());
	
	//commit the bulk entries
	iServerEntry->CompleteBulk();
	
	iServerEntry->SetEntry(iServiceId);
	//Let the client know that the bulk commit is done
	TMsvEntry childEntry;	
	childEntry.iType = KUidMsvMessageEntry;
	childEntry.iMtm = KUidBulkCommitTestMtm;
	childEntry.iServiceId = iServiceId;		
	childEntry.SetVisible(ETrue);
	childEntry.SetReadOnly(EFalse);
	childEntry.SetUnread(ETrue);
	childEntry.iDescription.Set(_L("Bulk Commit Done"));
	childEntry.SetSendingState(KMsvSendStateNotApplicable);	
	iServerEntry->CreateEntry(childEntry);
	
	//Set entry to NULL entry to avoid locking	
	iServerEntry->SetEntry(KMsvNullIndexEntryId);		
	}
// -----------------------------------------------------------------------------
// CMmsAdapterMsvApi::AddUserFolderL
// Creates new user folder
// -----------------------------------------------------------------------------        
TInt CMmsAdapterMsvApi::AddUserFolderL( TMsvId& aFolder, const TDesC& aName )
    {
    TRACE_FUNC_ENTRY;
    LOGGER_WRITE_1( "aName: %S", &aName );
        
    // Make sure that we are not going to add same folder twise
    TBool found( EFalse );
    found = FindUserFolderL( aName, aFolder );
    if ( found )
        {
        LOGGER_WRITE( "Folder already exists" );
        LOGGER_LEAVEFN( "CMmsAdapterMsvApi::AddUserFolderL" );
        return KErrNone;
        } 
        
    CMsvEntry* entry = iSession.GetEntryL(KMsvMyFoldersEntryIdValue);
    CleanupStack::PushL( entry );
    
    TTime date;
    date.UniversalTime();    
    
    TMsvEntry folderEntry;
    folderEntry.iType = KUidMsvFolderEntry;
    folderEntry.iMtm = KUidMsvLocalServiceMtm;
    folderEntry.iDetails.Set( aName );   
    folderEntry.iServiceId = KMsvLocalServiceIndexEntryIdValue;
    folderEntry.iSize = sizeof( folderEntry );
    folderEntry.iDate = date;
    folderEntry.SetStandardFolder( EFalse );
    folderEntry.SetVisible( ETrue );
    folderEntry.SetComplete( ETrue );
    folderEntry.SetInPreparation( EFalse ); 
    folderEntry.SetReadOnly( EFalse );
    
    entry->CreateL( folderEntry );
    CleanupStack::PopAndDestroy( entry );
    
    aFolder = folderEntry.Id();
    
    TRACE_FUNC_EXIT;
    return KErrNone;
    }
// -----------------------------------------------------------------------------
// CMmsAdapterMsvApi::DeleteUserFolderL
// -----------------------------------------------------------------------------
//
 TInt CMmsAdapterMsvApi::DeleteUserFolderL( TMsvId aUid )
    {
    TRACE_FUNC_ENTRY;
    
    CMsvEntry* entry = iSession.GetEntryL(aUid);
    CleanupStack::PushL(entry);
    
    TMsvEntry tEntry = entry->Entry();
    TMsvId parent = tEntry.Parent();        
    
    if ( tEntry.iType != KUidMsvFolderEntry || parent != KMsvMyFoldersEntryIdValue )
        {
        LOGGER_WRITE( "Not correct folder" );
        CleanupStack::PopAndDestroy(entry);
        LOGGER_LEAVEFN( "MsvApi::DeleteUserFolderL" );
        return KErrNotSupported;
        }
        
    CMsvEntrySelection* children = entry->ChildrenL();
    TInt count = children->Count();
    delete children;
    
    if ( count > 0 )
        {
        LOGGER_WRITE( "Folder not empty" );
        CleanupStack::PopAndDestroy( entry );
        LOGGER_LEAVEFN( "MsvApi::DeleteUserFolderL" );
        return KErrInUse;
        }
        
    tEntry.SetReadOnly( EFalse );
    entry->ChangeL( tEntry );
    
    entry->SetEntryL( parent );
    entry->DeleteL( aUid );
    
    CleanupStack::PopAndDestroy( entry );
    TRACE_FUNC_EXIT;
    return KErrNone;
    }   
TMsvId TestUniDataModelVCalPlugin::CreateBIOEntryL(TDesC& aText,
                                                   TBIOMessageType aMessageType)
{
		// Ensure that we have a valid service ID to work with:
		TMsvId iBioServiceId;

		iBioServiceId = SetBIOServiceIdL();

		HBufC* localBuffer = aText.AllocL();
		CleanupStack::PushL(localBuffer);

		TPtr messDes = localBuffer->Des();

		if (aMessageType != EBiovCardMessage && aMessageType
            != EBiovCalenderMessage)
			{
				// convert \r\n to \n since this is what is expected from SMS when not vCard data
				for (TInt i = 0; i < messDes.Length(); i++)
					{
						if (messDes[i] == (TText) '\r' && i < messDes.Length() - 1
								&& messDes[i + 1] == (TText) '\n')
							messDes.Delete(i, 1);
					}
			}

		//  Create and fill a CRichText object for the jobbie:
		CParaFormatLayer* paraFormatLayer = CParaFormatLayer::NewL();
		CleanupStack::PushL(paraFormatLayer);
		CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL();
		CleanupStack::PushL(charFormatLayer);
		CRichText* richText = CRichText::NewL(paraFormatLayer, charFormatLayer);
		CleanupStack::PushL(richText);

		TInt pos = richText->DocumentLength();
		richText->InsertL(pos, messDes);

		TMsvEntry newBioEntry;
		newBioEntry.SetNew(ETrue);
		newBioEntry.SetComplete(EFalse);
		newBioEntry.SetUnread(ETrue);
		newBioEntry.SetVisible(ETrue);
		newBioEntry.SetReadOnly(EFalse);
		newBioEntry.SetFailed(EFalse);
		newBioEntry.SetOperation(EFalse);
		newBioEntry.SetMultipleRecipients(EFalse);
		newBioEntry.SetAttachment(EFalse);
		newBioEntry.iMtm = KUidBIOMessageTypeMtm;
		newBioEntry.iType = KUidMsvMessageEntry;
		newBioEntry.iServiceId = iBioServiceId;
		TTime now;
		now.UniversalTime();
		newBioEntry.iDate = now;

		TTime unixEpoch(KUnixEpoch);
		TTimeIntervalSeconds seconds;
		TTime timeStamp = newBioEntry.iDate;
		timeStamp.SecondsFrom(unixEpoch, seconds);
		retTimeStamp.setTime_t(seconds.Int());

		newBioEntry.iDescription.Set(richText->Read(0, richText->DocumentLength()));
		TBufC<KTelephoneNumberMaxLength> telNumber;

		QString recepient(TEST_MSG_FROM1);
		tempNumber = XQConversions::qStringToS60Desc(recepient);

		telNumber = tempNumber->Des();
		newBioEntry.iDetails.Set(telNumber);

		SetForMtmTypeL(newBioEntry, aMessageType);

		newBioEntry.iSize = richText->DocumentLength();// msgSize;
		CreateBioEntryClientSideL(newBioEntry, *richText);

		CleanupStack::PopAndDestroy(4); // richText, charFormatLayer, paraFormatLayer, localBuffer
		return newBioEntry.Id();
}