×

Discussion Board

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

    Unhappy Is it ActiveScheduler Problem???

    Hello friends,
    It took my more than 3 days.

    I want to send an sms as soon as i click on Icon of my application on phone menu without going within application.
    The strange thing is that it works perfectly on application where i used to send sms through menu command within my application.

    I have included SMSHandler Class in my application.

    When i open an application it generates following error:
    App Closed KERN-EXEC 3

    My code look like following:

    CMyContainer
    -------------------
    void CMyContainer::ConstructL(const TRect& aRect)
    {
    CreateWindowL();

    iLabel = new (ELeave) CEikLabel;
    iLabel->SetContainerWindowL( *this );
    iLabel->SetTextL( _L("Hello") );

    iToDoLabel = new (ELeave) CEikEdwin;
    iToDoLabel->SetContainerWindowL( *this );
    iToDoLabel->ConstructL(EAknEditorFlagDefault,10,256,1) ;
    iToDoLabel->SetReadOnly(ETrue);

    SetRect(aRect);
    ActivateL();

    iSmsHandler = CSmsHandler::NewL();
    SendMsg();
    }

    void CMyContainer ::SendMsg()
    { CAknInformationNote* info= new (ELeave) CAknInformationNote;
    TBuf<128> SMSText,PhoneNumber;
    SMSText.Copy(_L("Hello Buddy"));
    PhoneNumber.Copy(_L("9857845745"));
    iSmsHandler->SendL( PhoneNumber, SMSText) ;
    info->ExecuteLD(_L("SMS sent"));
    }

    ...etc

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



    SMSHandler.cpp

    -------------------------
    CSmsHandler::CSmsHandler()
    : CActive( CActive::EPriorityStandard )
    {
    CActiveScheduler::Add( this );
    }

    // -----------------------------------------------------------------------------
    // 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;
    }

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

    if ( CreateMsgL() )
    {
    return ETrue;
    }

    return EFalse;
    }

    ...etc
    --------------------------------------------------------

    Error occurs when it reaches at:
    iSmsHandler->SendL( PhoneNumber, SMSText) ;

    I think it's an ActiveScheduler problem.
    Is it so? Then how to solve it?

    Please give me a solution.
    I am totally stuck.
    No way out.

    Thnaking u in advance.

    Kiran.

  2. #2
    Super Contributor
    Join Date
    Nov 2004
    Location
    Wiltshire, UK
    Posts
    3,644

    Re: Is it ActiveScheduler Problem???

    Looks like the messaging server session has not completed initializing yet, you can only call messaging functions once the OpenAsyncL call has reported it has successfully completed.

    You need to wait until MMsvSessionObserver::HandleSessionEvent has reported it has completed initializing (EMsvServerReady)
    Last edited by Paul.Todd; 2006-05-18 at 17:02.

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

    Re: Is it ActiveScheduler Problem???

    Hi,
    I tried as u suggested but it doesn't work.
    I return true on succesfully completion and it returns true.
    It still gives me KERN-EXEC 3 error.
    I don't understand what's the problem.
    Please suggest me the soltuion.
    Thanks.

  4. #4
    Super Contributor
    Join Date
    Nov 2004
    Location
    Wiltshire, UK
    Posts
    3,644

    Re: Is it ActiveScheduler Problem???

    Can you post the code for your implementation of the MMsvSessionObserver::HandleSessionEvent?

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

    Re: Is it ActiveScheduler Problem???

    Hello dear,
    Actually i have reused SmsHandler class.
    I just included smshandler.h n smshandler.cpp in my own application.


    SmsHandler.cpp
    ----------------

    ......
    ....
    ..
    // ============================ MEMBER FUNCTIONS ===============================
    // -----------------------------------------------------------------------------
    // CSmsHandler::CSmsHandler()
    // C++ default constructor can NOT contain any code, that might leave.
    // -----------------------------------------------------------------------------
    //
    CSmsHandler::CSmsHandler()
    : CActive( CActive::EPriorityStandard )
    {
    CActiveScheduler::Add( this );
    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 );
    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;
    }
    ...........
    ......
    ..
    .
    void CSmsHandler::HandleSessionEventL( TMsvSessionEvent aEvent,
    TAny* aArg1, TAny* aArg2, TAny* /*aArg3*/)
    {
    switch ( aEvent )
    {
    // 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 ) )
    {
    // Check that MtmRegistry has not already been accessed.
    if ( !iMtmRegistry )
    {
    AccessMtmL();
    }
    }

    else
    {
    }

    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::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;
    }

    ............
    ......
    ....
    .etc

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

    MyContainer.cpp
    -----------------------
    void CMyContainer::ConstructL(const TRect& aRect)
    {
    CreateWindowL();

    iLabel = new (ELeave) CEikLabel;
    iLabel->SetContainerWindowL( *this );
    iLabel->SetTextL( _L("PHONE") );

    iToDoLabel = new (ELeave) CEikEdwin;
    iToDoLabel->SetContainerWindowL( *this );
    iToDoLabel->ConstructL(EAknEditorFlagDefault,10,256,1) ;
    iToDoLabel->SetReadOnly(ETrue);

    SetRect(aRect);
    ActivateL();

    iSmsHandler = CSmsHandler::NewL();
    SendMsg();
    }
    .....
    ..
    void CMyContainer ::SendMsg()
    {
    TBuf<160> SMSText;
    TBuf<15> PhoneNumber;
    SMSText.Copy(_L("Hello Buddy"));
    PhoneNumber.Copy(_L("9898850654"));

    iSmsHandler->SendL( PhoneNumber, SMSText) ;
    }
    -------------------------------------------------------------------
    The strange thing is that it works fine when i send message from menu command from AppUi's HandleCommand(..).
    But the problem is new version where i want to send message as soon as i click on the icon of my application without going within application.

    Please help me out.
    Thanks.

  6. #6
    Super Contributor
    Join Date
    Nov 2004
    Location
    Wiltshire, UK
    Posts
    3,644

    Re: Is it ActiveScheduler Problem???

    Okay, so if you read the documentation you will find that you can only use the iSession after the EMsvServerReady state has been reported via CSmsHandler::HandleSessionEventL otherwise the messaging server has not yet completly initialized and hence the crash.

    I suggest you move the SendMsg call to EMsvServerReady case in the HandleSessionEvent.

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

    Smile Re: Is it ActiveScheduler Problem???

    Hi Paul,
    thank u very much. U solved my problem.
    U really deserve to be honoured.
    U made a broad smile on my face.

    U won't believe but i m so much happy because i was suffering for last three days.

    I am thanking u from bottom of my heart.

    Best wishes for u,
    Kiran.

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

    Re: Is it ActiveScheduler Problem???

    Hello dear,
    I want the same application to be converted in EXE.
    Means i want to send an SMS from EXE.
    But it creates problem.
    It results into E32USER-CBase 44 error.
    I created EXE from Application wizard from SDK.
    It came up with predifined stuff as follwows:

    MyExe
    --------
    /*
    * ============================================================================
    * Name : ExeTest.cpp
    * Part of : ExeTest
    * Created : 03.05.2006 by Kiran
    * Description:
    * Exe source file
    * Version :
    * Copyright:
    * ============================================================================
    */


    // Include Files

    #include "ExeTest.h"
    #include <e32base.h>
    #include <e32std.h>
    #include <e32cons.h> // Console


    // Constants

    _LIT(KTextConsoleTitle, "Console");
    _LIT(KTextFailed, " failed, leave code = %d");
    _LIT(KTextPressAnyKey, " [press any key]\n");


    // Global Variables

    LOCAL_D CConsoleBase* console; // write all messages to this


    // Local Functions

    LOCAL_C void MainL(const TDesC& aArgs)
    {
    //
    // add your program code here, example code below
    //
    console->Write(_L("Hello, world!\n"));
    console->Printf(_L("Command line args: \"%S\"\n"), &aArgs);
    }


    LOCAL_C void DoStartL()
    {
    // Create active scheduler (to run active objects)
    CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
    CleanupStack::PushL(scheduler);
    CActiveScheduler::Install(scheduler);

    // Call main function with command line
    TBuf<256> cmdLine;
    RProcess().CommandLine(cmdLine);
    MainL(cmdLine);

    // Delete active scheduler
    CleanupStack::PopAndDestroy(scheduler);
    }


    // Global Functions

    GLDEF_C TInt E32Main()
    {
    // Create cleanup stack
    __UHEAP_MARK;
    CTrapCleanup* cleanup = CTrapCleanup::New();

    // Create output console
    TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize(KConsFullScreen,KConsFullScreen)));
    if (createError)
    return createError;

    // Run application code inside TRAP harness, wait keypress when terminated
    TRAPD(mainError, DoStartL());
    if (mainError)
    console->Printf(KTextFailed, mainError);
    console->Printf(KTextPressAnyKey);
    console->Getch();

    delete console;
    delete cleanup;
    __UHEAP_MARKEND;
    return KErrNone;
    }


    // End of file
    ---------------------------------------------------------------

    So when i put
    iSmsHandler = CSmsHandler::NewL();
    it results into E32User-CBase 44 error

    I tried to put it at different place but it gave me different E32User-CBase errors.

    So please suggest me thes solution.

    Thanks.
    Kiran.

  9. #9
    Super Contributor
    Join Date
    Nov 2004
    Location
    Wiltshire, UK
    Posts
    3,644

    Re: Is it ActiveScheduler Problem???

    Which function and where did you put the CSmsHandler::NewL() ?

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

    Smile Re: Is it ActiveScheduler Problem???

    Hello Paul,

    I put it at:

    LOCAL_C void DoStartL()
    {

    // Create active scheduler (to run active objects)
    CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
    CleanupStack::PushL(scheduler);
    CActiveScheduler::Install(scheduler);

    CSmsHandler *iHandler=CSmsHandler::NewL();

    TBuf<256> cmdLine;
    RProcess().CommandLine(cmdLine);
    MainL(cmdLine);

    CleanupStack::PopAndDestroy(scheduler);
    }
    -------------------------------------------------------------------------
    Actually when i created Exe from application wizard it gave me Follwing code by default:

    MeExe:
    -----------------
    /*
    * ============================================================================
    * Name : ExeTest.cpp
    * Part of : ExeTest
    * Created : 03.05.2006 by Kiran
    * Description:
    * Exe source file
    * Version :
    * Copyright:
    * ============================================================================
    */


    // Include Files

    #include "ExeTest.h"
    #include <e32base.h>
    #include <e32std.h>
    #include <e32cons.h> // Console


    // Constants

    _LIT(KTextConsoleTitle, "Console");
    _LIT(KTextFailed, " failed, leave code = %d");
    _LIT(KTextPressAnyKey, " [press any key]\n");


    // Global Variables

    LOCAL_D CConsoleBase* console; // write all messages to this


    // Local Functions

    LOCAL_C void MainL(const TDesC& aArgs)
    {
    //
    // add your program code here, example code below
    //
    console->Write(_L("Hello, world!\n"));
    console->Printf(_L("Command line args: \"%S\"\n"), &aArgs);
    }


    LOCAL_C void DoStartL()
    {
    // Create active scheduler (to run active objects)
    CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
    CleanupStack::PushL(scheduler);
    CActiveScheduler::Install(scheduler);

    // Call main function with command line
    TBuf<256> cmdLine;
    RProcess().CommandLine(cmdLine);
    MainL(cmdLine);

    // Delete active scheduler
    CleanupStack::PopAndDestroy(scheduler);
    }


    // Global Functions

    GLDEF_C TInt E32Main()
    {
    // Create cleanup stack
    __UHEAP_MARK;
    CTrapCleanup* cleanup = CTrapCleanup::New();

    // Create output console
    TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize(KConsFullScreen,KConsFullScreen)));
    if (createError)
    return createError;

    // Run application code inside TRAP harness, wait keypress when terminated
    TRAPD(mainError, DoStartL());
    if (mainError)
    console->Printf(KTextFailed, mainError);
    console->Printf(KTextPressAnyKey);
    console->Getch();

    delete console;
    delete cleanup;
    __UHEAP_MARKEND;
    return KErrNone;
    }


    // End of file

    Thnaks Paul,
    I have been really waiting for yr reply n finally i got it.
    Thanks.

    Kiran.

  11. #11
    Super Contributor
    Join Date
    Nov 2004
    Location
    Wiltshire, UK
    Posts
    3,644

    Re: Is it ActiveScheduler Problem???

    After CSmsHandler *iHandler=CSmsHandler::NewL(); you need to add:
    iHandler->SetActive(); //to tell the active scheduler that there is a request outstanding
    CActiveScheduler::Start(); // to start the scheduler

    This will then start the active scheduler, allow the messaging app to start and callback into the handler interface implemented by your handler.

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

    Unhappy Re: Is it ActiveScheduler Problem???

    Hello Dear,
    When i tried to put iSmsHandler->SetActive() in my Exe, as u said, it gave me Error: ....can't access protected...etc.

    Then i put it in SMSHandler.cpp as Follows:
    ------------------------------------------
    CSmsHandler::CSmsHandler()
    : CActive( CActive::EPriorityStandard )
    {
    CActiveScheduler::Add( this );
    SetActive();
    iNextUnread = 0; // index of next unread message in iSelection
    }
    -------------------------------------------------------------------------

    I created one Log File which keeps track of entries in each function.
    When i executed my Exe, my log file contained:

    In NewLC
    After SetActive
    In ConstrcutL After MSVEntry


    Means i opened file in each function in SMSHandler.cpp.

    Finally problem is that no message was sent.

    Please guide me.

    Thanks.
    Kiran.

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

    Re: Is it ActiveScheduler Problem???

    hi,

    Don't use SetActive in the ConstructL itself,

    Use the SetActive where u need that a AO to be active when sending the sms .

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

  14. #14
    Super Contributor
    Join Date
    Nov 2004
    Location
    Wiltshire, UK
    Posts
    3,644

    Re: Is it ActiveScheduler Problem???

    You must call CActiveScheduler::Start() - note that control will not return from this function unless you add a CActiveScheduler::Stop after sending your SMS

    At some point after calling CActiveScheduler::Start you will get a callback to CSmsHandler::HandleSessionEvent when the messaging server has finished initialing once the state has reached EMsvServerReady.

    You can then send your sms as the messeging server is now ready

  15. #15
    Regular Contributor
    Join Date
    Feb 2009
    Posts
    188

    Re: Is it ActiveScheduler Problem???

    Hi

    I want to receive sms command only from predefined number silently. I am trying to use SMSHandler. I am able to send SMS. But I couldn't receive sms. please help me

Similar Threads

  1. J2ME: Problem in Nokia Solution for a software problem
    By mte01 in forum Mobile Java Tools & SDKs
    Replies: 4
    Last Post: 2011-06-08, 05:52
  2. problem when stop playing video on 3650 and try to play again
    By niko86 in forum Mobile Java General
    Replies: 5
    Last Post: 2007-08-03, 07:40
  3. Problem with eglSwapBuffers and heap corruption
    By greatape in forum Symbian Media (Closed)
    Replies: 2
    Last Post: 2007-05-24, 03:35
  4. Replies: 1
    Last Post: 2005-10-10, 05:06
  5. J2ME: Problem in Nokia Solution for a media problem
    By mte01 in forum Mobile Java Tools & SDKs
    Replies: 0
    Last Post: 2005-08-12, 11:30

Posting Permissions

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