×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 25
  1. #1
    Registered User
    Join Date
    Aug 2007
    Posts
    165

    Sending SMS using MTM Via Simple Console Application

    Hi to all Developers

    There is any option to send SMS using MTM via Simple Console Application ?
    - I am tring to use with SmsHandler.cpp (by Kiran)
    - I succed to that with the GUI Application but i don't understand how/where to Initialize the
    iSmsHandler = CSmsHandler::NewL();
    Please help....

    Code:
    //  Include Files  
    #if defined(__WINS__) && !defined(EKA2) 
    EXPORT_C TInt WinsMain()     
    {     
    return E32Main();
         } 
    TInt E32Dll(TDllReason /*aReason*/)    
     {
         return KErrNone;     
    } 
    #endif
    
    #include "testexe.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()
    	{
    	
       TBuf<128> SMSText,PhoneNumber;
       SMSText.Copy(_L("Test Message"));
       PhoneNumber.Copy(_L("+12345678")); //Change the number as per your Choice -Kiran
       iSmsHandler->SendL( PhoneNumber, SMSText) ; ///---- The Problem ;(
       console->Write(_L("1.Hello, World!\n"));
     	}
    
    
    LOCAL_C void DoStartL()
    	{
    	// Create active scheduler (to run active objects)
    	CActiveScheduler* scheduler = new (ELeave)CActiveScheduler();
    	CleanupStack::PushL(scheduler);
    	CActiveScheduler::Install(scheduler);
    
    	MainL();
    
    	// 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;
    	}

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

    Smile Re: Sending SMS using MTM Via Simple Console Application

    Check this another article: Sending-Receiving SMS through an Exe (Server)

    Kiran.
    Nokia Developer Wiki Moderation team

  3. #3
    Nokia Developer Moderator
    Join Date
    Sep 2004
    Location
    Tampere, Finland
    Posts
    11,359

    Re: Sending SMS using MTM Via Simple Console Application

    Better yet, try to learn from your mistake. What goes wrong if you run the code above?
    -- Lucian

    If you are not yet a DVLUP member it is time to correct that mistake :) Click here to join: http://www.dvlup.com/lucian/Invite

  4. #4
    Registered User
    Join Date
    Aug 2007
    Posts
    165

    Re: Sending SMS using MTM Via Simple Console Application

    You are always there!!! thanks you again kiran
    I start to study ..

  5. #5
    Registered User
    Join Date
    Aug 2007
    Posts
    165

    Re: Sending SMS using MTM Via Simple Console Application

    Kiran I tried this code but i have some problems
    1. me.CommandLine(cmdLine); -
    error: 'class RProcess' has no member named 'CommandLine'

    Then I tried the MainL with out any Args but it's doesn't send
    SMS and the application doesn't even start.

    Code:
    #include "testexe.h"
    #include <e32base.h>
    #include <e32std.h>
    #include "SMSHandler.h"
     
     
    //  Local Functions
    LOCAL_C void MainL(const TDesC& aArgs)
    {
        //
        // add your program code here, example code below
        //
    	//This is for initializing SMSHandler
    	CSmsHandler* iSmsHandler = CSmsHandler::NewL();
    }
     
     
    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);   ///ERROR
        MainL(cmdLine);
     
     
    	CActiveScheduler::Start();
     
        // Delete active scheduler
        CleanupStack::PopAndDestroy(scheduler);
    }
     
     
    //  Global Functions
    GLDEF_C TInt E32Main()
    {
        // Create cleanup stack
        __UHEAP_MARK;
        CTrapCleanup* cleanup = CTrapCleanup::New();
     
        // Run application code inside TRAP harness, wait keypress when terminated
        TRAPD(mainError, DoStartL());
     
        delete cleanup;
        __UHEAP_MARKEND;
    thanks.

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

    Re: Sending SMS using MTM Via Simple Console Application

    Remove those problematic lines. I posted that article from my working scenario. I need to make it more general. For now it should be something like below:

    Code:
    #include "testexe.h"
    #include <e32base.h>
    #include <e32std.h>
    #include "SMSHandler.h"
     
     
    //  Local Functions
    LOCAL_C void MainL()
    {
        //
        // add your program code here, example code below
        //
    	//This is for initializing SMSHandler
    	CSmsHandler* iSmsHandler = CSmsHandler::NewL();
    }
     
     
    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
        MainL();
     
     
    	CActiveScheduler::Start();
     
        // Delete active scheduler
        CleanupStack::PopAndDestroy(scheduler);
    }
     
     
    //  Global Functions
    GLDEF_C TInt E32Main()
    {
        // Create cleanup stack
        __UHEAP_MARK;
        CTrapCleanup* cleanup = CTrapCleanup::New();
     
        // Run application code inside TRAP harness, wait keypress when terminated
        TRAPD(mainError, DoStartL());
     
        delete cleanup;
        __UHEAP_MARKEND;
    Kiran.
    Nokia Developer Wiki Moderation team

  7. #7
    Registered User
    Join Date
    Aug 2007
    Posts
    165

    Re: Sending SMS using MTM Via Simple Console Application

    I tried this:

    (// the console doesn't open with this command line ;( )
    iSmsHandler->SendMsg(); // the console doesn't open with
    Code:
    /*
    ============================================================================
     Name		: testexe.cpp
     Author	  : 
     Copyright   : Your copyright notice
     Description : Exe source file
    ============================================================================
    */
    
    //  Include Files  
    #if defined(__WINS__) && !defined(EKA2) 
    EXPORT_C TInt WinsMain()     
    {     
    return E32Main();
         } 
    TInt E32Dll(TDllReason /*aReason*/)    
     {
         return KErrNone;     
    } 
    #endif
    
    #include "testexe.h"
    #include <e32base.h>
    #include <e32std.h>
    #include <e32cons.h>			// Console
    #include "SmsHandler.h"
    
    
    //  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()
    	{
    	
    	CSmsHandler* iSmsHandler = CSmsHandler::NewL();
    	iSmsHandler->SendMsg(); // the console doesn't open with this command line ;(
        console->Write(_L("1.Hello, need to send sms!\n"));
    	
     	}
    
    
    LOCAL_C void DoStartL()
    	{
    	// Create active scheduler (to run active objects)
    	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
    	CleanupStack::PushL(scheduler);
    	CActiveScheduler::Install(scheduler);
    
    	MainL();
    
    	// 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;
    	}

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

    Question Re: Sending SMS using MTM Via Simple Console Application

    Ok. One basic question: For which platform are you building your application? Is it S60 2nd edition or S60 3rd edition?

    Kiran.
    Nokia Developer Wiki Moderation team

  9. #9
    Registered User
    Join Date
    Aug 2007
    Posts
    165

    Re: Sending SMS using MTM Via Simple Console Application

    3d sdk symbian 9.2

  10. #10
    Nokia Developer Champion
    Join Date
    Jul 2004
    Posts
    2,015

    Re: Sending SMS using MTM Via Simple Console Application

    What do you mean by the application doesn't start and the console doesn't open? Does your code even compile, what does the implementation of CSmsHandler::SendMsg() look like? And why aren't you starting the active scheduler?

  11. #11
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,734

    Re: Sending SMS using MTM Via Simple Console Application

    Note that the referred Wiki article contains - at least its current version - "CActiveScheduler::Start();" after invoking MainL(). That has a reason.
    And put a SendL/SendMsg between the two.

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

    Smile Re: Sending SMS using MTM Via Simple Console Application

    Quote Originally Posted by Dvirus View Post
    3d sdk symbian 9.2
    Good. If you just want to send SMS then you can try a simple and straight away API. RSendAs.

    Here is an example: Sending SMS with RSendAs

    Do you want more than this? If yes then what is that?

    Kiran.
    Nokia Developer Wiki Moderation team

  13. #13
    Registered User
    Join Date
    Aug 2007
    Posts
    165

    Re: Sending SMS using MTM Via Simple Console Application

    This supposed to show the console ?!?!
    I given up... ;(

    Code:
    //  Include Files  
    #if defined(__WINS__) && !defined(EKA2) 
    EXPORT_C TInt WinsMain()     
    {     
    return E32Main();
         } 
    TInt E32Dll(TDllReason /*aReason*/)    
     {
         return KErrNone;     
    } 
    #endif
    
    #include "testexe.h"
    #include <e32base.h>
    #include <e32std.h>
    #include <e32cons.h>			// Console
    #include "SmsHandler.h"
    
    
    //  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()
    	{
        console->Write(_L("1.Hello, need to send sms!\n"));
     	}
    
    
    LOCAL_C void DoStartL()
    	{
    	CSmsHandler* iSmsHandler = CSmsHandler::NewL();	
    	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
    	CleanupStack::PushL(scheduler);
    	CActiveScheduler::Install(scheduler);
    	MainL();
    	iSmsHandler->SendMsg();
    	CActiveScheduler::Start();
    	CleanupStack::PopAndDestroy(scheduler);
    	}
    
    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;
    	}

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

    Re: Sending SMS using MTM Via Simple Console Application

    Quote Originally Posted by Dvirus View Post
    This supposed to show the console ?!?!
    I given up... ;(

    ...
    You didn't give answer to my question. Do you just want to send an SMS or do you want something more than that?

    Kiran.
    Nokia Developer Wiki Moderation team

  15. #15
    Registered User
    Join Date
    Aug 2007
    Posts
    165

    Re: Sending SMS using MTM Via Simple Console Application

    For now just to click on app icon
    send sms
    view "Hello world" on the Console
    that it.
    thanks.

Similar Threads

  1. Replies: 1
    Last Post: 2006-10-07, 18:55
  2. Replies: 1
    Last Post: 2005-12-01, 23:57
  3. example needed: sending SMS from an application
    By cl_bonesbb in forum Symbian Networking & Messaging (Closed)
    Replies: 5
    Last Post: 2003-07-04, 06:57
  4. Sending SMS from MIDP application in phone Nokia 6610
    By rajivm in forum General Messaging
    Replies: 1
    Last Post: 2003-03-11, 08:29
  5. Sending and receiving SMS messages from J2ME application
    By nkn_motoko in forum Mobile Java General
    Replies: 1
    Last Post: 2001-11-06, 20:34

Posting Permissions

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