×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Jul 2007
    Posts
    279

    Question about USSD with QT?

    Hi,
    How can i make a USSD call/sms ??
    the ussd is something like this "*505*number# "
    thanks in advance
    Ram

  2. #2
    Registered User
    Join Date
    Oct 2004
    Posts
    89

    Re: Question about USSD with QT?

    Hi

    To my knowledge there are no Qt APIs to achieve this. I wonder if the are Public Symbian API to achieve this also.
    In case there are no public API , you may find those from paid technical support

    -halderp

  3. #3
    Registered User
    Join Date
    Jul 2007
    Posts
    279

    Re: Question about USSD with QT?

    Hi halderp,
    i'm using the Symbian AT example in Qt as follows
    //.h
    Code:
    #ifndef USSDSENDER_H
    #define USSDSENDER_H
    
    #include <qstring.h>
    
    #ifdef Q_WS_S60
    #include <C32COMM.H>
    #include <BAUTILS.H>
    //c32.lib
    #endif
    
    #ifdef Q_WS_S60
    class CUSSDHandler : public CActive
        {
        enum TUSSDQState
        {
            EStateNone,
            EWriting,
            EFirstRead,
            ESecondRead,
            ESecondAdditional
        };
    public:	// Construction and Destruction
            static CUSSDHandler* NewL();
            static CUSSDHandler* NewLC();
            virtual ~CUSSDHandler();
    public:	// Public Methods
            void SendCUSDMessage();
            void SendMessage();
    protected:	// From CActive
            void RunL();
            void DoCancel();
    private:	// Construction
            void ConstructL();
            CUSSDHandler();
    private:
            TBuf8<1024>		iReplyData;
            RCommServ 		iCommServer;
            RComm 			iComm;
            TUSSDQState		iMyQState;
    
            TBuf<250> 		iSendString;
    };
    
    
    #endif
    class USSDSender
    {
    public:
        USSDSender();
        ~USSDSender();
        void sendUSSD(QString string);
    
        #ifdef Q_WS_S60
        CUSSDHandler* ussdObj;
        #endif
    };
    
    #endif // USSDSENDER_H
    //.cpp
    Code:
    #include "ussdsender.h"
    
    #ifdef Q_WS_S60
    #include <C32COMM.H>
    
    _LIT(KCsyName			,"DATAPORT");
    _LIT(KDataPort			,"DATAPORT::1");// this works with CUSD
    //_LIT(KDataPort			,"DATAPORT::0");// is in use -14
    /*
    -----------------------------------------------------------------------------
    ****************************************************************************
    -----------------------------------------------------------------------------
    */
    CUSSDHandler* CUSSDHandler::NewL()
        {
        CUSSDHandler* self = CUSSDHandler::NewLC();
        CleanupStack::Pop();
        return self;
        }
    /*
    -----------------------------------------------------------------------------
    -----------------------------------------------------------------------------
    */
    CUSSDHandler* CUSSDHandler::NewLC()
        {
        CUSSDHandler* self = new (ELeave) CUSSDHandler();
        CleanupStack::PushL(self);
        self->ConstructL();
        return self;
        }
    /*
    -----------------------------------------------------------------------------
    -----------------------------------------------------------------------------
    */
    void CUSSDHandler::ConstructL()
    {
            CActiveScheduler::Add(this);
    
            User::LeaveIfError(StartC32());
    
            // Connect the server
            User::LeaveIfError(iCommServer.Connect());
            // Load the CSY module
            User::LeaveIfError(iCommServer.LoadCommModule(KCsyName()));
    
            // Open the port
            User::LeaveIfError(iComm.Open (iCommServer, KDataPort, ECommShared));
    }
    /*
    -----------------------------------------------------------------------------
    -----------------------------------------------------------------------------
    */
    CUSSDHandler::CUSSDHandler()
    :CActive(EPriorityLow),iMyQState(EStateNone)
    {
    }
    
    /*
    -----------------------------------------------------------------------------
    -----------------------------------------------------------------------------
    */
    CUSSDHandler::~CUSSDHandler()
    {
            Cancel();
            iComm.Close();
            iCommServer.Close();
    }
    
    _LIT(KTestCommandEnd, "\r\n");
    
    void CUSSDHandler::SendMessage()
    {
            Cancel();
            iSendString.Copy(_L(""));
            /*CAknTextQueryDialog* Dialog = CAknTextQueryDialog::NewL(iSendString,CAknQueryDialog::ENoTone);
            Dialog->PrepareLC(R_ASK_NAME_DIALOG);
            Dialog->SetPromptL(_L("AT String"));
            if(Dialog->RunLD())
            {*/
                    iSendString.Append(KTestCommandEnd);
                    iReplyData.Copy(iSendString);
    
                    iMyQState = EWriting;
                    iComm.Write(iStatus,iReplyData);
                    SetActive();
            //}
    }
    
    /*
    -----------------------------------------------------------------------------
    
    -----------------------------------------------------------------------------
    */
    _LIT8(KWriteCommand1, "AT+CUSD = 1,\"");
    _LIT8(KWriteCommand2, "\",15\r\n");
    void CUSSDHandler::SendCUSDMessage(void)
    {
            Cancel();
    
            TBuf8<180> Querryl8;
    
            TBuf<250> sendString(_L("*100#"));
    
            /*CAknTextQueryDialog* Dialog = CAknTextQueryDialog::NewL(sendString,CAknQueryDialog::ENoTone);
            Dialog->PrepareLC(R_ASK_NAME_DIALOG);
            Dialog->SetPromptL(_L("USSD"));
            if(Dialog->RunLD())
            {*/
                Querryl8.Copy(sendString);
    
                iReplyData.Copy(KWriteCommand1);
                iReplyData.Append(Querryl8);
                iReplyData.Append(KWriteCommand2);
    
                iMyQState = EWriting;
                iComm.Write(iStatus,iReplyData);
                SetActive();
           // }
    }
    /*
    -----------------------------------------------------------------------------
    -----------------------------------------------------------------------------
    */
    void CUSSDHandler::RunL()
    {
            if(iStatus.Int() != KErrCancel)
            {
                    if(iMyQState == EWriting)
                    {
                        iReplyData.Zero();
                        iMyQState = EFirstRead;
                        iComm.ReadOneOrMore(iStatus, iReplyData);
                        SetActive();
                    }
                    else if(iMyQState == EFirstRead)
                    {
                        iReplyData.Zero();
                        iMyQState = ESecondRead;
                        iComm.ReadOneOrMore(iStatus, iReplyData);
                        SetActive();
                    }
                    else
                    {
                        iReplyData.Zero();
                        iMyQState = ESecondAdditional;
                        iComm.ReadOneOrMore(iStatus, iReplyData);
                        SetActive();
                    }
            }
    }
    /*
    -----------------------------------------------------------------------------
    -----------------------------------------------------------------------------
    */
    void CUSSDHandler::DoCancel()
    {
            iComm.Cancel();
    }
    
    #endif
    USSDSender::USSDSender()
    {
        #ifdef Q_WS_S60
        this->ussdObj = NULL;
        #endif
    
    }
    
    USSDSender::~USSDSender()
    {
    #ifdef Q_WS_S60
    if (this->ussdObj) delete this->ussdObj;
    this->ussdObj = NULL;
    #endif
    }
    void USSDSender::sendUSSD(QString string)
    {
        #ifdef Q_WS_S60
        TBuf<48> dNumeroTelefono(string.utf16());
    
        this->ussdObj = CUSSDHandler::NewL(/*dNumeroTelefono*/);
        this->ussdObj->SendCUSDMessage();
        #endif
    }
    and i added this in the .pro
    LIBS += -centralrepository -c32
    then i ran qmake and rebuild, after that i got some errors related to RComm like
    [undefined refrence iComm.Cancel();

    please Expert guys help me what is missing/wrong
    thanks

  4. #4
    Registered User
    Join Date
    Jul 2007
    Posts
    279

    Re: Question about USSD with QT?

    i solved the error by replacing the libs line by this
    LIBS += -lc32 //added "l" to "c32"
    then it is builded without problems but it is still not sending the ussd
    please help
    thanks
    Ram

Similar Threads

  1. Replies: 2
    Last Post: 2010-11-09, 21:00
  2. Replies: 11
    Last Post: 2010-06-16, 15:14
  3. Consult about USSD
    By viaris in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2007-11-05, 21:02

Posting Permissions

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