Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
AdrianQuartx
Posts: 105
Registered: ‎09-06-2013
My Device: Z10

Get email attachment download status (without activating download), is there a IsDownloaded method?

As above, is there a way to check if email attachment has been downloaded? I do not want to download it if it hasnt been downloaded yet. 

Currently the Attachment.data downloads the attachment if it has not been downloaded yet.

I know there is a downloadstatus signal, but that is used when the download has been initiated.

 

There is a AttachmentDownloadStatus class, so is there a way to get that status without forcing the download?

Please use plain text.
Retired
mwoolley
Posts: 571
Registered: ‎06-25-2010
My Device: Z10
My Carrier: Vodafone

Re: Get email attachment download status (without activating download), is there a IsDownloaded method?

The Message->attachments() method will give you a list of Attachment objects without downloading them.

 

See http://developer.blackberry.com/native/reference/cascades/bb__pim__message__message.html#function-at...

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
Please use plain text.
Developer
AdrianQuartx
Posts: 105
Registered: ‎09-06-2013
My Device: Z10

Re: Get email attachment download status (without activating download), is there a IsDownloaded method?

I need to know if they have been downloaded or not, if downloaded, backup them, if not ignore

Please use plain text.
Retired
mwoolley
Posts: 571
Registered: ‎06-25-2010
My Device: Z10
My Carrier: Vodafone

Re: Get email attachment download status (without activating download), is there a IsDownloaded method?

OK

 

There are signals emited when an attachment is downloaded or its status changes.

 

http://developer.blackberry.com/native/reference/cascades/bb__pim__message__messageservice.html#func...

 

The use of AttachmentDownloadStatus is not at all clear from the documentation so let me look into that and report back.

 

Regards

 

Martin

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
Please use plain text.
Retired
mwoolley
Posts: 571
Registered: ‎06-25-2010
My Device: Z10
My Carrier: Vodafone

Re: Get email attachment download status (without activating download), is there a IsDownloaded method?

OK, the only way to establish the status of an Attachment is via the signals in the MessageService class. You can see percentage downloaded is a parameter to the attachmentDownloadStatusChanged signal for example.

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
Please use plain text.
Developer
AdrianQuartx
Posts: 105
Registered: ‎09-06-2013
My Device: Z10

Re: Get email attachment download status (without activating download), is there a IsDownloaded method?

I found two ways of retrieving attachments

1. Using Message::attachments()

 

Returns QList<Attachment>

This method retrieves attachments for the message.

Only way to check downloaded status is through downloaded signal, but i want to check if message has been downloaded without activating download.

 

None existent IsDownloaded method

 

2. Using MessageService::attachments()

 

Returns QList<FileAttachment>

This method retrieves attachments for all messages in current conversation.

 

calling FileAttachment::downloadPath will return empty QURL if attachment has not been downloaded and thus can be used as a way for me to check if attachment has been downloaded without activating download.

 

However, as all attachments for conversation is retrieved, I would have to loop through all attachments and check messageid before saving them, my thoughts are would there be a performance hit if conversation has many attachments? The is a filter when using MessageService::attachments but no filter for messageID.

Seems like the 2 classes are more or less the same but just the scope of retrieving attachments and some methods. Any advice?

Please use plain text.
Retired
mwoolley
Posts: 571
Registered: ‎06-25-2010
My Device: Z10
My Carrier: Vodafone

Re: Get email attachment download status (without activating download), is there a IsDownloaded method?

I don't imagine performance would be a significant issue but the only way to be sure is to test with real data so I suggest you do just that.

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
Please use plain text.
Developer
AdrianQuartx
Posts: 105
Registered: ‎09-06-2013
My Device: Z10

Re: Get email attachment download status (without activating download), is there a IsDownloaded method?

i found the availableSize and totalSize methods for the Attachment class,

 

the docs say it is used to see if attachment has been downloaded, therefore I do a check for

 

if (attachment.availableSize == attachment.totalSize)

 to see if attachment has been downloaded. Currently waiting for device to test (again haha)

Please use plain text.