×

Discussion Board

Results 1 to 3 of 3

Hybrid View

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    65

    CMsvEntry::ReadStoreL KErrNotFound

    Здравствуйте, нужно сохранить все входящие смс в файл. Делаю так -
    Code:
    void CSMSUtils::ReadInbox()
    {
            HBufC* SMSContent = HBufC::NewLC(400);
    	HBufC8* SMSContent8 = HBufC8::NewLC(400);
    
    	TMsvSelectionOrdering sort;
    	sort.SetShowInvisibleEntries(ETrue); // we want to handle also the invisible entries
    
    	CMsvEntry* inboxContext=CMsvEntry::NewL(*iSession,KMsvGlobalInBoxIndexEntryId,sort); // Reading Messages from Inbox Folder
    	CleanupStack::PushL(inboxContext);
    
    	CMsvEntrySelection* entries = inboxContext->ChildrenL();
    	CleanupStack::PushL( entries );
    
    	TInt msgCount= entries->Count();
    	__LOGSTR1("EntryCount: %d",msgCount);
    	for (TInt i=0; i<entries->Count(); i++)
    	{
    
    		TMsvId entryID = entries->At(i);
    		iSmsMtm->SwitchCurrentEntryL(entryID);
    
    		CMsvEntry* entry= iSession->GetEntryL((*entries)[i]);
    
    		CleanupStack::PushL(entry);
    
    
    		CMsvStore* inboxStore;
                    /* Skip loop if fail in obtains the message store */
    		TRAPD(r, inboxStore = entry->ReadStoreL());
    
    		if(KErrNone != r)
    		{
    			__LOGSTR("r!=KErrNone");
    			CleanupStack::PopAndDestroy(entry);
    			continue;
    		}
    
    		CleanupStack::PushL(inboxStore);
    		__LOGSTR2("Count: %d, HasBodyText: %d",i,inboxStore->HasBodyTextL());
    		if (inboxStore->HasBodyTextL())
    		{
                            TMsvEntry entry1 =  entry->Entry();
                            /* Gives you phone Number or Contact Name if Contact is present*/
    			TBufC<50>text(entry1.iDetails);
                            TBuf16<30> msg;
    			msg.Copy(_L("Name: "));
    			msg.Append(text);
    
                             /*If you want to get the Recipient Number, when iDetails gives you Contact's Name. */
                            iSmsMtm->LoadMessageL();
                            CSmsHeader& header = iSmsMtm->SmsHeader();
                            /* This will give you actual phone number irrespective of the name of contact*/
                            TPtrC from = header.FromAddress();
                            TBuf8<60> number;
    			number.Copy(_L("Number: "));
    			number.Append(from);
    
                           /* To read phone number from Sent Item folder, see the Note below */
    
    			CRichText& richText= iSmsMtm->Body();
    			inboxStore->RestoreBodyTextL(richText);
    			const TInt length = richText.DocumentLength();
    
                            /* Gives you actual content(Body) of SMS */
    			SMSContent->Des().Copy(richText.Read(0,length));
    			richText.Reset();
    
    			SMSContent8->Des().Copy(SMSContent->Des());
    
                             /* Write SMS Body in the SMSBody.txt file*/
    			//WriteToFile(SMSContent8->Des());
    
                            /* Write SMS Body, number and contact name in file*/
                            WriteToFile(msg, number,SMSContent8->Des());
    		}
    		else
    		{
    		// no text in SMS
    		}
    		CleanupStack::PopAndDestroy(2,entry);
    	}
    	CleanupStack::PopAndDestroy(4,SMSContent);
    }
    По сути это пример из вики.
    В итоге из 42-х смсок сохраняет только две, в остальных 40 случаях функция entry->ReadStoreL() возвращает -1.
    Из library:
    KErrNotFound - There is no store associated with this entry
    В чём юмор? Смски-то вроде как все одинаковые.
    Зы. По форуму искал, но не нашёл

  2. #2
    Registered User
    Join Date
    Mar 2009
    Posts
    65

    Re: CMsvEntry::ReadStoreL KErrNotFound

    В принципе решил как-то так:
    Code:
    CMsvEntry* pMsvEntry = iSession->GetEntryL(KMsvGlobalInBoxIndexEntryId);
        TBuf8<256> buf;
        for(TInt i=0;i<pMsvEntry->Count();i++)
    	{
    
    	buf.Append((*pMsvEntry)[i].iDetails);
    	buf.Append((*pMsvEntry)[i].iDescription);
            .......
    	}
    Но ведь это не всё сообщение. Вопрос открыт в общем
    Last edited by SQR; 2010-12-20 at 10:50.

  3. #3
    Registered User
    Join Date
    Sep 2009
    Posts
    33

    Re: CMsvEntry::ReadStoreL KErrNotFound

    Порядок действий примерно такой:

    CMsvEntry *entry = iMsvSession->GetEntryL((*entries)[i]);
    if (entry)
    {
    CleanupStack::PushL(entry);
    if (entry->Entry().iMtm == KUidMsgTypeSms)
    {
    iSmsMtm->SwitchCurrentEntryL(entryID);
    iSmsMtm->LoadMessageL();
    iSmsMtm->SmsHeader().Message().Buffer(); // текст sms
    iSmsMtm->SmsHeader().FromAddress();
    }
    CleanupStack::PopAndestroy(entry);
    }

    Писал по памяти, код может не заработать сразу.

Similar Threads

  1. CMsvEntry ReadStoreL throws KErrAccessDenied
    By lokesh_kumar_s in forum Symbian C++
    Replies: 8
    Last Post: 2010-10-30, 20:34
  2. CMsvEntry error
    By andreip in forum Symbian C++
    Replies: 3
    Last Post: 2009-06-21, 23:31
  3. CSmsMessage to CMsvEntry
    By beltry in forum Symbian Networking & Messaging (Closed)
    Replies: 5
    Last Post: 2009-03-25, 12:00
  4. Help! I cannot destory CMsvEntry object.
    By autumnsea in forum Symbian Networking & Messaging (Closed)
    Replies: 5
    Last Post: 2006-10-08, 16:41
  5. Problem of Destorying CMsvEntry, thank you:D
    By autumnsea in forum Web Technologies and Multimedia Content- Web 技术和多媒体内容
    Replies: 3
    Last Post: 2006-10-08, 08:49

Posting Permissions

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