×

Discussion Board

Results 1 to 14 of 14
  1. #1
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    102

    keep image from an incoming mms

    Hi to all,

    I would like to know how can I keep an image from mms.
    At this moment I'm able to understand when an mms entry.
    Thanks a lot.

  2. #2
    Registered User
    Join Date
    Jan 2004
    Location
    The surburbs of Bangkok, Thailand
    Posts
    135

    Re: keep image from an incoming mms

    Greetings,

    Here's a code snippet I adjusted a bit from one of my apps for you - you could probably simply change it to search for what you want and copy its contents to where you want...

    Code:
    if(aEntry.Complete())
    {
    
    if ( aEntry.iMtm == KUidMsgTypeMultimedia )
    	{		   		            	   				       			
    		
    	TBuf<24> aAddress;		   		            	   								
    
    	iMmsClientMtm->SwitchCurrentEntryL(aMsvEntrySelection->At(i));            	   										
    	iMmsClientMtm->LoadMessageL();				   		            	   		   					
    	aAddress = iMmsClientMtm->Sender();
    	
    	RArray<TAttachmentInfo> attachments;							   		            	   		   	
    	CleanupClosePushL(attachments);
    																		
    	CMsvStore* store = iMmsClientMtm->Entry().ReadStoreL();
    	CleanupStack::PushL(store);
    	
    	MMsvAttachmentManager& attmanager = store->AttachmentManagerL();
    	
    					
    	
    	
    																					
    	for(TInt j(0); j < attmanager.AttachmentCount() ; j++)
    	{
    		CMsvAttachment* attinfo = attmanager.GetAttachmentInfoL(j);
    		CleanupStack::PushL(attinfo);
    		
    		attachments.Append(TAttachmentInfo(attinfo->AttachmentName(),attinfo->Size()));
    	  
    		_LIT(KJpgAttachmentExt,"jpg");
    		if(KTxtAttachmentExt() == attinfo->AttachmentName().Right(3)) //probably better to make a copy of both and lowercase() them before compare
    		{
    		
    			RFile rf = attmanager.GetAttachmentFileL(j);   		  				    
    																						
    			CleanupClosePushL(rf);		
    			
    			//copy the file contents to the new file you want to store
    			
    			CleanupStack::PopAndDestroy();//rf
    		}
    		
    		CleanupStack::PopAndDestroy(attinfo);
    	}					
    		
    	CleanupStack::PopAndDestroy(store);																				
    	
    	attachments.Reset();
    	CleanupStack::PopAndDestroy();//attachments
    	}															
    }
    Liberate yourself from the enslavement of World Monopoly!

  3. #3
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    102

    Re: keep image from an incoming mms

    Code:
    RArray<TAttachmentInfo> attachments;
    Compiler say me that TAttachmentInfo is an undefined type. I had searched that type but i idn't find nothig about it.
    What can i do?

    Thanks

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

    Re: keep image from an incoming mms

    Based on the line
    Quote Originally Posted by ykasidit
    attachments.Append(TAttachmentInfo(attinfo->AttachmentName(),attinfo->Size()));
    TAttachmentInfo seems to be a simple value type storing a descriptor and a number. So you can remove that line (and the Append one), and concentrate on CMsvAttachment.

  5. #5
    Registered User
    Join Date
    Jan 2004
    Location
    The surburbs of Bangkok, Thailand
    Posts
    135

    Re: keep image from an incoming mms

    Greetings,

    I'm really sorry for including my own type/class there... forgot to take it out.

    It was used for the purpose that an app needed to keep the attachment file name and size (and a reference of the array reported to an observer somewhere) for a purpose not related to this "copy file" purpose, exactly as wizard_hu stated, please remove the RArray.


    Best Regards,
    Chad.
    Last edited by ykasidit; 2008-09-08 at 23:13.
    Liberate yourself from the enslavement of World Monopoly!

  6. #6
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    102

    Re: keep image from an incoming mms

    Then what can i do to keep an image from an mms entry?
    Sorry but i'm a newer of symbian c++.

  7. #7
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,684

    Re: keep image from an incoming mms

    Quote Originally Posted by earendil View Post
    Then what can i do to keep an image from an mms entry?
    Copy the file as suggested in the code comments, and remove the does-not-compile lines as suggested in the posts
    Sorry but i'm a newer of symbian c++.
    That is not a problem, keep learning.

  8. #8
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    102

    Re: keep image from an incoming mms

    I foud this solution:
    Code:
    //String where i put the path of the image
    TBuf<512> myPathFile;
    
    //Recovering the path of my attachment
    myPathFile=attachment->FilePath();
    
    //Destination folder of my new image (copy of original sent by MMS)
    _LIT(newFile, "c:\\prova\\");
    					            
    RFs lSess;
    
    User::LeaveIfError(lSess.Connect());
    
    CFileMan* lFlMan = CFileMan::NewL(lSess);
    
    //Check if file exists
    if ((BaflUtils::FileExists(lSess,myPathFile)))
    	{
    	User::LeaveIfError(lFlMan->Copy(myPathFile,newFile));
    	}
    	
    delete lFlMan;
    lFlMan = NULL;
    lSess.Close();
    Thanks a lot to all
    Last edited by earendil; 2008-09-10 at 18:34.

  9. #9
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    102

    Re: keep image from an incoming mms

    I think that this method will be useless in a real phone. What is the object that keep me directly image of mms?
    Thanks.

  10. #10
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,684

    Re: keep image from an incoming mms

    Yes, I was a bit surprised about that solution.
    MMsvAttachmentManager::GetAttachmentFileL seems to be what you need.

  11. #11
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    102

    Re: keep image from an incoming mms

    Yessssssssssssssss!!!!!!!!!!

    I've arrived at the end!!!

    I post my code:

    Code:
    CMsvAttachment* attachment = attManager.GetAttachmentInfoL(i); 			
    					        
    TInt lunghezza=attachment->FilePath().Length();
    					            
    RFile file=attManager.GetAttachmentFileL(i); 			
    					            
    HBufC* myPathFile=HBufC::NewLC(lunghezza); 				
    *myPathFile=attachment->FilePath();						
    					            
    TInt lunghezzanome;									
    lunghezzanome=attachment->AttachmentName().Length();	
    					            
    HBufC* veroNome=HBufC::NewLC(lunghezzanome);			
    *veroNome=attachment->AttachmentName();					
    					            
    TInt size; 
    file.Size(size); //Mi salvo la grandezza del file
    
    TFileName copyFileName;
    copyFileName.Copy(_L("C:\\Prova\\"));
    copyFileName.Append(*veroNome);
    //---------------------------------------------------
    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();
    	}
    file.Close();
    iSession.Close();
    With this snipet code we're able to catch all file arrived from MMS.

    Thanks for your support

    Bye Bye...

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

    Re: keep image from an incoming mms

    Hi to all,
    i have a little question: when i use the method GetAttachmentInfoL (like in the earendil's example), have i to use the RemoveAttachmentL() for remove the attachment?
    Sorry, i'm a new user of symbian.c++
    Thank you very much

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

    Re: keep image from an incoming mms

    It highly depends on what you actually want to do
    - if your task is to delete an MMS, I would expect that deleting the main message entry also removes the attachments, but that should be tested
    - if you want to simply read the attachments, I think you should not delete them...
    - if you really want to delete a particular attachment, that is the case when you surely need RemoveAttachmentL

  14. #14
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    102

    Re: keep image from an incoming mms

    I've the same problem, but i don't understand why. When I've finished to copy file I close the attachment file the new file and I closed the connection with RFs. But if I go to delete mms in message inbox os respond me that the resource is in use.
    What can I do?
    Thanks.

Similar Threads

  1. Sending image from phone gallery via mms
    By meghaarya in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2008-04-15, 06:15
  2. Nokia Image Converter
    By davidpurdie in forum General Development Questions
    Replies: 0
    Last Post: 2004-02-18, 15:31
  3. Recommended Sizes for MMS Image, Text and Layout
    By sguthery in forum General Messaging
    Replies: 3
    Last Post: 2003-08-22, 09:10
  4. Image size for MMS phones
    By ravishankarbose in forum General Messaging
    Replies: 1
    Last Post: 2002-08-20, 05:56
  5. encoding of image size on mms header
    By pautamo in forum General Messaging
    Replies: 1
    Last Post: 2002-08-15, 11:55

Posting Permissions

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