×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,347

    SMS-Remove from sent Folder. How?

    Hello friends,

    I am using SMSHandler.cpp.
    Now i don't want to srote SMS in sent item Folder after SMS has been sent.

    How could i achieve so?
    Please suggest me the solution.

    Thanks.
    Kiran.

  2. #2
    Super Contributor
    Join Date
    Aug 2005
    Location
    india
    Posts
    2,078

    Re: SMS-Remove from sent Folder. How?

    Hi kiran,


    Try this for deletion form sent folder

    void CEngine:eleteSentEntry(TMsvId aEntryId)
    {
    // Load this entry to our mtm
    SetMtmEntryL( aEntryId );

    TMsvEntry msvEntry( (iMtm->Entry()).Entry() );


    TBufC<20> itext(msvEntry.iDetails);




    if (msvEntry.Parent() == KMsvSentEntryId ) // check again that our entry is in sent
    {



    if (msvEntry.iMtmData3 == KUidCurrentApp.iUid) // this entry has been created by our app
    {
    // Taking a handle to the Sent folder...
    TMsvSelectionOrdering sort;
    sort.SetShowInvisibleEntries(ETrue); // we want to handle also the invisible entries

    // Take a handle to the parent entry
    CMsvEntry* parentEntry = CMsvEntry::NewL(iMtm->Session(), msvEntry.Parent(), sort);
    CleanupStack::PushL(parentEntry);

    // here parentEntry is the Sent folder (must be so that we can call DeleteL)
    parentEntry->DeleteL(msvEntry.Id());

    CleanupStack::PopAndDestroy(parentEntry);

    // information to the user
    // iEikonEnv->InfoMsg(_L("Message deleted in SENT folder."));

    // return ETrue; // entry was deleted
    }
    }
    }


    Regards,

    Mateen Maldar
    "Whatever the mind can conceive and believe, the mind can achieve"

  3. #3
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,347

    Re: SMS-Remove from sent Folder. How?

    Hello dear,
    My SMSHandler.cpp:
    ----------------------
    ....
    ..
    ...
    -----------------------------------------------------------------------------
    // CSmsHandler::HandleSessionEventL()
    // Handles notifications of events from the Message Server.
    // -----------------------------------------------------------------------------
    //
    void CSmsHandler::HandleSessionEventL( TMsvSessionEvent aEvent,
    TAny* aArg1, TAny* aArg2, TAny* /*aArg3*/)
    {
    switch ( aEvent )
    {

    case EMsvEntriesMoved:
    {
    TMsvId aEntryId;
    SetEntryL( aEntryId );

    TMsvEntry msvEntry( (iSmsMtm->Entry()).Entry() );

    TBufC<20> itext(msvEntry.iDetails);

    if (msvEntry.Parent() == KMsvSentEntryId ) // check again that our entry is in sent
    {

    if (msvEntry.iMtmData3 == KUidMsgTypeSMS.iUid) // this entry has been created by our app
    {
    // Taking a handle to the Sent folder...
    TMsvSelectionOrdering sort;
    sort.SetShowInvisibleEntries(ETrue); // we want to handle also the invisible entries

    // Take a handle to the parent entry
    CMsvEntry* parentEntry = CMsvEntry::NewL(iSmsMtm->Session(), msvEntry.Parent(), sort);
    CleanupStack::PushL(parentEntry);

    // here parentEntry is the Sent folder (must be so that we can call DeleteL)
    parentEntry->DeleteL(msvEntry.Id());

    CleanupStack::PopAndDestroy(parentEntry);
    }
    }
    break;
    }


    // Session to server established
    case EMsvServerReady:
    {

    TMsvId serviceId( KUidMsgTypeSMS.iUid ); // SMS service id

    // Determine if the event was succesful.
    // ServiceProgress inserts TBuf8 value in progress.
    TBuf8<KBfrLength> progress;
    iSession->ServiceProgress( serviceId, progress );
    _LIT8( KCompare, "KErrNone" );

    if ( progress.Compare( KCompare ) )
    {
    /* HBufC* text = StringLoader::LoadLC( R_SMS_SERVER_SESSION );
    CAknInformationNote* informationNote =
    new ( ELeave ) CAknInformationNote;
    informationNote->ExecuteLD( *text );
    CleanupStack::PopAndDestroy( text );
    */
    // Check that MtmRegistry has not already been accessed.
    if ( !iMtmRegistry )
    {
    AccessMtmL();
    }
    SendMsg();
    }
    else
    {
    /* HBufC* text = StringLoader::LoadLC( R_SMS_SESSION_ERROR );
    CAknErrorNote* errorNote = new ( ELeave ) CAknErrorNote;
    errorNote->ExecuteLD( *text );
    CleanupStack::PopAndDestroy( text );*/

    }

    break;
    }

    // A new entry has been created on the message server.
    case EMsvEntriesCreated:
    {
    // Entry id is obtained from the session event arguments.
    TMsvId* entryId = STATIC_CAST( TMsvId*, aArg2 );

    // We are interested in messages that are created in Inbox.
    if ( *entryId != KMsvGlobalInBoxIndexEntryId )
    {
    break;
    }

    // We take the created entries into a selection
    CMsvEntrySelection* newEntries =
    STATIC_CAST( CMsvEntrySelection*, aArg1 );

    // Process each created entry.
    for ( TInt i( 0 ); i < newEntries->Count(); i++ )
    {
    // We are interested in SMS messages.
    if ( ( iSession->GetEntryL( newEntries->At( i ) ) )
    ->Entry().iMtm == KUidMsgTypeSMS )
    {
    // Add the entry to the selection of all received messages.
    iSelection->AppendL( newEntries->At( i ), 1 );

    // Set received messages visible.
    MessageReceivedL( newEntries->At( i ) );
    }
    }

    break;
    }
    case EMsvCloseSession:
    case EMsvServerTerminated:
    case EMsvGeneralError:
    case EMsvServerFailedToStart:
    {
    // iSmsAppUi->ServerDown( aEvent ); // close application
    break;
    }

    // All other events are ignored.
    default:
    break;
    }
    }

    // -----------------------------------------------------------------------------
    // CSmsHandler::AccessMtmL()
    // Access the MTM Registry and create a SMS specific Client MTM instance.
    // -----------------------------------------------------------------------------
    //
    void CSmsHandler::AccessMtmL()
    {
    // Create an MTM Registry object.
    iMtmRegistry = CClientMtmRegistry::NewL( *iSession );

    // Create an SMS Client MTM object.
    iSmsMtm = STATIC_CAST( CSmsClientMtm*, iMtmRegistry->NewMtmL( KUidMsgTypeSMS ) );
    }

    -----------------------------------------------------------------------------
    // CSmsHandler::CreateMsgL()
    // Create an SMS message.
    // -----------------------------------------------------------------------------
    //
    TBool CSmsHandler::CreateMsgL() // Group SMS can be sent by adding entries in iSmsMtm->AddAddresseeL(....)
    {
    // Current entry is the Draft folder.
    iSmsMtm->SwitchCurrentEntryL( KMsvDraftEntryId );
    //iSmsMtm->SwitchCurrentEntryL( KMsvGlobalOutBoxIndexEntryId );

    // Create a new SMS message entry as a child of the current context.
    iSmsMtm->CreateMessageL( KUidMsgTypeSMS.iUid );

    CMsvEntry& serverEntry = iSmsMtm->Entry();
    TMsvEntry entry( serverEntry.Entry() );

    CRichText& body = iSmsMtm->Body(); // the body of the message
    body.Reset();
    // Insert the message text gotten as input from user.
    body.InsertL( 0, iMessageText );

    // Message will be sent immediately.
    entry.SetSendingState( KMsvSendStateWaiting ); //Commented by Kiran
    // entry.SetSendingState( KMsvSendStateSending );
    entry.iDate.HomeTime(); // insert current time

    // Set the SMS message settings for the message.
    CSmsHeader& header = iSmsMtm->SmsHeader();
    CSmsSettings* settings = CSmsSettings::NewL();
    CleanupStack::PushL( settings );

    settings->CopyL( iSmsMtm->ServiceSettings() ); // restore settings
    settings->SetDelivery( ESmsDeliveryImmediately ); // to be delivered immediately
    header.SetSmsSettingsL( *settings ); // new settings

    // Let's check if there is a service center address.
    if ( header.Message().ServiceCenterAddress().Length() == 0 )
    {
    // No, there isn't. We assume there is at least one service center
    // number set and use the default service center number.
    CSmsSettings* serviceSettings = &( iSmsMtm->ServiceSettings() );

    // Check if number of service center addresses in the list is null.
    if ( !serviceSettings->NumSCAddresses() )
    {
    // Remember to pop settings even if this branch is taken.
    CleanupStack::PopAndDestroy( settings );
    return EFalse; // quit creating the message
    }

    else
    {
    // Set service center address to default.
    // The caller does not take ownership of the returned object.
    CSmsNumber* smsCenter =
    &( serviceSettings->SCAddress( serviceSettings->DefaultSC() ) );
    header.Message().SetServiceCenterAddressL( smsCenter->Address() );
    }
    }

    CleanupStack::PopAndDestroy( settings );

    // Recipient number is displayed also as the recipient alias.
    entry.iDetails.Set( iRecipientNumber );
    // Add addressee.
    iSmsMtm->AddAddresseeL( iRecipientNumber, entry.iDetails );

    // Validate message.
    if ( !ValidateL() )
    {
    return EFalse;
    }

    entry.SetVisible( ETrue ); // set message as visible
    entry.SetInPreparation( EFalse ); // set together with the visibility flag
    serverEntry.ChangeL( entry ); // commit changes
    iSmsMtm->SaveMessageL(); // save message

    TMsvSelectionOrdering selection;
    CMsvEntry* parentEntry =
    CMsvEntry::NewL( iSmsMtm->Session(), KMsvDraftEntryId, selection );
    CleanupStack::PushL( parentEntry );

    // Move message to Outbox.
    iOperation =
    parentEntry->MoveL( entry.Id(), KMsvGlobalOutBoxIndexEntryId, iStatus );

    CleanupStack::PopAndDestroy( parentEntry );

    iState = EWaitingForMoving;
    SetActive();
    return ETrue;
    }

    -----------------------------------------------------------------------------
    // CSmsHandler::ScheduleL()
    // Schedule an SMS message for sending.
    // -----------------------------------------------------------------------------
    //
    void CSmsHandler::ScheduleL()
    {
    CMsvEntrySelection* selection = new ( ELeave ) CMsvEntrySelection;
    CleanupStack::PushL( selection );
    selection->AppendL( iSmsMtm->Entry().EntryId() ); // add message to selection

    // Add entry to task scheduler.
    TBuf8<1> dummyParams; // dummy parameters needed for InvokeAsyncFunctionL
    iOperation = iSmsMtm->InvokeAsyncFunctionL( ESmsMtmCommandScheduleCopy,
    *selection, dummyParams, iStatus );

    CleanupStack::PopAndDestroy( selection );

    iState = EWaitingForScheduling;
    SetActive();
    }
    -------------------------------------------------------------

    I have used SMSHandler example from SDK.
    Where my SendMsg() calls SendL() of SMSHandler.cpp.

    Here i get error error C2065: 'SetEntryL' : undeclared identifier
    i included corresponding msvapi.h. but it still gives me same error.
    Please Guide me.
    Thanks.

  4. #4
    Super Contributor
    Join Date
    Aug 2005
    Location
    india
    Posts
    2,078

    Re: SMS-Remove from sent Folder. How?

    hi,

    void CEngine::SetMtmEntryL(TMsvId aEntryId)
    {
    // Get the server entry from our session
    CMsvEntry* entry = iSession->GetEntryL(aEntryId);
    CleanupStack::PushL(entry);

    // Check if our mtm is different from the mtm set to our entry
    if ((iMtm == NULL) || (entry->Entry().iMtm != (iMtm->Entry()).Entry().iMtm))
    {
    // If so, we delete the old...
    delete iMtm;
    iMtm = NULL;

    // ...and get a new one from the MtmRegistry
    iMtm = iMtmReg->NewMtmL(entry->Entry().iMtm);
    }
    Regards,
    Mateen Maldar
    "Whatever the mind can conceive and believe, the mind can achieve"

  5. #5
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,347

    Re: SMS-Remove from sent Folder. How?

    Hello dear,
    thanks for yr concern.

    Now i can delete SMS from sent Item. But have some problems.
    I have used the following code:

    case EMsvEntriesMoved:
    {

    // Entry id is obtained from the session event arguments.
    TMsvId* entryId = STATIC_CAST( TMsvId*, aArg2 );

    // We are interested in messages that are created in Inbox.
    if ( *entryId == KMsvSentEntryId )
    {
    TMsvSelectionOrdering sort;
    sort.SetShowInvisibleEntries(ETrue); // we want to handle also the invisible entries

    CMsvEntry* parentEntry = CMsvEntry::NewL(*iSession, KMsvSentEntryId, sort);

    CleanupStack::PushL(parentEntry);

    CMsvEntrySelection* entries = parentEntry->ChildrenL();

    CleanupStack::PushL(entries);

    parentEntry->DeleteL(entries->At(0));

    CleanupStack::PopAndDestroy( parentEntry );
    CleanupStack::PopAndDestroy( entries );
    User::Exit(0);
    }
    break;
    }

    -------------------------------------------------------------

    Now Problem is that:
    -When there is SMS alredy stored in Sent Item, it removes that SMS rather deleting my latest sent SMS.
    -it removes my latest SMS when Sent Item Folder is empty.

    How could i delete my latest sent SMS when Sent Item Folder already contains other messages?


    Thanks.
    Kiran.

  6. #6
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,347

    Re: SMS-Remove from sent Folder. How?

    Hello,
    i can delete SMS from sent Item. But have some problems.
    I have used the following code:

    case EMsvEntriesMoved:
    {

    // Entry id is obtained from the session event arguments.
    TMsvId* entryId = STATIC_CAST( TMsvId*, aArg2 );

    // We are interested in messages that are created in Inbox.
    if ( *entryId == KMsvSentEntryId )
    {
    TMsvSelectionOrdering sort;
    sort.SetShowInvisibleEntries(ETrue); // we want to handle also the invisible entries

    CMsvEntry* parentEntry = CMsvEntry::NewL(*iSession, KMsvSentEntryId, sort);

    CleanupStack::PushL(parentEntry);

    CMsvEntrySelection* entries = parentEntry->ChildrenL();

    CleanupStack::PushL(entries);

    parentEntry->DeleteL(entries->At(0));

    CleanupStack::PopAndDestroy( parentEntry );
    CleanupStack::PopAndDestroy( entries );
    User::Exit(0);
    }
    break;
    }

    -------------------------------------------------------------

    Now Problem is that:
    -When there is SMS alredy stored in Sent Item, it removes that SMS rather deleting my latest sent SMS.
    -it removes my latest SMS when Sent Item Folder is empty.

    How could i delete my latest sent SMS when Sent Item Folder already contains other messages?

    Thanks.
    Kiran.

  7. #7
    Super Contributor
    Join Date
    Aug 2005
    Location
    india
    Posts
    2,078

    Re: SMS-Remove from sent Folder. How?

    hi,

    Try this in ur HandleSeesionEventL


    case EMsvEntriesMoved:{

    TMsvId* entryId = static_cast<TMsvId*>(aArg2); // entry id from the session event

    if (*entryId == KMsvSentEntryId) // new entry has been created in Inbox folder
    {
    // We take the created entries into a selection
    CMsvEntrySelection* entries = static_cast<CMsvEntrySelection*>(aArg1);
    for(TInt i = 0; i < entries->Count(); i++)
    {
    // if( parentEntry->ChildDataL(entries->At(i)).iMtmData3 == KUidGDSMS.iUid ) // check that message is for GDSMS
    // {

    DeleteSentEntry(entries->At(i) ); // this checks the entry and handles it if it is targeted to SMS app
    // delete the current entry (message)
    // parentEntry->DeleteL(entries->At(i));
    // }

    Regards,
    Mateen Maldar
    "Whatever the mind can conceive and believe, the mind can achieve"

  8. #8
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,347

    Smile Re: SMS-Remove from sent Folder. How?

    Hello Mateen,
    Thank u very much.
    U solved my problem.

    Thanks again.
    May God fulfill all yr wishes.

    Kiran.

  9. #9
    Super Contributor
    Join Date
    Aug 2005
    Location
    india
    Posts
    2,078

    Re: SMS-Remove from sent Folder. How?

    hi,

    thanks for ur compliment.

    That's enough for me to continue my work for the forum.

    regards,
    Mateen Maldar
    "Whatever the mind can conceive and believe, the mind can achieve"

  10. #10
    Registered User
    Join Date
    Feb 2006
    Posts
    17

    Re: SMS-Remove from sent Folder. How?

    Hi,

    I want to delete message from sent item, if the recipient number is in my list. How do I get the recipient number?
    I'm using msvEntry.iDetails. But this will name of the contact.

    Regards,
    Vidya

  11. #11
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,347

    Smile Re: SMS-Remove from sent Folder. How?

    Hello Vidya,
    Quote Originally Posted by vidyamg
    Hi,

    I want to delete message from sent item, if the recipient number is in my list. How do I get the recipient number?
    I'm using msvEntry.iDetails. But this will name of the contact.

    Regards,
    Vidya
    Following will give you a number instead of name.
    CSmsHeader& header = iSmsMtm->SmsHeader();

    TPtrC from = header.FromAddress();
    const TDesC& phoneNumber = from;
    Regards.
    Kiran.

  12. #12
    Registered User
    Join Date
    Feb 2006
    Posts
    17

    Re: SMS-Remove from sent Folder. How?

    Hi Kiran,

    I tried this,

    CSmsHeader& header = iSmsMtm->SmsHeader();
    TPtrC from = header.FromAddress();

    but from is blank(Its not giving any number ). What may have gone wrong?

  13. #13
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,347

    Smile Re: SMS-Remove from sent Folder. How?

    Hi Vidya,

    //Added by Kiran
    iSmsMtm->SwitchCurrentEntryL(aEntryId);
    iSmsMtm->LoadMessageL();
    CSmsHeader& header = iSmsMtm->SmsHeader();

    TPtrC from = header.FromAddress();
    const TDesC& phoneNumber = from;
    I hope it won't be empty this time.
    Regards.
    Kiran.

  14. #14
    Registered User
    Join Date
    Feb 2006
    Posts
    17

    Re: SMS-Remove from sent Folder. How?

    Hi,

    The solution is working fine for SMS. Can you tell me how to get the recipient number if it is MMS?
    I'm using s60 3rd edition device.

    Regards,
    Vidya
    Last edited by vidyamg; 2007-01-04 at 08:38.

  15. #15
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,347

    Smile Re: SMS-Remove from sent Folder. How?

    Hello Vidya,

    Refer to the following example for MMS:
    S60_Platform_MMS_Example

    Regards.
    Kiran.

Similar Threads

  1. Read SMS/ SMS Alert.
    By nirenj in forum General Messaging
    Replies: 3
    Last Post: 2009-01-14, 12:39
  2. Replies: 2
    Last Post: 2007-11-10, 13:19
  3. sms folder problem
    By psi1983 in forum Symbian
    Replies: 3
    Last Post: 2006-07-13, 08:49
  4. Create new sms folder
    By liafail in forum Symbian
    Replies: 2
    Last Post: 2005-10-22, 14:17
  5. remove SMS messages from SIM-card
    By maniacdream in forum Nokia M2M
    Replies: 5
    Last Post: 2005-07-15, 15:06

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×