js/camera/com.nokia.device.camera.js
changeset 0 54063d8b0412
equal deleted inserted replaced
-1:000000000000 0:54063d8b0412
       
     1 /*
       
     2 Copyright © 2009 Nokia. All rights reserved.
       
     3 Code licensed under the BSD License:
       
     4 Software License Agreement (BSD License) Copyright © 2009 Nokia.
       
     5 All rights reserved.
       
     6 Redistribution and use of this software in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
       
     7 
       
     8 Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 
       
     9 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 
       
    10 Neither the name of Nokia Corporation. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission of Nokia Corporation. 
       
    11 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
       
    12 
       
    13 version: 1.0
       
    14 */
       
    15 
       
    16 
       
    17 // Camera service interface
       
    18 
       
    19 var __device_camera_service_entry =  {"name": null, 
       
    20 					 "version": null,
       
    21 					 "proto": __device_camera,
       
    22 					 "descriptor": __device_camera_descriptor,
       
    23 					 "providers": [{"descriptor": __sp_camera_descriptor, "instance": __sp_camera_instance}]
       
    24 					};
       
    25 
       
    26 function __device_camera_descriptor(provider){
       
    27   this.interfaceName = provider.interfaceName;
       
    28   this.version = provider.version;
       
    29 }
       
    30 
       
    31 
       
    32 // Private camera  prototype: called from service factory
       
    33 function __device_camera(provider){
       
    34   //Private properties
       
    35   this.provider = provider;
       
    36   //Read-only properties
       
    37   this.interfaceName = provider.descriptor.interfaceName;
       
    38   this.version = provider.descriptor.version;
       
    39  // this.supportedMediaTypes = provider.supportedMediaTypes;
       
    40  // this.supportedSizes = provider.supportedSizes;
       
    41   //Core methods
       
    42   this.startCamera = __device_camera_startCamera;
       
    43   this.stopViewfinder = __device_camera_stopViewfinder;
       
    44   //Extended methods
       
    45   this.takePicture = __device_camera_takePicture;
       
    46 }
       
    47 
       
    48 
       
    49 //Why bother to define these methods? Because the camera
       
    50 //object defines the contract for providers!
       
    51 
       
    52 function __device_camera_startCamera(camera_cb){
       
    53   return this.provider.startCamera(camera_cb);
       
    54 }
       
    55 
       
    56 function __device_camera_stopViewfinder(){
       
    57   this.provider.stopViewfinder();
       
    58 }
       
    59 
       
    60 function __device_camera_takePicture(format){
       
    61   this.provider.takePicture(format);
       
    62 }