×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Dec 2005
    Location
    Finland
    Posts
    109

    How to get attachment without AllFiles

    Hi,

    Please excuse me for posting this again, but I really need to know how to get attachement in S60 3rd without using AllFiles capability?

    Thanks

  2. #2
    Registered User
    Join Date
    Nov 2005
    Location
    Berlin, Germany
    Posts
    48

    Re: How to get attachment without AllFiles

    I want to know that too. Is this possible at all?

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

    Re: How to get attachment without AllFiles

    Yes, search for MMsvAttachmentManager in the help.

  4. #4
    Regular Contributor
    Join Date
    Aug 2004
    Location
    East Coast, USA
    Posts
    192

    Re: How to get attachment without AllFiles

    via MMsvAttachmentManager I can get an open RFile to the attachment. Am I then supposed to copy this to a non private location, then I also would have to take care of that temp file once the user is done viewing the attachment. If i just take the rfile and try to call RApaLsSession StartDocument() I am getting a "Already in Use" warning back.
    What is the intended procedure of viewing an attachment on s603 ?

    regards,

    -Blizzz

  5. #5
    Registered User
    Join Date
    Apr 2006
    Posts
    1

    Re: How to get attachment without AllFiles

    Probably because this RFile is read-only, so you need copy it to other location.

  6. #6
    Registered User
    Join Date
    Dec 2005
    Location
    Finland
    Posts
    109

    Re: How to get attachment without AllFiles

    Ok,
    Here is my solution, like it or not =)

    Find's .sis file from inbox which has mach to KMachSis literal and is received via BT. Also it's newest file which maches KMachSis. When file is found it's copied to C:\data so that it can be send forward. Sorry for poor commenting.

    Code:
    
    		CMsvSession* session = CMsvSession::OpenSyncL(*this);
    		if(session)
    		{
    			TMsvSelectionOrdering sort;
    			sort.SetShowInvisibleEntries(ETrue);
    			sort.SetSorting(EMsvSortByDate);
    			// Take a handle to the folder entry
    			CMsvEntry* parentEntry = CMsvEntry::NewL(*session,KMsvGlobalInBoxIndexEntryId, sort);
    			CleanupStack::PushL(parentEntry);
    			// A selection of all BT entries
    			CMsvEntrySelection* entries = parentEntry->ChildrenWithMtmL(KUidMsgTypeBt);
    			CleanupStack::PushL(entries);
    			
    			
    			//Process all entries
    			for(TInt i = 0; i < entries->Count(); i++)
    			{
    				//Get entry
    				CMsvEntry* btEntry = session->GetEntryL((*entries)[i]);
    				CleanupStack::PushL(btEntry);
    				//Then get entrys child
    				CMsvEntrySelection* btChildren = btEntry->ChildrenL();
    				CleanupStack::PushL(btChildren);
    				
    				TInt childc = btChildren->Count();
    				if (childc>0)
    				{
    					for(TInt i=0; i<childc; i++)
    					{
    						TMsvId btAtt = (*btChildren)[i];
    						btEntry->SetEntryL(btAtt);
    					
    						if (btEntry->HasStoreL())
    						{
    							CMsvStore* store = btEntry->ReadStoreL();
    							CleanupStack::PushL(store);
    
    							MMsvAttachmentManager& attMngr = store->AttachmentManagerL();
    							TInt attcount = attMngr.AttachmentCount();
    							for(TInt j=0; j<attcount; j++)
    							{
    								CMsvAttachment* attachment = attMngr.GetAttachmentInfoL(j);
    								if(attachment->AttachmentName().Match(KMatchSis))
    								{
    									
    									RFile file = attMngr.GetAttachmentFileL(j);
    									TInt size;
    									file.Size(size);
    									
    									TFileName copyfileName;
    									copyfileName.Copy( _L("C:\\Data\\application.sis_"));
    									RFile toFile;
    									RFs iSession;
    									iSession.Connect();
    									TInt delerr = iSession.Delete(copyfileName);
    									if(delerr == KErrNotFound || delerr == KErrNone)
    									{
    										toFile.Create(iSession,copyfileName,EFileWrite);
    										HBufC8* bufferDes = NULL;
    										bufferDes = HBufC8::NewLC(size);
    										TPtr8 BDPointer(bufferDes->Des());
    										User::LeaveIfError(file.Read(BDPointer, size));
    										User::LeaveIfError(toFile.Write(BDPointer,size));
    										toFile.Flush();
    										toFile.Close();
    										
    										iFilePaths->AppendL(copyfileName);
    										
    									}
    									else
    									{
    
    									}
    									file.Close();
    									iSession.Close();
    									CleanupStack::Pop();//bufferDes
    
    								}
    							}
    							CleanupStack::PopAndDestroy(store);
    						}
    					}
    				}
    				CleanupStack::PopAndDestroy(2);
    			}				
    			CleanupStack::PopAndDestroy(2);
    		}

  7. #7
    Registered User
    Join Date
    Nov 2004
    Posts
    12

    Unhappy Re: How to get attachment without AllFiles

    Has anyone had any problems reading JPEG or SMIL attachments? I can get a file handle to most attachments using the code below however JPEG and SMIL files always return a file size of 0!

    Could this be related to capabilities?

    CMsvStore* store = child->ReadStoreL();
    if(store!= NULL)
    {

    CleanupStack::PushL(store);
    MMsvAttachmentManager& attManager = store->AttachmentManagerL();

    // Cycle through the attachments
    for(TInt i=0; i<attManager.AttachmentCount(); i++)
    {
    CMsvAttachment* attachment = attManager.GetAttachmentInfoL(i);
    CleanupStack::PushL(attachment);

    // get attachment's type, and test if it's of a file type
    CMsvAttachment::TMsvAttachmentType attachType = attachment->Type();
    TBool fileTypeAttachment =
    (attachType == CMsvAttachment::EMsvFile
    || attachType == CMsvAttachment::EMsvLinkedFile);

    // File attachment
    if(fileTypeAttachment)
    {
    TInt nAttSize = attachment->Size();

    if(nAttSize > 0)
    {
    RFile file = attManager.GetAttachmentFileL(i);

    // Create a buffer to store attachment data
    HBufC8* buf8 = HBufC8::NewL(nAttSize);

    // Get a pointer to buffer
    TPtr8 pBuf8 = buf8->Des();

    // Read data into buffer
    file.Read(pBuf8, nAttSize);

    // DO SOMETHING WITH DATA ………


    // cleanup
    delete buf8;

    // Close file handle
    file.Close();
    }
    }
    CleanupStack::PopAndDestroy(attachment);

    }

    CleanupStack::PopAndDestroy(store);

    }

    Any ideas?

Similar Threads

  1. send email with attachment by CSmtpClientMtm
    By sam_jason in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2005-05-14, 10:05
  2. MMS attachment
    By Utk in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2004-12-16, 12:03
  3. How to send MMS with multiple attachment ?
    By Lebihen in forum Symbian
    Replies: 2
    Last Post: 2004-08-18, 15:58
  4. MMS Attachment
    By jdev in forum General Messaging
    Replies: 1
    Last Post: 2002-10-02, 11:38
  5. open email attachment in Series60?
    By bcchong in forum Symbian
    Replies: 0
    Last Post: 2002-07-09, 00:11

Posting Permissions

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