From: Tomasz Marciniak Date: Wed, 4 Feb 2015 07:38:24 +0000 (+0100) Subject: [Messaging] Show file path if attachment is loaded. X-Git-Tag: submit/tizen_tv/20150603.064601~1^2~488 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8c17f6dbda76da7fbb47a04ade6a76dc98ecd44b;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Messaging] Show file path if attachment is loaded. [Verification] Code compiles without errors. Change-Id: Iac52889c500de47e1fb6067492f2ddf11b9177e9 Signed-off-by: Tomasz Marciniak --- diff --git a/src/messaging/messaging_api.js b/src/messaging/messaging_api.js index d2a4927d..be6af161 100644 --- a/src/messaging/messaging_api.js +++ b/src/messaging/messaging_api.js @@ -584,6 +584,8 @@ function MessageBody(data) { ); }; +var messageAttachmentsLoaded = {}; + function MessageAttachment(first, second) { validator_.isConstructorCall(this, MessageAttachment); if (!this instanceof MessageAttachment) { @@ -639,7 +641,13 @@ function MessageAttachment(first, second) { this, 'filePath', { - get: function () {return _internal.filePath;}, + get: function () { + if (_internal.id && !messageAttachmentsLoaded[_internal.id]) { + return null; + } + + return _internal.filePath; + }, set: function (value) { if (value instanceof InternalValues_) _internal.filePath = value.filePath; }, @@ -783,6 +791,11 @@ MessageService.prototype.loadMessageAttachment = function () { ]); var self = this; + var firstCall = false; + if (!messageAttachmentsLoaded[args.attachment.id]) { + firstCall = true; + messageAttachmentsLoaded[args.attachment.id] = true; + } bridge.async({ cmd: 'MessageService_loadMessageAttachment', @@ -793,13 +806,21 @@ MessageService.prototype.loadMessageAttachment = function () { }).then({ success: function (data) { if (args.successCallback) { + var messageAttachment = data.messageAttachment; + if (messageAttachment) { + updateInternal_(args.attachment, messageAttachment); + } + args.successCallback.call( null, - new MessageAttachment(new InternalValues_(data.messageAttachment)) + args.attachment ); } }, error: function (e) { + if (firstCall) { + messageAttachmentsLoaded[args.attachment.id] = false; + } if (args.errorCallback) { args.errorCallback.call( null, @@ -931,6 +952,12 @@ MessageStorage.prototype.addDraftMessage = function () { updateInternal_(args.message.body, body) delete message.body; } + var attachments = message.attachments; + if (attachments) { + for (var i = 0; i < attachments.length; i++) { + messageAttachmentsLoaded[attachments[i].id] = true; + } + } updateInternal_(args.message, message); } @@ -1483,4 +1510,4 @@ tizen.Message = Message; tizen.MessageAttachment = MessageAttachment; -exports = new Messaging(); +exports = new Messaging(); \ No newline at end of file