×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Oct 2007
    Location
    Noida
    Posts
    152

    Question SMS handler in S60 second edition

    hello All,

    It was a fine morning today until a strange thing happened to me. I was trying to send sms using my second edition s60 device (Nokia N70) . Used a class called SmsHandler that i found out from the WIKI. Yesterday night i did a sample test for wherether the SMS is going with the help of this class and it worked for me.
    I'll Elaborate...
    On the click of the button i am calling the Smshandler's SendL method.. which in turn calls the CreateMsgL()..

    Smshandler.cpp

    Code:
    // INCLUDE FILES
    #include <eikenv.h>
    #include <coemain.h>
    #include <e32std.h>
    #include <msvids.h>
    #include <msvstd.h>
    #include <smsclnt.h>
    #include <smut.h>
    #include <mtclreg.h>
    #include <txtrich.h>
    #include <smscmds.h>
    #include <mtmuibas.h>
    #include <mtmdef.h>
    #include <AknNoteWrappers.h>
    #include <stringloader.h>
    #include "SmsHandler.h"
    #include "smutset.h"
    #include "smuthdr.h"
    
    
    
    // ============================ MEMBER FUNCTIONS ===============================
    // -----------------------------------------------------------------------------
    // CSmsHandler::CSmsHandler()
    // C++ default constructor can NOT contain any code, that might leave.
    // -----------------------------------------------------------------------------
    //
    CSmsHandler::CSmsHandler()
    : CActive( CActive::EPriorityStandard )
        {
        CActiveScheduler::Add( this );
    //    iSmsAppUi = aSmsAppUi;      // pointer to AppUi
        iNextUnread = 0;            // index of next unread message in iSelection
        }
    
    // -----------------------------------------------------------------------------
    // CSmsHandler::ConstructL()
    // Symbian 2nd phase constructor can leave.
    // -----------------------------------------------------------------------------
    //
    void CSmsHandler::ConstructL()
        {
        // Session to message server is opened asynchronously.
        iSession = CMsvSession::OpenAsyncL( *this );
    
        // Entry selection for all received messages.
        iSelection = new ( ELeave ) CMsvEntrySelection();
        }
    
    // -----------------------------------------------------------------------------
    // CSmsHandler::NewL()
    // Two-phased constructor.
    // -----------------------------------------------------------------------------
    //
    CSmsHandler* CSmsHandler::NewL( )
        {
        CSmsHandler* self = NewLC( );
        CleanupStack::Pop( self );
        return self;
        }
    
    // -----------------------------------------------------------------------------
    // CSmsHandler::NewLC()
    // Two-phased constructor.
    // -----------------------------------------------------------------------------
    //
    CSmsHandler* CSmsHandler::NewLC()
        {
        CSmsHandler* self = new ( ELeave ) CSmsHandler();
        CleanupStack::PushL( self );
        self->ConstructL();
        return self;
        }
    -----------------------------------------------------------------------------
    // CSmsHandler::RunL()
    // Handles request completion events.
    // -----------------------------------------------------------------------------
    //
    void CSmsHandler::RunL()
        {
        User::LeaveIfError( iStatus != KErrNone );
    
        // Determine the current operations progress.
        // ProgressL returns an 8 bit descriptor.
        TBufC8<KMsvProgressBufferLength> progress( iOperation->ProgressL() );
        _LIT8( KCompare, "KErrNone" );
        User::LeaveIfError( !progress.Compare( KCompare ) );
    
        // The pointer to the current CMsvOperation object is no longer needed.
        delete iOperation;
        iOperation = NULL;
    
        // Determine which request has finished.
        switch ( iState )
            {
            case EWaitingForMoving:
                // Once a message is moved to Outbox it is scheduled for sending.
                ScheduleL();
                break;
    
            case EWaitingForScheduling:
                {
                TMsvEntry entry( iSmsMtm->Entry().Entry() );
                TInt state( entry.SendingState() );
    
                if ( state == KMsvSendStateWaiting || state == KMsvSendStateScheduled)
                    {
    /*              HBufC* text = StringLoader::LoadLC( R_SMS_MOVED_TO_OUTBOX );
                    CAknInformationNote* informationNote =
                        new ( ELeave ) CAknInformationNote;
                    informationNote->ExecuteLD( *text );
                    CleanupStack::PopAndDestroy( text );*/
                    }
    
                break;
                }
    
            default:
                break;
            }
        }
    
    // -----------------------------------------------------------------------------
    // CSmsHandler::HandleSessionEventL()
    // Handles notifications of events from the Message Server.
    // -----------------------------------------------------------------------------
    // ----------------------- code truncated ---------------------
    
    
    // -----------------------------------------------------------------------------
    // CSmsHandler::SendL()
    // Starts the process of creating and sending an SMS message.
    // -----------------------------------------------------------------------------
    //
    TBool CSmsHandler::SendL( const TDesC& aRecipientNumber,
                                const TDesC& aMessageText )
        {
        iRecipientNumber = aRecipientNumber;
        iMessageText = aMessageText;
    
        if ( CreateMsgL() )
            {
            return ETrue;
            }
    
        return EFalse;
        }
    
    // -----------------------------------------------------------------------------
    // CSmsHandler::CreateMsgL()
    // Create an SMS message.
    // -----------------------------------------------------------------------------
    //
    TBool CSmsHandler::CreateMsgL()
        {
        // 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 );
        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() )
                {
    /*            HBufC* text = StringLoader::LoadLC( R_SMS_SC_NBR_MISSING );
                CAknWarningNote* warningNote = new ( ELeave ) CAknWarningNote;
                warningNote->ExecuteLD( *text );
                CleanupStack::PopAndDestroy( text );
    */
                // 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() ) );
    ---------------------------- code truncated--------------
    Now the problem is that the when i call this function from a button click its workig fine.But if i place the same code in the ConstructL() of the AppUi in a GUI application or even the MainL() of the console application this application exits..

    The Erronomous line is

    iSmsMtm->SwitchCurrentEntryL( KMsvDraftEntryId ); the first line in the method

    in the

    TBool CSmsHandler::CreateMsgL() mehod..

    the application simple terminates..


    any help or pointers for what the trouble may be ..

    many thanks
    Abhishek karmakar

    never- Never - NEVER -- !!! NEVER !!! GIVE UP

  2. #2
    Registered User
    Join Date
    Jun 2006
    Location
    India
    Posts
    1,043

    Re: SMS handler in S60 second edition

    Hi,
    What is the error you are getting when your application is terminated?
    One thing to check is that whether iSmsMtm is getting instantiated before you are callin an API on it.
    Maximus
    S60 Developer
    Impossible is nothing

  3. #3
    Registered User
    Join Date
    Oct 2007
    Location
    Noida
    Posts
    152

    Re: SMS handler in S60 second edition

    Hello Yogpan,

    I am working in a console window using the second edition SDK .. and i am testing it on emulator. Can u please tell me how can i get the panic code. I tried using the information given here but its not working .. can u please tell me how will i get the panic code.

    many thanks.
    Abhishek karmakar

    never- Never - NEVER -- !!! NEVER !!! GIVE UP

  4. #4
    Registered User
    Join Date
    Jun 2006
    Location
    India
    Posts
    1,043

    Re: SMS handler in S60 second edition

    Just try to debug your application in emulator (by opening in debug mode)by putting breakpoint in the line you suspect is giving error and check the call stack to find out what is the error/panic you are getting
    Maximus
    S60 Developer
    Impossible is nothing

  5. #5
    Registered User
    Join Date
    Oct 2007
    Location
    Noida
    Posts
    152

    Question Re: SMS handler in S60 second edition

    hello Yogpan,

    I just sorted it out .. as i told you in first post where the error was coming from, i was able to sort it from the help of this THREAD .

    after this entire program was debugging with no problems i tried the same thing on the phone. Now there was another strange behavior.

    The message is sent to the Outbox and from there it does not goes anywhere. I thought that the number to which i was sending the message might have some service problem but that is not the case. I transferred the message from the Outbox to Draft and then sent the message from there again and it was going..

    So what do u think the problem might be this time..

    has it got to do something with the Activeobjects that i am using or something else..

    Thanks in Adv
    Abhishek karmakar

    never- Never - NEVER -- !!! NEVER !!! GIVE UP

  6. #6
    Registered User
    Join Date
    Jun 2006
    Location
    India
    Posts
    1,043

    Re: SMS handler in S60 second edition

    Hi,
    Again I would suggest you to look into your code as to where your message is going.Try with the logs if your code is just moving your code to Outbox and not actually sending it to the intended receiver.
    Maximus
    S60 Developer
    Impossible is nothing

  7. #7
    Registered User
    Join Date
    Dec 2005
    Posts
    1,236

    Re: SMS handler in S60 second edition

    Hi,

    Did you check the sms operations link in wiki compare it with your code to find the missing information or code sth like http://wiki.forum.nokia.com/index.ph..._Edition_-_MTM
    Regards,
    Sriky

  8. #8
    Registered User
    Join Date
    Oct 2007
    Location
    Noida
    Posts
    152

    Re: SMS handler in S60 second edition

    hi Sriky/Yogpan,

    yogpan
    Hi,
    Again I would suggest you to look into your code as to where your message is going.Try with the logs if your code is just moving your code to Outbox and not actually sending it to the intended receiver.
    Well the code that i have written so far is sending the message when its being called from a button click. Which means the message is being sent and the code is actually ment for sending sms.

    A found out a similar thread which was facing the same problem.http://discussion.forum.nokia.com/fo...d.php?t=144348 Wizard_hu gave a solution to it. I implemented the same solution which is sending the message to the outbox, but surprisingly it is not sending it out of the outbox.

    The message keeps waiting in outbox.

    some clue please.
    Abhishek karmakar

    never- Never - NEVER -- !!! NEVER !!! GIVE UP

  9. #9
    Registered User
    Join Date
    Oct 2007
    Location
    Noida
    Posts
    152

    Question Re: SMS handler in S60 second edition

    hi All,
    Well so far what i was trying is to get the data like cellId,Lacid from the cell phone and send them as message over and over. I am doing the same for S60 Second Edition. I have written the code in the ConstructL of the AppUi class. and put the entire code in a while(ETrue) loop. At the end of the loop i am using a User::After(60000000) i.e. wait for a minute and then sending another message..

    I am able to send the message for the first time if i remove the sleep and the (while(ETrue)), but as soon as i put the loop or the wait, It creates the message and tries to send it(i think so because i can see the message in the outbox as 'waiting')

    I am not able to figure this behaviour.

    i am doing the same thing in s60 3rd edition .. and it works fine.

    some help please..
    Abhishek karmakar

    never- Never - NEVER -- !!! NEVER !!! GIVE UP

Similar Threads

  1. Nokia Connectivity Framework not Compatible with SMS S60 3rd Edition?
    By richardca in forum Mobile Java Tools & SDKs
    Replies: 1
    Last Post: 2008-10-21, 07:43
  2. Send sms(Symbian s60 2nd Edition FP3)
    By diptendulkar in forum Symbian Networking & Messaging (Closed)
    Replies: 7
    Last Post: 2008-09-13, 11:06
  3. Remote access on S60 phones (3rd Edition)
    By zhiliang in forum Symbian
    Replies: 0
    Last Post: 2007-07-30, 04:05
  4. SMS Receiving in S60 3rd Edition
    By anatcoh in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2007-01-23, 10:25
  5. Sending SMS to a specific port on S60 3rd Edition
    By gaohai in forum General Messaging
    Replies: 0
    Last Post: 2006-09-21, 09:45

Posting Permissions

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