From callback-dev-return-6109-apmail-incubator-callback-dev-archive=incubator.apache.org@incubator.apache.org Tue May 1 21:13:12 2012 Return-Path: X-Original-To: apmail-incubator-callback-dev-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 97B669DE8 for ; Tue, 1 May 2012 21:13:12 +0000 (UTC) Received: (qmail 72837 invoked by uid 500); 1 May 2012 21:13:12 -0000 Delivered-To: apmail-incubator-callback-dev-archive@incubator.apache.org Received: (qmail 72811 invoked by uid 500); 1 May 2012 21:13:12 -0000 Mailing-List: contact callback-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-dev@incubator.apache.org Received: (qmail 72803 invoked by uid 99); 1 May 2012 21:13:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 May 2012 21:13:12 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 May 2012 21:13:11 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 201B142A6A6 for ; Tue, 1 May 2012 21:12:51 +0000 (UTC) Date: Tue, 1 May 2012 21:12:51 +0000 (UTC) From: "Wayne Fisher (JIRA)" To: callback-dev@incubator.apache.org Message-ID: <819131185.14779.1335906771132.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <765708602.14529.1335904975474.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Commented] (CB-621) camera.getPicture() calls both the success and error callbacks when a picture is taken. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/CB-621?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13266109#comment-13266109 ] Wayne Fisher commented on CB-621: --------------------------------- To be honest, my code is more similar to the following. I moved the local callback functions within the if() in the code above to bring them closer the takePicture() call. But the Javascript strict mode didn't like that... {code} cameraAPI = { execute: function (webWorksResult, action, args, win, fail) { var pictureTaken = false; function success( picture ) { pictureTaken = true; win( picture ); } function cameraClose() { if( !pictureTaken ) { fail( "User canceled operation." ); } } if (action === 'takePicture') { blackberry.media.camera.takePicture(success, cameraClose, fail); return retAsyncCall(); } else { return retInvalidAction(); } } }, {code} > camera.getPicture() calls both the success and error callbacks when a picture is taken. > --------------------------------------------------------------------------------------- > > Key: CB-621 > URL: https://issues.apache.org/jira/browse/CB-621 > Project: Apache Callback > Issue Type: Bug > Components: BlackBerry > Affects Versions: 1.4.0, 1.7.0 > Environment: BlackBerry PlayBook v2.0. > Reporter: Wayne Fisher > > Testing on a 2.0 Playbook, I saw both of my callbacks (success and error) called when a picture was successfully taken and returned to my app. > The problem appears to be here: > {code} > cameraAPI = { > execute: function (webWorksResult, action, args, win, fail) { > if (action === 'takePicture') { > blackberry.media.camera.takePicture(win, fail, fail); > return retAsyncCall(); > } > else { > return retInvalidAction(); > } > } > }, > {code} > The second parameter to WebWorks takePicture() is defined to be "onCameraClosed". It appears that onCameraClosed is called after the onCaptured (the first parameter) callback is called. > I was able to achieve the documented behaviour for camera.getPicture() by modifying the above code to the following: > {code} > cameraAPI = { > execute: function (webWorksResult, action, args, win, fail) { > var pictureTaken = false; > if (action === 'takePicture') { > function success( picture ) { > pictureTaken = true; > win( picture ); > } > function cameraClose() { > if( !pictureTaken ) { > fail( "User canceled operation." ); > } > } > blackberry.media.camera.takePicture(success, cameraClose, fail); > return retAsyncCall(); > } > else { > return retInvalidAction(); > } > } > }, > {code} > I would expect that this issue also affects the use of the takePicture method as used in the Media APIs. > I tested with PhoneGap v1.4.0. The code example from above is from v1.7.0rc1 which is implemented virtually the same as v1.4.0. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira