×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Regular Contributor
    Join Date
    Aug 2008
    Posts
    128

    Send sms(Symbian s60 2nd Edition FP3)

    Hi All,
    I can send sms with Symbian S60 3rd Edition, but i am unable to send sms with Symbian S60 2nd Edition.
    CODE:
    Csend::Csend()
    : CActive( CActive::EPriorityStandard )
    {
    CActiveScheduler::Add( this );
    iNextUnread = 0;
    }

    void Csend::ConstructL()
    {
    iSession = CMsvSession::OpenAsyncL( *this );
    iSelection = new ( ELeave ) CMsvEntrySelection();
    }

    Csend* Csend::NewL( )
    {
    //As we do
    }

    Csend* Csend::NewLC()
    {
    //As we do
    }

    Csend::~Csend()
    {
    Cancel();
    delete iOperation;
    delete iMtmUiRegistry;
    delete iSelection;
    delete iSmsMtm;
    delete iMtmRegistry;
    delete iSession;
    }

    void Csend:: DoCancel()
    {
    if ( iOperation )
    {
    iOperation->Cancel();
    }
    }

    void Csend::RunL()
    {
    User::LeaveIfError( iStatus != KErrNone );
    TBufC8<KMsvProgressBufferLength> progress( iOperation->ProgressL() );
    _LIT8( KCompare, "KErrNone" );
    User::LeaveIfError( !progress.Compare( KCompare ) );

    delete iOperation;
    iOperation = NULL;

    switch ( iState )
    {
    case EWaitingForMoving:
    ScheduleL();
    break;

    case EWaitingForScheduling:
    {
    TMsvEntry entry( iSmsMtm->Entry().Entry() );
    TInt state( entry.SendingState() );
    if ( state == KMsvSendStateWaiting || state == KMsvSendStateScheduled)
    {
    }
    break;
    }
    default:
    break;
    }
    }

    void Csend::HandleSessionEventL( TMsvSessionEvent aEvent,
    TAny* aArg1, TAny* aArg2, TAny* /*aArg3*/)
    {
    switch ( aEvent )
    {
    case EMsvServerReady:
    {
    TMsvId serviceId( KUidMsgTypeSMS.iUid );
    TBuf8<KBfrLength1> progress;
    iSession->ServiceProgress( serviceId, progress );
    _LIT8( KCompare, "KErrNone" );

    if ( progress.Compare( KCompare ) )
    {
    if ( !iMtmRegistry )
    {
    AccessMtmL();
    }
    }
    break;
    }
    case EMsvEntriesCreated:
    {
    TMsvId* entryId = STATIC_CAST( TMsvId*, aArg2 );
    if ( *entryId != KMsvGlobalInBoxIndexEntryId )
    {
    break;
    }
    CMsvEntrySelection* newEntries =
    STATIC_CAST( CMsvEntrySelection*, aArg1 );
    for ( TInt i( 0 ); i < newEntries->Count(); i++ )
    {
    if ( ( iSession->GetEntryL( newEntries->At( i ) ) )
    ->Entry().iMtm == KUidMsgTypeSMS )
    {
    iSelection->AppendL( newEntries->At( i ), 1 );
    MessageReceivedL( newEntries->At( i ) );
    }
    }

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

    void Csend::AccessMtmL()
    {
    iMtmRegistry = CClientMtmRegistry::NewL( *iSession );
    iSmsMtm = STATIC_CAST( CSmsClientMtm*, iMtmRegistry->NewMtmL( KUidMsgTypeSMS ) );
    }

    TBool Csend::SendL( const TDesC& aRecipientNumber,
    const TDesC& aMessageText )
    {
    iRecipientNumber = aRecipientNumber;
    iMessageText = aMessageText;

    if ( CreateMsgL() )
    {
    return ETrue;
    }

    return EFalse;
    }

    TBool Csend::CreateMsgL()
    {
    iSmsMtm->SwitchCurrentEntryL( KMsvDraftEntryId );
    iSmsMtm->CreateMessageL( KUidMsgTypeSMS.iUid );
    CMsvEntry& serverEntry = iSmsMtm->Entry();
    TMsvEntry entry( serverEntry.Entry() );

    CRichText& body = iSmsMtm->Body();
    body.Reset();
    body.InsertL( 0, iMessageText );
    entry.SetSendingState( KMsvSendStateWaiting );

    //Added for 3rd edition
    // entry.iDate.HomeTime();
    entry.iDate.UniversalTime();
    CSmsHeader& header = iSmsMtm->SmsHeader();
    CSmsSettings* settings = CSmsSettings::NewL();
    CleanupStack::PushL( settings );

    settings->CopyL( iSmsMtm->ServiceSettings() );
    settings->SetDelivery( ESmsDeliveryImmediately );
    settings->SetDeliveryReport(ETrue);
    header.SetSmsSettingsL( *settings );
    if ( header.Message().ServiceCenterAddress().Length() == 0 )
    {
    CSmsSettings* serviceSettings = &( iSmsMtm->ServiceSettings() );

    //Changed for 3rd Edition specially
    // if ( !serviceSettings->NumSCAddresses() )
    if ( !serviceSettings->ServiceCenterCount() )
    {
    return EFalse; // quit creating the message
    }

    else
    {
    //Changed for 3rd Edition specially
    // CSmsNumber* smsCenter = &( serviceSettings->SCAddress( serviceSettings->DefaultSC() ) );
    CSmsNumber* smsCenter= CSmsNumber::NewL();
    CleanupStack::PushL(smsCenter);
    smsCenter->SetAddressL((serviceSettings->GetServiceCenter( serviceSettings->DefaultServiceCenter())).Address());
    header.Message().SetServiceCenterAddressL( smsCenter->Address() );
    CleanupStack::PopAndDestroy(smsCenter);
    }
    }

    CleanupStack::PopAndDestroy( settings );
    entry.iDetails.Set( iRecipientNumber );
    // Add addressee.
    iSmsMtm->AddAddresseeL( iRecipientNumber, entry.iDetails );
    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 );

    iOperation =parentEntry->MoveL( entry.Id(), KMsvGlobalOutBoxIndexEntryId, iStatus );

    CleanupStack::PopAndDestroy( parentEntry );

    iState = EWaitingForMoving;
    SetActive();

    return ETrue;
    }

    TBool Csend::ValidateL()
    {
    TMsvPartList result( KMsvMessagePartNone );
    result = iSmsMtm->ValidateMessage( KMsvMessagePartBody );
    if ( result != KMsvMessagePartNone )
    {
    return EFalse;
    }
    result = iSmsMtm->ValidateMessage( KMsvMessagePartRecipient );
    if ( result != KMsvMessagePartNone )
    {
    return EFalse;
    }
    return ETrue;
    }
    void Csend::ScheduleL()
    {
    CMsvEntrySelection* selection = new ( ELeave ) CMsvEntrySelection;
    CleanupStack::PushL( selection );
    selection->AppendL( iSmsMtm->Entry().EntryId() );
    TBuf8<1> dummyParams;
    iOperation = iSmsMtm->InvokeAsyncFunctionL( ESmsMtmCommandScheduleCopy,
    *selection, dummyParams, iStatus );
    CleanupStack::PopAndDestroy( selection );
    iState = EWaitingForScheduling;
    SetActive();
    }

    void Csend::MessageReceivedL( TMsvId aEntryId )
    {
    CMsvEntry* serverEntry = iSession->GetEntryL( aEntryId );
    CleanupStack::PushL( serverEntry );
    TMsvEntry entry = serverEntry->Entry();

    entry.SetNew( ETrue );
    entry.SetUnread( ETrue );
    entry.SetVisible( ETrue );

    serverEntry->ChangeL( entry );
    //iSmsAppUi->MessageReceived();
    CleanupStack::PopAndDestroy( serverEntry );
    }

    void Csend::ViewL()
    {
    iMtmUiRegistry = CMtmUiRegistry::NewL( *iSession );
    TMsvId entryId( iSelection->At( iNextUnread ) );
    CMsvEntry* serverEntry = iSession->GetEntryL( entryId );
    CleanupStack::PushL( serverEntry );
    CBaseMtm* clientMtm = iMtmRegistry->NewMtmL( serverEntry->Entry().iMtm );
    CleanupStack::PushL( clientMtm );
    clientMtm->SwitchCurrentEntryL( serverEntry->EntryId() );
    iNextUnread++;
    if ( iNextUnread < iSelection->Count() )
    {
    // iSmsAppUi->MessageReceived();
    }
    else
    {
    // iSmsAppUi->NoMoreUnread();
    }

    TMsvEntry entry( serverEntry->Entry() );
    entry.SetNew( EFalse );
    entry.SetUnread( EFalse );
    serverEntry->ChangeL( entry );
    CBaseMtmUi* ui = iMtmUiRegistry->NewMtmUiL( *clientMtm );
    CleanupStack::PushL( ui );
    iOperation = ui->ViewL( iStatus );

    CleanupStack::PopAndDestroy( 3 ); // ui, clientMtm, serverEntry
    SetActive();
    }
    **************************************************************
    After the line
    iSmsMtm->CreateMessageL(KUidMsgTypeSMS.iUid);//in function CreateMsgL
    the application got crashed.

    Can anyone help me to find out where i am doing wrong. Stucked here for a long time. Please help me its urgent.

    With regards,
    Diptendu
    Last edited by diptendulkar; 2008-09-12 at 15:08.
    Thanks & Regards
    Dip
    diptenduster@gmail.com

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,752

    Re: Send sms(Symbian s60 2nd Edition FP3)

    You should enable the panic codes (http://wiki.forum.nokia.com/index.ph...ded_panic_code).
    Your code appears to be very similar to S[eries]60Ex\smssend of S60 2nd edition SDK-s, have you modified anything in it?
    Where are you testing this code? Emulator or device?

  3. #3
    Regular Contributor
    Join Date
    Aug 2008
    Posts
    128

    Re: Send sms(Symbian s60 2nd Edition FP3)

    Hi wizard,

    I tried to view the panic code as it is told in the thread you gave, but not working. Anyway i tried the Example also given in the SDK, there it is giving "CdlEng 7" panic code.

    I am testing it in the emulator.

    with regards,
    Diptendu
    Thanks & Regards
    Dip
    diptenduster@gmail.com

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

    Re: Send sms(Symbian s60 2nd Edition FP3)

    Quote Originally Posted by diptendulkar View Post
    I tried to view the panic code as it is told in the thread you gave, but not working.

    I am testing it in the emulator.
    ...
    What does panic say in that case? And I could see some changes for SMS Center in your CreateMessageL() function which resembles to the article on Wiki. The article you are using from Wiki, illustrates about S60 3rd edition and it has some changes accordingly.

    You can straight away use SMSHandler stuff from SDK example. Also check this Wiki article if it helps: SMS Operations

    Finally if nothing works then you should try it on real device.
    Nokia Developer Wiki Moderation team

  5. #5
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,752

    Re: Send sms(Symbian s60 2nd Edition FP3)

    Quote Originally Posted by diptendulkar View Post
    I am testing it in the emulator.
    Some emulators support SMS, but not all of them. Prior to experimenting, you should test if you can send an SMS with the built-in Messages application. If it also dies, most probably you will not succeed in testing your own code, however there are good chances that it would work on the target device.

  6. #6
    Regular Contributor
    Join Date
    Aug 2008
    Posts
    128

    Re: Send sms(Symbian s60 2nd Edition FP3)

    Hi,
    The example is working good. What i have done i just use the SMShandler.cpp and SMShandler.h file in my application to send sms. I just modified these

    Csend::Csend(/* CSmsAppUi* aSmsAppUi */)
    : CActive( CActive::EPriorityStandard )
    {
    CActiveScheduler::Add( this );
    //iSmsAppUi = aSmsAppUi; // (pointer to AppUi) blocked the line
    iNextUnread = 0; // index of next unread message in iSelection
    }

    Csend* Csend::NewL( /*CSmsAppUi* aSmsAppUi*/ )
    {
    Csend* self = NewLC( /*aSmsAppUi*/ );
    CleanupStack::Pop( self );
    return self;
    }

    Simply blocked all the line where the file is using CSmsAppUi. i don't want to show any message.

    After the line
    iSmsMtm->CreateMessageL(KUidMsgTypeSMS.iUid);//in function CreateMsgL
    the application got crashed.

    So where i am doing wrong now. please help me to find it out.

    With regards,
    Diptendu
    Last edited by diptendulkar; 2008-09-13 at 09:19.
    Thanks & Regards
    Dip
    diptenduster@gmail.com

  7. #7
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,752

    Re: Send sms(Symbian s60 2nd Edition FP3)

    In fact I have never used CBaseMtm::CreateMessageL in particular, but it seems to be rather harmless.
    However according to your description, you have moved the code into a GUI-less code. An important thing you should note is that the "Async" in OpenAsyncL stands for [B]asynchronous, the actual CMsvSession should not be used until HandleSessionEventL gets invoked (and that is the palce where your MTM gets apparently initialized).
    So if you write something like iSomething=CSend::NewL();iSomething->CreateMsgL();, that will not work.
    If this is the situation, you can try what happens if you
    - modify OpenAsyncL to OpenSyncL
    - and move the EMsvServerReady-block after this line (and comment/remove it from HandleSessionEventL)

  8. #8
    Regular Contributor
    Join Date
    Aug 2008
    Posts
    128

    Re: Send sms(Symbian s60 2nd Edition FP3)

    Thanks wizard,

    Its working now. And thanks for your valuable information.
    Thanks & Regards
    Dip
    diptenduster@gmail.com

Similar Threads

  1. Replies: 3
    Last Post: 2008-08-29, 10:21
  2. S60 2nd (FP3) Emulator and InfoMsg
    By jmak in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2007-03-22, 05:35
  3. What is going on with Vibration on S60?
    By amd_rikus in forum Mobile Java General
    Replies: 3
    Last Post: 2006-06-16, 00:29

Posting Permissions

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