×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    27

    Help for sending international SMS with Qt for S60!

    Is there anyone send international SMS with Qt for S60 succefully?
    International SMS, it means here non-7bit SMS, such as chinese SMS.

    First I use RSendAs api, it works with English SMS wonderfully, but just works with 7bit SMS.

    Then I tried program referred by , and modified:
    settings->CopyL( iSmsMtm->ServiceSettings() ); // restore settings
    settings->SetDelivery( ESmsDeliveryImmediately ); // to be delivered immediately
    settings->SetDeliveryReport(ETrue);
    settings->SetCharacterSet( TSmsDataCodingScheme::ESmsAlphabetUCS2 );
    header.SetSmsSettingsL( *settings ); // new settings
    It works well with international SMS in the example.
    But when I tried in my QT for S60 program, the program just crashed.
    Code:
    int MsgHandler::nInit()
    {
    	this->nFini();
    
    	TRAPD( iErr, this->iSmsHandler	=	CSmsHandler::NewL() );
    
    	return 0;
    }
    
    int MsgHandler::nSend()
    {
    	if ( ! this->bInitialized() )
    	{
    		return -1;
    	}
    
    	TBuf16<32>	strRecipient;
    	TBuf16<256>	strContent;
    	strRecipient.Copy( _L("13957167942") );
    	strContent.Copy( _L("test SMS from Nokia 6110N - qt for s60") );
    
    	TRAPD( iErr, this->iSmsHandler->SendL( strRecipient, strContent ) );
    
    	return 0;
    }

  2. #2
    Registered User
    Join Date
    Dec 2006
    Posts
    2,280

    Re: Help for sending international SMS with Qt for S60!

    Hi,

    Where did it crash? Have you tried stepping through it in the debugger?

    For example, you ignore any error in the creation of the CSmsHandler, so if that fails for some reason then you'd be accessing a NULL pointer in the send function.

    Mark

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    27

    Re: Help for sending international SMS with Qt for S60!

    For some reason, I just not using Carbide++ IDE.
    I edit in notepad++, and compile in command line.
    What happened is the program just disappear, nothing for hint.
    What I need is a simple action to send SMS, why it's so complicated?

    I like the RSendAs api, but it doesn't work for non-7bit SMS.
    Code:
    	RSendAs saSrv;
    	saSrv.Connect();
    	CleanupClosePushL(saSrv);
    
    	RSendAsMessage msg;
    	msg.CreateL(saSrv, KUidMsgTypeSMS);
    	CleanupClosePushL(msg);
    	msg.AddRecipientL(strRecipient,RSendAsMessage::ESendAsRecipientTo);
    	msg.SetBodyTextL(strContent);
    
    	msg.SendMessageAndCloseL();
    
    	CleanupStack::Pop(&msg);
    	CleanupStack::PopAndDestroy(&saSrv);
    MsgHandler.h

    Code:
    #ifndef MUIP_WS_MSG_S60_H
    #define MUIP_WS_MSG_S60_H
    
    #include "SMShandler.h"
    
    class MsgHandler
    {
    public:
    	MsgHandler();
    	virtual ~MsgHandler();
    
    	int		nInit();
    	int		nFini();
    	bool	bInitialized();
    
    	int	nAddRecipient( const char* strRecipient_utf8 );
    	int	nSetBodyText( const char* strContent_utf8 );
    	int	nSend();
    
    private:
    	CSmsHandler*	iSmsHandler;
    };
    
    #endif //end MUIP_WS_MSG_S60_H
    MsgHandler.cpp
    Code:
    #include "MUIP_WS_msg_s60.h"
    
    #include <string.h>
    #include <utf.h>
    
    #define DEBUG_ONLY
    
    MsgHandler::MsgHandler()
    :iSmsHandler(NULL)
    {
    }
    
    MsgHandler::~MsgHandler()
    {
    	this->nFini();
    }
    
    int MsgHandler::nInit()
    {
    	this->nFini();
    
    	TRAPD( iErr, (this->iSmsHandler = CSmsHandler::NewL()) );
    
    	return 0;
    }
    
    int MsgHandler::nFini()
    {
    #ifndef DEBUG_ONLY
    	if ( this->bInitialized() )
    	{
    		delete this->iSmsHandler;
    		this->iSmsHandler	=	NULL;
    	}
    #endif //end DEBUG_ONLY
    
    	return 0;
    }
    
    bool MsgHandler::bInitialized()
    {
    	return (this->iSmsHandler != NULL);
    }
    
    int MsgHandler::nAddRecipient( const char* strRecipient_utf8 )
    {
    	if ( ! this->bInitialized() )
    	{
    		return -1;
    	}
    
    	//TODO
    
    	return 0;
    }
    
    int MsgHandler::nSetBodyText( const char* strContent_utf8 )
    {
    	if ( ! this->bInitialized() )
    	{
    		return -1;
    	}
    
    	//TODO
    
    	return 0;
    }
    
    int MsgHandler::nSend()
    {
    	if ( ! this->bInitialized() )
    	{
    		return -1;
    	}
    
    	TBuf16<32>	strRecipient;
    	TBuf16<256>	strContent;
    	strRecipient.Copy( _L("13957167942") );
    	strContent.Copy( _L("test SMS from Nokia 6110N - qt for s60") );
    
    	TRAPD( iErr, this->iSmsHandler->SendL( strRecipient, strContent ) );
    
    	return 0;
    }

  4. #4
    Registered User
    Join Date
    Dec 2006
    Posts
    2,280

    Re: Help for sending international SMS with Qt for S60!

    Hi,

    You're using native Symbian APIs. You might want to wait until there are easier to use alternatives...

    Does the application work if you remove the lines that try to send the SMS? If you're not going to use a debugger then you'll have to have some method of debugging software. How about simply logging some trace to a file?

    There is no reason why you can't make this work in principle. Just posting bits of your code isn't really likely to help.

    One possibility is that you haven't declared the necessary capability (NetworkServices) for sending an SMS, so the sending function just leaves. However, that's a pure guess.

    You haven't shown how you call this code, but for example if you create the handler and send within the same function then it won't work because the init is asynchronous and the send will fail if the init hasn't finished (assuming you're using the CSmsHandler example from the Wiki). Again, only guessing with what you've posted.

    My (polite) suggestions are:
    1) Figure out how you're going to debug Qt for S60 applications on the emulator and the target - this won't be the last bug you ever find.
    2) Don't post questions until you have a decent idea what you're asking, or which bit of your code might not be working - this usually involves doing some debugging yourself first.

    Good luck!
    Mark

  5. #5
    Registered User
    Join Date
    Jan 2008
    Posts
    27

    Re: Help for sending international SMS with Qt for S60!

    In my system, the SMS/MMS service is the only thing I need to use symbian native API.
    The others I will use QT or open C/C++.
    I just need a working example for this.

    These days, I downloaded many examples, and find 90% not working, so painfully.
    I have done C++ developping for years, and don't think symbian C++ is C++, especially for the spirit.

    I just need a mobile client, no matter it's Symbian, or Windows Mobile, or Linux.
    The first choice is symbian, for its market position.
    Maybe, I should make another choice.

    This version, I will use RSendAs with English support only, and wait for an new way to solve.
    The same time, waiting for QT 4.5 with LGPL for WinCE.

  6. #6
    Registered User
    Join Date
    Dec 2006
    Posts
    2,280

    Re: Help for sending international SMS with Qt for S60!

    Don't give up on Symbian just yet.

    I'd strongly recommend you try using Carbide.c++, it's pretty good.

    Also, easier ways to access these APIs from Qt will come... just a little patience is required.

    Unfortunately the quality of the code examples in the Forum Nokia wiki is very variable! They're only volunteer contributions, not official examples.

    Mark

  7. #7
    Registered User
    Join Date
    Jan 2008
    Posts
    27

    Re: Help for sending international SMS with Qt for S60!

    Not give up, just another choice.
    Then in plan, first stage on the mobile side, Windows Mobile will implement completely, Symbian implement partly(no international SMS support).
    Waiting for Qt Extended on Symbian and Windows Mobile platform.

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

    Re: Help for sending international SMS with Qt for S60!

    Wait wait wait...

    If you are referring to Wiki article for sending SMS from exe then it was done through asynchronous way. If you are sending SMS right from your exe then you need to change the code as below to use synchronous way:

    - Open your SmsHandler.cpp
    Code:
    void CSmsHandler::ConstructL()
        {
        // Session to message server is opened synchronously.
        iSession = CMsvSession::OpenSyncL( *this );
    
        iMtmRegistry = CClientMtmRegistry::NewL(*iSession);
        //iMtm = iMtmRegistry->NewMtmL(KUidMsgTypeSMS);
        iSmsMtm = STATIC_CAST(CSmsClientMtm*,iMtmRegistry->NewMtmL(KUidMsgTypeSMS));
        
        // Entry selection for all received messages.
        iSelection = new ( ELeave ) CMsvEntrySelection();
        }

    - Open your application
    Code:
    int MsgHandler::nInit()
    	{
    ....
    ....
    	iSmsHandler = CSmsHandler::NewL();
    	iSmsHandler->SendL( strRecipient, strContent ) );
    .......
    .......
    	}
    This should work. Let me know if you still find any problem....
    Nokia Developer Wiki Moderation team

  9. #9
    Registered User
    Join Date
    Jan 2008
    Posts
    27

    Re: Help for sending international SMS with Qt for S60!

    I tried this way before, with removing CActive operations.
    But while compling, the complier just throws other errors, mostly for Symbian envs.

    Let it be, I'm waiting for the next QT version.

Similar Threads

  1. SMS from Visual Basic with international characters
    By mads68 in forum General Messaging
    Replies: 2
    Last Post: 2008-12-06, 00:15
  2. problem sending CONCATENATED SMS
    By habier in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2007-07-11, 11:00
  3. Send SMS Problem. Cannot Get SMSC Address. Due to Strange SIM Card?
    By cksong in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2007-07-02, 16:13
  4. Replies: 2
    Last Post: 2002-10-02, 07:15

Posting Permissions

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