×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    17

    newbe need some help, background sms sending

    i am trying to implement background sms sending in my application.
    this is the codes im using -
    smssender.cpp -
    Code:
    // INCLUDE FILES
    
    
    #include <gsmubuf.h>
    #include <gsmuset.h>
    #include <stdio.h>
    #include <SMSCLNT.h>
    #include <SMUTHDR.h>
    #include <string.h>
    
    _LIT(KServiceCenterNumber, "+12063130004");
    
    SmsSender::SmsSender(RSocketServ iSocketServer, RFs iFs)
    :CActive(CActive::EPriorityLow)
    {
    
        mRSocketServer = iSocketServer;
        mRFs = iFs;
        memset(iServiceCenterAddress, 0, sizeof(iServiceCenterAddress));
    }
    
    SmsSender* SmsSender::NewL(RSocketServ iSocketServer, RFs iFs)
        {
        SmsSender* self = SmsSender::NewLC(iSocketServer, iFs);
        CleanupStack::Pop(self);
        return self;
        }
    
    SmsSender* SmsSender::NewLC(RSocketServ iSocketServer, RFs iFs)
        {
        SmsSender* self = new (ELeave) SmsSender(iSocketServer, iFs);
        if (self == NULL)
        {
                //KN_LOG ((KN_P2T_MAJOR,"KN_P2T_Smssender :: NewLC ERROR Unable to allocate memory for SmsSender"));
        }
        CleanupStack::PushL(self);
        self->ConstructL();
        return self;
        }
    
    void SmsSender::ConstructL()
    {
        CActiveScheduler::Add(this);
        User::LeaveIfError(mRSocketServer.Connect());
        User::LeaveIfError(mRFs.Connect());
    
        serviceCenterAddress = new ServiceCenterAddress;
        memset(iServiceCenterAddress,sizeof(iServiceCenterAddress),'\0');
    }
    
    void SmsSender::Open()
    {
        // Open a socket
        User::LeaveIfError(mRSocket.Open(mRSocketServer, KSMSAddrFamily, KSockDatagram, KSMSDatagramProtocol));
    
        // Bind to SMS port
        TSmsAddr smsAddr;
        smsAddr.SetSmsAddrFamily(ESmsAddrSendOnly);
        mRSocket.Bind(smsAddr);
    }
    
    KN_BOOL SmsSender::SendL(const char* aAddress, const char* aData, const char* smscAddress)
    {
    
        if (IsActive())
        {
    		Cancel(); // Cancels any outstanding request
    	}
    
        TBuf<20> desAddress;
        TBuf8<20> tempAddress;
        desAddress.FillZ();
        tempAddress.FillZ();
        tempAddress.Copy((TUint8*)aAddress);
    
        desAddress.Copy(tempAddress);
        //TBuf<165> msg;
        TBuf8<165> tempMsg;
        //msg.FillZ();
        tempMsg.FillZ();
    
    	tempMsg.Copy((TUint8*)aData);
    
        //msg.Copy(tempMsg);
    
        // Create the SMS message
        CSmsBuffer* smsBuffer = CSmsBuffer::NewL();
        mSmsMsg = CSmsMessage::NewL(mRFs, CSmsPDU::ESmsSubmit, smsBuffer);
    
        TSmsUserDataSettings smsSettings;
    //    smsSettings.SetAlphabet(TSmsDataCodingScheme::ESmsAlphabet8Bit);
        smsSettings.SetTextCompressed(EFalse);
    
        mSmsMsg->SetUserDataSettingsL(smsSettings);
    
        mSmsMsg->SetToFromAddressL(desAddress);
    
    
    
        TBuf<20> address;
        TBuf8<20> buf8;
        address.FillZ();
        buf8.FillZ();
        if(smscAddress == NULL)
        {
    		//non-smsc bypass case; only first PDU going out needs to get the service centre address
    		if(strlen(iServiceCenterAddress)==0)
        		serviceCenterAddress->GetServiceCenterAddress(iServiceCenterAddress);
    
    		buf8.Copy((TUint8*)iServiceCenterAddress);
        }
        else
        {
    		//smsc bypass case
            buf8.Copy((TUint8*)smscAddress);
        }
        address.Copy(buf8);
    
        mSmsMsg->SmsPDU().SetServiceCenterAddressL(address);
    
        // Insert our SMS pattern header so that our receiver is able to detect
        // the incoming message, and then append the data.
    
        // Change for thin call message - vchirag : 28th Sept., 2006
        //smsBuffer->InsertL(0, msg);
        mSmsMsg->SmsPDU().UserData().SetBodyL(tempMsg);    
    
        // Open a write stream on the socket and stream our message.
        RSmsSocketWriteStream writeStream(mRSocket);
        writeStream << *(mSmsMsg);
    
        // message has not been sent at this point
        writeStream.CommitL();
    
        // Send the message
        mRSocket.Ioctl(KIoctlSendSmsMessage, iStatus, &mOctlResult, KSolSmsProv);
        SetActive();
        //delete smsBuffer;
        if(mSmsMsg)
        {
    	    delete mSmsMsg;
            mSmsMsg = NULL;
        }
    #endif
        return KN_TRUE;
    }
    
    void SmsSender::RunL()
    {
    
    }
    
    void SmsSender::DoCancel()
    {
    }
    
    
    SmsSender::~SmsSender()
    {
        Cancel();
    
        if (serviceCenterAddress != NULL)
        {
            /* Cancel first */
            serviceCenterAddress->Cancel();
            delete serviceCenterAddress;
            serviceCenterAddress = NULL;
        }
        mRSocket.Close();
    }
    
    
    
    
    
    ServiceCenterAddress::ServiceCenterAddress():CActive(CActive::EPriorityLow)
    {
        CActiveScheduler::Add(this);
        iServiceCenterAddress.FillZ();
    }
    
    
    
    void ServiceCenterAddress::GetServiceCenterAddress(char * pServiceCenterAddress)
    {
        iSession = CMsvSession::OpenSyncL(*this);
    
        iMtmRegistry = CClientMtmRegistry::NewL(*iSession);
        iMtm = iMtmRegistry->NewMtmL(KUidMsgTypeSMS);
        ASSERT(iMtm);
        if (iMtm)
        {
            // To handle the sms specifics we start using SmsMtm
    
            CSmsClientMtm* smsMtm = static_cast<CSmsClientMtm*>(iMtm);
    
            smsMtm->RestoreServiceAndSettingsL();
    
    
            CSmsSettings& serviceSettings = smsMtm->ServiceSettings();
    
    
            #ifdef __UI_FRAMEWORKS_V2__
            if (serviceSettings.ServiceCenterCount() != 0)
            #else
            if (serviceSettings.NumSCAddresses() != 0)
            #endif
            {
                    // set sc address to default.
                    #ifdef __UI_FRAMEWORKS_V2__
                    CSmsServiceCenter& sc = serviceSettings.GetServiceCenter(serviceSettings.DefaultServiceCenter());
                    #else
                    CSmsNumber& sc = serviceSettings.SCAddress(serviceSettings.DefaultSC());
                    #endif
    
                    TBuf8<20> buf;
                    buf.FillZ();
                    buf.Copy(sc.Address());
                    iServiceCenterAddress.Copy(buf);
                    delete iMtmRegistry;
                    strcpy(pServiceCenterAddress,(char*)buf.Ptr());
                    return;
            }
        }
          if(iMtmRegistry)
        {
    	    delete iMtmRegistry;
            iMtmRegistry = NULL;
        }
        if(iOperation)
        {
    	    delete iOperation;
            iOperation = NULL;
        }
    
    }
    
    void ServiceCenterAddress::RunL()
    {
    }
    
    void ServiceCenterAddress::DoCancel()
    {
    }
    
    
    void ServiceCenterAddress::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/)
    {
    }
    
    
    // End of File
    smssender.h -
    Code:
    #ifndef __SMSSENDER_H__
    #define __SMSSENDER_H__
    
    // INCLUDES
    #include <e32base.h>
    #include <es_sock.h>
    #include <f32file.h>
    #include <smsuaddr.h> 
    #include <smsustrm.h>
    #include <Gsmumsg.h>
    #include <msvstd.h>
    #include <msvapi.h>
    #include <mtclreg.h>
    #include <SMSCLNT.h>
    #include <SMUTSET.h>
    
    
    // FORWARD DECLARATIONS
    class ServiceCenterAddress;
    
    
    // CLASS DECLARATION
    class SmsSender: public CActive
    {
        public: 
    		 
            
    		static SmsSender* NewL(RSocketServ iSocketServer, RFs iFs);
            construction,
            
    		static SmsSender* NewLC(RSocketServ iSocketServer, RFs iFs);
            
    		~SmsSender();
    
    	public: // New functions
    		void Open();
    		bool SendL(const char* aAddress, const char* aData);
        protected: // Functions from base classes
            
            void DoCancel();
    
            
            void RunL();
    
    	private: // Constructors and destructors
            
            SmsSender(RSocketServ iSocketServer, RFs iFs);
            
            void ConstructL();
    
    	public:     // Member Variable
    		void* mUserData;
    		char iServiceCenterAddress[20];    
    		ServiceCenterAddress *serviceCenterAddress;
    
    	private:	// Member Variable
    		RSocket        mRSocket;
    		RSocketServ     mRSocketServer;
    		RFs             mRFs;
    		CSmsMessage*    mSmsMsg;
    		TPckgBuf<TUint> mOctlResult;
    		TInt   mMessageCount;
                
    };
    
    // CLASS DECLARATION
    class ServiceCenterAddress: public CActive, public MMsvSessionObserver
    {
    public:
        ServiceCenterAddress();
        void RunL();
        void DoCancel();
    
        void GetServiceCenterAddress(char * pServiceCenterAddress);
        void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3);
        CMsvSession*        iSession;
        CBaseMtm*           iMtm;
        CMsvOperation*  iOperation;
        CClientMtmRegistry* iMtmRegistry;
    
        TBuf<20> iServiceCenterAddress;
    };
    
    #endif  // __SMSSENDER_H__
    
    // End of File
    and the code i got into one of my applications cpp files (smscontainer.cpp) in order to implement the sending -
    Code:
    CSmsContainer*    iSmsSender;   /// Make this as member of some class
    
    /// create this instance before sending out the SMS
    if (iSmsSender == NULL)
    {
    	     // starting the sender
             RSocketServ     mRSocketServer;
             RFs             mRFs;
    
             iSmsSender = SmsSender::NewL(mRSocketServer,mRFs);
             if (iSmsSender == NULL)
             {
                  return KN_FALSE;
             }
             iSmsSender->Open();
    }
    
    
    /// Use this method to send out the SMS
    TRAPD(err,lRetVal = iSmsSender->SendL(+972564572555, test));
    if(err!=KErrNone)
    {
    	//handle error
    }
    
    
    /// When you are done delete the instance of SmsSender
    if(iSmsSender)
    {
       delete iSmsSender;
       iSmsSender=NULL;
    }
    when compiling, i get 11 declaration syntax error's and two -
    undefined identifier 'iSmsSender' error's.
    i had another undefined identifier 'RSocketServ' error, that disapeared when i included those headers in smscontainer.cpp -
    #include <smsuaddr.h>
    #include <smsustrm.h>
    #include <gsmuset.h>
    #include <gsmupdu.h>
    #include <Gsmuelem.h>
    anyone can help and point out to me what i need to do in order to get this working?
    thank's alot!

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: newbe need some help, background sms sending

    you haven't added iSmsSender as a member variable. Yoi might want to follow only one naming convention at one time, it would make it easier to see mistakes like that, and would make your code more readable. Here at discussion board for Symbian development, you should propably consider using Symbian naming convention.

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

    Re: newbe need some help, background sms sending

    I would pass those parameters around by reference too rather than by value.

  4. #4
    Registered User
    Join Date
    Feb 2008
    Posts
    17

    Re: newbe need some help, background sms sending

    Quote Originally Posted by symbianyucca View Post
    you haven't added iSmsSender as a member variable. Yoi might want to follow only one naming convention at one time, it would make it easier to see mistakes like that, and would make your code more readable. Here at discussion board for Symbian development, you should propably consider using Symbian naming convention.
    iv'e tried to lookup some information on member variables.
    in -
    http://wiki.forum.nokia.com/index.ph...ymbian_C%2B%2B
    i found this example (under Initialize member data in T classes and structs) -
    Code:
    TClass::Tclass()
        : iMemberTInt( 0 )
        , iMemberTBool( EFalse )
        , iMemberTBuf()
        {
        }
    that's the way im supposed to add iSmsSender as a member variable?
    if so, what modifications i need to make in this example in order to fit it into my source code?
    thank's alot for the help!

  5. #5
    Regular Contributor
    Join Date
    May 2004
    Location
    Bangalore, India
    Posts
    118

    Re: newbe need some help, background sms sending

    Can you post your code smscontainer.cpp, where you are creating the instance of SmsSender. Also post exact compliation error output.
    Dushyant Gaur
    Sling Media,
    Bangalore
    cell:+91 9342276086
    email: dushyantg@slingmedia.com

  6. #6
    Regular Contributor
    Join Date
    Jan 2008
    Location
    Edinburgh, UK
    Posts
    100

    Re: newbe need some help, background sms sending

    Kururu,

    I'm just a newbie too, but after a quick glance at your 'smssender.cpp' file, there isn't actually an include for "smssender.h".

    I'm not sure if that's what the problem is, or whether it's irrlevent.

    I'm new to Symbian C++ and relatively new to normal C++, so I have no idea if this piece of information is of any use, it's just something that cought my eye as I was reading through it.

    Andy.

  7. #7
    Registered User
    Join Date
    Feb 2008
    Posts
    17

    Re: newbe need some help, background sms sending

    thank's andy, i accidentally forgot to include the header file.
    unforthunally, adding it didnt solve the problem.
    dgaur, here is the source code of smscontainer.cpp -
    Code:
    /*
    ========================================================================
     Name        : smsContainerView.cpp
     Author      : f
     Copyright   : Your copyright notice
     Description : 
    ========================================================================
    */
    // [[[ begin generated region: do not modify [Generated System Includes]
    #include <aknviewappui.h>
    #include <eikappui.h>
    #include <sms.rsg>
    // ]]] end generated region [Generated System Includes]
    #include <smsuaddr.h>
    #include <smsustrm.h>
    #include <f32file.h>
    #include <aknnotewrappers.h>
    #include <gsmuset.h>
    #include <gsmupdu.h>
    #include <Gsmuelem.h>
    // [[[ begin generated region: do not modify [Generated User Includes]
    #include "smsContainer.h"
    #include "smsContainerView.h"
    #include "sms.hrh"
    #include "smssender.h"
    // ]]] end generated region [Generated User Includes]
    
    // [[[ begin generated region: do not modify [Generated Constants]
    // ]]] end generated region [Generated Constants]
    
    /**
     * First phase of Symbian two-phase construction. Should not 
     * contain any code that could leave.
     */
    CSmsContainer::CSmsContainer()
    	{
    	// [[[ begin generated region: do not modify [Generated Contents]
    	// ]]] end generated region [Generated Contents]
    	
    	}
    /** 
     * Destroy child controls.
     */
    CSmsContainer::~CSmsContainer()
    	{
    	// [[[ begin generated region: do not modify [Generated Contents]
    	// ]]] end generated region [Generated Contents]
    	
    	}
    				
    /**
     * Construct the control (first phase).
     *  Creates an instance and initializes it.
     *  Instance is not left on cleanup stack.
     * @param aRect bounding rectangle
     * @param aParent owning parent, or NULL
     * @param aCommandObserver command observer
     * @return initialized instance of CSmsContainer
     */
    CSmsContainer* CSmsContainer::NewL( 
    		const TRect& aRect, 
    		const CCoeControl* aParent, 
    		MEikCommandObserver* aCommandObserver )
    	{
    	CSmsContainer* self = CSmsContainer::NewLC( 
    			aRect, 
    			aParent, 
    			aCommandObserver );
    	CleanupStack::Pop( self );
    	return self;
    	}
    /**
     * Construct the control (first phase).
     *  Creates an instance and initializes it.
     *  Instance is left on cleanup stack.
     * @param aRect The rectangle for this window
     * @param aParent owning parent, or NULL
     * @param aCommandObserver command observer
     * @return new instance of CSmsContainer
     */
    CSmsContainer* CSmsContainer::NewLC( 
    		const TRect& aRect, 
    		const CCoeControl* aParent, 
    		MEikCommandObserver* aCommandObserver )
    	{
    	CSmsContainer* self = new ( ELeave ) CSmsContainer();
    	CleanupStack::PushL( self );
    	self->ConstructL( aRect, aParent, aCommandObserver );
    	return self;
    	}
    			
    /**
     * Construct the control (second phase).
     *  Creates a window to contain the controls and activates it.
     * @param aRect bounding rectangle
     * @param aCommandObserver command observer
     * @param aParent owning parent, or NULL
     */ 
    void CSmsContainer::ConstructL( 
    		const TRect& aRect, 
    		const CCoeControl* aParent, 
    		MEikCommandObserver* aCommandObserver )
    	{
    	if ( aParent == NULL )
    	    {
    		CreateWindowL();
    	    }
    	else
    	    {
    	    SetContainerWindowL( *aParent );
    	    }
    	iFocusControl = NULL;
    	iCommandObserver = aCommandObserver;
    	InitializeControlsL();
    	SetRect( aRect );
    	ActivateL();
    	// [[[ begin generated region: do not modify [Post-ActivateL initializations]
    	// ]]] end generated region [Post-ActivateL initializations]
    	
    	}
    			
    /**
    * Return the number of controls in the container (override)
    * @return count
    */
    TInt CSmsContainer::CountComponentControls() const
    	{
    	return ( int ) ELastControl;
    	}
    				
    /**
    * Get the control with the given index (override)
    * @param aIndex Control index [0...n) (limited by #CountComponentControls)
    * @return Pointer to control
    */
    CCoeControl* CSmsContainer::ComponentControl( TInt aIndex ) const
    	{
    	// [[[ begin generated region: do not modify [Generated Contents]
    	switch ( aIndex )
    		{
    		}
    	// ]]] end generated region [Generated Contents]
    	
    	// handle any user controls here...
    	
    	return NULL;
    	}
    				
    /**
     *	Handle resizing of the container. This implementation will lay out
     *  full-sized controls like list boxes for any screen size, and will layout
     *  labels, editors, etc. to the size they were given in the UI designer.
     *  This code will need to be modified to adjust arbitrary controls to
     *  any screen size.
     */				
    void CSmsContainer::SizeChanged()
    	{
    	CCoeControl::SizeChanged();
    	LayoutControls();
    	// [[[ begin generated region: do not modify [Generated Contents]
    			
    	// ]]] end generated region [Generated Contents]
    	
    	}
    				
    // [[[ begin generated function: do not modify
    /**
     * Layout components as specified in the UI Designer
     */
    void CSmsContainer::LayoutControls()
    	{
    	}
    // ]]] end generated function
    
    /**
     *	Handle key events.
     */				
    TKeyResponse CSmsContainer::OfferKeyEventL( 
    		const TKeyEvent& aKeyEvent, 
    		TEventCode aType )
    	{
    	// [[[ begin generated region: do not modify [Generated Contents]
    	
    	// ]]] end generated region [Generated Contents]
    	
    	if ( iFocusControl != NULL
    		&& iFocusControl->OfferKeyEventL( aKeyEvent, aType ) == EKeyWasConsumed )
    		{
    		return EKeyWasConsumed;
    		}
    	return CCoeControl::OfferKeyEventL( aKeyEvent, aType );
    	}
    				
    // [[[ begin generated function: do not modify
    /**
     *	Initialize each control upon creation.
     */				
    void CSmsContainer::InitializeControlsL()
    	{
    	
    	}
    // ]]] end generated function
    
    /** 
     * Handle global resource changes, such as scalable UI or skin events (override)
     */
    void CSmsContainer::HandleResourceChange( TInt aType )
    	{
    	CCoeControl::HandleResourceChange( aType );
    	SetRect( iAvkonViewAppUi->View( TUid::Uid( ESmsContainerViewId ) )->ClientRect() );
    	// [[[ begin generated region: do not modify [Generated Contents]
    	// ]]] end generated region [Generated Contents]
    	
    	}
    				
    /**
     *	Draw container contents.
     */				
    void CSmsContainer::Draw( const TRect& aRect ) const
    	{
    	// [[[ begin generated region: do not modify [Generated Contents]
    	CWindowGc& gc = SystemGc();
    	gc.Clear( aRect );
    	
    	// ]]] end generated region [Generated Contents]
    	
    	}
    CSmsContainer*    iSmsSender;   /// Make this as member of some class
    
    /// create this instance before sending out the SMS
    if (iSmsSender == NULL)
    {
    	     // starting the sender
             RSocketServ     mRSocketServer;
             RFs             mRFs;
    
             iSmsSender = SmsSender::NewL(mRSocketServer,mRFs);
             if (iSmsSender == NULL)
             {
                  return KN_FALSE;
             }
             iSmsSender->Open();
    }
    
    
    /// Use this method to send out the SMS
    TRAPD(err,lRetVal = iSmsSender->SendL(+972565565455, test));
    if(err!=KErrNone)
    {
    	//handle error
    }
    
    /// When you are done delete the instance of SmsSender
    if(iSmsSender)
    {
       delete iSmsSender;
       iSmsSender=NULL;
    }
    here is the exact error output -
    Code:
    declaration syntax error, location - line 231
    declaration syntax error, location - line 232
    declaration syntax error, location - line 238
    declaration syntax error, location - line 239
    declaration syntax error, location - line 243
    declaration syntax error, location - line 247
    declaration syntax error, location - line 248
    declaration syntax error, location - line 249
    declaration syntax error, location - line 251
    declaration syntax error, location - line 254
    declaration syntax error, location - line 255
    undefined identifier 'iSmsSender',location - line 237
    undefined identifier 'iSmsSender',location - line 242
    can somone please tell me whats wrong? im pretty stuck with my project because of this prob, please help me...
    Last edited by kururu; 2008-02-29 at 13:55.

  8. #8
    Registered User
    Join Date
    Feb 2008
    Posts
    17

    Re: newbe need some help, background sms sending

    Some updates -
    i added iSmsSender as a member variable in the smssender.h file,
    and tried to add the instance properly (i think) like this -
    Code:
    SmsSender* iSmsSender()
    {
    	if (iSmsSender == NULL)
    	{
    		     // starting the sender
    	         RSocketServ     mRSocketServer;
    	         RFs             mRFs;
    
    	         iSmsSender = SmsSender::NewL(mRSocketServer,mRFs);
    	         if (iSmsSender == NULL)
    	         {
    	              return KN_FALSE;
    	         }
    	         iSmsSender->Open();
    	}
    }
    instead of what i showed in my previous replay.
    when trying to compile, i get the following errors -
    declaration syntax error, line 252
    declaration syntax error, line 253
    declaration syntax error, line 254
    declaration syntax error, line 256
    declaration syntax error, line 259
    declaration syntax error, line 260
    expression syntax error, line 59 wich is -
    Code:
    iSmsSender->Open();
    not an lvalue error, at line 54 -
    Code:
    iSmsSender = SmsSender::NewL(mRSocketServer,mRFs);
    and undefined identifier 'KN_FALSE', at line 57.
    i assume that i managed to add iSmsSender as a member variable properly because now there are no errors caused by it.
    how do i register SmsSender as an L value?
    and why dosent it identify KN_FALSE?
    thank's alot!

  9. #9
    Regular Contributor
    Join Date
    May 2004
    Location
    Bangalore, India
    Posts
    118

    Re: newbe need some help, background sms sending

    Looks like you are new to programming also...
    Not sure what the above function means to you...But instead you have to do something like this....

    1. Add this line in your CSmsContainer class.
    Code:
    SmsSender* iSmsSender;
    2. Add following code in CSmsContainer::ConstructL() method

    Code:
    	
         if (iSmsSender == NULL)
    	{
    		     // starting the sender
    	         RSocketServ     mRSocketServer;
    	         RFs             mRFs;
    
    	         iSmsSender = SmsSender::NewL(mRSocketServer,mRFs);
    	         if (iSmsSender == NULL)
    	         {
    	              return false;
    	         }
    	         iSmsSender->Open();
    	}
    3. Add following code in CSmsContainer::~CSmsContainer() destructor
    Code:
    if(iSmsSender)
    {
       delete iSmsSender;
       iSmsSender=NULL;
    }
    4. Add a method in CSmsContainer class

    Code:
    void CSmsContainer::SendSMS(char* destination, char* smsText)
    {
      TRAPD(err,lRetVal = iSmsSender->SendL(destination, smsText));
      if(err!=KErrNone)
      {
    	//handle error
      }
    }
    I hope this should be ok for you...
    enjoy...
    Dushyant Gaur
    Sling Media,
    Bangalore
    cell:+91 9342276086
    email: dushyantg@slingmedia.com

  10. #10
    Registered User
    Join Date
    Feb 2008
    Posts
    17

    Re: newbe need some help, background sms sending

    thank's alot for all the help, i now realize i was really out of direction
    yes, im pretty new to programing itself - therefore i really appriciate all of you guys help, thanks again!
    dear dgaur, after i followed your last directions i got only three compiling errors -
    one coming from this code i added to my constructL method -
    Code:
    void CkkContainerView::ConstructL()
    	{
    	// [[[ begin generated region: do not modify [Generated Code]
    	BaseConstructL( R_KK_CONTAINER_KK_CONTAINER_VIEW );
    	// ]]] end generated region [Generated Code]
    	
        if (iSmsSender == NULL)
        	{
        		     // starting the sender
        	         RSocketServ     mRSocketServer;
        	         RFs             mRFs;
    
        	         iSmsSender = SmsSender::NewL(mRSocketServer,mRFs);
        	         if (iSmsSender == NULL)
        	         {
        	              return false;
        	         }
        	         iSmsSender->Open();
        	}
    	}
    the error is - "illegal return value in void/constructor/destructor function" coming from line 108 wich is "return false;".
    how can i properly create a return method \ value for this function?
    the second and third errors are -
    comes from the code -
    Code:
    void CkkContainerView::SendSMS(char* destination, char* smsText)
    	{
    	  TRAPD(err,lRetVal = iSmsSender->SendL(destination, smsText));
    	  if(err!=KErrNone)
    	  {
    		//handle error
    	  }
    	}
    (this code is in a file called kkContainerView.cpp file)
    "undefined identifier 'SendSMS'" that's coming from line 67 wich is SendSMS methods opening "{" (the one that's right above TRAPD in the code),
    and a "declaration syntax error" coming from line 253 wich is the closing "}" sign, the one that's right below "//handle error" in the code.
    any idea how can i solve this problems?
    if you need me to post the source codes for kkContainerView.cpp and kkContainerView.h just say so and i will post them.
    thank's alot again for the help - kururu!

  11. #11
    Regular Contributor
    Join Date
    May 2004
    Location
    Bangalore, India
    Posts
    118

    Re: newbe need some help, background sms sending

    Hi,

    I guess before jumping to Symbian, you need to refresh your programming skills...Anyways, regarding the errors you mentioned follow the instructions...

    1. Remove false from return statement of CkkContainerView::ConstructL() method.

    2. Add the following line in your kkContainerView.h as a member of your CkkContainerView class
    Code:
    void SendSMS(char* destination, char* smsText);
    Dushyant Gaur
    Sling Media,
    Bangalore
    cell:+91 9342276086
    email: dushyantg@slingmedia.com

  12. #12
    Registered User
    Join Date
    Feb 2008
    Posts
    17

    Re: newbe need some help, background sms sending

    im facing one last compiling error, i hope after this the sending would finally work -
    im getting an "undefined identifier 'lRetVal'" from line 249 in the cpp file, wich is -
    Code:
    TRAPD(err,lRetVal = iSmsSender->SendL(destination, smsText));
    that's apart of your code for the actual sending method.
    this is the source code of the kkContainerView header file -
    Code:
    #ifndef KKCONTAINERVIEW_H
    #define KKCONTAINERVIEW_H
    
    // [[[ begin generated region: do not modify [Generated Includes]
    #include <aknview.h>
    #include <smssender.h>
    
    class CKkContainer;
    
    class CkkContainerView : public CAknView
    	{
    public:
    	// constructors and destructor
    	CkkContainerView();
    	static CkkContainerView* NewL();
    	static CkkContainerView* NewLC();        
    	void ConstructL();
    public:
    	SmsSender* iSmsSender;
    	virtual ~CkkContainerView();
    public:
    	// from base class CAknView
    	TUid Id() const;
    	void HandleCommandL( TInt aCommand );
    
    protected:
    	// from base class CAknView
    	void DoActivateL(
    		const TVwsViewId& aPrevViewId,
    		TUid aCustomMessageId,
    		const TDesC8& aCustomMessage );
    	void SendSMS(char* destination, char* smsText);
    	void DoDeactivate();
    	void HandleStatusPaneSizeChange();
    	
    private:
    	void SetupStatusPaneL();
    	void CleanupStatusPane();
    	// [[[ begin generated region: do not modify [Generated Methods]
    public: 
    	// ]]] end generated region [Generated Methods]
    	
    	
    	// [[[ begin [Overridden Methods]
    protected: 
    	// ]]] end [Overridden Methods]
    	
    	
    	// [[[ begin [User Handlers]
    protected: 
    
    	// ]]] end [User Handlers]
    	
    	// [[[ begin generated region: do not modify [Generated Instance Variables]
    private: 
    	CKkContainer* iKkContainer;
    	// ]]] end generated region [Generated Instance Variables]
    	
    	};
    
    #endif // KKCONTAINERVIEW_H
    you can see i added SendSMS as apart of the CkkContainerView Class (iv'e highlighted the text in red).
    how can i fix this minor problem?
    is it because i might have implemented the SendSMS method wrong in the header file? (although i dont think so).
    if so, how can i implement it the right way?
    if not, how can i solve the problem?
    thank's alot again, you have no idea how much i appriciate it!

  13. #13
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,689

    Re: newbe need some help, background sms sending

    The usual approach is declaring variables prior to using them.

  14. #14
    Registered User
    Join Date
    Feb 2008
    Posts
    17

    Re: newbe need some help, background sms sending

    okay, thank's for the note - but how do i solve this problem?
    iv'e tried to declare SendSMS earlyer in the header file like this -
    Code:
    #ifndef KKCONTAINERVIEW_H
    #define KKCONTAINERVIEW_H
    
    #include <aknview.h>
    #include <smssender.h>
    
    class CKkContainer;
    
    class CkkContainerView : public CAknView
    	{
    	void SendSMS(char* destination, char* smsText);
    public:
    	// constructors and destructor
    	CkkContainerView();
    	static CkkContainerView* NewL();
    	static CkkContainerView* NewLC(); 
    	void ConstructL();
    public:
    	SmsSender* iSmsSender;
    	virtual ~CkkContainerView();
    public:
    	// from base class CAknView
    	TUid Id() const;
    	void HandleCommandL( TInt aCommand );
    
    protected:
    	// from base class CAknView
    	void DoActivateL(
    		const TVwsViewId& aPrevViewId,
    		TUid aCustomMessageId,
    		const TDesC8& aCustomMessage );
    	void DoDeactivate();
    	void HandleStatusPaneSizeChange();
    	
    private:
    	void SetupStatusPaneL();
    	void CleanupStatusPane();
    	// [[[ begin generated region: do not modify [Generated Methods]
    public: 
    	// ]]] end generated region [Generated Methods]
    	
    	
    	// [[[ begin [Overridden Methods]
    protected: 
    	// ]]] end [Overridden Methods]
    	
    	
    	// [[[ begin [User Handlers]
    protected: 
    	
    	// ]]] end [User Handlers]
    	
    	// [[[ begin generated region: do not modify [Generated Instance Variables]
    private: 
    	CKkContainer* iKkContainer;
    	// ]]] end generated region [Generated Instance Variables]
    	
    	};
    
    #endif // KKCONTAINERVIEW_H
    although i dont think it's relevant beacause in symbian c++ the lines order dosent matter if im not mistakin.
    so, how can i fix this?
    where should i implement the SendSMS method in the header file?
    or the error is really coming from a different place?
    thank's alot to all of you helpers!

  15. #15
    Regular Contributor
    Join Date
    May 2004
    Location
    Bangalore, India
    Posts
    118

    Re: newbe need some help, background sms sending

    Just before the line in cpp which is giving error, add this

    Code:
    bool lRetVal;
    Dushyant Gaur
    Sling Media,
    Bangalore
    cell:+91 9342276086
    email: dushyantg@slingmedia.com

Similar Threads

  1. SMS sending problem
    By jini_1 in forum Mobile Java General
    Replies: 1
    Last Post: 2006-10-13, 06:54
  2. Problem in sending SMS using VB
    By sylvia in forum General Messaging
    Replies: 0
    Last Post: 2006-09-27, 07:38
  3. Problem in sending SMS
    By sylvia in forum Symbian Networking & Messaging (Closed)
    Replies: 4
    Last Post: 2006-09-27, 07:06
  4. HELP! problem w/ sending and reading sms..
    By mauve928 in forum General Messaging
    Replies: 0
    Last Post: 2003-12-14, 19:10
  5. nokia 30: no response on sending SMS
    By itsmeamar in forum Nokia M2M
    Replies: 2
    Last Post: 2003-05-26, 10:20

Posting Permissions

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