×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Regular Contributor
    Join Date
    Dec 2007
    Location
    Bangkok
    Posts
    55

    Question Create Message server session?

    Hi,

    I am dealing with message handle app. I try to merge it to my app.

    My problem is how to create session. Unlike to below code, I would like to create Msv session without creating the object from the class CTaskManagerConnectionOpenner because this class is blended into engine class in my app.

    Code:
    User::LeaveIfError(iSockServ.Connect());
    User::LeaveIfError(iConnection.Open(iSockServ));
    iConnOpener = CTaskManagerConnectionOpener::NewL(iConnection,*this);
    iMsvSession = CMsvSession::OpenAsyncL(*this);
    Please tell me how to create some object rather than "*this" for the argument of OpenAsyncL().

    Thank you for your idea
    Best regards,
    KK
    Last edited by kittinut_k; 2008-02-19 at 17:58. Reason: add info

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,674

    Re: Create Message server session?

    You may consider reading about the argument of OpenSyncL/OpenAsyncL in the SDK Help.

  3. #3
    Regular Contributor
    Join Date
    Dec 2007
    Location
    Bangkok
    Posts
    55

    Re: Create Message server session? + How to test on emulator?

    Thank you,

    I have read SDK help, but I do not sure that the meaning of argument "MMsvSessionObserver": A reference to a session observer, through which the program can be notified of important events regarding entries, MTMs, and the Message Server.

    If I apply this on AppUi, can I use the instance of AppEngine to be observer?
    After testing on device, there is no response with the message. ( I would like my app to response to the specific message by using EMsvEntriesCreated on HandleSessionEventL)
    I think that it is caused by AppEngine class is not belonged to CActive. Please tell me whether the instance should be the CActive or not.

    Moreover ,please let me know how to test on Emulator?

    Thank you

    Kittinut K.
    Last edited by kittinut_k; 2008-02-20 at 05:13. Reason: add info

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,674

    Re: Create Message server session? + How to test on emulator?

    Some C++ might be also handy indeed.
    So: yes, you can pass any object (or dereferenced pointer as *something - so *this is also a simple dereferenced pointer) which implements the MMsvSessionObserver interface (has "public MMsvSessionObserver", and declares+defines the HandleSessionEventL method).

  5. #5
    Regular Contributor
    Join Date
    Dec 2007
    Location
    Bangkok
    Posts
    55

    Re: Create Message server session?

    Hi,

    Now, my app is still not respond to the SMS. I used object of ConnOpener class(GPRS connection class) to be an argument of MsvSession rather than object of Engine class. I think there is some mistake in my code. Please guide me how to solve this.

    The Constructor

    Code:
    CClientEngine* CClientEngine::NewL()
    	{
    	CClientEngine* self = new (ELeave) CClientEngine;
        CleanupStack::PushL(self);
        self->ConstructL();
        CleanupStack::Pop(self);
        return self;
    	}
    
    void CClientEngine::ConstructL()
    	{
    	iRunning = EFalse;
        iPostData = NULL;
        //open socket server and start the connection
        User::LeaveIfError(iSocketServ.Connect());
        User::LeaveIfError(iConnection.Open(iSocketServ));
    	iConnOpener = CClientConnectionOpener::NewL(iConnection,*this);
    	iMsvSession = CMsvSession::OpenAsyncL(*this);
    	
        iAppContainer2 = new (ELeave) CClientContainer2;
        iAppContainer2->SetMopParent( this );
        iAppContainer2->ConstructL( ClientRect() );
        CCoeAppUi::AddToStackL( iAppContainer2 );
        iImageLoaded = EFalse;
        iConverter2 = CClientImageEngine::NewL( this);
    	// Open RHTTPSession with default protocol ("HTTP/TCP")
    	TRAPD(err, iSession.OpenL());
    	if(err != KErrNone) 
    		{
    		// Most common error; no access point configured, and session creation
    		// leaves with KErrNotFound.
    		_LIT(KErrMsg,"Cannot create session. Is internet access point configured?");
    		_LIT(KExitingApp, "Exiting app.");
    		CEikonEnv::Static()->InfoWinL(KErrMsg, KExitingApp);
    		User::Leave(err);
    		}
    	InstallAuthenticationL(iSession);
    The SMS Handling function

    Code:
    void CClientEngine::HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* /*aArg3*/)
    	{
    	switch (aEvent)
    		{
    		case EMsvServerReady:
    			if (!iMsvEntry)
    				{
    iMsvEntry = CMsvEntry::NewL(*iMsvSession, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering());
    				}
    			break;
    			
    		case EMsvEntriesCreated:
    			if (*(static_cast<TMsvId*>(aArg2)) == KMsvGlobalInBoxIndexEntryId)
    {CMsvEntrySelection* entries = static_cast<CMsvEntrySelection*>(aArg1);
    
    	iMsvEntry->SetEntryL(entries->At(0));
    	TMsvEntry msvEntry(iMsvEntry->Entry());
    	msvEntry.SetVisible(EFalse);
    	CClientMtmRegistry* mtmReg = CClientMtmRegistry::NewL(*iMsvSession);
    	CleanupStack::PushL(mtmReg);
    	CBaseMtm* smsMtm = mtmReg->NewMtmL(msvEntry.iMtm);
    	smsMtm->SwitchCurrentEntryL(entries->At(0));
    	smsMtm->LoadMessageL();
            TBool CorrectSms = EFalse;
    	// Correct sms content
    	if (smsMtm->Body().Read(0,KSmsUpdateMessage().Length()).Compare(KSmsUpdateMessage)==0)
            {msvEntry.SetVisible(ETrue);
    	CorrectSms = ETrue;
    	}
    	// incorrect sms content.
    	else
            {
    	msvEntry.SetVisible(ETrue);
    	}		
    	iMsvEntry->ChangeL(msvEntry);
    	CleanupStack::PopAndDestroy(smsMtm);
    	// if received SMS was correct.
    		if (CorrectSms)
    			{
    			iMode=2;
    	// if an HTTP transaction is running or program is in the background or busy. 
            // Don't fetch tasks yet.
    			if (iRunning)
    			{
    			break;
    			}
    		// HTTP transaction is not running, fetch tasks.
    			else
    			{
    			TBuf8<KDefaultBufferSize> uri;
    			_LIT(KUri,"http://stweb.ait.ac.th/%7est105000/ISE-20080131-233225.jpg");
    			uri.Append(KUri);
    			IssueHTTPGetL(uri,iMode);
    						}
    					}
    				}
    			break;
    			default:
    			break;	}}
    Best regards,

    Kittinut K.
    Last edited by kittinut_k; 2008-02-20 at 17:58. Reason: add info

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,674

    Re: Create Message server session?

    It is discussed several times and shown in every single example:
    - on EMsvEntriesCreated you do not have the message, the only thing you can do is storing the id of the new message
    - then on EMsvEntriesChanged you can verify that the new message is changed (without verification you could reparse an older message which has already been there, but is edited for example), and extract its contents.

    If you know the way of sending messages (SMS for example) with the MTM-based approach you can easily recognize why: when CMsvEntry::CreateL is invoked, there is no message at all, only a TMsvEntry object is filled, but it is usually filled partially (no sender and subject for example). And this CreateL triggers the EMsvEntriesCreated event for you. However after creating the message it is usually filled, then comes a CMsvEntry::ChageL, which actually triggers EMsvEntriesChanged. By that time the message contents are ready and you can extract them.

  7. #7
    Regular Contributor
    Join Date
    Dec 2007
    Location
    Bangkok
    Posts
    55

    Question Re: Create Message server session?

    Thank you for your kindly clear answer.

    Now, I try using this:
    http://wiki.forum.nokia.com/index.php/SMS_Receiver

    , but I found the time consuming problem.
    (I am sorry to ask you too much, but I try to solve it all of the afternoon, but can not finish it.)
    There are 3 errors.

    The first is that:
    illegal use of abstract class('MMsvSessionObserver::HandleSessionEventL(MMsvSessionObserver::TMsvSeesionEvent,void *,void *, void *)

    It is not the member function of MMsvSessionObserver, but why it emerge the error on the red code below.

    Code:
    CClientEngine* CClientEngine::NewL()
    	{
        CClientEngine* self = new (ELeave) CClientEngine;
        CleanupStack::PushL(self);
        self->ConstructL();
        CleanupStack::Pop(self);
        return self;
    	}
    The second and third is:
    'MSMSRecCallBack&' (or 'MSMSRecCallBack*' when I change the argument type)
    and
    'illegal implicit conversion from 'CClientEngine *' to

    (I think it may be: 'illegal implicit conversion from 'CClientEngine *' to 'MSMSRecCallBack*')

    It occur on the red line in the following cod.

    Code:
    void CClientEngine::ConstructL()
    	{
    	CSMSReceiver::NewL(this);
    -----
    }
    Moreover, when I replace the code to Constructor of AppUi as the red line, the first problem is disappeared.

    Code:
     iClient = CClientEngine::NewL();
        CSMSReceiver::NewL(&iClient);

    Please recommend the way to solve them.

    Thank you,
    Kittinut K.

    Remark
    The declaration of CSMSReceiver object is:
    static CSMSReceiver* NewL(MSMSRecCallBack& aObserver);

    The declaration of MSMSRecCallBack object is:
    MSMSRecCallBack& iObserver;
    Last edited by kittinut_k; 2008-02-21 at 14:58. Reason: add more info

  8. #8
    Regular Contributor
    Join Date
    Dec 2007
    Location
    Bangkok
    Posts
    55

    Lightbulb Re: Create Message server session?

    Hi,

    Six hours problem for 'illegal implicit conversion from 'CClientEngine *' to 'MSMSRecCallBack*' is that the class MSMSRecCallBack is missed in the position of base class of the observer class.


    Thank you very much for wizard_hu's help

    Best regards,

    Kittinut K.
    Remark
    I would like to inform the solution so that somebody can search this thread and there is no need to post the same question.

Similar Threads

  1. carbide-error
    By upendersolanki in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 5
    Last Post: 2008-02-06, 11:09
  2. Replies: 10
    Last Post: 2008-02-01, 20:20
  3. server to client message passing
    By sandy_zeng in forum Symbian
    Replies: 1
    Last Post: 2007-10-14, 11:44
  4. Problem with Cabride.c++ v1.1
    By markovuksanovic in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 3
    Last Post: 2007-01-24, 20:05
  5. how to create a m-retrive-conf mms message
    By lamng.gz in forum General Messaging
    Replies: 1
    Last Post: 2006-06-16, 05:36

Posting Permissions

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