×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User
    Join Date
    Sep 2012
    Location
    Bandung, Indonesia
    Posts
    27

    Lightbulb Trouble with Accessing CMsvStore

    Hi,
    This has been driving me (a complete newbie) really nuts for the last couple of days. CMsvStore seemed to be inaccessible as it resulted in my app leaving everytime it got notified of a new message. Please shed a light on this code snippet.

    Code:
    if (iSmsMtm->Entry().HasStoreL()) //This seems to be OK, on the device I could obtain the log statement that it does have stores.
    {
        //The following two uncommented lines seem to be the culprit
        CMsvStore* store;
        store = iMsvEntry->ReadStoreL();  //Previously I used "CMsvStore* store = iMsvEntry->ReadStoreL()", but then I changed it when I added a log to find out which parts of the code actually went wrong
        CleanupStack::PushL(store);
        //Some other lines...
        CleanupStack::PopAndDestroy(store);
        //Blah blah blah...
    }
    Thanks a million in advance...

    Best regards

    EDITED: Just installed Panic Observer and at the time of noticing the panic in my app, it informed me that the reason was: USER-11 (Categori: USER; Reason: 11; Status: -13), but I was a bit wondering why it *probably* didn't match the criterion as mentioned here and here.
    Last edited by asepm; 2012-09-07 at 05:53. Reason: More details

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

    Re: Trouble with Accessing CMsvStore

    You could check SDK docs, it states that the reason for this panic is This panic is raised when any operation that moves or copies data to a 16-bit variant descriptor, causes the length of that descriptor to exceed its maximum length., so do check your descriptor usage.

  3. #3
    Registered User
    Join Date
    Sep 2012
    Location
    Bandung, Indonesia
    Posts
    27

    Re: Trouble with Accessing CMsvStore

    Quote Originally Posted by symbianyucca View Post
    You could check SDK docs, it states that the reason for this panic is This panic is raised when any operation that moves or copies data to a 16-bit variant descriptor, causes the length of that descriptor to exceed its maximum length., so do check your descriptor usage.
    Thank you for your prompt reply. However, please let me know the most possible cause, because as per my code, there is no descriptor involved. There are several other lines of codes, for sure, but all of them are commented out, which I did not produce here. Please let me know if there might be a workaround to solve this troubled code.

    Any help is greatly appreciated.
    Last edited by asepm; 2012-09-07 at 08:53.

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

    Re: Trouble with Accessing CMsvStore

    Quote Originally Posted by asepm View Post
    Thank you for your prompt reply. However, please let me know the most possible cause, because as per my code, there is no descriptor involved. There are several other lines of codes, for sure, but all of them are commented out, which I did not produce here. Please let me know if there might be a workaround to solve this troubled code.
    Basically, if it is really USER 11, and nothing else , then I would suggest that you debug and find the exact line that causes the panic. It is simply a buffer overrun, i.e. in some point there is a line which is trying to put too long string into a descriptor.

  5. #5
    Registered User
    Join Date
    Sep 2012
    Location
    Bandung, Indonesia
    Posts
    27

    Re: Trouble with Accessing CMsvStore

    Quote Originally Posted by symbianyucca View Post
    Basically, if it is really USER 11, and nothing else , then I would suggest that you debug and find the exact line that causes the panic. It is simply a buffer overrun, i.e. in some point there is a line which is trying to put too long string into a descriptor.
    I'll try to debug it, though I don't know how to debug a messaging-related app on the emulator yet (maybe you can tell me how to use the emulator for debugging an sms app. I've searched "all over" this site but to no avail). I'll let you know the outcome if I can debug it. Thanks so much, Dr. Jukka. BTW, I've downloaded your Y-Tasks and Y-Browser as well. It leaves me wondering how I, a total beginner, can create such excellent apps.

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

    Re: Trouble with Accessing CMsvStore

    Emulator would do no good really, since it is likely that it works differently. So I would suggest adding some file logging code, and running it in a real device. Then with few iterations, you should be able to point out the last line called before the panic happens. Also do remember to log any returned error codes, to see whether there are errors before the panic occurs.

  7. #7
    Registered User
    Join Date
    Sep 2012
    Location
    Bandung, Indonesia
    Posts
    27

    Re: Trouble with Accessing CMsvStore

    Quote Originally Posted by symbianyucca View Post
    Emulator would do no good really, since it is likely that it works differently. So I would suggest adding some file logging code, and running it in a real device. Then with few iterations, you should be able to point out the last line called before the panic happens. Also do remember to log any returned error codes, to see whether there are errors before the panic occurs.
    In fact, like I said, that was exactly what I did: I created a logging file, a text file which produced lines of statements (typed just above whatever code in that function, i.e. MessageReceivedL()). The application always stopped writing the lines right there, at the line where CMsvStore object creation was placed. Please do me a favour, as I'm at my wit's end now.

    The full code on that function is as follows.

    Code:
    void CSmsHandler::MessageReceivedL( TMsvId aEntryId )
        {
    	RFs fs;
    	RFile file;
    	TFileText fileteks;
    
    	_LIT(KNamaFile, "C:\\Data\\Log.txt");
    	User::LeaveIfError(fs.Connect());
    	CleanupClosePushL(fs);
    	TInt err = file.Open(fs, KNamaFile, EFileStreamText|EFileWrite);
    	CleanupClosePushL(file);
    	if (err == KErrNotFound) err=file.Create(fs, KNamaFile, EFileStreamText|EFileWrite);
    	fileteks.Set(file);
            fileteks.Write(_L("fileteks di-set (melalui \"file\")\r\n"));
    	fileteks.Write(_L("Log dimulai...\r\n"));
    
    	fileteks.Write(_L("entry = iMsvEntry->Entry();\r\n"));
    	entry = iMsvEntry->Entry();
    	
    	fileteks.Write(_L("entry.SetNew( ETrue );\r\n"));
    	entry.SetNew( ETrue );
    	fileteks.Write(_L("entry.SetUnread( ETrue );\r\n"));
            entry.SetUnread( ETrue );
            fileteks.Write(_L("entry.SetVisible( ETrue );\r\n"));
            entry.SetVisible( ETrue );
        
            fileteks.Write(_L("iMsvEntry->ChangeL(entry);\r\n"));
            iMsvEntry->ChangeL(entry);
     
            fileteks.Write(_L("iSmsMtm->SwitchCurrentEntryL(aEntryId);\r\n"));
            iSmsMtm->SwitchCurrentEntryL(aEntryId);
            fileteks.Write(_L("iSmsMtm->LoadMessageL();\r\n"));
            iSmsMtm->LoadMessageL();
        
            fileteks.Write(_L("CSmsHeader& header = iSmsMtm->SmsHeader();\r\n"));
            CSmsHeader& header = iSmsMtm->SmsHeader();	
            fileteks.Write(_L("TTime waktu = header.Message().Time();\r\n"));
            TTime waktu = header.Message().Time();
        
            //TBuf<30> KWaktu;
            //_LIT(KFormatWaktu, "%D%M%Y%/0%1%/1%2%/2%3%/3");
    	
            _LIT(KPemisah, "<*>");
        
            //waktu.FormatL(KWaktu, KFormatWaktu);
    
            fileteks.Write(_L("TBuf<50> KWaktu = FormatTanggalWaktu(waktu);\r\n"));
    	TBuf<50> KWaktu = FormatTanggalWaktu(waktu);
    
    	fileteks.Write(_L("TPtrC from = header.FromAddress();\r\n"));
    	TPtrC from = header.FromAddress();
    	fileteks.Write(_L("const TDesC& phoneNumber = from;\r\n"));
    	const TDesC& phoneNumber = from;
        
    	fileteks.Write(_L("HBufC* KPesan=HBufC::NewL(KWaktu.Length());\r\n"));
    	HBufC* KPesan = HBufC::NewL(KWaktu.Length());
    	fileteks.Write(_L("CleanupStack::PushL(KPesan);\r\n"));
    	CleanupStack::PushL(KPesan);
    	fileteks.Write(_L("KPesan->Des().Copy(KWaktu);\r\n"));
    	KPesan->Des().Copy(KWaktu);
        
    	fileteks.Write(_L("TPtr ptr(KPesan->Des());\r\n"));
    	TPtr ptr(KPesan->Des());
    	fileteks.Write(_L("ptr.Append(KPemisah);\r\n"));
    	ptr.Append(KPemisah);
    	fileteks.Write(_L("ptr.Append(phoneNumber);\r\n"));
    	ptr.Append(phoneNumber);
        
    	fileteks.Write(_L("if (iSmsMtm->Entry().HasStoreL())\r\n"));
    	if (iSmsMtm->Entry().HasStoreL())
    	{
    	        fileteks.Write(_L("Punya toko lho...\r\n"));
    		
    	        //fileteks.Write(_L("CMsvStore* store = iMsvEntry->ReadStoreL();\r\n"));
    		//CMsvStore* store = iMsvEntry->ReadStoreL();
    		
    	        // *** The application always stopped writing any more lines right here ***
                    fileteks.Write(_L("CMsvStore* store;\r\n"));
    		CMsvStore* store;
    		fileteks.Write(_L("store = iMsvEntry->ReadStoreL();"));
    		store = iMsvEntry->ReadStoreL();		
    		fileteks.Write(_L("CleanupStack::PushL(store);\r\n"));
    		CleanupStack::PushL(store);
    
                    //TInt kesalahan;
    		fileteks.Write(_L("TRAPD(kesalahan, store = iMsvEntry->ReadStoreL();\r\n"));
    		TRAPD(kesalahan, store = iMsvEntry->ReadStoreL());
    		if (kesalahan != KErrNone)
    		{
    			//fileteks.Write(_L("delete store;\r\n"));
    			//delete store;
                            fileteks.Write(_L("CleanupStack::PopAndDestroy(store);\r\n"));
                            CleanupStack::PopAndDestroy(store);
    			fileteks.Write(_L("Ada kesalahan mengakses store...\r\n"));
    			SimpanDataSmsL(ptr);
    			fileteks.Write(_L("Log selesai. Ada kesalahan!"));
    			fileteks.Write(_L("file.Close();"));
    			file.Close();
    			CleanupStack::PopAndDestroy(&file);
    			fs.Close();
    			CleanupStack::PopAndDestroy(&fs);
    			CleanupStack::PopAndDestroy(store);
    			return;
    		}
    		
    		/// --- The lines below are actually all commented out...
    		/*
    		if (store->HasBodyTextL())
    		{
    			fileteks.Write(_L("CRichText& richText = iSmsMtm->Body();\r\n"));
    			CRichText& richText = iSmsMtm->Body();	
    			fileteks.Write(_L("store->RestoreBodyTextL(richText);\r\n"));
    			store->RestoreBodyTextL(richText);
    			fileteks.Write(_L("TInt PanjangTeks = richText.DocumentLength();\r\n"));
    			TInt PanjangTeks = richText.DocumentLength();
    		    
    			fileteks.Write(_L("RBuf KIsiSMS;\r\n"));
    			RBuf KIsiSMS;
    			fileteks.Write(_L("KIsiSMS.CleanupClosePushL();\r\n"));
    			KIsiSMS.CleanupClosePushL();
    			fileteks.Write(_L("KIsiSMS.CreateL(10));\r\n"));
    			KIsiSMS.CreateL(10);
    			fileteks.Write(_L("KIsiSMS.ReAlloc(PanjangTeks);\r\n"));
    			KIsiSMS.ReAlloc(PanjangTeks);
    			fileteks.Write(_L("richText.Extract(KIsiSMS, 0, PanjangTeks);\r\n"));
    			richText.Extract(KIsiSMS, 0, PanjangTeks);
    			richText.Reset();
    		    
    			fileteks.Write(_L("KPesan->ReAllocL(KWaktu.Length() + KPemisah().Length() + phoneNumber.Length() + KPemisah().Length() + PanjangTeks);\r\n"));
    			KPesan->ReAllocL(KWaktu.Length() + KPemisah().Length() +
    					phoneNumber.Length() + KPemisah().Length() + PanjangTeks);
    			fileteks.Write(_L("CleanupStack::Pop(KPesan);\r\n"));
    			CleanupStack::Pop(KPesan);
    			fileteks.Write(_L("CleanupStack::PushL(KPesan);\r\n"));
    			CleanupStack::PushL(KPesan);
    		        
    			fileteks.Write(_L("ptr.Append(KPemisah);\r\n"));
    			ptr.Append(KPemisah);
    			fileteks.Write(_L("ptr.Append(KIsiSMS);\r\n"));
    			ptr.Append(KIsiSMS);
    			fileteks.Write(_L("CleanupStack::PopAndDestroy(&KIsiSMS);\r\n"));
    			CleanupStack::PopAndDestroy(&KIsiSMS);
    		        
    			fileteks.Write(_L("SimpanDataSmsL(ptr);\r\n"));
    			SimpanDataSmsL(ptr);
    		        
    			//CleanupStack::PopAndDestroy(&entry);		    	
    			fileteks.Write(_L("CleanupStack::PopAndDestroy(KPesan);\r\n"));
    			CleanupStack::PopAndDestroy(KPesan);
    		}
    		//fileteks.Write(_L("delete store;\r\n"));
    	        //delete store;
                    fileteks.Write(_L("CleanupStack::PopAndDestroy(store);\r\n"));
                    CleanupStack::PopAndDestroy(store);
                   */
                   ///
    	}
    	else
    	{
    	       fileteks.Write(_L("Kagak punya toko kok.\r\n"));
    	}
        
    	fileteks.Write(_L("Log selesai...\r\n"));
            fileteks.Write(_L("file.Close();"));
    	file.Close();
    	CleanupStack::PopAndDestroy(&file);
            fs.Close();
    	CleanupStack::PopAndDestroy(&fs);
        }
    Last edited by asepm; 2012-09-07 at 11:16.

  8. #8
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,698

    Re: Trouble with Accessing CMsvStore

    You can check the menu of the emulator if it contains some items for emulating message receival. And there is an old way too: send an SMS with the built in Messages application (you can use any number for recipient and message center), then a file message0.sms will appear in epoc32\smsout. If you copy it to epoc32\smsin, it is going to be delivered to Inbox (though it will still have a "To:" header, so it is not a 100% delivery). It works for S60 emulators at least (I have not tried with Symbian^3/Belle).

    Side note: if you are logging this stuff "live", from HandleSessionEventL, note that message arrival issues at least two events: EMsvEntriesCreated means that a new, empty entry has been created. It might have no store that time (as I remember there is a HasStoreL method to check, but that can leave/panic too sometimes). EMsvEntriesChanged is the event when there is usually something in the messages. And actually TMsvEntry::Complete can tell when a message is finalized.
    Last edited by wizard_hu_; 2012-09-07 at 11:35.

  9. #9
    Registered User
    Join Date
    Sep 2012
    Location
    Bandung, Indonesia
    Posts
    27

    Re: Trouble with Accessing CMsvStore

    Wow, I am honored to receive replies from two experts I've seen this week: symbianyucca and wizard_hu. Looking forward to Kiran's advices too someday. Thanks so much, wizard. Gotta give it a try. Actually I've been curious about debugging sms apps on the emulator, and I'm planning to combine this "trivial" SMS Engine with Call Logs (Telephony). Honestly, the reason why I'm playing around with this kind of apps is because I used Daddy's Eye but I could monitor the logs on HER phone only for 4 days so I decided to make a similar app for myself. Thank you.
    Last edited by asepm; 2012-09-07 at 13:17.

  10. #10
    Registered User
    Join Date
    Sep 2012
    Location
    Bandung, Indonesia
    Posts
    27

    Re: Trouble with Accessing CMsvStore

    This problem was perfectly solved, by NOT using CMsvStore... Thanks, symbianyucca & wizard_hu, anyway!

Similar Threads

  1. How to close CMsvStore ?
    By siemensc55 in forum Symbian Networking & Messaging (Closed)
    Replies: 11
    Last Post: 2012-08-21, 08:28
  2. Trouble Accessing web applications
    By Tonata1988 in forum General Development Questions
    Replies: 1
    Last Post: 2009-06-17, 11:38
  3. JSR-82 trouble
    By dgcrouse in forum Mobile Java General
    Replies: 0
    Last Post: 2009-06-15, 17:19
  4. trouble please help
    By Mkekill in forum General Development Questions
    Replies: 5
    Last Post: 2008-10-11, 18:48
  5. Trouble with the SMS example in s60 sdk
    By cormen in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2004-01-04, 19:21

Posting Permissions

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